feat: refactor tool catalog to build static tools dynamically and improve tool code normalization

This commit is contained in:
mlogclub
2026-04-14 09:39:56 +08:00
parent 3e5f5b7589
commit 0ea113c621
3 changed files with 145 additions and 102 deletions
@@ -4,10 +4,11 @@ import (
"testing"
"cs-agent/internal/models"
"cs-agent/internal/pkg/toolx"
)
func TestNormalizeAllowedToolCodes(t *testing.T) {
ret := normalizeAllowedToolCodes([]string{
ret := toolx.NormalizeToolCodes([]string{
" ",
"graph/create_ticket_with_confirmation",
"builtin/create_ticket_with_confirmation",
@@ -52,3 +53,10 @@ func TestToolCatalogResolveAllowedToolCodesFallsBackWhenSkillEmpty(t *testing.T)
t.Fatalf("expected 2 tool codes, got %d: %#v", len(ret), ret)
}
}
func TestBuildRuntimeStaticTools(t *testing.T) {
ret := buildRuntimeStaticTools()
if len(ret) != len(toolx.ListRuntimeStaticToolSpecs()) {
t.Fatalf("expected %d runtime static tools, got %d", len(toolx.ListRuntimeStaticToolSpecs()), len(ret))
}
}