mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-12 10:15:31 +00:00
* feat(channels): add dmPolicy config to disable private/DM messages Add DmGate class mirroring GroupGate to gate DM/private messages in channel adapters. Operators can now set dmPolicy: 'disabled' in their channel config to silently drop all DM messages while keeping group messages active. Closes #6392 * fix(channels): address review feedback for dmPolicy - Add dmPolicy: 'open' to all test config factories (8 files) to maintain type correctness with required ChannelConfig field - Add integration tests in ChannelBase.test.ts: - preflightInbound: DM dropped + group passes when dmPolicy=disabled - isStoredLoopTargetAuthorized: DM loop job disabled + group passes - Add dmPolicy assertions in config-utils.test.ts (default + explicit) - Keep dmPolicy as required field (not optional) for strict parity with groupPolicy
88 lines
3.8 KiB
Markdown
88 lines
3.8 KiB
Markdown
# Custom Channel Plugins
|
|
|
|
You can extend the channel system with custom platform adapters packaged as [extensions](../../extension/introduction). This lets you connect Qwen Code to any messaging platform, webhook, or custom transport.
|
|
|
|
## How It Works
|
|
|
|
Channel plugins are loaded at startup from active extensions. When `qwen channel start` runs, it:
|
|
|
|
1. Scans all enabled extensions for `channels` entries in their `qwen-extension.json`
|
|
2. Dynamically imports each channel's entry point
|
|
3. Registers the channel type so it can be referenced in `settings.json`
|
|
4. Creates channel instances using the plugin's factory function
|
|
|
|
Your custom channel gets the full shared pipeline for free: sender gating, group policies, session routing, slash commands, crash recovery, and an agent bridge. Standalone `qwen channel start` currently supplies `AcpBridge`; plugin adapter code should depend on the adapter-facing `ChannelAgentBridge` contract. Existing TypeScript plugins with an explicit `AcpBridge` bridge parameter should migrate that annotation to `ChannelAgentBridge`; JavaScript plugins are unaffected at runtime.
|
|
|
|
## Installing a Custom Channel
|
|
|
|
Install an extension that provides a channel plugin:
|
|
|
|
```bash
|
|
# From a local path (for development or private plugins)
|
|
qwen extensions install /path/to/my-channel-extension
|
|
|
|
# Or link it for development (changes are reflected immediately)
|
|
qwen extensions link /path/to/my-channel-extension
|
|
```
|
|
|
|
## Configuring a Custom Channel
|
|
|
|
Add a channel entry to `~/.qwen/settings.json` using the custom type provided by the extension:
|
|
|
|
```json
|
|
{
|
|
"channels": {
|
|
"my-bot": {
|
|
"type": "my-platform",
|
|
"apiKey": "$MY_PLATFORM_API_KEY",
|
|
"senderPolicy": "open",
|
|
"cwd": "/path/to/project"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
The `type` must match a channel type registered by an installed extension. Check the extension's documentation for which plugin-specific fields are required (e.g., `apiKey`, `webhookUrl`).
|
|
|
|
All standard channel options work with custom channels:
|
|
|
|
| Option | Description |
|
|
| -------------- | ---------------------------------------------- |
|
|
| `senderPolicy` | `allowlist`, `pairing`, or `open` |
|
|
| `allowedUsers` | Static allowlist of sender IDs |
|
|
| `sessionScope` | `user`, `thread`, or `single` |
|
|
| `cwd` | Working directory for the agent |
|
|
| `instructions` | Prepended to the first message of each session |
|
|
| `model` | Model override for the channel |
|
|
| `groupPolicy` | `disabled`, `allowlist`, or `open` |
|
|
| `dmPolicy` | `open` or `disabled` |
|
|
| `groups` | Per-group settings |
|
|
|
|
See [Overview](./overview) for details on each option.
|
|
|
|
## Starting the Channel
|
|
|
|
```bash
|
|
# Start all channels including custom ones
|
|
qwen channel start
|
|
|
|
# Start just your custom channel
|
|
qwen channel start my-bot
|
|
```
|
|
|
|
## What You Get for Free
|
|
|
|
Custom channels automatically support everything built-in channels do:
|
|
|
|
- **Sender policies** — `allowlist`, `pairing`, and `open` access control
|
|
- **Group policies** — Per-group settings with optional @mention gating
|
|
- **Session routing** — Per-user, per-thread, or single shared sessions
|
|
- **DM pairing** — Full pairing code flow for unknown users
|
|
- **Slash commands** — `/help`, `/clear`, `/status` work out of the box
|
|
- **Custom instructions** — Prepended to the first message in each session
|
|
- **Crash recovery** — Automatic restart with session preservation
|
|
- **Per-session serialization** — Messages are queued to prevent race conditions
|
|
|
|
## Building Your Own Channel Plugin
|
|
|
|
Want to build a channel plugin for a new platform? See the [Channel Plugin Developer Guide](../../../developers/channel-plugins.md) for the `ChannelPlugin` interface, the `Envelope` format, and extension points.
|