feat(canvas): 云端 Agent - 完成策略分层、节点能力注册与可解释审批改造
This commit is contained in:
@@ -17,14 +17,14 @@ func skillFeedbackCall(id, path string) cloudAgentCall {
|
||||
}
|
||||
|
||||
func TestCloudAgentSkillEmptyDirectoryAndRepeatedRead(t *testing.T) {
|
||||
state := cloudAgentRuntime{Skills: []cloudAgentSkill{{ID: "script", Name: "剧本撰写", Files: map[string]string{}}}}
|
||||
state := cloudAgentRuntime{Skills: []cloudAgentSkill{{ID: "script", Name: "剧本撰写", Instruction: "# 剧本撰写", Files: map[string]string{}}}}
|
||||
call := skillFeedbackCall("script", "")
|
||||
result, err := cloudAgentReadTool(nil, "user", &state, call)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data := result.(map[string]any)
|
||||
if len(data["files"].([]string)) != 0 || !strings.Contains(data["guidance"].(string), "正文继续") {
|
||||
if data["entryPath"] != cloudAgentSkillEntryPath || strings.Join(data["files"].([]string), ",") != cloudAgentSkillEntryPath || !strings.Contains(data["guidance"].(string), "先读取 SKILL.md") {
|
||||
t.Fatalf("missing empty-directory guidance: %+v", data)
|
||||
}
|
||||
cloudAgentToolResult("run", &state, call, result, nil)
|
||||
@@ -44,6 +44,25 @@ func TestCloudAgentSkillEmptyDirectoryAndRepeatedRead(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudAgentSkillEntryDocumentIsReadableFromSnapshot(t *testing.T) {
|
||||
state := cloudAgentRuntime{Skills: []cloudAgentSkill{{
|
||||
ID: "script", Version: "v1", Instruction: "# 剧本撰写\n\n只是一份任务剧本。",
|
||||
Files: map[string]string{cloudAgentSkillEntryPath: "stale duplicate", "references/format.md": "格式参考"},
|
||||
}}}
|
||||
paths := cloudAgentSkillPaths(state.Skills[0])
|
||||
if strings.Join(paths, ",") != "SKILL.md,references/format.md" {
|
||||
t.Fatalf("entry path was missing or duplicated: %v", paths)
|
||||
}
|
||||
result, err := cloudAgentReadTool(nil, "user", &state, skillFeedbackCall("script", cloudAgentSkillEntryPath))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data := result.(map[string]any)
|
||||
if data["path"] != cloudAgentSkillEntryPath || data["content"] != state.Skills[0].Instruction {
|
||||
t.Fatalf("skill entry did not come from immutable instruction snapshot: %+v", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudAgentSkillMissingAndDistinctPaths(t *testing.T) {
|
||||
state := cloudAgentRuntime{Skills: []cloudAgentSkill{
|
||||
{ID: "script", Files: map[string]string{"references/b.md": "B", "references/a.md": "A"}},
|
||||
|
||||
Reference in New Issue
Block a user