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"); });