wildcrane-runner 0.6.91 → 0.6.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +362 -133
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +114 -40
- package/dist/codex-retained.mjs +2 -1
- package/dist/flow-worker-main.mjs +29293 -28939
- package/dist/launcher.mjs +22845 -2966
- package/dist/plugin.mjs +175 -50
- package/dist/runner.mjs +25147 -24792
- package/dist/settings.mjs +22832 -2953
- package/package.json +2 -2
package/dist/akb/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"wildcrane","version":"0.11.
|
|
1
|
+
{"name":"wildcrane","version":"0.11.75","akbContract":22,"type":"module","private":true}
|
package/dist/akb-proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.93 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
package/dist/codex-proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.93 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -958,9 +958,9 @@ var require_timers = __commonJS({
|
|
|
958
958
|
* before the specified function or code is executed.
|
|
959
959
|
* @param {*} arg
|
|
960
960
|
*/
|
|
961
|
-
constructor(callback,
|
|
961
|
+
constructor(callback, delay3, arg) {
|
|
962
962
|
this._onTimeout = callback;
|
|
963
|
-
this._idleTimeout =
|
|
963
|
+
this._idleTimeout = delay3;
|
|
964
964
|
this._timerArg = arg;
|
|
965
965
|
this.refresh();
|
|
966
966
|
}
|
|
@@ -1005,8 +1005,8 @@ var require_timers = __commonJS({
|
|
|
1005
1005
|
* when the timer expires.
|
|
1006
1006
|
* @returns {NodeJS.Timeout|FastTimer}
|
|
1007
1007
|
*/
|
|
1008
|
-
setTimeout(callback,
|
|
1009
|
-
return
|
|
1008
|
+
setTimeout(callback, delay3, arg) {
|
|
1009
|
+
return delay3 <= RESOLUTION_MS ? setTimeout(callback, delay3, arg) : new FastTimer(callback, delay3, arg);
|
|
1010
1010
|
},
|
|
1011
1011
|
/**
|
|
1012
1012
|
* The clearTimeout method cancels an instantiated Timer previously created
|
|
@@ -1032,8 +1032,8 @@ var require_timers = __commonJS({
|
|
|
1032
1032
|
* when the timer expires.
|
|
1033
1033
|
* @returns {FastTimer}
|
|
1034
1034
|
*/
|
|
1035
|
-
setFastTimeout(callback,
|
|
1036
|
-
return new FastTimer(callback,
|
|
1035
|
+
setFastTimeout(callback, delay3, arg) {
|
|
1036
|
+
return new FastTimer(callback, delay3, arg);
|
|
1037
1037
|
},
|
|
1038
1038
|
/**
|
|
1039
1039
|
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
@@ -1059,8 +1059,8 @@ var require_timers = __commonJS({
|
|
|
1059
1059
|
* @deprecated
|
|
1060
1060
|
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
1061
1061
|
*/
|
|
1062
|
-
tick(
|
|
1063
|
-
fastNow +=
|
|
1062
|
+
tick(delay3 = 0) {
|
|
1063
|
+
fastNow += delay3 - RESOLUTION_MS + 1;
|
|
1064
1064
|
onTick();
|
|
1065
1065
|
onTick();
|
|
1066
1066
|
},
|
|
@@ -7578,21 +7578,21 @@ var require_client_h1 = __commonJS({
|
|
|
7578
7578
|
this.connection = "";
|
|
7579
7579
|
this.maxResponseSize = client[kMaxResponseSize];
|
|
7580
7580
|
}
|
|
7581
|
-
setTimeout(
|
|
7582
|
-
if (
|
|
7581
|
+
setTimeout(delay3, type) {
|
|
7582
|
+
if (delay3 !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
|
|
7583
7583
|
if (this.timeout) {
|
|
7584
7584
|
timers.clearTimeout(this.timeout);
|
|
7585
7585
|
this.timeout = null;
|
|
7586
7586
|
}
|
|
7587
|
-
if (
|
|
7587
|
+
if (delay3) {
|
|
7588
7588
|
if (type & USE_FAST_TIMER) {
|
|
7589
|
-
this.timeout = timers.setFastTimeout(onParserTimeout,
|
|
7589
|
+
this.timeout = timers.setFastTimeout(onParserTimeout, delay3, this.timeoutWeakRef);
|
|
7590
7590
|
} else {
|
|
7591
|
-
this.timeout = setTimeout(onParserTimeout,
|
|
7591
|
+
this.timeout = setTimeout(onParserTimeout, delay3, this.timeoutWeakRef);
|
|
7592
7592
|
this.timeout?.unref();
|
|
7593
7593
|
}
|
|
7594
7594
|
}
|
|
7595
|
-
this.timeoutValue =
|
|
7595
|
+
this.timeoutValue = delay3;
|
|
7596
7596
|
} else if (this.timeout) {
|
|
7597
7597
|
if (this.timeout.refresh) {
|
|
7598
7598
|
this.timeout.refresh();
|
|
@@ -13758,7 +13758,7 @@ var require_mock_utils = __commonJS({
|
|
|
13758
13758
|
if (mockDispatch2.data.callback) {
|
|
13759
13759
|
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
13760
13760
|
}
|
|
13761
|
-
const { data: { statusCode, data, headers, trailers, error }, delay:
|
|
13761
|
+
const { data: { statusCode, data, headers, trailers, error }, delay: delay3, persist } = mockDispatch2;
|
|
13762
13762
|
const { timesInvoked, times } = mockDispatch2;
|
|
13763
13763
|
mockDispatch2.consumed = !persist && timesInvoked >= times;
|
|
13764
13764
|
mockDispatch2.pending = timesInvoked < times;
|
|
@@ -13781,11 +13781,11 @@ var require_mock_utils = __commonJS({
|
|
|
13781
13781
|
handler.onError(err);
|
|
13782
13782
|
}
|
|
13783
13783
|
handler.onConnect?.(abort, null);
|
|
13784
|
-
if (typeof
|
|
13784
|
+
if (typeof delay3 === "number" && delay3 > 0) {
|
|
13785
13785
|
timer = setTimeout(() => {
|
|
13786
13786
|
timer = null;
|
|
13787
13787
|
handleReply(this[kDispatches]);
|
|
13788
|
-
},
|
|
13788
|
+
}, delay3);
|
|
13789
13789
|
} else {
|
|
13790
13790
|
handleReply(this[kDispatches]);
|
|
13791
13791
|
}
|
|
@@ -27416,6 +27416,7 @@ import { createInterface } from "node:readline";
|
|
|
27416
27416
|
import crypto2 from "node:crypto";
|
|
27417
27417
|
import fs5 from "node:fs";
|
|
27418
27418
|
import path6 from "node:path";
|
|
27419
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
27419
27420
|
import { spawn } from "node:child_process";
|
|
27420
27421
|
import { fileURLToPath } from "node:url";
|
|
27421
27422
|
|
|
@@ -27666,6 +27667,7 @@ function executionFailure(error) {
|
|
|
27666
27667
|
return {
|
|
27667
27668
|
code: NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed",
|
|
27668
27669
|
level: NETWORK.has(code) ? 2 : 3,
|
|
27670
|
+
source: "harness",
|
|
27669
27671
|
reason
|
|
27670
27672
|
};
|
|
27671
27673
|
}
|
|
@@ -27939,9 +27941,13 @@ function executionOwner(environment) {
|
|
|
27939
27941
|
}
|
|
27940
27942
|
return { run: environment.KANBAN_RUN?.trim() || void 0, task: environment.AI4KANBAN_TASK?.trim() || void 0, job: str(execution.job).trim() || void 0 };
|
|
27941
27943
|
}
|
|
27942
|
-
function ownershipConflict(thread, requester, owner, status) {
|
|
27944
|
+
function ownershipConflict(thread, requester, owner, status, phase, wait = false) {
|
|
27943
27945
|
const describe = (value) => ({ run: value?.run ?? "unknown", task: value?.task ?? "unknown", job: value?.job ?? "unknown", pid: value?.pid ?? "unknown", lease: value?.lease ?? "unknown" });
|
|
27944
|
-
|
|
27946
|
+
const evidence = { thread, requester: describe(requester), owner: describe(owner), status, phase };
|
|
27947
|
+
const failure = wait ? { code: "codex_source_busy", level: 2, source: "harness", reason: "Waiting for the source conversation to finish." } : { code: "codex_ownership_unconfirmed", level: 3, source: "invariant", reason: "The conversation could not be opened safely. Saved work was preserved." };
|
|
27948
|
+
if (!wait) console.error(JSON.stringify({ code: failure.code, ...evidence }));
|
|
27949
|
+
const message = status === "caller-does-not-own-thread" ? "This run does not own that Codex thread." : "Codex thread is already in use by another run.";
|
|
27950
|
+
return new RpcError(`${message} ${JSON.stringify(evidence)}`, -32e3, { wildcraneFailure: failure });
|
|
27945
27951
|
}
|
|
27946
27952
|
async function inspectThread(rpc, threadId) {
|
|
27947
27953
|
let snapshot;
|
|
@@ -27978,19 +27984,29 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
27978
27984
|
let closing;
|
|
27979
27985
|
let settled;
|
|
27980
27986
|
let keeper = false;
|
|
27987
|
+
let stoppingForRetry = false;
|
|
27981
27988
|
const state = () => ({ ...identity, lease, instance: backend.instance, settings, threads: [...threads], ...settled ? { retained: settled } : {} });
|
|
27982
27989
|
const owned = (id) => readPrivate(leaseFile(backend, id))?.lease === lease;
|
|
27983
27990
|
const remove = (id) => {
|
|
27984
27991
|
if (owned(id)) fs5.rmSync(leaseFile(backend, id), { force: true });
|
|
27985
27992
|
};
|
|
27986
|
-
const
|
|
27993
|
+
const leaseAt = (id, phase) => {
|
|
27994
|
+
const file = leaseFile(backend, id);
|
|
27995
|
+
try {
|
|
27996
|
+
const current = readPrivate(file);
|
|
27997
|
+
if (current === void 0 || typeof current.lease === "string" && Array.isArray(current.threads)) return current;
|
|
27998
|
+
} catch {
|
|
27999
|
+
}
|
|
28000
|
+
throw ownershipConflict(id, state(), void 0, "invalid-ownership-record", phase);
|
|
28001
|
+
};
|
|
28002
|
+
const claim = (id, loaded = true, previous, forkSource = false) => {
|
|
27987
28003
|
if (!id) return;
|
|
27988
28004
|
const file = leaseFile(backend, id);
|
|
27989
28005
|
const release = tryLock(file + ".lock");
|
|
27990
|
-
if (!release) throw ownershipConflict(id, state(),
|
|
28006
|
+
if (!release) throw ownershipConflict(id, state(), leaseAt(id, "claim-thread"), "ownership-transfer", loaded ? "claim-thread" : "reserve-source", forkSource);
|
|
27991
28007
|
try {
|
|
27992
|
-
const current =
|
|
27993
|
-
if (current && current.lease !== lease && current.lease !== previous?.lease) throw ownershipConflict(id, state(), current, liveLease(current) ? "owner-alive" : "unverified");
|
|
28008
|
+
const current = leaseAt(id, "claim-thread");
|
|
28009
|
+
if (current && current.lease !== lease && current.lease !== previous?.lease) throw ownershipConflict(id, state(), current, liveLease(current) ? "owner-alive" : "unverified", loaded ? "claim-thread" : "reserve-source", forkSource && liveLease(current));
|
|
27994
28010
|
if (loaded) threads.add(id);
|
|
27995
28011
|
writeLease(backend, id, { ...state(), ...previous?.retained ? { retained: previous.retained, adopting: previous.lease } : {} });
|
|
27996
28012
|
for (const thread of threads) {
|
|
@@ -28001,8 +28017,8 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28001
28017
|
release();
|
|
28002
28018
|
}
|
|
28003
28019
|
};
|
|
28004
|
-
const reserve = async (id) => {
|
|
28005
|
-
const previous =
|
|
28020
|
+
const reserve = async (id, forkSource) => {
|
|
28021
|
+
const previous = leaseAt(id, "reserve-source");
|
|
28006
28022
|
if (previous && previous.lease !== lease) {
|
|
28007
28023
|
if (previous.retained) {
|
|
28008
28024
|
if (previous.retained.root !== id) throw Error("Resume the owning Codex thread to adopt its retained work.");
|
|
@@ -28012,19 +28028,19 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28012
28028
|
const key = (value) => JSON.stringify([value.threadId, value.itemId, value.processId]);
|
|
28013
28029
|
if (actual.length !== previous.retained.kept.length || actual.some((value) => !previous.retained.kept.some((item) => key(item) === key(value)))) throw Error("The retained Codex services changed; no new work was submitted.");
|
|
28014
28030
|
} else {
|
|
28015
|
-
if (liveLease(previous)) throw ownershipConflict(id, state(), previous, "owner-alive");
|
|
28031
|
+
if (liveLease(previous)) throw ownershipConflict(id, state(), previous, "owner-alive", "reserve-source", forkSource);
|
|
28016
28032
|
for (const thread of /* @__PURE__ */ new Set([id, ...previous.threads])) {
|
|
28017
28033
|
let status;
|
|
28018
28034
|
try {
|
|
28019
28035
|
status = await inspectThread(connection.rpc, thread);
|
|
28020
28036
|
} catch {
|
|
28021
|
-
throw ownershipConflict(thread, state(), previous, "unverified");
|
|
28037
|
+
throw ownershipConflict(thread, state(), previous, "unverified", "verify-source");
|
|
28022
28038
|
}
|
|
28023
|
-
if (status !== "idle" && status !== "notLoaded") throw ownershipConflict(thread, state(), previous, status === "active" || status === "background-work" ? "work still running; automatic replay refused" : "unverified");
|
|
28039
|
+
if (status !== "idle" && status !== "notLoaded") throw ownershipConflict(thread, state(), previous, status === "active" || status === "background-work" ? "work still running; automatic replay refused" : "unverified", "verify-source");
|
|
28024
28040
|
}
|
|
28025
28041
|
}
|
|
28026
28042
|
}
|
|
28027
|
-
claim(id, false, previous);
|
|
28043
|
+
claim(id, false, previous, forkSource);
|
|
28028
28044
|
preparing.set(id, (preparing.get(id) ?? 0) + 1);
|
|
28029
28045
|
return { previous: previous?.retained ? previous : void 0, release() {
|
|
28030
28046
|
const remaining = preparing.get(id) - 1;
|
|
@@ -28035,6 +28051,10 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28035
28051
|
}
|
|
28036
28052
|
} };
|
|
28037
28053
|
};
|
|
28054
|
+
const failNotification = (error) => {
|
|
28055
|
+
send({ method: "error", params: { error: error instanceof RpcError ? error.data : { message: String(error) } } });
|
|
28056
|
+
void close();
|
|
28057
|
+
};
|
|
28038
28058
|
const notify = (message) => {
|
|
28039
28059
|
const params = obj(message.params), thread = obj(params.thread);
|
|
28040
28060
|
const id = str(params.threadId) || str(thread.id);
|
|
@@ -28048,7 +28068,7 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28048
28068
|
try {
|
|
28049
28069
|
claim(id);
|
|
28050
28070
|
} catch (error) {
|
|
28051
|
-
|
|
28071
|
+
failNotification(error);
|
|
28052
28072
|
return;
|
|
28053
28073
|
}
|
|
28054
28074
|
}
|
|
@@ -28058,14 +28078,14 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28058
28078
|
return;
|
|
28059
28079
|
}
|
|
28060
28080
|
if (message.method === "turn/started") active.set(id, str(obj(params.turn).id));
|
|
28061
|
-
if (message.method === "turn/completed") active.delete(id);
|
|
28081
|
+
if (message.method === "turn/completed" && active.get(id) === str(obj(params.turn).id)) active.delete(id);
|
|
28062
28082
|
const item = obj(params.item);
|
|
28063
28083
|
const children = item.type === "subAgentActivity" && item.kind === "started" ? [item.agentThreadId] : item.type === "collabAgentToolCall" && item.tool === "spawnAgent" && Array.isArray(item.receiverThreadIds) ? item.receiverThreadIds : [];
|
|
28064
28084
|
for (const child of children) if (typeof child === "string" && !threads.has(child)) {
|
|
28065
28085
|
try {
|
|
28066
28086
|
claim(child);
|
|
28067
28087
|
} catch (error) {
|
|
28068
|
-
|
|
28088
|
+
failNotification(error);
|
|
28069
28089
|
return;
|
|
28070
28090
|
}
|
|
28071
28091
|
}
|
|
@@ -28129,6 +28149,52 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28129
28149
|
connection.close();
|
|
28130
28150
|
}
|
|
28131
28151
|
})();
|
|
28152
|
+
const stopForRetry = async (params) => {
|
|
28153
|
+
const threadId = str(params.threadId), turnId = str(params.turnId);
|
|
28154
|
+
if (params.instance !== backend.instance || params.lease !== lease || !turnId || active.get(threadId) !== turnId || !owned(threadId)) {
|
|
28155
|
+
throw ownershipConflict(threadId, state(), threadId ? leaseAt(threadId, "stop-idle-turn") : void 0, "idle-turn-ownership-unconfirmed", "stop-idle-turn");
|
|
28156
|
+
}
|
|
28157
|
+
stoppingForRetry = true;
|
|
28158
|
+
const otherWork = pending.size || requests.size || active.size !== 1;
|
|
28159
|
+
await bounded(connection.rpc.call("turn/interrupt", { threadId, turnId }), CODEX_TIMEOUT, "Codex did not acknowledge interrupting the idle turn.");
|
|
28160
|
+
if (otherWork) throw Error("Other Codex operations were pending when the idle turn was interrupted.");
|
|
28161
|
+
const deadline = Date.now() + CODEX_TIMEOUT;
|
|
28162
|
+
const call = (method, input) => bounded(connection.rpc.call(method, input), deadline - Date.now(), "Codex did not confirm the idle turn stopped.");
|
|
28163
|
+
for (; ; ) {
|
|
28164
|
+
const snapshot = obj((await call("thread/read", { threadId, includeTurns: false })).thread);
|
|
28165
|
+
if (snapshot.id !== threadId || closing) throw Error("Codex session availability could not be confirmed.");
|
|
28166
|
+
if (obj(snapshot.status).type === "idle" && !active.has(threadId)) {
|
|
28167
|
+
const paginated = snapshot.historyMode === "paginated";
|
|
28168
|
+
const listed = paginated ? (await call("thread/turns/list", { threadId, sortDirection: "desc", limit: 1, itemsView: "full" })).data : obj((await call("thread/read", { threadId, includeTurns: true })).thread).turns;
|
|
28169
|
+
const turns = Array.isArray(listed) ? listed.map(obj) : [];
|
|
28170
|
+
const turn = turns.at(paginated ? 0 : -1);
|
|
28171
|
+
if (turn?.id !== turnId || turn.status !== "interrupted" || !Array.isArray(turn.items)) {
|
|
28172
|
+
throw Error("Codex did not record the interrupted turn in the original session.");
|
|
28173
|
+
}
|
|
28174
|
+
if (turn.items.map(obj).some((item) => ["inProgress", "interrupted"].includes(str(item.status)) || item.type === "commandExecution" && typeof item.exitCode !== "number")) {
|
|
28175
|
+
throw Error("Codex has operations with unconfirmed results.");
|
|
28176
|
+
}
|
|
28177
|
+
break;
|
|
28178
|
+
}
|
|
28179
|
+
if (Date.now() >= deadline) throw Error("Codex did not confirm the idle turn stopped.");
|
|
28180
|
+
await delay(50);
|
|
28181
|
+
}
|
|
28182
|
+
const claimed = [...threads];
|
|
28183
|
+
for (const thread of claimed) {
|
|
28184
|
+
if (!owned(thread) || active.has(thread) || requests.size || closing) throw Error("Codex ownership or pending operations changed during interruption.");
|
|
28185
|
+
const status = await bounded(inspectThread(connection.rpc, thread), CODEX_TIMEOUT, "Codex work is unconfirmed after interruption.");
|
|
28186
|
+
if (status !== "idle" && (thread === threadId || status !== "notLoaded")) throw Error("Codex has unfinished work after interruption.");
|
|
28187
|
+
}
|
|
28188
|
+
await Promise.all(claimed.map((thread) => releaseNativeThread(connection, thread, void 0, false, unloading)));
|
|
28189
|
+
if (active.size || requests.size || threads.size !== claimed.length || claimed.some((thread) => !owned(thread)) || closing) {
|
|
28190
|
+
throw Error("Codex ownership or pending operations changed during release.");
|
|
28191
|
+
}
|
|
28192
|
+
for (const thread of claimed) {
|
|
28193
|
+
remove(thread);
|
|
28194
|
+
threads.delete(thread);
|
|
28195
|
+
}
|
|
28196
|
+
return { instance: backend.instance, lease, threadId, turnId };
|
|
28197
|
+
};
|
|
28132
28198
|
const request = async (message) => {
|
|
28133
28199
|
const id = message.id;
|
|
28134
28200
|
let source, previous;
|
|
@@ -28144,14 +28210,19 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28144
28210
|
else connection.rpc.reply(id, obj(message.result));
|
|
28145
28211
|
return;
|
|
28146
28212
|
}
|
|
28147
|
-
if (closing) throw Error("Codex execution is stopping.");
|
|
28213
|
+
if (closing || stoppingForRetry) throw Error("Codex execution is stopping.");
|
|
28148
28214
|
if (keeper) throw Error("Codex execution already handed off its retained services.");
|
|
28149
28215
|
if (message.method === "initialize") {
|
|
28150
|
-
send({ id, result: { ...initialized, wildcrane: { instance: backend.instance, lease } } });
|
|
28216
|
+
send({ id, result: { ...initialized, wildcrane: { instance: backend.instance, lease, idleRecovery: true } } });
|
|
28151
28217
|
return;
|
|
28152
28218
|
}
|
|
28153
28219
|
if (message.method === "initialized") return;
|
|
28154
28220
|
let params = obj(message.params);
|
|
28221
|
+
if (message.method === "wildcrane/stopForRetry") {
|
|
28222
|
+
const result2 = await stopForRetry(params);
|
|
28223
|
+
send({ id, result: result2 });
|
|
28224
|
+
return;
|
|
28225
|
+
}
|
|
28155
28226
|
if (message.method === "wildcrane/settled") {
|
|
28156
28227
|
if (params.instance !== backend.instance || params.lease !== lease || !threads.has(str(params.threadId)) || params.confirmed !== true || !str(params.execution)) throw Error("Codex cleanup ownership is unconfirmed.");
|
|
28157
28228
|
const kept = Array.isArray(params.kept) ? params.kept.map(obj) : [];
|
|
@@ -28171,9 +28242,9 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28171
28242
|
if (["thread/start", "thread/resume", "thread/fork"].includes(message.method)) {
|
|
28172
28243
|
if (message.method !== "thread/start") {
|
|
28173
28244
|
const id2 = str(params.threadId);
|
|
28174
|
-
if (message.method !== "thread/fork" || !
|
|
28245
|
+
if (message.method !== "thread/fork" || !leaseAt(id2, "reserve-source")?.retained) {
|
|
28175
28246
|
source = id2;
|
|
28176
|
-
const reservation = await reserve(source);
|
|
28247
|
+
const reservation = await reserve(source, message.method === "thread/fork");
|
|
28177
28248
|
previous = reservation.previous;
|
|
28178
28249
|
releaseSource = reservation.release;
|
|
28179
28250
|
}
|
|
@@ -28184,12 +28255,15 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28184
28255
|
params = { ...params, cwd: params.cwd ?? cwd, config: overrides };
|
|
28185
28256
|
} else {
|
|
28186
28257
|
const thread2 = str(params.threadId);
|
|
28187
|
-
if (!threads.has(thread2) || !owned(thread2)) throw
|
|
28258
|
+
if (!threads.has(thread2) || !owned(thread2)) throw ownershipConflict(thread2, state(), thread2 ? readPrivate(leaseFile(backend, thread2)) : void 0, "caller-does-not-own-thread", message.method);
|
|
28188
28259
|
}
|
|
28189
28260
|
if (message.method === "turn/start") settled = void 0;
|
|
28190
28261
|
const result = await connection.rpc.call(message.method, params);
|
|
28191
28262
|
if (message.method === "thread/resume" && !previous?.retained && str(config.model) && result.model && result.model !== config.model) throw Error("The previous Codex runtime has not unloaded; new execution settings were not applied. No new work was submitted.");
|
|
28192
28263
|
const thread = str(obj(result.thread).id);
|
|
28264
|
+
if (!thread && ["thread/start", "thread/resume", "thread/fork"].includes(message.method)) {
|
|
28265
|
+
throw ownershipConflict(source ?? "", state(), void 0, "missing-thread-id", message.method);
|
|
28266
|
+
}
|
|
28193
28267
|
if (thread) claim(thread, true, message.method === "thread/resume" ? previous : void 0);
|
|
28194
28268
|
if (previous?.retained && message.method === "thread/resume") {
|
|
28195
28269
|
for (const child of previous.threads) if (child !== thread) {
|
|
@@ -28250,7 +28324,7 @@ function executorRecord() {
|
|
|
28250
28324
|
}
|
|
28251
28325
|
|
|
28252
28326
|
// src/codex-server.ts
|
|
28253
|
-
var
|
|
28327
|
+
var delay2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
28254
28328
|
async function requestCodexBackend(argv, env) {
|
|
28255
28329
|
const until = Date.now() + CODEX_TIMEOUT;
|
|
28256
28330
|
for (; ; ) {
|
|
@@ -28286,7 +28360,7 @@ async function requestCodexBackend(argv, env) {
|
|
|
28286
28360
|
}
|
|
28287
28361
|
}
|
|
28288
28362
|
if (Date.now() >= until) throw Error("No active Runner could prepare Codex. Existing work was preserved.");
|
|
28289
|
-
await
|
|
28363
|
+
await delay2(50);
|
|
28290
28364
|
}
|
|
28291
28365
|
}
|
|
28292
28366
|
|
package/dist/codex-retained.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.93 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|
|
@@ -26868,6 +26868,7 @@ function executionFailure(error) {
|
|
|
26868
26868
|
return {
|
|
26869
26869
|
code: NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed",
|
|
26870
26870
|
level: NETWORK.has(code) ? 2 : 3,
|
|
26871
|
+
source: "harness",
|
|
26871
26872
|
reason
|
|
26872
26873
|
};
|
|
26873
26874
|
}
|