diff --git a/README.md b/README.md index deef033..c00f77e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ type Plugin interface { | 分类 | 方法 | 说明 | |------|------|------| | 阶段钩子 | `RegisterStage(stage, handler, scope...)` | 注册阶段回调,scope 可选:`StageScopeGlobal`(全局,默认)或 `StageScopeOwnTools`(仅自己工具) | -| 输出通道 | `RegisterOutputChannel(name, caps, desc, handler)` | 注册输出通道,caps 为能力位掩码 | +| 输入通道 | `RegisterInputChannel(name, def)` | 注册输入通道,def 为 `ChannelDef`(NoMemory/Cleaner) | +| 输出通道 | `RegisterOutputChannel(name, caps, desc, def, handler)` | 注册输出通道,def 为 `ChannelDef`,caps 为能力位掩码 | | 工具注册 | `RegisterTool(name, def, handler)` | 注册工具供 LLM 调用 | | 插件 API | `RegisterPluginAPI(name)` | 注册插件 API 供其他插件访问 | | 图记忆 | `Memory()` | 访问图记忆 API(实体-关系存储) | @@ -47,10 +48,30 @@ sdk.RegisterStage(StagePreAction, func(ctx *StageContext) error { return nil }) sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools) ``` +### ChannelDef + +```go +type ChannelDef struct { + NoMemory bool // 通道输入/输出不参与记忆计算(向量/关键词/蒸馏),原文保留 + Cleaner func(string) string // 可选:计算层过滤函数(不改原文) +} +``` + +`ChannelDef` 控制通道在记忆计算层的行为,与 `ToolDef` 的 `NoMemory`/`Cleaner` 语义一致。 + +### 输入通道 + +```go +sdk.RegisterInputChannel("qq", ChannelDef{ + NoMemory: true, + Cleaner: func(text string) string { return strings.TrimSpace(text) }, +}) +``` + ### 输出通道 ```go -sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "通道描述", handler) +sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "通道描述", ChannelDef{}, handler) ``` handler 接收三个参数: diff --git a/README_EN.md b/README_EN.md index bf27904..4995aaa 100644 --- a/README_EN.md +++ b/README_EN.md @@ -23,7 +23,8 @@ The SDK instance injected via `Start(sdk *PluginSDK)` provides: | Category | Method | Description | |----------|--------|-------------| | Stage Hooks | `RegisterStage(stage, handler, scope...)` | Register stage callback; scope: `StageScopeGlobal` (all, default) or `StageScopeOwnTools` (own tools only) | -| Output Channel | `RegisterOutputChannel(name, caps, desc, handler)` | Register output channel with capability bitmask | +| Input Channel | `RegisterInputChannel(name, def)` | Register input channel with `ChannelDef` (NoMemory/Cleaner) | +| Output Channel | `RegisterOutputChannel(name, caps, desc, def, handler)` | Register output channel with `ChannelDef` and capability bitmask | | Tool Registration | `RegisterTool(name, def, handler)` | Register a tool for LLM invocation | | Plugin API | `RegisterPluginAPI(name)` | Register plugin API for inter-plugin access | | Graph Memory | `Memory()` | Access graph memory API (entity-relation store) | @@ -47,10 +48,30 @@ sdk.RegisterStage(StagePreAction, func(ctx *StageContext) error { return nil }) sdk.RegisterStage(StageBeforeToolcall, myHandler, StageScopeOwnTools) ``` +### ChannelDef + +```go +type ChannelDef struct { + NoMemory bool // Channel input/output skips memory computation (vector/keyword/distill), original text preserved + Cleaner func(string) string // Optional: computation layer filter (does not modify original text) +} +``` + +`ChannelDef` controls channel behavior in the memory computation layer, with the same semantics as `ToolDef.NoMemory`/`Cleaner`. + +### Input Channels + +```go +sdk.RegisterInputChannel("qq", ChannelDef{ + NoMemory: true, + Cleaner: func(text string) string { return strings.TrimSpace(text) }, +}) +``` + ### Output Channels ```go -sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "channel description", handler) +sdk.RegisterOutputChannel("my-channel", CapText|CapFile, "channel description", ChannelDef{}, handler) ``` The handler receives three arguments: