Files
boss/tests/master-agent-control-intent-routing.test.ts

86 lines
2.9 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import {
classifyMasterAgentControlIntentForTesting,
resolveMasterAgentControlTargetDeviceIdForTesting,
} from "@/lib/boss-master-agent";
test("routes ordinary product discussion to discussion_only", () => {
const result = classifyMasterAgentControlIntentForTesting("帮我总结一下这个项目当前目标");
assert.equal(result.intentCategory, "discussion_only");
assert.equal(result.executionMode, "discussion");
});
test("routes development ask to project_development", () => {
const result = classifyMasterAgentControlIntentForTesting("继续开发这个项目,修掉登录闪退并跑测试");
assert.equal(result.intentCategory, "project_development");
assert.equal(result.executionMode, "development");
});
test("routes browser asks to browser_control", () => {
const result = classifyMasterAgentControlIntentForTesting("打开 Chrome 去后台看一下订单页");
assert.equal(result.intentCategory, "browser_control");
assert.equal(result.executionMode, "browser");
assert.equal(result.riskLevel, "medium");
});
test("routes desktop gui asks to desktop_control", () => {
const result = classifyMasterAgentControlIntentForTesting("打开微信并切到和产品经理的聊天窗口");
assert.equal(result.intentCategory, "desktop_control");
assert.equal(result.executionMode, "desktop");
assert.equal(result.riskLevel, "medium");
});
test("routes desktop control to the current project device before global master node", () => {
const deviceId = resolveMasterAgentControlTargetDeviceIdForTesting({
replyProjectId: "macbook-project",
intentCategory: "desktop_control",
preferredDeviceId: "mac-studio",
authorizedDeviceIds: ["macbook-air"],
devices: [
{
id: "mac-studio",
status: "online",
capabilities: { computerUse: { connected: true } },
},
{
id: "macbook-air",
status: "online",
capabilities: { computerUse: { connected: true } },
},
],
projects: [
{
id: "macbook-project",
deviceIds: ["macbook-air"],
},
],
});
assert.equal(deviceId, "macbook-air");
});
test("routes desktop control to the only authorized capable device for a subaccount", () => {
const deviceId = resolveMasterAgentControlTargetDeviceIdForTesting({
replyProjectId: "master-agent",
intentCategory: "desktop_control",
preferredDeviceId: "mac-studio",
authorizedDeviceIds: ["macbook-air"],
devices: [
{
id: "mac-studio",
status: "online",
capabilities: { computerUse: { connected: true } },
},
{
id: "macbook-air",
status: "online",
capabilities: { computerUse: { connected: true } },
},
],
projects: [{ id: "master-agent", deviceIds: [] }],
});
assert.equal(deviceId, "macbook-air");
});