mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-02 15:23:57 +00:00
feat(clawhubadapter): bridge OC channels to HomeAgent output/input channels
- registry.go: replace channelDevice+RegisterChannel with RegisterOutputChannel
handler routes output via sp.CallTool to JS manager outbound handlers
register {plugin}_read_{ch}_input tool for agent to poll buffered input
- plugin.go: handle channel_input notifications in translateAndRegister
buffer payload in channelInputBuf + InjectInterruptText to notify agent
- manager/main.js: registerChannel supports {plugin: ChannelPlugin} format
tools/call routes channel names to outbound.sendText/sendMedia
submitInput sends channel_input notification to Go side
This commit is contained in:
@ -670,6 +670,23 @@ func (p *Plugin) notifyLoop(sp *sidecarProcess, s *sdk.PluginSDK, pluginName str
|
||||
}
|
||||
|
||||
func (p *Plugin) translateAndRegister(n OCNotification, sp *sidecarProcess, s *sdk.PluginSDK, pluginName string) {
|
||||
if n.Method == "channel_input" {
|
||||
var params struct {
|
||||
Channel string `json:"channel"`
|
||||
Payload map[string]interface{} `json:"payload"`
|
||||
}
|
||||
if err := json.Unmarshal(n.Params, ¶ms); err != nil || params.Channel == "" {
|
||||
return
|
||||
}
|
||||
channelInputBuf[params.Channel] = append(channelInputBuf[params.Channel], params.Payload)
|
||||
content, _ := params.Payload["content"].(string)
|
||||
if content == "" {
|
||||
data, _ := json.Marshal(params.Payload)
|
||||
content = string(data)
|
||||
}
|
||||
s.InjectInterruptText(pluginName, params.Channel, fmt.Sprintf("[%s] %s", params.Channel, content))
|
||||
return
|
||||
}
|
||||
if n.Method != "register" {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user