mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-09-20 08:58:03 +00:00
docs: update output channel interface (payload/meta/type) in SDK docs
This commit is contained in:
14
README.md
14
README.md
@ -53,6 +53,11 @@ sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools)
|
|||||||
sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "通道描述", handler)
|
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 | 音频输出 |
|
| `CapAudio` | 8 | 音频输出 |
|
||||||
| `CapStructured` | 16 | 结构化数据输出 |
|
| `CapStructured` | 16 | 结构化数据输出 |
|
||||||
|
|
||||||
|
type 枚举值:
|
||||||
|
|
||||||
|
| 值 | 说明 |
|
||||||
|
|----|------|
|
||||||
|
| `text` | 纯文本 |
|
||||||
|
| `voice` / `audio` | 语音 |
|
||||||
|
| `image` | 图片 |
|
||||||
|
| `file` | 文件 |
|
||||||
|
|
||||||
### IOInjector 通道路由
|
### IOInjector 通道路由
|
||||||
|
|
||||||
| 方法 | 说明 |
|
| 方法 | 说明 |
|
||||||
|
|||||||
14
README_EN.md
14
README_EN.md
@ -53,6 +53,11 @@ sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools)
|
|||||||
sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "channel description", handler)
|
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:
|
Capability flags:
|
||||||
|
|
||||||
| Flag | Value | Description |
|
| Flag | Value | Description |
|
||||||
@ -63,6 +68,15 @@ Capability flags:
|
|||||||
| `CapAudio` | 8 | Audio output |
|
| `CapAudio` | 8 | Audio output |
|
||||||
| `CapStructured` | 16 | Structured data 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
|
### IOInjector Channel Routing
|
||||||
|
|
||||||
| Method | Description |
|
| Method | Description |
|
||||||
|
|||||||
@ -286,8 +286,8 @@ func (s *PluginSDK) RegisterPluginAPI(name string) error {
|
|||||||
// RegisterOutputChannel registers an output channel that the output_send tool can route to.
|
// RegisterOutputChannel registers an output channel that the output_send tool can route to.
|
||||||
// name: channel name (e.g. "qq", "webui")
|
// name: channel name (e.g. "qq", "webui")
|
||||||
// caps: bitmask of supported output capabilities (CapText, CapFile, etc.)
|
// caps: bitmask of supported output capabilities (CapText, CapFile, etc.)
|
||||||
// desc: description of the channel and expected JSON format for content
|
// desc: description of the channel, expected meta format, and type enum
|
||||||
// handler: receives the content (JSON string) and returns result/error
|
// 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 {
|
func (s *PluginSDK) RegisterOutputChannel(name string, caps int, desc string, handler ToolHandler) error {
|
||||||
if s.regOutput != nil {
|
if s.regOutput != nil {
|
||||||
return s.regOutput(name, caps, desc, handler)
|
return s.regOutput(name, caps, desc, handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user