diff --git a/bin/plugindev_linux_amd64 b/bin/plugindev_linux_amd64 index 5329012..51274e0 100755 Binary files a/bin/plugindev_linux_amd64 and b/bin/plugindev_linux_amd64 differ diff --git a/example/memo/plg.json b/example/memo/plg.json index 99e8c74..f100aeb 100644 --- a/example/memo/plg.json +++ b/example/memo/plg.json @@ -1,9 +1,9 @@ -{ +{ "name": "memo", "name_zh": "备忘录", - "name_en": "Memo/Notes", + "name_en": "Memo", "version": "1.0.0", - "description": "待办事项与备忘录管理插件。支持创建、完成、列表查看。通过阶段钩子在每次对话前注入待办提醒。", + "description": "待办与备忘录插件。待办(todo_add/todo_complete/todo_list)会主动提醒;备忘录(memo_create/memo_list/memo_delete)纯记事不提醒。", "author": "HomeAgent", "entry": "plugin.so", "tags": ["memo", "todo", "notes"], diff --git a/sdk/plugin.go b/sdk/plugin.go index fa3a89d..1378eaf 100644 --- a/sdk/plugin.go +++ b/sdk/plugin.go @@ -111,8 +111,8 @@ type IOInjector interface { InjectInterruptText(source, channel, text string) InjectText(source, channel, text string) InjectTextNoMemory(source, channel, text string) - // InjectInputSync injects a text message and synchronously waits for the agent - // reply, returning the reply text (empty string if no reply). + // InjectInputSync 注入输入事件并同步等待 agent 回复,返回回复文本(无回复时返回空串)。 + // 用于通道消息的完整闭环:收到入站 → agent 处理 → 回复取回 → 送回通道。 InjectInputSync(source, channel, text string) string } @@ -371,13 +371,13 @@ func (s *PluginSDK) InjectTextNoMemory(source, channel, text string) { } // InjectInputSync injects a text message and synchronously waits for the agent reply, -// returning the reply text (empty if no reply). Use it for request-response flows -// (e.g. channel plugins forwarding messages and sending the agent's reply back). +// returning the reply text (empty string if none). Replies must be dispatched back +// to the source channel by the caller. func (s *PluginSDK) InjectInputSync(source, channel, text string) string { - if s.io != nil { - return s.io.InjectInputSync(source, channel, text) + if s.io == nil { + return "" } - return "" + return s.io.InjectInputSync(source, channel, text) } // SetAutoRestart 设置插件是否允许内核自动重启(崩溃后自动重载)。 diff --git a/tools/plugindev/templates.go b/tools/plugindev/templates.go index abfdb3c..b6d667a 100644 --- a/tools/plugindev/templates.go +++ b/tools/plugindev/templates.go @@ -365,6 +365,7 @@ enum { CORE_INJECT_TEXT = 5, CORE_INJECT_INTERRUPT_TEXT = 6, CORE_INJECT_TEXT_NO_MEMORY = 7, + CORE_INJECT_INPUT_SYNC = 47, CORE_SET_AUTO_RESTART = 8, CORE_MEMORY_RECALL = 9, CORE_MEMORY_COMMIT = 10, @@ -533,6 +534,7 @@ type dispatchIO struct{} func (dispatchIO) InjectInterruptText(s, c, t string) { callVoid(6, s, c, t, 0, 0) } func (dispatchIO) InjectText(s, c, t string) { callVoid(5, s, c, t, 0, 0) } func (dispatchIO) InjectTextNoMemory(s, c, t string) { callVoid(7, s, c, t, 0, 0) } +func (dispatchIO) InjectInputSync(s, c, t string) string { r, _ := callString(47, s, c, t, 0, 0); return r } type dispatchMemory struct{} func (dispatchMemory) Recall(q []string, d int) ([]sdk.Entity, []sdk.Relation, error) {