feat: complete chat routing and openai onboarding

This commit is contained in:
kris
2026-03-31 03:31:22 +08:00
parent 5b590f7cc1
commit 9c02ebb574
25 changed files with 2241 additions and 133 deletions

View File

@@ -0,0 +1,93 @@
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",
]);
});