From 17963956682fe41614e3f0e682e939c8e94c4428 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 Aug 2026 15:30:22 +0800 Subject: [PATCH] =?UTF-8?q?sdk:=20=E5=85=AC=E5=85=B1=20IOInjector=20?= =?UTF-8?q?=E8=A1=A5=20InjectInputSync=EF=BC=88=E5=90=8C=E6=AD=A5=E6=B3=A8?= =?UTF-8?q?=E5=85=A5=E5=B9=B6=E7=AD=89=E5=BE=85=E5=9B=9E=E5=A4=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与主仓 third_party/homeagent-sdk 对齐:IOInjector 接口新增 InjectInputSync(source, channel, text) string + PluginSDK 便捷方法 (通道插件请求-响应流:转发入站消息并取回 agent 回复文本) --- sdk/plugin.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sdk/plugin.go b/sdk/plugin.go index ca5e9a6..fa3a89d 100644 --- a/sdk/plugin.go +++ b/sdk/plugin.go @@ -111,6 +111,9 @@ 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(source, channel, text string) string } // EventType identifies the kind of system event. @@ -367,6 +370,16 @@ 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). +func (s *PluginSDK) InjectInputSync(source, channel, text string) string { + if s.io != nil { + return s.io.InjectInputSync(source, channel, text) + } + return "" +} + // SetAutoRestart 设置插件是否允许内核自动重启(崩溃后自动重载)。 // 默认 true。如果插件有无法恢复的状态(如外部连接),应设为 false。 func (s *PluginSDK) SetAutoRestart(enabled bool) { s.autoRestart = enabled }