chore: checkpoint Boss app v2.5.11
This commit is contained in:
@@ -46,6 +46,39 @@ function resolveTaskTurnRef(task) {
|
||||
return trimToDefined(task?.targetCodexTurnId || task?.targetTurnId);
|
||||
}
|
||||
|
||||
function isActiveTurnStatus(status) {
|
||||
const normalized = String(status ?? "").trim().toLowerCase().replace(/[\s_-]+/g, "");
|
||||
return (
|
||||
normalized === "active" ||
|
||||
normalized === "running" ||
|
||||
normalized === "streaming" ||
|
||||
normalized === "inprogress"
|
||||
);
|
||||
}
|
||||
|
||||
function resolveActiveTurnRefFromThreadResult(threadResult) {
|
||||
const activeTurns = asArray(threadResult?.thread?.turns)
|
||||
.map((turn, index) => {
|
||||
const id = trimToDefined(turn?.id ?? turn?.turnId);
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
const status = extractDiscoveryTurnStatus(turn);
|
||||
const completedAt = trimToDefined(turn?.completedAt);
|
||||
if (completedAt || !isActiveTurnStatus(status)) {
|
||||
return null;
|
||||
}
|
||||
const startedAt = Number(turn?.startedAt ?? turn?.createdAt ?? turn?.updatedAt ?? 0);
|
||||
return {
|
||||
id,
|
||||
order: Number.isFinite(startedAt) && startedAt > 0 ? startedAt : index,
|
||||
};
|
||||
})
|
||||
.filter(Boolean)
|
||||
.sort((left, right) => right.order - left.order);
|
||||
return activeTurns[0]?.id;
|
||||
}
|
||||
|
||||
function resolveSourceThreadRef(task) {
|
||||
return trimToDefined(task?.sourceCodexThreadRef || task?.sourceThreadId);
|
||||
}
|
||||
@@ -177,7 +210,7 @@ function waitForCompactNotificationSettle() {
|
||||
|
||||
function normalizeTimeoutMs(value) {
|
||||
const numeric = Number(value);
|
||||
return Number.isFinite(numeric) && numeric > 0 ? Math.floor(numeric) : 120_000;
|
||||
return Number.isFinite(numeric) && numeric > 0 ? Math.floor(numeric) : 600_000;
|
||||
}
|
||||
|
||||
function normalizePositiveInteger(value, fallback) {
|
||||
@@ -471,6 +504,7 @@ function openStdioCodexAppServerTransport(runnerConfig, cwd, handlers) {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
});
|
||||
let stderr = "";
|
||||
let closed = false;
|
||||
const rl = readline.createInterface({ input: child.stdout });
|
||||
rl.on("line", handlers.onLine);
|
||||
child.stderr.on("data", (chunk) => {
|
||||
@@ -478,18 +512,33 @@ function openStdioCodexAppServerTransport(runnerConfig, cwd, handlers) {
|
||||
});
|
||||
child.on("error", handlers.onError);
|
||||
child.on("close", (code) => {
|
||||
closed = true;
|
||||
handlers.onClose({
|
||||
code,
|
||||
message: stderr.trim() || `CODEX_APP_SERVER_EXITED:${code ?? "unknown"}`,
|
||||
});
|
||||
});
|
||||
child.stdin.on("error", (error) => {
|
||||
closed = true;
|
||||
handlers.onError(error);
|
||||
});
|
||||
|
||||
return {
|
||||
transport: "stdio",
|
||||
send(line, callback) {
|
||||
child.stdin.write(`${line}\n`, callback);
|
||||
if (closed || child.stdin.destroyed || !child.stdin.writable) {
|
||||
callback?.(new Error("CODEX_APP_SERVER_STDIN_CLOSED"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
child.stdin.write(`${line}\n`, callback);
|
||||
} catch (error) {
|
||||
callback?.(error);
|
||||
handlers.onError(error);
|
||||
}
|
||||
},
|
||||
close(signal = "SIGTERM") {
|
||||
closed = true;
|
||||
rl.close();
|
||||
if (!child.killed) {
|
||||
child.kill(signal);
|
||||
@@ -3502,6 +3551,7 @@ export async function executeCodexAppServerTask(runnerConfig, task) {
|
||||
if (!threadId) {
|
||||
throw new Error("CODEX_APP_SERVER_THREAD_ID_MISSING");
|
||||
}
|
||||
const effectiveTurnRef = targetTurnRef || resolveActiveTurnRefFromThreadResult(threadResult);
|
||||
|
||||
if (isThreadRollbackTask(task)) {
|
||||
const numTurns = resolveRollbackNumTurns(task);
|
||||
@@ -3553,15 +3603,15 @@ export async function executeCodexAppServerTask(runnerConfig, task) {
|
||||
request,
|
||||
task,
|
||||
targetThreadId: threadId,
|
||||
targetTurnId: targetTurnRef,
|
||||
targetTurnId: effectiveTurnRef,
|
||||
hasExistingThreadRef: Boolean(targetThreadRef),
|
||||
});
|
||||
|
||||
const turnControl = targetTurnRef ? "steer" : "start";
|
||||
const turnResult = targetTurnRef
|
||||
const turnControl = effectiveTurnRef ? "steer" : "start";
|
||||
const turnResult = effectiveTurnRef
|
||||
? await request("turn/steer", {
|
||||
threadId,
|
||||
expectedTurnId: targetTurnRef,
|
||||
expectedTurnId: effectiveTurnRef,
|
||||
input: [{ type: "text", text: prompt }],
|
||||
})
|
||||
: await request("turn/start", {
|
||||
@@ -3571,7 +3621,7 @@ export async function executeCodexAppServerTask(runnerConfig, task) {
|
||||
model: runnerConfig.model,
|
||||
});
|
||||
activeTurnStarted = true;
|
||||
const activeTurnId = trimToDefined(turnResult?.turn?.id) || targetTurnRef;
|
||||
const activeTurnId = trimToDefined(turnResult?.turn?.id) || effectiveTurnRef;
|
||||
startActiveTurnInterruptPolling({ threadId, turnId: activeTurnId });
|
||||
await turnCompleted;
|
||||
if (progressEmits.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user