packages/channels/plugin-example/README.md
A reference channel plugin for Qwen Code. It connects to a WebSocket server and routes messages through the full channel pipeline (access control, session routing, agent bridge).
Use this package to:
npm install @qwen-code/channel-plugin-example
The package ships a qwen-extension.json manifest, so it works as an extension out of the box:
qwen extensions link ./node_modules/@qwen-code/channel-plugin-example
Add a channel entry to ~/.qwen/settings.json:
{
"channels": {
"my-plugin-test": {
"type": "plugin-example",
"serverWsUrl": "ws://localhost:9201",
"senderPolicy": "open",
"sessionScope": "user",
"cwd": "/path/to/your/project"
}
}
}
npx qwen-channel-plugin-example-server
The server prints the HTTP and WebSocket URLs. You can customize ports with environment variables:
HTTP_PORT=8080 WS_PORT=8081 npx qwen-channel-plugin-example-server
In a separate terminal:
qwen channel start my-plugin-test
curl -sX POST http://localhost:9200/message \
-H 'Content-Type: application/json' \
-d '{"senderId":"user1","senderName":"Tester","text":"What is 2+2?"}'
You should get a JSON response with the agent's reply.
Mock Server (HTTP + WS)
↕ WebSocket
MockPluginChannel (this package)
→ Envelope → ChannelBase.handleInbound()
→ SenderGate → SessionRouter → AcpBridge.prompt()
→ qwen-code agent → model API
← response
← sendMessage() → WebSocket → Mock Server
← HTTP response
See src/MockPluginChannel.ts for a working example. The key points:
ChannelBase and implement connect(), sendMessage(), disconnect()Envelope from incoming platform messages and call this.handleInbound(envelope)plugin object conforming to ChannelPluginqwen-extension.json manifestblockStreaming: "on" in config and the agent's response is automatically split into multiple messages at paragraph boundariesenvelope.attachments with images/files and handleInbound() routes them to the agent (images as vision input, files as paths in the prompt)onResponseChunk() for progressive display (e.g., editing a message in-place)Full guide: Channel Plugin Developer Guide