feat: surface codex thread config progress
This commit is contained in:
61
tests/fixtures/codex-app-server-runtime.mjs
vendored
61
tests/fixtures/codex-app-server-runtime.mjs
vendored
@@ -520,6 +520,67 @@ rl.on("line", (line) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_THREAD_CONFIG_EVENTS === "1") {
|
||||
send({
|
||||
method: "thread/goal/updated",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
goal: {
|
||||
threadId: message.params?.threadId,
|
||||
objective: "完成 App Server 线程目标同步",
|
||||
status: "active",
|
||||
tokenBudget: 120000,
|
||||
tokensUsed: 4800,
|
||||
timeUsedSeconds: 600,
|
||||
createdAt: 1770000000,
|
||||
updatedAt: 1770000300,
|
||||
},
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "thread/settings/updated",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
threadSettings: {
|
||||
cwd: "/Users/kris/code/boss/secret-project",
|
||||
approvalPolicy: "on-request",
|
||||
approvalsReviewer: "user",
|
||||
sandboxPolicy: {
|
||||
type: "workspaceWrite",
|
||||
writableRoots: ["/Users/kris/code/boss", "/Users/kris/.codex/memories"],
|
||||
networkAccess: false,
|
||||
excludeTmpdirEnvVar: false,
|
||||
excludeSlashTmp: false,
|
||||
},
|
||||
activePermissionProfile: {
|
||||
id: ":workspace",
|
||||
extends: null,
|
||||
},
|
||||
model: "gpt-5.5",
|
||||
modelProvider: "openai",
|
||||
serviceTier: "fast",
|
||||
effort: "low",
|
||||
summary: "concise",
|
||||
collaborationMode: {
|
||||
mode: "plan",
|
||||
settings: {
|
||||
developer_instructions: "internal prompt should not leak",
|
||||
model_instructions_file: "/Users/kris/.codex/secret-instructions.md",
|
||||
},
|
||||
},
|
||||
personality: "pragmatic",
|
||||
},
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "thread/compacted",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
},
|
||||
});
|
||||
}
|
||||
send({
|
||||
method: "item/agentMessage/delta",
|
||||
params: {
|
||||
|
||||
@@ -470,6 +470,65 @@ test("codex app-server runner maps runtime status events without leaking interna
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner maps thread goal, settings, and compaction events without leaking local paths", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_THREAD_CONFIG_EVENTS;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_THREAD_CONFIG_EVENTS = "1";
|
||||
try {
|
||||
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
|
||||
codexAppServerEnabled: true,
|
||||
codexAppServerCommand: process.execPath,
|
||||
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
|
||||
codexAppServerWorkdir: repoRoot,
|
||||
codexAppServerTimeoutMs: 5000,
|
||||
masterAgentModel: "gpt-5.4",
|
||||
});
|
||||
|
||||
const result = await executeCodexAppServerTask(runnerConfig, {
|
||||
taskId: "task-app-server-thread-config",
|
||||
taskType: "conversation_reply",
|
||||
targetCodexThreadRef: "019d-app-server-thread",
|
||||
targetCodexFolderRef: repoRoot,
|
||||
executionPrompt: "同步线程目标和设置",
|
||||
});
|
||||
|
||||
assert.equal(result.status, "completed");
|
||||
assert.deepEqual(result.executionProgress.threadGoal, {
|
||||
objective: "完成 App Server 线程目标同步",
|
||||
status: "active",
|
||||
tokenBudget: 120000,
|
||||
tokensUsed: 4800,
|
||||
timeUsedSeconds: 600,
|
||||
});
|
||||
assert.deepEqual(result.executionProgress.threadSettings, {
|
||||
model: "gpt-5.5",
|
||||
modelProvider: "openai",
|
||||
approvalPolicy: "on-request",
|
||||
approvalsReviewer: "user",
|
||||
sandboxPolicy: "workspaceWrite",
|
||||
permissionProfile: ":workspace",
|
||||
serviceTier: "fast",
|
||||
effort: "low",
|
||||
summary: "concise",
|
||||
collaborationMode: "plan",
|
||||
personality: "pragmatic",
|
||||
});
|
||||
assert.deepEqual(result.executionProgress.compaction, {
|
||||
status: "completed",
|
||||
message: "上下文已压缩",
|
||||
});
|
||||
const serialized = JSON.stringify(result.executionProgress);
|
||||
assert.equal(serialized.includes("/Users/kris"), false);
|
||||
assert.equal(serialized.includes("internal prompt"), false);
|
||||
assert.equal(serialized.includes("secret-instructions"), false);
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_THREAD_CONFIG_EVENTS;
|
||||
} else {
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_THREAD_CONFIG_EVENTS = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner bridges source thread context into target thread through inject_items", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD = "1";
|
||||
|
||||
@@ -294,3 +294,79 @@ test("POST task progress preserves Codex runtime status summaries", async () =>
|
||||
assert.equal(progress?.remoteControl?.status, "connected");
|
||||
assert.equal(JSON.stringify(progress).includes("install-secret-should-not-persist"), false);
|
||||
});
|
||||
|
||||
test("POST task progress preserves Codex thread goal, settings, and compaction summaries", async () => {
|
||||
const task = await data.queueMasterAgentTask({
|
||||
taskId: "route-progress-thread-config-task",
|
||||
projectId: "group-progress-test",
|
||||
taskType: "dispatch_execution",
|
||||
requestMessageId: "msg-route-progress-thread-config",
|
||||
requestText: "让目标线程同步目标和设置",
|
||||
executionPrompt: "让目标线程同步目标和设置",
|
||||
requestedBy: "krisolo",
|
||||
requestedByAccount: "krisolo",
|
||||
deviceId: "mac-studio",
|
||||
targetProjectId: "master-agent",
|
||||
targetThreadId: "master-agent-thread",
|
||||
});
|
||||
await data.claimNextMasterAgentTask("mac-studio");
|
||||
|
||||
const response = await postProgress(
|
||||
new NextRequest(`http://127.0.0.1:3000/api/v1/master-agent/tasks/${task.taskId}/progress`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"x-boss-device-token": "boss-mac-studio-token",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
deviceId: "mac-studio",
|
||||
status: "running",
|
||||
executionProgress: {
|
||||
steps: [{ text: "同步 Codex 线程配置", status: "running" }],
|
||||
threadGoal: {
|
||||
objective: "完成 App Server 线程目标同步",
|
||||
status: "active",
|
||||
tokenBudget: 120000,
|
||||
tokensUsed: 4800,
|
||||
timeUsedSeconds: 600,
|
||||
},
|
||||
threadSettings: {
|
||||
model: "gpt-5.5",
|
||||
modelProvider: "openai",
|
||||
approvalPolicy: "on-request",
|
||||
approvalsReviewer: "user",
|
||||
sandboxPolicy: "workspaceWrite",
|
||||
permissionProfile: ":workspace",
|
||||
serviceTier: "fast",
|
||||
effort: "low",
|
||||
summary: "concise",
|
||||
collaborationMode: "plan",
|
||||
personality: "pragmatic",
|
||||
cwd: "/Users/kris/code/boss/secret-project",
|
||||
},
|
||||
compaction: {
|
||||
status: "completed",
|
||||
message: "上下文已压缩",
|
||||
turnId: "turn-secret-should-not-persist",
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
{ params: Promise.resolve({ taskId: task.taskId }) },
|
||||
);
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
|
||||
const state = await data.readState();
|
||||
const progress = state.projects
|
||||
.find((project) => project.id === "master-agent")
|
||||
?.messages.find((message) => message.executionProgress?.taskId === task.taskId)
|
||||
?.executionProgress;
|
||||
assert.equal(progress?.threadGoal?.objective, "完成 App Server 线程目标同步");
|
||||
assert.equal(progress?.threadSettings?.model, "gpt-5.5");
|
||||
assert.equal(progress?.threadSettings?.sandboxPolicy, "workspaceWrite");
|
||||
assert.equal(progress?.compaction?.status, "completed");
|
||||
const serialized = JSON.stringify(progress);
|
||||
assert.equal(serialized.includes("/Users/kris"), false);
|
||||
assert.equal(serialized.includes("turn-secret-should-not-persist"), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user