mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-10-15 12:15:11 +00:00
sdk: 公共 IOInjector 补 InjectInputSync(同步注入并等待回复)
与主仓 third_party/homeagent-sdk 对齐:IOInjector 接口新增 InjectInputSync(source, channel, text) string + PluginSDK 便捷方法 (通道插件请求-响应流:转发入站消息并取回 agent 回复文本)
This commit is contained in:
@ -111,6 +111,9 @@ 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
|
||||||
|
// reply, returning the reply text (empty string if no reply).
|
||||||
|
InjectInputSync(source, channel, text string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventType identifies the kind of system event.
|
// 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 设置插件是否允许内核自动重启(崩溃后自动重载)。
|
// SetAutoRestart 设置插件是否允许内核自动重启(崩溃后自动重载)。
|
||||||
// 默认 true。如果插件有无法恢复的状态(如外部连接),应设为 false。
|
// 默认 true。如果插件有无法恢复的状态(如外部连接),应设为 false。
|
||||||
func (s *PluginSDK) SetAutoRestart(enabled bool) { s.autoRestart = enabled }
|
func (s *PluginSDK) SetAutoRestart(enabled bool) { s.autoRestart = enabled }
|
||||||
|
|||||||
Reference in New Issue
Block a user