From 719eb110784f5f5525e0bcd6f54cca06abdaa378 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 18 Jul 2026 20:48:54 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=81=A2=E5=A4=8D=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=AD=E6=96=AD=E6=8A=95=E9=80=92=20API=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PLUGIN_DEV.md 第二节保留公开 API (InjectText/InjectInterruptText/InjectTextNoMemory), 第四节新增"输入投递(内置插件)"小节展示 InjectInput/InjectInterrupt/InjectInputSync 等 内置插件专属方法,附注说明区分外部与内置插件 API 边界。 --- docs/en/PLUGIN_DEV.md | 20 ++++++++++++++++++++ docs/zh/PLUGIN_DEV.md | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/docs/en/PLUGIN_DEV.md b/docs/en/PLUGIN_DEV.md index 672a82e..4539f1b 100644 --- a/docs/en/PLUGIN_DEV.md +++ b/docs/en/PLUGIN_DEV.md @@ -349,6 +349,26 @@ s.UnregisterChannel("mydevice") channels := s.ListChannels() ``` +#### Input Delivery (built-in plugins) + +```go +// Queued delivery (processed in order) +s.InjectInput(source, channel, eventType string, payload map[string]interface{}) + +// Synchronous delivery (waits for response) +resp := s.InjectInputSync(source, channel, eventType string, payload map[string]interface{}) + +// Interrupt delivery (can preempt current LLM processing) +s.InjectInterrupt(source, channel, eventType string, payload map[string]interface{}) + +// Synchronous text shortcuts +resp := s.InjectTextSync(source, channel, text string) +resp := s.InjectTextSyncNoMemory(source, channel, text string) + +// Get output channel +outputCh := s.OutputChan() +``` + > **Note**: `Subscribe`, `Publish`, `RegisterChannel`, `UnregisterChannel`, `ListChannels`, `InjectInput`, `InjectInputSync`, `InjectInterrupt`, `InjectTextSync`, `InjectTextSyncNoMemory`, `OutputChan` are only available in built-in plugins (`internal/sdk` package). External dynamic plugins should use the public APIs: `InjectText`, `InjectInterruptText`, `InjectTextNoMemory`. --- diff --git a/docs/zh/PLUGIN_DEV.md b/docs/zh/PLUGIN_DEV.md index c4db4d8..9aeb9ae 100644 --- a/docs/zh/PLUGIN_DEV.md +++ b/docs/zh/PLUGIN_DEV.md @@ -350,6 +350,26 @@ s.UnregisterChannel("mydevice") channels := s.ListChannels() ``` +#### 输入投递(内置插件) + +```go +// 排队投递(按序处理) +s.InjectInput(source, channel, eventType string, payload map[string]interface{}) + +// 同步投递(等待响应) +resp := s.InjectInputSync(source, channel, eventType string, payload map[string]interface{}) + +// 中断投递(可打断当前 LLM 处理) +s.InjectInterrupt(source, channel, eventType string, payload map[string]interface{}) + +// 同步文本投递(快捷方式) +resp := s.InjectTextSync(source, channel, text string) +resp := s.InjectTextSyncNoMemory(source, channel, text string) + +// 获取输出通道 +outputCh := s.OutputChan() +``` + > **注意**:`Subscribe`、`Publish`、`RegisterChannel`、`UnregisterChannel`、`ListChannels`、`InjectInput`、`InjectInputSync`、`InjectInterrupt`、`InjectTextSync`、`InjectTextSyncNoMemory`、`OutputChan` 这些方法仅在内置插件中可用(`internal/sdk` 包),外部动态插件无法访问。外部插件请使用 `InjectText`、`InjectInterruptText`、`InjectTextNoMemory` 等公共 API。 ---