sdk: 公共 IOInjector 补 InjectInputSync(同步注入并等待回复)

与主仓 third_party/homeagent-sdk 对齐:IOInjector 接口新增
InjectInputSync(source, channel, text) string + PluginSDK 便捷方法
(通道插件请求-响应流:转发入站消息并取回 agent 回复文本)
This commit is contained in:
root
2026-08-02 15:30:22 +08:00
parent f3d87ec35f
commit 1796395668

View File

@ -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 }