wildcrane-runner 0.6.75 → 0.6.77
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 +615 -251
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +105 -249
- package/dist/codex-service-main.mjs +184 -229
- package/dist/flow-worker-main.mjs +557 -241
- package/dist/launcher.mjs +452 -173
- package/dist/plugin.mjs +471 -192
- package/dist/runner.mjs +778 -468
- package/dist/settings.mjs +446 -167
- package/package.json +1 -1
- package/dist/akb/dist/retire-legacy.mjs +0 -5337
package/dist/codex-proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.77 — 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;
|
|
@@ -2136,13 +2136,13 @@ var require_util = __commonJS({
|
|
|
2136
2136
|
function isFormDataLike(object) {
|
|
2137
2137
|
return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
|
|
2138
2138
|
}
|
|
2139
|
-
function addAbortListener(
|
|
2140
|
-
if ("addEventListener" in
|
|
2141
|
-
|
|
2142
|
-
return () =>
|
|
2139
|
+
function addAbortListener(signal, listener) {
|
|
2140
|
+
if ("addEventListener" in signal) {
|
|
2141
|
+
signal.addEventListener("abort", listener, { once: true });
|
|
2142
|
+
return () => signal.removeEventListener("abort", listener);
|
|
2143
2143
|
}
|
|
2144
|
-
|
|
2145
|
-
return () =>
|
|
2144
|
+
signal.once("abort", listener);
|
|
2145
|
+
return () => signal.removeListener("abort", listener);
|
|
2146
2146
|
}
|
|
2147
2147
|
var validTokenChars = new Uint8Array([
|
|
2148
2148
|
0,
|
|
@@ -8987,7 +8987,7 @@ var require_client_h2 = __commonJS({
|
|
|
8987
8987
|
const headersTimeout = request.headersTimeout ?? client[kHeadersTimeout];
|
|
8988
8988
|
const bodyTimeout = request.bodyTimeout ?? client[kBodyTimeout];
|
|
8989
8989
|
const session = client[kHTTP2Session];
|
|
8990
|
-
const { method, path: path8, host, upgrade, expectContinue, signal
|
|
8990
|
+
const { method, path: path8, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request;
|
|
8991
8991
|
let { body } = request;
|
|
8992
8992
|
if (upgrade != null && upgrade !== "websocket") {
|
|
8993
8993
|
util.errorRequest(client, request, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
|
|
@@ -9062,7 +9062,7 @@ var require_client_h2 = __commonJS({
|
|
|
9062
9062
|
} else {
|
|
9063
9063
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
9064
9064
|
}
|
|
9065
|
-
stream = session.request(headers, { endStream: false, signal
|
|
9065
|
+
stream = session.request(headers, { endStream: false, signal });
|
|
9066
9066
|
stream[kHTTP2Stream] = true;
|
|
9067
9067
|
++session[kOpenStreams];
|
|
9068
9068
|
stream.once("response", (headers2, _flags) => {
|
|
@@ -9087,7 +9087,7 @@ var require_client_h2 = __commonJS({
|
|
|
9087
9087
|
stream.setTimeout(headersTimeout);
|
|
9088
9088
|
return true;
|
|
9089
9089
|
}
|
|
9090
|
-
stream = session.request(headers, { endStream: false, signal
|
|
9090
|
+
stream = session.request(headers, { endStream: false, signal });
|
|
9091
9091
|
stream[kHTTP2Stream] = true;
|
|
9092
9092
|
++session[kOpenStreams];
|
|
9093
9093
|
stream.on("response", (headers2) => {
|
|
@@ -9151,13 +9151,13 @@ var require_client_h2 = __commonJS({
|
|
|
9151
9151
|
const shouldEndStream = method === "GET" || method === "HEAD" || body === null;
|
|
9152
9152
|
if (expectContinue) {
|
|
9153
9153
|
headers[HTTP2_HEADER_EXPECT] = "100-continue";
|
|
9154
|
-
stream = session.request(headers, { endStream: shouldEndStream, signal
|
|
9154
|
+
stream = session.request(headers, { endStream: shouldEndStream, signal });
|
|
9155
9155
|
stream[kHTTP2Stream] = true;
|
|
9156
9156
|
stream.once("continue", writeBodyH2);
|
|
9157
9157
|
} else {
|
|
9158
9158
|
stream = session.request(headers, {
|
|
9159
9159
|
endStream: shouldEndStream,
|
|
9160
|
-
signal
|
|
9160
|
+
signal
|
|
9161
9161
|
});
|
|
9162
9162
|
stream[kHTTP2Stream] = true;
|
|
9163
9163
|
writeBodyH2();
|
|
@@ -12477,13 +12477,13 @@ var require_readable = __commonJS({
|
|
|
12477
12477
|
* @returns {Promise<null>}
|
|
12478
12478
|
*/
|
|
12479
12479
|
dump(opts) {
|
|
12480
|
-
const
|
|
12481
|
-
if (
|
|
12480
|
+
const signal = opts?.signal;
|
|
12481
|
+
if (signal != null && (typeof signal !== "object" || !("aborted" in signal))) {
|
|
12482
12482
|
return Promise.reject(new InvalidArgumentError("signal must be an AbortSignal"));
|
|
12483
12483
|
}
|
|
12484
12484
|
const limit = opts?.limit && Number.isFinite(opts.limit) ? opts.limit : 128 * 1024;
|
|
12485
|
-
if (
|
|
12486
|
-
return Promise.reject(
|
|
12485
|
+
if (signal?.aborted) {
|
|
12486
|
+
return Promise.reject(signal.reason ?? new AbortError());
|
|
12487
12487
|
}
|
|
12488
12488
|
if (this._readableState.closeEmitted) {
|
|
12489
12489
|
return Promise.resolve(null);
|
|
@@ -12492,15 +12492,15 @@ var require_readable = __commonJS({
|
|
|
12492
12492
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
12493
12493
|
this.destroy(new AbortError());
|
|
12494
12494
|
}
|
|
12495
|
-
if (
|
|
12495
|
+
if (signal) {
|
|
12496
12496
|
const onAbort = () => {
|
|
12497
|
-
this.destroy(
|
|
12497
|
+
this.destroy(signal.reason ?? new AbortError());
|
|
12498
12498
|
};
|
|
12499
|
-
|
|
12499
|
+
signal.addEventListener("abort", onAbort);
|
|
12500
12500
|
this.on("close", function() {
|
|
12501
|
-
|
|
12502
|
-
if (
|
|
12503
|
-
reject(
|
|
12501
|
+
signal.removeEventListener("abort", onAbort);
|
|
12502
|
+
if (signal.aborted) {
|
|
12503
|
+
reject(signal.reason ?? new AbortError());
|
|
12504
12504
|
} else {
|
|
12505
12505
|
resolve(null);
|
|
12506
12506
|
}
|
|
@@ -12684,7 +12684,7 @@ var require_api_request = __commonJS({
|
|
|
12684
12684
|
if (!opts || typeof opts !== "object") {
|
|
12685
12685
|
throw new InvalidArgumentError("invalid opts");
|
|
12686
12686
|
}
|
|
12687
|
-
const { signal
|
|
12687
|
+
const { signal, method, opaque, body, onInfo, responseHeaders, highWaterMark } = opts;
|
|
12688
12688
|
try {
|
|
12689
12689
|
if (typeof callback !== "function") {
|
|
12690
12690
|
throw new InvalidArgumentError("invalid callback");
|
|
@@ -12692,7 +12692,7 @@ var require_api_request = __commonJS({
|
|
|
12692
12692
|
if (highWaterMark != null && (!Number.isFinite(highWaterMark) || highWaterMark < 0)) {
|
|
12693
12693
|
throw new InvalidArgumentError("invalid highWaterMark");
|
|
12694
12694
|
}
|
|
12695
|
-
if (
|
|
12695
|
+
if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") {
|
|
12696
12696
|
throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
|
|
12697
12697
|
}
|
|
12698
12698
|
if (method === "CONNECT") {
|
|
@@ -12721,11 +12721,11 @@ var require_api_request = __commonJS({
|
|
|
12721
12721
|
this.highWaterMark = highWaterMark;
|
|
12722
12722
|
this.reason = null;
|
|
12723
12723
|
this.removeAbortListener = null;
|
|
12724
|
-
if (
|
|
12725
|
-
this.reason =
|
|
12726
|
-
} else if (
|
|
12727
|
-
this.removeAbortListener = util.addAbortListener(
|
|
12728
|
-
this.reason =
|
|
12724
|
+
if (signal?.aborted) {
|
|
12725
|
+
this.reason = signal.reason ?? new RequestAbortedError();
|
|
12726
|
+
} else if (signal) {
|
|
12727
|
+
this.removeAbortListener = util.addAbortListener(signal, () => {
|
|
12728
|
+
this.reason = signal.reason ?? new RequestAbortedError();
|
|
12729
12729
|
if (this.res) {
|
|
12730
12730
|
util.destroy(this.res.on("error", noop), this.reason);
|
|
12731
12731
|
} else if (this.abort) {
|
|
@@ -12862,18 +12862,18 @@ var require_abort_signal = __commonJS({
|
|
|
12862
12862
|
}
|
|
12863
12863
|
removeSignal(self);
|
|
12864
12864
|
}
|
|
12865
|
-
function addSignal(self,
|
|
12865
|
+
function addSignal(self, signal) {
|
|
12866
12866
|
self.reason = null;
|
|
12867
12867
|
self[kSignal] = null;
|
|
12868
12868
|
self[kListener] = null;
|
|
12869
|
-
if (!
|
|
12869
|
+
if (!signal) {
|
|
12870
12870
|
return;
|
|
12871
12871
|
}
|
|
12872
|
-
if (
|
|
12872
|
+
if (signal.aborted) {
|
|
12873
12873
|
abort(self);
|
|
12874
12874
|
return;
|
|
12875
12875
|
}
|
|
12876
|
-
self[kSignal] =
|
|
12876
|
+
self[kSignal] = signal;
|
|
12877
12877
|
self[kListener] = () => {
|
|
12878
12878
|
abort(self);
|
|
12879
12879
|
};
|
|
@@ -12915,7 +12915,7 @@ var require_api_stream = __commonJS({
|
|
|
12915
12915
|
if (!opts || typeof opts !== "object") {
|
|
12916
12916
|
throw new InvalidArgumentError("invalid opts");
|
|
12917
12917
|
}
|
|
12918
|
-
const { signal
|
|
12918
|
+
const { signal, method, opaque, body, onInfo, responseHeaders } = opts;
|
|
12919
12919
|
try {
|
|
12920
12920
|
if (typeof callback !== "function") {
|
|
12921
12921
|
throw new InvalidArgumentError("invalid callback");
|
|
@@ -12923,7 +12923,7 @@ var require_api_stream = __commonJS({
|
|
|
12923
12923
|
if (typeof factory !== "function") {
|
|
12924
12924
|
throw new InvalidArgumentError("invalid factory");
|
|
12925
12925
|
}
|
|
12926
|
-
if (
|
|
12926
|
+
if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") {
|
|
12927
12927
|
throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
|
|
12928
12928
|
}
|
|
12929
12929
|
if (method === "CONNECT") {
|
|
@@ -12954,7 +12954,7 @@ var require_api_stream = __commonJS({
|
|
|
12954
12954
|
this.onError(err);
|
|
12955
12955
|
});
|
|
12956
12956
|
}
|
|
12957
|
-
addSignal(this,
|
|
12957
|
+
addSignal(this, signal);
|
|
12958
12958
|
}
|
|
12959
12959
|
onConnect(abort, context) {
|
|
12960
12960
|
if (this.reason) {
|
|
@@ -13120,8 +13120,8 @@ var require_api_pipeline = __commonJS({
|
|
|
13120
13120
|
if (typeof handler !== "function") {
|
|
13121
13121
|
throw new InvalidArgumentError("invalid handler");
|
|
13122
13122
|
}
|
|
13123
|
-
const { signal
|
|
13124
|
-
if (
|
|
13123
|
+
const { signal, method, opaque, onInfo, responseHeaders } = opts;
|
|
13124
|
+
if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") {
|
|
13125
13125
|
throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
|
|
13126
13126
|
}
|
|
13127
13127
|
if (method === "CONNECT") {
|
|
@@ -13174,7 +13174,7 @@ var require_api_pipeline = __commonJS({
|
|
|
13174
13174
|
req.push(null);
|
|
13175
13175
|
});
|
|
13176
13176
|
this.res = null;
|
|
13177
|
-
addSignal(this,
|
|
13177
|
+
addSignal(this, signal);
|
|
13178
13178
|
}
|
|
13179
13179
|
onConnect(abort, context) {
|
|
13180
13180
|
const { res } = this;
|
|
@@ -13278,8 +13278,8 @@ var require_api_upgrade = __commonJS({
|
|
|
13278
13278
|
if (typeof callback !== "function") {
|
|
13279
13279
|
throw new InvalidArgumentError("invalid callback");
|
|
13280
13280
|
}
|
|
13281
|
-
const { signal
|
|
13282
|
-
if (
|
|
13281
|
+
const { signal, opaque, responseHeaders } = opts;
|
|
13282
|
+
if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") {
|
|
13283
13283
|
throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
|
|
13284
13284
|
}
|
|
13285
13285
|
super("UNDICI_UPGRADE");
|
|
@@ -13288,7 +13288,7 @@ var require_api_upgrade = __commonJS({
|
|
|
13288
13288
|
this.callback = callback;
|
|
13289
13289
|
this.abort = null;
|
|
13290
13290
|
this.context = null;
|
|
13291
|
-
addSignal(this,
|
|
13291
|
+
addSignal(this, signal);
|
|
13292
13292
|
}
|
|
13293
13293
|
onConnect(abort, context) {
|
|
13294
13294
|
if (this.reason) {
|
|
@@ -13371,8 +13371,8 @@ var require_api_connect = __commonJS({
|
|
|
13371
13371
|
if (typeof callback !== "function") {
|
|
13372
13372
|
throw new InvalidArgumentError("invalid callback");
|
|
13373
13373
|
}
|
|
13374
|
-
const { signal
|
|
13375
|
-
if (
|
|
13374
|
+
const { signal, opaque, responseHeaders } = opts;
|
|
13375
|
+
if (signal && typeof signal.on !== "function" && typeof signal.addEventListener !== "function") {
|
|
13376
13376
|
throw new InvalidArgumentError("signal must be an EventEmitter or EventTarget");
|
|
13377
13377
|
}
|
|
13378
13378
|
super("UNDICI_CONNECT");
|
|
@@ -13380,7 +13380,7 @@ var require_api_connect = __commonJS({
|
|
|
13380
13380
|
this.responseHeaders = responseHeaders || null;
|
|
13381
13381
|
this.callback = callback;
|
|
13382
13382
|
this.abort = null;
|
|
13383
|
-
addSignal(this,
|
|
13383
|
+
addSignal(this, signal);
|
|
13384
13384
|
}
|
|
13385
13385
|
onConnect(abort, context) {
|
|
13386
13386
|
if (this.reason) {
|
|
@@ -15784,7 +15784,7 @@ var require_dump = __commonJS({
|
|
|
15784
15784
|
#size = 0;
|
|
15785
15785
|
aborted = false;
|
|
15786
15786
|
reason = false;
|
|
15787
|
-
constructor({ maxSize, signal
|
|
15787
|
+
constructor({ maxSize, signal }, handler) {
|
|
15788
15788
|
if (maxSize != null && (!Number.isFinite(maxSize) || maxSize < 1)) {
|
|
15789
15789
|
throw new InvalidArgumentError("maxSize must be a number greater than 0");
|
|
15790
15790
|
}
|
|
@@ -21087,8 +21087,8 @@ var require_request2 = __commonJS({
|
|
|
21087
21087
|
var assert = __require("node:assert");
|
|
21088
21088
|
var { getMaxListeners, setMaxListeners, defaultMaxListeners } = __require("node:events");
|
|
21089
21089
|
var kAbortController = /* @__PURE__ */ Symbol("abortController");
|
|
21090
|
-
var requestFinalizer = new FinalizationRegistry(({ signal
|
|
21091
|
-
|
|
21090
|
+
var requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|
21091
|
+
signal.removeEventListener("abort", abort);
|
|
21092
21092
|
});
|
|
21093
21093
|
var dependentControllerMap = /* @__PURE__ */ new WeakMap();
|
|
21094
21094
|
var abortSignalHasEventHandlerLeakWarning;
|
|
@@ -21143,7 +21143,7 @@ var require_request2 = __commonJS({
|
|
|
21143
21143
|
let request = null;
|
|
21144
21144
|
let fallbackMode = null;
|
|
21145
21145
|
const baseUrl = environmentSettingsObject.settingsObject.baseUrl;
|
|
21146
|
-
let
|
|
21146
|
+
let signal = null;
|
|
21147
21147
|
if (typeof input2 === "string") {
|
|
21148
21148
|
this.#dispatcher = init.dispatcher;
|
|
21149
21149
|
let parsedURL;
|
|
@@ -21162,7 +21162,7 @@ var require_request2 = __commonJS({
|
|
|
21162
21162
|
} else {
|
|
21163
21163
|
assert(webidl.is.Request(input2));
|
|
21164
21164
|
request = input2.#state;
|
|
21165
|
-
|
|
21165
|
+
signal = input2.#signal;
|
|
21166
21166
|
this.#dispatcher = init.dispatcher || input2.#dispatcher;
|
|
21167
21167
|
}
|
|
21168
21168
|
const origin = environmentSettingsObject.settingsObject.origin;
|
|
@@ -21312,23 +21312,23 @@ var require_request2 = __commonJS({
|
|
|
21312
21312
|
}
|
|
21313
21313
|
}
|
|
21314
21314
|
if (init.signal !== void 0) {
|
|
21315
|
-
|
|
21315
|
+
signal = init.signal;
|
|
21316
21316
|
}
|
|
21317
21317
|
this.#state = request;
|
|
21318
21318
|
const ac = new AbortController();
|
|
21319
21319
|
this.#signal = ac.signal;
|
|
21320
|
-
if (
|
|
21321
|
-
if (
|
|
21322
|
-
ac.abort(
|
|
21320
|
+
if (signal != null) {
|
|
21321
|
+
if (signal.aborted) {
|
|
21322
|
+
ac.abort(signal.reason);
|
|
21323
21323
|
} else {
|
|
21324
21324
|
this[kAbortController] = ac;
|
|
21325
21325
|
const acRef = new WeakRef(ac);
|
|
21326
21326
|
const abort = buildAbort(acRef);
|
|
21327
|
-
if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(
|
|
21328
|
-
setMaxListeners(1500,
|
|
21327
|
+
if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(signal) === defaultMaxListeners) {
|
|
21328
|
+
setMaxListeners(1500, signal);
|
|
21329
21329
|
}
|
|
21330
|
-
util.addAbortListener(
|
|
21331
|
-
requestFinalizer.register(ac, { signal
|
|
21330
|
+
util.addAbortListener(signal, abort);
|
|
21331
|
+
requestFinalizer.register(ac, { signal, abort }, abort);
|
|
21332
21332
|
}
|
|
21333
21333
|
}
|
|
21334
21334
|
this.#headers = new Headers(kConstruct);
|
|
@@ -21667,11 +21667,11 @@ var require_request2 = __commonJS({
|
|
|
21667
21667
|
}
|
|
21668
21668
|
return newRequest;
|
|
21669
21669
|
}
|
|
21670
|
-
function fromInnerRequest(innerRequest, dispatcher,
|
|
21670
|
+
function fromInnerRequest(innerRequest, dispatcher, signal, guard) {
|
|
21671
21671
|
const request = new Request(kConstruct);
|
|
21672
21672
|
setRequestState(request, innerRequest);
|
|
21673
21673
|
setRequestDispatcher(request, dispatcher);
|
|
21674
|
-
setRequestSignal(request,
|
|
21674
|
+
setRequestSignal(request, signal);
|
|
21675
21675
|
const headers = new Headers(kConstruct);
|
|
21676
21676
|
setRequestHeaders(request, headers);
|
|
21677
21677
|
setHeadersList(headers, innerRequest.headersList);
|
|
@@ -21774,8 +21774,8 @@ var require_request2 = __commonJS({
|
|
|
21774
21774
|
{
|
|
21775
21775
|
key: "signal",
|
|
21776
21776
|
converter: webidl.nullableConverter(
|
|
21777
|
-
(
|
|
21778
|
-
|
|
21777
|
+
(signal) => webidl.converters.AbortSignal(
|
|
21778
|
+
signal,
|
|
21779
21779
|
"RequestInit",
|
|
21780
21780
|
"signal"
|
|
21781
21781
|
)
|
|
@@ -26250,18 +26250,18 @@ var require_websocketstream = __commonJS({
|
|
|
26250
26250
|
this.#openedPromise = createDeferredPromise();
|
|
26251
26251
|
this.#closedPromise = createDeferredPromise();
|
|
26252
26252
|
if (options.signal != null) {
|
|
26253
|
-
const
|
|
26254
|
-
if (
|
|
26255
|
-
this.#openedPromise.reject(
|
|
26256
|
-
this.#closedPromise.reject(
|
|
26253
|
+
const signal = options.signal;
|
|
26254
|
+
if (signal.aborted) {
|
|
26255
|
+
this.#openedPromise.reject(signal.reason);
|
|
26256
|
+
this.#closedPromise.reject(signal.reason);
|
|
26257
26257
|
return;
|
|
26258
26258
|
}
|
|
26259
|
-
|
|
26259
|
+
signal.addEventListener("abort", () => {
|
|
26260
26260
|
if (!isEstablished(this.#handler.readyState)) {
|
|
26261
26261
|
failWebsocketConnection(this.#handler);
|
|
26262
26262
|
this.#handler.readyState = states.CLOSING;
|
|
26263
|
-
this.#openedPromise.reject(
|
|
26264
|
-
this.#closedPromise.reject(
|
|
26263
|
+
this.#openedPromise.reject(signal.reason);
|
|
26264
|
+
this.#closedPromise.reject(signal.reason);
|
|
26265
26265
|
this.#handshakeAborted = true;
|
|
26266
26266
|
}
|
|
26267
26267
|
}, { once: true });
|
|
@@ -27411,19 +27411,20 @@ ${captureLines}` : capture.stack;
|
|
|
27411
27411
|
|
|
27412
27412
|
// src/codex-proxy.ts
|
|
27413
27413
|
import net2 from "node:net";
|
|
27414
|
-
import
|
|
27414
|
+
import fs6 from "node:fs";
|
|
27415
27415
|
import { createInterface } from "node:readline";
|
|
27416
27416
|
|
|
27417
27417
|
// src/codex-server.ts
|
|
27418
27418
|
import { spawn } from "node:child_process";
|
|
27419
|
-
import
|
|
27419
|
+
import fs5 from "node:fs";
|
|
27420
27420
|
import net from "node:net";
|
|
27421
27421
|
import path7 from "node:path";
|
|
27422
27422
|
import { fileURLToPath } from "node:url";
|
|
27423
27423
|
|
|
27424
|
-
// ../cli/src/lib/
|
|
27425
|
-
import {
|
|
27424
|
+
// ../cli/src/lib/lock.ts
|
|
27425
|
+
import { randomUUID } from "node:crypto";
|
|
27426
27426
|
import fs2 from "node:fs";
|
|
27427
|
+
import path3 from "node:path";
|
|
27427
27428
|
|
|
27428
27429
|
// ../cli/src/lib/paths.ts
|
|
27429
27430
|
import path2 from "node:path";
|
|
@@ -27566,155 +27567,7 @@ function setBoardRoot(root, named = false) {
|
|
|
27566
27567
|
}
|
|
27567
27568
|
setBoardRoot(process.cwd());
|
|
27568
27569
|
|
|
27569
|
-
// ../cli/src/lib/agent/stop.ts
|
|
27570
|
-
var WINDOWS = process.platform === "win32";
|
|
27571
|
-
function markedInProc(entry, strict = false, since) {
|
|
27572
|
-
const pids = [];
|
|
27573
|
-
for (const name of fs2.readdirSync("/proc")) {
|
|
27574
|
-
if (!/^\d+$/.test(name)) continue;
|
|
27575
|
-
try {
|
|
27576
|
-
if (fs2.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
27577
|
-
} catch (error) {
|
|
27578
|
-
if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
|
|
27579
|
-
const stat = fs2.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
27580
|
-
if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error;
|
|
27581
|
-
}
|
|
27582
|
-
}
|
|
27583
|
-
}
|
|
27584
|
-
return pids;
|
|
27585
|
-
}
|
|
27586
|
-
function startedBefore(pid, since) {
|
|
27587
|
-
if (since === void 0) return false;
|
|
27588
|
-
const result = spawnSync("ps", ["-p", String(pid), "-o", "lstart="], {
|
|
27589
|
-
encoding: "utf8",
|
|
27590
|
-
timeout: 5e3,
|
|
27591
|
-
env: { ...process.env, LC_ALL: "C" }
|
|
27592
|
-
});
|
|
27593
|
-
const birth = Date.parse(result.stdout?.trim() ?? "");
|
|
27594
|
-
return result.status === 0 && Number.isFinite(birth) && birth + 2e3 <= since;
|
|
27595
|
-
}
|
|
27596
|
-
function markedInPs(entry, roots) {
|
|
27597
|
-
const ps = spawnSync("ps", ["-A", "-E", "-ww", "-o", "pid=,ppid=,command="], {
|
|
27598
|
-
encoding: "utf8",
|
|
27599
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
27600
|
-
timeout: 5e3
|
|
27601
|
-
});
|
|
27602
|
-
if (ps.status !== 0 || !ps.stdout) throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u8FDB\u7A0B\u6811\u3002");
|
|
27603
|
-
const children = /* @__PURE__ */ new Map();
|
|
27604
|
-
const listed = /* @__PURE__ */ new Set();
|
|
27605
|
-
const found = /* @__PURE__ */ new Set();
|
|
27606
|
-
for (const line of ps.stdout.split("\n")) {
|
|
27607
|
-
const m = /^\s*(\d+)\s+(\d+)\s(.*)$/.exec(line);
|
|
27608
|
-
if (!m) continue;
|
|
27609
|
-
const pid = Number(m[1]);
|
|
27610
|
-
const ppid = Number(m[2]);
|
|
27611
|
-
listed.add(pid);
|
|
27612
|
-
children.set(ppid, [...children.get(ppid) ?? [], pid]);
|
|
27613
|
-
if (`${m[3]} `.includes(` ${entry} `)) found.add(pid);
|
|
27614
|
-
}
|
|
27615
|
-
const queue = [...found, ...roots.filter((pid) => listed.has(pid))];
|
|
27616
|
-
for (const pid of queue) {
|
|
27617
|
-
found.add(pid);
|
|
27618
|
-
for (const child of children.get(pid) ?? []) if (!found.has(child)) queue.push(child);
|
|
27619
|
-
}
|
|
27620
|
-
return [...found];
|
|
27621
|
-
}
|
|
27622
|
-
function marked(mark, roots = []) {
|
|
27623
|
-
if (WINDOWS || !mark.value) return [];
|
|
27624
|
-
const entry = `${mark.name}=${mark.value}`;
|
|
27625
|
-
try {
|
|
27626
|
-
const pids = process.platform === "linux" ? markedInProc(entry) : markedInPs(entry, roots);
|
|
27627
|
-
return pids.filter((pid) => pid !== process.pid);
|
|
27628
|
-
} catch {
|
|
27629
|
-
return [];
|
|
27630
|
-
}
|
|
27631
|
-
}
|
|
27632
|
-
function signal(pids, sig) {
|
|
27633
|
-
for (const pid of pids) {
|
|
27634
|
-
try {
|
|
27635
|
-
process.kill(pid, sig);
|
|
27636
|
-
} catch {
|
|
27637
|
-
}
|
|
27638
|
-
}
|
|
27639
|
-
}
|
|
27640
|
-
function startedUnder(list, root, since) {
|
|
27641
|
-
const self = list.procs.find((p) => p.pid === root);
|
|
27642
|
-
const from = since ?? self?.startedAt;
|
|
27643
|
-
if (from === void 0 || list.bootedAt > from) return [];
|
|
27644
|
-
if (self && self.startedAt > from) return [];
|
|
27645
|
-
const found = self ? [root] : [];
|
|
27646
|
-
const seen = /* @__PURE__ */ new Set([root]);
|
|
27647
|
-
const queue = [{ pid: root, startedAt: from }];
|
|
27648
|
-
for (const parent of queue) {
|
|
27649
|
-
for (const p of list.procs) {
|
|
27650
|
-
if (p.ppid !== parent.pid || seen.has(p.pid) || p.startedAt < parent.startedAt) continue;
|
|
27651
|
-
seen.add(p.pid);
|
|
27652
|
-
found.push(p.pid);
|
|
27653
|
-
queue.push(p);
|
|
27654
|
-
}
|
|
27655
|
-
}
|
|
27656
|
-
return found.reverse();
|
|
27657
|
-
}
|
|
27658
|
-
var LIST_PROCS = [
|
|
27659
|
-
"$ErrorActionPreference = 'Stop'",
|
|
27660
|
-
"Get-CimInstance Win32_Process | ForEach-Object { if ($_.CreationDate) { '{0} {1} {2}' -f $_.ProcessId, $_.ParentProcessId, ([DateTimeOffset]$_.CreationDate).ToUnixTimeMilliseconds() } }",
|
|
27661
|
-
"'boot {0}' -f ([DateTimeOffset](Get-CimInstance Win32_OperatingSystem).LastBootUpTime).ToUnixTimeMilliseconds()"
|
|
27662
|
-
].join("; ");
|
|
27663
|
-
function readProcList(out) {
|
|
27664
|
-
const procs = [];
|
|
27665
|
-
let bootedAt;
|
|
27666
|
-
for (const line of out.split(/\r?\n/)) {
|
|
27667
|
-
const boot = /^boot (\d+)$/.exec(line.trim());
|
|
27668
|
-
if (boot) bootedAt = Number(boot[1]);
|
|
27669
|
-
const m = /^(\d+) (\d+) (\d+)$/.exec(line.trim());
|
|
27670
|
-
if (m) procs.push({ pid: Number(m[1]), ppid: Number(m[2]), startedAt: Number(m[3]) });
|
|
27671
|
-
}
|
|
27672
|
-
return bootedAt !== void 0 && procs.length ? { procs, bootedAt } : void 0;
|
|
27673
|
-
}
|
|
27674
|
-
function procsOnWindows() {
|
|
27675
|
-
const ps = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", LIST_PROCS], {
|
|
27676
|
-
encoding: "utf8",
|
|
27677
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
27678
|
-
timeout: 5e3,
|
|
27679
|
-
windowsHide: true
|
|
27680
|
-
});
|
|
27681
|
-
return ps.status === 0 && ps.stdout ? readProcList(ps.stdout) : void 0;
|
|
27682
|
-
}
|
|
27683
|
-
function killUnderOnWindows(pid, since) {
|
|
27684
|
-
if (!WINDOWS || !pid) return;
|
|
27685
|
-
const list = procsOnWindows();
|
|
27686
|
-
if (!list) return;
|
|
27687
|
-
const pids = startedUnder(list, pid, since).filter((p) => p !== process.pid);
|
|
27688
|
-
if (!pids.length) return;
|
|
27689
|
-
spawnSync("taskkill", ["/F", ...pids.flatMap((p) => ["/PID", String(p)])], { stdio: "ignore", windowsHide: true, timeout: 1e4 });
|
|
27690
|
-
}
|
|
27691
|
-
function killMarked(mark, agent) {
|
|
27692
|
-
if (WINDOWS) {
|
|
27693
|
-
if (agent) killUnderOnWindows(agent.pid, agent.since);
|
|
27694
|
-
return;
|
|
27695
|
-
}
|
|
27696
|
-
signal(marked(mark), "SIGKILL");
|
|
27697
|
-
}
|
|
27698
|
-
function processesStopped(mark, root) {
|
|
27699
|
-
try {
|
|
27700
|
-
if (WINDOWS) {
|
|
27701
|
-
const list = procsOnWindows();
|
|
27702
|
-
if (!list || !root) return false;
|
|
27703
|
-
const current = list.procs.find((p) => p.pid === root.pid);
|
|
27704
|
-
if (current && current.startedAt > root.since) return false;
|
|
27705
|
-
return startedUnder(list, root.pid, root.since).length === 0;
|
|
27706
|
-
}
|
|
27707
|
-
const entry = `${mark.name}=${mark.value}`;
|
|
27708
|
-
return (process.platform === "linux" ? markedInProc(entry, true, mark.since) : markedInPs(entry, root ? [root.pid] : [])).length === 0;
|
|
27709
|
-
} catch {
|
|
27710
|
-
return false;
|
|
27711
|
-
}
|
|
27712
|
-
}
|
|
27713
|
-
|
|
27714
27570
|
// ../cli/src/lib/lock.ts
|
|
27715
|
-
import { randomUUID } from "node:crypto";
|
|
27716
|
-
import fs3 from "node:fs";
|
|
27717
|
-
import path3 from "node:path";
|
|
27718
27571
|
function pidAlive(pid) {
|
|
27719
27572
|
if (!pid) return false;
|
|
27720
27573
|
try {
|
|
@@ -27727,13 +27580,13 @@ function pidAlive(pid) {
|
|
|
27727
27580
|
function removeClaim(dir, token) {
|
|
27728
27581
|
if (token) {
|
|
27729
27582
|
try {
|
|
27730
|
-
|
|
27583
|
+
fs2.unlinkSync(path3.join(dir, token));
|
|
27731
27584
|
} catch (err) {
|
|
27732
27585
|
if (err.code !== "ENOENT") throw err;
|
|
27733
27586
|
}
|
|
27734
27587
|
}
|
|
27735
27588
|
try {
|
|
27736
|
-
|
|
27589
|
+
fs2.rmdirSync(dir);
|
|
27737
27590
|
return true;
|
|
27738
27591
|
} catch (err) {
|
|
27739
27592
|
const code = err.code;
|
|
@@ -27743,14 +27596,14 @@ function removeClaim(dir, token) {
|
|
|
27743
27596
|
}
|
|
27744
27597
|
}
|
|
27745
27598
|
function tryLock(dir) {
|
|
27746
|
-
|
|
27599
|
+
fs2.mkdirSync(path3.dirname(dir), { recursive: true });
|
|
27747
27600
|
const token = `${process.pid}-${randomUUID()}`;
|
|
27748
|
-
const candidate =
|
|
27601
|
+
const candidate = fs2.mkdtempSync(`${dir}.`);
|
|
27749
27602
|
try {
|
|
27750
|
-
|
|
27603
|
+
fs2.writeFileSync(path3.join(candidate, token), "");
|
|
27751
27604
|
for (; ; ) {
|
|
27752
27605
|
try {
|
|
27753
|
-
|
|
27606
|
+
fs2.renameSync(candidate, dir);
|
|
27754
27607
|
return () => {
|
|
27755
27608
|
removeClaim(dir, token);
|
|
27756
27609
|
};
|
|
@@ -27760,7 +27613,7 @@ function tryLock(dir) {
|
|
|
27760
27613
|
}
|
|
27761
27614
|
let entries;
|
|
27762
27615
|
try {
|
|
27763
|
-
entries =
|
|
27616
|
+
entries = fs2.readdirSync(dir);
|
|
27764
27617
|
} catch (err) {
|
|
27765
27618
|
if (err.code === "ENOENT") continue;
|
|
27766
27619
|
throw err;
|
|
@@ -27773,7 +27626,7 @@ function tryLock(dir) {
|
|
|
27773
27626
|
if (!removeClaim(dir, entries[0])) return void 0;
|
|
27774
27627
|
}
|
|
27775
27628
|
} finally {
|
|
27776
|
-
|
|
27629
|
+
fs2.rmSync(candidate, { recursive: true, force: true });
|
|
27777
27630
|
}
|
|
27778
27631
|
}
|
|
27779
27632
|
|
|
@@ -27781,8 +27634,16 @@ function tryLock(dir) {
|
|
|
27781
27634
|
import path6 from "node:path";
|
|
27782
27635
|
var import_smol_toml = __toESM(require_dist(), 1);
|
|
27783
27636
|
|
|
27637
|
+
// ../cli/src/lib/agent/stop.ts
|
|
27638
|
+
var WINDOWS = process.platform === "win32";
|
|
27639
|
+
var LIST_PROCS = [
|
|
27640
|
+
"$ErrorActionPreference = 'Stop'",
|
|
27641
|
+
"Get-CimInstance Win32_Process | ForEach-Object { if ($_.CreationDate) { '{0} {1} {2}' -f $_.ProcessId, $_.ParentProcessId, ([DateTimeOffset]$_.CreationDate).ToUnixTimeMilliseconds() } }",
|
|
27642
|
+
"'boot {0}' -f ([DateTimeOffset](Get-CimInstance Win32_OperatingSystem).LastBootUpTime).ToUnixTimeMilliseconds()"
|
|
27643
|
+
].join("; ");
|
|
27644
|
+
|
|
27784
27645
|
// src/home.ts
|
|
27785
|
-
import
|
|
27646
|
+
import fs3 from "node:fs";
|
|
27786
27647
|
import os from "node:os";
|
|
27787
27648
|
import path4 from "node:path";
|
|
27788
27649
|
|
|
@@ -27795,32 +27656,32 @@ function runnerHome() {
|
|
|
27795
27656
|
}
|
|
27796
27657
|
function runnerCwd() {
|
|
27797
27658
|
const dir = runnerHome();
|
|
27798
|
-
|
|
27659
|
+
fs3.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
27799
27660
|
return dir;
|
|
27800
27661
|
}
|
|
27801
27662
|
|
|
27802
27663
|
// src/settings-control.ts
|
|
27803
|
-
import
|
|
27664
|
+
import fs4 from "node:fs";
|
|
27804
27665
|
import path5 from "node:path";
|
|
27805
27666
|
var epochFile = () => path5.join(runnerHome(), "account-generation");
|
|
27806
27667
|
function accountGeneration() {
|
|
27807
27668
|
try {
|
|
27808
|
-
return
|
|
27669
|
+
return fs4.readFileSync(epochFile(), "utf8");
|
|
27809
27670
|
} catch {
|
|
27810
27671
|
return "";
|
|
27811
27672
|
}
|
|
27812
27673
|
}
|
|
27813
27674
|
|
|
27814
27675
|
// src/codex-service.ts
|
|
27815
|
-
var CODEX_PROTOCOL =
|
|
27816
|
-
var codexRecordFile = () => path6.join(runnerCwd(), "codex-service.json");
|
|
27676
|
+
var CODEX_PROTOCOL = 2;
|
|
27677
|
+
var codexRecordFile = () => path6.join(runnerCwd(), "codex-service-v2.json");
|
|
27817
27678
|
|
|
27818
27679
|
// src/codex-server.ts
|
|
27819
27680
|
var entryOf = (name) => process.env.RUNNER_DIST ? path7.join(process.env.RUNNER_DIST, name) : fileURLToPath(new URL(name, import.meta.url));
|
|
27820
27681
|
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
27821
27682
|
function readRecord() {
|
|
27822
27683
|
try {
|
|
27823
|
-
const record = JSON.parse(
|
|
27684
|
+
const record = JSON.parse(fs5.readFileSync(codexRecordFile(), "utf8"));
|
|
27824
27685
|
if (!record.path || !record.token || !record.instance || !Number.isSafeInteger(record.pid) || record.pid <= 0 || !Array.isArray(record.backends)) throw Error("Invalid Codex service record.");
|
|
27825
27686
|
if (record.protocol !== CODEX_PROTOCOL) throw Error("Codex service protocol is incompatible; existing work was preserved.");
|
|
27826
27687
|
return record;
|
|
@@ -27864,7 +27725,7 @@ async function openService() {
|
|
|
27864
27725
|
const until = Date.now() + 1e4;
|
|
27865
27726
|
let socket2;
|
|
27866
27727
|
for (; ; ) {
|
|
27867
|
-
const release = tryLock(path7.join(runnerCwd(), "codex-service.start.lock"));
|
|
27728
|
+
const release = tryLock(path7.join(runnerCwd(), "codex-service-v2.start.lock"));
|
|
27868
27729
|
if (!release) {
|
|
27869
27730
|
if (Date.now() >= until) throw Error("Codex service startup is busy.");
|
|
27870
27731
|
await wait(50);
|
|
@@ -27877,27 +27738,19 @@ async function openService() {
|
|
|
27877
27738
|
socket2 = await attach(record);
|
|
27878
27739
|
} catch (error) {
|
|
27879
27740
|
if (pidAlive(record.pid)) throw error;
|
|
27880
|
-
|
|
27881
|
-
if (!backend.mark?.name || !backend.mark.value || !Number.isSafeInteger(backend.pid) || !Number.isFinite(backend.since)) throw Error("Cannot identify the old Codex execution; existing work was preserved.");
|
|
27882
|
-
killMarked(backend.mark, backend);
|
|
27883
|
-
while (!processesStopped(backend.mark, backend)) {
|
|
27884
|
-
if (Date.now() >= until) throw Error("Previous Codex execution could not be confirmed stopped.");
|
|
27885
|
-
await wait(50);
|
|
27886
|
-
}
|
|
27887
|
-
}
|
|
27888
|
-
fs6.rmSync(codexRecordFile(), { force: true });
|
|
27741
|
+
fs5.rmSync(codexRecordFile(), { force: true });
|
|
27889
27742
|
}
|
|
27890
27743
|
}
|
|
27891
27744
|
if (!socket2) {
|
|
27892
27745
|
const entry = entryOf("codex-service-main.mjs");
|
|
27893
27746
|
const env = { ...process.env };
|
|
27894
27747
|
for (const key of Object.keys(env)) if (/^(KANBAN_|AI4KANBAN_EXECUTION|WILDCRANE_FLOW_WORKER|WILDCRANE_CODEX_(SERVER|PROXY)|WILDCRANE_JOB)/.test(key)) delete env[key];
|
|
27895
|
-
const log =
|
|
27748
|
+
const log = fs5.openSync(path7.join(runnerCwd(), "codex-service.log"), "a", 384);
|
|
27896
27749
|
let child;
|
|
27897
27750
|
try {
|
|
27898
27751
|
child = spawn(process.execPath, [entry], { cwd: runnerCwd(), env, detached: true, stdio: ["ignore", log, log], windowsHide: true });
|
|
27899
27752
|
} finally {
|
|
27900
|
-
|
|
27753
|
+
fs5.closeSync(log);
|
|
27901
27754
|
}
|
|
27902
27755
|
let failure;
|
|
27903
27756
|
child.on("error", (error) => {
|
|
@@ -27965,7 +27818,7 @@ async function codexServer() {
|
|
|
27965
27818
|
// src/codex-proxy.ts
|
|
27966
27819
|
if (process.env.WILDCRANE_CODEX_GENERATION !== void 0 && process.env.WILDCRANE_CODEX_GENERATION !== accountGeneration()) throw Error("Codex task belongs to an expired account session.");
|
|
27967
27820
|
var owner = await codexServer();
|
|
27968
|
-
var endpoint = JSON.parse(
|
|
27821
|
+
var endpoint = JSON.parse(fs6.readFileSync(owner.env.WILDCRANE_CODEX_SERVER, "utf8"));
|
|
27969
27822
|
var socket = net2.connect(endpoint.path);
|
|
27970
27823
|
var input = createInterface({ input: process.stdin });
|
|
27971
27824
|
var queued = [];
|
|
@@ -27994,6 +27847,9 @@ var close = () => {
|
|
|
27994
27847
|
if (closing) return;
|
|
27995
27848
|
closing = true;
|
|
27996
27849
|
void owner.close();
|
|
27850
|
+
const timer = setTimeout(() => socket.destroy(), 12e3);
|
|
27851
|
+
timer.unref();
|
|
27852
|
+
socket.once("close", () => clearTimeout(timer));
|
|
27997
27853
|
if (ready) send(JSON.stringify({ method: "wildcrane/release" }));
|
|
27998
27854
|
else socket.destroy();
|
|
27999
27855
|
input.close();
|