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 YouTube search asks to browser_control even without browser keyword", () => { const result = classifyMasterAgentControlIntentForTesting("打开 YouTube 搜索周杰伦。"); assert.equal(result.intentCategory, "browser_control"); assert.equal(result.executionMode, "browser"); assert.equal(result.riskLevel, "medium"); }); test("routes current YouTube page search asks to browser_control", () => { const result = classifyMasterAgentControlIntentForTesting("你在刚才打开的YouTube页面里面搜索华为手机"); assert.equal(result.intentCategory, "browser_control"); assert.equal(result.executionMode, "browser"); }); 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"); assert.equal(result.recommendedProvider, "codex-computer-use"); }); 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"); });