mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-04 00:03:59 +00:00
IO 抽象层增强:非文本输入支持 + waiter CLI 重写
PluginSDK: - 添加 InjectInput / InjectInputSync / InjectInterrupt 泛型接口 - 插件现在可注入 image/audio/file 等任意类型输入 Provider: - 添加 ContentBlock / ImageURL / AudioURL 类型 - Message 增加 Blocks 字段,Content 在非空 Blocks 时序列化为数组(多模态格式) Agent: - handleInput 新增 image/audio 类型分发 → processMediaInput - processMediaInput 将媒体数据附着到对话上下文,LLM 自主决策处理策略 - 新增内置工具:describe_image / transcribe_audio / ocr_image(pendingMedia 驱动) - 工具仅当有未处理媒体数据时注册,通过 Provider 直接调用多模态模型 Config: - 新增 InputProcessingConfig(image/audio 处理配置) - 含 fallback_provider / describe_prompt / ocr_enabled 等选项 Waiter CLI 重写: - 配置文件 ~/.config/homeagent/cli.yaml(自动发现 socket) - 原始终端行编辑 + 命令历史持久化 + 彩色输出 - 内置命令:/help /reconnect /connect /remote /local /prompt - 断线自动重连
This commit is contained in:
@ -120,57 +120,57 @@ func New(name string, iom *agentIO.IOManager, eventBus *events.Bus, mem MemoryAP
|
||||
|
||||
// === IO 双通道 ===
|
||||
|
||||
func (s *PluginSDK) InjectInput(source, channel string, payload map[string]interface{}) {
|
||||
// InjectInput 注入任意类型的输入事件。
|
||||
// eventType 可选值: "text", "event", "command", 或插件自定义类型。
|
||||
// payload 可包含 "content" (文本), "image" (图片), "file" (文件), "audio" (音频) 等字段。
|
||||
func (s *PluginSDK) InjectInput(source, channel, eventType string, payload map[string]interface{}) {
|
||||
if s.iom != nil {
|
||||
s.iom.InjectInputTo(source, channel, "text", payload)
|
||||
s.iom.InjectInputTo(source, channel, eventType, payload)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PluginSDK) InjectInterrupt(source, channel string, payload map[string]interface{}) {
|
||||
// InjectInputSync 注入任意类型输入并同步等待响应。
|
||||
func (s *PluginSDK) InjectInputSync(source, channel, eventType string, payload map[string]interface{}) *agentIO.OutputEvent {
|
||||
if s.iom != nil {
|
||||
p := payload
|
||||
if p == nil {
|
||||
p = map[string]interface{}{}
|
||||
return s.iom.InjectInputSyncTo(source, channel, eventType, payload)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InjectInterrupt 向中断通道注入任意类型的输入事件,可打断当前 LLM 处理。
|
||||
// eventType 会被写入 payload["type"]。
|
||||
func (s *PluginSDK) InjectInterrupt(source, channel, eventType string, payload map[string]interface{}) {
|
||||
if s.iom != nil {
|
||||
if payload == nil {
|
||||
payload = map[string]interface{}{}
|
||||
}
|
||||
if _, ok := p["type"]; !ok {
|
||||
p["type"] = "text"
|
||||
}
|
||||
s.iom.InjectInterrupt(source, channel, p)
|
||||
payload["type"] = eventType
|
||||
s.iom.InjectInterrupt(source, channel, payload)
|
||||
}
|
||||
}
|
||||
|
||||
// 以下 InjectText* / InjectInterruptText 为快捷方式,等价于调用对应的泛型方法并传入 "text" 类型。
|
||||
|
||||
func (s *PluginSDK) InjectText(source, channel, text string) {
|
||||
if s.iom != nil {
|
||||
s.iom.InjectTextTo(source, channel, text)
|
||||
}
|
||||
s.InjectInput(source, channel, "text", map[string]interface{}{"content": text})
|
||||
}
|
||||
|
||||
// InjectTextNoMemory 注入文本输入(不产生记忆)。适用于健康检查等无需记忆碎片的场景。
|
||||
func (s *PluginSDK) InjectTextNoMemory(source, channel, text string) {
|
||||
if s.iom != nil {
|
||||
s.iom.InjectTextNoMemoryTo(source, channel, text)
|
||||
}
|
||||
s.InjectInput(source, channel, "text", map[string]interface{}{"content": text, "no_memory": true})
|
||||
}
|
||||
|
||||
func (s *PluginSDK) InjectTextSync(source, channel, text string) *agentIO.OutputEvent {
|
||||
if s.iom != nil {
|
||||
return s.iom.InjectTextSyncTo(source, channel, text)
|
||||
}
|
||||
return nil
|
||||
return s.InjectInputSync(source, channel, "text", map[string]interface{}{"content": text})
|
||||
}
|
||||
|
||||
// InjectTextSyncNoMemory 注入文本输入(同步等待,不产生记忆)。
|
||||
func (s *PluginSDK) InjectTextSyncNoMemory(source, channel, text string) *agentIO.OutputEvent {
|
||||
if s.iom != nil {
|
||||
return s.iom.InjectTextSyncNoMemoryTo(source, channel, text)
|
||||
}
|
||||
return nil
|
||||
return s.InjectInputSync(source, channel, "text", map[string]interface{}{"content": text, "no_memory": true})
|
||||
}
|
||||
|
||||
func (s *PluginSDK) InjectInterruptText(source, channel, text string) {
|
||||
if s.iom != nil {
|
||||
s.iom.InjectInterruptText(source, channel, text)
|
||||
}
|
||||
s.InjectInterrupt(source, channel, "text", map[string]interface{}{"content": text})
|
||||
}
|
||||
|
||||
func (s *PluginSDK) OutputChan() <-chan *agentIO.OutputEvent {
|
||||
|
||||
Reference in New Issue
Block a user