From d38d42e57ff5c23e40e7e37498377cd74359804e Mon Sep 17 00:00:00 2001 From: root Date: Sun, 19 Jul 2026 10:35:25 +0800 Subject: [PATCH] docs: update output channel interface (payload/meta/type) in SDK docs --- README.md | 14 ++++++++++++++ README_EN.md | 14 ++++++++++++++ sdk/plugin.go | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index debe9be..4542962 100644 --- a/README.md +++ b/README.md @@ -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 通道路由 | 方法 | 说明 | diff --git a/README_EN.md b/README_EN.md index b5905f0..cfcb172 100644 --- a/README_EN.md +++ b/README_EN.md @@ -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 | diff --git a/sdk/plugin.go b/sdk/plugin.go index c93afa0..7663ae2 100644 --- a/sdk/plugin.go +++ b/sdk/plugin.go @@ -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)