wildcrane-runner 0.6.105 → 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.
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.105 — built by runner/scripts/build.mjs. Do not edit.
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;
@@ -1899,33 +1899,33 @@ var require_stats = __commonJS({
1899
1899
  var require_diagnostics = __commonJS({
1900
1900
  "node_modules/undici/lib/core/diagnostics.js"(exports, module) {
1901
1901
  "use strict";
1902
- var diagnosticsChannel = __require("node:diagnostics_channel");
1902
+ var diagnosticsChannel2 = __require("node:diagnostics_channel");
1903
1903
  var util = __require("node:util");
1904
1904
  var undiciDebugLog = util.debuglog("undici");
1905
1905
  var fetchDebuglog = util.debuglog("fetch");
1906
1906
  var websocketDebuglog = util.debuglog("websocket");
1907
1907
  var channels = {
1908
1908
  // Client
1909
- beforeConnect: diagnosticsChannel.channel("undici:client:beforeConnect"),
1910
- connected: diagnosticsChannel.channel("undici:client:connected"),
1911
- connectError: diagnosticsChannel.channel("undici:client:connectError"),
1912
- sendHeaders: diagnosticsChannel.channel("undici:client:sendHeaders"),
1909
+ beforeConnect: diagnosticsChannel2.channel("undici:client:beforeConnect"),
1910
+ connected: diagnosticsChannel2.channel("undici:client:connected"),
1911
+ connectError: diagnosticsChannel2.channel("undici:client:connectError"),
1912
+ sendHeaders: diagnosticsChannel2.channel("undici:client:sendHeaders"),
1913
1913
  // Request
1914
- create: diagnosticsChannel.channel("undici:request:create"),
1915
- bodySent: diagnosticsChannel.channel("undici:request:bodySent"),
1916
- bodyChunkSent: diagnosticsChannel.channel("undici:request:bodyChunkSent"),
1917
- bodyChunkReceived: diagnosticsChannel.channel("undici:request:bodyChunkReceived"),
1918
- headers: diagnosticsChannel.channel("undici:request:headers"),
1919
- trailers: diagnosticsChannel.channel("undici:request:trailers"),
1920
- error: diagnosticsChannel.channel("undici:request:error"),
1914
+ create: diagnosticsChannel2.channel("undici:request:create"),
1915
+ bodySent: diagnosticsChannel2.channel("undici:request:bodySent"),
1916
+ bodyChunkSent: diagnosticsChannel2.channel("undici:request:bodyChunkSent"),
1917
+ bodyChunkReceived: diagnosticsChannel2.channel("undici:request:bodyChunkReceived"),
1918
+ headers: diagnosticsChannel2.channel("undici:request:headers"),
1919
+ trailers: diagnosticsChannel2.channel("undici:request:trailers"),
1920
+ error: diagnosticsChannel2.channel("undici:request:error"),
1921
1921
  // WebSocket
1922
- open: diagnosticsChannel.channel("undici:websocket:open"),
1923
- close: diagnosticsChannel.channel("undici:websocket:close"),
1924
- socketError: diagnosticsChannel.channel("undici:websocket:socket_error"),
1925
- ping: diagnosticsChannel.channel("undici:websocket:ping"),
1926
- pong: diagnosticsChannel.channel("undici:websocket:pong"),
1922
+ open: diagnosticsChannel2.channel("undici:websocket:open"),
1923
+ close: diagnosticsChannel2.channel("undici:websocket:close"),
1924
+ socketError: diagnosticsChannel2.channel("undici:websocket:socket_error"),
1925
+ ping: diagnosticsChannel2.channel("undici:websocket:ping"),
1926
+ pong: diagnosticsChannel2.channel("undici:websocket:pong"),
1927
1927
  // ProxyAgent
1928
- proxyConnected: diagnosticsChannel.channel("undici:proxy:connected")
1928
+ proxyConnected: diagnosticsChannel2.channel("undici:proxy:connected")
1929
1929
  };
1930
1930
  var isTrackingClientEvents = false;
1931
1931
  function trackClientEvents(debugLog = undiciDebugLog) {
@@ -1937,7 +1937,7 @@ var require_diagnostics = __commonJS({
1937
1937
  return;
1938
1938
  }
1939
1939
  isTrackingClientEvents = true;
1940
- diagnosticsChannel.subscribe(
1940
+ diagnosticsChannel2.subscribe(
1941
1941
  "undici:client:beforeConnect",
1942
1942
  (evt) => {
1943
1943
  const {
@@ -1952,7 +1952,7 @@ var require_diagnostics = __commonJS({
1952
1952
  );
1953
1953
  }
1954
1954
  );
1955
- diagnosticsChannel.subscribe(
1955
+ diagnosticsChannel2.subscribe(
1956
1956
  "undici:client:connected",
1957
1957
  (evt) => {
1958
1958
  const {
@@ -1967,7 +1967,7 @@ var require_diagnostics = __commonJS({
1967
1967
  );
1968
1968
  }
1969
1969
  );
1970
- diagnosticsChannel.subscribe(
1970
+ diagnosticsChannel2.subscribe(
1971
1971
  "undici:client:connectError",
1972
1972
  (evt) => {
1973
1973
  const {
@@ -1984,7 +1984,7 @@ var require_diagnostics = __commonJS({
1984
1984
  );
1985
1985
  }
1986
1986
  );
1987
- diagnosticsChannel.subscribe(
1987
+ diagnosticsChannel2.subscribe(
1988
1988
  "undici:client:sendHeaders",
1989
1989
  (evt) => {
1990
1990
  const {
@@ -2004,7 +2004,7 @@ var require_diagnostics = __commonJS({
2004
2004
  return;
2005
2005
  }
2006
2006
  isTrackingRequestEvents = true;
2007
- diagnosticsChannel.subscribe(
2007
+ diagnosticsChannel2.subscribe(
2008
2008
  "undici:request:headers",
2009
2009
  (evt) => {
2010
2010
  const {
@@ -2020,7 +2020,7 @@ var require_diagnostics = __commonJS({
2020
2020
  );
2021
2021
  }
2022
2022
  );
2023
- diagnosticsChannel.subscribe(
2023
+ diagnosticsChannel2.subscribe(
2024
2024
  "undici:request:trailers",
2025
2025
  (evt) => {
2026
2026
  const {
@@ -2029,7 +2029,7 @@ var require_diagnostics = __commonJS({
2029
2029
  debugLog("trailers received from %s %s%s", method, origin, path6);
2030
2030
  }
2031
2031
  );
2032
- diagnosticsChannel.subscribe(
2032
+ diagnosticsChannel2.subscribe(
2033
2033
  "undici:request:error",
2034
2034
  (evt) => {
2035
2035
  const {
@@ -2056,7 +2056,7 @@ var require_diagnostics = __commonJS({
2056
2056
  return;
2057
2057
  }
2058
2058
  isTrackingWebSocketEvents = true;
2059
- diagnosticsChannel.subscribe(
2059
+ diagnosticsChannel2.subscribe(
2060
2060
  "undici:websocket:open",
2061
2061
  (evt) => {
2062
2062
  if (evt.address != null) {
@@ -2067,7 +2067,7 @@ var require_diagnostics = __commonJS({
2067
2067
  }
2068
2068
  }
2069
2069
  );
2070
- diagnosticsChannel.subscribe(
2070
+ diagnosticsChannel2.subscribe(
2071
2071
  "undici:websocket:close",
2072
2072
  (evt) => {
2073
2073
  const { websocket, code, reason } = evt;
@@ -2079,19 +2079,19 @@ var require_diagnostics = __commonJS({
2079
2079
  );
2080
2080
  }
2081
2081
  );
2082
- diagnosticsChannel.subscribe(
2082
+ diagnosticsChannel2.subscribe(
2083
2083
  "undici:websocket:socket_error",
2084
2084
  (err) => {
2085
2085
  debugLog("connection errored - %s", err.message);
2086
2086
  }
2087
2087
  );
2088
- diagnosticsChannel.subscribe(
2088
+ diagnosticsChannel2.subscribe(
2089
2089
  "undici:websocket:ping",
2090
2090
  (evt) => {
2091
2091
  debugLog("ping received");
2092
2092
  }
2093
2093
  );
2094
- diagnosticsChannel.subscribe(
2094
+ diagnosticsChannel2.subscribe(
2095
2095
  "undici:websocket:pong",
2096
2096
  (evt) => {
2097
2097
  debugLog("pong received");
@@ -18990,11 +18990,11 @@ var require_deduplication_handler = __commonJS({
18990
18990
  var require_deduplicate = __commonJS({
18991
18991
  "node_modules/undici/lib/interceptor/deduplicate.js"(exports, module) {
18992
18992
  "use strict";
18993
- var diagnosticsChannel = __require("node:diagnostics_channel");
18993
+ var diagnosticsChannel2 = __require("node:diagnostics_channel");
18994
18994
  var util = require_util();
18995
18995
  var DeduplicationHandler = require_deduplication_handler();
18996
18996
  var { normalizeHeaders, makeCacheKey, makeDeduplicationKey } = require_cache();
18997
- var pendingRequestsChannel = diagnosticsChannel.channel("undici:request:pending-requests");
18997
+ var pendingRequestsChannel = diagnosticsChannel2.channel("undici:request:pending-requests");
18998
18998
  module.exports = (opts = {}) => {
18999
18999
  const {
19000
19000
  methods = ["GET"],
@@ -26675,6 +26675,7 @@ import fs5 from "node:fs";
26675
26675
 
26676
26676
  // src/codex-native.ts
26677
26677
  import crypto from "node:crypto";
26678
+ import diagnosticsChannel from "node:diagnostics_channel";
26678
26679
  import fs3 from "node:fs";
26679
26680
  var import_undici2 = __toESM(require_undici(), 1);
26680
26681
  import path4 from "node:path";
@@ -26845,6 +26846,36 @@ function connectionIdentity(pid) {
26845
26846
  return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
26846
26847
  }
26847
26848
 
26849
+ // ../cli/src/lib/agent/retry.ts
26850
+ var MAX_SUMMARY_CHARS = 300;
26851
+ var MAX_DETAIL_CHARS = 4e3;
26852
+ function clipSummary(text) {
26853
+ const clean = text.replace(/\s+/g, " ").trim();
26854
+ return clean.length > MAX_SUMMARY_CHARS ? `${clean.slice(0, MAX_SUMMARY_CHARS - 1)}\u2026` : clean;
26855
+ }
26856
+ function clipDetail(text) {
26857
+ if (!text) return void 0;
26858
+ const trimmed = text.trim();
26859
+ if (!trimmed) return void 0;
26860
+ return trimmed.length > MAX_DETAIL_CHARS ? `${trimmed.slice(0, MAX_DETAIL_CHARS - 1)}\u2026` : trimmed;
26861
+ }
26862
+ function makeFailure(source, rawSummary, options) {
26863
+ const summary = clipSummary(rawSummary) || "Execution failed.";
26864
+ const rawDetail = options?.detail?.trim() || (rawSummary.trim().length > summary.length || rawSummary.includes("\n") ? rawSummary.trim() : void 0);
26865
+ const detail = clipDetail(rawDetail);
26866
+ return {
26867
+ ...options?.code ? { code: options.code } : {},
26868
+ source,
26869
+ summary,
26870
+ ...detail && detail !== summary ? { detail } : {},
26871
+ ...typeof options?.retryAfterMs === "number" && Number.isFinite(options.retryAfterMs) && options.retryAfterMs >= 0 ? { retryAfterMs: options.retryAfterMs } : {}
26872
+ };
26873
+ }
26874
+ var SESSION_MISSING_RE = /no rollout found for thread id|no conversation found with session id|session[_\s-]*not[_\s-]*found|session[_\s-]*mismatch|(?:session|thread|conversation)\s+\S+\s+not\s+found|unknown\s+(?:session|thread)|did not resume the requested conversation|did not return the requested session/i;
26875
+ function isSessionMissingText(text) {
26876
+ return !!text && SESSION_MISSING_RE.test(text);
26877
+ }
26878
+
26848
26879
  // ../cli/src/lib/agent/wire/json.ts
26849
26880
  function obj(value) {
26850
26881
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -26856,7 +26887,7 @@ function str(value) {
26856
26887
  // ../cli/src/lib/agent/wire/failures.ts
26857
26888
  var ExecutionError = class extends Error {
26858
26889
  constructor(failure) {
26859
- super(failure.reason);
26890
+ super(failure.summary);
26860
26891
  this.failure = failure;
26861
26892
  }
26862
26893
  failure;
@@ -26865,13 +26896,9 @@ var NETWORK = /* @__PURE__ */ new Set(["ECONNRESET", "ECONNREFUSED", "EPIPE", "E
26865
26896
  function executionFailure(error) {
26866
26897
  if (error instanceof ExecutionError) return error.failure;
26867
26898
  const code = str(obj(error).code);
26868
- const reason = error instanceof Error ? error.message : String(error);
26869
- return {
26870
- code: NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed",
26871
- level: NETWORK.has(code) ? 2 : 3,
26872
- source: "harness",
26873
- reason
26874
- };
26899
+ const raw = error instanceof Error ? error.message : String(error);
26900
+ const resolvedCode = isSessionMissingText(raw) ? "session_not_found" : NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed";
26901
+ return makeFailure("runner", raw, { code: resolvedCode, detail: raw });
26875
26902
  }
26876
26903
 
26877
26904
  // ../cli/src/lib/agent/wire/rpc.ts
@@ -26930,7 +26957,7 @@ function connect(stdout, stdin, onCall, dialect = {}) {
26930
26957
  } else pending.ok(obj(msg.result));
26931
26958
  }
26932
26959
  });
26933
- stdout.on("close", () => closed(new ExecutionError({ code: "connection_lost", level: 2, reason: "The agent closed the connection." })));
26960
+ stdout.on("close", () => closed(new ExecutionError({ code: "connection_lost", source: "runtime", summary: "The agent closed the connection." })));
26934
26961
  stdout.on("error", (err) => closed(new ExecutionError(executionFailure(err))));
26935
26962
  stdin.on("error", (err) => closed(new ExecutionError(executionFailure(err))));
26936
26963
  return {
@@ -26998,9 +27025,41 @@ function readPrivate(file) {
26998
27025
  function writeLease(backend, thread, value) {
26999
27026
  writePrivate(leaseFile(backend, thread), { ...value, thread });
27000
27027
  }
27028
+ function nativeErrorText(error) {
27029
+ if (!error) return "";
27030
+ if (error instanceof RpcError) return `RPC ${error.code ?? "unknown"}: ${error.message}`;
27031
+ if (error instanceof Error) {
27032
+ const code = error.code;
27033
+ const text = error.message.trim() || error.name;
27034
+ return code && !text.includes(code) ? `${code}: ${text}` : text;
27035
+ }
27036
+ return String(error);
27037
+ }
27038
+ function nativeEventDetail(event, fallback) {
27039
+ const value = event;
27040
+ const message = typeof value.message === "string" && value.message.trim() && value.message !== "undefined" ? value.message.trim() : "";
27041
+ const code = typeof value.code === "number" ? `code ${value.code}${value.reason ? `: ${value.reason}` : ""}` : "";
27042
+ const error = value.error instanceof Error && !value.error.message.trim() ? "" : nativeErrorText(value.error);
27043
+ return fallback || error || message || code || nativeErrorText(value.error);
27044
+ }
27001
27045
  async function nativeConnection(backend, onMessage) {
27002
27046
  const unix = backend.endpoint.startsWith("unix://");
27003
- const dispatcher = unix ? new import_undici2.Agent({ connect: { socketPath: backend.endpoint.slice(7) } }) : void 0;
27047
+ const socketPath = unix ? backend.endpoint.slice(7) : void 0;
27048
+ const dispatcher = unix ? new import_undici2.Agent({ connect: { socketPath } }) : void 0;
27049
+ let lastError = "";
27050
+ const onSocketError = (err) => {
27051
+ lastError = nativeErrorText(err) || lastError;
27052
+ };
27053
+ const onConnectError = (data) => {
27054
+ const record = data;
27055
+ if (!socketPath || record.connectParams?.socketPath === socketPath) lastError = nativeErrorText(record.error) || lastError;
27056
+ };
27057
+ diagnosticsChannel.subscribe("undici:websocket:socket_error", onSocketError);
27058
+ diagnosticsChannel.subscribe("undici:client:connectError", onConnectError);
27059
+ const unsubscribeDiagnostics = () => {
27060
+ diagnosticsChannel.unsubscribe("undici:websocket:socket_error", onSocketError);
27061
+ diagnosticsChannel.unsubscribe("undici:client:connectError", onConnectError);
27062
+ };
27004
27063
  const ws = new import_undici2.WebSocket(unix ? "ws://localhost" : backend.endpoint, {
27005
27064
  ...dispatcher ? { dispatcher } : {},
27006
27065
  ...backend.token ? { headers: { authorization: `Bearer ${backend.token}` } } : {}
@@ -27018,11 +27077,30 @@ async function nativeConnection(backend, onMessage) {
27018
27077
  });
27019
27078
  outgoing.on("error", () => {
27020
27079
  });
27080
+ let closing = false;
27021
27081
  ws.addEventListener("message", (event) => incoming.write(String(event.data) + "\n"));
27022
- ws.addEventListener("close", () => incoming.destroy());
27023
- ws.addEventListener("error", () => incoming.destroy(Error("Codex native connection failed.")));
27082
+ ws.addEventListener("close", (event) => {
27083
+ unsubscribeDiagnostics();
27084
+ if (!closing && !incoming.destroyed && (!event.wasClean || event.code !== 1e3 && event.code !== 1005)) {
27085
+ const detail = nativeEventDetail(event, lastError);
27086
+ const message = detail ? `Codex native connection closed (${detail}).` : "Codex native connection closed.";
27087
+ console.error(message);
27088
+ incoming.destroy(Error(message));
27089
+ return;
27090
+ }
27091
+ incoming.destroy();
27092
+ });
27093
+ ws.addEventListener("error", (event) => {
27094
+ if (closing || incoming.destroyed) return;
27095
+ const detail = nativeEventDetail(event, lastError);
27096
+ const message = detail ? `Codex native connection failed: ${detail}` : "Codex native connection failed.";
27097
+ console.error(message);
27098
+ incoming.destroy(Error(message));
27099
+ });
27024
27100
  const close = () => {
27025
- ws.close();
27101
+ closing = true;
27102
+ unsubscribeDiagnostics();
27103
+ if (ws.readyState === import_undici2.WebSocket.OPEN || ws.readyState === import_undici2.WebSocket.CONNECTING) ws.close();
27026
27104
  incoming.destroy();
27027
27105
  outgoing.destroy();
27028
27106
  void dispatcher?.destroy();
@@ -27030,7 +27108,10 @@ async function nativeConnection(backend, onMessage) {
27030
27108
  try {
27031
27109
  await bounded(new Promise((resolve, reject) => {
27032
27110
  ws.addEventListener("open", () => resolve(), { once: true });
27033
- ws.addEventListener("error", () => reject(Error("Codex native listener did not answer.")), { once: true });
27111
+ ws.addEventListener("error", (event) => {
27112
+ const detail = nativeEventDetail(event, lastError);
27113
+ reject(Error(detail ? `Codex native listener did not answer (${detail}).` : "Codex native listener did not answer."));
27114
+ }, { once: true });
27034
27115
  }), CODEX_TIMEOUT, "Codex native connection timed out.");
27035
27116
  } catch (error) {
27036
27117
  close();