docs: update output channel interface (payload/meta/type) in SDK docs

This commit is contained in:
root
2026-07-19 10:35:25 +08:00
parent bf08764c29
commit d38d42e57f
3 changed files with 30 additions and 2 deletions

View File

@ -53,6 +53,11 @@ sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools)
sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "通道描述", handler)
```
handler 接收三个参数:
- `payload` (string) — 消息载荷。`type=text` 时直接填文字,`type=file/image` 时填 URL
- `meta` (string) — 可选的 JSON 路由元数据(如 `{"group_id":123,"user_id":456}`
- `type` (string) — 载荷类型,枚举值见下
能力标志位:
| 标志 | 值 | 说明 |
@ -63,6 +68,15 @@ sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "通道描述", handler
| `CapAudio` | 8 | 音频输出 |
| `CapStructured` | 16 | 结构化数据输出 |
type 枚举值:
| 值 | 说明 |
|----|------|
| `text` | 纯文本 |
| `voice` / `audio` | 语音 |
| `image` | 图片 |
| `file` | 文件 |
### IOInjector 通道路由
| 方法 | 说明 |

View File

@ -53,6 +53,11 @@ sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools)
sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "channel description", handler)
```
The handler receives three arguments:
- `payload` (string) — message content. For `type=text` it's plain text, for `type=file/image` it's a URL
- `meta` (string) — optional JSON routing metadata (e.g. `{"group_id":123,"user_id":456}`)
- `type` (string) — content type enum (see below)
Capability flags:
| Flag | Value | Description |
@ -63,6 +68,15 @@ Capability flags:
| `CapAudio` | 8 | Audio output |
| `CapStructured` | 16 | Structured data output |
Type enum values:
| Value | Description |
|-------|-------------|
| `text` | plain text |
| `voice` / `audio` | audio/voice |
| `image` | image |
| `file` | file |
### IOInjector Channel Routing
| Method | Description |

View File

@ -286,8 +286,8 @@ func (s *PluginSDK) RegisterPluginAPI(name string) error {
// RegisterOutputChannel registers an output channel that the output_send tool can route to.
// name: channel name (e.g. "qq", "webui")
// caps: bitmask of supported output capabilities (CapText, CapFile, etc.)
// desc: description of the channel and expected JSON format for content
// handler: receives the content (JSON string) and returns result/error
// desc: description of the channel, expected meta format, and type enum
// handler: receives args map with keys: payload (string), type (string), meta (string|optional)
func (s *PluginSDK) RegisterOutputChannel(name string, caps int, desc string, handler ToolHandler) error {
if s.regOutput != nil {
return s.regOutput(name, caps, desc, handler)