wildcrane-runner 0.6.78 → 0.6.80

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/runner.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.78 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.80 — 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;
@@ -231,9 +231,9 @@ var require_timers = __commonJS({
231
231
  * before the specified function or code is executed.
232
232
  * @param {*} arg
233
233
  */
234
- constructor(callback2, delay, arg) {
234
+ constructor(callback2, delay2, arg) {
235
235
  this._onTimeout = callback2;
236
- this._idleTimeout = delay;
236
+ this._idleTimeout = delay2;
237
237
  this._timerArg = arg;
238
238
  this.refresh();
239
239
  }
@@ -278,8 +278,8 @@ var require_timers = __commonJS({
278
278
  * when the timer expires.
279
279
  * @returns {NodeJS.Timeout|FastTimer}
280
280
  */
281
- setTimeout(callback2, delay, arg) {
282
- return delay <= RESOLUTION_MS ? setTimeout(callback2, delay, arg) : new FastTimer(callback2, delay, arg);
281
+ setTimeout(callback2, delay2, arg) {
282
+ return delay2 <= RESOLUTION_MS ? setTimeout(callback2, delay2, arg) : new FastTimer(callback2, delay2, arg);
283
283
  },
284
284
  /**
285
285
  * The clearTimeout method cancels an instantiated Timer previously created
@@ -305,8 +305,8 @@ var require_timers = __commonJS({
305
305
  * when the timer expires.
306
306
  * @returns {FastTimer}
307
307
  */
308
- setFastTimeout(callback2, delay, arg) {
309
- return new FastTimer(callback2, delay, arg);
308
+ setFastTimeout(callback2, delay2, arg) {
309
+ return new FastTimer(callback2, delay2, arg);
310
310
  },
311
311
  /**
312
312
  * The clearTimeout method cancels an instantiated FastTimer previously
@@ -332,8 +332,8 @@ var require_timers = __commonJS({
332
332
  * @deprecated
333
333
  * @param {number} [delay=0] The delay in milliseconds to add to the now value.
334
334
  */
335
- tick(delay = 0) {
336
- fastNow += delay - RESOLUTION_MS + 1;
335
+ tick(delay2 = 0) {
336
+ fastNow += delay2 - RESOLUTION_MS + 1;
337
337
  onTick();
338
338
  onTick();
339
339
  },
@@ -6851,21 +6851,21 @@ var require_client_h1 = __commonJS({
6851
6851
  this.connection = "";
6852
6852
  this.maxResponseSize = client[kMaxResponseSize];
6853
6853
  }
6854
- setTimeout(delay, type) {
6855
- if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
6854
+ setTimeout(delay2, type) {
6855
+ if (delay2 !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
6856
6856
  if (this.timeout) {
6857
6857
  timers.clearTimeout(this.timeout);
6858
6858
  this.timeout = null;
6859
6859
  }
6860
- if (delay) {
6860
+ if (delay2) {
6861
6861
  if (type & USE_FAST_TIMER) {
6862
- this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef);
6862
+ this.timeout = timers.setFastTimeout(onParserTimeout, delay2, this.timeoutWeakRef);
6863
6863
  } else {
6864
- this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef);
6864
+ this.timeout = setTimeout(onParserTimeout, delay2, this.timeoutWeakRef);
6865
6865
  this.timeout?.unref();
6866
6866
  }
6867
6867
  }
6868
- this.timeoutValue = delay;
6868
+ this.timeoutValue = delay2;
6869
6869
  } else if (this.timeout) {
6870
6870
  if (this.timeout.refresh) {
6871
6871
  this.timeout.refresh();
@@ -9863,7 +9863,7 @@ var require_agent = __commonJS({
9863
9863
  function defaultFactory(origin, opts) {
9864
9864
  return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
9865
9865
  }
9866
- var Agent = class extends DispatcherBase {
9866
+ var Agent2 = class extends DispatcherBase {
9867
9867
  constructor({ factory = defaultFactory, maxOrigins = Infinity, connect: connect2, tls, ...options } = {}) {
9868
9868
  if (typeof factory !== "function") {
9869
9869
  throw new InvalidArgumentError("factory must be a function.");
@@ -9975,7 +9975,7 @@ var require_agent = __commonJS({
9975
9975
  return allClientStats;
9976
9976
  }
9977
9977
  };
9978
- module.exports = Agent;
9978
+ module.exports = Agent2;
9979
9979
  }
9980
9980
  });
9981
9981
 
@@ -10681,7 +10681,7 @@ var require_proxy_agent = __commonJS({
10681
10681
  "node_modules/undici/lib/dispatcher/proxy-agent.js"(exports, module) {
10682
10682
  "use strict";
10683
10683
  var { kProxy, kClose, kDestroy, kDispatch } = require_symbols();
10684
- var Agent = require_agent();
10684
+ var Agent2 = require_agent();
10685
10685
  var Pool = require_pool();
10686
10686
  var DispatcherBase = require_dispatcher_base();
10687
10687
  var { InvalidArgumentError, RequestAbortedError, SecureProxyConnectionError } = require_errors();
@@ -10812,7 +10812,7 @@ var require_proxy_agent = __commonJS({
10812
10812
  } else {
10813
10813
  this[kClient] = clientFactory(url, { connect: connect2 });
10814
10814
  }
10815
- this[kAgent] = new Agent({
10815
+ this[kAgent] = new Agent2({
10816
10816
  ...opts,
10817
10817
  factory,
10818
10818
  connect: async (opts2, callback2) => {
@@ -10940,7 +10940,7 @@ var require_env_http_proxy_agent = __commonJS({
10940
10940
  var DispatcherBase = require_dispatcher_base();
10941
10941
  var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
10942
10942
  var ProxyAgent = require_proxy_agent();
10943
- var Agent = require_agent();
10943
+ var Agent2 = require_agent();
10944
10944
  var DEFAULT_PORTS = {
10945
10945
  "http:": 80,
10946
10946
  "https:": 443
@@ -10953,7 +10953,7 @@ var require_env_http_proxy_agent = __commonJS({
10953
10953
  super();
10954
10954
  this.#opts = opts;
10955
10955
  const { httpProxy, httpsProxy, noProxy, ...agentOpts } = opts;
10956
- this[kNoProxyAgent] = new Agent(agentOpts);
10956
+ this[kNoProxyAgent] = new Agent2(agentOpts);
10957
10957
  const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
10958
10958
  if (HTTP_PROXY) {
10959
10959
  this[kHttpProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTP_PROXY });
@@ -12339,7 +12339,7 @@ var require_api_pipeline = __commonJS({
12339
12339
  var {
12340
12340
  Readable,
12341
12341
  Duplex,
12342
- PassThrough
12342
+ PassThrough: PassThrough2
12343
12343
  } = __require("node:stream");
12344
12344
  var assert = __require("node:assert");
12345
12345
  var { AsyncResource } = __require("node:async_hooks");
@@ -12526,7 +12526,7 @@ var require_api_pipeline = __commonJS({
12526
12526
  this.dispatch({ ...opts, body: pipelineHandler.req }, pipelineHandler);
12527
12527
  return pipelineHandler.ret;
12528
12528
  } catch (err) {
12529
- return new PassThrough().destroy(err);
12529
+ return new PassThrough2().destroy(err);
12530
12530
  }
12531
12531
  }
12532
12532
  module.exports = pipeline;
@@ -13031,7 +13031,7 @@ var require_mock_utils = __commonJS({
13031
13031
  if (mockDispatch2.data.callback) {
13032
13032
  mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
13033
13033
  }
13034
- const { data: { statusCode, data, headers, trailers, error }, delay, persist } = mockDispatch2;
13034
+ const { data: { statusCode, data, headers, trailers, error }, delay: delay2, persist } = mockDispatch2;
13035
13035
  const { timesInvoked, times } = mockDispatch2;
13036
13036
  mockDispatch2.consumed = !persist && timesInvoked >= times;
13037
13037
  mockDispatch2.pending = timesInvoked < times;
@@ -13054,11 +13054,11 @@ var require_mock_utils = __commonJS({
13054
13054
  handler.onError(err);
13055
13055
  }
13056
13056
  handler.onConnect?.(abort, null);
13057
- if (typeof delay === "number" && delay > 0) {
13057
+ if (typeof delay2 === "number" && delay2 > 0) {
13058
13058
  timer = setTimeout(() => {
13059
13059
  timer = null;
13060
13060
  handleReply(this[kDispatches]);
13061
- }, delay);
13061
+ }, delay2);
13062
13062
  } else {
13063
13063
  handleReply(this[kDispatches]);
13064
13064
  }
@@ -13702,7 +13702,7 @@ var require_mock_agent = __commonJS({
13702
13702
  "node_modules/undici/lib/mock/mock-agent.js"(exports, module) {
13703
13703
  "use strict";
13704
13704
  var { kClients } = require_symbols();
13705
- var Agent = require_agent();
13705
+ var Agent2 = require_agent();
13706
13706
  var {
13707
13707
  kAgent,
13708
13708
  kMockAgentSet,
@@ -13740,7 +13740,7 @@ var require_mock_agent = __commonJS({
13740
13740
  if (opts?.agent && typeof opts.agent.dispatch !== "function") {
13741
13741
  throw new InvalidArgumentError("Argument opts.agent must implement Agent");
13742
13742
  }
13743
- const agent = opts?.agent ? opts.agent : new Agent(opts);
13743
+ const agent = opts?.agent ? opts.agent : new Agent2(opts);
13744
13744
  this[kAgent] = agent;
13745
13745
  this[kClients] = agent[kClients];
13746
13746
  this[kOptions] = mockOptions;
@@ -13895,8 +13895,8 @@ var require_snapshot_utils = __commonJS({
13895
13895
  match: new Set(matchHeaders.map((header) => caseSensitive ? header : header.toLowerCase()))
13896
13896
  };
13897
13897
  }
13898
- var crypto15 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
13899
- var hashId = crypto15?.hash ? (value) => crypto15.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
13898
+ var crypto17 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
13899
+ var hashId = crypto17?.hash ? (value) => crypto17.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
13900
13900
  function isUndiciHeaders(headers) {
13901
13901
  return Array.isArray(headers) && (headers.length & 1) === 0;
13902
13902
  }
@@ -14347,7 +14347,7 @@ var require_snapshot_recorder = __commonJS({
14347
14347
  var require_snapshot_agent = __commonJS({
14348
14348
  "node_modules/undici/lib/mock/snapshot-agent.js"(exports, module) {
14349
14349
  "use strict";
14350
- var Agent = require_agent();
14350
+ var Agent2 = require_agent();
14351
14351
  var MockAgent = require_mock_agent();
14352
14352
  var { SnapshotRecorder } = require_snapshot_recorder();
14353
14353
  var WrapHandler = require_wrap_handler();
@@ -14398,7 +14398,7 @@ var require_snapshot_agent = __commonJS({
14398
14398
  });
14399
14399
  this[kSnapshotLoaded] = false;
14400
14400
  if (this[kSnapshotMode] === "record" || this[kSnapshotMode] === "update" || this[kSnapshotMode] === "playback" && opts.excludeUrls && opts.excludeUrls.length > 0) {
14401
- this[kRealAgent] = new Agent(opts);
14401
+ this[kRealAgent] = new Agent2(opts);
14402
14402
  }
14403
14403
  if ((this[kSnapshotMode] === "playback" || this[kSnapshotMode] === "update") && this[kSnapshotPath]) {
14404
14404
  this.loadSnapshots().catch(() => {
@@ -14637,9 +14637,9 @@ var require_global2 = __commonJS({
14637
14637
  var globalDispatcher = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.2");
14638
14638
  var legacyGlobalDispatcher = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
14639
14639
  var { InvalidArgumentError } = require_errors();
14640
- var Agent = require_agent();
14640
+ var Agent2 = require_agent();
14641
14641
  if (getGlobalDispatcher() === void 0) {
14642
- setGlobalDispatcher2(new Agent());
14642
+ setGlobalDispatcher2(new Agent2());
14643
14643
  }
14644
14644
  function setGlobalDispatcher2(agent) {
14645
14645
  if (!agent || typeof agent.dispatch !== "function") {
@@ -17329,7 +17329,7 @@ var require_cache_handler = __commonJS({
17329
17329
  var require_memory_cache_store = __commonJS({
17330
17330
  "node_modules/undici/lib/cache/memory-cache-store.js"(exports, module) {
17331
17331
  "use strict";
17332
- var { Writable } = __require("node:stream");
17332
+ var { Writable: Writable2 } = __require("node:stream");
17333
17333
  var { EventEmitter } = __require("node:events");
17334
17334
  var { assertCacheKey, assertCacheValue } = require_cache();
17335
17335
  var MemoryCacheStore = class extends EventEmitter {
@@ -17419,7 +17419,7 @@ var require_memory_cache_store = __commonJS({
17419
17419
  const topLevelKey = `${key.origin}:${key.path}`;
17420
17420
  const store = this;
17421
17421
  const entry = { ...key, ...val, body: [], size: 0 };
17422
- return new Writable({
17422
+ return new Writable2({
17423
17423
  write(chunk, encoding, callback2) {
17424
17424
  if (typeof chunk === "string") {
17425
17425
  chunk = Buffer.from(chunk, encoding);
@@ -19087,7 +19087,7 @@ var require_deduplicate = __commonJS({
19087
19087
  var require_sqlite_cache_store = __commonJS({
19088
19088
  "node_modules/undici/lib/cache/sqlite-cache-store.js"(exports, module) {
19089
19089
  "use strict";
19090
- var { Writable } = __require("node:stream");
19090
+ var { Writable: Writable2 } = __require("node:stream");
19091
19091
  var { assertCacheKey, assertCacheValue } = require_cache();
19092
19092
  var DatabaseSync;
19093
19093
  var VERSION3 = 4;
@@ -19331,7 +19331,7 @@ var require_sqlite_cache_store = __commonJS({
19331
19331
  let size = 0;
19332
19332
  const body = [];
19333
19333
  const store = this;
19334
- return new Writable({
19334
+ return new Writable2({
19335
19335
  decodeStrings: true,
19336
19336
  write(chunk, encoding, callback2) {
19337
19337
  size += chunk.byteLength;
@@ -21094,10 +21094,10 @@ var require_subresource_integrity = __commonJS({
21094
21094
  var { runtimeFeatures } = require_runtime_features();
21095
21095
  var { asciiLowercase } = require_infra();
21096
21096
  var validSRIHashAlgorithmTokenSet = /* @__PURE__ */ new Map([["sha256", 0], ["sha384", 1], ["sha512", 2]]);
21097
- var crypto15;
21097
+ var crypto17;
21098
21098
  if (runtimeFeatures.has("crypto")) {
21099
- crypto15 = __require("node:crypto");
21100
- const cryptoHashes = crypto15.getHashes();
21099
+ crypto17 = __require("node:crypto");
21100
+ const cryptoHashes = crypto17.getHashes();
21101
21101
  if (cryptoHashes.length === 0) {
21102
21102
  validSRIHashAlgorithmTokenSet.clear();
21103
21103
  }
@@ -21185,7 +21185,7 @@ var require_subresource_integrity = __commonJS({
21185
21185
  return result;
21186
21186
  }
21187
21187
  var applyAlgorithmToBytes = (algorithm, bytes2) => {
21188
- return crypto15.hash(algorithm, bytes2, "base64");
21188
+ return crypto17.hash(algorithm, bytes2, "base64");
21189
21189
  };
21190
21190
  function caseSensitiveMatch(actualValue, expectedValue) {
21191
21191
  let actualValueLength = actualValue.length;
@@ -24173,7 +24173,7 @@ var require_connection = __commonJS({
24173
24173
  var { WebsocketFrameSend } = require_frame();
24174
24174
  var assert = __require("node:assert");
24175
24175
  var { runtimeFeatures } = require_runtime_features();
24176
- var crypto15 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
24176
+ var crypto17 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
24177
24177
  var warningEmitted = false;
24178
24178
  function establishWebSocketConnection(url, protocols, client, handler, options) {
24179
24179
  const requestURL = url;
@@ -24193,7 +24193,7 @@ var require_connection = __commonJS({
24193
24193
  const headersList = getHeadersList(new Headers2(options.headers));
24194
24194
  request2.headersList = headersList;
24195
24195
  }
24196
- const keyValue = crypto15.randomBytes(16).toString("base64");
24196
+ const keyValue = crypto17.randomBytes(16).toString("base64");
24197
24197
  request2.headersList.append("sec-websocket-key", keyValue, true);
24198
24198
  request2.headersList.append("sec-websocket-version", "13", true);
24199
24199
  for (const protocol of protocols) {
@@ -24233,7 +24233,7 @@ var require_connection = __commonJS({
24233
24233
  return;
24234
24234
  }
24235
24235
  const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
24236
- const digest2 = crypto15.hash("sha1", keyValue + uid, "base64");
24236
+ const digest2 = crypto17.hash("sha1", keyValue + uid, "base64");
24237
24237
  if (secWSAccept !== digest2) {
24238
24238
  failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
24239
24239
  return;
@@ -24408,7 +24408,7 @@ var require_permessage_deflate = __commonJS({
24408
24408
  var require_receiver = __commonJS({
24409
24409
  "node_modules/undici/lib/web/websocket/receiver.js"(exports, module) {
24410
24410
  "use strict";
24411
- var { Writable } = __require("node:stream");
24411
+ var { Writable: Writable2 } = __require("node:stream");
24412
24412
  var assert = __require("node:assert");
24413
24413
  var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants5();
24414
24414
  var {
@@ -24424,7 +24424,7 @@ var require_receiver = __commonJS({
24424
24424
  var { WebsocketFrameSend } = require_frame();
24425
24425
  var { PerMessageDeflate } = require_permessage_deflate();
24426
24426
  var { MessageSizeExceededError } = require_errors();
24427
- var ByteParser = class extends Writable {
24427
+ var ByteParser = class extends Writable2 {
24428
24428
  #buffers = [];
24429
24429
  #fragmentsBytes = 0;
24430
24430
  #byteOffset = 0;
@@ -24896,7 +24896,7 @@ var require_websocket = __commonJS({
24896
24896
  }
24897
24897
  return null;
24898
24898
  }
24899
- var WebSocket2 = class _WebSocket extends EventTarget {
24899
+ var WebSocket3 = class _WebSocket extends EventTarget {
24900
24900
  #events = {
24901
24901
  open: null,
24902
24902
  error: null,
@@ -25264,13 +25264,13 @@ var require_websocket = __commonJS({
25264
25264
  }
25265
25265
  }
25266
25266
  };
25267
- var { ping } = WebSocket2;
25268
- Reflect.deleteProperty(WebSocket2, "ping");
25269
- WebSocket2.CONNECTING = WebSocket2.prototype.CONNECTING = states.CONNECTING;
25270
- WebSocket2.OPEN = WebSocket2.prototype.OPEN = states.OPEN;
25271
- WebSocket2.CLOSING = WebSocket2.prototype.CLOSING = states.CLOSING;
25272
- WebSocket2.CLOSED = WebSocket2.prototype.CLOSED = states.CLOSED;
25273
- Object.defineProperties(WebSocket2.prototype, {
25267
+ var { ping } = WebSocket3;
25268
+ Reflect.deleteProperty(WebSocket3, "ping");
25269
+ WebSocket3.CONNECTING = WebSocket3.prototype.CONNECTING = states.CONNECTING;
25270
+ WebSocket3.OPEN = WebSocket3.prototype.OPEN = states.OPEN;
25271
+ WebSocket3.CLOSING = WebSocket3.prototype.CLOSING = states.CLOSING;
25272
+ WebSocket3.CLOSED = WebSocket3.prototype.CLOSED = states.CLOSED;
25273
+ Object.defineProperties(WebSocket3.prototype, {
25274
25274
  CONNECTING: staticPropertyDescriptors,
25275
25275
  OPEN: staticPropertyDescriptors,
25276
25276
  CLOSING: staticPropertyDescriptors,
@@ -25294,7 +25294,7 @@ var require_websocket = __commonJS({
25294
25294
  configurable: true
25295
25295
  }
25296
25296
  });
25297
- Object.defineProperties(WebSocket2, {
25297
+ Object.defineProperties(WebSocket3, {
25298
25298
  CONNECTING: staticPropertyDescriptors,
25299
25299
  OPEN: staticPropertyDescriptors,
25300
25300
  CLOSING: staticPropertyDescriptors,
@@ -25343,7 +25343,7 @@ var require_websocket = __commonJS({
25343
25343
  return webidl.converters.USVString(V3);
25344
25344
  };
25345
25345
  module.exports = {
25346
- WebSocket: WebSocket2,
25346
+ WebSocket: WebSocket3,
25347
25347
  ping
25348
25348
  };
25349
25349
  }
@@ -26496,7 +26496,7 @@ var require_undici = __commonJS({
26496
26496
  var Pool = require_pool();
26497
26497
  var BalancedPool = require_balanced_pool();
26498
26498
  var RoundRobinPool = require_round_robin_pool();
26499
- var Agent = require_agent();
26499
+ var Agent2 = require_agent();
26500
26500
  var ProxyAgent = require_proxy_agent();
26501
26501
  var Socks5ProxyAgent = require_socks5_proxy_agent();
26502
26502
  var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
@@ -26523,7 +26523,7 @@ var require_undici = __commonJS({
26523
26523
  module.exports.Pool = Pool;
26524
26524
  module.exports.BalancedPool = BalancedPool;
26525
26525
  module.exports.RoundRobinPool = RoundRobinPool;
26526
- module.exports.Agent = Agent;
26526
+ module.exports.Agent = Agent2;
26527
26527
  module.exports.ProxyAgent = ProxyAgent;
26528
26528
  module.exports.Socks5ProxyAgent = Socks5ProxyAgent;
26529
26529
  module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
@@ -26644,8 +26644,8 @@ ${captureLines}` : capture.stack;
26644
26644
  module.exports.parseMIMEType = parseMIMEType;
26645
26645
  module.exports.serializeAMimeType = serializeAMimeType;
26646
26646
  var { CloseEvent, ErrorEvent, MessageEvent } = require_events();
26647
- var { WebSocket: WebSocket2, ping } = require_websocket();
26648
- module.exports.WebSocket = WebSocket2;
26647
+ var { WebSocket: WebSocket3, ping } = require_websocket();
26648
+ module.exports.WebSocket = WebSocket3;
26649
26649
  module.exports.CloseEvent = CloseEvent;
26650
26650
  module.exports.ErrorEvent = ErrorEvent;
26651
26651
  module.exports.MessageEvent = MessageEvent;
@@ -26683,16 +26683,16 @@ ${captureLines}` : capture.stack;
26683
26683
  });
26684
26684
 
26685
26685
  // ../cli/src/lib/dress-page.ts
26686
- import fs29 from "node:fs";
26687
- import path33 from "node:path";
26686
+ import fs31 from "node:fs";
26687
+ import path35 from "node:path";
26688
26688
  function dressPage(file3) {
26689
- const folder = path33.dirname(file3);
26690
- const html = fs29.readFileSync(file3, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
26689
+ const folder = path35.dirname(file3);
26690
+ const html = fs31.readFileSync(file3, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
26691
26691
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
26692
26692
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
26693
- const at3 = path33.resolve(folder, href);
26694
- if (!at3.startsWith(folder + path33.sep) || !fs29.existsSync(at3)) return tag;
26695
- const css = fs29.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path33.relative(folder, path33.resolve(path33.dirname(at3), src)).split(path33.sep).join("/")}${quote2})`);
26693
+ const at3 = path35.resolve(folder, href);
26694
+ if (!at3.startsWith(folder + path35.sep) || !fs31.existsSync(at3)) return tag;
26695
+ const css = fs31.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path35.relative(folder, path35.resolve(path35.dirname(at3), src)).split(path35.sep).join("/")}${quote2})`);
26696
26696
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
26697
26697
  });
26698
26698
  const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -26704,7 +26704,7 @@ var init_dress_page = __esm({
26704
26704
  "use strict";
26705
26705
  CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
26706
26706
  head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
26707
- referenceText = (file3) => /\.html$/i.test(file3) ? dressPage(file3) : fs29.readFileSync(file3, "utf8");
26707
+ referenceText = (file3) => /\.html$/i.test(file3) ? dressPage(file3) : fs31.readFileSync(file3, "utf8");
26708
26708
  }
26709
26709
  });
26710
26710
 
@@ -34176,7 +34176,7 @@ var require_react_dom_server_node_production = __commonJS({
34176
34176
  "../cli/node_modules/react-dom/cjs/react-dom-server.node.production.js"(exports) {
34177
34177
  "use strict";
34178
34178
  var util = __require("util");
34179
- var crypto15 = __require("crypto");
34179
+ var crypto17 = __require("crypto");
34180
34180
  var async_hooks = __require("async_hooks");
34181
34181
  var React4 = require_react();
34182
34182
  var ReactDOM = require_react_dom();
@@ -37041,7 +37041,7 @@ var require_react_dom_server_node_production = __commonJS({
37041
37041
  function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
37042
37042
  if (void 0 !== permalink) return "p" + permalink;
37043
37043
  permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
37044
- componentKeyPath = crypto15.createHash("md5");
37044
+ componentKeyPath = crypto17.createHash("md5");
37045
37045
  componentKeyPath.update(permalink);
37046
37046
  return "k" + componentKeyPath.digest("hex");
37047
37047
  }
@@ -51035,7 +51035,7 @@ var require_react_dom_server_node_development = __commonJS({
51035
51035
  function createPostbackActionStateKey(permalink, componentKeyPath, hookIndex) {
51036
51036
  if (void 0 !== permalink) return "p" + permalink;
51037
51037
  permalink = JSON.stringify([componentKeyPath, null, hookIndex]);
51038
- componentKeyPath = crypto15.createHash("md5");
51038
+ componentKeyPath = crypto17.createHash("md5");
51039
51039
  componentKeyPath.update(permalink);
51040
51040
  return "k" + componentKeyPath.digest("hex");
51041
51041
  }
@@ -54697,7 +54697,7 @@ var require_react_dom_server_node_development = __commonJS({
54697
54697
  }
54698
54698
  };
54699
54699
  }
54700
- var util = __require("util"), crypto15 = __require("crypto"), async_hooks = __require("async_hooks"), React4 = require_react(), ReactDOM = require_react_dom(), stream = __require("stream"), REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_SCOPE_TYPE = /* @__PURE__ */ Symbol.for("react.scope"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_LEGACY_HIDDEN_TYPE = /* @__PURE__ */ Symbol.for("react.legacy_hidden"), REACT_MEMO_CACHE_SENTINEL = /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_RECOVERABLE_TYPE = /* @__PURE__ */ Symbol.for("react.recoverable"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, ASYNC_ITERATOR = Symbol.asyncIterator, REACT_OPTIMISTIC_KEY = /* @__PURE__ */ Symbol.for("react.optimistic_key"), isArrayImpl = Array.isArray, jsxPropsParents = /* @__PURE__ */ new WeakMap(), jsxChildrenParents = /* @__PURE__ */ new WeakMap(), CLIENT_REFERENCE_TAG = /* @__PURE__ */ Symbol.for("react.client.reference"), hasOwnProperty = Object.prototype.hasOwnProperty, supportsArrayBufferDetached = hasOwnProperty.call(
54700
+ var util = __require("util"), crypto17 = __require("crypto"), async_hooks = __require("async_hooks"), React4 = require_react(), ReactDOM = require_react_dom(), stream = __require("stream"), REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_SCOPE_TYPE = /* @__PURE__ */ Symbol.for("react.scope"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_LEGACY_HIDDEN_TYPE = /* @__PURE__ */ Symbol.for("react.legacy_hidden"), REACT_MEMO_CACHE_SENTINEL = /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_RECOVERABLE_TYPE = /* @__PURE__ */ Symbol.for("react.recoverable"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, ASYNC_ITERATOR = Symbol.asyncIterator, REACT_OPTIMISTIC_KEY = /* @__PURE__ */ Symbol.for("react.optimistic_key"), isArrayImpl = Array.isArray, jsxPropsParents = /* @__PURE__ */ new WeakMap(), jsxChildrenParents = /* @__PURE__ */ new WeakMap(), CLIENT_REFERENCE_TAG = /* @__PURE__ */ Symbol.for("react.client.reference"), hasOwnProperty = Object.prototype.hasOwnProperty, supportsArrayBufferDetached = hasOwnProperty.call(
54701
54701
  ArrayBuffer.prototype,
54702
54702
  "detached"
54703
54703
  ), didWarnAboutMissingArrayBufferDetached = false, scheduleMicrotask = queueMicrotask, currentView = null, writtenBytes = 0, destinationHasCapacity$1 = true, textEncoder = new util.TextEncoder(), assign = Object.assign, VALID_ATTRIBUTE_NAME_REGEX = RegExp(
@@ -110866,8 +110866,8 @@ var init_dist = __esm({
110866
110866
  });
110867
110867
 
110868
110868
  // ../cli/src/lib/draw-mockup.ts
110869
- import fs32 from "node:fs";
110870
- import path36 from "node:path";
110869
+ import fs34 from "node:fs";
110870
+ import path38 from "node:path";
110871
110871
  import vm from "node:vm";
110872
110872
  async function loadPackage(id) {
110873
110873
  if (id === "react") return import_react3.default;
@@ -110880,23 +110880,23 @@ async function loadPackage(id) {
110880
110880
  return { __esModule: true, ...await load() };
110881
110881
  }
110882
110882
  function resolveFile(id, from, folder) {
110883
- const at2 = path36.resolve(path36.dirname(from), id);
110884
- if (at2 !== folder && !at2.startsWith(folder + path36.sep)) throw new Error(`${id} is outside the mockup's folder`);
110885
- const tries = path36.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path36.join(at2, `index${e2}`))];
110886
- const file3 = tries.find((f2) => fs32.statSync(f2, { throwIfNoEntry: false })?.isFile());
110883
+ const at2 = path38.resolve(path38.dirname(from), id);
110884
+ if (at2 !== folder && !at2.startsWith(folder + path38.sep)) throw new Error(`${id} is outside the mockup's folder`);
110885
+ const tries = path38.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path38.join(at2, `index${e2}`))];
110886
+ const file3 = tries.find((f2) => fs34.statSync(f2, { throwIfNoEntry: false })?.isFile());
110887
110887
  if (!file3) throw new Error(`no such file: ${id}`);
110888
- if (!fs32.realpathSync(file3).startsWith(fs32.realpathSync(folder) + path36.sep)) throw new Error(`${id} is outside the mockup's folder`);
110888
+ if (!fs34.realpathSync(file3).startsWith(fs34.realpathSync(folder) + path38.sep)) throw new Error(`${id} is outside the mockup's folder`);
110889
110889
  return file3;
110890
110890
  }
110891
110891
  async function readGraph(entry) {
110892
- const folder = path36.dirname(entry);
110892
+ const folder = path38.dirname(entry);
110893
110893
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
110894
110894
  const walk = async (file3) => {
110895
110895
  if (graph.code.has(file3)) return;
110896
110896
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
110897
110897
  let location = file3;
110898
110898
  try {
110899
- const js = (0, import_sucrase.transform)(fs32.readFileSync(file3, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file3 }).code;
110899
+ const js = (0, import_sucrase.transform)(fs34.readFileSync(file3, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file3 }).code;
110900
110900
  graph.code.set(file3, js);
110901
110901
  const link = /* @__PURE__ */ new Map();
110902
110902
  graph.links.set(file3, link);
@@ -110910,7 +110910,7 @@ async function readGraph(entry) {
110910
110910
  const target = resolveFile(id, file3, folder);
110911
110911
  link.set(id, target);
110912
110912
  if (!target.endsWith(".css")) await walk(target);
110913
- else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs32.readFileSync(target, "utf8") });
110913
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs34.readFileSync(target, "utf8") });
110914
110914
  }
110915
110915
  } catch (error) {
110916
110916
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -110927,13 +110927,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
110927
110927
  async function tailwindFor(markup, sheets, folder) {
110928
110928
  const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
110929
110929
  const compiler = await rc(source2, {
110930
- base: sheets.length ? path36.dirname(sheets[0].path) : "/",
110930
+ base: sheets.length ? path38.dirname(sheets[0].path) : "/",
110931
110931
  loadStylesheet: async (id, from) => {
110932
110932
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
110933
110933
  if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
110934
- const at2 = path36.resolve(from, id);
110935
- if (!fs32.realpathSync(at2).startsWith(fs32.realpathSync(folder) + path36.sep)) throw new Error(`${id} is outside the mockup's folder`);
110936
- return { path: at2, base: path36.dirname(at2), content: fs32.readFileSync(at2, "utf8") };
110934
+ const at2 = path38.resolve(from, id);
110935
+ if (!fs34.realpathSync(at2).startsWith(fs34.realpathSync(folder) + path38.sep)) throw new Error(`${id} is outside the mockup's folder`);
110936
+ return { path: at2, base: path38.dirname(at2), content: fs34.readFileSync(at2, "utf8") };
110937
110937
  }
110938
110938
  });
110939
110939
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
@@ -110982,7 +110982,7 @@ ${graph.code.get(file3)}
110982
110982
  if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
110983
110983
  sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
110984
110984
  const markup = run2("__draw()", context, entry, deadline);
110985
- const css = (await tailwindFor(markup, graph.sheets, path36.dirname(entry))).replace(/<\/style/gi, "<\\/style");
110985
+ const css = (await tailwindFor(markup, graph.sheets, path38.dirname(entry))).replace(/<\/style/gi, "<\\/style");
110986
110986
  return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
110987
110987
  }
110988
110988
  var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, MOCKUP_IMPORTS;
@@ -111856,8 +111856,8 @@ function deferRefresh(session, error, after) {
111856
111856
  const attempt = Math.min((readRetry(session)?.attempt ?? 0) + 1, 4);
111857
111857
  const seconds = after?.trim() ? Number(after) : NaN;
111858
111858
  const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after ?? "") - Date.now();
111859
- const delay = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
111860
- const retry2 = { key: refreshKey(session), until: Date.now() + delay, attempt, error };
111859
+ const delay2 = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
111860
+ const retry2 = { key: refreshKey(session), until: Date.now() + delay2, attempt, error };
111861
111861
  const temporary = `${retryFile()}.${process.pid}.tmp`;
111862
111862
  fs.writeFileSync(temporary, JSON.stringify(retry2), { mode: 384 });
111863
111863
  fs.renameSync(temporary, retryFile());
@@ -112193,8 +112193,8 @@ function status(line) {
112193
112193
  }
112194
112194
 
112195
112195
  // src/protocol.ts
112196
- var VERSION = true ? "0.6.78" : "0.0.0";
112197
- var AKB_VERSION = true ? "0.11.63" : "0.0.0";
112196
+ var VERSION = true ? "0.6.80" : "0.0.0";
112197
+ var AKB_VERSION = true ? "0.11.64" : "0.0.0";
112198
112198
  var AKB_CONTRACT = true ? 17 : 0;
112199
112199
  var EXIT_REFUSED = 10;
112200
112200
  var EXIT_OUTDATED = 11;
@@ -112202,10 +112202,10 @@ var EXIT_UPDATE = 12;
112202
112202
 
112203
112203
  // src/runtimes.ts
112204
112204
  import { spawn as spawn2 } from "node:child_process";
112205
- import { randomUUID as randomUUID2 } from "node:crypto";
112206
- import fs17 from "node:fs";
112207
- import os5 from "node:os";
112208
- import path21 from "node:path";
112205
+ import { randomUUID as randomUUID3 } from "node:crypto";
112206
+ import fs19 from "node:fs";
112207
+ import os6 from "node:os";
112208
+ import path23 from "node:path";
112209
112209
 
112210
112210
  // ../cli/src/lib/agent/harnesses/antigravity.ts
112211
112211
  import fs7 from "node:fs";
@@ -112592,7 +112592,6 @@ function modelsIn(file3, pick2, salt = "") {
112592
112592
  import { createHash as createHash2 } from "node:crypto";
112593
112593
  import fs5 from "node:fs";
112594
112594
  import path6 from "node:path";
112595
- var SKILL_SENTENCE = "Use the kanban skill";
112596
112595
  function namesFlag(argv, flags) {
112597
112596
  return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
112598
112597
  }
@@ -113107,7 +113106,6 @@ ${rule}
113107
113106
  adoptsSessionId: false,
113108
113107
  savesSessionAtOpen: false,
113109
113108
  stopsOnRateLimit: false,
113110
- skillCall: SKILL_SENTENCE,
113111
113109
  // `models` is read-only. Only explicit authentication errors mean signed out.
113112
113110
  login: {
113113
113111
  args: ["models"],
@@ -114330,7 +114328,7 @@ function createTail(log) {
114330
114328
  // ../cli/package.json
114331
114329
  var package_default = {
114332
114330
  name: "wildcrane",
114333
- version: "0.11.63",
114331
+ version: "0.11.64",
114334
114332
  akbContract: 17,
114335
114333
  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.",
114336
114334
  keywords: [
@@ -116151,8 +116149,6 @@ var CLAUDE_CODE = {
116151
116149
  savesSessionAtOpen: false,
116152
116150
  // Its own Read tool opens an image file, so a path in the message is the whole of it.
116153
116151
  images: { as: "message" },
116154
- // Claude Code loads a skill from its slash name.
116155
- skillCall: "/kanban",
116156
116152
  // `claude auth status` prints one JSON object saying whether it is signed in and how. Its
116157
116153
  // `loggedIn` flag is read, not its exit code: this one does set the code, and two of the
116158
116154
  // other three leave it at 0 in both states, so the output is the rule everywhere.
@@ -116511,10 +116507,6 @@ var CODEX = {
116511
116507
  // tokens it would swallow the prompt that follows it as a second file — Codex would then
116512
116508
  // read the prompt from a stdin the board never opens and send an empty turn.
116513
116509
  images: { as: "args", args: (file3) => [`--image=${file3}`] },
116514
- // Codex ignores a slash name — it reads as plain chat text — and triggers a skill from a
116515
- // `$` name. The install already writes the skill to `.agents/skills/kanban/`, which is
116516
- // where Codex looks.
116517
- skillCall: "$kanban",
116518
116510
  // `codex login status` prints one line and nothing else: "Logged in using ChatGPT" —
116519
116511
  // or an API key, which is why the reading stops at the first two words — and "Not logged
116520
116512
  // in".
@@ -116575,7 +116567,6 @@ var CURSOR = {
116575
116567
  savesSessionAtOpen: false,
116576
116568
  // Its own file reading opens a picture from a path written into the words.
116577
116569
  images: { as: "message" },
116578
- skillCall: SKILL_SENTENCE,
116579
116570
  // `cursor-agent status` exits 0 whether or not anybody is signed in, so its output is the
116580
116571
  // whole of the answer.
116581
116572
  login: {
@@ -116687,9 +116678,6 @@ ${text4}` } };
116687
116678
  // And it has written that session down before it answers: killed right after
116688
116679
  // `session/new`, dsh-acp reopens the id from a fresh command about half a second later.
116689
116680
  savesSessionAtOpen: true,
116690
- // dsh has no slash or `$` skill syntax a headless run can use, so the prompt asks for the
116691
- // skill in a sentence. It reads `.agents/skills/`, the folder an install already writes.
116692
- skillCall: SKILL_SENTENCE,
116693
116681
  // No login probe: dsh has no login to probe. Its own command offers `web` and `plugin` and
116694
116682
  // nothing else — a run signs with the key in `$DSH_HOME`'s settings, or with the box above
116695
116683
  // — so there is no CLI sign-in for a logged-out reading to be about.
@@ -116796,10 +116784,6 @@ var GROK = {
116796
116784
  // And it has written that session down before it answers: killed the instant
116797
116785
  // `session/new` returns, grok reopens the id from a fresh command.
116798
116786
  savesSessionAtOpen: true,
116799
- // Grok lists its skills as slash names, but a slash typed into an ACP `session/prompt` is
116800
- // not the same thing as one typed into its TUI, and the sentence is proved: asked this
116801
- // way, grok found `.agents/skills/kanban/SKILL.md` in the project and read it.
116802
- skillCall: SKILL_SENTENCE,
116803
116787
  installs: () => [...process.env.GROK_BIN_DIR ? [join4(process.env.GROK_BIN_DIR, "grok")] : [], home(".grok", "bin", "grok")],
116804
116788
  install: "curl -fsSL https://x.ai/cli/install.sh | bash"
116805
116789
  };
@@ -116998,13 +116982,6 @@ ${text4}
116998
116982
  // Kimi names its own session, and prints the id as its closing row.
116999
116983
  adoptsSessionId: false,
117000
116984
  savesSessionAtOpen: false,
117001
- // Kimi does have a slash name for a skill — `/skill:kanban` — but whether one typed into
117002
- // a `-p` prompt is read as a command or as plain chat text is unprobed. The sentence
117003
- // works either way, because Kimi's model picks a skill from its description on its own.
117004
- //
117005
- // PROBE: if `/skill:kanban` triggers the skill from a `-p` prompt, this becomes that and
117006
- // the connector stops showing a "Direct skill call" gap.
117007
- skillCall: SKILL_SENTENCE,
117008
116985
  // No login probe, so Kimi is never called logged out. `kimi login` is the way in, but
117009
116986
  // nothing was found that PRINTS whether that login is there, and `kimi` was not on the
117010
116987
  // machine this was written on to read one off — and a reading nobody has seen is exactly
@@ -117088,9 +117065,6 @@ var OPENCODE = {
117088
117065
  savesSessionAtOpen: true,
117089
117066
  // Its own file reading opens a picture from a path written into the words.
117090
117067
  images: { as: "message" },
117091
- // No slash or `$` skill syntax in a sent message, so the prompt asks for the skill in a
117092
- // sentence. It scans `.agents/skills/` and `.claude/skills/`, where an install writes.
117093
- skillCall: SKILL_SENTENCE,
117094
117068
  // No login probe: OpenCode's free models need no sign-in, so a machine with no saved
117095
117069
  // credential is not logged out.
117096
117070
  installs: () => [...process.env.OPENCODE_INSTALL_DIR ? [join6(process.env.OPENCODE_INSTALL_DIR, "opencode")] : [], home(".opencode", "bin", "opencode")],
@@ -117188,10 +117162,6 @@ var ZCODE = {
117188
117162
  // answers "Session not found" ten seconds after the id came back. So a ZCode run that
117189
117163
  // dies before its first turn has nothing to go back to.
117190
117164
  savesSessionAtOpen: false,
117191
- // ZCode's slash and `$` names are its terminal UI's, not something a sent prompt
117192
- // triggers, so the prompt asks for the skill in a sentence. It reads `.agents/skills/`,
117193
- // the folder an install already writes, and finds the board's rules there by itself.
117194
- skillCall: SKILL_SENTENCE,
117195
117165
  // No login probe: a ZCode run signs with the Coding Plan key above and never with a
117196
117166
  // `zcode login`, whose credential the command's own config never points at (#282). Its
117197
117167
  // CLI's login decides nothing here, so there is nothing to warn about.
@@ -117413,41 +117383,255 @@ __export(api_exports, {
117413
117383
  });
117414
117384
 
117415
117385
  // src/goals.ts
117386
+ import fs17 from "node:fs";
117387
+ import path21 from "node:path";
117388
+
117389
+ // src/settings-control.ts
117390
+ import fs16 from "node:fs";
117391
+ import path20 from "node:path";
117392
+
117393
+ // src/codex-native.ts
117394
+ var import_undici2 = __toESM(require_undici(), 1);
117395
+ import crypto2 from "node:crypto";
117416
117396
  import fs15 from "node:fs";
117397
+ import os5 from "node:os";
117417
117398
  import path19 from "node:path";
117399
+ import { PassThrough, Writable } from "node:stream";
117418
117400
 
117419
- // src/settings-control.ts
117401
+ // ../cli/src/lib/agent/connection-process.ts
117402
+ import { spawnSync as spawnSync4 } from "node:child_process";
117403
+
117404
+ // ../cli/src/lib/lock.ts
117405
+ import { randomUUID as randomUUID2 } from "node:crypto";
117420
117406
  import fs14 from "node:fs";
117421
117407
  import path18 from "node:path";
117422
- var directory = () => path18.join(runnerHome(), "executors");
117423
- var epochFile = () => path18.join(runnerHome(), "account-generation");
117408
+ function pidAlive(pid) {
117409
+ if (!pid) return false;
117410
+ try {
117411
+ process.kill(pid, 0);
117412
+ return true;
117413
+ } catch (e2) {
117414
+ return e2.code === "EPERM";
117415
+ }
117416
+ }
117417
+ function removeClaim(dir, token) {
117418
+ if (token) {
117419
+ try {
117420
+ fs14.unlinkSync(path18.join(dir, token));
117421
+ } catch (err) {
117422
+ if (err.code !== "ENOENT") throw err;
117423
+ }
117424
+ }
117425
+ try {
117426
+ fs14.rmdirSync(dir);
117427
+ return true;
117428
+ } catch (err) {
117429
+ const code = err.code;
117430
+ if (code === "ENOENT") return true;
117431
+ if (code === "ENOTEMPTY" || code === "EEXIST") return false;
117432
+ throw err;
117433
+ }
117434
+ }
117435
+ function tryLock(dir) {
117436
+ fs14.mkdirSync(path18.dirname(dir), { recursive: true });
117437
+ const token = `${process.pid}-${randomUUID2()}`;
117438
+ const candidate = fs14.mkdtempSync(`${dir}.`);
117439
+ try {
117440
+ fs14.writeFileSync(path18.join(candidate, token), "");
117441
+ for (; ; ) {
117442
+ try {
117443
+ fs14.renameSync(candidate, dir);
117444
+ return () => {
117445
+ removeClaim(dir, token);
117446
+ };
117447
+ } catch (err) {
117448
+ const code = err.code;
117449
+ if (code !== "ENOTEMPTY" && code !== "EEXIST") throw err;
117450
+ }
117451
+ let entries;
117452
+ try {
117453
+ entries = fs14.readdirSync(dir);
117454
+ } catch (err) {
117455
+ if (err.code === "ENOENT") continue;
117456
+ throw err;
117457
+ }
117458
+ if (entries.length) {
117459
+ if (entries.length !== 1 || !/^\d+-[a-f0-9-]{36}$/.test(entries[0])) return void 0;
117460
+ const owner2 = Number(entries[0].split("-")[0]);
117461
+ if (pidAlive(owner2)) return void 0;
117462
+ }
117463
+ if (!removeClaim(dir, entries[0])) return void 0;
117464
+ }
117465
+ } finally {
117466
+ fs14.rmSync(candidate, { recursive: true, force: true });
117467
+ }
117468
+ }
117469
+
117470
+ // ../cli/src/lib/agent/connection-process.ts
117471
+ function connectionIdentity(pid) {
117472
+ const result = process.platform === "win32" ? spawnSync4("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CreationDate.ToUniversalTime().ToString('o')`], { encoding: "utf8", timeout: 2e3, windowsHide: true }) : spawnSync4("ps", ["-p", String(pid), "-o", "lstart="], { encoding: "utf8", timeout: 2e3, env: { ...process.env, LC_ALL: "C" } });
117473
+ return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
117474
+ }
117475
+ function connectionStopped(root2) {
117476
+ if (!root2) return true;
117477
+ if (!pidAlive(root2.pid)) return true;
117478
+ const identity = connectionIdentity(root2.pid);
117479
+ return !!root2.identity && !!identity && identity !== root2.identity;
117480
+ }
117481
+ function endConnection(child, grace = 12e3) {
117482
+ child.stdin?.end();
117483
+ child.kill("SIGTERM");
117484
+ const timer = setTimeout(() => child.kill("SIGKILL"), grace);
117485
+ timer.unref();
117486
+ child.once("close", () => clearTimeout(timer));
117487
+ }
117488
+ async function stopConnection(root2, timeout) {
117489
+ if (connectionStopped(root2)) return true;
117490
+ if (!root2?.identity || connectionIdentity(root2.pid) !== root2.identity) return false;
117491
+ try {
117492
+ process.kill(root2.pid, "SIGTERM");
117493
+ } catch {
117494
+ }
117495
+ const until = Date.now() + timeout;
117496
+ while (!connectionStopped(root2)) {
117497
+ if (Date.now() >= until) {
117498
+ if (connectionIdentity(root2.pid) === root2.identity) try {
117499
+ process.kill(root2.pid, "SIGKILL");
117500
+ } catch {
117501
+ }
117502
+ return connectionStopped(root2);
117503
+ }
117504
+ await new Promise((resolve2) => setTimeout(resolve2, 100));
117505
+ }
117506
+ return true;
117507
+ }
117508
+
117509
+ // src/codex-native.ts
117510
+ var CODEX_PROTOCOL = 3;
117511
+ var CODEX_TIMEOUT = 1e4;
117512
+ var nativeDirectory = () => path19.join(runnerCwd(), "codex-native");
117513
+ var codexRecordFile = () => path19.join(nativeDirectory(), "runner.json");
117514
+ var backendFile = (key) => path19.join(nativeDirectory(), `${key}.json`);
117515
+ var liveBackend = (backend) => !connectionStopped(backend);
117516
+ var processIdentity = () => ({ pid: process.pid, identity: connectionIdentity(process.pid) });
117517
+ function writePrivate(file3, value) {
117518
+ fs15.mkdirSync(path19.dirname(file3), { recursive: true, mode: 448 });
117519
+ const temporary = `${file3}.${crypto2.randomUUID()}.tmp`;
117520
+ fs15.writeFileSync(temporary, JSON.stringify(value), { mode: 384 });
117521
+ fs15.renameSync(temporary, file3);
117522
+ }
117523
+ function readPrivate(file3) {
117524
+ try {
117525
+ return JSON.parse(fs15.readFileSync(file3, "utf8"));
117526
+ } catch (error) {
117527
+ if (error.code === "ENOENT") return;
117528
+ throw error;
117529
+ }
117530
+ }
117531
+ function nativeEndpoint(key) {
117532
+ const directory3 = path19.join(os5.tmpdir(), `wc-codex-${crypto2.createHash("sha256").update(runnerCwd()).digest("hex").slice(0, 12)}`);
117533
+ fs15.mkdirSync(directory3, { recursive: true, mode: 448 });
117534
+ fs15.chmodSync(directory3, 448);
117535
+ return `unix://${path19.join(directory3, `${key.slice(0, 12)}-${crypto2.randomBytes(6).toString("hex")}.sock`)}`;
117536
+ }
117537
+ async function nativeConnection(backend, onMessage) {
117538
+ const unix = backend.endpoint.startsWith("unix://");
117539
+ const dispatcher = unix ? new import_undici2.Agent({ connect: { socketPath: backend.endpoint.slice(7) } }) : void 0;
117540
+ const ws = new import_undici2.WebSocket(unix ? "ws://localhost" : backend.endpoint, {
117541
+ ...dispatcher ? { dispatcher } : {},
117542
+ ...backend.token ? { headers: { authorization: `Bearer ${backend.token}` } } : {}
117543
+ });
117544
+ const incoming = new PassThrough();
117545
+ const outgoing = new Writable({ write(chunk, _encoding, done) {
117546
+ try {
117547
+ ws.send(String(chunk).trimEnd());
117548
+ done();
117549
+ } catch (error) {
117550
+ done(error);
117551
+ }
117552
+ } });
117553
+ incoming.on("error", () => {
117554
+ });
117555
+ outgoing.on("error", () => {
117556
+ });
117557
+ ws.addEventListener("message", (event2) => incoming.write(String(event2.data) + "\n"));
117558
+ ws.addEventListener("close", () => incoming.destroy());
117559
+ ws.addEventListener("error", () => incoming.destroy(Error("Codex native connection failed.")));
117560
+ const close = () => {
117561
+ ws.close();
117562
+ incoming.destroy();
117563
+ outgoing.destroy();
117564
+ void dispatcher?.destroy();
117565
+ };
117566
+ try {
117567
+ await bounded(new Promise((resolve2, reject) => {
117568
+ ws.addEventListener("open", () => resolve2(), { once: true });
117569
+ ws.addEventListener("error", () => reject(Error("Codex native listener did not answer.")), { once: true });
117570
+ }), CODEX_TIMEOUT, "Codex native connection timed out.");
117571
+ } catch (error) {
117572
+ close();
117573
+ throw error;
117574
+ }
117575
+ const rpc = connect(incoming, outgoing, onMessage);
117576
+ return { rpc, incoming, close };
117577
+ }
117578
+ async function initializeNative(connection) {
117579
+ const result = await bounded(connection.rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), CODEX_TIMEOUT, "Codex initialize timed out.");
117580
+ connection.rpc.notify("initialized");
117581
+ return result;
117582
+ }
117583
+ function stopNativeBackends() {
117584
+ let files = [];
117585
+ try {
117586
+ files = fs15.readdirSync(nativeDirectory()).filter((name) => /^[a-f0-9]{64}\.json$/.test(name));
117587
+ } catch {
117588
+ return [];
117589
+ }
117590
+ const targets = [];
117591
+ for (const file3 of files) {
117592
+ const backend = readPrivate(path19.join(nativeDirectory(), file3));
117593
+ if (backend?.identity && liveBackend(backend) && connectionIdentity(backend.pid) === backend.identity) {
117594
+ targets.push(backend);
117595
+ try {
117596
+ process.kill(backend.pid, "SIGTERM");
117597
+ } catch {
117598
+ }
117599
+ }
117600
+ }
117601
+ return targets;
117602
+ }
117603
+
117604
+ // src/settings-control.ts
117605
+ var directory = () => path20.join(runnerHome(), "executors");
117606
+ var epochFile = () => path20.join(runnerHome(), "account-generation");
117424
117607
  function accountGeneration() {
117425
117608
  try {
117426
- return fs14.readFileSync(epochFile(), "utf8");
117609
+ return fs16.readFileSync(epochFile(), "utf8");
117427
117610
  } catch {
117428
117611
  return "";
117429
117612
  }
117430
117613
  }
117431
117614
  function executorRecord() {
117432
- fs14.mkdirSync(directory(), { recursive: true, mode: 448 });
117433
- const file3 = path18.join(directory(), `${process.pid}.json`);
117434
- fs14.writeFileSync(file3, "{}", { mode: 384 });
117435
- return () => fs14.rmSync(file3, { force: true });
117615
+ fs16.mkdirSync(directory(), { recursive: true, mode: 448 });
117616
+ const file3 = path20.join(directory(), `${process.pid}.json`);
117617
+ fs16.writeFileSync(file3, "{}", { mode: 384 });
117618
+ return () => fs16.rmSync(file3, { force: true });
117436
117619
  }
117437
117620
  async function stopExecutors() {
117438
- fs14.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
117439
- fs14.writeFileSync(epochFile(), `${Date.now()}-${process.pid}`, { mode: 384 });
117621
+ fs16.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
117622
+ fs16.writeFileSync(epochFile(), `${Date.now()}-${process.pid}`, { mode: 384 });
117623
+ const backends = stopNativeBackends();
117440
117624
  for (let n = 0; n < 160; n++) {
117441
- const active = fs14.existsSync(directory()) ? fs14.readdirSync(directory()).filter((name) => {
117625
+ const active = fs16.existsSync(directory()) ? fs16.readdirSync(directory()).filter((name) => {
117442
117626
  try {
117443
117627
  process.kill(Number(name.split(".")[0]), 0);
117444
117628
  return true;
117445
117629
  } catch {
117446
- fs14.rmSync(path18.join(directory(), name), { force: true });
117630
+ fs16.rmSync(path20.join(directory(), name), { force: true });
117447
117631
  return false;
117448
117632
  }
117449
117633
  }) : [];
117450
- if (!active.length) return true;
117634
+ if (!active.length && backends.every((backend) => !liveBackend(backend))) return true;
117451
117635
  await new Promise((resolve2) => setTimeout(resolve2, 100));
117452
117636
  }
117453
117637
  return false;
@@ -117460,11 +117644,11 @@ function goalsOf(held5) {
117460
117644
  if (!Array.isArray(goals)) throw new Error("The goals array is missing or invalid.");
117461
117645
  return goals;
117462
117646
  }
117463
- var goalsFileOf = (job) => path19.join(runnerHome(), "ideas", `${job.id}.json`);
117647
+ var goalsFileOf = (job) => path21.join(runnerHome(), "ideas", `${job.id}.json`);
117464
117648
  async function writeGoals(job, list3, preserveGoals = false) {
117465
117649
  let goals;
117466
117650
  try {
117467
- goals = preserveGoals && fs15.existsSync(goalsFileOf(job)) ? goalsOf(JSON.parse(fs15.readFileSync(goalsFileOf(job), "utf8"))) : goalsOf(job.discussion);
117651
+ goals = preserveGoals && fs17.existsSync(goalsFileOf(job)) ? goalsOf(JSON.parse(fs17.readFileSync(goalsFileOf(job), "utf8"))) : goalsOf(job.discussion);
117468
117652
  } catch (e2) {
117469
117653
  return { error: String(e2) };
117470
117654
  }
@@ -117475,18 +117659,18 @@ async function writeGoals(job, list3, preserveGoals = false) {
117475
117659
  return { error: e2 instanceof Error ? e2.message : String(e2) };
117476
117660
  }
117477
117661
  const file3 = goalsFileOf(job);
117478
- fs15.mkdirSync(path19.dirname(file3), { recursive: true });
117479
- fs15.writeFileSync(file3, `${JSON.stringify({ workspace: job.discussion.workspace, studios, ideas: goals }, null, 2)}
117662
+ fs17.mkdirSync(path21.dirname(file3), { recursive: true });
117663
+ fs17.writeFileSync(file3, `${JSON.stringify({ workspace: job.discussion.workspace, studios, ideas: goals }, null, 2)}
117480
117664
  `);
117481
117665
  return { file: file3 };
117482
117666
  }
117483
117667
  function readGoals(file3) {
117484
117668
  try {
117485
- return goalsOf(JSON.parse(fs15.readFileSync(file3, "utf8")));
117669
+ return goalsOf(JSON.parse(fs17.readFileSync(file3, "utf8")));
117486
117670
  } catch {
117487
117671
  return void 0;
117488
117672
  } finally {
117489
- fs15.rmSync(file3, { force: true });
117673
+ fs17.rmSync(file3, { force: true });
117490
117674
  }
117491
117675
  }
117492
117676
  var owner = "";
@@ -117533,12 +117717,12 @@ async function studioSnapshot(workspace, catalog, list3) {
117533
117717
  }
117534
117718
 
117535
117719
  // src/secrets.ts
117536
- import fs16 from "node:fs";
117537
- import path20 from "node:path";
117538
- var file = () => path20.join(runnerHome(), "secrets.json");
117720
+ import fs18 from "node:fs";
117721
+ import path22 from "node:path";
117722
+ var file = () => path22.join(runnerHome(), "secrets.json");
117539
117723
  function readAll() {
117540
117724
  try {
117541
- const held5 = JSON.parse(fs16.readFileSync(file(), "utf8"));
117725
+ const held5 = JSON.parse(fs18.readFileSync(file(), "utf8"));
117542
117726
  return held5 && typeof held5 === "object" ? held5 : {};
117543
117727
  } catch {
117544
117728
  return {};
@@ -117554,11 +117738,11 @@ function keepSecrets(runtime, given) {
117554
117738
  }
117555
117739
  if (Object.keys(held5).length) all2[runtime] = held5;
117556
117740
  else delete all2[runtime];
117557
- fs16.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
117741
+ fs18.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
117558
117742
  const temp = `${file()}.${process.pid}.tmp`;
117559
- fs16.writeFileSync(temp, `${JSON.stringify(all2)}
117743
+ fs18.writeFileSync(temp, `${JSON.stringify(all2)}
117560
117744
  `, { mode: 384 });
117561
- fs16.renameSync(temp, file());
117745
+ fs18.renameSync(temp, file());
117562
117746
  }
117563
117747
  var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id, keys]) => [id, Object.keys(keys)]));
117564
117748
 
@@ -117745,7 +117929,7 @@ function plan(runtime, prompt, cwd, resume, model, given = {}, fork = false, lan
117745
117929
  const values = held2(runtime, model, given);
117746
117930
  const [binary, ...flags] = commandOf(harness);
117747
117931
  const base = [binary, ...flags, ...settingArgs(harness, values)];
117748
- const id = randomUUID2();
117932
+ const id = randomUUID3();
117749
117933
  const copied = fork && resume && harness.forkArgs ? harness.forkArgs(base, resume, id, cwd) : null;
117750
117934
  if (fork) resume = null;
117751
117935
  const extra = copied ?? (resume ? harness.resumeArgs(base, resume, cwd) : harness.extraArgs(base, id, cwd));
@@ -117840,14 +118024,14 @@ var listed = (harness) => async () => (harness.models?.() ?? []).map((id) => ({
117840
118024
  var readModels = (name) => (MODELS[name] ?? listed(HARNESSES2[name]))().catch(() => []);
117841
118025
  var MODELS = {
117842
118026
  "claude-code": async () => {
117843
- const cached2 = claudeModels(path21.join(process.env.CLAUDE_CONFIG_DIR || path21.join(os5.homedir(), ".claude"), "cache", "model-catalog"));
118027
+ const cached2 = claudeModels(path23.join(process.env.CLAUDE_CONFIG_DIR || path23.join(os6.homedir(), ".claude"), "cache", "model-catalog"));
117844
118028
  return cached2.length ? cached2 : [
117845
118029
  { id: "opus", name: "Opus" },
117846
118030
  { id: "sonnet", name: "Sonnet" },
117847
118031
  { id: "haiku", name: "Haiku" }
117848
118032
  ];
117849
118033
  },
117850
- codex: async () => codexModels(path21.join(process.env.CODEX_HOME || path21.join(os5.homedir(), ".codex"), "models_cache.json")),
118034
+ codex: async () => codexModels(path23.join(process.env.CODEX_HOME || path23.join(os6.homedir(), ".codex"), "models_cache.json")),
117851
118035
  opencode: async () => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"])),
117852
118036
  cursor: () => cursorModels(),
117853
118037
  antigravity: async () => antigravityModels(await output(commandOf(HARNESSES2.antigravity)[0], ["models"]))
@@ -117860,7 +118044,7 @@ function cursorModels() {
117860
118044
  return new Promise((resolve2) => {
117861
118045
  let child;
117862
118046
  try {
117863
- const start = spawnable(argv[0], argv.slice(1), { cwd: os5.tmpdir(), stdio: ["pipe", "pipe", "ignore"], env: copyEnv(argv[0], withSystemProxy({ ...process.env, ...HARNESSES2.cursor.env() })) });
118047
+ const start = spawnable(argv[0], argv.slice(1), { cwd: os6.tmpdir(), stdio: ["pipe", "pipe", "ignore"], env: copyEnv(argv[0], withSystemProxy({ ...process.env, ...HARNESSES2.cursor.env() })) });
117864
118048
  child = spawn2(start.command, start.args, start.options);
117865
118049
  } catch {
117866
118050
  return resolve2([]);
@@ -117873,7 +118057,7 @@ function cursorModels() {
117873
118057
  const timer = setTimeout(() => done([]), MODELS_MS);
117874
118058
  child.on("error", () => done([]));
117875
118059
  const rpc = connect(child.stdout, child.stdin, (msg) => msg.id !== void 0 && rpc.refuse(msg.id, "no"), { jsonrpc: true });
117876
- rpc.call("initialize", { protocolVersion: 1, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } }).then(() => rpc.call("session/new", { cwd: os5.tmpdir(), mcpServers: [] })).then((opened) => done(acpModels(opened))).catch(() => done([]));
118060
+ rpc.call("initialize", { protocolVersion: 1, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } }).then(() => rpc.call("session/new", { cwd: os6.tmpdir(), mcpServers: [] })).then((opened) => done(acpModels(opened))).catch(() => done([]));
117877
118061
  });
117878
118062
  }
117879
118063
  function acpModels(opened) {
@@ -117907,7 +118091,7 @@ function output(command, args2) {
117907
118091
  }
117908
118092
  function codexModels(file3) {
117909
118093
  try {
117910
- const cache = JSON.parse(fs17.readFileSync(file3, "utf8"));
118094
+ const cache = JSON.parse(fs19.readFileSync(file3, "utf8"));
117911
118095
  if (!Array.isArray(cache.models)) return [];
117912
118096
  return cache.models.flatMap(
117913
118097
  (m) => m.visibility === "list" && typeof m.slug === "string" && m.slug ? [{ id: m.slug, name: typeof m.display_name === "string" && m.display_name ? m.display_name : m.slug }] : []
@@ -117919,13 +118103,13 @@ function codexModels(file3) {
117919
118103
  function claudeModels(dir) {
117920
118104
  let files;
117921
118105
  try {
117922
- files = fs17.readdirSync(dir).filter((f2) => f2.endsWith(".json"));
118106
+ files = fs19.readdirSync(dir).filter((f2) => f2.endsWith(".json"));
117923
118107
  } catch {
117924
118108
  return [];
117925
118109
  }
117926
118110
  const catalogs = files.flatMap((f2) => {
117927
118111
  try {
117928
- const data = obj2(JSON.parse(fs17.readFileSync(path21.join(dir, f2), "utf8")));
118112
+ const data = obj2(JSON.parse(fs19.readFileSync(path23.join(dir, f2), "utf8")));
117929
118113
  const catalog = obj2(data.catalog);
117930
118114
  const surface = str2(catalog.surface);
117931
118115
  return surface === "cc" || surface === "ccd" ? [{ surface, at: Number(data.fetchedAt) || 0, config: obj2(catalog.config) }] : [];
@@ -118046,9 +118230,9 @@ function connectCloudLive(handlers) {
118046
118230
  if (closed || retry2) return;
118047
118231
  teardown();
118048
118232
  handlers.onState?.("retrying", reason);
118049
- const wait4 = Math.min(3e4, BACKOFF_MS[Math.min(attempts, BACKOFF_MS.length - 1)] * (0.8 + Math.random() * 0.4));
118233
+ const wait3 = Math.min(3e4, BACKOFF_MS[Math.min(attempts, BACKOFF_MS.length - 1)] * (0.8 + Math.random() * 0.4));
118050
118234
  attempts += 1;
118051
- retry2 = setTimeout(open, wait4);
118235
+ retry2 = setTimeout(open, wait3);
118052
118236
  retry2.unref?.();
118053
118237
  };
118054
118238
  const open = async () => {
@@ -118150,20 +118334,20 @@ function connectCloudLive(handlers) {
118150
118334
  }
118151
118335
 
118152
118336
  // src/folders.ts
118153
- import fs18 from "node:fs";
118154
- import os6 from "node:os";
118155
- import path22 from "node:path";
118156
- var projectsFile = () => path22.join(runnerHome(), "projects.json");
118337
+ import fs20 from "node:fs";
118338
+ import os7 from "node:os";
118339
+ import path24 from "node:path";
118340
+ var projectsFile = () => path24.join(runnerHome(), "projects.json");
118157
118341
  function realpath(p2) {
118158
118342
  try {
118159
- return fs18.realpathSync(p2);
118343
+ return fs20.realpathSync(p2);
118160
118344
  } catch {
118161
118345
  return null;
118162
118346
  }
118163
118347
  }
118164
118348
  function readGrants() {
118165
118349
  try {
118166
- const held5 = JSON.parse(fs18.readFileSync(projectsFile(), "utf8"));
118350
+ const held5 = JSON.parse(fs20.readFileSync(projectsFile(), "utf8"));
118167
118351
  if (!Array.isArray(held5.projects)) throw new Error("invalid_projects");
118168
118352
  return held5;
118169
118353
  } catch (error) {
@@ -118177,23 +118361,23 @@ function listOf(held5) {
118177
118361
  return subject ? held5.accounts[subject] ?? [] : [];
118178
118362
  }
118179
118363
  function update2(change) {
118180
- fs18.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
118364
+ fs20.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
118181
118365
  const lock = `${projectsFile()}.lock`;
118182
118366
  let fd;
118183
118367
  const until = Date.now() + 2e3;
118184
118368
  for (; ; ) {
118185
118369
  try {
118186
- fd = fs18.openSync(lock, "wx", 384);
118187
- fs18.writeFileSync(fd, String(process.pid));
118370
+ fd = fs20.openSync(lock, "wx", 384);
118371
+ fs20.writeFileSync(fd, String(process.pid));
118188
118372
  break;
118189
118373
  } catch {
118190
118374
  try {
118191
- const pid = Number(fs18.readFileSync(lock, "utf8"));
118375
+ const pid = Number(fs20.readFileSync(lock, "utf8"));
118192
118376
  if (pid > 0) {
118193
118377
  try {
118194
118378
  process.kill(pid, 0);
118195
118379
  } catch {
118196
- fs18.rmSync(lock, { force: true });
118380
+ fs20.rmSync(lock, { force: true });
118197
118381
  }
118198
118382
  }
118199
118383
  } catch {
@@ -118216,13 +118400,13 @@ function update2(change) {
118216
118400
  held5.projects = after;
118217
118401
  } else held5.projects = after;
118218
118402
  const tmp = `${projectsFile()}.${process.pid}.tmp`;
118219
- fs18.writeFileSync(tmp, `${JSON.stringify(held5, null, 2)}
118403
+ fs20.writeFileSync(tmp, `${JSON.stringify(held5, null, 2)}
118220
118404
  `, { mode: 384 });
118221
- fs18.renameSync(tmp, projectsFile());
118405
+ fs20.renameSync(tmp, projectsFile());
118222
118406
  return before.filter((p2) => !after.includes(p2));
118223
118407
  } finally {
118224
- fs18.closeSync(fd);
118225
- fs18.rmSync(lock, { force: true });
118408
+ fs20.closeSync(fd);
118409
+ fs20.rmSync(lock, { force: true });
118226
118410
  }
118227
118411
  }
118228
118412
  function adoptLegacy() {
@@ -118231,7 +118415,7 @@ function adoptLegacy() {
118231
118415
  function allowedProjects() {
118232
118416
  return listOf(readGrants()).flatMap((p2) => {
118233
118417
  const real = realpath(p2);
118234
- return real && fs18.statSync(real).isDirectory() ? [real] : [];
118418
+ return real && fs20.statSync(real).isDirectory() ? [real] : [];
118235
118419
  });
118236
118420
  }
118237
118421
  var allow = (dir) => {
@@ -118240,12 +118424,12 @@ var allow = (dir) => {
118240
118424
  var disallow = (dir) => update2((list3) => list3.filter((p2) => p2 !== dir));
118241
118425
  var SYSTEM_MAC = ["/System", "/Library", "/Applications", "/usr", "/bin", "/sbin", "/etc", "/var", "/private", "/opt", "/cores", "/dev"];
118242
118426
  var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramData"];
118243
- var here = () => ({ platform: process.platform, home: os6.homedir(), resolve: realpath });
118427
+ var here = () => ({ platform: process.platform, home: os7.homedir(), resolve: realpath });
118244
118428
  function refusal2(picked, where = here()) {
118245
118429
  const win = where.platform === "win32";
118246
- const p2 = win ? path22.win32 : path22.posix;
118430
+ const p2 = win ? path24.win32 : path24.posix;
118247
118431
  const real = where.resolve(picked);
118248
- if (!real || !p2.isAbsolute(real) || where.resolve === realpath && !fs18.statSync(real).isDirectory()) return "missing";
118432
+ if (!real || !p2.isAbsolute(real) || where.resolve === realpath && !fs20.statSync(real).isDirectory()) return "missing";
118249
118433
  const norm = (d2) => {
118250
118434
  const n = p2.normalize(d2).replace(/[\\/]+$/, "") || p2.sep;
118251
118435
  return win ? n.toLowerCase() : n;
@@ -118266,7 +118450,7 @@ function refusal2(picked, where = here()) {
118266
118450
  }
118267
118451
 
118268
118452
  // src/connect.ts
118269
- import fs49 from "node:fs";
118453
+ import fs50 from "node:fs";
118270
118454
  import path53 from "node:path";
118271
118455
 
118272
118456
  // ../cli/src/lib/agent/due.ts
@@ -118293,9 +118477,9 @@ function scheduleDue(ask, now = Date.now()) {
118293
118477
  }
118294
118478
  const newest2 = ask.attempts.reduce((a2, r2) => a2 && a2.startedAt >= r2.startedAt ? a2 : r2, null);
118295
118479
  const retrying = isAuto(ask.cadence) && newest2?.status === "error";
118296
- const wait4 = next.getTime() > now ? retrying ? "retrying" : "tooSoon" : !ask.newWork() ? "nothingNew" : null;
118297
- const reason = !wait4 || wait4 === "tooSoon" ? void 0 : wait4 === "nothingNew" ? ask.reads : wait4;
118298
- return { next, wait: wait4, ...reason ? { reason } : {} };
118480
+ const wait3 = next.getTime() > now ? retrying ? "retrying" : "tooSoon" : !ask.newWork() ? "nothingNew" : null;
118481
+ const reason = !wait3 || wait3 === "tooSoon" ? void 0 : wait3 === "nothingNew" ? ask.reads : wait3;
118482
+ return { next, wait: wait3, ...reason ? { reason } : {} };
118299
118483
  }
118300
118484
 
118301
118485
  // src/agents.ts
@@ -118341,48 +118525,48 @@ async function askDueAgents(machineId2, now = Date.now()) {
118341
118525
 
118342
118526
  // src/akb-version.ts
118343
118527
  import { execFile } from "node:child_process";
118344
- import fs26 from "node:fs";
118345
- import path30 from "node:path";
118528
+ import fs28 from "node:fs";
118529
+ import path32 from "node:path";
118346
118530
 
118347
118531
  // src/akb.ts
118348
118532
  import { spawn as spawn3 } from "node:child_process";
118349
- import fs19 from "node:fs";
118350
- import path23 from "node:path";
118533
+ import fs21 from "node:fs";
118534
+ import path25 from "node:path";
118351
118535
  import { fileURLToPath, pathToFileURL } from "node:url";
118352
- var akbHome = () => path23.join(runnerHome(), "bin", "akb");
118536
+ var akbHome = () => path25.join(runnerHome(), "bin", "akb");
118353
118537
  var BUNDLED_SHIM = `bundled-${AKB_VERSION}`;
118354
- var HERE = path23.dirname(fileURLToPath(import.meta.url));
118538
+ var HERE = path25.dirname(fileURLToPath(import.meta.url));
118355
118539
  function akbArgs(entry, dist = HERE) {
118356
- const preload = path23.join(dist, "akb-proxy.mjs");
118357
- return fs19.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry] : [entry];
118540
+ const preload = path25.join(dist, "akb-proxy.mjs");
118541
+ return fs21.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry] : [entry];
118358
118542
  }
118359
118543
  var bundledAkb = (dist = HERE) => ({
118360
118544
  command: process.execPath,
118361
- args: akbArgs(path23.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
118545
+ args: akbArgs(path25.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
118362
118546
  version: AKB_VERSION,
118363
- shim: path23.join(akbHome(), BUNDLED_SHIM)
118547
+ shim: path25.join(akbHome(), BUNDLED_SHIM)
118364
118548
  });
118365
118549
  var quote = (s) => /^[\w./:@=-]+$/.test(s) ? s : `"${s}"`;
118366
118550
  function shimDir(akb) {
118367
118551
  const dir = akb.shim;
118368
118552
  const line = [akb.command, ...akb.args].map(quote).join(" ");
118369
- const [file3, text4] = process.platform === "win32" ? [path23.join(dir, "akb.cmd"), `@${line} %*\r
118370
- `] : [path23.join(dir, "akb"), `#!/bin/sh
118553
+ const [file3, text4] = process.platform === "win32" ? [path25.join(dir, "akb.cmd"), `@${line} %*\r
118554
+ `] : [path25.join(dir, "akb"), `#!/bin/sh
118371
118555
  exec ${line} "$@"
118372
118556
  `];
118373
118557
  if (process.platform === "win32") {
118374
- fs19.mkdirSync(dir, { recursive: true });
118558
+ fs21.mkdirSync(dir, { recursive: true });
118375
118559
  const shellLine = [akb.command, ...akb.args].map((s) => `'${s.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`).join(" ");
118376
- fs19.writeFileSync(path23.join(dir, "akb"), `#!/bin/sh
118560
+ fs21.writeFileSync(path25.join(dir, "akb"), `#!/bin/sh
118377
118561
  exec ${shellLine} "$@"
118378
118562
  `, { mode: 493 });
118379
118563
  }
118380
118564
  try {
118381
- if (fs19.readFileSync(file3, "utf8") === text4) return dir;
118565
+ if (fs21.readFileSync(file3, "utf8") === text4) return dir;
118382
118566
  } catch {
118383
118567
  }
118384
- fs19.mkdirSync(dir, { recursive: true });
118385
- fs19.writeFileSync(file3, text4, { mode: 493 });
118568
+ fs21.mkdirSync(dir, { recursive: true });
118569
+ fs21.writeFileSync(file3, text4, { mode: 493 });
118386
118570
  return dir;
118387
118571
  }
118388
118572
  function akbEnv(akb, board, task, language, base = process.env) {
@@ -118390,7 +118574,7 @@ function akbEnv(akb, board, task, language, base = process.env) {
118390
118574
  const dropped = ["AI4KANBAN_PREVIEW_BRIDGE", "AI4KANBAN_REPLY_APPROVAL", "AI4KANBAN_BOARD", "AI4KANBAN_TASK", "AI4KANBAN_EXECUTION", LANGUAGE_ENV, SCHEDULED_AGENTS_ENV, SESSION_COST_ENV];
118391
118575
  for (const [k2, v] of Object.entries({ ...proxyEnv(), ...base })) if (!k2.startsWith("KANBAN_") && !dropped.includes(k2)) env2[k2] = v;
118392
118576
  const key = Object.keys(env2).find((k2) => k2.toUpperCase() === "PATH") ?? "PATH";
118393
- env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(path23.delimiter);
118577
+ env2[key] = [shimDir(akb), env2[key]].filter(Boolean).join(path25.delimiter);
118394
118578
  if (Object.keys(proxyEnv()).some((k2) => !/^no_proxy$/i.test(k2)) && env2.NODE_USE_ENV_PROXY === void 0) env2.NODE_USE_ENV_PROXY = "1";
118395
118579
  env2[HOST_PROXY_ENV] = JSON.stringify(hostProxy());
118396
118580
  env2.AI4KANBAN_COMMAND = "akb";
@@ -118440,13 +118624,13 @@ function answerOf2(ran) {
118440
118624
  }
118441
118625
 
118442
118626
  // src/cache.ts
118443
- import crypto3 from "node:crypto";
118444
- import fs24 from "node:fs";
118445
- import path28 from "node:path";
118627
+ import crypto4 from "node:crypto";
118628
+ import fs26 from "node:fs";
118629
+ import path30 from "node:path";
118446
118630
 
118447
118631
  // ../cli/src/lib/agent/cloud-studios.ts
118448
- import fs23 from "node:fs";
118449
- import path27 from "node:path";
118632
+ import fs25 from "node:fs";
118633
+ import path29 from "node:path";
118450
118634
 
118451
118635
  // ../cli/src/lib/shared/file-limits.ts
118452
118636
  var BOARD_FILE_LIMIT = 10 * 1024 * 1024;
@@ -118498,9 +118682,9 @@ function cardFront(body) {
118498
118682
  }
118499
118683
 
118500
118684
  // ../official/pack.ts
118501
- import crypto2 from "node:crypto";
118502
- import fs21 from "node:fs";
118503
- import path25 from "node:path";
118685
+ import crypto3 from "node:crypto";
118686
+ import fs23 from "node:fs";
118687
+ import path27 from "node:path";
118504
118688
  import { fileURLToPath as fileURLToPath2 } from "node:url";
118505
118689
 
118506
118690
  // ../cli/src/lib/agents/icon.ts
@@ -118923,8 +119107,8 @@ function parseStudioFile(id, source2, from) {
118923
119107
  }
118924
119108
 
118925
119109
  // ../cli/src/lib/agent/studio-folder.ts
118926
- import fs20 from "node:fs";
118927
- import path24 from "node:path";
119110
+ import fs22 from "node:fs";
119111
+ import path26 from "node:path";
118928
119112
 
118929
119113
  // ../cli/src/lib/shared/studio-files.ts
118930
119114
  var STUDIO_FILE = "STUDIO.md";
@@ -119059,34 +119243,34 @@ function inspect(value, official) {
119059
119243
  // ../cli/src/lib/agent/studio-folder.ts
119060
119244
  var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
119061
119245
  function filesOf(dir, base = dir) {
119062
- return fs20.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
119063
- const full = path24.join(dir, e2.name);
119064
- return e2.isDirectory() ? filesOf(full, base) : [path24.relative(base, full).split(path24.sep).join("/")];
119246
+ return fs22.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
119247
+ const full = path26.join(dir, e2.name);
119248
+ return e2.isDirectory() ? filesOf(full, base) : [path26.relative(base, full).split(path26.sep).join("/")];
119065
119249
  });
119066
119250
  }
119067
119251
  function readStudioFile(dir, file3) {
119068
- const full = path24.join(dir, file3);
119069
- return isAboutFile(file3) && !file3.endsWith(".md") ? `data:${MIME[path24.extname(file3)]};base64,${fs20.readFileSync(full).toString("base64")}` : fs20.readFileSync(full, "utf8");
119252
+ const full = path26.join(dir, file3);
119253
+ return isAboutFile(file3) && !file3.endsWith(".md") ? `data:${MIME[path26.extname(file3)]};base64,${fs22.readFileSync(full).toString("base64")}` : fs22.readFileSync(full, "utf8");
119070
119254
  }
119071
119255
  var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readStudioFile(dir, f2)]));
119072
119256
 
119073
119257
  // ../official/pack.ts
119074
- var OFFICIAL = path25.dirname(fileURLToPath2(import.meta.url));
119075
- var dirs = (dir) => fs21.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
119076
- var hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
119258
+ var OFFICIAL = path27.dirname(fileURLToPath2(import.meta.url));
119259
+ var dirs = (dir) => fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
119260
+ var hashOf = (files) => crypto3.createHash("sha256").update(hashInput(files)).digest("hex");
119077
119261
  function packOfficial(root2 = OFFICIAL, loose = false) {
119078
- const agentsDir = path25.join(root2, "agents");
119262
+ const agentsDir = path27.join(root2, "agents");
119079
119263
  const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
119080
- const dir = path25.join(agentsDir, name);
119264
+ const dir = path27.join(agentsDir, name);
119081
119265
  return [name, readStudioFolder(dir)];
119082
119266
  }));
119083
119267
  for (const [name, own2] of Object.entries(loose ? {} : agentFiles)) {
119084
119268
  const read5 = parseSpecAgent(own2["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own2[p2] ?? null, true);
119085
119269
  if ("problem" in read5) throw new Error(read5.problem);
119086
119270
  }
119087
- const studiosDir = path25.join(root2, "studios");
119271
+ const studiosDir = path27.join(root2, "studios");
119088
119272
  return dirs(studiosDir).map((folder) => {
119089
- const dir = path25.join(studiosDir, folder);
119273
+ const dir = path27.join(studiosDir, folder);
119090
119274
  const files = {};
119091
119275
  for (const f2 of filesOf(dir).sort()) {
119092
119276
  if (f2 === STUDIO_FILE || f2 === CARD_TEMPLATE_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || f2.startsWith(SHARED_DIR) || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
@@ -119118,23 +119302,23 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
119118
119302
  }
119119
119303
 
119120
119304
  // ../cli/src/lib/cloud/tasks.ts
119121
- import fs22 from "node:fs";
119122
- import path26 from "node:path";
119305
+ import fs24 from "node:fs";
119306
+ import path28 from "node:path";
119123
119307
  var TASK_ENV = "AI4KANBAN_TASK";
119124
119308
  function workspaceTask() {
119125
119309
  const id = process.env[TASK_ENV];
119126
119310
  return id && id.trim() ? id.trim() : null;
119127
119311
  }
119128
119312
  function runnerProject(board) {
119129
- if (path26.basename(board) !== "kanban" || path26.basename(path26.dirname(board)) !== ".akb") return null;
119130
- const linked = linkedProject(board, path26.dirname(path26.dirname(board)));
119313
+ if (path28.basename(board) !== "kanban" || path28.basename(path28.dirname(board)) !== ".akb") return null;
119314
+ const linked = linkedProject(board, path28.dirname(path28.dirname(board)));
119131
119315
  return linked.ok ? linked.value : null;
119132
119316
  }
119133
119317
  function linkedProject(board, root2) {
119134
- const file3 = path26.join(root2, ".akb", "base.json");
119135
- if (!fs22.existsSync(file3)) return { ok: true, value: null };
119318
+ const file3 = path28.join(root2, ".akb", "base.json");
119319
+ if (!fs24.existsSync(file3)) return { ok: true, value: null };
119136
119320
  try {
119137
- const base = JSON.parse(fs22.readFileSync(file3, "utf8"));
119321
+ const base = JSON.parse(fs24.readFileSync(file3, "utf8"));
119138
119322
  if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
119139
119323
  const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
119140
119324
  if (typeof base.project === "string") projects.add(base.project);
@@ -119147,29 +119331,29 @@ function linkedProject(board, root2) {
119147
119331
 
119148
119332
  // ../cli/src/lib/agent/cloud-studios.ts
119149
119333
  var DEV = "AI4KANBAN_STUDIOS";
119150
- var root = () => path27.join(machineHome(), "studios");
119334
+ var root = () => path29.join(machineHome(), "studios");
119151
119335
  var safe = (name) => name.replace(/[^\w.@-]/g, "_");
119152
- var versionFile = (id, version) => path27.join(root(), "versions", `${safe(id)}@${version}.json`);
119153
- var listFile = (project) => path27.join(root(), "lists", `${safe(project)}.json`);
119154
- var pinFile = (task) => path27.join(root(), "tasks", `${safe(task)}.json`);
119336
+ var versionFile = (id, version) => path29.join(root(), "versions", `${safe(id)}@${version}.json`);
119337
+ var listFile = (project) => path29.join(root(), "lists", `${safe(project)}.json`);
119338
+ var pinFile = (task) => path29.join(root(), "tasks", `${safe(task)}.json`);
119155
119339
  function readJson(file3) {
119156
119340
  try {
119157
- return JSON.parse(fs23.readFileSync(file3, "utf8"));
119341
+ return JSON.parse(fs25.readFileSync(file3, "utf8"));
119158
119342
  } catch {
119159
119343
  return null;
119160
119344
  }
119161
119345
  }
119162
119346
  function writeJson(file3, value) {
119163
- fs23.mkdirSync(path27.dirname(file3), { recursive: true });
119347
+ fs25.mkdirSync(path29.dirname(file3), { recursive: true });
119164
119348
  const tmp = `${file3}.${process.pid}.tmp`;
119165
- fs23.writeFileSync(tmp, `${JSON.stringify(value)}
119349
+ fs25.writeFileSync(tmp, `${JSON.stringify(value)}
119166
119350
  `);
119167
- fs23.renameSync(tmp, file3);
119351
+ fs25.renameSync(tmp, file3);
119168
119352
  }
119169
119353
  var readVersion2 = (id, version) => readJson(versionFile(id, version));
119170
119354
  function saveVersion(held5) {
119171
119355
  const file3 = versionFile(held5.id, held5.version);
119172
- if (!fs23.existsSync(file3)) writeJson(file3, { id: held5.id, version: held5.version, name: held5.name, names: held5.names, files: held5.files });
119356
+ if (!fs25.existsSync(file3)) writeJson(file3, { id: held5.id, version: held5.version, name: held5.name, names: held5.names, files: held5.files });
119173
119357
  }
119174
119358
  function savePin(task, held5) {
119175
119359
  saveVersion(held5);
@@ -119178,22 +119362,22 @@ function savePin(task, held5) {
119178
119362
  var readPin = (task) => readJson(pinFile(task));
119179
119363
  var jsonIn = (dir) => {
119180
119364
  try {
119181
- return fs23.readdirSync(path27.join(root(), dir)).filter((f2) => f2.endsWith(".json"));
119365
+ return fs25.readdirSync(path29.join(root(), dir)).filter((f2) => f2.endsWith(".json"));
119182
119366
  } catch {
119183
119367
  return [];
119184
119368
  }
119185
119369
  };
119186
119370
  async function sweepVersions(ended2) {
119187
119371
  const keep2 = /* @__PURE__ */ new Set();
119188
- const held5 = (id, version) => keep2.add(path27.basename(versionFile(id, version)));
119372
+ const held5 = (id, version) => keep2.add(path29.basename(versionFile(id, version)));
119189
119373
  for (const file3 of jsonIn("tasks")) {
119190
- const at2 = path27.join(root(), "tasks", file3);
119374
+ const at2 = path29.join(root(), "tasks", file3);
119191
119375
  const pin = readJson(at2);
119192
- if (!pin || await ended2(file3.slice(0, -".json".length))) fs23.rmSync(at2, { force: true });
119376
+ if (!pin || await ended2(file3.slice(0, -".json".length))) fs25.rmSync(at2, { force: true });
119193
119377
  else held5(pin.studio, pin.version);
119194
119378
  }
119195
119379
  for (const file3 of jsonIn("lists")) {
119196
- for (const w2 of readJson(path27.join(root(), "lists", file3))?.studios ?? []) held5(w2.id, w2.version);
119380
+ for (const w2 of readJson(path29.join(root(), "lists", file3))?.studios ?? []) held5(w2.id, w2.version);
119197
119381
  }
119198
119382
  const versions = jsonIn("versions");
119199
119383
  const newest2 = /* @__PURE__ */ new Map();
@@ -119203,7 +119387,7 @@ async function sweepVersions(ended2) {
119203
119387
  if (version > (newest2.get(id) ?? -1)) newest2.set(id, version);
119204
119388
  }
119205
119389
  const gone = versions.filter((file3) => !keep2.has(file3) && newest2.get(parts(file3).id) !== parts(file3).version);
119206
- for (const file3 of gone) fs23.rmSync(path27.join(root(), "versions", file3), { force: true });
119390
+ for (const file3 of gone) fs25.rmSync(path29.join(root(), "versions", file3), { force: true });
119207
119391
  return gone;
119208
119392
  }
119209
119393
  var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
@@ -119263,39 +119447,39 @@ function cloudAgentFiles() {
119263
119447
  var IDLE_MS = 7 * 24 * 60 * 6e4;
119264
119448
  var SWEEP_MS = 24 * 60 * 6e4;
119265
119449
  var PROJECT_ID = /^[\w-]{1,100}$/;
119266
- var cacheRoot = () => path28.join(runnerHome(), "cache");
119450
+ var cacheRoot = () => path30.join(runnerHome(), "cache");
119267
119451
  function cacheDir(project) {
119268
119452
  if (!PROJECT_ID.test(project)) throw new Error("This job names no project.");
119269
- return path28.join(cacheRoot(), project);
119453
+ return path30.join(cacheRoot(), project);
119270
119454
  }
119271
- var akbDir = (dir) => path28.join(dir, ".akb");
119272
- var usedFile = (dir) => path28.join(akbDir(dir), "used.json");
119273
- var unsentFile = (dir) => path28.join(akbDir(dir), "unsent");
119455
+ var akbDir = (dir) => path30.join(dir, ".akb");
119456
+ var usedFile = (dir) => path30.join(akbDir(dir), "used.json");
119457
+ var unsentFile = (dir) => path30.join(akbDir(dir), "unsent");
119274
119458
  function markUsed(dir, at2 = Date.now()) {
119275
- fs24.mkdirSync(akbDir(dir), { recursive: true });
119276
- fs24.writeFileSync(usedFile(dir), `${JSON.stringify({ at: at2 })}
119459
+ fs26.mkdirSync(akbDir(dir), { recursive: true });
119460
+ fs26.writeFileSync(usedFile(dir), `${JSON.stringify({ at: at2 })}
119277
119461
  `);
119278
119462
  }
119279
119463
  function usedAt(dir) {
119280
119464
  try {
119281
- const at2 = JSON.parse(fs24.readFileSync(usedFile(dir), "utf8")).at;
119465
+ const at2 = JSON.parse(fs26.readFileSync(usedFile(dir), "utf8")).at;
119282
119466
  return typeof at2 === "number" ? at2 : null;
119283
119467
  } catch {
119284
119468
  return null;
119285
119469
  }
119286
119470
  }
119287
- var unsent = (dir) => fs24.existsSync(unsentFile(dir));
119471
+ var unsent = (dir) => fs26.existsSync(unsentFile(dir));
119288
119472
  function markUnsent(dir, unsent2) {
119289
- if (!unsent2) return void fs24.rmSync(unsentFile(dir), { force: true });
119290
- fs24.mkdirSync(akbDir(dir), { recursive: true });
119291
- fs24.writeFileSync(unsentFile(dir), "");
119473
+ if (!unsent2) return void fs26.rmSync(unsentFile(dir), { force: true });
119474
+ fs26.mkdirSync(akbDir(dir), { recursive: true });
119475
+ fs26.writeFileSync(unsentFile(dir), "");
119292
119476
  }
119293
119477
  var holds = /* @__PURE__ */ new Map();
119294
- var holdsDir = () => path28.join(runnerHome(), "holds");
119295
- var holdFile = (dir) => path28.join(holdsDir(), `${crypto3.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
119478
+ var holdsDir = () => path30.join(runnerHome(), "holds");
119479
+ var holdFile = (dir) => path30.join(holdsDir(), `${crypto4.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
119296
119480
  function hold(dir) {
119297
- fs24.mkdirSync(holdsDir(), { recursive: true, mode: 448 });
119298
- fs24.writeFileSync(holdFile(dir), "", { mode: 384 });
119481
+ fs26.mkdirSync(holdsDir(), { recursive: true, mode: 448 });
119482
+ fs26.writeFileSync(holdFile(dir), "", { mode: 384 });
119299
119483
  holds.set(dir, (holds.get(dir) ?? 0) + 1);
119300
119484
  let held5 = true;
119301
119485
  return () => {
@@ -119305,14 +119489,14 @@ function hold(dir) {
119305
119489
  if (left) holds.set(dir, left);
119306
119490
  else {
119307
119491
  holds.delete(dir);
119308
- fs24.rmSync(holdFile(dir), { force: true });
119492
+ fs26.rmSync(holdFile(dir), { force: true });
119309
119493
  }
119310
119494
  };
119311
119495
  }
119312
119496
  function paused(dir) {
119313
119497
  try {
119314
- const file3 = path28.join(projectStateDir(path28.join(akbDir(dir), "kanban")), SESSIONS_FILE);
119315
- const held5 = JSON.parse(fs24.readFileSync(file3, "utf8"));
119498
+ const file3 = path30.join(projectStateDir(path30.join(akbDir(dir), "kanban")), SESSIONS_FILE);
119499
+ const held5 = JSON.parse(fs26.readFileSync(file3, "utf8"));
119316
119500
  return (held5.deliveries ?? []).some((d2) => d2.status === "active");
119317
119501
  } catch {
119318
119502
  return false;
@@ -119320,14 +119504,14 @@ function paused(dir) {
119320
119504
  }
119321
119505
  function busy(dir) {
119322
119506
  if (holds.has(dir)) return true;
119323
- const prefix = path28.basename(holdFile(dir)).split(".")[0] + ".";
119507
+ const prefix = path30.basename(holdFile(dir)).split(".")[0] + ".";
119324
119508
  try {
119325
- return fs24.readdirSync(holdsDir()).filter((file3) => file3.startsWith(prefix)).some((file3) => {
119509
+ return fs26.readdirSync(holdsDir()).filter((file3) => file3.startsWith(prefix)).some((file3) => {
119326
119510
  try {
119327
119511
  process.kill(Number(file3.split(".")[1]), 0);
119328
119512
  return true;
119329
119513
  } catch {
119330
- fs24.rmSync(path28.join(holdsDir(), file3), { force: true });
119514
+ fs26.rmSync(path30.join(holdsDir(), file3), { force: true });
119331
119515
  return false;
119332
119516
  }
119333
119517
  });
@@ -119338,14 +119522,14 @@ function busy(dir) {
119338
119522
  var kept2 = (dir) => busy(dir) || unsent(dir) || paused(dir);
119339
119523
  function clearAkb(dir) {
119340
119524
  dir = realpath2(dir);
119341
- if (kept2(dir) || fs24.existsSync(path28.join(akbDir(dir), "worktrees")) || fs24.existsSync(path28.join(akbDir(dir), "handoffs"))) return false;
119525
+ if (kept2(dir) || fs26.existsSync(path30.join(akbDir(dir), "worktrees")) || fs26.existsSync(path30.join(akbDir(dir), "handoffs"))) return false;
119342
119526
  let entries;
119343
119527
  try {
119344
- entries = fs24.readdirSync(akbDir(dir));
119528
+ entries = fs26.readdirSync(akbDir(dir));
119345
119529
  } catch {
119346
119530
  return true;
119347
119531
  }
119348
- for (const name of entries) fs24.rmSync(path28.join(akbDir(dir), name), { recursive: true, force: true });
119532
+ for (const name of entries) fs26.rmSync(path30.join(akbDir(dir), name), { recursive: true, force: true });
119349
119533
  return true;
119350
119534
  }
119351
119535
  async function readAccess(machineId2) {
@@ -119359,7 +119543,7 @@ async function readAccess(machineId2) {
119359
119543
  }
119360
119544
  function realpath2(p2) {
119361
119545
  try {
119362
- return fs24.realpathSync(p2);
119546
+ return fs26.realpathSync(p2);
119363
119547
  } catch {
119364
119548
  return p2;
119365
119549
  }
@@ -119374,22 +119558,22 @@ async function sweepCache(machineId2, now = Date.now()) {
119374
119558
  const swept = [];
119375
119559
  let cached2 = [];
119376
119560
  try {
119377
- cached2 = fs24.readdirSync(cacheRoot(), { withFileTypes: true });
119561
+ cached2 = fs26.readdirSync(cacheRoot(), { withFileTypes: true });
119378
119562
  } catch {
119379
119563
  }
119380
119564
  for (const e2 of cached2) {
119381
- const dir = path28.join(cacheRoot(), e2.name);
119382
- if (!e2.isDirectory() || kept2(dir) || fs24.existsSync(path28.join(dir, ".git"))) continue;
119565
+ const dir = path30.join(cacheRoot(), e2.name);
119566
+ if (!e2.isDirectory() || kept2(dir) || fs26.existsSync(path30.join(dir, ".git"))) continue;
119383
119567
  const gone = access && !access.projects.has(e2.name);
119384
- if ((idle(dir, now) || gone) && !fs24.existsSync(path28.join(akbDir(dir), "worktrees")) && !fs24.existsSync(path28.join(akbDir(dir), "handoffs"))) {
119385
- fs24.rmSync(dir, { recursive: true, force: true });
119568
+ if ((idle(dir, now) || gone) && !fs26.existsSync(path30.join(akbDir(dir), "worktrees")) && !fs26.existsSync(path30.join(akbDir(dir), "handoffs"))) {
119569
+ fs26.rmSync(dir, { recursive: true, force: true });
119386
119570
  swept.push(dir);
119387
119571
  }
119388
119572
  }
119389
119573
  for (const dir of allowedProjects()) {
119390
119574
  let held5 = [];
119391
119575
  try {
119392
- held5 = fs24.readdirSync(akbDir(dir));
119576
+ held5 = fs26.readdirSync(akbDir(dir));
119393
119577
  } catch {
119394
119578
  }
119395
119579
  if (!held5.length) continue;
@@ -119405,34 +119589,34 @@ var sweepStudios = () => sweepVersions(async (task) => {
119405
119589
  });
119406
119590
  function removeLegacy() {
119407
119591
  const home4 = runnerHome();
119408
- for (const name of ["boards", "akb-bin"]) fs24.rmSync(path28.join(home4, name), { recursive: true, force: true });
119592
+ for (const name of ["boards", "akb-bin"]) fs26.rmSync(path30.join(home4, name), { recursive: true, force: true });
119409
119593
  let entries = [];
119410
119594
  try {
119411
- entries = fs24.readdirSync(home4, { withFileTypes: true });
119595
+ entries = fs26.readdirSync(home4, { withFileTypes: true });
119412
119596
  } catch {
119413
119597
  return;
119414
119598
  }
119415
119599
  for (const e2 of entries) {
119416
- const account = path28.join(home4, e2.name);
119417
- if (!e2.isDirectory() || !fs24.existsSync(path28.join(account, "unfiled"))) continue;
119418
- fs24.rmSync(path28.join(account, "unfiled"), { recursive: true, force: true });
119419
- if (!fs24.readdirSync(account).length) fs24.rmdirSync(account);
119600
+ const account = path30.join(home4, e2.name);
119601
+ if (!e2.isDirectory() || !fs26.existsSync(path30.join(account, "unfiled"))) continue;
119602
+ fs26.rmSync(path30.join(account, "unfiled"), { recursive: true, force: true });
119603
+ if (!fs26.readdirSync(account).length) fs26.rmdirSync(account);
119420
119604
  }
119421
119605
  }
119422
119606
 
119423
119607
  // src/update.ts
119424
- import crypto4 from "node:crypto";
119425
- import fs25 from "node:fs";
119426
- import path29 from "node:path";
119608
+ import crypto5 from "node:crypto";
119609
+ import fs27 from "node:fs";
119610
+ import path31 from "node:path";
119427
119611
  import zlib from "node:zlib";
119428
119612
  var TIMEOUT_MS2 = 6e4;
119429
- var versionsDir = () => path29.join(runnerHome(), "bin", "runner");
119430
- var versionDir = (version) => path29.join(versionsDir(), version);
119431
- var entryOf = (dir) => path29.join(dir, "dist", "runner.mjs");
119613
+ var versionsDir = () => path31.join(runnerHome(), "bin", "runner");
119614
+ var versionDir = (version) => path31.join(versionsDir(), version);
119615
+ var entryOf = (dir) => path31.join(dir, "dist", "runner.mjs");
119432
119616
  var registry = () => (process.env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
119433
119617
  async function installPackage(pkg, version, nodeVersion = process.versions.node) {
119434
119618
  const dir = pkg.dirOf(version);
119435
- if (fs25.existsSync(pkg.entryOf(dir))) return { ok: true, dir };
119619
+ if (fs27.existsSync(pkg.entryOf(dir))) return { ok: true, dir };
119436
119620
  let meta;
119437
119621
  let tarball;
119438
119622
  try {
@@ -119449,17 +119633,17 @@ async function installPackage(pkg, version, nodeVersion = process.versions.node)
119449
119633
  return { ok: false, why: "unreachable", detail: e2 instanceof Error ? e2.message : String(e2) };
119450
119634
  }
119451
119635
  const expected = /^sha512-(.+)$/.exec(meta.dist.integrity ?? "")?.[1];
119452
- const actual = crypto4.createHash("sha512").update(tarball).digest("base64");
119636
+ const actual = crypto5.createHash("sha512").update(tarball).digest("base64");
119453
119637
  if (!expected || expected !== actual) return { ok: false, why: "integrity", detail: "sha512 mismatch" };
119454
119638
  const staging = `${dir}.${process.pid}.tmp`;
119455
119639
  try {
119456
- fs25.rmSync(staging, { recursive: true, force: true });
119640
+ fs27.rmSync(staging, { recursive: true, force: true });
119457
119641
  extract(zlib.gunzipSync(tarball), staging);
119458
- if (!fs25.existsSync(pkg.entryOf(staging))) throw new Error(`the package carries no ${path29.relative(staging, pkg.entryOf(staging))}`);
119459
- fs25.rmSync(dir, { recursive: true, force: true });
119460
- fs25.renameSync(staging, dir);
119642
+ if (!fs27.existsSync(pkg.entryOf(staging))) throw new Error(`the package carries no ${path31.relative(staging, pkg.entryOf(staging))}`);
119643
+ fs27.rmSync(dir, { recursive: true, force: true });
119644
+ fs27.renameSync(staging, dir);
119461
119645
  } catch (e2) {
119462
- fs25.rmSync(staging, { recursive: true, force: true });
119646
+ fs27.rmSync(staging, { recursive: true, force: true });
119463
119647
  return { ok: false, why: "integrity", detail: e2 instanceof Error ? e2.message : String(e2) };
119464
119648
  }
119465
119649
  return { ok: true, dir };
@@ -119489,12 +119673,12 @@ function extract(tar, into) {
119489
119673
  if (type !== "0" && type !== "5") continue;
119490
119674
  const relative = name.replace(/^[^/]+\//, "");
119491
119675
  if (!relative) continue;
119492
- const target = path29.resolve(into, relative);
119493
- if (!target.startsWith(path29.resolve(into) + path29.sep)) throw new Error(`refusing ${name}`);
119494
- if (type === "5") fs25.mkdirSync(target, { recursive: true });
119676
+ const target = path31.resolve(into, relative);
119677
+ if (!target.startsWith(path31.resolve(into) + path31.sep)) throw new Error(`refusing ${name}`);
119678
+ if (type === "5") fs27.mkdirSync(target, { recursive: true });
119495
119679
  else {
119496
- fs25.mkdirSync(path29.dirname(target), { recursive: true });
119497
- fs25.writeFileSync(target, body);
119680
+ fs27.mkdirSync(path31.dirname(target), { recursive: true });
119681
+ fs27.writeFileSync(target, body);
119498
119682
  }
119499
119683
  }
119500
119684
  }
@@ -119555,33 +119739,33 @@ function meets(version, comparator) {
119555
119739
  // src/akb-version.ts
119556
119740
  var CHECK_MS2 = 1e4;
119557
119741
  var VERSION2 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
119558
- var stateFile = () => path30.join(akbHome(), "state.json");
119559
- var akbVersionDir = (version) => path30.join(akbHome(), version);
119560
- var entryOf2 = (dir) => path30.join(dir, "bin", "ai4kanban.mjs");
119742
+ var stateFile = () => path32.join(akbHome(), "state.json");
119743
+ var akbVersionDir = (version) => path32.join(akbHome(), version);
119744
+ var entryOf2 = (dir) => path32.join(dir, "bin", "ai4kanban.mjs");
119561
119745
  var AKB = { name: "wildcrane", dirOf: akbVersionDir, entryOf: entryOf2 };
119562
119746
  function readAkbState() {
119563
119747
  try {
119564
- const held5 = JSON.parse(fs26.readFileSync(stateFile(), "utf8"));
119748
+ const held5 = JSON.parse(fs28.readFileSync(stateFile(), "utf8"));
119565
119749
  return { current: held5.current ?? null, bad: held5.bad ?? [] };
119566
119750
  } catch {
119567
119751
  return { current: null, bad: [] };
119568
119752
  }
119569
119753
  }
119570
119754
  function writeAkbState(state) {
119571
- fs26.mkdirSync(akbHome(), { recursive: true });
119755
+ fs28.mkdirSync(akbHome(), { recursive: true });
119572
119756
  const staging = `${stateFile()}.${process.pid}.tmp`;
119573
- fs26.writeFileSync(staging, `${JSON.stringify(state, null, 2)}
119757
+ fs28.writeFileSync(staging, `${JSON.stringify(state, null, 2)}
119574
119758
  `);
119575
- fs26.renameSync(staging, stateFile());
119759
+ fs28.renameSync(staging, stateFile());
119576
119760
  }
119577
119761
  function contractOf(dir) {
119578
119762
  try {
119579
- return JSON.parse(fs26.readFileSync(path30.join(dir, "package.json"), "utf8")).akbContract ?? null;
119763
+ return JSON.parse(fs28.readFileSync(path32.join(dir, "package.json"), "utf8")).akbContract ?? null;
119580
119764
  } catch {
119581
119765
  return null;
119582
119766
  }
119583
119767
  }
119584
- var usable = (dir) => fs26.existsSync(entryOf2(dir)) && contractOf(dir) === AKB_CONTRACT;
119768
+ var usable = (dir) => fs28.existsSync(entryOf2(dir)) && contractOf(dir) === AKB_CONTRACT;
119585
119769
  function currentAkb() {
119586
119770
  const { current: current2 } = readAkbState();
119587
119771
  if (!current2) return bundledAkb();
@@ -119589,10 +119773,10 @@ function currentAkb() {
119589
119773
  if (!usable(dir)) return bundledAkb();
119590
119774
  try {
119591
119775
  const now = /* @__PURE__ */ new Date();
119592
- fs26.utimesSync(dir, now, now);
119776
+ fs28.utimesSync(dir, now, now);
119593
119777
  } catch {
119594
119778
  }
119595
- return { command: process.execPath, args: akbArgs(entryOf2(dir)), version: current2, shim: path30.join(dir, "shim") };
119779
+ return { command: process.execPath, args: akbArgs(entryOf2(dir)), version: current2, shim: path32.join(dir, "shim") };
119596
119780
  }
119597
119781
  var answers2 = (dir, version) => new Promise((resolve2) => {
119598
119782
  execFile(process.execPath, [entryOf2(dir), "--version"], { cwd: runnerCwd(), timeout: CHECK_MS2, killSignal: "SIGKILL" }, (error, stdout) => resolve2(!error && stdout.trim().split(/\s+/).at(-1) === version));
@@ -119632,37 +119816,37 @@ function sweepAkb(now = Date.now()) {
119632
119816
  const { current: current2 } = readAkbState();
119633
119817
  let entries = [];
119634
119818
  try {
119635
- entries = fs26.readdirSync(akbHome(), { withFileTypes: true });
119819
+ entries = fs28.readdirSync(akbHome(), { withFileTypes: true });
119636
119820
  } catch {
119637
119821
  return;
119638
119822
  }
119639
119823
  for (const e2 of entries) {
119640
119824
  if (!e2.isDirectory() || e2.name === current2 || e2.name === BUNDLED_SHIM) continue;
119641
- const dir = path30.join(akbHome(), e2.name);
119642
- if (!busy(dir) && now - fs26.statSync(dir).mtimeMs > IDLE_MS) fs26.rmSync(dir, { recursive: true, force: true });
119825
+ const dir = path32.join(akbHome(), e2.name);
119826
+ if (!busy(dir) && now - fs28.statSync(dir).mtimeMs > IDLE_MS) fs28.rmSync(dir, { recursive: true, force: true });
119643
119827
  }
119644
119828
  }
119645
119829
 
119646
119830
  // src/chats.ts
119647
- import fs28 from "node:fs";
119648
- import path32 from "node:path";
119831
+ import fs30 from "node:fs";
119832
+ import path34 from "node:path";
119649
119833
 
119650
119834
  // ../cli/src/lib/shared/chats.ts
119651
119835
  var CHAT_KEEP_DAYS = 30;
119652
119836
 
119653
119837
  // ../cli/src/lib/agent/task-chats.ts
119654
- import fs27 from "node:fs";
119655
- import path31 from "node:path";
119838
+ import fs29 from "node:fs";
119839
+ import path33 from "node:path";
119656
119840
  var TASK = /^[\w-]{1,100}$/;
119657
- var taskChatsDir = (home4 = machineHome()) => path31.join(home4, "chats");
119841
+ var taskChatsDir = (home4 = machineHome()) => path33.join(home4, "chats");
119658
119842
  function taskChatFile(task, home4) {
119659
119843
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
119660
- return path31.join(taskChatsDir(home4), `${task}.jsonl`);
119844
+ return path33.join(taskChatsDir(home4), `${task}.jsonl`);
119661
119845
  }
119662
119846
  function readTaskChat(task, home4) {
119663
119847
  let text4;
119664
119848
  try {
119665
- text4 = fs27.readFileSync(taskChatFile(task, home4), "utf8");
119849
+ text4 = fs29.readFileSync(taskChatFile(task, home4), "utf8");
119666
119850
  } catch {
119667
119851
  return [];
119668
119852
  }
@@ -119683,18 +119867,18 @@ var DAY_MS = 24 * 60 * 6e4;
119683
119867
  var REVIEW_EVERY_MS = DAY_MS;
119684
119868
  var KEEP_MS2 = CHAT_KEEP_DAYS * DAY_MS;
119685
119869
  var home3 = () => runnerHome();
119686
- var reviewedFile = () => path32.join(taskChatsDir(home3()), "reviewed.json");
119870
+ var reviewedFile = () => path34.join(taskChatsDir(home3()), "reviewed.json");
119687
119871
  function readReviewed() {
119688
119872
  try {
119689
- const held5 = JSON.parse(fs28.readFileSync(reviewedFile(), "utf8"));
119873
+ const held5 = JSON.parse(fs30.readFileSync(reviewedFile(), "utf8"));
119690
119874
  return { checkedAt: Number(held5.checkedAt) || 0, tasks: held5.tasks ?? {} };
119691
119875
  } catch {
119692
119876
  return { checkedAt: 0, tasks: {} };
119693
119877
  }
119694
119878
  }
119695
119879
  function writeReviewed(reviewed) {
119696
- fs28.mkdirSync(path32.dirname(reviewedFile()), { recursive: true });
119697
- fs28.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
119880
+ fs30.mkdirSync(path34.dirname(reviewedFile()), { recursive: true });
119881
+ fs30.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
119698
119882
  `);
119699
119883
  }
119700
119884
  function keepChat(job, reply, at2 = Date.now()) {
@@ -119704,16 +119888,16 @@ function keepChat(job, reply, at2 = Date.now()) {
119704
119888
  { id: job.id, role: "agent", text: reply, at: at2, runtime: job.runtime, model: job.model ?? null }
119705
119889
  ];
119706
119890
  const file3 = taskChatFile(job.task, home3());
119707
- fs28.mkdirSync(path32.dirname(file3), { recursive: true });
119708
- fs28.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119891
+ fs30.mkdirSync(path34.dirname(file3), { recursive: true });
119892
+ fs30.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119709
119893
  `).join(""));
119710
119894
  }
119711
119895
  function keepCloudChat(task, messages) {
119712
119896
  const file3 = taskChatFile(task, home3());
119713
- if (!messages.length) return fs28.rmSync(file3, { force: true });
119897
+ if (!messages.length) return fs30.rmSync(file3, { force: true });
119714
119898
  const lines = messages.map((m) => ({ id: m.id, role: m.role, text: m.body, at: Date.parse(m.created_at) || Date.now() }));
119715
- fs28.mkdirSync(path32.dirname(file3), { recursive: true });
119716
- fs28.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119899
+ fs30.mkdirSync(path34.dirname(file3), { recursive: true });
119900
+ fs30.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119717
119901
  `).join(""));
119718
119902
  }
119719
119903
  async function keepDecisions(task, read5) {
@@ -119731,13 +119915,13 @@ async function keepDecisions(task, read5) {
119731
119915
  const ids = new Set(comments.map((c2) => c2.id));
119732
119916
  const lines = [...readTaskChat(task, home3()).filter((l2) => !ids.has(l2.id)), ...comments].sort((a2, b2) => a2.at - b2.at);
119733
119917
  const file3 = taskChatFile(task, home3());
119734
- fs28.mkdirSync(path32.dirname(file3), { recursive: true });
119735
- fs28.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119918
+ fs30.mkdirSync(path34.dirname(file3), { recursive: true });
119919
+ fs30.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
119736
119920
  `).join(""));
119737
119921
  }
119738
119922
  var tasksKept = () => {
119739
119923
  try {
119740
- return fs28.readdirSync(taskChatsDir(home3())).map((n) => /^([\w-]{1,100})\.jsonl$/.exec(n)?.[1]).filter((t2) => !!t2);
119924
+ return fs30.readdirSync(taskChatsDir(home3())).map((n) => /^([\w-]{1,100})\.jsonl$/.exec(n)?.[1]).filter((t2) => !!t2);
119741
119925
  } catch {
119742
119926
  return [];
119743
119927
  }
@@ -119748,9 +119932,9 @@ function pruneChats(now = Date.now()) {
119748
119932
  const kept4 = lines.filter((l2) => now - l2.at < KEEP_MS2);
119749
119933
  if (kept4.length === lines.length) continue;
119750
119934
  const file3 = taskChatFile(task, home3());
119751
- if (kept4.length) fs28.writeFileSync(file3, kept4.map((l2) => `${JSON.stringify(l2)}
119935
+ if (kept4.length) fs30.writeFileSync(file3, kept4.map((l2) => `${JSON.stringify(l2)}
119752
119936
  `).join(""));
119753
- else fs28.rmSync(file3, { force: true });
119937
+ else fs30.rmSync(file3, { force: true });
119754
119938
  }
119755
119939
  }
119756
119940
  var lastOf = (task) => readTaskChat(task, home3()).at(-1);
@@ -119788,8 +119972,8 @@ async function reviewChats(machineId2, runtimes, now = Date.now()) {
119788
119972
  }
119789
119973
 
119790
119974
  // src/board-watch.ts
119791
- import fs34 from "node:fs";
119792
- import path38 from "node:path";
119975
+ import fs36 from "node:fs";
119976
+ import path40 from "node:path";
119793
119977
 
119794
119978
  // ../artifact-sdk/src/builtin/compare.json
119795
119979
  var compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/b", "types": ["storyboard", "compare", "spritesheet", "studio"] },\n { "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "studio"] }\n ]\n}\n';
@@ -120199,9 +120383,9 @@ function collectSources(sources2, card, host) {
120199
120383
  }
120200
120384
 
120201
120385
  // src/task-folder.ts
120202
- import crypto5 from "node:crypto";
120203
- import fs33 from "node:fs";
120204
- import path37 from "node:path";
120386
+ import crypto6 from "node:crypto";
120387
+ import fs35 from "node:fs";
120388
+ import path39 from "node:path";
120205
120389
  import { isDeepStrictEqual } from "node:util";
120206
120390
 
120207
120391
  // node_modules/node-diff3/dist/diff3.mjs
@@ -120449,9 +120633,9 @@ function renderError(error) {
120449
120633
  init_dress_page();
120450
120634
 
120451
120635
  // src/kanban-skill.ts
120452
- import { spawnSync as spawnSync4 } from "node:child_process";
120453
- import fs30 from "node:fs";
120454
- import path34 from "node:path";
120636
+ import { spawnSync as spawnSync5 } from "node:child_process";
120637
+ import fs32 from "node:fs";
120638
+ import path36 from "node:path";
120455
120639
 
120456
120640
  // ../skill/SKILL.md
120457
120641
  var SKILL_default = '---\nname: kanban\ndescription: Manage the file-based task board with akb. Use for creating and planning tasks, revising or implementing cards, and managing background runs; also for "what\'s running".\n---\n\n# Kanban board\n\nThe board is worked only through `akb`. Find the command for the job in `akb help` and run\nit; never do its work by hand or from memory.\n\n- **`--print` does it here**: `akb raw card revise 12 --print "drop the export"` prints the whole\n flow for that card on this board; follow it to its closing steps. Without `--print` the\n same command starts a separate agent.\n- **Keys**: never read or write API keys; the user sets them with `akb raw agent set apiKey`.\n';
@@ -120465,24 +120649,24 @@ var CONTENT = `${SKILL_default.trimEnd()}
120465
120649
  var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
120466
120650
  function prepareKanbanSkill(root2) {
120467
120651
  for (const folder of SKILL_FOLDERS) {
120468
- const dir = path34.join(root2, folder);
120469
- const file3 = path34.join(dir, "SKILL.md");
120652
+ const dir = path36.join(root2, folder);
120653
+ const file3 = path36.join(dir, "SKILL.md");
120470
120654
  try {
120471
120655
  let linked = false;
120472
120656
  let at2 = root2;
120473
120657
  for (const name of `${folder}/SKILL.md`.split("/")) {
120474
- at2 = path34.join(at2, name);
120475
- if (fs30.lstatSync(at2, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
120658
+ at2 = path36.join(at2, name);
120659
+ if (fs32.lstatSync(at2, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
120476
120660
  }
120477
- const held5 = fs30.existsSync(file3) ? fs30.readFileSync(file3, "utf8") : null;
120478
- const exists = fs30.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
120661
+ const held5 = fs32.existsSync(file3) ? fs32.readFileSync(file3, "utf8") : null;
120662
+ const exists = fs32.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
120479
120663
  if (linked || exists && !MANAGED.test(held5 ?? "")) {
120480
120664
  if (!held5?.trim()) throw new Error("\u7528\u6237\u81EA\u6709\u76EE\u5F55\u6216\u7B26\u53F7\u94FE\u63A5\u4E2D\u7F3A\u5C11\u53EF\u8BFB\u7684 SKILL.md");
120481
120665
  continue;
120482
120666
  }
120483
120667
  if (held5 !== CONTENT) {
120484
- fs30.mkdirSync(dir, { recursive: true });
120485
- fs30.writeFileSync(file3, CONTENT);
120668
+ fs32.mkdirSync(dir, { recursive: true });
120669
+ fs32.writeFileSync(file3, CONTENT);
120486
120670
  }
120487
120671
  } catch (e2) {
120488
120672
  throw new Error(`\u65E0\u6CD5\u51C6\u5907 ${folder}\uFF1A${e2 instanceof Error ? e2.message : String(e2)}`);
@@ -120490,15 +120674,15 @@ function prepareKanbanSkill(root2) {
120490
120674
  }
120491
120675
  }
120492
120676
  function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
120493
- const git3 = (...args2) => spawnSync4("git", ["-C", dir, ...args2], { encoding: "utf8" });
120677
+ const git3 = (...args2) => spawnSync5("git", ["-C", dir, ...args2], { encoding: "utf8" });
120494
120678
  const inside2 = git3("rev-parse", "--git-path", "info/exclude");
120495
120679
  if (inside2.status !== 0) return;
120496
120680
  const missing = [".akb/", ...folders2.map((f2) => `${f2}/`)].filter((p2) => git3("check-ignore", "-q", p2).status !== 0);
120497
120681
  if (!missing.length) return;
120498
- const exclude = path34.resolve(dir, inside2.stdout.trim());
120499
- fs30.mkdirSync(path34.dirname(exclude), { recursive: true });
120500
- const held5 = fs30.existsSync(exclude) ? fs30.readFileSync(exclude, "utf8") : "";
120501
- fs30.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
120682
+ const exclude = path36.resolve(dir, inside2.stdout.trim());
120683
+ fs32.mkdirSync(path36.dirname(exclude), { recursive: true });
120684
+ const held5 = fs32.existsSync(exclude) ? fs32.readFileSync(exclude, "utf8") : "";
120685
+ fs32.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
120502
120686
  `);
120503
120687
  }
120504
120688
  function installKanbanSkill(dir) {
@@ -120512,8 +120696,8 @@ function installKanbanSkill(dir) {
120512
120696
  }
120513
120697
 
120514
120698
  // ../cli/src/lib/agents/shared-memory.ts
120515
- import fs31 from "node:fs";
120516
- import path35 from "node:path";
120699
+ import fs33 from "node:fs";
120700
+ import path37 from "node:path";
120517
120701
 
120518
120702
  // ../cli/src/lib/agents/bundled.ts
120519
120703
  var shippedAgentFiles = () => cloudAgentFiles().files;
@@ -120527,7 +120711,7 @@ function sharedMemory(board) {
120527
120711
  const read5 = parseSpecAgent(text4, folder, (relative) => {
120528
120712
  if (builtIn) return shippedAgentFiles()[`${folder}/${relative}`] ?? null;
120529
120713
  try {
120530
- return fs31.readFileSync(path35.join(board, "agents", folder, relative), "utf8");
120714
+ return fs33.readFileSync(path37.join(board, "agents", folder, relative), "utf8");
120531
120715
  } catch {
120532
120716
  return null;
120533
120717
  }
@@ -120538,16 +120722,16 @@ function sharedMemory(board) {
120538
120722
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
120539
120723
  if (at2) take(at2[1], text4, officialAgent(at2[1]));
120540
120724
  }
120541
- const root2 = path35.join(board, "agents");
120725
+ const root2 = path37.join(board, "agents");
120542
120726
  let folders2 = [];
120543
120727
  try {
120544
- folders2 = fs31.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
120728
+ folders2 = fs33.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
120545
120729
  } catch {
120546
120730
  }
120547
120731
  for (const folder of folders2.sort()) {
120548
120732
  let text4 = null;
120549
120733
  try {
120550
- text4 = fs31.readFileSync(path35.join(root2, folder, "AGENT.md"), "utf8");
120734
+ text4 = fs33.readFileSync(path37.join(root2, folder, "AGENT.md"), "utf8");
120551
120735
  } catch {
120552
120736
  }
120553
120737
  take(folder, text4, false);
@@ -120576,8 +120760,8 @@ function logSync(event2, fields = {}) {
120576
120760
  if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields }));
120577
120761
  }
120578
120762
  if (syncDebug) {
120579
- const delay = monitorEventLoopDelay({ resolution: 20 });
120580
- delay.enable();
120763
+ const delay2 = monitorEventLoopDelay({ resolution: 20 });
120764
+ delay2.enable();
120581
120765
  let cpu = process.cpuUsage();
120582
120766
  let at2 = performance.now();
120583
120767
  setInterval(() => {
@@ -120585,14 +120769,14 @@ if (syncDebug) {
120585
120769
  const used = process.cpuUsage(cpu);
120586
120770
  logSync("health", {
120587
120771
  cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
120588
- delayMaxMs: Math.round(delay.max / 1e6),
120589
- delayP99Ms: Math.round(delay.percentile(99) / 1e6),
120772
+ delayMaxMs: Math.round(delay2.max / 1e6),
120773
+ delayP99Ms: Math.round(delay2.percentile(99) / 1e6),
120590
120774
  ...counts
120591
120775
  });
120592
120776
  for (const name of Object.keys(counts)) delete counts[name];
120593
120777
  cpu = process.cpuUsage();
120594
120778
  at2 = now;
120595
- delay.reset();
120779
+ delay2.reset();
120596
120780
  }, 5e3).unref();
120597
120781
  }
120598
120782
 
@@ -120607,16 +120791,16 @@ function openTaskFolder(job, projectDir2) {
120607
120791
  if (!projectDir2) throw new Error(NO_FOLDER);
120608
120792
  keepOutOfGit(projectDir2);
120609
120793
  markUsed(projectDir2);
120610
- const board = path37.join(projectDir2, ".akb", "kanban");
120611
- fs33.mkdirSync(board, { recursive: true });
120794
+ const board = path39.join(projectDir2, ".akb", "kanban");
120795
+ fs35.mkdirSync(board, { recursive: true });
120612
120796
  return { task, cloudTask: task, board, cwd: projectDir2, project: job.project, number: job.number ?? null, studio: job.studio ?? job.flow?.studio ?? null };
120613
120797
  }
120614
120798
  function openAgentFolder(job, projectDir2) {
120615
120799
  if (!job.project || !job.agent) throw new Error("This job names no project.");
120616
120800
  keepOutOfGit(projectDir2);
120617
120801
  markUsed(projectDir2);
120618
- const board = path37.join(projectDir2, ".akb", "kanban");
120619
- fs33.mkdirSync(board, { recursive: true });
120802
+ const board = path39.join(projectDir2, ".akb", "kanban");
120803
+ fs35.mkdirSync(board, { recursive: true });
120620
120804
  return {
120621
120805
  task: `agent-${safe2(job.agent.studio ? `${job.agent.studio}-${job.agent.name}` : job.agent.name)}`,
120622
120806
  cloudTask: job.agent.tasks?.[0]?.id ?? null,
@@ -120631,13 +120815,13 @@ function openDiscussionFolder(job, projectDir2) {
120631
120815
  if (!job.project) throw new Error("This job names no project.");
120632
120816
  keepOutOfGit(projectDir2);
120633
120817
  markUsed(projectDir2);
120634
- const board = path37.join(projectDir2, ".akb", "kanban");
120635
- fs33.mkdirSync(board, { recursive: true });
120818
+ const board = path39.join(projectDir2, ".akb", "kanban");
120819
+ fs35.mkdirSync(board, { recursive: true });
120636
120820
  return { task: "discussion", cloudTask: null, board, cwd: projectDir2, project: job.project, number: null, studio: null };
120637
120821
  }
120638
120822
  var boardFolder = (ws) => ({ task: "board", cloudTask: null, board: ws.board, cwd: ws.cwd, project: ws.project, number: null, studio: null });
120639
120823
  function keptBoard(cwd) {
120640
- const board = path37.join(cwd, ".akb", "kanban");
120824
+ const board = path39.join(cwd, ".akb", "kanban");
120641
120825
  const base = readBase({ cwd });
120642
120826
  const project = base.project ?? /^projects\/([^/]+)\//.exec(Object.keys(base.files).find((p2) => p2.startsWith("projects/")) ?? "")?.[1];
120643
120827
  return base.head_seq === null || !project ? null : boardFolder({ board, cwd, project });
@@ -120663,37 +120847,37 @@ function inFolder(dir, work) {
120663
120847
  }
120664
120848
  var safe2 = (name) => name.replace(/[^\w.-]/g, "_") || "default";
120665
120849
  var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
120666
- var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path37.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
120850
+ var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path39.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
120667
120851
  function findCard(board, number) {
120668
120852
  const named = new RegExp(`^${number}-`);
120669
120853
  const walk = (dir) => {
120670
120854
  let entries;
120671
120855
  try {
120672
- entries = fs33.readdirSync(dir, { withFileTypes: true });
120856
+ entries = fs35.readdirSync(dir, { withFileTypes: true });
120673
120857
  } catch {
120674
120858
  return null;
120675
120859
  }
120676
120860
  for (const e2 of entries) {
120677
120861
  if (!named.test(e2.name)) continue;
120678
- if (e2.isFile() && e2.name.endsWith(".md")) return path37.join(dir, e2.name);
120679
- const root2 = path37.join(dir, e2.name, "root.md");
120680
- if (e2.isDirectory() && fs33.existsSync(root2)) return root2;
120862
+ if (e2.isFile() && e2.name.endsWith(".md")) return path39.join(dir, e2.name);
120863
+ const root2 = path39.join(dir, e2.name, "root.md");
120864
+ if (e2.isDirectory() && fs35.existsSync(root2)) return root2;
120681
120865
  }
120682
120866
  for (const e2 of entries) if (e2.isDirectory() && !e2.name.startsWith(".")) {
120683
- const hit = walk(path37.join(dir, e2.name));
120867
+ const hit = walk(path39.join(dir, e2.name));
120684
120868
  if (hit) return hit;
120685
120869
  }
120686
120870
  return null;
120687
120871
  };
120688
- return walk(path37.join(board, "todo")) ?? walk(path37.join(board, ".archive"));
120872
+ return walk(path39.join(board, "todo")) ?? walk(path39.join(board, ".archive"));
120689
120873
  }
120690
120874
  function akbCardOf(ws) {
120691
120875
  return ws.number && findCard(ws.board, ws.number) ? ws.number : void 0;
120692
120876
  }
120693
- var recordFile = (ws) => path37.join(ws.board, ".sync", `${ws.task}.json`);
120877
+ var recordFile = (ws) => path39.join(ws.board, ".sync", `${ws.task}.json`);
120694
120878
  function readRecord(ws) {
120695
120879
  try {
120696
- return { ...EMPTY, ...JSON.parse(fs33.readFileSync(recordFile(ws), "utf8")) };
120880
+ return { ...EMPTY, ...JSON.parse(fs35.readFileSync(recordFile(ws), "utf8")) };
120697
120881
  } catch {
120698
120882
  return structuredClone(EMPTY);
120699
120883
  }
@@ -120704,8 +120888,8 @@ function writeRecord(ws, record) {
120704
120888
  if (readText(recordFile(ws)) === content) return;
120705
120889
  countSync("recordWrites");
120706
120890
  if (syncDebug) countSync("recordBytes", Buffer.byteLength(content));
120707
- fs33.mkdirSync(path37.dirname(recordFile(ws)), { recursive: true });
120708
- fs33.writeFileSync(recordFile(ws), content);
120891
+ fs35.mkdirSync(path39.dirname(recordFile(ws)), { recursive: true });
120892
+ fs35.writeFileSync(recordFile(ws), content);
120709
120893
  }
120710
120894
  async function cleanRecords(ws, base, removed = [], tasks) {
120711
120895
  const retired = /* @__PURE__ */ new Set();
@@ -120713,11 +120897,11 @@ async function cleanRecords(ws, base, removed = [], tasks) {
120713
120897
  const removedPaths = new Set(removed);
120714
120898
  const numbers = new Set(Object.keys(base.files).filter((p2) => p2.startsWith(root2) && !removedPaths.has(p2)).map((p2) => numberOfCard(p2.slice(root2.length))));
120715
120899
  const deleted = new Map(removed.filter((p2) => p2.startsWith(root2 + ".archive/")).map((p2) => [numberOfCard(p2.slice(root2.length)), p2.slice(root2.length)]));
120716
- for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path37.join(ws.board, ".sync"))) {
120900
+ for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path39.join(ws.board, ".sync"))) {
120717
120901
  if (!name.endsWith(".json") || name.includes("/")) continue;
120718
120902
  let record;
120719
120903
  try {
120720
- record = JSON.parse(fs33.readFileSync(path37.join(ws.board, ".sync", name), "utf8"));
120904
+ record = JSON.parse(fs35.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
120721
120905
  } catch {
120722
120906
  continue;
120723
120907
  }
@@ -120741,13 +120925,13 @@ async function cleanRecords(ws, base, removed = [], tasks) {
120741
120925
  index.retiring.add(record.task);
120742
120926
  if (card || kept2(ws.cwd) || base.pendingAssets?.includes(record.task)) continue;
120743
120927
  const list3 = assetsFile(record.task);
120744
- const here2 = readText(path37.join(ws.board, list3));
120928
+ const here2 = readText(path39.join(ws.board, list3));
120745
120929
  if (here2 !== null && here2 !== (base.files[root2 + list3]?.content ?? null)) continue;
120746
120930
  let changed = false;
120747
120931
  for (const [name2, entry] of Object.entries(record.assets ?? {})) {
120748
120932
  let file3;
120749
120933
  try {
120750
- file3 = assetPath(folder, name2, typeof record.deleted === "string" ? path37.join(ws.board, record.deleted) : cardFile(folder));
120934
+ file3 = assetPath(folder, name2, typeof record.deleted === "string" ? path39.join(ws.board, record.deleted) : cardFile(folder));
120751
120935
  } catch {
120752
120936
  changed = true;
120753
120937
  break;
@@ -120760,16 +120944,16 @@ async function cleanRecords(ws, base, removed = [], tasks) {
120760
120944
  }
120761
120945
  }
120762
120946
  if (!changed) {
120763
- fs33.rmSync(recordFile(folder), { force: true });
120947
+ fs35.rmSync(recordFile(folder), { force: true });
120764
120948
  forgetTask(index, record.task);
120765
120949
  }
120766
120950
  }
120767
120951
  return retired;
120768
120952
  }
120769
- var baseFile = (ws) => path37.join(ws.cwd, ".akb", "base.json");
120953
+ var baseFile = (ws) => path39.join(ws.cwd, ".akb", "base.json");
120770
120954
  function readBase(ws) {
120771
120955
  try {
120772
- const base = JSON.parse(fs33.readFileSync(baseFile(ws), "utf8"));
120956
+ const base = JSON.parse(fs35.readFileSync(baseFile(ws), "utf8"));
120773
120957
  if (base.layout === "workspace") return base;
120774
120958
  } catch {
120775
120959
  }
@@ -120777,25 +120961,25 @@ function readBase(ws) {
120777
120961
  }
120778
120962
  function writeBase(ws, base) {
120779
120963
  const file3 = baseFile(ws);
120780
- fs33.mkdirSync(path37.dirname(file3), { recursive: true });
120781
- fs33.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
120782
- fs33.renameSync(`${file3}.tmp`, file3);
120964
+ fs35.mkdirSync(path39.dirname(file3), { recursive: true });
120965
+ fs35.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
120966
+ fs35.renameSync(`${file3}.tmp`, file3);
120783
120967
  }
120784
- var hashOf2 = (bytes2) => crypto5.createHash("sha256").update(bytes2).digest("hex");
120968
+ var hashOf2 = (bytes2) => crypto6.createHash("sha256").update(bytes2).digest("hex");
120785
120969
  function hashFile(file3) {
120786
120970
  try {
120787
- return hashOf2(fs33.readFileSync(file3));
120971
+ return hashOf2(fs35.readFileSync(file3));
120788
120972
  } catch {
120789
120973
  return null;
120790
120974
  }
120791
120975
  }
120792
120976
  function write(file3, bytes2) {
120793
- fs33.mkdirSync(path37.dirname(file3), { recursive: true });
120794
- fs33.writeFileSync(file3, bytes2);
120977
+ fs35.mkdirSync(path39.dirname(file3), { recursive: true });
120978
+ fs35.writeFileSync(file3, bytes2);
120795
120979
  }
120796
120980
  function readText(file3) {
120797
120981
  try {
120798
- return fs33.readFileSync(file3, "utf8");
120982
+ return fs35.readFileSync(file3, "utf8");
120799
120983
  } catch {
120800
120984
  return null;
120801
120985
  }
@@ -120803,14 +120987,14 @@ function readText(file3) {
120803
120987
  function filesUnder(dir, base = dir) {
120804
120988
  let entries;
120805
120989
  try {
120806
- entries = fs33.readdirSync(dir, { withFileTypes: true });
120990
+ entries = fs35.readdirSync(dir, { withFileTypes: true });
120807
120991
  } catch {
120808
120992
  return [];
120809
120993
  }
120810
120994
  return entries.flatMap((e2) => {
120811
- const full = path37.join(dir, e2.name);
120995
+ const full = path39.join(dir, e2.name);
120812
120996
  if (e2.isDirectory()) return filesUnder(full, base);
120813
- return e2.isFile() ? [path37.relative(base, full).split(path37.sep).join("/")] : [];
120997
+ return e2.isFile() ? [path39.relative(base, full).split(path39.sep).join("/")] : [];
120814
120998
  });
120815
120999
  }
120816
121000
  var kept3 = isBoardPath;
@@ -120833,18 +121017,18 @@ function assetFiles(ws, list3) {
120833
121017
  return null;
120834
121018
  }
120835
121019
  };
120836
- return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path37.relative(ws.board, f2).split(path37.sep).join("/")));
121020
+ return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path39.relative(ws.board, f2).split(path39.sep).join("/")));
120837
121021
  }
120838
121022
  var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
120839
121023
  var localFiles = (ws, base) => {
120840
- const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path37.join(ws.board, assetsFile(ws.task))))]);
121024
+ const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path39.join(ws.board, assetsFile(ws.task))))]);
120841
121025
  return filesUnder(ws.board).filter((p2) => kept3(p2) && !assets.has(p2));
120842
121026
  };
120843
121027
  var SKILL_PATH = /^skills\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?:[\w.-]+\/)*[\w.-]+)$/;
120844
121028
  function pullTools(ws, record, files) {
120845
121029
  const held5 = record.tools?.skills ?? {};
120846
121030
  const ours = new Set(Object.keys(held5).map((name) => name.split("/")[1]));
120847
- const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs33.existsSync(path37.join(ws.cwd, root2, skill)));
121031
+ const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs35.existsSync(path39.join(ws.cwd, root2, skill)));
120848
121032
  const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
120849
121033
  const skills = {};
120850
121034
  for (const [name, text4] of Object.entries(files)) {
@@ -120852,7 +121036,7 @@ function pullTools(ws, record, files) {
120852
121036
  if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
120853
121037
  skills[name] = hashOf2(text4);
120854
121038
  for (const root2 of SKILL_ROOTS) {
120855
- const file3 = path37.join(ws.cwd, root2, at2[1], at2[2]);
121039
+ const file3 = path39.join(ws.cwd, root2, at2[1], at2[2]);
120856
121040
  if (held5[name] !== skills[name] || hashFile(file3) !== skills[name]) write(file3, text4);
120857
121041
  }
120858
121042
  }
@@ -120861,8 +121045,8 @@ function pullTools(ws, record, files) {
120861
121045
  const [, skill, rest] = SKILL_PATH.exec(name) ?? [];
120862
121046
  if (!skill || !rest) continue;
120863
121047
  for (const root2 of SKILL_ROOTS) {
120864
- fs33.rmSync(path37.join(ws.cwd, root2, skill, rest), { force: true });
120865
- if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs33.rmSync(path37.join(ws.cwd, root2, skill), { recursive: true, force: true });
121048
+ fs35.rmSync(path39.join(ws.cwd, root2, skill, rest), { force: true });
121049
+ if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs35.rmSync(path39.join(ws.cwd, root2, skill), { recursive: true, force: true });
120866
121050
  }
120867
121051
  }
120868
121052
  const names2 = [...new Set(Object.keys(skills).map((name) => name.split("/")[1]))];
@@ -120899,46 +121083,46 @@ async function pullStudio(ws, record) {
120899
121083
  if (files.ok) pullTools(ws, record, files.value);
120900
121084
  }
120901
121085
  dropPlacedAgents(ws);
120902
- for (const name of Object.keys(record.agents ?? {})) fs33.rmSync(path37.join(ws.board, name), { force: true });
121086
+ for (const name of Object.keys(record.agents ?? {})) fs35.rmSync(path39.join(ws.board, name), { force: true });
120903
121087
  record.agents = {};
120904
121088
  return { ok: true, value: void 0 };
120905
121089
  }
120906
- var agentsRecord = (ws) => path37.join(ws.board, ".sync", "agents.json");
121090
+ var agentsRecord = (ws) => path39.join(ws.board, ".sync", "agents.json");
120907
121091
  function readPlaced(ws) {
120908
121092
  try {
120909
- return JSON.parse(fs33.readFileSync(agentsRecord(ws), "utf8"));
121093
+ return JSON.parse(fs35.readFileSync(agentsRecord(ws), "utf8"));
120910
121094
  } catch {
120911
121095
  return {};
120912
121096
  }
120913
121097
  }
120914
121098
  function dropPlacedAgents(ws) {
120915
121099
  const placed = readPlaced(ws);
120916
- for (const name of Object.keys(placed)) if (hashFile(path37.join(ws.board, name)) === placed[name]) fs33.rmSync(path37.join(ws.board, name), { force: true });
120917
- fs33.rmSync(agentsRecord(ws), { force: true });
121100
+ for (const name of Object.keys(placed)) if (hashFile(path39.join(ws.board, name)) === placed[name]) fs35.rmSync(path39.join(ws.board, name), { force: true });
121101
+ fs35.rmSync(agentsRecord(ws), { force: true });
120918
121102
  }
120919
121103
  function assetPath(ws, name, owner2) {
120920
121104
  if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
120921
- if (path37.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
121105
+ if (path39.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
120922
121106
  const held5 = /^\.assets\//.exec(name);
120923
121107
  const state = stateDir(ws);
120924
- const root2 = held5 && state ? path37.join(state, "assets") : ws.board;
120925
- const file3 = held5 && state ? path37.resolve(root2, name.slice(held5[0].length)) : path37.resolve(path37.dirname(owner2), name);
120926
- const roots = [ws.board, ...state ? ["assets"].map((folder) => path37.join(state, folder, ...ws.number ? [String(ws.number)] : [])) : []];
120927
- const inside2 = (file4, root3) => file4.startsWith(root3 + path37.sep);
121108
+ const root2 = held5 && state ? path39.join(state, "assets") : ws.board;
121109
+ const file3 = held5 && state ? path39.resolve(root2, name.slice(held5[0].length)) : path39.resolve(path39.dirname(owner2), name);
121110
+ const roots = [ws.board, ...state ? ["assets"].map((folder) => path39.join(state, folder, ...ws.number ? [String(ws.number)] : [])) : []];
121111
+ const inside2 = (file4, root3) => file4.startsWith(root3 + path39.sep);
120928
121112
  if (!roots.some((root3) => inside2(file3, root3))) throw new Error(`outside the board: ${name}`);
120929
121113
  let existing = file3;
120930
- while (!fs33.existsSync(existing) && path37.dirname(existing) !== existing) existing = path37.dirname(existing);
120931
- const real = path37.join(fs33.realpathSync(existing), path37.relative(existing, file3));
121114
+ while (!fs35.existsSync(existing) && path39.dirname(existing) !== existing) existing = path39.dirname(existing);
121115
+ const real = path39.join(fs35.realpathSync(existing), path39.relative(existing, file3));
120932
121116
  let stateParent = state;
120933
- while (stateParent && !fs33.existsSync(stateParent) && path37.dirname(stateParent) !== stateParent) stateParent = path37.dirname(stateParent);
120934
- const realState = state && stateParent ? path37.resolve(fs33.realpathSync(stateParent), path37.relative(stateParent, state)) : null;
120935
- const realRoots = [fs33.realpathSync(ws.board), ...realState ? ["assets"].map((folder) => path37.join(realState, folder, ...ws.number ? [String(ws.number)] : [])) : []];
121117
+ while (stateParent && !fs35.existsSync(stateParent) && path39.dirname(stateParent) !== stateParent) stateParent = path39.dirname(stateParent);
121118
+ const realState = state && stateParent ? path39.resolve(fs35.realpathSync(stateParent), path39.relative(stateParent, state)) : null;
121119
+ const realRoots = [fs35.realpathSync(ws.board), ...realState ? ["assets"].map((folder) => path39.join(realState, folder, ...ws.number ? [String(ws.number)] : [])) : []];
120936
121120
  if (!realRoots.some((root3) => real === root3 || inside2(real, root3))) throw new Error(`link outside the board: ${name}`);
120937
121121
  return file3;
120938
121122
  }
120939
121123
  function cardAssetsDir(ws, id) {
120940
121124
  const state = stateDir(ws);
120941
- return state && path37.join(state, "assets", String(id));
121125
+ return state && path39.join(state, "assets", String(id));
120942
121126
  }
120943
121127
  function stateDir(ws) {
120944
121128
  try {
@@ -120988,13 +121172,13 @@ var pullChanges = (ws) => inFolder(ws.cwd, async () => {
120988
121172
  if (index) rememberDirectories(index.directories, p2);
120989
121173
  const isShared = p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length));
120990
121174
  if (kept3(p2) && isShared === !f2.path.startsWith(root2)) {
120991
- const file3 = path37.join(ws.board, p2);
121175
+ const file3 = path39.join(ws.board, p2);
120992
121176
  const here2 = readText(file3);
120993
121177
  if (here2 !== f2.content && here2 !== (base.files[f2.path]?.content ?? null)) {
120994
121178
  skipped = true;
120995
121179
  continue;
120996
121180
  }
120997
- if (f2.content === null) fs33.rmSync(file3, { force: true });
121181
+ if (f2.content === null) fs35.rmSync(file3, { force: true });
120998
121182
  else if (here2 !== f2.content) write(file3, f2.content);
120999
121183
  }
121000
121184
  if (f2.content === null) delete base.files[f2.path];
@@ -121015,7 +121199,7 @@ async function readCloud(ws) {
121015
121199
  const base = readBase(ws);
121016
121200
  const previous = { ...base.files };
121017
121201
  const known2 = new Set(Object.keys(base.files));
121018
- const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path37.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
121202
+ const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path39.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
121019
121203
  if (base.workspace === void 0) {
121020
121204
  const project = await readProject(ws.project);
121021
121205
  if (!project.ok) return project;
@@ -121031,20 +121215,20 @@ async function readCloud(ws) {
121031
121215
  const removed = [...known2].filter((p2) => !base.files[p2]);
121032
121216
  for (const p2 of removed) {
121033
121217
  const local = p2.startsWith(rootOf(ws)) ? p2.slice(rootOf(ws).length) : p2;
121034
- if (local.startsWith(".archive/") && readText(path37.join(ws.board, local)) !== null && readText(path37.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
121218
+ if (local.startsWith(".archive/") && readText(path39.join(ws.board, local)) !== null && readText(path39.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
121035
121219
  }
121036
121220
  base.head_seq = read5.value.head_seq;
121037
121221
  base.project = ws.project;
121038
121222
  writeBase(ws, base);
121039
121223
  const reset = (view2) => {
121040
121224
  for (const [p2, content] of view2) {
121041
- const file3 = path37.join(ws.board, p2);
121225
+ const file3 = path39.join(ws.board, p2);
121042
121226
  if (!keepDraft.has(p2) && kept3(p2) && readText(file3) !== content) write(file3, content);
121043
121227
  }
121044
121228
  };
121045
121229
  const view = viewOf(ws, base, sharedMemory(ws.board));
121046
121230
  const first = (p2) => isSettingsPath(p2) && !known2.has(rootOf(ws) + p2);
121047
- for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs33.rmSync(path37.join(ws.board, p2), { force: true });
121231
+ for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs35.rmSync(path39.join(ws.board, p2), { force: true });
121048
121232
  reset(view);
121049
121233
  const retired = await cleanRecords(ws, base, removed);
121050
121234
  if (retired.has(ws.task)) {
@@ -121062,18 +121246,18 @@ async function readCloud(ws) {
121062
121246
  return { ok: true, value: void 0 };
121063
121247
  }
121064
121248
  function writeIndex(board) {
121065
- const todo = path37.join(board, "todo");
121249
+ const todo = path39.join(board, "todo");
121066
121250
  const cards = [];
121067
121251
  let entries = [];
121068
121252
  try {
121069
- entries = fs33.readdirSync(todo, { withFileTypes: true });
121253
+ entries = fs35.readdirSync(todo, { withFileTypes: true });
121070
121254
  } catch {
121071
121255
  }
121072
121256
  for (const e2 of entries) {
121073
121257
  const id = /^(\d+)-/.exec(e2.name)?.[1];
121074
121258
  if (!id) continue;
121075
121259
  const link = e2.isDirectory() ? `${e2.name}/root.md` : e2.name.endsWith(".md") ? e2.name : null;
121076
- const text5 = link && readText(path37.join(todo, link));
121260
+ const text5 = link && readText(path39.join(todo, link));
121077
121261
  if (text5 === null || !link) continue;
121078
121262
  cards.push({ id: Number(id), title: cardFront(text5).title ?? e2.name.replace(/\.md$/, ""), link });
121079
121263
  }
@@ -121088,7 +121272,7 @@ the number at the front of a filename is the task id.
121088
121272
 
121089
121273
  ${list3}
121090
121274
  `;
121091
- if (readText(path37.join(todo, "README.md")) !== text4) write(path37.join(todo, "README.md"), text4);
121275
+ if (readText(path39.join(todo, "README.md")) !== text4) write(path39.join(todo, "README.md"), text4);
121092
121276
  }
121093
121277
  var workspaceOf = (ws) => readBase(ws).workspace ?? null;
121094
121278
  async function pullAssets(ws, record, assets) {
@@ -121167,7 +121351,7 @@ async function pullAssets(ws, record, assets) {
121167
121351
  }
121168
121352
  if (!child) return src;
121169
121353
  dependencies.push(name2);
121170
- const back = !found.text && /^\.assets\//.test(name2) ? name2 : path37.relative(path37.dirname(target), child).split(path37.sep).join("/");
121354
+ const back = !found.text && /^\.assets\//.test(name2) ? name2 : path39.relative(path39.dirname(target), child).split(path39.sep).join("/");
121171
121355
  if (back !== src) changed = true;
121172
121356
  return back;
121173
121357
  });
@@ -121204,16 +121388,16 @@ async function readAsset(artifact, version) {
121204
121388
  return { ok: true, value: Buffer.from(typeof content === "string" ? content : JSON.stringify(content)) };
121205
121389
  }
121206
121390
  async function sentOf(file3, kind) {
121207
- const ext = path37.extname(file3).toLowerCase();
121208
- if (kind !== "html") return { bytes: fs33.readFileSync(file3), type: kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext] ?? "application/octet-stream", kind };
121391
+ const ext = path39.extname(file3).toLowerCase();
121392
+ if (kind !== "html") return { bytes: fs35.readFileSync(file3), type: kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext] ?? "application/octet-stream", kind };
121209
121393
  const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file3);
121210
121394
  return { bytes: Buffer.from(page), type: "text/html", kind };
121211
121395
  }
121212
- var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path37.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
121396
+ var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path39.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
121213
121397
  function undrawn(ws, reason) {
121214
121398
  const state = stateDir(ws);
121215
- for (const [root2, shown] of [...state ? [[path37.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
121216
- reason = reason.split(`file://${root2}${path37.sep}`).join(shown && `${shown}/`).split(`${root2}${path37.sep}`).join(shown && `${shown}/`);
121399
+ for (const [root2, shown] of [...state ? [[path39.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
121400
+ reason = reason.split(`file://${root2}${path39.sep}`).join(shown && `${shown}/`).split(`${root2}${path39.sep}`).join(shown && `${shown}/`);
121217
121401
  }
121218
121402
  return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
121219
121403
  }
@@ -121248,14 +121432,14 @@ async function pushAssets(ws, record, before) {
121248
121432
  if (body === null) return { ok: true, value: void 0 };
121249
121433
  const refs = {};
121250
121434
  const canonical = (target) => {
121251
- const real = (file4) => fs33.existsSync(file4) ? fs33.realpathSync(file4) : path37.dirname(file4) === file4 ? file4 : path37.join(real(path37.dirname(file4)), path37.basename(file4));
121435
+ const real = (file4) => fs35.existsSync(file4) ? fs35.realpathSync(file4) : path39.dirname(file4) === file4 ? file4 : path39.join(real(path39.dirname(file4)), path39.basename(file4));
121252
121436
  target = real(target);
121253
121437
  const state = stateDir(ws);
121254
121438
  for (const folder of ["assets"]) {
121255
- const root2 = state && real(path37.join(state, folder));
121256
- if (root2 && target.startsWith(root2 + path37.sep)) return `.${folder}/${path37.relative(root2, target).split(path37.sep).join("/")}`;
121439
+ const root2 = state && real(path39.join(state, folder));
121440
+ if (root2 && target.startsWith(root2 + path39.sep)) return `.${folder}/${path39.relative(root2, target).split(path39.sep).join("/")}`;
121257
121441
  }
121258
- return path37.relative(real(path37.dirname(file3)), target).split(path37.sep).join("/");
121442
+ return path39.relative(real(path39.dirname(file3)), target).split(path39.sep).join("/");
121259
121443
  };
121260
121444
  try {
121261
121445
  let recoveredReferences = false;
@@ -121266,11 +121450,11 @@ async function pushAssets(ws, record, before) {
121266
121450
  const target = assetPath(ws, src, owner2);
121267
121451
  if (!target) return null;
121268
121452
  const key = owner2 === file3 && before[src] ? src : canonical(target);
121269
- if (!fs33.statSync(target, { throwIfNoEntry: false })?.isFile()) {
121453
+ if (!fs35.statSync(target, { throwIfNoEntry: false })?.isFile()) {
121270
121454
  if (before[key]) return { key, file: null };
121271
121455
  throw new Error(`file not found: ${target}`);
121272
121456
  }
121273
- return { key: canonical(fs33.realpathSync(target)), file: target };
121457
+ return { key: canonical(fs35.realpathSync(target)), file: target };
121274
121458
  },
121275
121459
  read: referenceText,
121276
121460
  retained: (key, types) => {
@@ -121294,7 +121478,7 @@ async function pushAssets(ws, record, before) {
121294
121478
  let why2 = node.error ?? (partialStudio ? void 0 : [...node.dependencies.values()].map((key) => refs[key]?.error).find(Boolean));
121295
121479
  if (!why2 && node.file) {
121296
121480
  try {
121297
- if (fs33.statSync(node.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
121481
+ if (fs35.statSync(node.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
121298
121482
  out = await sentOf(node.file, kind);
121299
121483
  } catch (error) {
121300
121484
  why2 = renderError(error);
@@ -121352,7 +121536,7 @@ async function pushAssets(ws, record, before) {
121352
121536
  const unchanged = restored && previous && (previous.kind ?? out.kind) === out.kind && localHash === (previous.localHash ?? previous.hash) && [...node.dependencies.values()].every((key) => refs[key]?.artifact === before[key]?.artifact);
121353
121537
  if (!entry || !unchanged && entry.hash !== hash || entry.kind && entry.kind !== out.kind) {
121354
121538
  if (!ws.cloudTask) continue;
121355
- let artifact = previous && (previous.kind ?? kindOf2(path37.extname(node.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
121539
+ let artifact = previous && (previous.kind ?? kindOf2(path39.extname(node.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
121356
121540
  if (!artifact) {
121357
121541
  const made = await createArtifact(ws.cloudTask, node.key.slice(0, 200), out.kind);
121358
121542
  if (!made.ok) return { ...made, error: `${node.key}: ${made.error}` };
@@ -121378,25 +121562,25 @@ async function pushAssets(ws, record, before) {
121378
121562
  } catch (error) {
121379
121563
  return { ok: false, code: "bad_request", error: error instanceof Error ? error.message : String(error) };
121380
121564
  }
121381
- const list3 = path37.join(ws.board, assetsFile(ws.task));
121382
- if (Object.keys(refs).length || fs33.existsSync(list3)) {
121565
+ const list3 = path39.join(ws.board, assetsFile(ws.task));
121566
+ if (Object.keys(refs).length || fs35.existsSync(list3)) {
121383
121567
  if (!isDeepStrictEqual(assetsOf(readText(list3)), refs)) write(list3, assetsText(refs));
121384
121568
  }
121385
121569
  logSync("assets.end", { project: ws.project, task: ws.task, ms: Math.round(performance.now() - started) });
121386
121570
  return { ok: true, value: void 0 };
121387
121571
  }
121388
121572
  function resetSorted(ws) {
121389
- for (const sub of ["dismissed", "archived"]) fs33.rmSync(path37.join(ws.board, "triage", sub), { recursive: true, force: true });
121573
+ for (const sub of ["dismissed", "archived"]) fs35.rmSync(path39.join(ws.board, "triage", sub), { recursive: true, force: true });
121390
121574
  for (const [p2, content] of viewOf(ws, readBase(ws), sharedMemory(ws.board))) {
121391
- if (/^triage\/(?:dismissed|archived)\//.test(p2)) write(path37.join(ws.board, p2), content);
121575
+ if (/^triage\/(?:dismissed|archived)\//.test(p2)) write(path39.join(ws.board, p2), content);
121392
121576
  }
121393
121577
  }
121394
121578
  function proposeItems(ws, base, paths) {
121395
121579
  const root2 = rootOf(ws);
121396
121580
  for (const p2 of paths ?? localFiles(ws, base)) {
121397
121581
  if (itemAt(p2)?.state !== "open" || base.files[root2 + p2]) continue;
121398
- const file3 = path37.join(ws.board, p2);
121399
- const content = fs33.readFileSync(file3, "utf8");
121582
+ const file3 = path39.join(ws.board, p2);
121583
+ const content = fs35.readFileSync(file3, "utf8");
121400
121584
  const said = (key) => new RegExp(`^${key}:`, "m").test(content.split(/\n---/)[0] ?? "");
121401
121585
  const fields = {
121402
121586
  ...ws.cloudTask && !said("source_task") ? { source_task: ws.cloudTask } : {},
@@ -121435,11 +121619,11 @@ async function sendMarked(ws, job, paths) {
121435
121619
  return pushed;
121436
121620
  }
121437
121621
  var boardIdentity = (ws) => {
121438
- const stat = fs33.statSync(ws.board);
121622
+ const stat = fs35.statSync(ws.board);
121439
121623
  return `${stat.dev}:${stat.ino}:${stat.birthtimeMs}`;
121440
121624
  };
121441
121625
  function rememberDirectories(directories, file3) {
121442
- for (let dir = path37.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path37.posix.dirname(dir)) directories.add(dir);
121626
+ for (let dir = path39.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path39.posix.dirname(dir)) directories.add(dir);
121443
121627
  }
121444
121628
  function newIndex(ws) {
121445
121629
  const directories = /* @__PURE__ */ new Set();
@@ -121468,7 +121652,7 @@ function forgetTask(index, task) {
121468
121652
  }
121469
121653
  function indexTask(ws, record, card = cardFile(ws)) {
121470
121654
  if (!ws.cloudTask || !ws.number) return;
121471
- const paths = /* @__PURE__ */ new Set([card, path37.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
121655
+ const paths = /* @__PURE__ */ new Set([card, path39.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
121472
121656
  for (const name of Object.keys(record.assets)) {
121473
121657
  try {
121474
121658
  const file3 = assetPath(ws, name, card);
@@ -121477,7 +121661,7 @@ function indexTask(ws, record, card = cardFile(ws)) {
121477
121661
  }
121478
121662
  }
121479
121663
  for (const file3 of [...paths]) {
121480
- for (let dir = path37.dirname(file3); dir.startsWith(ws.cwd + path37.sep); dir = path37.dirname(dir)) paths.add(dir);
121664
+ for (let dir = path39.dirname(file3); dir.startsWith(ws.cwd + path39.sep); dir = path39.dirname(dir)) paths.add(dir);
121481
121665
  }
121482
121666
  const index = syncIndex(ws) ?? newIndex(ws);
121483
121667
  for (const file3 of index.tasks.get(ws.task)?.paths ?? []) {
@@ -121497,7 +121681,7 @@ function affectedTasks(ws, paths) {
121497
121681
  const index = syncIndex(ws);
121498
121682
  const tasks = new Set(index?.retiring);
121499
121683
  for (const p2 of paths) {
121500
- for (const task2 of index?.files.get(path37.resolve(ws.board, p2)) ?? []) tasks.add(task2);
121684
+ for (const task2 of index?.files.get(path39.resolve(ws.board, p2)) ?? []) tasks.add(task2);
121501
121685
  const task = /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
121502
121686
  if (task) tasks.add(task);
121503
121687
  }
@@ -121514,13 +121698,13 @@ async function send2(ws, job, paths) {
121514
121698
  const retired = await cleanRecords(ws, base, [], names2 ?? void 0);
121515
121699
  if (retired.has(ws.task)) record.deleted = true;
121516
121700
  const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
121517
- ...filesUnder(path37.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
121701
+ ...filesUnder(path39.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
121518
121702
  ...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
121519
121703
  ])];
121520
121704
  const tasks = ws.cloudTask ? [{ folder: ws, record }] : records.flatMap((name) => {
121521
121705
  let held5;
121522
121706
  try {
121523
- held5 = JSON.parse(fs33.readFileSync(path37.join(ws.board, ".sync", name), "utf8"));
121707
+ held5 = JSON.parse(fs35.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
121524
121708
  } catch {
121525
121709
  const known2 = syncIndex(ws)?.tasks.get(name.replace(/\.json$/, ""));
121526
121710
  if (!known2) return [];
@@ -121538,7 +121722,7 @@ async function send2(ws, job, paths) {
121538
121722
  const assetErrors = {};
121539
121723
  const processed = /* @__PURE__ */ new Set();
121540
121724
  const cards = !selected2 && !ws.cloudTask ? new Map(
121541
- [".archive", "todo"].flatMap((dir) => filesUnder(path37.join(ws.board, dir), ws.board)).flatMap((p2) => {
121725
+ [".archive", "todo"].flatMap((dir) => filesUnder(path39.join(ws.board, dir), ws.board)).flatMap((p2) => {
121542
121726
  const number = numberOfCard(p2);
121543
121727
  return number ? [[number, p2]] : [];
121544
121728
  })
@@ -121546,8 +121730,8 @@ async function send2(ws, job, paths) {
121546
121730
  for (const item of tasks) {
121547
121731
  processed.add(item.folder.task);
121548
121732
  if (processed.size === 1 || processed.size % 25 === 0) logSync("board.progress", { project: ws.project, processed: processed.size, total: tasks.length });
121549
- const card = cards?.get(item.folder.number) ?? path37.relative(ws.board, cardFile(item.folder)).split(path37.sep).join("/");
121550
- indexTask(item.folder, item.record, path37.join(ws.board, card));
121733
+ const card = cards?.get(item.folder.number) ?? path39.relative(ws.board, cardFile(item.folder)).split(path39.sep).join("/");
121734
+ indexTask(item.folder, item.record, path39.join(ws.board, card));
121551
121735
  selected2?.add(card);
121552
121736
  const before = assetsOf(assetsListOf(item.folder, base));
121553
121737
  const newer = Object.entries(before).some(([name, ref]) => {
@@ -121556,13 +121740,13 @@ async function send2(ws, job, paths) {
121556
121740
  });
121557
121741
  const clean = () => Object.entries(item.record.assets).every(([name, entry]) => {
121558
121742
  try {
121559
- const file3 = assetPath(item.folder, name, path37.join(ws.board, card));
121743
+ const file3 = assetPath(item.folder, name, path39.join(ws.board, card));
121560
121744
  return !file3 || hashFile(file3) === (entry.localHash ?? entry.hash);
121561
121745
  } catch {
121562
121746
  return false;
121563
121747
  }
121564
121748
  });
121565
- const archived = !selected2 && boardSync && card.startsWith(".archive/") && readText(path37.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
121749
+ const archived = !selected2 && boardSync && card.startsWith(".archive/") && readText(path39.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
121566
121750
  if (!archived && !item.record.deleted) {
121567
121751
  const refreshed = newer && clean() ? await pullAssets(item.folder, item.record, before) : { ok: true, value: void 0 };
121568
121752
  const assets = refreshed.ok ? await pushAssets(item.folder, item.record, before) : refreshed;
@@ -121582,10 +121766,10 @@ async function send2(ws, job, paths) {
121582
121766
  }
121583
121767
  if (!ws.cloudTask) syncIndex(ws).ready = true;
121584
121768
  const scoped = selected2 && [...new Set([...selected2].flatMap((p2) => {
121585
- if (!isBoardPath(p2) && !fs33.statSync(path37.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
121586
- const file3 = path37.join(ws.board, p2);
121587
- return fs33.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
121588
- }))].filter((p2) => fs33.statSync(path37.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
121769
+ if (!isBoardPath(p2) && !fs35.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
121770
+ const file3 = path39.join(ws.board, p2);
121771
+ return fs35.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
121772
+ }))].filter((p2) => fs35.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
121589
121773
  for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
121590
121774
  proposeItems(ws, base, scoped);
121591
121775
  const shared = sharedMemory(ws.board);
@@ -121620,7 +121804,7 @@ async function send2(ws, job, paths) {
121620
121804
  for (const p2 of local) {
121621
121805
  if (defer(p2) || owed(p2)) continue;
121622
121806
  if (selected2 && tasks.some((item) => assetFiles(item.folder, assetsListOf(item.folder, base)).has(p2))) continue;
121623
- const content = fs33.readFileSync(path37.join(ws.board, p2), "utf8");
121807
+ const content = fs35.readFileSync(path39.join(ws.board, p2), "utf8");
121624
121808
  const remote2 = remoteOf(ws, shared, p2);
121625
121809
  localOf.set(remote2, p2);
121626
121810
  const held5 = base.files[remote2];
@@ -121630,7 +121814,7 @@ async function send2(ws, job, paths) {
121630
121814
  }
121631
121815
  const previous = selected2 ? new Set([...selected2].flatMap((p2) => {
121632
121816
  if (base.files[remoteOf(ws, shared, p2)]) return [p2];
121633
- if (!syncIndex(ws)?.directories.has(p2) && !fs33.statSync(path37.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
121817
+ if (!syncIndex(ws)?.directories.has(p2) && !fs35.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
121634
121818
  return [...viewOf(ws, base, shared).keys()].filter((file3) => file3.startsWith(p2 + "/"));
121635
121819
  })) : viewOf(ws, base, shared).keys();
121636
121820
  for (const p2 of previous) {
@@ -121665,7 +121849,7 @@ async function send2(ws, job, paths) {
121665
121849
  deferred.add(assetsFile(item.folder.task));
121666
121850
  }
121667
121851
  } else {
121668
- fs33.rmSync(path37.join(ws.board, p2), { force: true });
121852
+ fs35.rmSync(path39.join(ws.board, p2), { force: true });
121669
121853
  writeIndex(ws.board);
121670
121854
  }
121671
121855
  writeBase(ws, base);
@@ -121677,8 +121861,8 @@ async function send2(ws, job, paths) {
121677
121861
  const merged = itemAt(p2) ? { content: theirs.content } : mergeFile(base.files[theirs.path]?.content ?? null, changes[at2].content, theirs.content);
121678
121862
  logSync("merge.end", { project: ws.project, path: p2, ms: Math.round(performance.now() - started) });
121679
121863
  changes[at2] = { path: theirs.path, content: merged.content, base_seq: theirs.seq };
121680
- if (merged.content === null) fs33.rmSync(path37.join(ws.board, p2), { force: true });
121681
- else write(path37.join(ws.board, p2), merged.content);
121864
+ if (merged.content === null) fs35.rmSync(path39.join(ws.board, p2), { force: true });
121865
+ else write(path39.join(ws.board, p2), merged.content);
121682
121866
  }
121683
121867
  if (!changes.length) return success(false);
121684
121868
  sent = await commitBoard(ws.project, job.id, job.machineId, changes);
@@ -121699,7 +121883,7 @@ var BUSY_MS = 3e4;
121699
121883
  function keptFolders() {
121700
121884
  let cached2 = [];
121701
121885
  try {
121702
- cached2 = fs34.readdirSync(cacheRoot()).map((name) => fs34.realpathSync(path38.join(cacheRoot(), name)));
121886
+ cached2 = fs36.readdirSync(cacheRoot()).map((name) => fs36.realpathSync(path40.join(cacheRoot(), name)));
121703
121887
  } catch {
121704
121888
  }
121705
121889
  return [.../* @__PURE__ */ new Set([...allowedProjects(), ...cached2])].flatMap((dir) => [keptBoard(dir)].filter((ws) => !!ws));
@@ -121759,10 +121943,10 @@ function watchBoards(machineId2, ms, lookMs = LOOK_MS, pullMs = PULL_MS, busyMs
121759
121943
  const watch = (ws) => {
121760
121944
  let watcher;
121761
121945
  try {
121762
- const state = path38.relative(ws.board, projectStateDir(ws.board)).split(path38.sep).join("/");
121946
+ const state = path40.relative(ws.board, projectStateDir(ws.board)).split(path40.sep).join("/");
121763
121947
  const assets = ["assets"].map((dir) => `${state}/${dir}/`);
121764
- watcher = fs34.watch(path38.dirname(ws.board), { recursive: true }, (_event, name) => {
121765
- const p2 = name && path38.relative(ws.board, path38.join(path38.dirname(ws.board), String(name))).split(path38.sep).join("/");
121948
+ watcher = fs36.watch(path40.dirname(ws.board), { recursive: true }, (_event, name) => {
121949
+ const p2 = name && path40.relative(ws.board, path40.join(path40.dirname(ws.board), String(name))).split(path40.sep).join("/");
121766
121950
  const held5 = watched.get(ws.cwd);
121767
121951
  if (closed || !p2 || !held5) return;
121768
121952
  if (!isBoardPath(p2) && !/^(?:todo|\.archive|memory|assets|studios|triage|rules)(?:\/|$)/.test(p2) && !assets.some((root2) => p2.startsWith(root2)) && !/^\.sync\/[\w-]+\.json$/.test(p2)) return;
@@ -121828,8 +122012,8 @@ function watchBoards(machineId2, ms, lookMs = LOOK_MS, pullMs = PULL_MS, busyMs
121828
122012
 
121829
122013
  // src/diff.ts
121830
122014
  import { execFile as execFile2 } from "node:child_process";
121831
- import fs35 from "node:fs";
121832
- import path39 from "node:path";
122015
+ import fs37 from "node:fs";
122016
+ import path41 from "node:path";
121833
122017
  var FILE_BYTES = 256 * 1024;
121834
122018
  var TOTAL_BYTES = 1024 * 1024;
121835
122019
  var EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
@@ -121846,7 +122030,7 @@ var git2 = (dir, args2, maxBuffer = 4 * TOTAL_BYTES) => new Promise(
121846
122030
  function projectDir(placed, project) {
121847
122031
  if (placed) {
121848
122032
  const real = realpath3(placed);
121849
- return real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path39.sep)) ? real : null;
122033
+ return real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path41.sep)) ? real : null;
121850
122034
  }
121851
122035
  let cached2;
121852
122036
  try {
@@ -121854,11 +122038,11 @@ function projectDir(placed, project) {
121854
122038
  } catch {
121855
122039
  return null;
121856
122040
  }
121857
- return fs35.existsSync(path39.join(cached2, ".git")) ? cached2 : null;
122041
+ return fs37.existsSync(path41.join(cached2, ".git")) ? cached2 : null;
121858
122042
  }
121859
122043
  function realpath3(p2) {
121860
122044
  try {
121861
- return fs35.realpathSync(p2);
122045
+ return fs37.realpathSync(p2);
121862
122046
  } catch {
121863
122047
  return null;
121864
122048
  }
@@ -121902,119 +122086,11 @@ async function answerHint(machineId2, hint2) {
121902
122086
  if (!sent.ok) console.error(`runner: the diff of ${commit.slice(0, 7)} was not sent: ${sent.error}`);
121903
122087
  }
121904
122088
 
121905
- // ../cli/src/lib/agent/connection-process.ts
121906
- import { spawnSync as spawnSync5 } from "node:child_process";
121907
-
121908
- // ../cli/src/lib/lock.ts
121909
- import { randomUUID as randomUUID3 } from "node:crypto";
121910
- import fs36 from "node:fs";
121911
- import path40 from "node:path";
121912
- function pidAlive(pid) {
121913
- if (!pid) return false;
121914
- try {
121915
- process.kill(pid, 0);
121916
- return true;
121917
- } catch (e2) {
121918
- return e2.code === "EPERM";
121919
- }
121920
- }
121921
- function removeClaim(dir, token) {
121922
- if (token) {
121923
- try {
121924
- fs36.unlinkSync(path40.join(dir, token));
121925
- } catch (err) {
121926
- if (err.code !== "ENOENT") throw err;
121927
- }
121928
- }
121929
- try {
121930
- fs36.rmdirSync(dir);
121931
- return true;
121932
- } catch (err) {
121933
- const code = err.code;
121934
- if (code === "ENOENT") return true;
121935
- if (code === "ENOTEMPTY" || code === "EEXIST") return false;
121936
- throw err;
121937
- }
121938
- }
121939
- function tryLock(dir) {
121940
- fs36.mkdirSync(path40.dirname(dir), { recursive: true });
121941
- const token = `${process.pid}-${randomUUID3()}`;
121942
- const candidate = fs36.mkdtempSync(`${dir}.`);
121943
- try {
121944
- fs36.writeFileSync(path40.join(candidate, token), "");
121945
- for (; ; ) {
121946
- try {
121947
- fs36.renameSync(candidate, dir);
121948
- return () => {
121949
- removeClaim(dir, token);
121950
- };
121951
- } catch (err) {
121952
- const code = err.code;
121953
- if (code !== "ENOTEMPTY" && code !== "EEXIST") throw err;
121954
- }
121955
- let entries;
121956
- try {
121957
- entries = fs36.readdirSync(dir);
121958
- } catch (err) {
121959
- if (err.code === "ENOENT") continue;
121960
- throw err;
121961
- }
121962
- if (entries.length) {
121963
- if (entries.length !== 1 || !/^\d+-[a-f0-9-]{36}$/.test(entries[0])) return void 0;
121964
- const owner2 = Number(entries[0].split("-")[0]);
121965
- if (pidAlive(owner2)) return void 0;
121966
- }
121967
- if (!removeClaim(dir, entries[0])) return void 0;
121968
- }
121969
- } finally {
121970
- fs36.rmSync(candidate, { recursive: true, force: true });
121971
- }
121972
- }
121973
-
121974
- // ../cli/src/lib/agent/connection-process.ts
121975
- function connectionIdentity(pid) {
121976
- const result = process.platform === "win32" ? spawnSync5("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CreationDate.ToUniversalTime().ToString('o')`], { encoding: "utf8", timeout: 2e3, windowsHide: true }) : spawnSync5("ps", ["-p", String(pid), "-o", "lstart="], { encoding: "utf8", timeout: 2e3, env: { ...process.env, LC_ALL: "C" } });
121977
- return result.status === 0 ? result.stdout.trim() || void 0 : void 0;
121978
- }
121979
- function connectionStopped(root2) {
121980
- if (!root2) return true;
121981
- if (!pidAlive(root2.pid)) return true;
121982
- const identity = connectionIdentity(root2.pid);
121983
- return !!root2.identity && !!identity && identity !== root2.identity;
121984
- }
121985
- function endConnection(child, grace = 12e3) {
121986
- child.stdin?.end();
121987
- child.kill("SIGTERM");
121988
- const timer = setTimeout(() => child.kill("SIGKILL"), grace);
121989
- timer.unref();
121990
- child.once("close", () => clearTimeout(timer));
121991
- }
121992
- async function stopConnection(root2, timeout) {
121993
- if (connectionStopped(root2)) return true;
121994
- if (!root2?.identity || connectionIdentity(root2.pid) !== root2.identity) return false;
121995
- try {
121996
- process.kill(root2.pid, "SIGTERM");
121997
- } catch {
121998
- }
121999
- const until = Date.now() + timeout;
122000
- while (!connectionStopped(root2)) {
122001
- if (Date.now() >= until) {
122002
- if (connectionIdentity(root2.pid) === root2.identity) try {
122003
- process.kill(root2.pid, "SIGKILL");
122004
- } catch {
122005
- }
122006
- return connectionStopped(root2);
122007
- }
122008
- await new Promise((resolve2) => setTimeout(resolve2, 100));
122009
- }
122010
- return true;
122011
- }
122012
-
122013
122089
  // src/preview-bridge.ts
122014
122090
  import http from "node:http";
122015
- import crypto6 from "node:crypto";
122091
+ import crypto7 from "node:crypto";
122016
122092
  async function previewBridge(work, card) {
122017
- const token = crypto6.randomBytes(32).toString("hex");
122093
+ const token = crypto7.randomBytes(32).toString("hex");
122018
122094
  let serial = Promise.resolve();
122019
122095
  const server = http.createServer((req, res) => {
122020
122096
  const answer = (status2, body) => {
@@ -122053,20 +122129,20 @@ async function previewBridge(work, card) {
122053
122129
  // ../cli/src/lib/agent/stop.ts
122054
122130
  import { spawnSync as spawnSync6 } from "node:child_process";
122055
122131
  import { randomUUID as randomUUID4 } from "node:crypto";
122056
- import fs37 from "node:fs";
122132
+ import fs38 from "node:fs";
122057
122133
  var runMark = (sessionId, since) => ({ name: RUN_ENV, value: sessionId, ...since === void 0 ? {} : { since } });
122058
122134
  var stopMark = () => ({ name: STOP_ENV, value: randomUUID4(), since: Date.now() });
122059
122135
  var markEnv = (env2, mark) => ({ ...env2, [mark.name]: mark.value });
122060
122136
  var WINDOWS3 = process.platform === "win32";
122061
122137
  function markedInProc(entry, strict = false, since) {
122062
122138
  const pids = [];
122063
- for (const name of fs37.readdirSync("/proc")) {
122139
+ for (const name of fs38.readdirSync("/proc")) {
122064
122140
  if (!/^\d+$/.test(name)) continue;
122065
122141
  try {
122066
- if (fs37.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
122142
+ if (fs38.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
122067
122143
  } catch (error) {
122068
122144
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
122069
- const stat = fs37.statSync(`/proc/${name}`, { throwIfNoEntry: false });
122145
+ const stat = fs38.statSync(`/proc/${name}`, { throwIfNoEntry: false });
122070
122146
  if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error;
122071
122147
  }
122072
122148
  }
@@ -122202,8 +122278,8 @@ function processesStopped(mark, root2) {
122202
122278
  }
122203
122279
 
122204
122280
  // src/flow.ts
122205
- import fs40 from "node:fs";
122206
- import path43 from "node:path";
122281
+ import fs41 from "node:fs";
122282
+ import path44 from "node:path";
122207
122283
 
122208
122284
  // ../cli/src/lib/question-block.ts
122209
122285
  var MODES = ["single", "multi"];
@@ -122355,8 +122431,8 @@ function reviewOf(meta) {
122355
122431
  }
122356
122432
 
122357
122433
  // src/triage.ts
122358
- import fs38 from "node:fs";
122359
- import path41 from "node:path";
122434
+ import fs39 from "node:fs";
122435
+ import path42 from "node:path";
122360
122436
 
122361
122437
  // ../cli/src/lib/signals/identity.ts
122362
122438
  import { createHash as createHash5 } from "node:crypto";
@@ -122370,8 +122446,8 @@ function slugify(s) {
122370
122446
  }
122371
122447
 
122372
122448
  // src/triage.ts
122373
- var triageDir = (board) => path41.join(board, "triage");
122374
- var rejectedDir = (board) => path41.join(board, ".archive", REJECTIONS_TO_REVIEW);
122449
+ var triageDir = (board) => path42.join(board, "triage");
122450
+ var rejectedDir = (board) => path42.join(board, ".archive", REJECTIONS_TO_REVIEW);
122375
122451
  var SCRATCH = ["dismissed", "archived"];
122376
122452
  var stamp2 = (at2) => formatStamp(at2 ? new Date(at2) : /* @__PURE__ */ new Date());
122377
122453
  function slugOf(title) {
@@ -122380,7 +122456,7 @@ function slugOf(title) {
122380
122456
  function freeName(dir, title) {
122381
122457
  const stem = slugOf(title);
122382
122458
  let name = `${stem}.md`;
122383
- for (let n = 2; fs38.existsSync(path41.join(dir, name)); n++) name = `${stem}-${n}.md`;
122459
+ for (let n = 2; fs39.existsSync(path42.join(dir, name)); n++) name = `${stem}-${n}.md`;
122384
122460
  return name;
122385
122461
  }
122386
122462
  function itemText(item, fields = {}) {
@@ -122400,17 +122476,17 @@ ${item.text.trim()}
122400
122476
  `;
122401
122477
  }
122402
122478
  function writeItem(dir, item, fields = {}) {
122403
- fs38.mkdirSync(dir, { recursive: true });
122479
+ fs39.mkdirSync(dir, { recursive: true });
122404
122480
  const name = freeName(dir, item.title);
122405
- fs38.writeFileSync(path41.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields } : fields));
122481
+ fs39.writeFileSync(path42.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields } : fields));
122406
122482
  return name;
122407
122483
  }
122408
122484
  function layOut(board, rejections) {
122409
122485
  clearLaid(board);
122410
122486
  const dir = rejectedDir(board);
122411
- fs38.mkdirSync(dir, { recursive: true });
122487
+ fs39.mkdirSync(dir, { recursive: true });
122412
122488
  for (const t2 of rejections.tasks) {
122413
- fs38.writeFileSync(path41.join(dir, `${t2.number}-${slugify(t2.title)}.md`), [
122489
+ fs39.writeFileSync(path42.join(dir, `${t2.number}-${slugify(t2.title)}.md`), [
122414
122490
  "---",
122415
122491
  `title: ${yamlScalar(t2.title)}`,
122416
122492
  "status: todo",
@@ -122425,25 +122501,25 @@ function layOut(board, rejections) {
122425
122501
  ].join("\n"));
122426
122502
  }
122427
122503
  for (const item of rejections.triage) {
122428
- const sub = path41.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
122504
+ const sub = path42.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
122429
122505
  const fields = item.state === "dismissed" ? { dismissed_at: stamp2(item.dismissed_at), dismissed_by: "user", ...item.dismissed_reason ? { dismissed_reason: item.dismissed_reason } : {} } : {};
122430
122506
  writeItem(sub, item, fields);
122431
122507
  }
122432
122508
  return { tasks: rejections.tasks.map((t2) => t2.id), triage: rejections.triage.map((i) => i.id) };
122433
122509
  }
122434
122510
  function clearLaid(board) {
122435
- fs38.rmSync(rejectedDir(board), { recursive: true, force: true });
122436
- for (const sub of SCRATCH) fs38.rmSync(path41.join(triageDir(board), sub), { recursive: true, force: true });
122511
+ fs39.rmSync(rejectedDir(board), { recursive: true, force: true });
122512
+ for (const sub of SCRATCH) fs39.rmSync(path42.join(triageDir(board), sub), { recursive: true, force: true });
122437
122513
  }
122438
122514
 
122439
122515
  // ../cli/src/lib/skill/hook.ts
122440
122516
  import { spawnSync as spawnSync7 } from "node:child_process";
122441
- import fs39 from "node:fs";
122442
- import path42 from "node:path";
122517
+ import fs40 from "node:fs";
122518
+ import path43 from "node:path";
122443
122519
  var MARKER_LINE = /^# ai4kanban commit guard\b/m;
122444
122520
  var read2 = (file3) => {
122445
122521
  try {
122446
- return fs39.readFileSync(file3, "utf8");
122522
+ return fs40.readFileSync(file3, "utf8");
122447
122523
  } catch {
122448
122524
  return null;
122449
122525
  }
@@ -122455,15 +122531,15 @@ function hooksDir(root2) {
122455
122531
  windowsHide: true
122456
122532
  });
122457
122533
  if (out.error || out.status !== 0 || !out.stdout.trim()) return null;
122458
- return path42.resolve(root2, out.stdout.trim());
122534
+ return path43.resolve(root2, out.stdout.trim());
122459
122535
  }
122460
122536
  function installCommitHook(root2, _board) {
122461
122537
  const dir = hooksDir(root2);
122462
122538
  if (!dir) return {};
122463
- const file3 = path42.join(dir, "pre-commit");
122464
- if (fs39.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
122539
+ const file3 = path43.join(dir, "pre-commit");
122540
+ if (fs40.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
122465
122541
  const source2 = read2(file3);
122466
- if (source2 && MARKER_LINE.test(source2)) fs39.unlinkSync(file3);
122542
+ if (source2 && MARKER_LINE.test(source2)) fs40.unlinkSync(file3);
122467
122543
  return {};
122468
122544
  }
122469
122545
 
@@ -122500,7 +122576,7 @@ function runtimeCosts(runs, job) {
122500
122576
  }
122501
122577
  function reviewOf2(file3) {
122502
122578
  try {
122503
- const meta = parseFrontmatter(fs40.readFileSync(file3, "utf8")).meta;
122579
+ const meta = parseFrontmatter(fs41.readFileSync(file3, "utf8")).meta;
122504
122580
  return meta ? reviewOf(meta) : null;
122505
122581
  } catch {
122506
122582
  return null;
@@ -122508,15 +122584,15 @@ function reviewOf2(file3) {
122508
122584
  }
122509
122585
  function asks(file3) {
122510
122586
  try {
122511
- return (parseFrontmatter(fs40.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
122587
+ return (parseFrontmatter(fs41.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
122512
122588
  } catch {
122513
122589
  return false;
122514
122590
  }
122515
122591
  }
122516
122592
  function mcpConfig(servers, file3) {
122517
122593
  if (!Object.keys(servers).length) return null;
122518
- fs40.mkdirSync(path43.dirname(file3), { recursive: true });
122519
- fs40.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
122594
+ fs41.mkdirSync(path44.dirname(file3), { recursive: true });
122595
+ fs41.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
122520
122596
  `);
122521
122597
  return file3;
122522
122598
  }
@@ -122555,7 +122631,7 @@ function deliveryEnding(ws, id, asked = false) {
122555
122631
  if (!id) return null;
122556
122632
  let held5;
122557
122633
  try {
122558
- held5 = JSON.parse(fs40.readFileSync(path43.join(ws.board, "deliveries", `${path43.basename(id)}.json`), "utf8"));
122634
+ held5 = JSON.parse(fs41.readFileSync(path44.join(ws.board, "deliveries", `${path44.basename(id)}.json`), "utf8"));
122559
122635
  } catch {
122560
122636
  return null;
122561
122637
  }
@@ -122567,16 +122643,16 @@ function deliveryEnding(ws, id, asked = false) {
122567
122643
  return null;
122568
122644
  }
122569
122645
  function checkoutsOf(ws, id) {
122570
- const dir = path43.join(ws.board, "deliveries");
122646
+ const dir = path44.join(ws.board, "deliveries");
122571
122647
  let names2;
122572
122648
  try {
122573
- names2 = fs40.readdirSync(dir).filter((n) => n.endsWith(".json"));
122649
+ names2 = fs41.readdirSync(dir).filter((n) => n.endsWith(".json"));
122574
122650
  } catch {
122575
122651
  return [];
122576
122652
  }
122577
122653
  return names2.flatMap((n) => {
122578
122654
  try {
122579
- const held5 = JSON.parse(fs40.readFileSync(path43.join(dir, n), "utf8"));
122655
+ const held5 = JSON.parse(fs41.readFileSync(path44.join(dir, n), "utf8"));
122580
122656
  return held5.cardId === id && held5.deliveryId ? [held5.deliveryId] : [];
122581
122657
  } catch {
122582
122658
  return [];
@@ -122590,7 +122666,7 @@ var RESUME_REFUSED = {
122590
122666
  deliveryRunGoing: "\u4E0A\u6B21\u7684\u8FD0\u884C\u8FD8\u6CA1\u505C\u4E0B\uFF0C\u8BF7\u7A0D\u540E\u518D\u70B9\u300C\u7EED\u8DD1\u300D\u3002",
122591
122667
  deliveryCardGone: "\u8FD9\u5F20\u5361\u5DF2\u4E0D\u5728\u770B\u677F\u4E0A\uFF0C\u6CA1\u6709\u53EF\u7EED\u8DD1\u7684\u5185\u5BB9\uFF0C\u8BF7\u70B9\u300C\u91CD\u65B0\u53D1\u8D77\u300D\u3002"
122592
122668
  };
122593
- var isArchived = (ws, id) => path43.relative(ws.board, findCard(ws.board, id) ?? ws.board).split(path43.sep)[0] === ".archive";
122669
+ var isArchived = (ws, id) => path44.relative(ws.board, findCard(ws.board, id) ?? ws.board).split(path44.sep)[0] === ".archive";
122594
122670
  var refusal3 = (ran) => ran.last.replace(/^akb( raw)?: /, "").slice(0, 300) || "akb stopped with an error.";
122595
122671
  var reasonOf = (text4) => (text4 ?? "").split("\n").map((l2) => l2.trim()).filter((l2) => l2 && !/^at\s/.test(l2)).join("\n").slice(0, 300) || void 0;
122596
122672
  function logLines(show, event2) {
@@ -122660,7 +122736,7 @@ async function setUp(job, ws, deps, io) {
122660
122736
  const runtime = job.runtime;
122661
122737
  const missing = unavailable(runtime, await deps.runtimes());
122662
122738
  if (missing) return missing;
122663
- if (!fs40.existsSync(path43.join(ws.board, "config.md"))) {
122739
+ if (!fs41.existsSync(path44.join(ws.board, "config.md"))) {
122664
122740
  const init = await akb(["raw", "init"]);
122665
122741
  if (init.code !== 0) return refusal3(init);
122666
122742
  }
@@ -122677,7 +122753,7 @@ async function setUp(job, ws, deps, io) {
122677
122753
  const used = await akb(["raw", "agent", "use", runtime]);
122678
122754
  if (used.code !== 0) return refusal3(used);
122679
122755
  const servers = mcpServersOf(ws);
122680
- const mcpFile = path43.join(ws.board, ".sync", `${ws.task}.mcp.json`);
122756
+ const mcpFile = path44.join(ws.board, ".sync", `${ws.task}.mcp.json`);
122681
122757
  const takes = new Set(settingKeys(runtime));
122682
122758
  const given = job.settings ?? {};
122683
122759
  const values = valuesOf(runtime, job.model, given, servers, mcpFile);
@@ -122800,19 +122876,19 @@ async function runAgent(job, ws, deps, io) {
122800
122876
  }
122801
122877
  function writeTranscript(job, dir) {
122802
122878
  if (!job.transcript) return "";
122803
- const file3 = path43.join(dir, "discussion.md");
122804
- fs40.mkdirSync(dir, { recursive: true });
122805
- fs40.writeFileSync(file3, `${job.transcript}
122879
+ const file3 = path44.join(dir, "discussion.md");
122880
+ fs41.mkdirSync(dir, { recursive: true });
122881
+ fs41.writeFileSync(file3, `${job.transcript}
122806
122882
  `);
122807
122883
  return file3;
122808
122884
  }
122809
122885
  function pictures(job, ws, id) {
122810
122886
  const dir = cardAssetsDir(ws, id);
122811
122887
  if (!job.attachments.length || !dir) return "";
122812
- fs40.mkdirSync(dir, { recursive: true });
122888
+ fs41.mkdirSync(dir, { recursive: true });
122813
122889
  return job.attachments.map((a2, i) => {
122814
- const file3 = `${i + 1}-${path43.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
122815
- fs40.writeFileSync(path43.join(dir, file3), Buffer.from(a2.content, "base64"));
122890
+ const file3 = `${i + 1}-${path44.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
122891
+ fs41.writeFileSync(path44.join(dir, file3), Buffer.from(a2.content, "base64"));
122816
122892
  return `
122817
122893
  <Asset src=".assets/${id}/${file3}" label="${a2.name.replace(/["<>]/g, "") || file3}" />
122818
122894
  `;
@@ -122820,7 +122896,7 @@ function pictures(job, ws, id) {
122820
122896
  }
122821
122897
  function cardFlags(ws, fields) {
122822
122898
  if (!fields) return [];
122823
- const open = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path43.join(ws.board, "todo") + path43.sep));
122899
+ const open = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path44.join(ws.board, "todo") + path44.sep));
122824
122900
  const lists = [["--modules", fields.modules ?? []], ["--related", open(fields.related)], ["--blocked-by", open(fields.blocked_by)]];
122825
122901
  return [
122826
122902
  ...fields.priority ? ["--priority", fields.priority] : [],
@@ -122851,10 +122927,10 @@ async function runFlow(job, ws, deps, io) {
122851
122927
  said = { title: task.value.title?.trim() ?? "", request: task.value.request?.trim() ?? "" };
122852
122928
  }
122853
122929
  const title = said.title || "Untitled";
122854
- const body = path43.join(ws.board, ".sync", `${ws.task}.request.md`);
122855
- fs40.mkdirSync(path43.dirname(body), { recursive: true });
122930
+ const body = path44.join(ws.board, ".sync", `${ws.task}.request.md`);
122931
+ fs41.mkdirSync(path44.dirname(body), { recursive: true });
122856
122932
  if (!ws.number) return fail("This task has no number yet.");
122857
- fs40.writeFileSync(body, `${said.request || title}
122933
+ fs41.writeFileSync(body, `${said.request || title}
122858
122934
  ${pictures(job, ws, ws.number)}`);
122859
122935
  const created = await withBoard(ws, async (push2) => {
122860
122936
  const card2 = made(await akb([
@@ -122871,7 +122947,7 @@ ${pictures(job, ws, ws.number)}`);
122871
122947
  ...cardFlags(ws, flow.metadata),
122872
122948
  "--json"
122873
122949
  ]));
122874
- fs40.rmSync(body, { force: true });
122950
+ fs41.rmSync(body, { force: true });
122875
122951
  if (!card2.ok) return card2;
122876
122952
  const sent = await push2({ id: job.id, machineId: deps.machineId });
122877
122953
  if (!sent.ok) return { ok: false, error: sent.error };
@@ -122892,7 +122968,7 @@ ${pictures(job, ws, ws.number)}`);
122892
122968
  if (io.lost()) return fail("");
122893
122969
  return await workOn(card);
122894
122970
  } finally {
122895
- fs40.rmSync(path43.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
122971
+ fs41.rmSync(path44.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
122896
122972
  const left = working.get(key) - 1;
122897
122973
  if (left) working.set(key, left);
122898
122974
  else working.delete(key);
@@ -122937,7 +123013,7 @@ ${pictures(job, ws, ws.number)}`);
122937
123013
  const resolved = await akb(["raw", "card", "resolve", String(id2), "--follow", "--events", "--json", "--", text4], true);
122938
123014
  if (io.lost()) return fail("");
122939
123015
  const file3 = findCard(ws.board, id2);
122940
- rejected = !!file3 && path43.relative(ws.board, file3).split(path43.sep)[0] === ".archive" && parseFrontmatter(fs40.readFileSync(file3, "utf8")).meta?.rejected === true;
123016
+ rejected = !!file3 && path44.relative(ws.board, file3).split(path44.sep)[0] === ".archive" && parseFrontmatter(fs41.readFileSync(file3, "utf8")).meta?.rejected === true;
122941
123017
  if (rejected) ran = resolved;
122942
123018
  else if (resolved.code !== 0) note = text4;
122943
123019
  }
@@ -122986,8 +123062,8 @@ ${pictures(job, ws, ws.number)}`);
122986
123062
  return { ok: true, report: { card: card2 } };
122987
123063
  }
122988
123064
  function carryArgs(verb) {
122989
- if (!["refine", "resolve", "revise", "implement"].includes(verb)) return [];
122990
- const transcript = writeTranscript(job, path43.join(ws.board, ".sync", `${ws.task}.discussion`));
123065
+ if (!["refine", "resolve", "revise"].includes(verb)) return [];
123066
+ const transcript = writeTranscript(job, path44.join(ws.board, ".sync", `${ws.task}.discussion`));
122991
123067
  return [
122992
123068
  ...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
122993
123069
  ...transcript ? ["--transcript", transcript] : []
@@ -123006,8 +123082,8 @@ async function confirmFlowStopped(ws, job, deps) {
123006
123082
  }
123007
123083
 
123008
123084
  // src/recovery.ts
123009
- import fs41 from "node:fs";
123010
- import path44 from "node:path";
123085
+ import fs42 from "node:fs";
123086
+ import path45 from "node:path";
123011
123087
 
123012
123088
  // ../cli/src/lib/agent/retry.ts
123013
123089
  var RETRY_WINDOW_MS = 15 * 6e4;
@@ -123023,10 +123099,10 @@ function backoffMs(attempt, random2 = Math.random) {
123023
123099
  var PREPARE_REASON = "Runner update prepare.";
123024
123100
  var UPDATE_REASON = "Runner update checkpoint.";
123025
123101
  var UNCERTAIN = "\u66F4\u65B0\u4E2D\u65AD\u65F6\u6709\u64CD\u4F5C\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u68C0\u67E5\u5DF2\u6709\u7ED3\u679C\u540E\u518D\u7EED\u8DD1\u3002";
123026
- var fileOf = (id) => path44.join(runnerHome(), "checkpoints", `${encodeURIComponent(id)}.json`);
123102
+ var fileOf = (id) => path45.join(runnerHome(), "checkpoints", `${encodeURIComponent(id)}.json`);
123027
123103
  function readCheckpoint(id) {
123028
123104
  try {
123029
- const held5 = JSON.parse(fs41.readFileSync(fileOf(id), "utf8"));
123105
+ const held5 = JSON.parse(fs42.readFileSync(fileOf(id), "utf8"));
123030
123106
  if (!held5 || !Array.isArray(held5.pending) || !held5.pending.every((id2) => typeof id2 === "string")) throw new Error("\u8FDB\u5EA6\u683C\u5F0F\u9519\u8BEF");
123031
123107
  return held5;
123032
123108
  } catch (e2) {
@@ -123036,12 +123112,12 @@ function readCheckpoint(id) {
123036
123112
  }
123037
123113
  function saveCheckpoint(id, checkpoint) {
123038
123114
  const file3 = fileOf(id);
123039
- fs41.mkdirSync(path44.dirname(file3), { recursive: true, mode: 448 });
123040
- fs41.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
123041
- fs41.renameSync(`${file3}.tmp`, file3);
123115
+ fs42.mkdirSync(path45.dirname(file3), { recursive: true, mode: 448 });
123116
+ fs42.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
123117
+ fs42.renameSync(`${file3}.tmp`, file3);
123042
123118
  }
123043
123119
  function clearCheckpoint(id) {
123044
- fs41.rmSync(fileOf(id), { force: true });
123120
+ fs42.rmSync(fileOf(id), { force: true });
123045
123121
  }
123046
123122
  function checkpointEvent(checkpoint, event2) {
123047
123123
  if (event2.kind === "phase" && event2.data.phase === "submitted") checkpoint.submitted = true;
@@ -123072,8 +123148,8 @@ function replyRetry(checkpoint, reason, now = Date.now(), backoff = backoffMs) {
123072
123148
  if (!retry2 || retry2.attempt >= 3) return null;
123073
123149
  if (retry2.attempt === 1 && retry2.at === void 0) retry2.since = now;
123074
123150
  const seconds = /retry[-_\s]?after["':=\s]+(\d+)/i.exec(reason)?.[1];
123075
- const delay = seconds ? Number(seconds) * 1e3 : backoff(retry2.attempt + 1);
123076
- const at2 = now + delay;
123151
+ const delay2 = seconds ? Number(seconds) * 1e3 : backoff(retry2.attempt + 1);
123152
+ const at2 = now + delay2;
123077
123153
  return at2 <= retry2.since + 12e4 ? at2 : null;
123078
123154
  }
123079
123155
  function replayable(checkpoint) {
@@ -123103,17 +123179,17 @@ function replySpent(checkpoint, runtime) {
123103
123179
  }
123104
123180
 
123105
123181
  // src/lock.ts
123106
- import crypto7 from "node:crypto";
123107
- import fs42 from "node:fs";
123182
+ import crypto8 from "node:crypto";
123183
+ import fs43 from "node:fs";
123108
123184
  import net from "node:net";
123109
- import path45 from "node:path";
123185
+ import path46 from "node:path";
123110
123186
  var RETRY_MS = 5e3;
123111
123187
  var KIND_MS = 1e3;
123112
123188
  var HOLDERS = ["claude-code", "codex", "cursor", "dsh", "zcode", "kimi", "terminal"];
123113
123189
  function lockPath() {
123114
123190
  const home4 = runnerHome();
123115
- if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${crypto7.createHash("sha256").update(home4).digest("hex").slice(0, 16)}`;
123116
- return path45.join(home4, "runner.sock");
123191
+ if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${crypto8.createHash("sha256").update(home4).digest("hex").slice(0, 16)}`;
123192
+ return path46.join(home4, "runner.sock");
123117
123193
  }
123118
123194
  function holdMachine(kind, onHeld, onWaiting) {
123119
123195
  const where = lockPath();
@@ -123128,7 +123204,7 @@ function holdMachine(kind, onHeld, onWaiting) {
123128
123204
  const attempt = () => {
123129
123205
  timer = null;
123130
123206
  if (closed) return;
123131
- if (process.platform !== "win32") fs42.mkdirSync(path45.dirname(where), { recursive: true, mode: 448 });
123207
+ if (process.platform !== "win32") fs43.mkdirSync(path46.dirname(where), { recursive: true, mode: 448 });
123132
123208
  const s = net.createServer((peer) => {
123133
123209
  peers.add(peer);
123134
123210
  peer.on("error", () => {
@@ -123176,7 +123252,7 @@ function holdMachine(kind, onHeld, onWaiting) {
123176
123252
  later(0);
123177
123253
  });
123178
123254
  removeIfStill.once("error", () => {
123179
- fs42.rmSync(where, { force: true });
123255
+ fs43.rmSync(where, { force: true });
123180
123256
  later(50 + Math.random() * 200);
123181
123257
  });
123182
123258
  return;
@@ -123322,9 +123398,9 @@ function conversationProgress(attempt, send3, valid, unconfirmed) {
123322
123398
  }
123323
123399
 
123324
123400
  // src/reply-images.ts
123325
- import fs43 from "node:fs";
123326
- import path46 from "node:path";
123327
- import os7 from "node:os";
123401
+ import fs44 from "node:fs";
123402
+ import path47 from "node:path";
123403
+ import os8 from "node:os";
123328
123404
  import { fileURLToPath as fileURLToPath3 } from "node:url";
123329
123405
  import { createHash as createHash6 } from "node:crypto";
123330
123406
 
@@ -123341,16 +123417,16 @@ function imageMime(bytes2) {
123341
123417
 
123342
123418
  // src/reply-images.ts
123343
123419
  var inside = (root2, file3) => {
123344
- const p2 = path46.relative(root2, file3);
123345
- return p2 !== ".." && !p2.startsWith(`..${path46.sep}`) && !path46.isAbsolute(p2);
123420
+ const p2 = path47.relative(root2, file3);
123421
+ return p2 !== ".." && !p2.startsWith(`..${path47.sep}`) && !path47.isAbsolute(p2);
123346
123422
  };
123347
123423
  function collectReplyImages(parts, cwd) {
123348
123424
  const files = /* @__PURE__ */ new Map();
123349
123425
  const tools = [];
123350
123426
  const output2 = [];
123351
- const roots = [cwd, path46.join(process.env.CODEX_HOME?.trim() || path46.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
123427
+ const roots = [cwd, path47.join(process.env.CODEX_HOME?.trim() || path47.join(os8.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
123352
123428
  try {
123353
- return [fs43.realpathSync(p2)];
123429
+ return [fs44.realpathSync(p2)];
123354
123430
  } catch {
123355
123431
  return [];
123356
123432
  }
@@ -123358,17 +123434,17 @@ function collectReplyImages(parts, cwd) {
123358
123434
  const registered = new Set(parts.flatMap((p2) => {
123359
123435
  if (p2.type !== "image" || !p2.registered || !p2.path) return [];
123360
123436
  try {
123361
- const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path46.resolve(cwd, p2.path);
123362
- if (!fs43.lstatSync(file3).isFile()) return [];
123363
- const real = fs43.realpathSync(file3);
123364
- const fd = fs43.openSync(real, fs43.constants.O_RDONLY | (fs43.constants.O_NOFOLLOW ?? 0));
123437
+ const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path47.resolve(cwd, p2.path);
123438
+ if (!fs44.lstatSync(file3).isFile()) return [];
123439
+ const real = fs44.realpathSync(file3);
123440
+ const fd = fs44.openSync(real, fs44.constants.O_RDONLY | (fs44.constants.O_NOFOLLOW ?? 0));
123365
123441
  try {
123366
- const stat = fs43.fstatSync(fd);
123442
+ const stat = fs44.fstatSync(fd);
123367
123443
  if (!stat.isFile() || stat.size > ASSET_FILE_LIMIT) return [];
123368
- const mime = imageMime(fs43.readFileSync(fd));
123444
+ const mime = imageMime(fs44.readFileSync(fd));
123369
123445
  return mime && (!p2.mime || p2.mime === mime) ? [real] : [];
123370
123446
  } finally {
123371
- fs43.closeSync(fd);
123447
+ fs44.closeSync(fd);
123372
123448
  }
123373
123449
  } catch {
123374
123450
  return [];
@@ -123384,16 +123460,16 @@ function collectReplyImages(parts, cwd) {
123384
123460
  if (!p2.path) throw Error();
123385
123461
  const source2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : decodeURIComponent(p2.path);
123386
123462
  if (/^[a-z][a-z0-9+.-]*:/i.test(source2) && !/^[A-Za-z]:[\\/]/.test(source2)) throw Error();
123387
- const real = fs43.realpathSync(path46.resolve(cwd, source2));
123463
+ const real = fs44.realpathSync(path47.resolve(cwd, source2));
123388
123464
  if (!/\.(png|jpe?g|gif|webp)$/i.test(source2) && !registered.has(real)) throw Error();
123389
123465
  if (!roots.some((root2) => inside(root2, real)) && !registered.has(real)) throw Error();
123390
- const fd = fs43.openSync(real, fs43.constants.O_RDONLY | (fs43.constants.O_NOFOLLOW ?? 0));
123466
+ const fd = fs44.openSync(real, fs44.constants.O_RDONLY | (fs44.constants.O_NOFOLLOW ?? 0));
123391
123467
  try {
123392
- const stat = fs43.fstatSync(fd);
123468
+ const stat = fs44.fstatSync(fd);
123393
123469
  if (!stat.isFile() || stat.size > ASSET_FILE_LIMIT) throw Error();
123394
- bytes2 = fs43.readFileSync(fd);
123470
+ bytes2 = fs44.readFileSync(fd);
123395
123471
  } finally {
123396
- fs43.closeSync(fd);
123472
+ fs44.closeSync(fd);
123397
123473
  }
123398
123474
  }
123399
123475
  return bytes2;
@@ -123478,9 +123554,9 @@ async function saveReplyImages(parts, cwd, upload2) {
123478
123554
 
123479
123555
  // src/handoff.ts
123480
123556
  import { execFileSync as execFileSync2 } from "node:child_process";
123481
- import crypto8 from "node:crypto";
123482
- import fs44 from "node:fs";
123483
- import path47 from "node:path";
123557
+ import crypto9 from "node:crypto";
123558
+ import fs45 from "node:fs";
123559
+ import path48 from "node:path";
123484
123560
  var gitRead = (cwd, args2) => {
123485
123561
  try {
123486
123562
  return execFileSync2("git", ["-C", cwd, ...args2], {
@@ -123493,12 +123569,12 @@ var gitRead = (cwd, args2) => {
123493
123569
  return null;
123494
123570
  }
123495
123571
  };
123496
- var digest = (value) => crypto8.createHash("sha256").update(value).digest("hex");
123572
+ var digest = (value) => crypto9.createHash("sha256").update(value).digest("hex");
123497
123573
  function authorizedFolder(folder) {
123498
123574
  if (!folder) return null;
123499
123575
  try {
123500
- const real = fs44.realpathSync(folder);
123501
- return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path47.sep)) ? real : null;
123576
+ const real = fs45.realpathSync(folder);
123577
+ return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path48.sep)) ? real : null;
123502
123578
  } catch {
123503
123579
  return null;
123504
123580
  }
@@ -123508,9 +123584,9 @@ function progressFolder(job, folder) {
123508
123584
  if (!token) return folder;
123509
123585
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) return null;
123510
123586
  try {
123511
- const dir = fs44.realpathSync(path47.join(folder, ".akb", "handoffs", token));
123512
- if (!dir.startsWith(fs44.realpathSync(folder) + path47.sep)) return null;
123513
- const marker = JSON.parse(fs44.readFileSync(path47.join(dir, ".akb", "handoff.json"), "utf8"));
123587
+ const dir = fs45.realpathSync(path48.join(folder, ".akb", "handoffs", token));
123588
+ if (!dir.startsWith(fs45.realpathSync(folder) + path48.sep)) return null;
123589
+ const marker = JSON.parse(fs45.readFileSync(path48.join(dir, ".akb", "handoff.json"), "utf8"));
123514
123590
  return marker.task === job.task && marker.isolation === token ? dir : null;
123515
123591
  } catch {
123516
123592
  return null;
@@ -123518,38 +123594,38 @@ function progressFolder(job, folder) {
123518
123594
  }
123519
123595
  function progressEvidence(job, folder) {
123520
123596
  try {
123521
- const board = path47.join(folder, ".akb", "kanban");
123522
- const deliveries = path47.join(board, "deliveries");
123523
- const rows = fs44.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs44.readFileSync(path47.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
123597
+ const board = path48.join(folder, ".akb", "kanban");
123598
+ const deliveries = path48.join(board, "deliveries");
123599
+ const rows = fs45.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs45.readFileSync(path48.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
123524
123600
  const row = rows[0];
123525
123601
  if (!row?.deliveryId) return null;
123526
- const tree = fs44.realpathSync(path47.resolve(folder, row.worktree ?? "."));
123527
- if (tree !== fs44.realpathSync(folder) && !tree.startsWith(fs44.realpathSync(folder) + path47.sep)) return null;
123602
+ const tree = fs45.realpathSync(path48.resolve(folder, row.worktree ?? "."));
123603
+ if (tree !== fs45.realpathSync(folder) && !tree.startsWith(fs45.realpathSync(folder) + path48.sep)) return null;
123528
123604
  const inventory = gitRead(tree, ["worktree", "list", "--porcelain"]);
123529
123605
  const related = (inventory ?? "").split("\n\n").flatMap((entry) => {
123530
123606
  const branch = /^branch refs\/heads\/(.+)$/m.exec(entry)?.[1];
123531
123607
  const dir = /^worktree (.+)$/m.exec(entry)?.[1];
123532
- return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs44.realpathSync(folder) + path47.sep) ? [dir] : [];
123608
+ return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs45.realpathSync(folder) + path48.sep) ? [dir] : [];
123533
123609
  });
123534
123610
  const filesIn = (tree2) => {
123535
123611
  const changed = [];
123536
123612
  const walk = (dir, prefix = "") => {
123537
- for (const entry of fs44.readdirSync(dir, { withFileTypes: true })) {
123613
+ for (const entry of fs45.readdirSync(dir, { withFileTypes: true })) {
123538
123614
  if ([".git", ".akb", "node_modules", ".claude", ".agents"].includes(entry.name)) continue;
123539
123615
  const name = prefix + entry.name;
123540
- if (entry.isDirectory()) walk(path47.join(dir, entry.name), name + "/");
123616
+ if (entry.isDirectory()) walk(path48.join(dir, entry.name), name + "/");
123541
123617
  else changed.push(name);
123542
123618
  }
123543
123619
  };
123544
123620
  walk(tree2);
123545
123621
  changed.sort();
123546
123622
  return changed.map((name) => {
123547
- const file3 = path47.join(tree2, name);
123623
+ const file3 = path48.join(tree2, name);
123548
123624
  try {
123549
- const stat = fs44.lstatSync(file3);
123550
- if (stat.isSymbolicLink()) return [name, "link", digest(fs44.readlinkSync(file3))];
123625
+ const stat = fs45.lstatSync(file3);
123626
+ if (stat.isSymbolicLink()) return [name, "link", digest(fs45.readlinkSync(file3))];
123551
123627
  if (!stat.isFile()) throw new Error("\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B");
123552
- return [name, stat.mode & 511, digest(fs44.readFileSync(file3))];
123628
+ return [name, stat.mode & 511, digest(fs45.readFileSync(file3))];
123553
123629
  } catch (e2) {
123554
123630
  if (e2.code === "ENOENT") return [name, "deleted"];
123555
123631
  throw e2;
@@ -123586,60 +123662,60 @@ function progressEvidence(job, folder) {
123586
123662
  function restartFolder(job, folder) {
123587
123663
  const token = job.handoff?.isolation ?? job.id;
123588
123664
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) throw new Error("\u9694\u79BB\u76EE\u5F55\u7F16\u53F7\u65E0\u6548\u3002");
123589
- const dir = path47.join(folder, ".akb", "handoffs", token);
123590
- const marker = path47.join(dir, ".akb", "handoff.json");
123591
- for (const parent of [path47.join(folder, ".akb"), path47.dirname(dir), dir]) {
123592
- if (fs44.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
123665
+ const dir = path48.join(folder, ".akb", "handoffs", token);
123666
+ const marker = path48.join(dir, ".akb", "handoff.json");
123667
+ for (const parent of [path48.join(folder, ".akb"), path48.dirname(dir), dir]) {
123668
+ if (fs45.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
123593
123669
  }
123594
- if (fs44.existsSync(dir)) {
123670
+ if (fs45.existsSync(dir)) {
123595
123671
  if (job.handoff?.recovering) {
123596
123672
  try {
123597
- const saved = JSON.parse(fs44.readFileSync(marker, "utf8"));
123673
+ const saved = JSON.parse(fs45.readFileSync(marker, "utf8"));
123598
123674
  if (saved.task === job.task && saved.isolation === token) return dir;
123599
123675
  } catch {
123600
123676
  }
123601
123677
  }
123602
123678
  throw new Error("\u91CD\u542F\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u3002");
123603
123679
  }
123604
- fs44.mkdirSync(path47.dirname(dir), { recursive: true });
123605
- fs44.mkdirSync(dir);
123606
- for (const entry of fs44.readdirSync(folder)) {
123680
+ fs45.mkdirSync(path48.dirname(dir), { recursive: true });
123681
+ fs45.mkdirSync(dir);
123682
+ for (const entry of fs45.readdirSync(folder)) {
123607
123683
  if ([".akb", ".git", "node_modules", ".claude", ".agents"].includes(entry)) continue;
123608
- fs44.cpSync(path47.join(folder, entry), path47.join(dir, entry), { recursive: true, verbatimSymlinks: true });
123684
+ fs45.cpSync(path48.join(folder, entry), path48.join(dir, entry), { recursive: true, verbatimSymlinks: true });
123609
123685
  }
123610
- if (fs44.lstatSync(path47.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
123611
- fs44.mkdirSync(path47.dirname(marker), { recursive: true });
123612
- fs44.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
123686
+ if (fs45.lstatSync(path48.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
123687
+ fs45.mkdirSync(path48.dirname(marker), { recursive: true });
123688
+ fs45.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
123613
123689
  return dir;
123614
123690
  }
123615
123691
 
123616
123692
  // src/jobs.ts
123617
123693
  import { spawn as spawn4 } from "node:child_process";
123618
- import fs46 from "node:fs";
123619
- import path49 from "node:path";
123694
+ import fs47 from "node:fs";
123695
+ import path50 from "node:path";
123620
123696
 
123621
123697
  // ../cli/src/lib/agent/catalog.ts
123622
- import fs45 from "node:fs";
123623
- import path48 from "node:path";
123698
+ import fs46 from "node:fs";
123699
+ import path49 from "node:path";
123624
123700
  var CATALOGUE = "https://models.dev/api.json";
123625
123701
  var FRESH_FOR_MS = 24 * 60 * 6e4;
123626
123702
  var ANSWER_BY_MS = 2e4;
123627
123703
  function cacheFile() {
123628
- return path48.join(machineHome(), "models-dev.json");
123704
+ return path49.join(machineHome(), "models-dev.json");
123629
123705
  }
123630
123706
  var held3;
123631
123707
  function readCache() {
123632
123708
  const file3 = cacheFile();
123633
123709
  let stamp3;
123634
123710
  try {
123635
- const stat = fs45.statSync(file3);
123711
+ const stat = fs46.statSync(file3);
123636
123712
  stamp3 = `${stat.mtimeMs}:${stat.size}`;
123637
123713
  } catch {
123638
123714
  return void 0;
123639
123715
  }
123640
123716
  if (held3?.stamp === stamp3) return held3.cached;
123641
123717
  try {
123642
- const data = JSON.parse(fs45.readFileSync(file3, "utf8"));
123718
+ const data = JSON.parse(fs46.readFileSync(file3, "utf8"));
123643
123719
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
123644
123720
  const cached2 = {
123645
123721
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -123678,8 +123754,8 @@ function refreshCatalog() {
123678
123754
  const limits = limitsIn(await answer.json());
123679
123755
  if (Object.keys(limits).length === 0) return;
123680
123756
  const file3 = cacheFile();
123681
- fs45.mkdirSync(path48.dirname(file3), { recursive: true });
123682
- fs45.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
123757
+ fs46.mkdirSync(path49.dirname(file3), { recursive: true });
123758
+ fs46.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
123683
123759
  } catch {
123684
123760
  }
123685
123761
  })();
@@ -123724,9 +123800,9 @@ function contextLimit(harness, model) {
123724
123800
 
123725
123801
  // src/reply-approval.ts
123726
123802
  import http2 from "node:http";
123727
- import crypto9 from "node:crypto";
123803
+ import crypto10 from "node:crypto";
123728
123804
  async function replyApprovalBridge(task, number, approve) {
123729
- const token = crypto9.randomBytes(32).toString("hex");
123805
+ const token = crypto10.randomBytes(32).toString("hex");
123730
123806
  let serial = Promise.resolve();
123731
123807
  const server = http2.createServer((req, res) => {
123732
123808
  const answer = (status2, body) => {
@@ -123836,32 +123912,32 @@ var defaultDeps = (machineId2) => ({
123836
123912
  akb: currentAkb,
123837
123913
  runtimes: detectRuntimes
123838
123914
  });
123839
- var ownFolder = () => path49.join(runnerHome(), "work");
123915
+ var ownFolder = () => path50.join(runnerHome(), "work");
123840
123916
  function folderFor(job) {
123841
123917
  if (!job.projectDir) {
123842
- const cwd = path49.join(ownFolder(), job.id);
123843
- fs46.mkdirSync(cwd, { recursive: true });
123918
+ const cwd = path50.join(ownFolder(), job.id);
123919
+ fs47.mkdirSync(cwd, { recursive: true });
123844
123920
  return { cwd };
123845
123921
  }
123846
123922
  const real = realpath4(job.projectDir);
123847
- if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path49.sep))) return { cwd: real };
123923
+ if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path50.sep))) return { cwd: real };
123848
123924
  return { refused: `This Runner is not allowed to work in ${job.projectDir}.` };
123849
123925
  }
123850
123926
  function realpath4(p2) {
123851
123927
  try {
123852
- return fs46.realpathSync(p2);
123928
+ return fs47.realpathSync(p2);
123853
123929
  } catch {
123854
123930
  return null;
123855
123931
  }
123856
123932
  }
123857
- var attachmentsOf = (job) => path49.join(runnerHome(), "attachments", job.id);
123933
+ var attachmentsOf = (job) => path50.join(runnerHome(), "attachments", job.id);
123858
123934
  function writeAttachments(job) {
123859
123935
  if (!job.attachments.length) return "";
123860
123936
  const dir = attachmentsOf(job);
123861
- fs46.mkdirSync(dir, { recursive: true });
123937
+ fs47.mkdirSync(dir, { recursive: true });
123862
123938
  const files = job.attachments.map((a2) => {
123863
- const file3 = path49.join(dir, path49.basename(a2.name));
123864
- fs46.writeFileSync(file3, Buffer.from(a2.content, "base64"));
123939
+ const file3 = path50.join(dir, path50.basename(a2.name));
123940
+ fs47.writeFileSync(file3, Buffer.from(a2.content, "base64"));
123865
123941
  return file3;
123866
123942
  });
123867
123943
  return `
@@ -124160,12 +124236,12 @@ async function runJob(id, deps, track = () => {
124160
124236
  const releases = [];
124161
124237
  try {
124162
124238
  const akb = deps.akb();
124163
- releases.push(hold(path49.dirname(akb.shim)));
124239
+ releases.push(hold(path50.dirname(akb.shim)));
124164
124240
  releases.push(hold(akb.shim));
124165
124241
  await runClaimed(job, { ...deps, akb }, track, (dir) => releases.push(hold(dir)), lease);
124166
124242
  } finally {
124167
124243
  for (const release2 of releases) release2();
124168
- fs46.rmSync(attachmentsOf(job), { recursive: true, force: true });
124244
+ fs47.rmSync(attachmentsOf(job), { recursive: true, force: true });
124169
124245
  }
124170
124246
  }
124171
124247
  async function runClaimed(job, deps, track, keep2, lease, replyStream) {
@@ -124842,8 +124918,8 @@ async function runTest(job, deps, lease) {
124842
124918
  const report2 = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
124843
124919
  if (!report2?.installed) return finish2("failed", "not_installed");
124844
124920
  if (report2.loggedIn === false) return finish2("failed", "signed_out");
124845
- const cwd = path49.join(ownFolder(), "test");
124846
- fs46.mkdirSync(cwd, { recursive: true });
124921
+ const cwd = path50.join(ownFolder(), "test");
124922
+ fs47.mkdirSync(cwd, { recursive: true });
124847
124923
  const run3 = deps.plan(job.runtime, job.prompt, cwd, null, job.model, settingsOf(job));
124848
124924
  const startedAt = Date.now();
124849
124925
  if (run3.converse) {
@@ -125006,160 +125082,254 @@ function keepPresence(machineId2, pingMs = PING_MS, onJob) {
125006
125082
 
125007
125083
  // src/codex-server.ts
125008
125084
  import { spawn as spawn5 } from "node:child_process";
125009
- import fs47 from "node:fs";
125085
+ import crypto11 from "node:crypto";
125086
+ import fs48 from "node:fs";
125010
125087
  import net2 from "node:net";
125011
125088
  import path51 from "node:path";
125012
125089
  import { fileURLToPath as fileURLToPath4 } from "node:url";
125090
+ import { createInterface } from "node:readline";
125013
125091
 
125014
- // src/codex-service.ts
125015
- import path50 from "node:path";
125092
+ // src/codex-config.ts
125016
125093
  var import_smol_toml = __toESM(require_dist3(), 1);
125017
- var CODEX_PROTOCOL = 2;
125018
- var codexRecordFile = () => path50.join(runnerCwd(), "codex-service-v2.json");
125094
+ function threadConfig(argv, env2) {
125095
+ const config = {};
125096
+ for (let i = 2; i < argv.length; i++) {
125097
+ const flag = argv[i];
125098
+ if (flag === "--enable" || flag === "--disable") {
125099
+ config[`features.${argv[++i]}`] = flag === "--enable";
125100
+ continue;
125101
+ }
125102
+ if (flag !== "-c" && flag !== "--config") throw Error("Unsupported shared Codex option.");
125103
+ const pair = argv[++i] ?? "";
125104
+ const at2 = pair.indexOf("=");
125105
+ if (at2 < 1) throw Error("Invalid Codex configuration override.");
125106
+ const key = pair.slice(0, at2), value = pair.slice(at2 + 1).trim();
125107
+ try {
125108
+ config[key] = (0, import_smol_toml.parse)(`value = ${value}`).value;
125109
+ } catch {
125110
+ config[key] = value;
125111
+ }
125112
+ }
125113
+ const local = Object.fromEntries(Object.entries(env2).filter(([key, value]) => value !== void 0 && key !== "OPENAI_API_KEY" && key !== "WILDCRANE_FLOW_WORKER" && (process.env[key] !== value || /^(KANBAN_|AI4KANBAN_|WILDCRANE_|PATH$)/.test(key))));
125114
+ config["shell_environment_policy.set"] = { ...obj2(config["shell_environment_policy.set"]), ...local };
125115
+ return config;
125116
+ }
125117
+ function providerCredentials(config, env2) {
125118
+ const credentials = {};
125119
+ for (const [key, value] of Object.entries(config)) if (/^model_providers\..+\.env_key$/.test(key) && typeof value === "string") {
125120
+ if (!env2[value]) throw Error("The Codex provider credential is missing.");
125121
+ credentials[value] = env2[value];
125122
+ }
125123
+ return credentials;
125124
+ }
125125
+ function tomlValue(value) {
125126
+ if (Array.isArray(value)) return `[${value.map(tomlValue).join(",")}]`;
125127
+ if (value && typeof value === "object") return `{${Object.entries(value).map(([key, v]) => `${JSON.stringify(key)}=${tomlValue(v)}`).join(",")}}`;
125128
+ return JSON.stringify(value);
125129
+ }
125019
125130
 
125020
125131
  // src/codex-server.ts
125021
125132
  var entryOf3 = (name) => process.env.RUNNER_DIST ? path51.join(process.env.RUNNER_DIST, name) : fileURLToPath4(new URL(name, import.meta.url));
125022
- var wait3 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
125023
- function readRecord2() {
125024
- try {
125025
- const record = JSON.parse(fs47.readFileSync(codexRecordFile(), "utf8"));
125026
- if (!record.path || !record.token || !record.instance || !Number.isSafeInteger(record.pid) || record.pid <= 0 || !Array.isArray(record.backends)) throw Error("Invalid Codex service record.");
125027
- if (record.protocol !== CODEX_PROTOCOL) throw Error("Codex service protocol is incompatible; existing work was preserved.");
125028
- return record;
125029
- } catch (error) {
125030
- if (error.code === "ENOENT") return void 0;
125031
- throw error;
125032
- }
125033
- }
125034
- function attach(record) {
125035
- return new Promise((resolve2, reject) => {
125036
- const socket = net2.connect(record.path);
125037
- const timer = setTimeout(() => fail(Error("Codex service did not answer; existing work was preserved.")), 2e3);
125038
- const fail = (error) => {
125039
- clearTimeout(timer);
125040
- socket.destroy();
125041
- reject(error);
125042
- };
125043
- let buffer = "";
125044
- socket.once("error", fail);
125045
- socket.once("connect", () => socket.write(JSON.stringify({ token: record.token, control: true, protocol: CODEX_PROTOCOL, generation: accountGeneration() }) + "\n"));
125046
- socket.on("data", function hello(chunk) {
125047
- buffer += chunk;
125048
- if (!buffer.includes("\n")) return;
125049
- try {
125050
- const answer = JSON.parse(buffer.split("\n")[0]);
125051
- if (answer.instance !== record.instance || answer.pid !== record.pid || answer.protocol !== CODEX_PROTOCOL || answer.generation !== accountGeneration()) throw Error("Codex service identity changed; existing work was preserved.");
125052
- clearTimeout(timer);
125053
- socket.removeListener("data", hello);
125054
- socket.removeListener("error", fail);
125055
- socket.on("error", () => {
125133
+ var delay = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
125134
+ async function codexServer() {
125135
+ fs48.mkdirSync(nativeDirectory(), { recursive: true, mode: 448 });
125136
+ const generation = accountGeneration();
125137
+ const token = crypto11.randomBytes(32).toString("hex");
125138
+ const instance = crypto11.randomUUID();
125139
+ const address = process.platform === "win32" ? `\\\\.\\pipe\\wc-codex-runner-${instance}` : nativeEndpoint(`runner-${instance}`).slice(7);
125140
+ const record = { path: address, token, pid: process.pid, instance, protocol: CODEX_PROTOCOL, generation };
125141
+ const pending = /* @__PURE__ */ new Map();
125142
+ const sockets = /* @__PURE__ */ new Set();
125143
+ const idle2 = /* @__PURE__ */ new Map();
125144
+ let closed = false;
125145
+ const ensure = async (argv, environment) => {
125146
+ const config = threadConfig(argv, environment);
125147
+ const provider = Object.fromEntries(Object.entries(config).filter(([key2]) => key2 === "model_provider" || key2.startsWith("model_providers.")));
125148
+ const credentials = providerCredentials(provider, environment);
125149
+ const key = crypto11.createHash("sha256").update(JSON.stringify([argv[0], environment.CODEX_HOME ?? "", Object.entries(provider).sort(), credentials])).digest("hex");
125150
+ if (pending.has(key)) return pending.get(key);
125151
+ const work = (async () => {
125152
+ const previous = readPrivate(backendFile(key));
125153
+ if (previous && previous.generation === generation && liveBackend(previous)) {
125154
+ const probe2 = await nativeConnection(previous, () => {
125056
125155
  });
125057
- resolve2(socket);
125058
- } catch (error) {
125059
- fail(error);
125060
- }
125061
- });
125062
- socket.once("end", () => fail(Error("Codex service refused this Runner.")));
125063
- });
125064
- }
125065
- async function openService() {
125066
- const until = Date.now() + 1e4;
125067
- let socket;
125068
- for (; ; ) {
125069
- const release2 = tryLock(path51.join(runnerCwd(), "codex-service-v2.start.lock"));
125070
- if (!release2) {
125071
- if (Date.now() >= until) throw Error("Codex service startup is busy.");
125072
- await wait3(50);
125073
- continue;
125074
- }
125075
- try {
125076
- let record = readRecord2();
125077
- if (record) {
125078
- try {
125079
- socket = await attach(record);
125080
- } catch (error) {
125081
- if (pidAlive(record.pid)) throw error;
125082
- fs47.rmSync(codexRecordFile(), { force: true });
125083
- }
125084
- }
125085
- if (!socket) {
125086
- const entry = entryOf3("codex-service-main.mjs");
125087
- const env2 = { ...process.env };
125088
- for (const key of Object.keys(env2)) if (/^(KANBAN_|AI4KANBAN_EXECUTION|WILDCRANE_FLOW_WORKER|WILDCRANE_CODEX_(SERVER|PROXY)|WILDCRANE_JOB)/.test(key)) delete env2[key];
125089
- const log = fs47.openSync(path51.join(runnerCwd(), "codex-service.log"), "a", 384);
125090
- let child;
125091
125156
  try {
125092
- child = spawn5(process.execPath, [entry], { cwd: runnerCwd(), env: env2, detached: true, stdio: ["ignore", log, log], windowsHide: true });
125157
+ await initializeNative(probe2);
125093
125158
  } finally {
125094
- fs47.closeSync(log);
125159
+ probe2.close();
125095
125160
  }
125096
- let failure2;
125097
- child.on("error", (error) => {
125098
- failure2 = error;
125161
+ return previous;
125162
+ }
125163
+ if (previous && liveBackend(previous)) throw Error("Codex backend belongs to an expired account session; stop it before reconnecting.");
125164
+ const backend = { ...processIdentity(), key, instance: crypto11.randomUUID(), generation, endpoint: nativeEndpoint(key) };
125165
+ const extra = [];
125166
+ if (process.platform === "win32") {
125167
+ const reservation = net2.createServer();
125168
+ await new Promise((resolve2, reject) => {
125169
+ reservation.once("error", reject);
125170
+ reservation.listen(0, "127.0.0.1", resolve2);
125099
125171
  });
125100
- child.unref();
125172
+ const port = reservation.address().port;
125173
+ await new Promise((resolve2) => reservation.close(() => resolve2()));
125174
+ backend.endpoint = `ws://127.0.0.1:${port}`;
125175
+ backend.token = crypto11.randomBytes(32).toString("hex");
125176
+ const file3 = path51.join(nativeDirectory(), `${key}.token`);
125177
+ fs48.writeFileSync(file3, backend.token, { mode: 384 });
125178
+ extra.push("--ws-auth", "capability-token", "--ws-token-file", file3);
125179
+ }
125180
+ const env2 = { ...process.env, CODEX_HOME: environment.CODEX_HOME ?? process.env.CODEX_HOME, OPENAI_API_KEY: void 0, WILDCRANE_JOB: "1" };
125181
+ for (const name of Object.keys(env2)) if (/^(KANBAN_|AI4KANBAN_EXECUTION|WILDCRANE_FLOW_WORKER|WILDCRANE_CODEX_)/.test(name)) delete env2[name];
125182
+ Object.assign(env2, credentials);
125183
+ const log = fs48.openSync(path51.join(nativeDirectory(), `${key}.log`), "a", 384);
125184
+ const start = spawnable(argv[0], ["app-server", "--listen", backend.endpoint, ...extra, "-c", "thread_unload_delay_secs=0", ...Object.entries(provider).flatMap(([name, value]) => ["-c", `${name}=${tomlValue(value)}`])], { cwd: runnerCwd(), env: markEnv(env2, stopMark()), detached: process.platform !== "win32", stdio: ["ignore", log, log] });
125185
+ const child = spawn5(start.command, start.args, start.options);
125186
+ fs48.closeSync(log);
125187
+ let failure2;
125188
+ child.on("error", (error) => {
125189
+ failure2 = error;
125190
+ });
125191
+ child.unref();
125192
+ backend.pid = child.pid;
125193
+ const until = Date.now() + CODEX_TIMEOUT;
125194
+ try {
125101
125195
  for (; ; ) {
125102
125196
  if (failure2) throw failure2;
125103
- record = readRecord2();
125104
- if (record) {
125105
- socket = await attach(record);
125197
+ if (child.exitCode !== null || child.signalCode !== null || Date.now() >= until) throw Error("Codex did not start its native listener. Update Codex to a version supporting persistent local App Server connections.");
125198
+ if (backend.endpoint.startsWith("unix://") && !fs48.existsSync(backend.endpoint.slice(7))) {
125199
+ await delay(25);
125200
+ continue;
125201
+ }
125202
+ try {
125203
+ const probe2 = await nativeConnection(backend, () => {
125204
+ });
125205
+ try {
125206
+ await initializeNative(probe2);
125207
+ } finally {
125208
+ probe2.close();
125209
+ }
125106
125210
  break;
125211
+ } catch (error) {
125212
+ if (Date.now() >= until) throw error;
125213
+ await delay(50);
125107
125214
  }
125108
- if (child.exitCode !== null || Date.now() >= until) throw Error("Codex service failed to start; inspect codex-service.log.");
125109
- await wait3(50);
125110
125215
  }
125216
+ backend.identity = connectionIdentity(child.pid);
125217
+ if (!backend.identity) throw Error("Codex native process identity could not be confirmed.");
125218
+ writePrivate(backendFile(key), backend);
125219
+ return backend;
125220
+ } catch (error) {
125221
+ child.kill("SIGKILL");
125222
+ throw error;
125111
125223
  }
125112
- return socket;
125224
+ })();
125225
+ pending.set(key, work);
125226
+ try {
125227
+ return await work;
125113
125228
  } finally {
125114
- release2();
125229
+ pending.delete(key);
125115
125230
  }
125116
- }
125117
- }
125118
- async function codexServer() {
125119
- const generation = accountGeneration();
125120
- let socket = await openService();
125121
- let closed = false;
125122
- let recovering;
125123
- const watch = () => socket.once("close", () => {
125124
- if (closed || generation !== accountGeneration()) return;
125125
- recovering = (async () => {
125126
- for (let attempt = 0; attempt < 3 && !closed && generation === accountGeneration(); attempt++) {
125231
+ };
125232
+ const server = net2.createServer((socket) => {
125233
+ sockets.add(socket);
125234
+ socket.on("error", () => {
125235
+ });
125236
+ const timer2 = setTimeout(() => socket.destroy(), CODEX_TIMEOUT);
125237
+ const lines = createInterface({ input: socket });
125238
+ let accepted = false;
125239
+ lines.on("line", (line) => {
125240
+ if (accepted) return;
125241
+ accepted = true;
125242
+ void (async () => {
125127
125243
  try {
125128
- await wait3(250 * (attempt + 1));
125129
- if (closed || generation !== accountGeneration()) return;
125130
- const next = await openService();
125131
- if (closed || generation !== accountGeneration()) {
125132
- next.destroy();
125133
- return;
125244
+ const request2 = JSON.parse(line);
125245
+ if (closed || request2.token !== token || request2.protocol !== CODEX_PROTOCOL || request2.generation !== generation || accountGeneration() !== generation) throw Error("Codex Runner ownership expired.");
125246
+ if (!Array.isArray(request2.argv) || typeof request2.argv[0] !== "string") throw Error("Invalid Codex backend request.");
125247
+ const environment = obj2(request2.env);
125248
+ const config = threadConfig(request2.argv, environment);
125249
+ socket.end(JSON.stringify({ backend: await ensure(request2.argv, environment), config }) + "\n");
125250
+ } catch (error) {
125251
+ socket.end(JSON.stringify({ error: error instanceof Error ? error.message : String(error) }) + "\n");
125252
+ } finally {
125253
+ clearTimeout(timer2);
125254
+ }
125255
+ })();
125256
+ });
125257
+ socket.once("close", () => {
125258
+ clearTimeout(timer2);
125259
+ sockets.delete(socket);
125260
+ });
125261
+ });
125262
+ await new Promise((resolve2, reject) => {
125263
+ server.once("error", reject);
125264
+ server.listen(address, resolve2);
125265
+ });
125266
+ if (process.platform !== "win32") fs48.chmodSync(address, 384);
125267
+ writePrivate(codexRecordFile(), record);
125268
+ const sweep = async () => {
125269
+ if (closed) return;
125270
+ retireLegacy(generation);
125271
+ for (const name of fs48.readdirSync(nativeDirectory()).filter((value) => /^[a-f0-9]{64}\.json$/.test(value))) {
125272
+ const backend = readPrivate(path51.join(nativeDirectory(), name));
125273
+ let used = false;
125274
+ const leases = path51.join(nativeDirectory(), "threads", backend.instance);
125275
+ try {
125276
+ used = fs48.readdirSync(leases).filter((file3) => file3.endsWith(".json")).some((file3) => !!readPrivate(path51.join(leases, file3)));
125277
+ } catch {
125278
+ }
125279
+ if (used || pending.has(backend.key)) idle2.delete(backend.key);
125280
+ else {
125281
+ const since = idle2.get(backend.key) ?? Date.now();
125282
+ idle2.set(backend.key, since);
125283
+ if (Date.now() - since > (Number(process.env.WILDCRANE_CODEX_IDLE_MS) || 3e4) && liveBackend(backend)) {
125284
+ try {
125285
+ process.kill(backend.pid, "SIGTERM");
125286
+ } catch {
125134
125287
  }
125135
- socket = next;
125136
- watch();
125137
- return;
125138
- } catch {
125139
125288
  }
125140
125289
  }
125141
- if (!closed && generation === accountGeneration()) console.error("runner: Codex service recovery failed; existing task progress was preserved.");
125142
- })();
125143
- });
125144
- watch();
125290
+ }
125291
+ };
125292
+ const timer = setInterval(() => void sweep().catch((error) => console.error(`runner: Codex cleanup: ${String(error)}`)), 1e3);
125293
+ timer.unref();
125294
+ void sweep();
125295
+ const close = async () => {
125296
+ if (closed) return;
125297
+ closed = true;
125298
+ clearInterval(timer);
125299
+ server.close();
125300
+ for (const socket of sockets) socket.destroy();
125301
+ await Promise.allSettled(pending.values());
125302
+ if (readPrivate(codexRecordFile())?.instance === instance) fs48.rmSync(codexRecordFile(), { force: true });
125303
+ if (process.platform !== "win32") fs48.rmSync(address, { force: true });
125304
+ if (generation !== accountGeneration()) stopNativeBackends();
125305
+ };
125145
125306
  return {
125146
125307
  env: { WILDCRANE_CODEX_SERVER: codexRecordFile(), WILDCRANE_CODEX_GENERATION: generation, WILDCRANE_CODEX_PROXY: entryOf3("codex-proxy.mjs") },
125147
- async close() {
125148
- closed = true;
125149
- socket.destroy();
125150
- await recovering;
125151
- },
125308
+ close,
125152
125309
  async shutdown() {
125153
- closed = true;
125154
- socket.write(JSON.stringify({ method: "shutdown" }) + "\n");
125310
+ stopNativeBackends();
125311
+ await close();
125155
125312
  }
125156
125313
  };
125157
125314
  }
125315
+ function retireLegacy(generation) {
125316
+ const legacy = readPrivate(path51.join(runnerCwd(), "codex-service-v2.json"));
125317
+ if (!legacy || legacy.generation !== generation) return;
125318
+ const socket = net2.connect(legacy.path);
125319
+ socket.on("error", () => socket.destroy());
125320
+ socket.once("connect", () => socket.write(JSON.stringify({ token: legacy.token, protocol: 2, generation, control: true }) + "\n"));
125321
+ socket.once("data", () => {
125322
+ socket.end(JSON.stringify({ method: "shutdown" }) + "\n");
125323
+ });
125324
+ const timer = setTimeout(() => socket.destroy(), 1e3);
125325
+ timer.unref();
125326
+ socket.once("close", () => clearTimeout(timer));
125327
+ }
125158
125328
 
125159
125329
  // src/flow-worker.ts
125160
125330
  import { spawn as spawn6 } from "node:child_process";
125161
- import crypto10 from "node:crypto";
125162
- import fs48 from "node:fs";
125331
+ import crypto12 from "node:crypto";
125332
+ import fs49 from "node:fs";
125163
125333
  import path52 from "node:path";
125164
125334
  import { fileURLToPath as fileURLToPath5 } from "node:url";
125165
125335
  var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
@@ -125170,21 +125340,21 @@ var flowWorkerEntry = fileURLToPath5(new URL("./flow-worker-main.mjs", import.me
125170
125340
  var canKeepFlow = (job) => !!job.task && !!job.flow && ["create", "refine", "implement", "preview"].includes(job.flow.verb) && !job.agent && !job.review && !job.discussion && !job.test && !job.secret;
125171
125341
  function read3(id) {
125172
125342
  try {
125173
- return JSON.parse(fs48.readFileSync(fileOf2(id), "utf8"));
125343
+ return JSON.parse(fs49.readFileSync(fileOf2(id), "utf8"));
125174
125344
  } catch {
125175
125345
  return null;
125176
125346
  }
125177
125347
  }
125178
125348
  function hasFlowWorker(id) {
125179
- return fs48.existsSync(fileOf2(id));
125349
+ return fs49.existsSync(fileOf2(id));
125180
125350
  }
125181
125351
  function launchFlowWorker(id, machine, entry = flowWorkerEntry) {
125182
- fs48.mkdirSync(directory2(), { recursive: true, mode: 448 });
125352
+ fs49.mkdirSync(directory2(), { recursive: true, mode: 448 });
125183
125353
  const account = readSession()?.subject;
125184
125354
  if (!account) throw new Error("\u8D26\u53F7\u5DF2\u9000\u51FA\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002");
125185
- const worker = { id, token: crypto10.randomUUID(), machine, account, generation: accountGeneration(), at: Date.now(), markedAt: Date.now() };
125186
- fs48.writeFileSync(fileOf2(id), JSON.stringify(worker), { flag: "wx", mode: 384 });
125187
- const log = fs48.openSync(`${fileOf2(id)}.log`, "a", 384);
125355
+ const worker = { id, token: crypto12.randomUUID(), machine, account, generation: accountGeneration(), at: Date.now(), markedAt: Date.now() };
125356
+ fs49.writeFileSync(fileOf2(id), JSON.stringify(worker), { flag: "wx", mode: 384 });
125357
+ const log = fs49.openSync(`${fileOf2(id)}.log`, "a", 384);
125188
125358
  try {
125189
125359
  const child = spawn6(process.execPath, [entry, id, worker.token], {
125190
125360
  cwd: runnerCwd(),
@@ -125200,7 +125370,7 @@ function launchFlowWorker(id, machine, entry = flowWorkerEntry) {
125200
125370
  });
125201
125371
  child.unref();
125202
125372
  } finally {
125203
- fs48.closeSync(log);
125373
+ fs49.closeSync(log);
125204
125374
  }
125205
125375
  }
125206
125376
  async function watchFlowWorker(id, machine, detached) {
@@ -125227,7 +125397,7 @@ async function stopFlowWorker(id, ms) {
125227
125397
  try {
125228
125398
  const worker = read3(id);
125229
125399
  if (!worker || worker.ended) return;
125230
- fs48.writeFileSync(stopFile(id), worker.token, { mode: 384 });
125400
+ fs49.writeFileSync(stopFile(id), worker.token, { mode: 384 });
125231
125401
  } finally {
125232
125402
  release2();
125233
125403
  }
@@ -125298,7 +125468,7 @@ async function reclaimFlowWorkers(machine, given, only) {
125298
125468
  const sweep = async () => {
125299
125469
  let names2;
125300
125470
  try {
125301
- names2 = only ? [`${encodeURIComponent(only)}.json`] : fs48.readdirSync(directory2());
125471
+ names2 = only ? [`${encodeURIComponent(only)}.json`] : fs49.readdirSync(directory2());
125302
125472
  } catch {
125303
125473
  return;
125304
125474
  }
@@ -125307,7 +125477,7 @@ async function reclaimFlowWorkers(machine, given, only) {
125307
125477
  if (!name.endsWith(".json")) continue;
125308
125478
  try {
125309
125479
  const file3 = path52.join(directory2(), name);
125310
- const original = fs48.readFileSync(file3, "utf8");
125480
+ const original = fs49.readFileSync(file3, "utf8");
125311
125481
  const worker = JSON.parse(original);
125312
125482
  if (!worker || typeof worker.id !== "string" || name !== `${encodeURIComponent(worker.id)}.json` || typeof worker.token !== "string" || !worker.token || worker.machine !== machine || worker.account !== account || typeof worker.generation !== "string" || !Number.isFinite(worker.at)) continue;
125313
125483
  if (!writerStopped(worker)) {
@@ -125324,7 +125494,7 @@ async function reclaimFlowWorkers(machine, given, only) {
125324
125494
  const folder = job.projectDir ? folderFor(job) : { cwd: path52.join(runnerHome(), "work", job.id) };
125325
125495
  if ("refused" in folder || !job.task || !job.project) continue;
125326
125496
  const board = path52.join(folder.cwd, ".akb", "kanban");
125327
- if (!fs48.existsSync(board)) continue;
125497
+ if (!fs49.existsSync(board)) continue;
125328
125498
  const deps = given ?? defaultDeps(machine);
125329
125499
  if (!await confirmFlowStopped(
125330
125500
  {
@@ -125345,10 +125515,10 @@ async function reclaimFlowWorkers(machine, given, only) {
125345
125515
  const release2 = tryLock(`${file3}.lock`);
125346
125516
  if (!release2) continue;
125347
125517
  try {
125348
- if (!writerStopped(worker) || !valid() || fs48.readFileSync(file3, "utf8") !== original) continue;
125349
- fs48.rmSync(`${file3}.log`, { force: true });
125350
- fs48.rmSync(`${file3}.stop`, { force: true });
125351
- fs48.unlinkSync(file3);
125518
+ if (!writerStopped(worker) || !valid() || fs49.readFileSync(file3, "utf8") !== original) continue;
125519
+ fs49.rmSync(`${file3}.log`, { force: true });
125520
+ fs49.rmSync(`${file3}.stop`, { force: true });
125521
+ fs49.unlinkSync(file3);
125352
125522
  } finally {
125353
125523
  release2();
125354
125524
  }
@@ -125748,7 +125918,7 @@ function startRunner(options) {
125748
125918
  let refresh2 = "";
125749
125919
  const accountWatch = setInterval(() => {
125750
125920
  try {
125751
- const value = fs49.readFileSync(path53.join(runnerHome(), "settings-refresh"), "utf8");
125921
+ const value = fs50.readFileSync(path53.join(runnerHome(), "settings-refresh"), "utf8");
125752
125922
  if (value !== refresh2) {
125753
125923
  refresh2 = value;
125754
125924
  redetect = true;
@@ -125785,7 +125955,7 @@ function startRunner(options) {
125785
125955
 
125786
125956
  // src/signin.ts
125787
125957
  import { spawn as spawn7 } from "node:child_process";
125788
- import crypto11 from "node:crypto";
125958
+ import crypto13 from "node:crypto";
125789
125959
  import http3 from "node:http";
125790
125960
  var WAIT_MS = 10 * 60 * 1e3;
125791
125961
  var CRANE = "M2 55.75C2 55.69 2.69 55.09 3.55 54.37L5.09 53.1L6.61 53.1L8.13 53.1L12.49 49.87C14.9 48.07 16.83 46.58 16.77 46.53C16.75 46.47 15.56 46.64 14.15 46.89C12.74 47.13 11.55 47.3 11.53 47.24C11.47 47.19 12.02 46.22 12.71 45.06L14.01 42.96L18.21 41.34C20.53 40.45 22.41 39.65 22.41 39.57C22.41 39.49 21.27 38.55 19.92 37.5C15.92 34.4 13.13 31.31 10.86 27.47L10.01 26.01L10.53 26.18C10.84 26.26 12.96 27.2 15.28 28.25C17.6 29.32 19.53 30.12 19.59 30.07C19.64 30.01 17.68 28.69 15.25 27.11C12.8 25.57 10.56 23.97 10.31 23.58C9.15 21.95 7.25 17.5 7.25 16.46C7.25 16.26 10.01 17.95 13.38 20.18C16.77 22.45 19.73 24.38 19.95 24.49C20.42 24.74 20.25 24.57 13.9 19.02L9.18 14.88L8.6 13.36C7.72 10.96 6.97 7.54 6.97 5.77L6.97 4.14L9.4 6.46C12.66 9.61 15.56 12.01 23.57 18.25C27.32 21.18 30.5 23.72 30.64 23.91C30.8 24.08 31.68 26.51 32.6 29.3L34.28 34.35L35.72 35.65C37.54 37.3 37.98 37.47 36.85 36.09L35.96 35.01L37.12 34.71C39.11 34.21 40.16 33.52 42.54 31.12L44.8 28.8L46.02 28.96C46.71 29.07 47.56 29.07 47.95 28.96L48.67 28.8L48.67 28.25L48.67 27.69L49.27 27.69C49.63 27.69 50.1 27.58 50.32 27.42L50.71 27.17L51.01 27.42C51.18 27.56 52.78 27.86 54.58 28.08C56.37 28.3 57.86 28.52 57.94 28.58C58 28.63 56.73 28.85 55.13 29.05C53.53 29.24 50.96 29.77 49.44 30.21C47.92 30.65 46.57 31.01 46.43 31.01C46.29 31.01 44.22 32.97 41.85 35.37C37.57 39.62 34.42 42.14 30.83 44.15L29.14 45.09L25.97 45.73L22.77 46.39L14.59 51.11L6.42 55.86L4.21 55.86C2.99 55.86 2 55.8 2 55.75Z";
@@ -125858,8 +126028,8 @@ var PAGE = (outcome, lang, links) => {
125858
126028
  };
125859
126029
  async function signIn(options = {}) {
125860
126030
  const generation = accountGeneration();
125861
- const verifier = base64url(crypto11.randomBytes(32));
125862
- const challenge = base64url(crypto11.createHash("sha256").update(verifier).digest());
126031
+ const verifier = base64url(crypto13.randomBytes(32));
126032
+ const challenge = base64url(crypto13.createHash("sha256").update(verifier).digest());
125863
126033
  let finish2 = () => {
125864
126034
  };
125865
126035
  const answered = new Promise((resolve2) => finish2 = resolve2);
@@ -125994,18 +126164,18 @@ function openBrowser(url) {
125994
126164
  var base64url = (bytes2) => bytes2.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
125995
126165
 
125996
126166
  // src/settings.ts
125997
- import crypto13 from "node:crypto";
125998
- import fs51 from "node:fs";
126167
+ import crypto15 from "node:crypto";
126168
+ import fs52 from "node:fs";
125999
126169
  import path55 from "node:path";
126000
126170
 
126001
126171
  // src/preferences.ts
126002
- import crypto12 from "node:crypto";
126003
- import fs50 from "node:fs";
126172
+ import crypto14 from "node:crypto";
126173
+ import fs51 from "node:fs";
126004
126174
  import path54 from "node:path";
126005
126175
  var file2 = () => path54.join(runnerHome(), "preferences.json");
126006
126176
  function read4() {
126007
126177
  try {
126008
- const value = JSON.parse(fs50.readFileSync(file2(), "utf8"));
126178
+ const value = JSON.parse(fs51.readFileSync(file2(), "utf8"));
126009
126179
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
126010
126180
  } catch {
126011
126181
  return {};
@@ -126013,13 +126183,13 @@ function read4() {
126013
126183
  }
126014
126184
  var acceptAlphaUpdates = () => read4().acceptAlphaUpdates === true;
126015
126185
  function saveAlphaUpdates(value) {
126016
- const target = file2(), temporary = `${target}.${crypto12.randomUUID()}.tmp`;
126017
- fs50.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126186
+ const target = file2(), temporary = `${target}.${crypto14.randomUUID()}.tmp`;
126187
+ fs51.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126018
126188
  try {
126019
- fs50.writeFileSync(temporary, JSON.stringify({ ...read4(), acceptAlphaUpdates: value }) + "\n", { mode: 384 });
126020
- fs50.renameSync(temporary, target);
126189
+ fs51.writeFileSync(temporary, JSON.stringify({ ...read4(), acceptAlphaUpdates: value }) + "\n", { mode: 384 });
126190
+ fs51.renameSync(temporary, target);
126021
126191
  } finally {
126022
- fs50.rmSync(temporary, { force: true });
126192
+ fs51.rmSync(temporary, { force: true });
126023
126193
  }
126024
126194
  }
126025
126195
 
@@ -126058,8 +126228,8 @@ var stopping = false;
126058
126228
  var callback = () => {
126059
126229
  };
126060
126230
  var notify = () => {
126061
- fs51.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126062
- fs51.writeFileSync(path55.join(runnerHome(), "settings-refresh"), crypto13.randomUUID(), { mode: 384 });
126231
+ fs52.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126232
+ fs52.writeFileSync(path55.join(runnerHome(), "settings-refresh"), crypto15.randomUUID(), { mode: 384 });
126063
126233
  callback();
126064
126234
  };
126065
126235
  function startSignIn() {
@@ -126098,7 +126268,7 @@ async function folderOf(cwd) {
126098
126268
  if (!list3.ok) return { ...failure(list3), folders: [], folder: null };
126099
126269
  const real = (dir) => {
126100
126270
  try {
126101
- return fs51.realpathSync(dir);
126271
+ return fs52.realpathSync(dir);
126102
126272
  } catch {
126103
126273
  return dir;
126104
126274
  }
@@ -126111,7 +126281,7 @@ async function addFolder2(dir, bind, strict = false) {
126111
126281
  const subject = readSession().subject;
126112
126282
  const why2 = refusal2(dir);
126113
126283
  if (why2) return { error: why2 };
126114
- const real = fs51.realpathSync(dir);
126284
+ const real = fs52.realpathSync(dir);
126115
126285
  const found = await folderOf(real);
126116
126286
  if ("error" in found) return found;
126117
126287
  let project = found.folder?.project;
@@ -126203,7 +126373,7 @@ async function settingsState(context) {
126203
126373
  account,
126204
126374
  connected: runner.ok && runner.value.runner?.connected,
126205
126375
  workspaces: workspaces.value,
126206
- projects: folders2.value.folders.map((f2) => ({ ...f2, ...metadata(f2.project), busy: kept2(f2.path), missing: !fs51.existsSync(f2.path) })),
126376
+ projects: folders2.value.folders.map((f2) => ({ ...f2, ...metadata(f2.project), busy: kept2(f2.path), missing: !fs52.existsSync(f2.path) })),
126207
126377
  elsewhere: projects.filter((p2) => !p2.general && !folders2.value.folders.some((f2) => f2.project === p2.id)).map((p2) => ({ project: p2.id, name: p2.name, ...metadata(p2.id) })),
126208
126378
  ...context.project && !projects.some((p2) => p2.id === context.project) ? { error: "not_found" } : {}
126209
126379
  };
@@ -126235,7 +126405,7 @@ async function settingsAction(action, body, context) {
126235
126405
  if (!dir) return { cancelled: true };
126236
126406
  const why2 = refusal2(dir);
126237
126407
  if (why2) return { error: why2 };
126238
- const real = fs51.realpathSync(dir);
126408
+ const real = fs52.realpathSync(dir);
126239
126409
  selected.set(context, { path: real, subject: readSession().subject });
126240
126410
  return { path: real, name: path55.basename(real) };
126241
126411
  } catch {
@@ -126264,7 +126434,7 @@ async function settingsAction(action, body, context) {
126264
126434
  if ("error" in found) return found;
126265
126435
  if (found.folder) return { error: "folder_taken" };
126266
126436
  if (choice.subject !== readSession()?.subject) return { error: "signed_out" };
126267
- if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key: crypto13.randomUUID(), name, workspace: body.workspace };
126437
+ if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key: crypto15.randomUUID(), name, workspace: body.workspace };
126268
126438
  const created = choice.creation.project ? { ok: true, value: { id: choice.creation.project } } : await createProject(name, body.workspace, choice.creation.key);
126269
126439
  if (!created.ok) return failure(created);
126270
126440
  project = created.value.id;
@@ -126281,26 +126451,26 @@ async function settingsAction(action, body, context) {
126281
126451
 
126282
126452
  // src/settings-server.ts
126283
126453
  import { spawn as spawn9 } from "node:child_process";
126284
- import crypto14 from "node:crypto";
126285
- import fs53 from "node:fs";
126454
+ import crypto16 from "node:crypto";
126455
+ import fs54 from "node:fs";
126286
126456
  import http4 from "node:http";
126287
126457
  import path57 from "node:path";
126288
126458
 
126289
126459
  // src/launcher.ts
126290
- import fs52 from "node:fs";
126460
+ import fs53 from "node:fs";
126291
126461
  import path56 from "node:path";
126292
126462
  var CONNECT_MS = 2 * 6e4;
126293
126463
  var stateFile2 = () => path56.join(versionsDir(), "state.json");
126294
126464
  function readState() {
126295
126465
  try {
126296
- const held5 = JSON.parse(fs52.readFileSync(stateFile2(), "utf8"));
126466
+ const held5 = JSON.parse(fs53.readFileSync(stateFile2(), "utf8"));
126297
126467
  return { ...held5, good: held5.good ?? [], bad: held5.bad ?? [] };
126298
126468
  } catch {
126299
126469
  return { good: [], bad: [] };
126300
126470
  }
126301
126471
  }
126302
126472
  function provenNewer(own2) {
126303
- const proven = readState().good.find((v) => fs52.existsSync(entryOf(versionDir(v))));
126473
+ const proven = readState().good.find((v) => fs53.existsSync(entryOf(versionDir(v))));
126304
126474
  return proven && compare(proven, own2) > 0 ? proven : null;
126305
126475
  }
126306
126476
 
@@ -126314,7 +126484,7 @@ var settings_client_default = '"use strict";(()=>{var j6=Object.create;var Ff=Ob
126314
126484
  var recordFile2 = () => path57.join(runnerHome(), "settings-page.json");
126315
126485
  var sessionsFile = () => path57.join(runnerHome(), "settings-sessions.json");
126316
126486
  var sleep2 = (ms) => new Promise((r2) => setTimeout(r2, ms));
126317
- var random = () => crypto14.randomBytes(32).toString("hex");
126487
+ var random = () => crypto16.randomBytes(32).toString("hex");
126318
126488
  var PAGE_VERSION = process.env.WILDCRANE_SETTINGS_VERSION ?? VERSION;
126319
126489
  var own = null;
126320
126490
  var helper = null;
@@ -126332,14 +126502,14 @@ async function control(record, action, body = {}) {
126332
126502
  }
126333
126503
  function discover() {
126334
126504
  try {
126335
- return JSON.parse(fs53.readFileSync(recordFile2(), "utf8"));
126505
+ return JSON.parse(fs54.readFileSync(recordFile2(), "utf8"));
126336
126506
  } catch {
126337
126507
  return null;
126338
126508
  }
126339
126509
  }
126340
126510
  async function openSettings(action, context = {}, open = true) {
126341
126511
  if (process.env.WILDCRANE_JOB) throw new Error("nested_session");
126342
- fs53.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126512
+ fs54.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
126343
126513
  const lock = `${recordFile2()}.lock`;
126344
126514
  for (let attempt = 0; attempt < 100; attempt++) {
126345
126515
  const held5 = discover();
@@ -126355,16 +126525,16 @@ async function openSettings(action, context = {}, open = true) {
126355
126525
  }
126356
126526
  if (attempt === 0 && await startNewer(action)) continue;
126357
126527
  try {
126358
- const fd = fs53.openSync(lock, "wx", 384);
126359
- fs53.writeFileSync(fd, String(process.pid));
126360
- fs53.closeSync(fd);
126528
+ const fd = fs54.openSync(lock, "wx", 384);
126529
+ fs54.writeFileSync(fd, String(process.pid));
126530
+ fs54.closeSync(fd);
126361
126531
  } catch {
126362
126532
  try {
126363
- const pid = Number(fs53.readFileSync(lock, "utf8"));
126533
+ const pid = Number(fs54.readFileSync(lock, "utf8"));
126364
126534
  try {
126365
126535
  process.kill(pid, 0);
126366
126536
  } catch {
126367
- fs53.rmSync(lock, { force: true });
126537
+ fs54.rmSync(lock, { force: true });
126368
126538
  }
126369
126539
  } catch {
126370
126540
  }
@@ -126382,14 +126552,14 @@ async function openSettings(action, context = {}, open = true) {
126382
126552
  own = await startSettingsServer(action, Number(process.env.WILDCRANE_SETTINGS_PORT) || 0);
126383
126553
  follow({ version: PAGE_VERSION, port: own.port, action });
126384
126554
  } finally {
126385
- fs53.rmSync(lock, { force: true });
126555
+ fs54.rmSync(lock, { force: true });
126386
126556
  }
126387
126557
  }
126388
126558
  throw new Error("settings_unavailable");
126389
126559
  }
126390
126560
  var newerPage = () => {
126391
126561
  const version = process.env.WILDCRANE_SETTINGS_CHILD ? null : provenNewer(VERSION);
126392
- return version && fs53.existsSync(path57.join(versionDir(version), "dist", "settings.mjs")) ? version : null;
126562
+ return version && fs54.existsSync(path57.join(versionDir(version), "dist", "settings.mjs")) ? version : null;
126393
126563
  };
126394
126564
  async function startNewer(action, port = 0) {
126395
126565
  const version = helper ? null : newerPage();
@@ -126460,7 +126630,7 @@ async function startSettingsServer(action, port = 0) {
126460
126630
  const tickets = /* @__PURE__ */ new Map();
126461
126631
  const sessions = /* @__PURE__ */ new Map();
126462
126632
  try {
126463
- const held5 = JSON.parse(fs53.readFileSync(sessionsFile(), "utf8"));
126633
+ const held5 = JSON.parse(fs54.readFileSync(sessionsFile(), "utf8"));
126464
126634
  for (const [key, value] of held5.tickets ?? []) tickets.set(key, value);
126465
126635
  for (const [key, value] of held5.sessions ?? []) sessions.set(key, value);
126466
126636
  } catch {
@@ -126468,8 +126638,8 @@ async function startSettingsServer(action, port = 0) {
126468
126638
  const keep2 = () => {
126469
126639
  for (const map2 of [tickets, sessions]) for (const [key, value] of map2) if (value.until < Date.now()) map2.delete(key);
126470
126640
  const tmp2 = `${sessionsFile()}.${process.pid}.tmp`;
126471
- fs53.writeFileSync(tmp2, JSON.stringify({ tickets: [...tickets], sessions: [...sessions] }), { mode: 384 });
126472
- fs53.renameSync(tmp2, sessionsFile());
126641
+ fs54.writeFileSync(tmp2, JSON.stringify({ tickets: [...tickets], sessions: [...sessions] }), { mode: 384 });
126642
+ fs54.renameSync(tmp2, sessionsFile());
126473
126643
  };
126474
126644
  let origin = "";
126475
126645
  let record;
@@ -126534,13 +126704,13 @@ async function startSettingsServer(action, port = 0) {
126534
126704
  origin = `http://127.0.0.1:${bound}`;
126535
126705
  record = { port: bound, secret, pid: process.pid };
126536
126706
  const tmp = `${recordFile2()}.${process.pid}.tmp`;
126537
- fs53.writeFileSync(tmp, JSON.stringify(record), { mode: 384 });
126538
- fs53.renameSync(tmp, recordFile2());
126707
+ fs54.writeFileSync(tmp, JSON.stringify(record), { mode: 384 });
126708
+ fs54.renameSync(tmp, recordFile2());
126539
126709
  return {
126540
126710
  origin,
126541
126711
  port: bound,
126542
126712
  async close() {
126543
- if (discover()?.secret === secret) fs53.rmSync(recordFile2(), { force: true });
126713
+ if (discover()?.secret === secret) fs54.rmSync(recordFile2(), { force: true });
126544
126714
  server.closeAllConnections();
126545
126715
  await new Promise((resolve2) => server.close(() => resolve2()));
126546
126716
  }