94 lines
2.3 KiB
JavaScript
94 lines
2.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { buildCodexTaskExecution } from "../local-agent/codex-task-runner.mjs";
|
|
|
|
test("conversation reply resumes the real Codex thread when thread ref is available", () => {
|
|
const execution = buildCodexTaskExecution(
|
|
{
|
|
masterAgentWorkdir: "/Users/kris/code/boss",
|
|
masterAgentSandbox: "workspace-write",
|
|
masterAgentModel: "gpt-5.4",
|
|
},
|
|
{
|
|
taskType: "conversation_reply",
|
|
executionPrompt: "请回复用户",
|
|
targetCodexThreadRef: "019d-thread-real",
|
|
targetCodexFolderRef: "/Users/kris/code/meiyesaas",
|
|
},
|
|
"/tmp/reply.txt",
|
|
);
|
|
|
|
assert.equal(execution.mode, "resume");
|
|
assert.equal(execution.cwd, "/Users/kris/code/meiyesaas");
|
|
assert.deepEqual(execution.args, [
|
|
"exec",
|
|
"resume",
|
|
"--skip-git-repo-check",
|
|
"-o",
|
|
"/tmp/reply.txt",
|
|
"-m",
|
|
"gpt-5.4",
|
|
"019d-thread-real",
|
|
"请回复用户",
|
|
]);
|
|
});
|
|
|
|
test("dispatch execution falls back to targetThreadId when codex thread ref is missing", () => {
|
|
const execution = buildCodexTaskExecution(
|
|
{
|
|
masterAgentWorkdir: "/Users/kris/code/boss",
|
|
masterAgentSandbox: "workspace-write",
|
|
},
|
|
{
|
|
taskType: "dispatch_execution",
|
|
executionPrompt: "请执行群聊任务",
|
|
targetThreadId: "019d-thread-fallback",
|
|
},
|
|
"/tmp/reply.txt",
|
|
);
|
|
|
|
assert.equal(execution.mode, "resume");
|
|
assert.deepEqual(execution.args, [
|
|
"exec",
|
|
"resume",
|
|
"--skip-git-repo-check",
|
|
"-o",
|
|
"/tmp/reply.txt",
|
|
"019d-thread-fallback",
|
|
"请执行群聊任务",
|
|
]);
|
|
});
|
|
|
|
test("master agent reply without target thread stays on ephemeral exec", () => {
|
|
const execution = buildCodexTaskExecution(
|
|
{
|
|
masterAgentWorkdir: "/Users/kris/code/boss",
|
|
masterAgentSandbox: "workspace-write",
|
|
masterAgentModel: "gpt-5.4",
|
|
},
|
|
{
|
|
taskType: "conversation_reply",
|
|
executionPrompt: "你是主 Agent",
|
|
},
|
|
"/tmp/master.txt",
|
|
);
|
|
|
|
assert.equal(execution.mode, "ephemeral");
|
|
assert.equal(execution.cwd, "/Users/kris/code/boss");
|
|
assert.deepEqual(execution.args, [
|
|
"exec",
|
|
"--ephemeral",
|
|
"--skip-git-repo-check",
|
|
"-C",
|
|
"/Users/kris/code/boss",
|
|
"-s",
|
|
"workspace-write",
|
|
"-o",
|
|
"/tmp/master.txt",
|
|
"-m",
|
|
"gpt-5.4",
|
|
"你是主 Agent",
|
|
]);
|
|
});
|