refactor(agent): Pi 会话运行时 - 接入原生 Agent 与 Skills 工具链

This commit is contained in:
ddcat666 committed 2026-09-29 08:21:11 +08:00
1 parent f9b8c5a43e
commit 387d3562ad
69 files changed
+11460 -207

No files matched your search

@@ -0,0 +1,39 @@
package app
import (
"context"
"encoding/json"
"strings"
"testing"
)
func TestPiStandardToolsFailWhenExecutorIsUnavailable(t *testing.T) {
service := &Service{}
tools := []string{
"read_file", "write_file", "edit_file", "delete_file",
"list_directory", "search_files", "glob_files",
"bash", "shell_command", "web_search", "fetch_url",
}
for _, tool := range tools {
t.Run(tool, func(t *testing.T) {
payload := map[string]json.RawMessage{"arguments": json.RawMessage(`{"command":"pwd"}`)}
_, err := service.routeStandardTool(context.Background(), "user", "run", tool, payload)
if err == nil {
t.Fatal("expected unavailable tool to return an error")
}
if strings.Contains(strings.ToLower(err.Error()), "success") {
t.Fatalf("unavailable tool reported success: %v", err)
}
})
}
}
func TestPiStandardToolRejectsMalformedArguments(t *testing.T) {
service := &Service{}
payload := map[string]json.RawMessage{"path": json.RawMessage(`{"unterminated"`)}
_, err := service.routeStandardTool(context.Background(), "user", "run", "read_file", payload)
if err == nil || !strings.Contains(err.Error(), `parameter "path"`) {
t.Fatalf("expected parameter decode error, got %v", err)
}
}