wildcrane-runner 0.6.106 → 0.6.107
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 +13 -4
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +136 -45
- package/dist/codex-retained.mjs +93 -38
- package/dist/flow-worker-main.mjs +14 -5
- package/dist/launcher.mjs +15 -6
- package/dist/plugin.mjs +35 -15
- package/dist/runner.mjs +122 -52
- package/dist/settings.mjs +15 -6
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.87 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -22831,7 +22831,7 @@ var init_package = __esm({
|
|
|
22831
22831
|
"../cli/package.json"() {
|
|
22832
22832
|
package_default = {
|
|
22833
22833
|
name: "wildcrane",
|
|
22834
|
-
version: "0.11.
|
|
22834
|
+
version: "0.11.87",
|
|
22835
22835
|
akbContract: 29,
|
|
22836
22836
|
description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
22837
22837
|
keywords: [
|
|
@@ -27145,6 +27145,7 @@ async function run(io, options, count3) {
|
|
|
27145
27145
|
const execution = randomUUID4();
|
|
27146
27146
|
let host2 = {};
|
|
27147
27147
|
let cleanup = { status: "confirmed", execution, kept: [] };
|
|
27148
|
+
let hostCleanup;
|
|
27148
27149
|
let settlement;
|
|
27149
27150
|
let replySnapshots = /* @__PURE__ */ new Map();
|
|
27150
27151
|
const visible = /* @__PURE__ */ new Set();
|
|
@@ -27201,11 +27202,11 @@ async function run(io, options, count3) {
|
|
|
27201
27202
|
};
|
|
27202
27203
|
const closed2 = () => {
|
|
27203
27204
|
const reason = "Codex connection closed before all work and results finished.";
|
|
27204
|
-
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
27205
|
+
if (hostCleanup !== "confirmed" && work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
27205
27206
|
end2(reason, makeFailure("runtime", reason, { code: "connection_lost", detail: reason }));
|
|
27206
27207
|
};
|
|
27207
27208
|
const inputFailed = (e) => {
|
|
27208
|
-
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
27209
|
+
if (hostCleanup !== "confirmed" && work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
27209
27210
|
end2(e.message, executionFailure(e));
|
|
27210
27211
|
};
|
|
27211
27212
|
io.stdout.once("close", closed2);
|
|
@@ -27428,6 +27429,14 @@ async function run(io, options, count3) {
|
|
|
27428
27429
|
return;
|
|
27429
27430
|
}
|
|
27430
27431
|
const p = obj2(msg.params);
|
|
27432
|
+
if (msg.method === "wildcrane/cleanup") {
|
|
27433
|
+
if (p.status === "confirmed") hostCleanup = "confirmed";
|
|
27434
|
+
else if (p.status === "unconfirmed") {
|
|
27435
|
+
hostCleanup = "unconfirmed";
|
|
27436
|
+
note(str2(p.diagnostic) || "Codex cleanup is unconfirmed.");
|
|
27437
|
+
}
|
|
27438
|
+
return;
|
|
27439
|
+
}
|
|
27431
27440
|
const source2 = str2(p.threadId);
|
|
27432
27441
|
if (!work.own(source2)) return;
|
|
27433
27442
|
if (msg.method === "item/commandExecution/terminalInteraction") {
|
package/dist/akb/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"wildcrane","version":"0.11.
|
|
1
|
+
{"name":"wildcrane","version":"0.11.87","akbContract":29,"type":"module","private":true}
|
package/dist/akb-proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.107 — 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.107 — 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;
|
|
@@ -2638,33 +2638,33 @@ var require_stats = __commonJS({
|
|
|
2638
2638
|
var require_diagnostics = __commonJS({
|
|
2639
2639
|
"node_modules/undici/lib/core/diagnostics.js"(exports, module) {
|
|
2640
2640
|
"use strict";
|
|
2641
|
-
var
|
|
2641
|
+
var diagnosticsChannel2 = __require("node:diagnostics_channel");
|
|
2642
2642
|
var util = __require("node:util");
|
|
2643
2643
|
var undiciDebugLog = util.debuglog("undici");
|
|
2644
2644
|
var fetchDebuglog = util.debuglog("fetch");
|
|
2645
2645
|
var websocketDebuglog = util.debuglog("websocket");
|
|
2646
2646
|
var channels = {
|
|
2647
2647
|
// Client
|
|
2648
|
-
beforeConnect:
|
|
2649
|
-
connected:
|
|
2650
|
-
connectError:
|
|
2651
|
-
sendHeaders:
|
|
2648
|
+
beforeConnect: diagnosticsChannel2.channel("undici:client:beforeConnect"),
|
|
2649
|
+
connected: diagnosticsChannel2.channel("undici:client:connected"),
|
|
2650
|
+
connectError: diagnosticsChannel2.channel("undici:client:connectError"),
|
|
2651
|
+
sendHeaders: diagnosticsChannel2.channel("undici:client:sendHeaders"),
|
|
2652
2652
|
// Request
|
|
2653
|
-
create:
|
|
2654
|
-
bodySent:
|
|
2655
|
-
bodyChunkSent:
|
|
2656
|
-
bodyChunkReceived:
|
|
2657
|
-
headers:
|
|
2658
|
-
trailers:
|
|
2659
|
-
error:
|
|
2653
|
+
create: diagnosticsChannel2.channel("undici:request:create"),
|
|
2654
|
+
bodySent: diagnosticsChannel2.channel("undici:request:bodySent"),
|
|
2655
|
+
bodyChunkSent: diagnosticsChannel2.channel("undici:request:bodyChunkSent"),
|
|
2656
|
+
bodyChunkReceived: diagnosticsChannel2.channel("undici:request:bodyChunkReceived"),
|
|
2657
|
+
headers: diagnosticsChannel2.channel("undici:request:headers"),
|
|
2658
|
+
trailers: diagnosticsChannel2.channel("undici:request:trailers"),
|
|
2659
|
+
error: diagnosticsChannel2.channel("undici:request:error"),
|
|
2660
2660
|
// WebSocket
|
|
2661
|
-
open:
|
|
2662
|
-
close:
|
|
2663
|
-
socketError:
|
|
2664
|
-
ping:
|
|
2665
|
-
pong:
|
|
2661
|
+
open: diagnosticsChannel2.channel("undici:websocket:open"),
|
|
2662
|
+
close: diagnosticsChannel2.channel("undici:websocket:close"),
|
|
2663
|
+
socketError: diagnosticsChannel2.channel("undici:websocket:socket_error"),
|
|
2664
|
+
ping: diagnosticsChannel2.channel("undici:websocket:ping"),
|
|
2665
|
+
pong: diagnosticsChannel2.channel("undici:websocket:pong"),
|
|
2666
2666
|
// ProxyAgent
|
|
2667
|
-
proxyConnected:
|
|
2667
|
+
proxyConnected: diagnosticsChannel2.channel("undici:proxy:connected")
|
|
2668
2668
|
};
|
|
2669
2669
|
var isTrackingClientEvents = false;
|
|
2670
2670
|
function trackClientEvents(debugLog = undiciDebugLog) {
|
|
@@ -2676,7 +2676,7 @@ var require_diagnostics = __commonJS({
|
|
|
2676
2676
|
return;
|
|
2677
2677
|
}
|
|
2678
2678
|
isTrackingClientEvents = true;
|
|
2679
|
-
|
|
2679
|
+
diagnosticsChannel2.subscribe(
|
|
2680
2680
|
"undici:client:beforeConnect",
|
|
2681
2681
|
(evt) => {
|
|
2682
2682
|
const {
|
|
@@ -2691,7 +2691,7 @@ var require_diagnostics = __commonJS({
|
|
|
2691
2691
|
);
|
|
2692
2692
|
}
|
|
2693
2693
|
);
|
|
2694
|
-
|
|
2694
|
+
diagnosticsChannel2.subscribe(
|
|
2695
2695
|
"undici:client:connected",
|
|
2696
2696
|
(evt) => {
|
|
2697
2697
|
const {
|
|
@@ -2706,7 +2706,7 @@ var require_diagnostics = __commonJS({
|
|
|
2706
2706
|
);
|
|
2707
2707
|
}
|
|
2708
2708
|
);
|
|
2709
|
-
|
|
2709
|
+
diagnosticsChannel2.subscribe(
|
|
2710
2710
|
"undici:client:connectError",
|
|
2711
2711
|
(evt) => {
|
|
2712
2712
|
const {
|
|
@@ -2723,7 +2723,7 @@ var require_diagnostics = __commonJS({
|
|
|
2723
2723
|
);
|
|
2724
2724
|
}
|
|
2725
2725
|
);
|
|
2726
|
-
|
|
2726
|
+
diagnosticsChannel2.subscribe(
|
|
2727
2727
|
"undici:client:sendHeaders",
|
|
2728
2728
|
(evt) => {
|
|
2729
2729
|
const {
|
|
@@ -2743,7 +2743,7 @@ var require_diagnostics = __commonJS({
|
|
|
2743
2743
|
return;
|
|
2744
2744
|
}
|
|
2745
2745
|
isTrackingRequestEvents = true;
|
|
2746
|
-
|
|
2746
|
+
diagnosticsChannel2.subscribe(
|
|
2747
2747
|
"undici:request:headers",
|
|
2748
2748
|
(evt) => {
|
|
2749
2749
|
const {
|
|
@@ -2759,7 +2759,7 @@ var require_diagnostics = __commonJS({
|
|
|
2759
2759
|
);
|
|
2760
2760
|
}
|
|
2761
2761
|
);
|
|
2762
|
-
|
|
2762
|
+
diagnosticsChannel2.subscribe(
|
|
2763
2763
|
"undici:request:trailers",
|
|
2764
2764
|
(evt) => {
|
|
2765
2765
|
const {
|
|
@@ -2768,7 +2768,7 @@ var require_diagnostics = __commonJS({
|
|
|
2768
2768
|
debugLog("trailers received from %s %s%s", method, origin, path9);
|
|
2769
2769
|
}
|
|
2770
2770
|
);
|
|
2771
|
-
|
|
2771
|
+
diagnosticsChannel2.subscribe(
|
|
2772
2772
|
"undici:request:error",
|
|
2773
2773
|
(evt) => {
|
|
2774
2774
|
const {
|
|
@@ -2795,7 +2795,7 @@ var require_diagnostics = __commonJS({
|
|
|
2795
2795
|
return;
|
|
2796
2796
|
}
|
|
2797
2797
|
isTrackingWebSocketEvents = true;
|
|
2798
|
-
|
|
2798
|
+
diagnosticsChannel2.subscribe(
|
|
2799
2799
|
"undici:websocket:open",
|
|
2800
2800
|
(evt) => {
|
|
2801
2801
|
if (evt.address != null) {
|
|
@@ -2806,7 +2806,7 @@ var require_diagnostics = __commonJS({
|
|
|
2806
2806
|
}
|
|
2807
2807
|
}
|
|
2808
2808
|
);
|
|
2809
|
-
|
|
2809
|
+
diagnosticsChannel2.subscribe(
|
|
2810
2810
|
"undici:websocket:close",
|
|
2811
2811
|
(evt) => {
|
|
2812
2812
|
const { websocket, code, reason } = evt;
|
|
@@ -2818,19 +2818,19 @@ var require_diagnostics = __commonJS({
|
|
|
2818
2818
|
);
|
|
2819
2819
|
}
|
|
2820
2820
|
);
|
|
2821
|
-
|
|
2821
|
+
diagnosticsChannel2.subscribe(
|
|
2822
2822
|
"undici:websocket:socket_error",
|
|
2823
2823
|
(err) => {
|
|
2824
2824
|
debugLog("connection errored - %s", err.message);
|
|
2825
2825
|
}
|
|
2826
2826
|
);
|
|
2827
|
-
|
|
2827
|
+
diagnosticsChannel2.subscribe(
|
|
2828
2828
|
"undici:websocket:ping",
|
|
2829
2829
|
(evt) => {
|
|
2830
2830
|
debugLog("ping received");
|
|
2831
2831
|
}
|
|
2832
2832
|
);
|
|
2833
|
-
|
|
2833
|
+
diagnosticsChannel2.subscribe(
|
|
2834
2834
|
"undici:websocket:pong",
|
|
2835
2835
|
(evt) => {
|
|
2836
2836
|
debugLog("pong received");
|
|
@@ -19729,11 +19729,11 @@ var require_deduplication_handler = __commonJS({
|
|
|
19729
19729
|
var require_deduplicate = __commonJS({
|
|
19730
19730
|
"node_modules/undici/lib/interceptor/deduplicate.js"(exports, module) {
|
|
19731
19731
|
"use strict";
|
|
19732
|
-
var
|
|
19732
|
+
var diagnosticsChannel2 = __require("node:diagnostics_channel");
|
|
19733
19733
|
var util = require_util();
|
|
19734
19734
|
var DeduplicationHandler = require_deduplication_handler();
|
|
19735
19735
|
var { normalizeHeaders, makeCacheKey, makeDeduplicationKey } = require_cache();
|
|
19736
|
-
var pendingRequestsChannel =
|
|
19736
|
+
var pendingRequestsChannel = diagnosticsChannel2.channel("undici:request:pending-requests");
|
|
19737
19737
|
module.exports = (opts = {}) => {
|
|
19738
19738
|
const {
|
|
19739
19739
|
methods = ["GET"],
|
|
@@ -27804,6 +27804,7 @@ import path6 from "node:path";
|
|
|
27804
27804
|
|
|
27805
27805
|
// src/codex-native.ts
|
|
27806
27806
|
import crypto from "node:crypto";
|
|
27807
|
+
import diagnosticsChannel from "node:diagnostics_channel";
|
|
27807
27808
|
import fs4 from "node:fs";
|
|
27808
27809
|
var import_undici2 = __toESM(require_undici(), 1);
|
|
27809
27810
|
import path5 from "node:path";
|
|
@@ -27848,6 +27849,7 @@ var nativeDirectory = () => path5.join(runnerCwd(), "codex-native");
|
|
|
27848
27849
|
var codexRecordFile = () => path5.join(nativeDirectory(), "runner.json");
|
|
27849
27850
|
var backendFile = (key) => path5.join(nativeDirectory(), `${key}.json`);
|
|
27850
27851
|
var leaseFile = (backend, thread) => path5.join(nativeDirectory(), "threads", backend.instance, `${crypto.createHash("sha256").update(thread).digest("hex")}.json`);
|
|
27852
|
+
var liveBackend = (backend) => !connectionStopped(backend);
|
|
27851
27853
|
var liveLease = (lease) => !connectionStopped(lease);
|
|
27852
27854
|
var processIdentity = () => ({ pid: process.pid, identity: connectionIdentity(process.pid) });
|
|
27853
27855
|
function writePrivate(file, value) {
|
|
@@ -27867,9 +27869,41 @@ function readPrivate(file) {
|
|
|
27867
27869
|
function writeLease(backend, thread, value) {
|
|
27868
27870
|
writePrivate(leaseFile(backend, thread), { ...value, thread });
|
|
27869
27871
|
}
|
|
27872
|
+
function nativeErrorText(error) {
|
|
27873
|
+
if (!error) return "";
|
|
27874
|
+
if (error instanceof RpcError) return `RPC ${error.code ?? "unknown"}: ${error.message}`;
|
|
27875
|
+
if (error instanceof Error) {
|
|
27876
|
+
const code = error.code;
|
|
27877
|
+
const text = error.message.trim() || error.name;
|
|
27878
|
+
return code && !text.includes(code) ? `${code}: ${text}` : text;
|
|
27879
|
+
}
|
|
27880
|
+
return String(error);
|
|
27881
|
+
}
|
|
27882
|
+
function nativeEventDetail(event, fallback) {
|
|
27883
|
+
const value = event;
|
|
27884
|
+
const message = typeof value.message === "string" && value.message.trim() && value.message !== "undefined" ? value.message.trim() : "";
|
|
27885
|
+
const code = typeof value.code === "number" ? `code ${value.code}${value.reason ? `: ${value.reason}` : ""}` : "";
|
|
27886
|
+
const error = value.error instanceof Error && !value.error.message.trim() ? "" : nativeErrorText(value.error);
|
|
27887
|
+
return fallback || error || message || code || nativeErrorText(value.error);
|
|
27888
|
+
}
|
|
27870
27889
|
async function nativeConnection(backend, onMessage) {
|
|
27871
27890
|
const unix = backend.endpoint.startsWith("unix://");
|
|
27872
|
-
const
|
|
27891
|
+
const socketPath = unix ? backend.endpoint.slice(7) : void 0;
|
|
27892
|
+
const dispatcher = unix ? new import_undici2.Agent({ connect: { socketPath } }) : void 0;
|
|
27893
|
+
let lastError = "";
|
|
27894
|
+
const onSocketError = (err) => {
|
|
27895
|
+
lastError = nativeErrorText(err) || lastError;
|
|
27896
|
+
};
|
|
27897
|
+
const onConnectError = (data) => {
|
|
27898
|
+
const record = data;
|
|
27899
|
+
if (!socketPath || record.connectParams?.socketPath === socketPath) lastError = nativeErrorText(record.error) || lastError;
|
|
27900
|
+
};
|
|
27901
|
+
diagnosticsChannel.subscribe("undici:websocket:socket_error", onSocketError);
|
|
27902
|
+
diagnosticsChannel.subscribe("undici:client:connectError", onConnectError);
|
|
27903
|
+
const unsubscribeDiagnostics = () => {
|
|
27904
|
+
diagnosticsChannel.unsubscribe("undici:websocket:socket_error", onSocketError);
|
|
27905
|
+
diagnosticsChannel.unsubscribe("undici:client:connectError", onConnectError);
|
|
27906
|
+
};
|
|
27873
27907
|
const ws = new import_undici2.WebSocket(unix ? "ws://localhost" : backend.endpoint, {
|
|
27874
27908
|
...dispatcher ? { dispatcher } : {},
|
|
27875
27909
|
...backend.token ? { headers: { authorization: `Bearer ${backend.token}` } } : {}
|
|
@@ -27887,11 +27921,30 @@ async function nativeConnection(backend, onMessage) {
|
|
|
27887
27921
|
});
|
|
27888
27922
|
outgoing.on("error", () => {
|
|
27889
27923
|
});
|
|
27924
|
+
let closing = false;
|
|
27890
27925
|
ws.addEventListener("message", (event) => incoming.write(String(event.data) + "\n"));
|
|
27891
|
-
ws.addEventListener("close", () =>
|
|
27892
|
-
|
|
27926
|
+
ws.addEventListener("close", (event) => {
|
|
27927
|
+
unsubscribeDiagnostics();
|
|
27928
|
+
if (!closing && !incoming.destroyed && (!event.wasClean || event.code !== 1e3 && event.code !== 1005)) {
|
|
27929
|
+
const detail = nativeEventDetail(event, lastError);
|
|
27930
|
+
const message = detail ? `Codex native connection closed (${detail}).` : "Codex native connection closed.";
|
|
27931
|
+
console.error(message);
|
|
27932
|
+
incoming.destroy(Error(message));
|
|
27933
|
+
return;
|
|
27934
|
+
}
|
|
27935
|
+
incoming.destroy();
|
|
27936
|
+
});
|
|
27937
|
+
ws.addEventListener("error", (event) => {
|
|
27938
|
+
if (closing || incoming.destroyed) return;
|
|
27939
|
+
const detail = nativeEventDetail(event, lastError);
|
|
27940
|
+
const message = detail ? `Codex native connection failed: ${detail}` : "Codex native connection failed.";
|
|
27941
|
+
console.error(message);
|
|
27942
|
+
incoming.destroy(Error(message));
|
|
27943
|
+
});
|
|
27893
27944
|
const close = () => {
|
|
27894
|
-
|
|
27945
|
+
closing = true;
|
|
27946
|
+
unsubscribeDiagnostics();
|
|
27947
|
+
if (ws.readyState === import_undici2.WebSocket.OPEN || ws.readyState === import_undici2.WebSocket.CONNECTING) ws.close();
|
|
27895
27948
|
incoming.destroy();
|
|
27896
27949
|
outgoing.destroy();
|
|
27897
27950
|
void dispatcher?.destroy();
|
|
@@ -27899,7 +27952,10 @@ async function nativeConnection(backend, onMessage) {
|
|
|
27899
27952
|
try {
|
|
27900
27953
|
await bounded(new Promise((resolve, reject) => {
|
|
27901
27954
|
ws.addEventListener("open", () => resolve(), { once: true });
|
|
27902
|
-
ws.addEventListener("error", () =>
|
|
27955
|
+
ws.addEventListener("error", (event) => {
|
|
27956
|
+
const detail = nativeEventDetail(event, lastError);
|
|
27957
|
+
reject(Error(detail ? `Codex native listener did not answer (${detail}).` : "Codex native listener did not answer."));
|
|
27958
|
+
}, { once: true });
|
|
27903
27959
|
}), CODEX_TIMEOUT, "Codex native connection timed out.");
|
|
27904
27960
|
} catch (error) {
|
|
27905
27961
|
close();
|
|
@@ -28282,16 +28338,51 @@ async function codexExecution(backend, config, environment, cwd, send) {
|
|
|
28282
28338
|
}
|
|
28283
28339
|
};
|
|
28284
28340
|
const cleanup = async () => {
|
|
28341
|
+
const dropped = connection.incoming.destroyed;
|
|
28285
28342
|
await bounded(Promise.allSettled(pending), CODEX_TIMEOUT, "Codex pending requests did not settle.");
|
|
28286
28343
|
if (keeper) return;
|
|
28287
28344
|
for (const id of requests) connection.rpc.refuse(id, "Execution disconnected.");
|
|
28288
|
-
const
|
|
28289
|
-
|
|
28290
|
-
|
|
28291
|
-
|
|
28292
|
-
|
|
28293
|
-
|
|
28294
|
-
|
|
28345
|
+
const remaining = () => [...threads].filter((id) => owned(id));
|
|
28346
|
+
let failure;
|
|
28347
|
+
if (!connection.incoming.destroyed && remaining().length) {
|
|
28348
|
+
const results = await Promise.allSettled(remaining().map(async (id) => {
|
|
28349
|
+
await releaseNativeThread(connection, id, active.get(id), !settled);
|
|
28350
|
+
remove(id);
|
|
28351
|
+
}));
|
|
28352
|
+
const rejected = results.find((result) => result.status === "rejected");
|
|
28353
|
+
if (rejected?.status === "rejected") failure = rejected.reason;
|
|
28354
|
+
}
|
|
28355
|
+
if (connection.incoming.destroyed && remaining().length) {
|
|
28356
|
+
if (!liveBackend(backend)) {
|
|
28357
|
+
for (const id of remaining()) remove(id);
|
|
28358
|
+
failure = void 0;
|
|
28359
|
+
} else {
|
|
28360
|
+
const deadline = Date.now() + CODEX_TIMEOUT;
|
|
28361
|
+
let probe;
|
|
28362
|
+
try {
|
|
28363
|
+
probe = await nativeConnection(backend, () => {
|
|
28364
|
+
});
|
|
28365
|
+
await initializeNative(probe);
|
|
28366
|
+
const results = await Promise.allSettled(remaining().map(async (id) => {
|
|
28367
|
+
await releaseNativeThread(probe, id, active.get(id), !settled, deadline);
|
|
28368
|
+
remove(id);
|
|
28369
|
+
}));
|
|
28370
|
+
const rejected = results.find((result) => result.status === "rejected");
|
|
28371
|
+
failure = rejected?.status === "rejected" ? rejected.reason : void 0;
|
|
28372
|
+
} catch (error) {
|
|
28373
|
+
if (!liveBackend(backend)) {
|
|
28374
|
+
for (const id of remaining()) remove(id);
|
|
28375
|
+
failure = void 0;
|
|
28376
|
+
} else {
|
|
28377
|
+
failure = error ?? failure;
|
|
28378
|
+
}
|
|
28379
|
+
} finally {
|
|
28380
|
+
probe?.close();
|
|
28381
|
+
}
|
|
28382
|
+
}
|
|
28383
|
+
}
|
|
28384
|
+
if (failure !== void 0) throw failure;
|
|
28385
|
+
if (dropped || connection.incoming.destroyed) send({ method: "wildcrane/cleanup", params: { status: "confirmed", lease } });
|
|
28295
28386
|
};
|
|
28296
28387
|
const close = () => closing ??= (async () => {
|
|
28297
28388
|
try {
|