tools: plugindev 工具链支持公共 IOInjector.InjectInputSync(CORE_INJECT_INPUT_SYNC=47,z_bridge dispatchIO 桥接),重建 bin 预编译二进制;example/memo: plg.json 修复(name_en 去斜杠、去 BOM);sdk/plugin.go 注释精简

This commit is contained in:
root
2026-08-02 16:24:59 +08:00
parent 8e5610c494
commit b6e30f9279
4 changed files with 12 additions and 10 deletions

Binary file not shown.

View File

@ -1,9 +1,9 @@
{ {
"name": "memo", "name": "memo",
"name_zh": "备忘录", "name_zh": "备忘录",
"name_en": "Memo/Notes", "name_en": "Memo",
"version": "1.0.0", "version": "1.0.0",
"description": "待办事项与备忘录管理插件。支持创建、完成、列表查看。通过阶段钩子在每次对话前注入待办提醒。", "description": "待办与备忘录插件。待办todo_add/todo_complete/todo_list会主动提醒备忘录memo_create/memo_list/memo_delete纯记事不提醒。",
"author": "HomeAgent", "author": "HomeAgent",
"entry": "plugin.so", "entry": "plugin.so",
"tags": ["memo", "todo", "notes"], "tags": ["memo", "todo", "notes"],

View File

@ -111,8 +111,8 @@ type IOInjector interface {
InjectInterruptText(source, channel, text string) InjectInterruptText(source, channel, text string)
InjectText(source, channel, text string) InjectText(source, channel, text string)
InjectTextNoMemory(source, channel, text string) InjectTextNoMemory(source, channel, text string)
// InjectInputSync injects a text message and synchronously waits for the agent // InjectInputSync 注入输入事件并同步等待 agent 回复,返回回复文本(无回复时返回空串)。
// reply, returning the reply text (empty string if no reply). // 用于通道消息的完整闭环:收到入站 → agent 处理 → 回复取回 → 送回通道。
InjectInputSync(source, channel, text string) string 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, // 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 // returning the reply text (empty string if none). Replies must be dispatched back
// (e.g. channel plugins forwarding messages and sending the agent's reply back). // to the source channel by the caller.
func (s *PluginSDK) InjectInputSync(source, channel, text string) string { func (s *PluginSDK) InjectInputSync(source, channel, text string) string {
if s.io != nil { if s.io == nil {
return s.io.InjectInputSync(source, channel, text)
}
return "" return ""
}
return s.io.InjectInputSync(source, channel, text)
} }
// SetAutoRestart 设置插件是否允许内核自动重启(崩溃后自动重载)。 // SetAutoRestart 设置插件是否允许内核自动重启(崩溃后自动重载)。

View File

@ -365,6 +365,7 @@ enum {
CORE_INJECT_TEXT = 5, CORE_INJECT_TEXT = 5,
CORE_INJECT_INTERRUPT_TEXT = 6, CORE_INJECT_INTERRUPT_TEXT = 6,
CORE_INJECT_TEXT_NO_MEMORY = 7, CORE_INJECT_TEXT_NO_MEMORY = 7,
CORE_INJECT_INPUT_SYNC = 47,
CORE_SET_AUTO_RESTART = 8, CORE_SET_AUTO_RESTART = 8,
CORE_MEMORY_RECALL = 9, CORE_MEMORY_RECALL = 9,
CORE_MEMORY_COMMIT = 10, 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) 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) 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) 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{} type dispatchMemory struct{}
func (dispatchMemory) Recall(q []string, d int) ([]sdk.Entity, []sdk.Relation, error) { func (dispatchMemory) Recall(q []string, d int) ([]sdk.Entity, []sdk.Relation, error) {