#23625: feat(plugin-sdk): Add channel development helpers and discovery metadata
docs
size: M
Cluster:
Network Error Handling Improvements
## Summary
Enhanced the Plugin SDK with simplified configuration helpers and discovery metadata support to make channel plugin development easier and enable better organization of plugins.
## Changes
### 1. Simple Configuration Schema Helpers
Added `src/channels/plugins/simple-config-helpers.ts` with helper functions:
- `buildSimpleChannelConfigSchema()` - Quick schema creation from simple options
- `buildSimpleZodChannelConfigSchema()` - Convert Zod schemas to JSON Schema
These reduce boilerplate by ~50% for simple channel configurations.
**Example**:
```typescript
import { buildSimpleChannelConfigSchema } from 'openclaw/plugin-sdk';
const schema = buildSimpleChannelConfigSchema({
accountProperties: {
apiKey: { type: 'string', description: 'API key' },
region: { type: 'string', enum: ['us', 'eu', 'asia'] }
}
});
```
### 2. Discovery Metadata Support
Enhanced `ChannelPlugin` type with optional discovery metadata:
```typescript
type ChannelDiscoveryMeta = {
category?: string; // e.g., "email", "messaging", "social"
keywords?: string[]; // Search keywords
maturity?: "stable" | "beta" | "experimental";
docsLink?: string; // Documentation URL
author?: string; // Maintainer
}
```
**Usage**:
```typescript
const plugin: ChannelPlugin = {
id: "my-channel",
meta: {
label: "My Channel",
discovery: {
category: "messaging",
keywords: ["chat", "messaging"],
maturity: "stable"
}
},
// ...
};
```
### 3. New Plugin SDK Exports
Updated `src/plugin-sdk/index.ts` to export:
- `buildSimpleChannelConfigSchema`
- `buildSimpleZodChannelConfigSchema`
- `SimpleChannelAccountConfig`
- `BuildSimpleChannelConfigSchemaOptions`
- `ChannelDiscoveryMeta`
### 4. Comprehensive Documentation
Added `docs/plugins/developing-channel-plugins.md` (616 lines) covering:
- Quick start with project structure
- Configuration schema options
- Channel adapter implementation details
- Development workflow and testing
- Distribution methods (npm, GitHub, local paths)
- Best practices and troubleshooting
- Complete code examples
## Backward Compatibility
✅ **100% backward compatible**
- All new fields are optional
- No breaking changes to existing types
- Existing channels work without any modification
- Uses TypeScript intersection types for compatibility
**Old channels continue to work unchanged**:
```typescript
// This still works perfectly - no changes needed
const slackPlugin: ChannelPlugin = {
id: "slack",
meta: {
label: "Slack",
// No discovery field required
},
capabilities: { ... },
config: { ... }
};
```
## Benefits
- **Easier Development**: ~50% less boilerplate for simple channels
- **Better Organization**: Plugin catalogs with categories and keywords
- **Flexible Configuration**: Choose between simple, Zod, or manual schemas
- **Type Safe**: Full TypeScript support throughout
- **Well Documented**: Comprehensive guide with examples
- **Zero Breaking Changes**: Existing code works unchanged
## Testing
- ✅ TypeScript compilation passes
- ✅ Build succeeds
- ✅ ESLint checks pass
- ✅ No breaking changes
- ✅ Backward compatible with all existing channels
## Files Changed
| File | Status | Lines |
|------|--------|-------|
| `src/channels/plugins/simple-config-helpers.ts` | New | +169 |
| `src/channels/plugins/types.plugin.ts` | Modified | +33 |
| `src/plugin-sdk/index.ts` | Modified | +9 |
| `docs/plugins/developing-channel-plugins.md` | New | +616 |
**Total**: 4 files, +827 lines
## Use Cases
### Simple Channel (Before)
```typescript
// Required manual schema definition
const schema = buildChannelConfigSchema(
z.object({
enabled: z.boolean().optional(),
accounts: z.record(z.object({
apiKey: z.string(),
region: z.enum(['us', 'eu'])
}))
})
);
```
### Simple Channel (After)
```typescript
// One-liner with helper
const schema = buildSimpleChannelConfigSchema({
accountProperties: {
apiKey: { type: 'string' },
region: { type: 'string', enum: ['us', 'eu'] }
}
});
```
## Related
- Enables easier creation of external channel plugins
- Supports future plugin registry/catalog features
- Improves developer experience for channel development
- No changes to existing channel loading mechanism
## Checklist
- [x] Code compiles correctly
- [x] Tests pass (existing tests unaffected)
- [x] Documentation added
- [x] Backward compatible
- [x] No breaking changes
- [x] Follows existing code patterns
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR enhances the Plugin SDK with configuration helpers and discovery metadata to simplify channel plugin development. The changes add two new helper functions (`buildSimpleChannelConfigSchema` and `buildSimpleZodChannelConfigSchema`) that reduce boilerplate configuration code, and introduce optional discovery metadata fields (`category`, `keywords`, `maturity`, `docsLink`, `author`) for better plugin organization. The implementation is fully backward compatible - all new fields are optional and use TypeScript intersection types. The PR also includes comprehensive documentation (616 lines) covering plugin development workflows. The code follows existing patterns (consistent with `buildChannelConfigSchema` in `config-schema.ts`) and properly exports the new types and functions through the Plugin SDK.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk
- The PR is well-implemented and backward compatible, but lacks unit tests for the new helper functions. The code follows existing patterns, uses TypeScript properly, and all changes are additive (optional fields only). The discovery metadata is purely informational and not consumed by any runtime code yet, reducing risk. Documentation is comprehensive. One point deducted for missing tests.
- Consider adding unit tests for `src/channels/plugins/simple-config-helpers.ts` to verify schema generation logic
<sub>Last reviewed commit: 93c0f49</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19030: feat(simplex): add SimpleX Chat channel plugin
by Bladerunner-hue · 2026-02-17
75.4%
#18966: fix(config): downgrade unknown bundled plugin references to warnings
by moxunjinmu · 2026-02-17
74.2%
#23727: Fix Telegram channel resolution drift across announce + message sen...
by SmithLabsLLC · 2026-02-22
73.5%
#9594: feat: add SimpleX messaging channel
by dangoldbj · 2026-02-05
73.5%
#17361: feat(channels): add Tuitui (推推) channel support
by haomehaode · 2026-02-15
73.2%
#21981: feat: Add email channel plugin with channelRuntime support
by guxiaobo · 2026-02-20
72.7%
#16507: feat(nostr): refactor channel dispatch logic (AI-assisted)
by tanujbhaud · 2026-02-14
72.3%
#20348: Add support for Keybase as a channel
by xgess · 2026-02-18
72.3%
#17878: Refactor: share allowlist normalization
by iyoda · 2026-02-16
71.8%
#23464: feat(synology-chat): add group/channel support
by druide67 · 2026-02-22
71.5%