5d7c10aeab
- Updated runtime configuration to use __CS_AI_AGENT_WIDGET_CONFIG__ instead of __CS_AGENT_WIDGET_CONFIG__. - Changed message types in support host bridge from "cs-agent" to "cs-ai-agent". - Minified SDK script updated to reflect new AI agent naming conventions. - Adjusted scrollbar styles in main.scss to use .cs-ai-agent-scrollbar instead of .cs-agent-scrollbar.
63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package runtime
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"cs-ai-agent/internal/models"
|
|
"cs-ai-agent/internal/pkg/toolx"
|
|
)
|
|
|
|
func TestNormalizeAllowedToolCodes(t *testing.T) {
|
|
ret := toolx.NormalizeToolCodes([]string{
|
|
" ",
|
|
"graph/create_ticket_with_confirmation",
|
|
"builtin/create_ticket_with_confirmation",
|
|
"graph/handoff_to_human",
|
|
"graph/handoff_to_human",
|
|
})
|
|
if len(ret) != 2 {
|
|
t.Fatalf("expected 2 tool codes, got %d: %#v", len(ret), ret)
|
|
}
|
|
if ret[0] != "graph/create_ticket_with_confirmation" {
|
|
t.Fatalf("unexpected first tool code: %s", ret[0])
|
|
}
|
|
if ret[1] != "graph/handoff_to_human" {
|
|
t.Fatalf("unexpected second tool code: %s", ret[1])
|
|
}
|
|
}
|
|
|
|
func TestToolCatalogResolveAllowedToolCodes(t *testing.T) {
|
|
catalog := newToolCatalog()
|
|
agent := models.AIAgent{
|
|
AllowedMCPTools: `[{"toolCode":"graph/create_ticket_with_confirmation"},{"toolCode":"graph/handoff_to_human"}]`,
|
|
}
|
|
skill := &models.SkillDefinition{
|
|
ToolWhitelist: `["builtin/create_ticket_with_confirmation","graph/prepare_ticket_draft"]`,
|
|
}
|
|
ret := catalog.resolveAllowedToolCodes(agent, skill)
|
|
if len(ret) != 1 {
|
|
t.Fatalf("expected 1 tool code, got %d: %#v", len(ret), ret)
|
|
}
|
|
if ret[0] != "graph/create_ticket_with_confirmation" {
|
|
t.Fatalf("unexpected tool code: %s", ret[0])
|
|
}
|
|
}
|
|
|
|
func TestToolCatalogResolveAllowedToolCodesFallsBackWhenSkillEmpty(t *testing.T) {
|
|
catalog := newToolCatalog()
|
|
agent := models.AIAgent{
|
|
AllowedMCPTools: `[{"toolCode":"graph/create_ticket_with_confirmation"},{"toolCode":"graph/handoff_to_human"}]`,
|
|
}
|
|
ret := catalog.resolveAllowedToolCodes(agent, nil)
|
|
if len(ret) != 2 {
|
|
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))
|
|
}
|
|
}
|