Files
boss/tests/remote-runtime-adapter.test.ts

64 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from "node:test";
import assert from "node:assert/strict";
import { normalizeRemoteExecutionResultForTesting } from "../src/lib/execution/remote-runtime-adapter.ts";
test("RemoteRuntimeAdapter 会把 local-agent 回写标准化成统一结果", () => {
const normalized = normalizeRemoteExecutionResultForTesting({
status: "completed",
dispatchExecutionId: "dx-1",
targetProjectId: "project-1",
targetThreadId: "thread-1",
rawThreadReply: " 链路正常 ",
replyBody: " 主 Agent 汇总:链路正常 ",
});
assert.equal(normalized.status, "completed");
assert.equal(normalized.dispatchExecutionId, "dx-1");
assert.equal(normalized.targetProjectId, "project-1");
assert.equal(normalized.targetThreadId, "thread-1");
assert.equal(normalized.rawThreadReply, "链路正常");
assert.equal(normalized.replyBody, "主 Agent 汇总:链路正常");
});
test("RemoteRuntimeAdapter 会忽略空白字段并保留失败状态", () => {
const normalized = normalizeRemoteExecutionResultForTesting({
status: "failed",
dispatchExecutionId: " ",
targetProjectId: " project-2 ",
targetThreadId: "",
rawThreadReply: " ",
errorMessage: " MODEL_CALL_FAILED ",
});
assert.equal(normalized.status, "failed");
assert.equal(normalized.dispatchExecutionId, undefined);
assert.equal(normalized.targetProjectId, "project-2");
assert.equal(normalized.targetThreadId, undefined);
assert.equal(normalized.rawThreadReply, undefined);
assert.equal(normalized.errorMessage, "MODEL_CALL_FAILED");
});
test("RemoteRuntimeAdapter 会把线程环境脏回复改写成失败", () => {
const normalized = normalizeRemoteExecutionResultForTesting({
status: "completed",
replyBody:
"我不能直接把当前会话环境从只读改回可写。cwd 我可以在命令里指向 /Users/kris/code/gptpluscontrol但真正卡住的是只读权限。",
});
assert.equal(normalized.status, "failed");
assert.equal(normalized.replyBody, undefined);
assert.equal(normalized.rawThreadReply, undefined);
assert.match(normalized.errorMessage ?? "", /THREAD_ENVIRONMENT_INVALID/);
});
test("RemoteRuntimeAdapter 不会误杀包含路径和 sandbox 描述的有效线程回复", () => {
const normalized = normalizeRemoteExecutionResultForTesting({
status: "completed",
replyBody:
"已经把配置写到 /Users/kris/code/gptpluscontrol/.env.local接下来如果线上仍受 sandbox 限制,我们再切到服务器验证。",
});
assert.equal(normalized.status, "completed");
assert.match(normalized.replyBody ?? "", /gptpluscontrol/);
});