mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
1. 提示词去污染: buildToolCatalog 从全量工具定义改为按插件分组摘要 (插件名 + 工具数 + 能力概览), 完整工具定义由新工具 get_plugin_tools(plugin_name) 动态拉取; 新增 executeGetPluginTools 支持按插件过滤 stageHost/io 工具 2. 设备命令类型: device_ctl_cmdrun 的 command 支持前缀区分 - shell-cmd <cmd> -> 设备端执行原生 shell - homeagent-<cap> -> 设备端 HomeAgent 内置能力(如 camerasue/screensue) - homeagent-cmd <cap> -> 同上(兼容写法) PushCmd 增加 cmd_type 字段下发给设备端分发 3. 测试: TestExecuteGetPluginTools 验证按插件拉取/全部摘要/未知插件
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package core
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitcode.com/JianFeeeee/HomeAgent/internal/sdk"
|
|
)
|
|
|
|
func TestExecuteGetPluginTools(tmp *testing.T) {
|
|
sh := NewStageHost()
|
|
sh.RegisterTool("weather_current", sdk.ToolDef{Name: "weather_current", Plugin: "weather", Description: "当前天气", Parameters: map[string]interface{}{"type": "object"}}, nil)
|
|
sh.RegisterTool("weather_forecast", sdk.ToolDef{Name: "weather_forecast", Plugin: "weather", Description: "天气预报"}, nil)
|
|
sh.RegisterTool("device_ctl_cmdrun", sdk.ToolDef{Name: "device_ctl_cmdrun", Plugin: "remotedevice", Description: "下发命令"}, nil)
|
|
|
|
a := New(AgentConfig{ID: "t", StageHost: sh})
|
|
|
|
out := a.executeGetPluginTools("weather")
|
|
if !strings.Contains(out, "weather_current") || !strings.Contains(out, "weather_forecast") {
|
|
tmp.Fatalf("weather tools missing:\n%s", out)
|
|
}
|
|
if strings.Contains(out, "device_ctl_cmdrun") {
|
|
tmp.Fatalf("should not contain other plugin:\n%s", out)
|
|
}
|
|
all := a.executeGetPluginTools("")
|
|
if !strings.Contains(all, "weather_current") || !strings.Contains(all, "device_ctl_cmdrun") {
|
|
tmp.Fatalf("all tools missing:\n%s", all)
|
|
}
|
|
none := a.executeGetPluginTools("nope")
|
|
if !strings.Contains(none, "没有可用的工具") {
|
|
tmp.Fatalf("unknown plugin msg:\n%s", none)
|
|
}
|
|
}
|