wildcrane-runner 0.6.44 → 0.6.46

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/launcher.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.44 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.46 — 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;
@@ -1146,14 +1146,14 @@ var require_util = __commonJS({
1146
1146
  }
1147
1147
  const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
1148
1148
  let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
1149
- let path26 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1149
+ let path31 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
1150
1150
  if (origin[origin.length - 1] === "/") {
1151
1151
  origin = origin.slice(0, origin.length - 1);
1152
1152
  }
1153
- if (path26 && path26[0] !== "/") {
1154
- path26 = `/${path26}`;
1153
+ if (path31 && path31[0] !== "/") {
1154
+ path31 = `/${path31}`;
1155
1155
  }
1156
- return new URL(`${origin}${path26}`);
1156
+ return new URL(`${origin}${path31}`);
1157
1157
  }
1158
1158
  if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
1159
1159
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -1988,9 +1988,9 @@ var require_diagnostics = __commonJS({
1988
1988
  "undici:client:sendHeaders",
1989
1989
  (evt) => {
1990
1990
  const {
1991
- request: { method, path: path26, origin }
1991
+ request: { method, path: path31, origin }
1992
1992
  } = evt;
1993
- debugLog("sending request to %s %s%s", method, origin, path26);
1993
+ debugLog("sending request to %s %s%s", method, origin, path31);
1994
1994
  }
1995
1995
  );
1996
1996
  }
@@ -2008,14 +2008,14 @@ var require_diagnostics = __commonJS({
2008
2008
  "undici:request:headers",
2009
2009
  (evt) => {
2010
2010
  const {
2011
- request: { method, path: path26, origin },
2011
+ request: { method, path: path31, origin },
2012
2012
  response: { statusCode }
2013
2013
  } = evt;
2014
2014
  debugLog(
2015
2015
  "received response to %s %s%s - HTTP %d",
2016
2016
  method,
2017
2017
  origin,
2018
- path26,
2018
+ path31,
2019
2019
  statusCode
2020
2020
  );
2021
2021
  }
@@ -2024,23 +2024,23 @@ var require_diagnostics = __commonJS({
2024
2024
  "undici:request:trailers",
2025
2025
  (evt) => {
2026
2026
  const {
2027
- request: { method, path: path26, origin }
2027
+ request: { method, path: path31, origin }
2028
2028
  } = evt;
2029
- debugLog("trailers received from %s %s%s", method, origin, path26);
2029
+ debugLog("trailers received from %s %s%s", method, origin, path31);
2030
2030
  }
2031
2031
  );
2032
2032
  diagnosticsChannel.subscribe(
2033
2033
  "undici:request:error",
2034
2034
  (evt) => {
2035
2035
  const {
2036
- request: { method, path: path26, origin },
2036
+ request: { method, path: path31, origin },
2037
2037
  error
2038
2038
  } = evt;
2039
2039
  debugLog(
2040
2040
  "request to %s %s%s errored - %s",
2041
2041
  method,
2042
2042
  origin,
2043
- path26,
2043
+ path31,
2044
2044
  error.message
2045
2045
  );
2046
2046
  }
@@ -2155,7 +2155,7 @@ var require_request = __commonJS({
2155
2155
  var kHandler = /* @__PURE__ */ Symbol("handler");
2156
2156
  var Request = class {
2157
2157
  constructor(origin, {
2158
- path: path26,
2158
+ path: path31,
2159
2159
  method,
2160
2160
  body,
2161
2161
  headers,
@@ -2172,11 +2172,11 @@ var require_request = __commonJS({
2172
2172
  maxRedirections,
2173
2173
  typeOfService
2174
2174
  }, handler) {
2175
- if (typeof path26 !== "string") {
2175
+ if (typeof path31 !== "string") {
2176
2176
  throw new InvalidArgumentError("path must be a string");
2177
- } else if (path26[0] !== "/" && !(path26.startsWith("http://") || path26.startsWith("https://")) && method !== "CONNECT") {
2177
+ } else if (path31[0] !== "/" && !(path31.startsWith("http://") || path31.startsWith("https://")) && method !== "CONNECT") {
2178
2178
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
2179
- } else if (invalidPathRegex.test(path26)) {
2179
+ } else if (invalidPathRegex.test(path31)) {
2180
2180
  throw new InvalidArgumentError("invalid request path");
2181
2181
  }
2182
2182
  if (typeof method !== "string") {
@@ -2251,7 +2251,7 @@ var require_request = __commonJS({
2251
2251
  this.completed = false;
2252
2252
  this.aborted = false;
2253
2253
  this.upgrade = upgrade || null;
2254
- this.path = query ? serializePathWithQuery(path26, query) : path26;
2254
+ this.path = query ? serializePathWithQuery(path31, query) : path31;
2255
2255
  this.origin = origin;
2256
2256
  this.protocol = getProtocolFromUrlString(origin);
2257
2257
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -2443,11 +2443,11 @@ var require_request = __commonJS({
2443
2443
  } else if (typeof val[i] === "object") {
2444
2444
  throw new InvalidArgumentError(`invalid ${key} header`);
2445
2445
  } else {
2446
- const str3 = `${val[i]}`;
2447
- if (!isValidHeaderValue(str3)) {
2446
+ const str4 = `${val[i]}`;
2447
+ if (!isValidHeaderValue(str4)) {
2448
2448
  throw new InvalidArgumentError(`invalid ${key} header`);
2449
2449
  }
2450
- arr2.push(str3);
2450
+ arr2.push(str4);
2451
2451
  }
2452
2452
  }
2453
2453
  val = arr2;
@@ -3990,8 +3990,8 @@ var require_infra = __commonJS({
3990
3990
  }
3991
3991
  var ASCII_WHITESPACE_REPLACE_REGEX = /[\u0009\u000A\u000C\u000D\u0020]/g;
3992
3992
  var nonASCIIRegex = /[^\x00-\x7F]/;
3993
- function asciiLowercase(str3) {
3994
- return nonASCIIRegex.test(str3) ? str3.replace(/[A-Z]+/g, (upper) => upper.toLowerCase()) : str3.toLowerCase();
3993
+ function asciiLowercase(str4) {
3994
+ return nonASCIIRegex.test(str4) ? str4.replace(/[A-Z]+/g, (upper) => upper.toLowerCase()) : str4.toLowerCase();
3995
3995
  }
3996
3996
  function forgivingBase64(data) {
3997
3997
  data = data.replace(ASCII_WHITESPACE_REPLACE_REGEX, "");
@@ -4041,22 +4041,22 @@ var require_infra = __commonJS({
4041
4041
  assert(!invalidIsomorphicEncodeValueRegex.test(input));
4042
4042
  return input;
4043
4043
  }
4044
- function parseJSONFromBytes(bytes) {
4045
- return JSON.parse(utf8DecodeBytes(bytes));
4044
+ function parseJSONFromBytes(bytes2) {
4045
+ return JSON.parse(utf8DecodeBytes(bytes2));
4046
4046
  }
4047
- function removeASCIIWhitespace(str3, leading = true, trailing = true) {
4048
- return removeChars(str3, leading, trailing, isASCIIWhitespace);
4047
+ function removeASCIIWhitespace(str4, leading = true, trailing = true) {
4048
+ return removeChars(str4, leading, trailing, isASCIIWhitespace);
4049
4049
  }
4050
- function removeChars(str3, leading, trailing, predicate) {
4050
+ function removeChars(str4, leading, trailing, predicate) {
4051
4051
  let lead = 0;
4052
- let trail = str3.length - 1;
4052
+ let trail = str4.length - 1;
4053
4053
  if (leading) {
4054
- while (lead < str3.length && predicate(str3.charCodeAt(lead))) lead++;
4054
+ while (lead < str4.length && predicate(str4.charCodeAt(lead))) lead++;
4055
4055
  }
4056
4056
  if (trailing) {
4057
- while (trail > 0 && predicate(str3.charCodeAt(trail))) trail--;
4057
+ while (trail > 0 && predicate(str4.charCodeAt(trail))) trail--;
4058
4058
  }
4059
- return lead === 0 && trail === str3.length - 1 ? str3 : str3.slice(lead, trail + 1);
4059
+ return lead === 0 && trail === str4.length - 1 ? str4 : str4.slice(lead, trail + 1);
4060
4060
  }
4061
4061
  function serializeJavascriptValueToJSONString(value) {
4062
4062
  const result = JSON.stringify(value);
@@ -4142,8 +4142,8 @@ var require_data_url = __commonJS({
4142
4142
  return serialized;
4143
4143
  }
4144
4144
  function stringPercentDecode(input) {
4145
- const bytes = encoder.encode(input);
4146
- return percentDecode(bytes);
4145
+ const bytes2 = encoder.encode(input);
4146
+ return percentDecode(bytes2);
4147
4147
  }
4148
4148
  function isHexCharByte(byte) {
4149
4149
  return byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102;
@@ -4308,8 +4308,8 @@ var require_data_url = __commonJS({
4308
4308
  function isHTTPWhiteSpace(char) {
4309
4309
  return char === 13 || char === 10 || char === 9 || char === 32;
4310
4310
  }
4311
- function removeHTTPWhitespace(str3, leading = true, trailing = true) {
4312
- return removeChars(str3, leading, trailing, isHTTPWhiteSpace);
4311
+ function removeHTTPWhitespace(str4, leading = true, trailing = true) {
4312
+ return removeChars(str4, leading, trailing, isHTTPWhiteSpace);
4313
4313
  }
4314
4314
  function minimizeSupportedMimeType(mimeType) {
4315
4315
  switch (mimeType.essence) {
@@ -4468,7 +4468,7 @@ var require_webidl = __commonJS({
4468
4468
  "node_modules/undici/lib/web/webidl/index.js"(exports, module) {
4469
4469
  "use strict";
4470
4470
  var assert = __require("node:assert");
4471
- var { types, inspect } = __require("node:util");
4471
+ var { types, inspect: inspect2 } = __require("node:util");
4472
4472
  var { runtimeFeatures } = require_runtime_features();
4473
4473
  var UNDEFINED = 1;
4474
4474
  var BOOLEAN = 2;
@@ -4660,7 +4660,7 @@ var require_webidl = __commonJS({
4660
4660
  case SYMBOL:
4661
4661
  return `Symbol(${V.description})`;
4662
4662
  case OBJECT:
4663
- return inspect(V);
4663
+ return inspect2(V);
4664
4664
  case STRING:
4665
4665
  return `"${V}"`;
4666
4666
  case BIGINT:
@@ -4829,10 +4829,10 @@ var require_webidl = __commonJS({
4829
4829
  if (jsArrayBuffer.detached) {
4830
4830
  return new Uint8Array(0);
4831
4831
  }
4832
- const bytes = new Uint8Array(length);
4832
+ const bytes2 = new Uint8Array(length);
4833
4833
  const view = new Uint8Array(jsArrayBuffer, offset, length);
4834
- bytes.set(view);
4835
- return bytes;
4834
+ bytes2.set(view);
4835
+ return bytes2;
4836
4836
  };
4837
4837
  webidl.converters.DOMString = function(V, prefix, argument, flags) {
4838
4838
  if (V === null && webidl.util.HasFlag(flags, webidl.attributes.LegacyNullToEmptyString)) {
@@ -5548,19 +5548,19 @@ var require_util2 = __commonJS({
5548
5548
  }
5549
5549
  async function readAllBytes(reader, successSteps, failureSteps) {
5550
5550
  try {
5551
- const bytes = [];
5551
+ const bytes2 = [];
5552
5552
  let byteLength = 0;
5553
5553
  do {
5554
5554
  const { done, value: chunk } = await reader.read();
5555
5555
  if (done) {
5556
- successSteps(Buffer.concat(bytes, byteLength));
5556
+ successSteps(Buffer.concat(bytes2, byteLength));
5557
5557
  return;
5558
5558
  }
5559
5559
  if (!isUint8Array(chunk)) {
5560
5560
  failureSteps(new TypeError("Received non-Uint8Array chunk"));
5561
5561
  return;
5562
5562
  }
5563
- bytes.push(chunk);
5563
+ bytes2.push(chunk);
5564
5564
  byteLength += chunk.length;
5565
5565
  } while (true);
5566
5566
  } catch (e) {
@@ -6430,7 +6430,7 @@ var require_body = __commonJS({
6430
6430
  const boundary = `----formdata-undici-0${`${random2(1e11)}`.padStart(11, "0")}`;
6431
6431
  const prefix = `--${boundary}\r
6432
6432
  Content-Disposition: form-data`;
6433
- const formdataEscape = (str3) => str3.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
6433
+ const formdataEscape = (str4) => str4.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
6434
6434
  const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
6435
6435
  const blobParts = [];
6436
6436
  const rn = new Uint8Array([13, 10]);
@@ -6519,19 +6519,19 @@ Content-Type: ${value.type || "application/octet-stream"}\r
6519
6519
  function bodyMixinMethods(instance, getInternalState) {
6520
6520
  const methods = {
6521
6521
  blob() {
6522
- return consumeBody(this, (bytes) => {
6522
+ return consumeBody(this, (bytes2) => {
6523
6523
  let mimeType = bodyMimeType(getInternalState(this));
6524
6524
  if (mimeType === null) {
6525
6525
  mimeType = "";
6526
6526
  } else if (mimeType) {
6527
6527
  mimeType = serializeAMimeType(mimeType);
6528
6528
  }
6529
- return new Blob([bytes], { type: mimeType });
6529
+ return new Blob([bytes2], { type: mimeType });
6530
6530
  }, instance, getInternalState);
6531
6531
  },
6532
6532
  arrayBuffer() {
6533
- return consumeBody(this, (bytes) => {
6534
- return new Uint8Array(bytes).buffer;
6533
+ return consumeBody(this, (bytes2) => {
6534
+ return new Uint8Array(bytes2).buffer;
6535
6535
  }, instance, getInternalState);
6536
6536
  },
6537
6537
  text() {
@@ -6567,8 +6567,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
6567
6567
  }, instance, getInternalState);
6568
6568
  },
6569
6569
  bytes() {
6570
- return consumeBody(this, (bytes) => {
6571
- return new Uint8Array(bytes);
6570
+ return consumeBody(this, (bytes2) => {
6571
+ return new Uint8Array(bytes2);
6572
6572
  }, instance, getInternalState);
6573
6573
  }
6574
6574
  };
@@ -7495,7 +7495,7 @@ var require_client_h1 = __commonJS({
7495
7495
  }
7496
7496
  }
7497
7497
  function writeH1(client, request2) {
7498
- const { method, path: path26, host, upgrade, blocking, reset } = request2;
7498
+ const { method, path: path31, host, upgrade, blocking, reset } = request2;
7499
7499
  let { body, headers, contentLength } = request2;
7500
7500
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
7501
7501
  if (util.isFormDataLike(body)) {
@@ -7571,7 +7571,7 @@ var require_client_h1 = __commonJS({
7571
7571
  socket[kBlocking] = true;
7572
7572
  }
7573
7573
  setTypeOfService(socket, request2);
7574
- let header = `${method} ${path26} HTTP/1.1\r
7574
+ let header = `${method} ${path31} HTTP/1.1\r
7575
7575
  `;
7576
7576
  if (typeof host === "string") {
7577
7577
  header += `host: ${host}\r
@@ -8248,7 +8248,7 @@ var require_client_h2 = __commonJS({
8248
8248
  const headersTimeout = request2.headersTimeout ?? client[kHeadersTimeout];
8249
8249
  const bodyTimeout = request2.bodyTimeout ?? client[kBodyTimeout];
8250
8250
  const session = client[kHTTP2Session];
8251
- const { method, path: path26, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request2;
8251
+ const { method, path: path31, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request2;
8252
8252
  let { body } = request2;
8253
8253
  if (upgrade != null && upgrade !== "websocket") {
8254
8254
  util.errorRequest(client, request2, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -8317,7 +8317,7 @@ var require_client_h2 = __commonJS({
8317
8317
  }
8318
8318
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
8319
8319
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
8320
- headers[HTTP2_HEADER_PATH] = path26;
8320
+ headers[HTTP2_HEADER_PATH] = path31;
8321
8321
  if (protocol === "ws:" || protocol === "wss:") {
8322
8322
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
8323
8323
  } else {
@@ -8369,7 +8369,7 @@ var require_client_h2 = __commonJS({
8369
8369
  stream.setTimeout(headersTimeout);
8370
8370
  return true;
8371
8371
  }
8372
- headers[HTTP2_HEADER_PATH] = path26;
8372
+ headers[HTTP2_HEADER_PATH] = path31;
8373
8373
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8374
8374
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
8375
8375
  if (body && typeof body.read === "function") {
@@ -10725,10 +10725,10 @@ var require_proxy_agent = __commonJS({
10725
10725
  };
10726
10726
  const {
10727
10727
  origin,
10728
- path: path26 = "/",
10728
+ path: path31 = "/",
10729
10729
  headers = {}
10730
10730
  } = opts;
10731
- opts.path = origin + path26;
10731
+ opts.path = origin + path31;
10732
10732
  if (!("host" in headers) && !("Host" in headers)) {
10733
10733
  const { host } = new URL(origin);
10734
10734
  headers.host = host;
@@ -12888,20 +12888,20 @@ var require_mock_utils = __commonJS({
12888
12888
  }
12889
12889
  return normalizedQp;
12890
12890
  }
12891
- function safeUrl(path26) {
12892
- if (typeof path26 !== "string") {
12893
- return path26;
12891
+ function safeUrl(path31) {
12892
+ if (typeof path31 !== "string") {
12893
+ return path31;
12894
12894
  }
12895
- const pathSegments = path26.split("?", 3);
12895
+ const pathSegments = path31.split("?", 3);
12896
12896
  if (pathSegments.length !== 2) {
12897
- return path26;
12897
+ return path31;
12898
12898
  }
12899
12899
  const qp = new URLSearchParams(pathSegments.pop());
12900
12900
  qp.sort();
12901
12901
  return [...pathSegments, qp.toString()].join("?");
12902
12902
  }
12903
- function matchKey(mockDispatch2, { path: path26, method, body, headers }) {
12904
- const pathMatch = matchValue(mockDispatch2.path, path26);
12903
+ function matchKey(mockDispatch2, { path: path31, method, body, headers }) {
12904
+ const pathMatch = matchValue(mockDispatch2.path, path31);
12905
12905
  const methodMatch = matchValue(mockDispatch2.method, method);
12906
12906
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
12907
12907
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -12926,8 +12926,8 @@ var require_mock_utils = __commonJS({
12926
12926
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
12927
12927
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
12928
12928
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
12929
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path26, ignoreTrailingSlash }) => {
12930
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path26)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path26), resolvedPath);
12929
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path31, ignoreTrailingSlash }) => {
12930
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path31)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path31), resolvedPath);
12931
12931
  });
12932
12932
  if (matchedMockDispatches.length === 0) {
12933
12933
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -12966,19 +12966,19 @@ var require_mock_utils = __commonJS({
12966
12966
  mockDispatches.splice(index, 1);
12967
12967
  }
12968
12968
  }
12969
- function removeTrailingSlash(path26) {
12970
- while (path26.endsWith("/")) {
12971
- path26 = path26.slice(0, -1);
12969
+ function removeTrailingSlash(path31) {
12970
+ while (path31.endsWith("/")) {
12971
+ path31 = path31.slice(0, -1);
12972
12972
  }
12973
- if (path26.length === 0) {
12974
- path26 = "/";
12973
+ if (path31.length === 0) {
12974
+ path31 = "/";
12975
12975
  }
12976
- return path26;
12976
+ return path31;
12977
12977
  }
12978
12978
  function buildKey(opts) {
12979
- const { path: path26, method, body, headers, query } = opts;
12979
+ const { path: path31, method, body, headers, query } = opts;
12980
12980
  return {
12981
- path: path26,
12981
+ path: path31,
12982
12982
  method,
12983
12983
  body,
12984
12984
  headers,
@@ -13668,10 +13668,10 @@ var require_pending_interceptors_formatter = __commonJS({
13668
13668
  }
13669
13669
  format(pendingInterceptors) {
13670
13670
  const withPrettyHeaders = pendingInterceptors.map(
13671
- ({ method, path: path26, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13671
+ ({ method, path: path31, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13672
13672
  Method: method,
13673
13673
  Origin: origin,
13674
- Path: path26,
13674
+ Path: path31,
13675
13675
  "Status code": statusCode,
13676
13676
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
13677
13677
  Invocations: timesInvoked,
@@ -13753,9 +13753,9 @@ var require_mock_agent = __commonJS({
13753
13753
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
13754
13754
  const dispatchOpts = { ...opts };
13755
13755
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
13756
- const [path26, searchParams] = dispatchOpts.path.split("?");
13756
+ const [path31, searchParams] = dispatchOpts.path.split("?");
13757
13757
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
13758
- dispatchOpts.path = `${path26}?${normalizedSearchParams}`;
13758
+ dispatchOpts.path = `${path31}?${normalizedSearchParams}`;
13759
13759
  }
13760
13760
  return this[kAgent].dispatch(dispatchOpts, handler);
13761
13761
  }
@@ -13883,8 +13883,8 @@ var require_snapshot_utils = __commonJS({
13883
13883
  match: new Set(matchHeaders.map((header) => caseSensitive ? header : header.toLowerCase()))
13884
13884
  };
13885
13885
  }
13886
- var crypto9 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
13887
- var hashId = crypto9?.hash ? (value) => crypto9.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
13886
+ var crypto10 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
13887
+ var hashId = crypto10?.hash ? (value) => crypto10.hash("sha256", value, "base64url") : (value) => Buffer.from(value).toString("base64url");
13888
13888
  function isUndiciHeaders(headers) {
13889
13889
  return Array.isArray(headers) && (headers.length & 1) === 0;
13890
13890
  }
@@ -14156,12 +14156,12 @@ var require_snapshot_recorder = __commonJS({
14156
14156
  * @return {Promise<void>} - Resolves when snapshots are loaded
14157
14157
  */
14158
14158
  async loadSnapshots(filePath) {
14159
- const path26 = filePath || this.#snapshotPath;
14160
- if (!path26) {
14159
+ const path31 = filePath || this.#snapshotPath;
14160
+ if (!path31) {
14161
14161
  throw new InvalidArgumentError("Snapshot path is required");
14162
14162
  }
14163
14163
  try {
14164
- const data = await readFile(resolve2(path26), "utf8");
14164
+ const data = await readFile(resolve2(path31), "utf8");
14165
14165
  const parsed = JSON.parse(data);
14166
14166
  if (Array.isArray(parsed)) {
14167
14167
  this.#snapshots.clear();
@@ -14175,7 +14175,7 @@ var require_snapshot_recorder = __commonJS({
14175
14175
  if (error.code === "ENOENT") {
14176
14176
  this.#snapshots.clear();
14177
14177
  } else {
14178
- throw new UndiciError(`Failed to load snapshots from ${path26}`, { cause: error });
14178
+ throw new UndiciError(`Failed to load snapshots from ${path31}`, { cause: error });
14179
14179
  }
14180
14180
  }
14181
14181
  }
@@ -14186,11 +14186,11 @@ var require_snapshot_recorder = __commonJS({
14186
14186
  * @returns {Promise<void>} - Resolves when snapshots are saved
14187
14187
  */
14188
14188
  async saveSnapshots(filePath) {
14189
- const path26 = filePath || this.#snapshotPath;
14190
- if (!path26) {
14189
+ const path31 = filePath || this.#snapshotPath;
14190
+ if (!path31) {
14191
14191
  throw new InvalidArgumentError("Snapshot path is required");
14192
14192
  }
14193
- const resolvedPath = resolve2(path26);
14193
+ const resolvedPath = resolve2(path31);
14194
14194
  await mkdir(dirname(resolvedPath), { recursive: true });
14195
14195
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
14196
14196
  hash,
@@ -14831,15 +14831,15 @@ var require_redirect_handler = __commonJS({
14831
14831
  receivedAt: Date.now()
14832
14832
  });
14833
14833
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
14834
- const path26 = search ? `${pathname}${search}` : pathname;
14835
- const redirectUrlString = `${origin}${path26}`;
14834
+ const path31 = search ? `${pathname}${search}` : pathname;
14835
+ const redirectUrlString = `${origin}${path31}`;
14836
14836
  for (const historyUrl of this.history) {
14837
14837
  if (historyUrl.toString() === redirectUrlString) {
14838
14838
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
14839
14839
  }
14840
14840
  }
14841
14841
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
14842
- this.opts.path = path26;
14842
+ this.opts.path = path31;
14843
14843
  this.opts.origin = origin;
14844
14844
  this.opts.query = null;
14845
14845
  }
@@ -16656,10 +16656,10 @@ var require_cache_handler = __commonJS({
16656
16656
  }
16657
16657
  return locationUrl.pathname + locationUrl.search;
16658
16658
  }
16659
- function deleteCachedUri(store, cacheKey, path26) {
16659
+ function deleteCachedUri(store, cacheKey, path31) {
16660
16660
  deleteCachedValue(store, {
16661
16661
  ...cacheKey,
16662
- path: path26
16662
+ path: path31
16663
16663
  });
16664
16664
  for (let i = 0; i < util.safeHTTPMethods.length; i++) {
16665
16665
  const method = util.safeHTTPMethods[i];
@@ -16667,7 +16667,7 @@ var require_cache_handler = __commonJS({
16667
16667
  deleteCachedValue(store, {
16668
16668
  ...cacheKey,
16669
16669
  method,
16670
- path: path26
16670
+ path: path31
16671
16671
  });
16672
16672
  }
16673
16673
  }
@@ -16678,9 +16678,9 @@ var require_cache_handler = __commonJS({
16678
16678
  }
16679
16679
  const values = Array.isArray(headerValue) ? headerValue : [headerValue];
16680
16680
  for (let i = 0; i < values.length; i++) {
16681
- const path26 = getSameOriginPath(cacheKey, values[i]);
16682
- if (path26 !== void 0) {
16683
- deleteCachedUri(store, cacheKey, path26);
16681
+ const path31 = getSameOriginPath(cacheKey, values[i]);
16682
+ if (path31 !== void 0) {
16683
+ deleteCachedUri(store, cacheKey, path31);
16684
16684
  }
16685
16685
  }
16686
16686
  }
@@ -19513,13 +19513,13 @@ var require_headers = __commonJS({
19513
19513
  return headersList.sortedMap;
19514
19514
  }
19515
19515
  const headers = [];
19516
- const names = headersList.toSortedArray();
19516
+ const names2 = headersList.toSortedArray();
19517
19517
  const cookies = headersList.cookies;
19518
19518
  if (cookies === null || cookies.length === 1) {
19519
- return headersList.sortedMap = names;
19519
+ return headersList.sortedMap = names2;
19520
19520
  }
19521
- for (let i = 0; i < names.length; ++i) {
19522
- const { 0: name, 1: value } = names[i];
19521
+ for (let i = 0; i < names2.length; ++i) {
19522
+ const { 0: name, 1: value } = names2[i];
19523
19523
  if (name === "set-cookie") {
19524
19524
  for (let j = 0; j < cookies.length; ++j) {
19525
19525
  headers.push([name, cookies[j]]);
@@ -19937,10 +19937,10 @@ var require_response = __commonJS({
19937
19937
  if (init !== null) {
19938
19938
  init = webidl.converters.ResponseInit(init);
19939
19939
  }
19940
- const bytes = textEncoder.encode(
19940
+ const bytes2 = textEncoder.encode(
19941
19941
  serializeJavascriptValueToJSONString(data)
19942
19942
  );
19943
- const body = extractBody(bytes);
19943
+ const body = extractBody(bytes2);
19944
19944
  const responseObject = fromInnerResponse(makeResponse({}), "response");
19945
19945
  initializeResponse(responseObject, init, { body: body[0], type: "application/json" });
19946
19946
  return responseObject;
@@ -21082,10 +21082,10 @@ var require_subresource_integrity = __commonJS({
21082
21082
  var { runtimeFeatures } = require_runtime_features();
21083
21083
  var { asciiLowercase } = require_infra();
21084
21084
  var validSRIHashAlgorithmTokenSet = /* @__PURE__ */ new Map([["sha256", 0], ["sha384", 1], ["sha512", 2]]);
21085
- var crypto9;
21085
+ var crypto10;
21086
21086
  if (runtimeFeatures.has("crypto")) {
21087
- crypto9 = __require("node:crypto");
21088
- const cryptoHashes = crypto9.getHashes();
21087
+ crypto10 = __require("node:crypto");
21088
+ const cryptoHashes = crypto10.getHashes();
21089
21089
  if (cryptoHashes.length === 0) {
21090
21090
  validSRIHashAlgorithmTokenSet.clear();
21091
21091
  }
@@ -21104,7 +21104,7 @@ var require_subresource_integrity = __commonJS({
21104
21104
  )
21105
21105
  );
21106
21106
  var isValidSRIHashAlgorithm = (algorithm) => validSRIHashAlgorithmTokenSet.has(asciiLowercase(algorithm));
21107
- var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (bytes, metadataList) => {
21107
+ var bytesMatch = runtimeFeatures.has("crypto") === false || validSRIHashAlgorithmTokenSet.size === 0 ? () => true : (bytes2, metadataList) => {
21108
21108
  const parsedMetadata = parseMetadata(metadataList);
21109
21109
  if (parsedMetadata.length === 0) {
21110
21110
  return true;
@@ -21113,7 +21113,7 @@ var require_subresource_integrity = __commonJS({
21113
21113
  for (const item of metadata) {
21114
21114
  const algorithm = item.alg;
21115
21115
  const expectedValue = item.val;
21116
- const actualValue = applyAlgorithmToBytes(algorithm, bytes);
21116
+ const actualValue = applyAlgorithmToBytes(algorithm, bytes2);
21117
21117
  if (caseSensitiveMatch(actualValue, expectedValue)) {
21118
21118
  return true;
21119
21119
  }
@@ -21172,8 +21172,8 @@ var require_subresource_integrity = __commonJS({
21172
21172
  }
21173
21173
  return result;
21174
21174
  }
21175
- var applyAlgorithmToBytes = (algorithm, bytes) => {
21176
- return crypto9.hash(algorithm, bytes, "base64");
21175
+ var applyAlgorithmToBytes = (algorithm, bytes2) => {
21176
+ return crypto10.hash(algorithm, bytes2, "base64");
21177
21177
  };
21178
21178
  function caseSensitiveMatch(actualValue, expectedValue) {
21179
21179
  let actualValueLength = actualValue.length;
@@ -21584,12 +21584,12 @@ var require_fetch = __commonJS({
21584
21584
  processBodyError(response.error);
21585
21585
  return;
21586
21586
  }
21587
- const processBody = (bytes) => {
21588
- if (!bytesMatch(bytes, request2.integrity)) {
21587
+ const processBody = (bytes2) => {
21588
+ if (!bytesMatch(bytes2, request2.integrity)) {
21589
21589
  processBodyError("integrity mismatch");
21590
21590
  return;
21591
21591
  }
21592
- response.body = safelyExtractBody(bytes)[0];
21592
+ response.body = safelyExtractBody(bytes2)[0];
21593
21593
  fetchFinale(fetchParams, response);
21594
21594
  };
21595
21595
  fullyReadBody(response.body, processBody, processBodyError);
@@ -22032,12 +22032,12 @@ var require_fetch = __commonJS({
22032
22032
  if (request2.body == null && fetchParams.processRequestEndOfBody) {
22033
22033
  queueMicrotask(() => fetchParams.processRequestEndOfBody());
22034
22034
  } else if (request2.body != null) {
22035
- const processBodyChunk = async function* (bytes) {
22035
+ const processBodyChunk = async function* (bytes2) {
22036
22036
  if (isCancelled(fetchParams)) {
22037
22037
  return;
22038
22038
  }
22039
- yield bytes;
22040
- fetchParams.processRequestBodyChunkLength?.(bytes.byteLength);
22039
+ yield bytes2;
22040
+ fetchParams.processRequestBodyChunkLength?.(bytes2.byteLength);
22041
22041
  };
22042
22042
  const processEndOfBody = () => {
22043
22043
  if (isCancelled(fetchParams)) {
@@ -22059,8 +22059,8 @@ var require_fetch = __commonJS({
22059
22059
  };
22060
22060
  requestBody = (async function* () {
22061
22061
  try {
22062
- for await (const bytes of request2.body.stream) {
22063
- yield* processBodyChunk(bytes);
22062
+ for await (const bytes2 of request2.body.stream) {
22063
+ yield* processBodyChunk(bytes2);
22064
22064
  }
22065
22065
  processEndOfBody();
22066
22066
  } catch (err) {
@@ -22108,33 +22108,33 @@ var require_fetch = __commonJS({
22108
22108
  }
22109
22109
  fetchParams.controller.resume = async () => {
22110
22110
  while (true) {
22111
- let bytes;
22111
+ let bytes2;
22112
22112
  let isFailure;
22113
22113
  try {
22114
22114
  const { done, value } = await fetchParams.controller.next();
22115
22115
  if (isAborted(fetchParams)) {
22116
22116
  break;
22117
22117
  }
22118
- bytes = done ? void 0 : value;
22118
+ bytes2 = done ? void 0 : value;
22119
22119
  } catch (err) {
22120
22120
  if (fetchParams.controller.ended && !timingInfo.encodedBodySize) {
22121
- bytes = void 0;
22121
+ bytes2 = void 0;
22122
22122
  } else {
22123
- bytes = err;
22123
+ bytes2 = err;
22124
22124
  isFailure = true;
22125
22125
  }
22126
22126
  }
22127
- if (bytes === void 0) {
22127
+ if (bytes2 === void 0) {
22128
22128
  readableStreamClose(fetchParams.controller.controller);
22129
22129
  finalizeResponse(fetchParams, response);
22130
22130
  return;
22131
22131
  }
22132
- timingInfo.decodedBodySize += bytes?.byteLength ?? 0;
22132
+ timingInfo.decodedBodySize += bytes2?.byteLength ?? 0;
22133
22133
  if (isFailure) {
22134
- fetchParams.controller.terminate(bytes);
22134
+ fetchParams.controller.terminate(bytes2);
22135
22135
  return;
22136
22136
  }
22137
- const buffer = new Uint8Array(bytes);
22137
+ const buffer = new Uint8Array(bytes2);
22138
22138
  if (buffer.byteLength) {
22139
22139
  fetchParams.controller.controller.enqueue(buffer);
22140
22140
  }
@@ -22168,11 +22168,11 @@ var require_fetch = __commonJS({
22168
22168
  function dispatch({ body }) {
22169
22169
  const url = requestCurrentURL(request2);
22170
22170
  const agent = fetchParams.controller.dispatcher;
22171
- const path26 = url.pathname + url.search;
22171
+ const path31 = url.pathname + url.search;
22172
22172
  const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
22173
22173
  return new Promise((resolve2, reject) => agent.dispatch(
22174
22174
  {
22175
- path: hasTrailingQuestionMark ? `${path26}?` : path26,
22175
+ path: hasTrailingQuestionMark ? `${path31}?` : path31,
22176
22176
  origin: url.origin,
22177
22177
  method: request2.method,
22178
22178
  body: agent.isMockActive ? request2.body && (request2.body.source || request2.body.stream) : body,
@@ -22274,9 +22274,9 @@ var require_fetch = __commonJS({
22274
22274
  if (fetchParams.controller.dump) {
22275
22275
  return;
22276
22276
  }
22277
- const bytes = chunk;
22278
- timingInfo.encodedBodySize += bytes.byteLength;
22279
- return this.body.push(bytes);
22277
+ const bytes2 = chunk;
22278
+ timingInfo.encodedBodySize += bytes2.byteLength;
22279
+ return this.body.push(bytes2);
22280
22280
  },
22281
22281
  onComplete() {
22282
22282
  if (this.abort) {
@@ -22607,9 +22607,9 @@ var require_cache3 = __commonJS({
22607
22607
  // 16.
22608
22608
  };
22609
22609
  operations.push(operation);
22610
- const bytes = await bodyReadPromise.promise;
22610
+ const bytes2 = await bodyReadPromise.promise;
22611
22611
  if (clonedResponse.body != null) {
22612
- clonedResponse.body.source = bytes;
22612
+ clonedResponse.body.source = bytes2;
22613
22613
  }
22614
22614
  const cacheJobPromise = createDeferredPromise();
22615
22615
  let errorData = null;
@@ -23119,9 +23119,9 @@ var require_util4 = __commonJS({
23119
23119
  }
23120
23120
  }
23121
23121
  }
23122
- function validateCookiePath(path26) {
23123
- for (let i = 0; i < path26.length; ++i) {
23124
- const code = path26.charCodeAt(i);
23122
+ function validateCookiePath(path31) {
23123
+ for (let i = 0; i < path31.length; ++i) {
23124
+ const code = path31.charCodeAt(i);
23125
23125
  if (code < 32 || // exclude CTLs (0-31)
23126
23126
  code > 126 || // exclude DEL and non-ascii
23127
23127
  code === 59) {
@@ -23460,9 +23460,9 @@ var require_cookies = __commonJS({
23460
23460
  webidl.argumentLengthCheck(arguments, 2, "setCookie");
23461
23461
  brandChecks(headers);
23462
23462
  cookie = webidl.converters.Cookie(cookie);
23463
- const str3 = stringify(cookie);
23464
- if (str3) {
23465
- headers.append("set-cookie", str3, true);
23463
+ const str4 = stringify(cookie);
23464
+ if (str4) {
23465
+ headers.append("set-cookie", str4, true);
23466
23466
  }
23467
23467
  }
23468
23468
  webidl.converters.DeleteCookieAttributes = webidl.dictionaryConverter([
@@ -24161,7 +24161,7 @@ var require_connection = __commonJS({
24161
24161
  var { WebsocketFrameSend } = require_frame();
24162
24162
  var assert = __require("node:assert");
24163
24163
  var { runtimeFeatures } = require_runtime_features();
24164
- var crypto9 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
24164
+ var crypto10 = runtimeFeatures.has("crypto") ? __require("node:crypto") : null;
24165
24165
  var warningEmitted = false;
24166
24166
  function establishWebSocketConnection(url, protocols, client, handler, options) {
24167
24167
  const requestURL = url;
@@ -24181,7 +24181,7 @@ var require_connection = __commonJS({
24181
24181
  const headersList = getHeadersList(new Headers(options.headers));
24182
24182
  request2.headersList = headersList;
24183
24183
  }
24184
- const keyValue = crypto9.randomBytes(16).toString("base64");
24184
+ const keyValue = crypto10.randomBytes(16).toString("base64");
24185
24185
  request2.headersList.append("sec-websocket-key", keyValue, true);
24186
24186
  request2.headersList.append("sec-websocket-version", "13", true);
24187
24187
  for (const protocol of protocols) {
@@ -24221,7 +24221,7 @@ var require_connection = __commonJS({
24221
24221
  return;
24222
24222
  }
24223
24223
  const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
24224
- const digest = crypto9.hash("sha1", keyValue + uid, "base64");
24224
+ const digest = crypto10.hash("sha1", keyValue + uid, "base64");
24225
24225
  if (secWSAccept !== digest) {
24226
24226
  failHandshake(handler, response, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
24227
24227
  return;
@@ -26557,11 +26557,11 @@ var require_undici = __commonJS({
26557
26557
  if (typeof opts.path !== "string") {
26558
26558
  throw new InvalidArgumentError("invalid opts.path");
26559
26559
  }
26560
- let path26 = opts.path;
26560
+ let path31 = opts.path;
26561
26561
  if (!opts.path.startsWith("/")) {
26562
- path26 = `/${path26}`;
26562
+ path31 = `/${path31}`;
26563
26563
  }
26564
- url = new URL(util.parseOrigin(url).origin + path26);
26564
+ url = new URL(util.parseOrigin(url).origin + path31);
26565
26565
  } else {
26566
26566
  if (!opts) {
26567
26567
  opts = typeof url === "object" ? url : {};
@@ -26671,8 +26671,8 @@ ${captureLines}` : capture.stack;
26671
26671
  });
26672
26672
 
26673
26673
  // src/launcher-main.ts
26674
- import path25 from "node:path";
26675
- import { fileURLToPath as fileURLToPath2 } from "node:url";
26674
+ import path30 from "node:path";
26675
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
26676
26676
 
26677
26677
  // src/home.ts
26678
26678
  import crypto from "node:crypto";
@@ -26889,8 +26889,8 @@ function saveAlphaUpdates(value) {
26889
26889
  }
26890
26890
 
26891
26891
  // src/protocol.ts
26892
- var VERSION = true ? "0.6.44" : "0.0.0";
26893
- var AKB_VERSION = true ? "0.11.38" : "0.0.0";
26892
+ var VERSION = true ? "0.6.46" : "0.0.0";
26893
+ var AKB_VERSION = true ? "0.11.40" : "0.0.0";
26894
26894
  var EXIT_REFUSED = 10;
26895
26895
  var EXIT_OUTDATED = 11;
26896
26896
  var EXIT_UPDATE = 12;
@@ -27601,7 +27601,7 @@ async function startSettingsServer(action, port = 0) {
27601
27601
  } catch {
27602
27602
  }
27603
27603
  const keep2 = () => {
27604
- for (const map of [tickets, sessions]) for (const [key, value] of map) if (value.until < Date.now()) map.delete(key);
27604
+ for (const map2 of [tickets, sessions]) for (const [key, value] of map2) if (value.until < Date.now()) map2.delete(key);
27605
27605
  const tmp2 = `${sessionsFile()}.${process.pid}.tmp`;
27606
27606
  fs6.writeFileSync(tmp2, JSON.stringify({ tickets: [...tickets], sessions: [...sessions] }), { mode: 384 });
27607
27607
  fs6.renameSync(tmp2, sessionsFile());
@@ -27683,9 +27683,9 @@ async function startSettingsServer(action, port = 0) {
27683
27683
  }
27684
27684
 
27685
27685
  // src/settings.ts
27686
- import crypto8 from "node:crypto";
27687
- import fs20 from "node:fs";
27688
- import path24 from "node:path";
27686
+ import crypto9 from "node:crypto";
27687
+ import fs25 from "node:fs";
27688
+ import path29 from "node:path";
27689
27689
 
27690
27690
  // src/api.ts
27691
27691
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok"];
@@ -27731,7 +27731,7 @@ var FILE_TIMEOUT_MS = 10 * 6e4;
27731
27731
  var readRunner = () => request("GET", "/v1/runner");
27732
27732
  var q = encodeURIComponent;
27733
27733
  var listFolders = (machineId2) => request("GET", `/v1/runner/folders?machine=${q(machineId2)}`);
27734
- var addFolder = (machineId2, name, path26, project) => request("POST", "/v1/runner/folders", { machineId: machineId2, name, path: path26, ...project ? { project } : {} });
27734
+ var addFolder = (machineId2, name, path31, project) => request("POST", "/v1/runner/folders", { machineId: machineId2, name, path: path31, ...project ? { project } : {} });
27735
27735
  async function createProject(name, workspace, key) {
27736
27736
  const sent = await send("POST", "/v1/projects", { name, workspace }, true, TIMEOUT_MS2, void 0, { "idempotency-key": key });
27737
27737
  return sent.ok ? answerOf(sent.value) : sent;
@@ -27739,13 +27739,718 @@ async function createProject(name, workspace, key) {
27739
27739
  var removeFolder = (machineId2, project) => request("POST", `/v1/runner/folders/${q(project)}/remove`, { machineId: machineId2 });
27740
27740
 
27741
27741
  // src/cache.ts
27742
+ import crypto6 from "node:crypto";
27743
+ import fs14 from "node:fs";
27744
+ import path16 from "node:path";
27745
+
27746
+ // ../cli/src/lib/agent/cloud-studios.ts
27747
+ import fs12 from "node:fs";
27748
+ import path14 from "node:path";
27749
+
27750
+ // ../cli/src/lib/shared/board-files.ts
27751
+ var BOARD_FILE_LIMIT = 256 * 1024;
27752
+ var studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
27753
+ var studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
27754
+
27755
+ // ../official/pack.ts
27742
27756
  import crypto5 from "node:crypto";
27757
+ import fs8 from "node:fs";
27758
+ import path9 from "node:path";
27759
+ import { fileURLToPath } from "node:url";
27760
+
27761
+ // ../cli/src/lib/agents/icon.ts
27762
+ var ICON_NAMES = [
27763
+ "file",
27764
+ "text",
27765
+ "article",
27766
+ "outline",
27767
+ "script",
27768
+ "prompt",
27769
+ "email",
27770
+ "image",
27771
+ "post-image",
27772
+ "social-image",
27773
+ "cover",
27774
+ "carousel",
27775
+ "carousel-outline",
27776
+ "slides",
27777
+ "wireframe",
27778
+ "screen",
27779
+ "video",
27780
+ "storyboard",
27781
+ "template",
27782
+ "shots",
27783
+ "api",
27784
+ "schema",
27785
+ "compare",
27786
+ "stack",
27787
+ "studio",
27788
+ "code",
27789
+ "checklist",
27790
+ "card",
27791
+ "plan",
27792
+ "proposal",
27793
+ "dismissed",
27794
+ "inbox",
27795
+ "notebook",
27796
+ "squeeze",
27797
+ "folder",
27798
+ "reply",
27799
+ "feedback",
27800
+ "software",
27801
+ "product-video",
27802
+ "social-post",
27803
+ "blog",
27804
+ "deck",
27805
+ "video-clone",
27806
+ "studio-kit"
27807
+ ];
27808
+ var ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
27809
+ var PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
27810
+ var isColor = (v) => ICON_COLORS.includes(v);
27811
+ function readIcon(raw) {
27812
+ if (raw === void 0 || raw === "") return void 0;
27813
+ if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
27814
+ if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
27815
+ const parts = [];
27816
+ for (const [i, item] of raw.entries()) {
27817
+ const at = `part ${i + 1}`;
27818
+ if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
27819
+ const { d, f, o, s, w, ...extra } = item;
27820
+ if (Object.keys(extra).length) return { problem: `${at} has \`${Object.keys(extra).join("`, `")}\`` };
27821
+ if (typeof d !== "string" || !PATH.test(d)) return { problem: `${at} has no \`d\` of SVG path commands and numbers` };
27822
+ const part = { d: d.trim() };
27823
+ for (const [key, value] of [["f", f], ["s", s]]) {
27824
+ if (value === void 0) continue;
27825
+ if (typeof value !== "string" || !isColor(value)) return { problem: `${at} colours \`${key}\` with "${String(value)}"` };
27826
+ part[key] = value;
27827
+ }
27828
+ if (o !== void 0) {
27829
+ if (o !== "true") return { problem: `${at} has \`o: ${String(o)}\`, not \`true\`` };
27830
+ part.o = true;
27831
+ }
27832
+ if (w !== void 0) {
27833
+ const width = typeof w === "string" ? Number(w) : NaN;
27834
+ if (!(width > 0 && width <= 3)) return { problem: `${at} has \`w: ${String(w)}\`, not above 0 and up to 3` };
27835
+ part.w = width;
27836
+ }
27837
+ parts.push(part);
27838
+ }
27839
+ return parts;
27840
+ }
27841
+
27842
+ // ../cli/src/lib/yaml.ts
27843
+ function unquote(v) {
27844
+ const text3 = String(v).trim();
27845
+ if (text3.startsWith('"') && text3.endsWith('"')) {
27846
+ try {
27847
+ return JSON.parse(text3);
27848
+ } catch {
27849
+ return text3.slice(1, -1);
27850
+ }
27851
+ }
27852
+ if (text3.startsWith("'") && text3.endsWith("'")) return text3.slice(1, -1);
27853
+ return text3;
27854
+ }
27855
+
27856
+ // ../cli/src/lib/agents/yaml.ts
27857
+ function stripComment(value) {
27858
+ let from = 0;
27859
+ const quote2 = value[0];
27860
+ if (quote2 === '"' || quote2 === "'") {
27861
+ let i = 1;
27862
+ while (i < value.length) {
27863
+ if (quote2 === '"' && value[i] === "\\") i += 2;
27864
+ else if (value[i] === quote2 && quote2 === "'" && value[i + 1] === "'") i += 2;
27865
+ else if (value[i] === quote2) break;
27866
+ else i++;
27867
+ }
27868
+ from = i + 1;
27869
+ }
27870
+ const hash = value.slice(from).search(/(^|[ \t])#/);
27871
+ return hash < 0 ? value : value.slice(0, from + hash).trim();
27872
+ }
27873
+ var readLines = (text3) => text3.split("\n").map((raw) => ({ indent: raw.match(/^[ \t]*/)[0].length, text: raw.trim() })).filter((line) => line.text && !line.text.startsWith("#"));
27874
+ function parseYamlBlock(text3) {
27875
+ const [map2] = readMap(readLines(text3), 0, 0);
27876
+ return map2;
27877
+ }
27878
+ function readMap(lines, start, indent) {
27879
+ const out = {};
27880
+ let i = start;
27881
+ while (i < lines.length && lines[i].indent >= indent) {
27882
+ const line = lines[i];
27883
+ if (line.indent > indent) {
27884
+ i++;
27885
+ continue;
27886
+ }
27887
+ if (line.text.startsWith("-")) break;
27888
+ const match = line.text.match(/^([^:]+):\s*(.*)$/);
27889
+ if (!match) {
27890
+ i++;
27891
+ continue;
27892
+ }
27893
+ const key = match[1].trim();
27894
+ const inline = stripComment(match[2].trim());
27895
+ i++;
27896
+ if (inline) {
27897
+ out[key] = readScalar(inline);
27898
+ continue;
27899
+ }
27900
+ const [value, next] = readBlock(lines, i, indent);
27901
+ out[key] = value;
27902
+ i = next;
27903
+ }
27904
+ return [out, i];
27905
+ }
27906
+ function readScalar(value) {
27907
+ const flow = value.match(/^\[(.*)\]$/);
27908
+ if (!flow) return unquote(value);
27909
+ return flow[1].split(",").map((item) => unquote(item.trim())).filter(Boolean);
27910
+ }
27911
+ function readBlock(lines, start, parentIndent) {
27912
+ if (start >= lines.length || lines[start].indent <= parentIndent) return ["", start];
27913
+ const indent = lines[start].indent;
27914
+ if (lines[start].text.startsWith("-")) return readList(lines, start, indent);
27915
+ return readMap(lines, start, indent);
27916
+ }
27917
+ function readList(lines, start, indent) {
27918
+ const out = [];
27919
+ let i = start;
27920
+ while (i < lines.length && lines[i].indent === indent && lines[i].text.startsWith("-")) {
27921
+ const line = lines[i];
27922
+ const rest = line.text.replace(/^-\s*/, "");
27923
+ const keyIndent = indent + (line.text.length - rest.length);
27924
+ i++;
27925
+ if (!stripComment(rest)) {
27926
+ const [value, next2] = readBlock(lines, i, indent);
27927
+ out.push(value);
27928
+ i = next2;
27929
+ continue;
27930
+ }
27931
+ const match = rest.match(/^([^:]+):\s*(.*)$/);
27932
+ if (!match || /^\[.*\]$/.test(stripComment(rest))) {
27933
+ out.push(readScalar(stripComment(rest)));
27934
+ continue;
27935
+ }
27936
+ const item = {};
27937
+ const inline = stripComment(match[2].trim());
27938
+ if (inline) item[match[1].trim()] = unquote(inline);
27939
+ else {
27940
+ const [value, next2] = readBlock(lines, i, keyIndent);
27941
+ item[match[1].trim()] = value;
27942
+ i = next2;
27943
+ }
27944
+ const [rest_, next] = readMap(lines, i, keyIndent);
27945
+ Object.assign(item, rest_);
27946
+ i = next;
27947
+ out.push(item);
27948
+ }
27949
+ return [out, i];
27950
+ }
27951
+ function splitFrontmatter(text3) {
27952
+ const lines = text3.replace(/^/, "").split("\n");
27953
+ if (lines[0]?.trim() !== "---") return { meta: null, body: text3 };
27954
+ let i = 1;
27955
+ while (i < lines.length && lines[i].trim() !== "---") i++;
27956
+ if (i >= lines.length) return { meta: null, body: text3 };
27957
+ return { meta: lines.slice(1, i).join("\n"), body: lines.slice(i + 1).join("\n") };
27958
+ }
27959
+
27960
+ // ../cli/src/lib/agents/parse.ts
27961
+ var OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
27962
+ var AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
27963
+ var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
27964
+ var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
27965
+ function parseSpecAgent(text3, from, file2, builtIn = false, list = () => []) {
27966
+ let named = "";
27967
+ const bad = (why, old2) => ({
27968
+ problem: `${from}: ${why}`,
27969
+ ...named ? { name: named } : {},
27970
+ ...old2 ? { old: old2 } : {}
27971
+ });
27972
+ const { meta, body } = splitFrontmatter(text3);
27973
+ if (meta === null) return bad("no `---` frontmatter, so it declares no name or description");
27974
+ const front = parseYamlBlock(meta);
27975
+ const name = str(front.name);
27976
+ if (!name) return bad("its frontmatter has no `name`");
27977
+ if (!AGENT_NAME.test(name)) return bad(`"${name}" is not a usable agent name \u2014 use lower-case words joined by "-"`);
27978
+ named = name;
27979
+ const description = str(front.description);
27980
+ if (!description) return bad(`\`${name}\` has no \`description\`, which says what it does`);
27981
+ const akb = map(front.akb) ?? {};
27982
+ const old = OLD_ROLE_KEYS.filter((key) => akb[key] !== void 0);
27983
+ if (old.length) {
27984
+ return bad(
27985
+ `\`${name}\` declares ${old.map((key) => `\`akb.${key}\``).join(", ")}, which the board no longer reads \u2014 remove ${old.length > 1 ? "them" : "it"}, and list the agent in its studio's \`STUDIO.md\` under \`previews\`, \`land\` or \`scheduled\` (\`akb guide write-agent\`), or ask the Studio builder to rewrite it`,
27986
+ { keys: old }
27987
+ );
27988
+ }
27989
+ const declaredReads = str(akb.reads) === "commits" ? "archived-cards" : str(akb.reads);
27990
+ if (declaredReads && !isScheduleReads(declaredReads)) {
27991
+ return bad(`\`${name}\` declares \`akb.reads: ${declaredReads}\` \u2014 it is \`${SCHEDULE_READS.join("` or `")}\``);
27992
+ }
27993
+ const when = str(akb.when);
27994
+ const after = names(akb.after);
27995
+ const declaredSession = str(akb.session);
27996
+ if (declaredSession && declaredSession !== "new") {
27997
+ return bad(`\`${name}\` declares \`akb.session: ${declaredSession}\` \u2014 it is \`new\`, or left out to run in the planning session`);
27998
+ }
27999
+ const components = akb.components === void 0 ? ["Asset"] : akb.components;
28000
+ if (!Array.isArray(components) || components.some((value) => typeof value !== "string" || !value.trim())) {
28001
+ return bad(`\`${name}\` declares \`akb.components\` that is not a list of component IDs`);
28002
+ }
28003
+ const icon = readIcon(akb.icon);
28004
+ if (icon && typeof icon === "object" && "problem" in icon) {
28005
+ return bad(
28006
+ `\`${name}\` declares an \`akb.icon\` where ${icon.problem} \u2014 use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
28007
+ );
28008
+ }
28009
+ const workspace = memoryPaths(akb.memoryFiles);
28010
+ if (typeof workspace === "string") return bad(`\`${name}\` declares ${workspace}`);
28011
+ const instructions = body.trim();
28012
+ if (!instructions) return bad(`\`${name}\` has frontmatter but no instructions under it`);
28013
+ return {
28014
+ agent: {
28015
+ name,
28016
+ description,
28017
+ ...when ? { when } : {},
28018
+ after,
28019
+ components: [...new Set(components.map((value) => value.trim()))],
28020
+ ...icon ? { icon } : {},
28021
+ ...akb.merges === "true" ? { merges: true } : {},
28022
+ i18n: readTranslations(akb.i18n),
28023
+ ...declaredReads ? { reads: declaredReads } : {},
28024
+ ...declaredSession ? { session: "new" } : {},
28025
+ memory: names(akb.memory),
28026
+ memoryFiles: { workspace },
28027
+ files: list(),
28028
+ body: instructions,
28029
+ from,
28030
+ builtIn,
28031
+ file: file2
28032
+ }
28033
+ };
28034
+ }
28035
+ function readTranslations(raw) {
28036
+ const block = map(raw);
28037
+ if (!block) return {};
28038
+ const out = {};
28039
+ for (const [tag, value] of Object.entries(block)) {
28040
+ const said = map(value);
28041
+ if (!said) continue;
28042
+ const lines = {
28043
+ ...str(said.title) ? { title: str(said.title) } : {},
28044
+ ...str(said.description) ? { description: str(said.description) } : {},
28045
+ ...str(said.when) ? { when: str(said.when) } : {}
28046
+ };
28047
+ if (Object.keys(lines).length) out[tag] = lines;
28048
+ }
28049
+ return out;
28050
+ }
28051
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
28052
+ if (raw === void 0) return [];
28053
+ const block = map(raw);
28054
+ const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
28055
+ if (!block || extra.length) return `\`akb.memoryFiles\` with ${block ? `\`${extra.join("`, `")}\`` : "no `workspace:` list"} \u2014 it holds only \`workspace: [<path>, ...]\``;
28056
+ const list = block.workspace;
28057
+ if (list === void 0) return [];
28058
+ if (!Array.isArray(list) || list.some((v) => typeof v !== "string" || !v.trim())) {
28059
+ return "`akb.memoryFiles.workspace` that is not a list of paths \u2014 write `workspace: [style.md]`";
28060
+ }
28061
+ const paths = [...new Set(list.map((v) => v.trim()))];
28062
+ const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
28063
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
28064
+ return paths;
28065
+ }
28066
+ var names = (value) => [...new Set((Array.isArray(value) ? value : [value]).map((v) => str(v)).filter(Boolean))];
28067
+ var str = (value) => typeof value === "string" ? value.trim() : "";
28068
+ var map = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
28069
+
28070
+ // ../cli/src/lib/spec-agent-names.ts
28071
+ var LEGACY_SPEC_AGENT_NAMES = {
28072
+ "recommend-tech-stack": "tech-stack-advisor",
28073
+ "technology-selection": "tech-stack-advisor",
28074
+ "ui-design": "ui-designer",
28075
+ // Renamed in #945 and folded into the editor in #1057; its asset memory stays in
28076
+ // `memory/agents/video-assets/`.
28077
+ "video-assets": "hyperframes-editor",
28078
+ // Renamed in #1502: it reads chats, and writes memory as a result.
28079
+ "memory-reviewer": "chat-reviewer",
28080
+ // Folded into `copywriting` in #1582.
28081
+ "user-docs": "copywriting"
28082
+ };
28083
+ var canonicalSpecAgent = (name) => {
28084
+ const asked = name.trim();
28085
+ return LEGACY_SPEC_AGENT_NAMES[asked] ?? asked;
28086
+ };
28087
+
28088
+ // ../cli/src/lib/agent/studio-def.ts
28089
+ var STUDIO_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
28090
+ var OLD_KEYS = ["stages", "delivers", "helpers", "every"];
28091
+ var box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
28092
+ var text = (value) => typeof value === "string" ? value.trim() : "";
28093
+ function readAgent(item) {
28094
+ const row = typeof item === "string" ? { agent: item } : box(item);
28095
+ const agent = canonicalSpecAgent(text(row.agent));
28096
+ if (!agent) return null;
28097
+ return { agent, extra: typeof row.extra === "string" ? row.extra : "", ...text(row.off) === "true" ? { off: true } : {} };
28098
+ }
28099
+ var readGroup = (value) => (Array.isArray(value) ? value : []).map(readAgent).filter((h) => !!h);
28100
+ function readPreviews(value) {
28101
+ if (value === void 0 || value === "") return [];
28102
+ if (!Array.isArray(value)) return "`previews` is a list of agents";
28103
+ if (value.some(Array.isArray)) {
28104
+ return "`previews` is one list of agents, not a list of lists \u2014 flatten it, and give an agent `after` to make it wait on another's approval";
28105
+ }
28106
+ return readGroup(value);
28107
+ }
28108
+ function parseStudioFile(id, source, from) {
28109
+ if (!STUDIO_ID.test(id)) return { problem: `${from}: \`${id}\` is not a studio id \u2014 use lowercase letters, digits and dashes` };
28110
+ const { meta, body } = splitFrontmatter(source);
28111
+ if (meta === null) return { problem: `${from}: no \`---\` frontmatter` };
28112
+ const raw = parseYamlBlock(meta);
28113
+ const name = text(raw.name).replace(/\s+/g, " ");
28114
+ if (!name) return { problem: `${from}: its frontmatter has no \`name\`` };
28115
+ const old = OLD_KEYS.filter((key) => key in raw);
28116
+ if (old.length) {
28117
+ return {
28118
+ problem: `${from}: \`${old.join("`, `")}\` ${old.length > 1 ? "are" : "is"} no longer read \u2014 list the agents under \`previews\`, \`land\` and \`scheduled\` instead (\`akb guide write-agent\`), or ask the Studio builder to rewrite it`
28119
+ };
28120
+ }
28121
+ const icon = readIcon(raw.icon);
28122
+ if (icon && typeof icon === "object" && "problem" in icon) {
28123
+ return {
28124
+ problem: `${from}: its \`icon\` is wrong \u2014 ${icon.problem}; use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
28125
+ };
28126
+ }
28127
+ const previews = readPreviews(raw.previews);
28128
+ if (typeof previews === "string") return { problem: `${from}: ${previews}` };
28129
+ const land = readGroup(raw.land);
28130
+ const seen = /* @__PURE__ */ new Set();
28131
+ for (const { agent } of [...previews, ...land]) {
28132
+ if (seen.has(agent)) return { problem: `${from}: \`${agent}\` is listed more than once \u2014 list an agent once` };
28133
+ seen.add(agent);
28134
+ }
28135
+ const scheduled = [];
28136
+ for (const item of Array.isArray(raw.scheduled) ? raw.scheduled : []) {
28137
+ const row = typeof item === "string" ? { agent: item } : box(item);
28138
+ const agent = canonicalSpecAgent(text(row.agent));
28139
+ if (!agent || scheduled.some((s) => s.agent === agent)) continue;
28140
+ scheduled.push({ agent, ...text(row.cadence) ? { cadence: text(row.cadence) } : {} });
28141
+ }
28142
+ const workspace = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
28143
+ if (typeof workspace === "string") return { problem: `${from}: declares ${workspace}` };
28144
+ const names2 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said]) => [lang, text(said)]).filter(([, said]) => said));
28145
+ return {
28146
+ def: {
28147
+ id,
28148
+ name,
28149
+ ...Object.keys(names2).length ? { names: names2 } : {},
28150
+ description: text(raw.description),
28151
+ when: text(raw.when),
28152
+ needsArtifact: text(raw.needsArtifact) === "true",
28153
+ ...icon ? { icon } : {},
28154
+ previews,
28155
+ land,
28156
+ scheduled,
28157
+ ...workspace.length ? { memoryFiles: { workspace } } : {},
28158
+ rules: body.trim()
28159
+ }
28160
+ };
28161
+ }
28162
+
28163
+ // ../cli/src/lib/agent/studio-folder.ts
28164
+ import fs7 from "node:fs";
28165
+ import path8 from "node:path";
28166
+
28167
+ // ../cli/src/lib/shared/studio-files.ts
28168
+ var STUDIO_FILE = "STUDIO.md";
28169
+ var MCP_FILE = "mcp.json";
28170
+ var CARD_TEMPLATE_FILE = "CARD.md";
28171
+ var SHARED_DIR = "shared/";
28172
+ var VERSION_FILE = "version.json";
28173
+ var KB = 1024;
28174
+ var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
28175
+ var officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
28176
+ var hashInput = (files) => JSON.stringify(Object.entries(files).sort(([a], [b]) => a < b ? -1 : 1));
28177
+ var landsOf = (def) => ({ lands: def.land.some((h) => !h.off) });
28178
+ var SEGMENT = /^[\w.-]+$/;
28179
+ var isAboutFile = (file2) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file2) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file2);
28180
+ var bytes = (text3) => new TextEncoder().encode(text3).length;
28181
+ var isSharedFile = (file2) => {
28182
+ const parts = file2.split("/");
28183
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
28184
+ };
28185
+ function folderPath(file2, top) {
28186
+ const parts = file2.split("/");
28187
+ if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
28188
+ if (parts.slice(2).some((p) => !SEGMENT.test(p) || p === "." || p === "..")) return null;
28189
+ return [parts[1], parts.slice(2).join("/")];
28190
+ }
28191
+ function mcpProblem(text3) {
28192
+ let read2;
28193
+ try {
28194
+ read2 = JSON.parse(text3);
28195
+ } catch {
28196
+ return "is not JSON";
28197
+ }
28198
+ const servers = read2?.mcpServers;
28199
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
28200
+ for (const [name, server] of Object.entries(servers)) {
28201
+ const { command, args, ...rest } = server ?? {};
28202
+ if (!AGENT_NAME.test(name)) return `names a server \`${name}\`; use lowercase letters, digits and dashes`;
28203
+ if (typeof command !== "string" || !command) return `server \`${name}\` needs a \`command\``;
28204
+ if (args !== void 0 && !(Array.isArray(args) && args.every((a) => typeof a === "string"))) return `server \`${name}\`: \`args\` must be a list of strings`;
28205
+ if (Object.keys(rest).length) return `server \`${name}\` takes only \`command\` and \`args\``;
28206
+ }
28207
+ return null;
28208
+ }
28209
+ function checkStudioFiles(value, official = false) {
28210
+ const read2 = inspect(value, official);
28211
+ const first = read2.problems[0];
28212
+ return first ? { ok: false, ...first } : { ok: true, def: read2.def, files: read2.files };
28213
+ }
28214
+ function inspect(value, official) {
28215
+ const problems = [];
28216
+ const fail = (file2, reason, tooLarge = false) => {
28217
+ problems.push({ file: file2, reason, ...tooLarge ? { tooLarge } : {} });
28218
+ return { problems };
28219
+ };
28220
+ if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
28221
+ const files = Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE));
28222
+ const entries = Object.entries(files);
28223
+ if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
28224
+ let total = 0;
28225
+ const folders2 = /* @__PURE__ */ new Map();
28226
+ const skills = /* @__PURE__ */ new Set();
28227
+ for (const [file2, text3] of entries) {
28228
+ if (typeof text3 !== "string" || text3.includes("\0")) {
28229
+ fail(file2, "is not a text file");
28230
+ continue;
28231
+ }
28232
+ if (file2.length > FILE_LIMITS.path) {
28233
+ fail(file2, `the path is longer than ${FILE_LIMITS.path} characters`);
28234
+ continue;
28235
+ }
28236
+ const size = bytes(text3);
28237
+ if (size > FILE_LIMITS.file) return fail(file2, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
28238
+ total += size;
28239
+ if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
28240
+ if (file2 === STUDIO_FILE || file2 === CARD_TEMPLATE_FILE) continue;
28241
+ if (official && file2 === MCP_FILE) {
28242
+ const problem = mcpProblem(text3);
28243
+ if (problem) fail(file2, problem);
28244
+ continue;
28245
+ }
28246
+ if (official && isAboutFile(file2)) continue;
28247
+ if (official && file2.startsWith("skills/")) {
28248
+ if (!folderPath(file2, "skills")) fail(file2, "is not inside skills/<name>/");
28249
+ else skills.add(file2.split("/")[1]);
28250
+ continue;
28251
+ }
28252
+ if (isSharedFile(file2)) continue;
28253
+ const at = folderPath(file2, "agents");
28254
+ if (!at) {
28255
+ fail(file2, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
28256
+ continue;
28257
+ }
28258
+ if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
28259
+ folders2.get(at[0]).set(at[1], text3);
28260
+ }
28261
+ for (const name of skills) {
28262
+ if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
28263
+ }
28264
+ const source = files[STUDIO_FILE];
28265
+ const read2 = typeof source === "string" ? parseStudioFile("studio", source, STUDIO_FILE) : null;
28266
+ if (!read2) fail(STUDIO_FILE, "is missing");
28267
+ else if ("problem" in read2) fail(STUDIO_FILE, read2.problem.replace(`${STUDIO_FILE}: `, ""));
28268
+ const agents = /* @__PURE__ */ new Map();
28269
+ for (const [name, own2] of folders2) {
28270
+ const from = `agents/${name}/AGENT.md`;
28271
+ const text3 = own2.get("AGENT.md");
28272
+ if (text3 === void 0) {
28273
+ fail(from, "is missing");
28274
+ continue;
28275
+ }
28276
+ const parsed = parseSpecAgent(text3, from, (p) => own2.get(p) ?? null, false, () => [...own2.keys()].filter((p) => p !== "AGENT.md"));
28277
+ if ("problem" in parsed) fail(from, parsed.problem.replace(`${from}: `, ""));
28278
+ else if (parsed.agent.name !== name) fail(from, `calls itself \`${parsed.agent.name}\`; it must match its folder`);
28279
+ else agents.set(name, parsed.agent);
28280
+ }
28281
+ if (!read2 || "problem" in read2) return { problems };
28282
+ const def = read2.def;
28283
+ const named = [
28284
+ ...def.previews.map((h) => [h.agent, "it previews with"]),
28285
+ ...def.land.map((h) => [h.agent, "it lands with"]),
28286
+ ...def.scheduled.map((s) => [s.agent, "it schedules"])
28287
+ ];
28288
+ for (const [name, why] of named) {
28289
+ if (!agents.has(name) && !folders2.has(name)) fail(STUDIO_FILE, `${why} \`${name}\`, which has no agents/${name}/AGENT.md`);
28290
+ }
28291
+ return { problems, def, files };
28292
+ }
28293
+
28294
+ // ../cli/src/lib/agent/studio-folder.ts
28295
+ var MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
28296
+ function filesOf(dir, base = dir) {
28297
+ return fs7.readdirSync(dir, { withFileTypes: true }).filter((e) => !e.name.startsWith(".")).flatMap((e) => {
28298
+ const full = path8.join(dir, e.name);
28299
+ return e.isDirectory() ? filesOf(full, base) : [path8.relative(base, full).split(path8.sep).join("/")];
28300
+ });
28301
+ }
28302
+ function readStudioFile(dir, file2) {
28303
+ const full = path8.join(dir, file2);
28304
+ return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path8.extname(file2)]};base64,${fs7.readFileSync(full).toString("base64")}` : fs7.readFileSync(full, "utf8");
28305
+ }
28306
+ var readStudioFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f) => [f, readStudioFile(dir, f)]));
28307
+
28308
+ // ../official/pack.ts
28309
+ var OFFICIAL = path9.dirname(fileURLToPath(import.meta.url));
28310
+ var dirs = (dir) => fs8.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
28311
+ var hashOf = (files) => crypto5.createHash("sha256").update(hashInput(files)).digest("hex");
28312
+ function packOfficial(root2 = OFFICIAL, loose = false) {
28313
+ const agentsDir = path9.join(root2, "agents");
28314
+ const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
28315
+ const dir = path9.join(agentsDir, name);
28316
+ return [name, readStudioFolder(dir)];
28317
+ }));
28318
+ for (const [name, own2] of Object.entries(loose ? {} : agentFiles)) {
28319
+ const read2 = parseSpecAgent(own2["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p) => own2[p] ?? null, true);
28320
+ if ("problem" in read2) throw new Error(read2.problem);
28321
+ }
28322
+ const studiosDir = path9.join(root2, "studios");
28323
+ return dirs(studiosDir).map((folder) => {
28324
+ const dir = path9.join(studiosDir, folder);
28325
+ const files = {};
28326
+ for (const f of filesOf(dir).sort()) {
28327
+ if (f === STUDIO_FILE || f === CARD_TEMPLATE_FILE || f === MCP_FILE || f.startsWith("skills/") || f.startsWith(SHARED_DIR) || isAboutFile(f)) files[f] = readStudioFile(dir, f);
28328
+ }
28329
+ const read2 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
28330
+ Object.entries(agentFiles).flatMap(([name, own2]) => Object.entries(own2).map(([f, t2]) => [`agents/${name}/${f}`, t2]))
28331
+ ) });
28332
+ if (!read2.ok && !loose) throw new Error(`official/studios/${folder}: ${read2.file}: ${read2.reason}`);
28333
+ const parsed = parseStudioFile(folder, files[STUDIO_FILE] ?? "", STUDIO_FILE);
28334
+ if ("problem" in parsed) throw new Error(parsed.problem);
28335
+ const def = parsed.def;
28336
+ for (const name of [...new Set([...def.previews, ...def.land, ...def.scheduled].map((h) => h.agent))].sort()) {
28337
+ for (const [f, text3] of Object.entries(agentFiles[name] ?? {})) files[`agents/${name}/${f}`] = text3;
28338
+ }
28339
+ const checked = loose ? { ok: true } : checkStudioFiles(files, true);
28340
+ if (!checked.ok) throw new Error(`official/studios/${folder}: ${checked.file}: ${checked.reason}`);
28341
+ if (!def.names?.zh && !loose) throw new Error(`official/studios/${folder}/${STUDIO_FILE}: add its Chinese name under \`names: zh\``);
28342
+ return {
28343
+ id: officialId(folder),
28344
+ name: def.name,
28345
+ names: { en: def.name, ...def.names },
28346
+ description: def.description,
28347
+ when: def.when,
28348
+ ...landsOf(def),
28349
+ hash: hashOf(files),
28350
+ files
28351
+ };
28352
+ });
28353
+ }
28354
+
28355
+ // ../cli/src/lib/cloud/tasks.ts
27743
28356
  import fs9 from "node:fs";
27744
28357
  import path10 from "node:path";
28358
+ var TASK_ENV = "AI4KANBAN_TASK";
28359
+ function workspaceTask() {
28360
+ const id = process.env[TASK_ENV];
28361
+ return id && id.trim() ? id.trim() : null;
28362
+ }
28363
+ function runnerProject(board) {
28364
+ if (path10.basename(board) !== "kanban" || path10.basename(path10.dirname(board)) !== ".akb") return null;
28365
+ const linked = linkedProject(board, path10.dirname(path10.dirname(board)));
28366
+ return linked.ok ? linked.value : null;
28367
+ }
28368
+ function linkedProject(board, root2) {
28369
+ const file2 = path10.join(root2, ".akb", "base.json");
28370
+ if (!fs9.existsSync(file2)) return { ok: true, value: null };
28371
+ try {
28372
+ const base = JSON.parse(fs9.readFileSync(file2, "utf8"));
28373
+ 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();
28374
+ const projects = new Set(Object.keys(base.files ?? {}).flatMap((p) => /^projects\/([^/]+)\//.exec(p)?.[1] ?? []));
28375
+ if (typeof base.project === "string") projects.add(base.project);
28376
+ if (projects.size !== 1) throw new Error();
28377
+ return { ok: true, value: [...projects][0] };
28378
+ } catch {
28379
+ return { ok: false, error: "The project link is invalid or names multiple projects.", code: "invalid-link" };
28380
+ }
28381
+ }
28382
+
28383
+ // ../cli/src/lib/file-memo.ts
28384
+ import fs10 from "node:fs";
28385
+ import path11 from "node:path";
28386
+ function stamp(paths) {
28387
+ const parts = [];
28388
+ const visit = (p) => {
28389
+ let st;
28390
+ try {
28391
+ st = fs10.statSync(p, { bigint: true });
28392
+ } catch {
28393
+ parts.push(`${p}:-`);
28394
+ return;
28395
+ }
28396
+ if (!st.isDirectory()) {
28397
+ parts.push(`${p}:${st.mtimeNs}:${st.size}`);
28398
+ return;
28399
+ }
28400
+ parts.push(`${p}/`);
28401
+ let names2;
28402
+ try {
28403
+ names2 = fs10.readdirSync(p).sort();
28404
+ } catch {
28405
+ return;
28406
+ }
28407
+ for (const name of names2) if (name !== "node_modules" && name !== ".git") visit(path11.join(p, name));
28408
+ };
28409
+ for (const p of paths) visit(p);
28410
+ return parts.join("\n");
28411
+ }
28412
+ function copy(v) {
28413
+ if (Array.isArray(v)) return v.map(copy);
28414
+ if (v instanceof Map) return new Map([...v].map(([k, x]) => [k, copy(x)]));
28415
+ if (v instanceof Set) return new Set([...v].map(copy));
28416
+ if (v && typeof v === "object" && Object.getPrototypeOf(v) === Object.prototype) {
28417
+ return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)]));
28418
+ }
28419
+ return v;
28420
+ }
28421
+ var perTurn = false;
28422
+ var turn = 0;
28423
+ var turnEnding = false;
28424
+ function currentTurn() {
28425
+ if (!perTurn) return ++turn;
28426
+ if (!turnEnding) {
28427
+ turnEnding = true;
28428
+ setImmediate(() => {
28429
+ turn++;
28430
+ turnEnding = false;
28431
+ }).unref();
28432
+ }
28433
+ return turn;
28434
+ }
28435
+ function memoByFiles(paths, read2) {
28436
+ let last2 = null;
28437
+ return () => {
28438
+ const now = currentTurn();
28439
+ if (last2?.turn !== now) {
28440
+ const seen = stamp(paths());
28441
+ if (last2?.stamp === seen) last2.turn = now;
28442
+ else last2 = { stamp: seen, turn: now, value: read2() };
28443
+ }
28444
+ return copy(last2.value);
28445
+ };
28446
+ }
28447
+
28448
+ // ../cli/src/lib/paths.ts
28449
+ import path13 from "node:path";
27745
28450
 
27746
28451
  // ../cli/src/lib/machine/project.ts
27747
- import fs7 from "node:fs";
27748
- import path8 from "node:path";
28452
+ import fs11 from "node:fs";
28453
+ import path12 from "node:path";
27749
28454
  var SESSIONS_FILE = "sessions.json";
27750
28455
  var SESSIONS_FOLDER = "sessions";
27751
28456
  var ASSETS_FOLDER = "assets";
@@ -27754,16 +28459,16 @@ var SESSIONS_LOCK = "sessions.lock";
27754
28459
  var INDEX_LOCK = "index.lock";
27755
28460
  var UI_CONFIG_FILE = "ui.config.json";
27756
28461
  function realPathOf(dir) {
27757
- const here2 = path8.resolve(dir);
28462
+ const here2 = path12.resolve(dir);
27758
28463
  const rest = [];
27759
28464
  let at = here2;
27760
28465
  for (; ; ) {
27761
28466
  try {
27762
- return path8.join(fs7.realpathSync(at), ...rest);
28467
+ return path12.join(fs11.realpathSync(at), ...rest);
27763
28468
  } catch {
27764
- const up = path8.dirname(at);
28469
+ const up = path12.dirname(at);
27765
28470
  if (up === at) return here2;
27766
- rest.unshift(path8.basename(at));
28471
+ rest.unshift(path12.basename(at));
27767
28472
  at = up;
27768
28473
  }
27769
28474
  }
@@ -27771,40 +28476,191 @@ function realPathOf(dir) {
27771
28476
  function stateRootOf(board) {
27772
28477
  let dir = realPathOf(board);
27773
28478
  for (; ; ) {
27774
- if (fs7.existsSync(path8.join(dir, ".git"))) return dir;
27775
- const up = path8.dirname(dir);
28479
+ if (fs11.existsSync(path12.join(dir, ".git"))) return dir;
28480
+ const up = path12.dirname(dir);
27776
28481
  if (up === dir) break;
27777
28482
  dir = up;
27778
28483
  }
27779
28484
  return rootAbove(realPathOf(board));
27780
28485
  }
27781
28486
  function rootAbove(board) {
27782
- const parent = path8.dirname(board);
27783
- return ["docs", ".akb"].includes(path8.basename(parent)) ? path8.dirname(parent) : parent;
28487
+ const parent = path12.dirname(board);
28488
+ return ["docs", ".akb"].includes(path12.basename(parent)) ? path12.dirname(parent) : parent;
27784
28489
  }
27785
- function projectStateDir(board, root = stateRootOf(board)) {
27786
- const relative = path8.relative(realPathOf(root), realPathOf(board));
27787
- if (relative === ".." || relative.startsWith(`..${path8.sep}`) || path8.isAbsolute(relative)) {
28490
+ function projectStateDir(board, root2 = stateRootOf(board)) {
28491
+ const relative = path12.relative(realPathOf(root2), realPathOf(board));
28492
+ if (relative === ".." || relative.startsWith(`..${path12.sep}`) || path12.isAbsolute(relative)) {
27788
28493
  throw new Error("The board must be inside its project root.");
27789
28494
  }
27790
- return path8.join(realPathOf(root), ".akb", "boards", relative || "_root");
28495
+ return path12.join(realPathOf(root2), ".akb", "boards", relative || "_root");
27791
28496
  }
27792
28497
 
28498
+ // ../cli/src/lib/paths.ts
28499
+ var REPO_ROOT = "";
28500
+ var KANBAN = "";
28501
+ var TODO = "";
28502
+ var ARCHIVE = "";
28503
+ var ARCHIVE_MD = "";
28504
+ var README = "";
28505
+ var MODULES_MD = "";
28506
+ var CONFIG = "";
28507
+ var KANBAN_GITIGNORE = "";
28508
+ var RELEASES = "";
28509
+ var RELEASE_SUMMARIES = "";
28510
+ var AGENTS = "";
28511
+ var STUDIOS = "";
28512
+ var LEGACY_AGENTS = "";
28513
+ var ASSETS = "";
28514
+ var BOARD_STATE = "";
28515
+ var MOCKUPS = "";
28516
+ var MEMORY = "";
28517
+ var AGENT_MEMORY = "";
28518
+ var PROJECT_MD = "";
28519
+ var LOCK = "";
28520
+ var UI_CONFIG = "";
28521
+ var LEGACY_UI_CONFIG = "";
28522
+ var LOCAL_CONFIG = "";
28523
+ var ENV_FILE = "";
28524
+ var SESSIONS = "";
28525
+ var SESSIONS_DIR = "";
28526
+ var SESSIONS_LOCK2 = "";
28527
+ var INDEX_LOCK2 = "";
28528
+ var DELIVERIES = "";
28529
+ var PLANS = "";
28530
+ var PLANS_ARCHIVE = "";
28531
+ var RULES = "";
28532
+ var TRIAGE = "";
28533
+ var SIGNALS_ARCHIVED = "";
28534
+ var SIGNALS_DISMISSED = "";
28535
+ var SIGNALS_FILES = "";
28536
+ var SIGNALS_OLD_INBOX = "";
28537
+ var SIGNALS_OLD_HANDLED = "";
28538
+ var AKB_DIR = "";
28539
+ var ROOT_GITIGNORE = "";
28540
+ function boardLockName(kanban, root2) {
28541
+ const from = path13.relative(root2, kanban);
28542
+ const name = from && !from.startsWith("..") ? from : path13.basename(kanban);
28543
+ return `${name.split(path13.sep).join("-")}.lock`;
28544
+ }
28545
+ var BOARD_FLAG = "";
28546
+ function setBoard(kanban, root2, flag) {
28547
+ REPO_ROOT = path13.resolve(root2);
28548
+ KANBAN = path13.resolve(kanban);
28549
+ BOARD_FLAG = flag;
28550
+ TODO = path13.join(KANBAN, "todo");
28551
+ ARCHIVE = path13.join(KANBAN, ".archive");
28552
+ ARCHIVE_MD = path13.join(KANBAN, "archive.md");
28553
+ README = path13.join(TODO, "README.md");
28554
+ MODULES_MD = path13.join(KANBAN, "modules.md");
28555
+ CONFIG = path13.join(KANBAN, "config.md");
28556
+ KANBAN_GITIGNORE = path13.join(KANBAN, ".gitignore");
28557
+ RELEASES = path13.join(KANBAN, "releases.md");
28558
+ RELEASE_SUMMARIES = path13.join(KANBAN, ".release-summaries");
28559
+ AGENTS = path13.join(KANBAN, "agents");
28560
+ STUDIOS = path13.join(KANBAN, "studios");
28561
+ LEGACY_AGENTS = path13.join(KANBAN, "skills");
28562
+ MEMORY = path13.join(KANBAN, "memory");
28563
+ AGENT_MEMORY = path13.join(MEMORY, "agents");
28564
+ PROJECT_MD = path13.join(MEMORY, "project.md");
28565
+ LEGACY_UI_CONFIG = path13.join(KANBAN, UI_CONFIG_FILE);
28566
+ LOCAL_CONFIG = path13.join(KANBAN, ".local.json");
28567
+ ENV_FILE = path13.join(KANBAN, ".env");
28568
+ const machine = projectStateDir(KANBAN, REPO_ROOT);
28569
+ BOARD_STATE = machine;
28570
+ UI_CONFIG = path13.join(machine, UI_CONFIG_FILE);
28571
+ ASSETS = path13.join(machine, ASSETS_FOLDER);
28572
+ MOCKUPS = path13.join(machine, MOCKUPS_FOLDER);
28573
+ SESSIONS = path13.join(machine, SESSIONS_FILE);
28574
+ SESSIONS_DIR = path13.join(machine, SESSIONS_FOLDER);
28575
+ SESSIONS_LOCK2 = path13.join(machine, SESSIONS_LOCK);
28576
+ INDEX_LOCK2 = path13.join(machine, INDEX_LOCK);
28577
+ DELIVERIES = path13.join(KANBAN, "deliveries");
28578
+ RULES = path13.join(KANBAN, "rules");
28579
+ PLANS = path13.join(machine, "plans");
28580
+ PLANS_ARCHIVE = path13.join(PLANS, "archive");
28581
+ TRIAGE = path13.join(KANBAN, "triage");
28582
+ SIGNALS_ARCHIVED = path13.join(TRIAGE, "archived");
28583
+ SIGNALS_DISMISSED = path13.join(TRIAGE, "dismissed");
28584
+ SIGNALS_FILES = path13.join(TRIAGE, "files");
28585
+ SIGNALS_OLD_INBOX = path13.join(TRIAGE, "inbox");
28586
+ SIGNALS_OLD_HANDLED = path13.join(TRIAGE, "handled.md");
28587
+ AKB_DIR = path13.join(REPO_ROOT, ".akb");
28588
+ ROOT_GITIGNORE = path13.join(REPO_ROOT, ".gitignore");
28589
+ LOCK = path13.join(AKB_DIR, boardLockName(KANBAN, REPO_ROOT));
28590
+ return REPO_ROOT;
28591
+ }
28592
+ function setBoardRoot(root2, named = false) {
28593
+ const project = path13.resolve(root2);
28594
+ return setBoard(path13.join(project, "docs", "kanban"), project, named ? ` --dir ${project}` : "");
28595
+ }
28596
+ setBoardRoot(process.cwd());
28597
+
28598
+ // ../cli/src/lib/agent/cloud-studios.ts
28599
+ var DEV = "AI4KANBAN_STUDIOS";
28600
+ var root = () => path14.join(machineHome(), "studios");
28601
+ var safe = (name) => name.replace(/[^\w.@-]/g, "_");
28602
+ var versionFile = (id, version) => path14.join(root(), "versions", `${safe(id)}@${version}.json`);
28603
+ var listFile = (project) => path14.join(root(), "lists", `${safe(project)}.json`);
28604
+ var pinFile = (task) => path14.join(root(), "tasks", `${safe(task)}.json`);
28605
+ function readJson(file2) {
28606
+ try {
28607
+ return JSON.parse(fs12.readFileSync(file2, "utf8"));
28608
+ } catch {
28609
+ return null;
28610
+ }
28611
+ }
28612
+ var readVersion = (id, version) => readJson(versionFile(id, version));
28613
+ var readPin = (task) => readJson(pinFile(task));
28614
+ var boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
28615
+ var devFolder = () => process.env[DEV]?.trim() || "";
28616
+ var flowOf = (held) => {
28617
+ const id = studioName(held.id);
28618
+ const read2 = parseStudioFile(id, held.files["STUDIO.md"] ?? "", `the \`${id}\` studio`);
28619
+ if ("problem" in read2) return null;
28620
+ return { def: read2.def, cloudId: held.id, version: held.version, builtIn: held.id.startsWith("wf_builtin_"), files: held.files };
28621
+ };
28622
+ function readFlows() {
28623
+ const dev = devFolder();
28624
+ if (dev) {
28625
+ return packOfficial(dev, true).flatMap((w) => flowOf({ id: w.id, version: 1, name: w.name, names: w.names, files: w.files }) ?? []);
28626
+ }
28627
+ const project = boardProject();
28628
+ if (!project || !readSession()) return [];
28629
+ const list = readJson(listFile(project))?.studios ?? [];
28630
+ const flows2 = list.flatMap((w) => {
28631
+ const held = readVersion(w.id, w.version);
28632
+ return held ? flowOf(held) ?? [] : [];
28633
+ });
28634
+ const task = workspaceTask();
28635
+ const pin = task ? readPin(task) : null;
28636
+ const pinned = pin && readVersion(pin.studio, pin.version);
28637
+ const mine = pinned && flowOf(pinned);
28638
+ if (!mine) return flows2;
28639
+ return [mine, ...flows2.filter((f) => f.cloudId !== mine.cloudId)];
28640
+ }
28641
+ var sources = () => {
28642
+ if (devFolder()) return [devFolder()];
28643
+ const project = boardProject();
28644
+ const task = workspaceTask();
28645
+ return [sessionFile(), ...project ? [listFile(project)] : [], ...task ? [pinFile(task)] : []];
28646
+ };
28647
+ var flows = memoByFiles(sources, readFlows);
28648
+
27793
28649
  // src/folders.ts
27794
- import fs8 from "node:fs";
28650
+ import fs13 from "node:fs";
27795
28651
  import os3 from "node:os";
27796
- import path9 from "node:path";
27797
- var projectsFile = () => path9.join(runnerHome(), "projects.json");
28652
+ import path15 from "node:path";
28653
+ var projectsFile = () => path15.join(runnerHome(), "projects.json");
27798
28654
  function realpath(p) {
27799
28655
  try {
27800
- return fs8.realpathSync(p);
28656
+ return fs13.realpathSync(p);
27801
28657
  } catch {
27802
28658
  return null;
27803
28659
  }
27804
28660
  }
27805
28661
  function readGrants() {
27806
28662
  try {
27807
- const held = JSON.parse(fs8.readFileSync(projectsFile(), "utf8"));
28663
+ const held = JSON.parse(fs13.readFileSync(projectsFile(), "utf8"));
27808
28664
  if (!Array.isArray(held.projects)) throw new Error("invalid_projects");
27809
28665
  return held;
27810
28666
  } catch (error) {
@@ -27818,23 +28674,23 @@ function listOf(held) {
27818
28674
  return subject ? held.accounts[subject] ?? [] : [];
27819
28675
  }
27820
28676
  function update(change) {
27821
- fs8.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
28677
+ fs13.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
27822
28678
  const lock = `${projectsFile()}.lock`;
27823
28679
  let fd;
27824
28680
  const until = Date.now() + 2e3;
27825
28681
  for (; ; ) {
27826
28682
  try {
27827
- fd = fs8.openSync(lock, "wx", 384);
27828
- fs8.writeFileSync(fd, String(process.pid));
28683
+ fd = fs13.openSync(lock, "wx", 384);
28684
+ fs13.writeFileSync(fd, String(process.pid));
27829
28685
  break;
27830
28686
  } catch {
27831
28687
  try {
27832
- const pid = Number(fs8.readFileSync(lock, "utf8"));
28688
+ const pid = Number(fs13.readFileSync(lock, "utf8"));
27833
28689
  if (pid > 0) {
27834
28690
  try {
27835
28691
  process.kill(pid, 0);
27836
28692
  } catch {
27837
- fs8.rmSync(lock, { force: true });
28693
+ fs13.rmSync(lock, { force: true });
27838
28694
  }
27839
28695
  }
27840
28696
  } catch {
@@ -27857,13 +28713,13 @@ function update(change) {
27857
28713
  held.projects = after;
27858
28714
  } else held.projects = after;
27859
28715
  const tmp = `${projectsFile()}.${process.pid}.tmp`;
27860
- fs8.writeFileSync(tmp, `${JSON.stringify(held, null, 2)}
28716
+ fs13.writeFileSync(tmp, `${JSON.stringify(held, null, 2)}
27861
28717
  `, { mode: 384 });
27862
- fs8.renameSync(tmp, projectsFile());
28718
+ fs13.renameSync(tmp, projectsFile());
27863
28719
  return before.filter((p) => !after.includes(p));
27864
28720
  } finally {
27865
- fs8.closeSync(fd);
27866
- fs8.rmSync(lock, { force: true });
28721
+ fs13.closeSync(fd);
28722
+ fs13.rmSync(lock, { force: true });
27867
28723
  }
27868
28724
  }
27869
28725
  function adoptLegacy() {
@@ -27878,15 +28734,15 @@ var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramDat
27878
28734
  var here = () => ({ platform: process.platform, home: os3.homedir(), resolve: realpath });
27879
28735
  function refusal(picked, where = here()) {
27880
28736
  const win = where.platform === "win32";
27881
- const p = win ? path9.win32 : path9.posix;
28737
+ const p = win ? path15.win32 : path15.posix;
27882
28738
  const real = where.resolve(picked);
27883
- if (!real || !p.isAbsolute(real) || where.resolve === realpath && !fs8.statSync(real).isDirectory()) return "missing";
28739
+ if (!real || !p.isAbsolute(real) || where.resolve === realpath && !fs13.statSync(real).isDirectory()) return "missing";
27884
28740
  const norm = (d) => {
27885
28741
  const n = p.normalize(d).replace(/[\\/]+$/, "") || p.sep;
27886
28742
  return win ? n.toLowerCase() : n;
27887
28743
  };
27888
- const within = (dir, root) => {
27889
- const [d, r] = [norm(dir), norm(root)];
28744
+ const within = (dir, root2) => {
28745
+ const [d, r] = [norm(dir), norm(root2)];
27890
28746
  return d === r || d.startsWith(r.endsWith(p.sep) ? r : r + p.sep);
27891
28747
  };
27892
28748
  const forms = [picked, real];
@@ -27903,16 +28759,16 @@ function refusal(picked, where = here()) {
27903
28759
  // src/cache.ts
27904
28760
  var IDLE_MS = 7 * 24 * 60 * 6e4;
27905
28761
  var SWEEP_MS = 24 * 60 * 6e4;
27906
- var akbDir = (dir) => path10.join(dir, ".akb");
27907
- var unsentFile = (dir) => path10.join(akbDir(dir), "unsent");
27908
- var unsent = (dir) => fs9.existsSync(unsentFile(dir));
28762
+ var akbDir = (dir) => path16.join(dir, ".akb");
28763
+ var unsentFile = (dir) => path16.join(akbDir(dir), "unsent");
28764
+ var unsent = (dir) => fs14.existsSync(unsentFile(dir));
27909
28765
  var holds = /* @__PURE__ */ new Map();
27910
- var holdsDir = () => path10.join(runnerHome(), "holds");
27911
- var holdFile = (dir) => path10.join(holdsDir(), `${crypto5.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
28766
+ var holdsDir = () => path16.join(runnerHome(), "holds");
28767
+ var holdFile = (dir) => path16.join(holdsDir(), `${crypto6.createHash("sha256").update(dir).digest("hex")}.${process.pid}`);
27912
28768
  function paused(dir) {
27913
28769
  try {
27914
- const file2 = path10.join(projectStateDir(path10.join(akbDir(dir), "kanban")), SESSIONS_FILE);
27915
- const held = JSON.parse(fs9.readFileSync(file2, "utf8"));
28770
+ const file2 = path16.join(projectStateDir(path16.join(akbDir(dir), "kanban")), SESSIONS_FILE);
28771
+ const held = JSON.parse(fs14.readFileSync(file2, "utf8"));
27916
28772
  return (held.deliveries ?? []).some((d) => d.status === "active");
27917
28773
  } catch {
27918
28774
  return false;
@@ -27920,14 +28776,14 @@ function paused(dir) {
27920
28776
  }
27921
28777
  function busy(dir) {
27922
28778
  if (holds.has(dir)) return true;
27923
- const prefix = path10.basename(holdFile(dir)).split(".")[0] + ".";
28779
+ const prefix = path16.basename(holdFile(dir)).split(".")[0] + ".";
27924
28780
  try {
27925
- return fs9.readdirSync(holdsDir()).filter((file2) => file2.startsWith(prefix)).some((file2) => {
28781
+ return fs14.readdirSync(holdsDir()).filter((file2) => file2.startsWith(prefix)).some((file2) => {
27926
28782
  try {
27927
28783
  process.kill(Number(file2.split(".")[1]), 0);
27928
28784
  return true;
27929
28785
  } catch {
27930
- fs9.rmSync(path10.join(holdsDir(), file2), { force: true });
28786
+ fs14.rmSync(path16.join(holdsDir(), file2), { force: true });
27931
28787
  return false;
27932
28788
  }
27933
28789
  });
@@ -27938,19 +28794,19 @@ function busy(dir) {
27938
28794
  var kept = (dir) => busy(dir) || unsent(dir) || paused(dir);
27939
28795
  function clearAkb(dir) {
27940
28796
  dir = realpath2(dir);
27941
- if (kept(dir) || fs9.existsSync(path10.join(akbDir(dir), "worktrees")) || fs9.existsSync(path10.join(akbDir(dir), "handoffs"))) return false;
28797
+ if (kept(dir) || fs14.existsSync(path16.join(akbDir(dir), "worktrees")) || fs14.existsSync(path16.join(akbDir(dir), "handoffs"))) return false;
27942
28798
  let entries;
27943
28799
  try {
27944
- entries = fs9.readdirSync(akbDir(dir));
28800
+ entries = fs14.readdirSync(akbDir(dir));
27945
28801
  } catch {
27946
28802
  return true;
27947
28803
  }
27948
- for (const name of entries) fs9.rmSync(path10.join(akbDir(dir), name), { recursive: true, force: true });
28804
+ for (const name of entries) fs14.rmSync(path16.join(akbDir(dir), name), { recursive: true, force: true });
27949
28805
  return true;
27950
28806
  }
27951
28807
  function realpath2(p) {
27952
28808
  try {
27953
- return fs9.realpathSync(p);
28809
+ return fs14.realpathSync(p);
27954
28810
  } catch {
27955
28811
  return p;
27956
28812
  }
@@ -27958,8 +28814,8 @@ function realpath2(p) {
27958
28814
 
27959
28815
  // src/kanban-skill.ts
27960
28816
  import { spawnSync } from "node:child_process";
27961
- import fs10 from "node:fs";
27962
- import path11 from "node:path";
28817
+ import fs15 from "node:fs";
28818
+ import path17 from "node:path";
27963
28819
 
27964
28820
  // ../skill/SKILL.md
27965
28821
  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';
@@ -27971,26 +28827,26 @@ var CONTENT = `${SKILL_default.trimEnd()}
27971
28827
  <!-- ai4kanban managed -->
27972
28828
  `;
27973
28829
  var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
27974
- function prepareKanbanSkill(root) {
28830
+ function prepareKanbanSkill(root2) {
27975
28831
  for (const folder of SKILL_FOLDERS) {
27976
- const dir = path11.join(root, folder);
27977
- const file2 = path11.join(dir, "SKILL.md");
28832
+ const dir = path17.join(root2, folder);
28833
+ const file2 = path17.join(dir, "SKILL.md");
27978
28834
  try {
27979
28835
  let linked = false;
27980
- let at = root;
28836
+ let at = root2;
27981
28837
  for (const name of `${folder}/SKILL.md`.split("/")) {
27982
- at = path11.join(at, name);
27983
- if (fs10.lstatSync(at, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
28838
+ at = path17.join(at, name);
28839
+ if (fs15.lstatSync(at, { throwIfNoEntry: false })?.isSymbolicLink()) linked = true;
27984
28840
  }
27985
- const held = fs10.existsSync(file2) ? fs10.readFileSync(file2, "utf8") : null;
27986
- const exists = fs10.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
28841
+ const held = fs15.existsSync(file2) ? fs15.readFileSync(file2, "utf8") : null;
28842
+ const exists = fs15.lstatSync(dir, { throwIfNoEntry: false }) !== void 0;
27987
28843
  if (linked || exists && !MANAGED.test(held ?? "")) {
27988
28844
  if (!held?.trim()) throw new Error("\u7528\u6237\u81EA\u6709\u76EE\u5F55\u6216\u7B26\u53F7\u94FE\u63A5\u4E2D\u7F3A\u5C11\u53EF\u8BFB\u7684 SKILL.md");
27989
28845
  continue;
27990
28846
  }
27991
28847
  if (held !== CONTENT) {
27992
- fs10.mkdirSync(dir, { recursive: true });
27993
- fs10.writeFileSync(file2, CONTENT);
28848
+ fs15.mkdirSync(dir, { recursive: true });
28849
+ fs15.writeFileSync(file2, CONTENT);
27994
28850
  }
27995
28851
  } catch (e) {
27996
28852
  throw new Error(`\u65E0\u6CD5\u51C6\u5907 ${folder}\uFF1A${e instanceof Error ? e.message : String(e)}`);
@@ -28003,10 +28859,10 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
28003
28859
  if (inside.status !== 0) return;
28004
28860
  const missing = [".akb/", ...folders2.map((f) => `${f}/`)].filter((p) => git2("check-ignore", "-q", p).status !== 0);
28005
28861
  if (!missing.length) return;
28006
- const exclude = path11.resolve(dir, inside.stdout.trim());
28007
- fs10.mkdirSync(path11.dirname(exclude), { recursive: true });
28008
- const held = fs10.existsSync(exclude) ? fs10.readFileSync(exclude, "utf8") : "";
28009
- fs10.writeFileSync(exclude, `${held}${held && !held.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
28862
+ const exclude = path17.resolve(dir, inside.stdout.trim());
28863
+ fs15.mkdirSync(path17.dirname(exclude), { recursive: true });
28864
+ const held = fs15.existsSync(exclude) ? fs15.readFileSync(exclude, "utf8") : "";
28865
+ fs15.writeFileSync(exclude, `${held}${held && !held.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
28010
28866
  `);
28011
28867
  }
28012
28868
  function installKanbanSkill(dir) {
@@ -28021,9 +28877,9 @@ function installKanbanSkill(dir) {
28021
28877
 
28022
28878
  // src/runtimes.ts
28023
28879
  import { spawn as spawn5 } from "node:child_process";
28024
- import fs17 from "node:fs";
28880
+ import fs22 from "node:fs";
28025
28881
  import os5 from "node:os";
28026
- import path20 from "node:path";
28882
+ import path25 from "node:path";
28027
28883
 
28028
28884
  // ../cli/src/lib/agent/argv.ts
28029
28885
  function splitCommand(command) {
@@ -28057,8 +28913,8 @@ function splitCommand(command) {
28057
28913
 
28058
28914
  // ../cli/src/lib/agent/harnesses/types.ts
28059
28915
  import { createHash } from "node:crypto";
28060
- import fs11 from "node:fs";
28061
- import path12 from "node:path";
28916
+ import fs16 from "node:fs";
28917
+ import path18 from "node:path";
28062
28918
  var SKILL_SENTENCE = "Use the kanban skill";
28063
28919
  function namesFlag(argv, flags) {
28064
28920
  return argv.some((tok) => flags.some((flag) => tok === flag || tok.startsWith(`${flag}=`)));
@@ -28079,15 +28935,15 @@ var MCP_CONFIG = {
28079
28935
  placeholder: "/path/to/mcp.json",
28080
28936
  help: "A JSON file of `mcpServers`, as Claude Code's --mcp-config takes. Empty opens no servers."
28081
28937
  };
28082
- function machineFile(name, text2) {
28083
- const suffix = createHash("sha256").update(text2).digest("hex").slice(0, 16);
28084
- const file2 = path12.join(machineHome(), "prompts", `${path12.parse(name).name}-${suffix}${path12.extname(name)}`);
28938
+ function machineFile(name, text3) {
28939
+ const suffix = createHash("sha256").update(text3).digest("hex").slice(0, 16);
28940
+ const file2 = path18.join(machineHome(), "prompts", `${path18.parse(name).name}-${suffix}${path18.extname(name)}`);
28085
28941
  try {
28086
- if (fs11.readFileSync(file2, "utf8") === text2) return file2;
28942
+ if (fs16.readFileSync(file2, "utf8") === text3) return file2;
28087
28943
  } catch {
28088
28944
  }
28089
- fs11.mkdirSync(path12.dirname(file2), { recursive: true });
28090
- fs11.writeFileSync(file2, text2);
28945
+ fs16.mkdirSync(path18.dirname(file2), { recursive: true });
28946
+ fs16.writeFileSync(file2, text3);
28091
28947
  return file2;
28092
28948
  }
28093
28949
 
@@ -28169,13 +29025,13 @@ function checkHarnesses(harnesses) {
28169
29025
  }
28170
29026
 
28171
29027
  // ../cli/src/lib/agent/harnesses/claude-code.ts
28172
- import path16 from "node:path";
29028
+ import path22 from "node:path";
28173
29029
 
28174
29030
  // ../cli/src/lib/agent/locate.ts
28175
29031
  import { spawn as spawn4, spawnSync as spawnSync2 } from "node:child_process";
28176
- import fs13 from "node:fs";
29032
+ import fs18 from "node:fs";
28177
29033
  import os4 from "node:os";
28178
- import path14 from "node:path";
29034
+ import path20 from "node:path";
28179
29035
 
28180
29036
  // ../cli/src/lib/agent/installed.ts
28181
29037
  var WINDOWS = process.platform === "win32";
@@ -28184,8 +29040,8 @@ function commandBinary(command) {
28184
29040
  }
28185
29041
 
28186
29042
  // ../cli/src/lib/agent/spawnable.ts
28187
- import fs12 from "node:fs";
28188
- import path13 from "node:path";
29043
+ import fs17 from "node:fs";
29044
+ import path19 from "node:path";
28189
29045
  var META = /([()\][%!^"`<>&|;, *?])/g;
28190
29046
  function cmdArg(arg) {
28191
29047
  const quoted = `"${arg.replace(/\r?\n|\r/g, " ").replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1")}"`;
@@ -28194,22 +29050,22 @@ function cmdArg(arg) {
28194
29050
  function cmdLine(file2, args) {
28195
29051
  return `"${[file2.replace(META, "^$1"), ...args.map(cmdArg)].join(" ")}"`;
28196
29052
  }
28197
- function shimTarget(text2, file2) {
28198
- const dir = path13.win32.dirname(file2);
28199
- const found = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(text2);
28200
- if (!found || !/\\node\.exe"/i.test(text2)) return null;
28201
- const script = path13.win32.resolve(dir, found[1].replace(/\//g, "\\"));
28202
- const local = path13.win32.join(dir, "node.exe");
28203
- const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(text2)?.[1];
28204
- return { script, node: fs12.existsSync(local) ? local : "node", env: nodePath ? { NODE_PATH: nodePath } : {} };
29053
+ function shimTarget(text3, file2) {
29054
+ const dir = path19.win32.dirname(file2);
29055
+ const found = /"%(?:~dp0|dp0%)\\?([^"%]+)"\s+%\*/i.exec(text3);
29056
+ if (!found || !/\\node\.exe"/i.test(text3)) return null;
29057
+ const script = path19.win32.resolve(dir, found[1].replace(/\//g, "\\"));
29058
+ const local = path19.win32.join(dir, "node.exe");
29059
+ const nodePath = /SET "NODE_PATH=([^"]*)"/i.exec(text3)?.[1];
29060
+ return { script, node: fs17.existsSync(local) ? local : "node", env: nodePath ? { NODE_PATH: nodePath } : {} };
28205
29061
  }
28206
29062
  function onWindowsPath(name, env2) {
28207
29063
  const exts = (env2.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
28208
29064
  const key = Object.keys(env2).find((k) => k.toUpperCase() === "PATH") ?? "PATH";
28209
29065
  for (const dir of (env2[key] ?? "").split(";").filter(Boolean)) {
28210
29066
  for (const ext of exts) {
28211
- const file2 = path13.win32.join(dir, `${name}${ext.toLowerCase()}`);
28212
- if (fs12.existsSync(file2)) return file2;
29067
+ const file2 = path19.win32.join(dir, `${name}${ext.toLowerCase()}`);
29068
+ if (fs17.existsSync(file2)) return file2;
28213
29069
  }
28214
29070
  }
28215
29071
  return void 0;
@@ -28217,16 +29073,16 @@ function onWindowsPath(name, env2) {
28217
29073
  function spawnable(command, args, options = {}, platform = process.platform) {
28218
29074
  if (platform !== "win32") return { command, args, options };
28219
29075
  const env2 = options.env ?? process.env;
28220
- const file2 = path13.extname(command) || /[\\/]/.test(command) ? command : onWindowsPath(command, env2) ?? command;
28221
- const ext = path13.extname(file2).toLowerCase();
29076
+ const file2 = path19.extname(command) || /[\\/]/.test(command) ? command : onWindowsPath(command, env2) ?? command;
29077
+ const ext = path19.extname(file2).toLowerCase();
28222
29078
  const hidden = { ...options, windowsHide: true, shell: false };
28223
29079
  if (ext !== ".cmd" && ext !== ".bat") return { command: file2, args, options: hidden };
28224
- let text2 = "";
29080
+ let text3 = "";
28225
29081
  try {
28226
- text2 = fs12.readFileSync(file2, "utf8");
29082
+ text3 = fs17.readFileSync(file2, "utf8");
28227
29083
  } catch {
28228
29084
  }
28229
- const shim = shimTarget(text2, file2);
29085
+ const shim = shimTarget(text3, file2);
28230
29086
  if (shim) {
28231
29087
  return { command: shim.node, args: [shim.script, ...args], options: { ...hidden, env: { ...env2, ...shim.env } } };
28232
29088
  }
@@ -28268,33 +29124,33 @@ function compareVersions(a, b) {
28268
29124
  }
28269
29125
  function newest(copies) {
28270
29126
  let best = copies[0] ?? null;
28271
- for (const copy of copies) {
28272
- if (!copy.version) return null;
29127
+ for (const copy2 of copies) {
29128
+ if (!copy2.version) return null;
28273
29129
  for (const other of copies) {
28274
- if (!other.version || compareVersions(copy.version, other.version) === null) return null;
29130
+ if (!other.version || compareVersions(copy2.version, other.version) === null) return null;
28275
29131
  }
28276
- if (compareVersions(copy.version, best.version) > 0) best = copy;
29132
+ if (compareVersions(copy2.version, best.version) > 0) best = copy2;
28277
29133
  }
28278
29134
  return best;
28279
29135
  }
28280
29136
  function pick(copies) {
28281
- const live = copies.filter((copy) => copy.starts);
28282
- if (!live.length) return copies.find((copy) => copy.entry) ?? copies[0] ?? null;
28283
- const entry2 = live.find((copy) => copy.entry);
29137
+ const live = copies.filter((copy2) => copy2.starts);
29138
+ if (!live.length) return copies.find((copy2) => copy2.entry) ?? copies[0] ?? null;
29139
+ const entry2 = live.find((copy2) => copy2.entry);
28284
29140
  const best = newest(live);
28285
29141
  if (best) return entry2 && compareVersions(entry2.version, best.version) === 0 ? entry2 : best;
28286
- return entry2 ?? newest(live.filter((copy) => copy.version)) ?? live[0];
29142
+ return entry2 ?? newest(live.filter((copy2) => copy2.version)) ?? live[0];
28287
29143
  }
28288
29144
  function folders(parent) {
28289
29145
  try {
28290
- return fs13.readdirSync(parent, { withFileTypes: true }).filter((one) => one.isDirectory()).map((one) => one.name);
29146
+ return fs18.readdirSync(parent, { withFileTypes: true }).filter((one) => one.isDirectory()).map((one) => one.name);
28291
29147
  } catch {
28292
29148
  return [];
28293
29149
  }
28294
29150
  }
28295
- function byVersion(names) {
29151
+ function byVersion(names2) {
28296
29152
  const numbers = (name) => /(\d+(?:\.\d+)+)/.exec(name)?.[1]?.split(".").map(Number) ?? [];
28297
- return [...names].sort((a, b) => {
29153
+ return [...names2].sort((a, b) => {
28298
29154
  const [x, y] = [numbers(a), numbers(b)];
28299
29155
  for (let i = 0; i < Math.max(x.length, y.length); i++) {
28300
29156
  const step = (y[i] ?? -1) - (x[i] ?? -1);
@@ -28304,31 +29160,31 @@ function byVersion(names) {
28304
29160
  });
28305
29161
  }
28306
29162
  function latestIn(parent, tail = "") {
28307
- let names;
29163
+ let names2;
28308
29164
  try {
28309
- names = fs13.readdirSync(parent);
29165
+ names2 = fs18.readdirSync(parent);
28310
29166
  } catch {
28311
29167
  return [];
28312
29168
  }
28313
- return byVersion(names.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) => path14.join(parent, name, tail));
29169
+ return byVersion(names2.filter((name) => !name.startsWith("."))).slice(0, 2).map((name) => path20.join(parent, name, tail));
28314
29170
  }
28315
29171
  var env = (name) => process.env[name]?.trim() ?? "";
28316
29172
  function commonDirs() {
28317
29173
  const home3 = os4.homedir();
28318
- const under = (...parts) => path14.join(home3, ...parts);
28319
- const nodes = (root, tail = []) => root ? folders(root).map((version) => path14.join(root, version, ...tail)) : [];
29174
+ const under = (...parts) => path20.join(home3, ...parts);
29175
+ const nodes = (root2, tail = []) => root2 ? folders(root2).map((version) => path20.join(root2, version, ...tail)) : [];
28320
29176
  if (WINDOWS2) {
28321
29177
  const [app, local, data, programs] = [env("APPDATA"), env("LOCALAPPDATA"), env("ProgramData"), env("ProgramFiles")];
28322
29178
  return [
28323
29179
  under(".local", "bin"),
28324
29180
  under(".bun", "bin"),
28325
29181
  under("scoop", "shims"),
28326
- ...app ? [path14.join(app, "npm")] : [],
28327
- ...local ? [path14.join(local, "pnpm"), path14.join(local, "Volta", "bin"), path14.join(local, "Microsoft", "WinGet", "Links")] : [],
28328
- ...data ? [path14.join(data, "chocolatey", "bin")] : [],
28329
- ...programs ? [path14.join(programs, "nodejs")] : [],
29182
+ ...app ? [path20.join(app, "npm")] : [],
29183
+ ...local ? [path20.join(local, "pnpm"), path20.join(local, "Volta", "bin"), path20.join(local, "Microsoft", "WinGet", "Links")] : [],
29184
+ ...data ? [path20.join(data, "chocolatey", "bin")] : [],
29185
+ ...programs ? [path20.join(programs, "nodejs")] : [],
28330
29186
  ...nodes(env("NVM_HOME")),
28331
- ...app ? nodes(path14.join(app, "fnm", "node-versions"), ["installation"]) : []
29187
+ ...app ? nodes(path20.join(app, "fnm", "node-versions"), ["installation"]) : []
28332
29188
  ];
28333
29189
  }
28334
29190
  const support = process.platform === "darwin" ? under("Library", "Application Support") : under(".local", "share");
@@ -28345,22 +29201,22 @@ function commonDirs() {
28345
29201
  ...env("PNPM_HOME") ? [env("PNPM_HOME")] : [],
28346
29202
  under("Library", "pnpm"),
28347
29203
  under(".local", "share", "pnpm"),
28348
- path14.join(env("VOLTA_HOME") || under(".volta"), "bin"),
28349
- ...nodes(path14.join(env("NVM_DIR") || under(".nvm"), "versions", "node"), ["bin"]),
28350
- ...nodes(path14.join(env("FNM_DIR") || path14.join(support, "fnm"), "node-versions"), ["installation", "bin"]),
28351
- ...nodes(path14.join(env("ASDF_DATA_DIR") || under(".asdf"), "installs", "nodejs"), ["bin"]),
29204
+ path20.join(env("VOLTA_HOME") || under(".volta"), "bin"),
29205
+ ...nodes(path20.join(env("NVM_DIR") || under(".nvm"), "versions", "node"), ["bin"]),
29206
+ ...nodes(path20.join(env("FNM_DIR") || path20.join(support, "fnm"), "node-versions"), ["installation", "bin"]),
29207
+ ...nodes(path20.join(env("ASDF_DATA_DIR") || under(".asdf"), "installs", "nodejs"), ["bin"]),
28352
29208
  ...nodes(under(".local", "share", "mise", "installs", "node"), ["bin"]),
28353
29209
  ...nodes(under(".nodenv", "versions"), ["bin"]),
28354
29210
  ...nodes("/usr/local/n/versions/node", ["bin"])
28355
29211
  ];
28356
29212
  }
28357
29213
  function onPath(binary) {
28358
- const names = WINDOWS2 ? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((ext) => `${binary}${ext.toLowerCase()}`) : [binary];
28359
- return (process.env.PATH ?? "").split(path14.delimiter).filter(Boolean).flatMap((dir) => names.map((name) => path14.join(dir, name)));
29214
+ const names2 = WINDOWS2 ? (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((ext) => `${binary}${ext.toLowerCase()}`) : [binary];
29215
+ return (process.env.PATH ?? "").split(path20.delimiter).filter(Boolean).flatMap((dir) => names2.map((name) => path20.join(dir, name)));
28360
29216
  }
28361
29217
  var isFile = (file2) => {
28362
29218
  try {
28363
- return fs13.statSync(file2).isFile();
29219
+ return fs18.statSync(file2).isFile();
28364
29220
  } catch {
28365
29221
  return false;
28366
29222
  }
@@ -28369,24 +29225,24 @@ function copyFiles(harness) {
28369
29225
  const pinned = harness.pinned?.();
28370
29226
  if (pinned && isFile(pinned)) return [{ file: pinned, entry: false }];
28371
29227
  const binary = commandBinary(harness.command);
28372
- const exe = (file2) => WINDOWS2 && !path14.extname(file2) ? [`${file2}.exe`, `${file2}.cmd`] : [file2];
29228
+ const exe = (file2) => WINDOWS2 && !path20.extname(file2) ? [`${file2}.exe`, `${file2}.cmd`] : [file2];
28373
29229
  const path_ = onPath(binary).filter(isFile);
28374
- const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) => path14.join(dir, binary))];
29230
+ const elsewhere = process.env.AI4KANBAN_PATH_ONLY ? [] : [...harness.installs?.() ?? [], ...commonDirs().map((dir) => path20.join(dir, binary))];
28375
29231
  const others = elsewhere.flatMap(exe).filter(isFile);
28376
29232
  const seen = /* @__PURE__ */ new Set();
28377
29233
  return [...path_, ...others].flatMap((file2, i) => {
28378
- const real = fs13.realpathSync.native(file2);
29234
+ const real = fs18.realpathSync.native(file2);
28379
29235
  if (seen.has(real)) return [];
28380
29236
  seen.add(real);
28381
29237
  return [{ file: file2, entry: i === 0 && path_.length > 0 }];
28382
29238
  });
28383
29239
  }
28384
29240
  var answers;
28385
- var answersFile = () => path14.join(machineHome(), "agent-copies.json");
29241
+ var answersFile = () => path20.join(machineHome(), "agent-copies.json");
28386
29242
  function kept2() {
28387
29243
  if (answers) return answers;
28388
29244
  try {
28389
- answers = JSON.parse(fs13.readFileSync(answersFile(), "utf8"));
29245
+ answers = JSON.parse(fs18.readFileSync(answersFile(), "utf8"));
28390
29246
  } catch {
28391
29247
  answers = {};
28392
29248
  }
@@ -28395,16 +29251,16 @@ function kept2() {
28395
29251
  function keep(file2, answer) {
28396
29252
  kept2()[file2] = answer;
28397
29253
  try {
28398
- fs13.mkdirSync(machineHome(), { recursive: true });
29254
+ fs18.mkdirSync(machineHome(), { recursive: true });
28399
29255
  const staged = `${answersFile()}.${process.pid}`;
28400
- fs13.writeFileSync(staged, JSON.stringify(answers));
28401
- fs13.renameSync(staged, answersFile());
29256
+ fs18.writeFileSync(staged, JSON.stringify(answers));
29257
+ fs18.renameSync(staged, answersFile());
28402
29258
  } catch {
28403
29259
  }
28404
29260
  }
28405
29261
  function keyOf(file2) {
28406
- const real = fs13.realpathSync.native(file2);
28407
- const stat = fs13.statSync(real);
29262
+ const real = fs18.realpathSync.native(file2);
29263
+ const stat = fs18.statSync(real);
28408
29264
  return `${real}|${stat.size}|${stat.mtimeMs}`;
28409
29265
  }
28410
29266
  function known(file2, maxAge) {
@@ -28417,8 +29273,8 @@ function judge(code, status2, stdout, stderr) {
28417
29273
  return { starts: true, version: status2 === 0 ? versionIn(stdout) ?? versionIn(stderr) : null };
28418
29274
  }
28419
29275
  function copyEnv(file2, given = process.env) {
28420
- if (!path14.isAbsolute(file2)) return given;
28421
- return { ...given, PATH: [path14.dirname(file2), given.PATH].filter(Boolean).join(path14.delimiter) };
29276
+ if (!path20.isAbsolute(file2)) return given;
29277
+ return { ...given, PATH: [path20.dirname(file2), given.PATH].filter(Boolean).join(path20.delimiter) };
28422
29278
  }
28423
29279
  var probeOptions = (file2) => ({ cwd: os4.tmpdir(), env: copyEnv(file2), windowsHide: true, shell: false });
28424
29280
  function probe(file2) {
@@ -28467,13 +29323,13 @@ function chooseCopy(harness, maxAge = KEEP_MS) {
28467
29323
  const files = copyFiles(harness);
28468
29324
  return files.length === 1 ? { ...files[0], starts: true, version: null } : locate(harness, maxAge);
28469
29325
  }
28470
- var spawnName = (copy, binary) => copy && (!copy.entry || /\.(cmd|bat)$/i.test(copy.file)) ? copy.file : binary;
29326
+ var spawnName = (copy2, binary) => copy2 && (!copy2.entry || /\.(cmd|bat)$/i.test(copy2.file)) ? copy2.file : binary;
28471
29327
 
28472
29328
  // ../cli/src/lib/agent/wire/json.ts
28473
29329
  function obj(value) {
28474
29330
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
28475
29331
  }
28476
- function str(value) {
29332
+ function str2(value) {
28477
29333
  return typeof value === "string" ? value : "";
28478
29334
  }
28479
29335
  function num(value) {
@@ -28487,7 +29343,7 @@ function hint(raw) {
28487
29343
  function argHint(input, keys) {
28488
29344
  const args = obj(input);
28489
29345
  for (const key of keys) {
28490
- const value = str(args[key]);
29346
+ const value = str2(args[key]);
28491
29347
  if (value.trim()) return hint(value);
28492
29348
  }
28493
29349
  return "";
@@ -28495,7 +29351,7 @@ function argHint(input, keys) {
28495
29351
 
28496
29352
  // ../cli/src/lib/agent/wire/events.ts
28497
29353
  var TOOL_KINDS = ["read", "edit", "delete", "move", "search", "execute", "fetch", "other"];
28498
- var toolKind = (v) => TOOL_KINDS.includes(str(v)) ? v : "other";
29354
+ var toolKind = (v) => TOOL_KINDS.includes(str2(v)) ? v : "other";
28499
29355
  function targetOf(raw) {
28500
29356
  const line = raw.split("\n")[0].trim();
28501
29357
  if (!line) return void 0;
@@ -28505,28 +29361,28 @@ function contentText(raw) {
28505
29361
  const parts = Array.isArray(raw) ? raw : [];
28506
29362
  return parts.map((p) => {
28507
29363
  const part = obj(p);
28508
- if (part.type === "diff") return str(part.path);
28509
- return str(obj(part.content).text) || str(part.text);
29364
+ if (part.type === "diff") return str2(part.path);
29365
+ return str2(obj(part.content).text) || str2(part.text);
28510
29366
  }).filter((t2) => t2.trim()).join("\n");
28511
29367
  }
28512
29368
  function statusOf(raw) {
28513
- const s = str(raw).toLowerCase();
29369
+ const s = str2(raw).toLowerCase();
28514
29370
  if (s.includes("progress")) return "in_progress";
28515
29371
  if (/complete|done|cancel/.test(s)) return "completed";
28516
29372
  return "pending";
28517
29373
  }
28518
29374
  function entriesOf(raw) {
28519
29375
  return (Array.isArray(raw) ? raw : []).map(obj).flatMap((e) => {
28520
- const content = str(e.content).trim();
29376
+ const content = str2(e.content).trim();
28521
29377
  if (!content) return [];
28522
- return [{ content, status: statusOf(e.status), ...str(e.priority) ? { priority: str(e.priority) } : {} }];
29378
+ return [{ content, status: statusOf(e.status), ...str2(e.priority) ? { priority: str2(e.priority) } : {} }];
28523
29379
  });
28524
29380
  }
28525
- var isTodoCall = (u) => str(u.title) === "todowrite" || str(obj(u.rawInput)._toolName) === "updateTodos";
28526
- var inputTarget = (input) => str(input.command) || str(input.path) || str(input.filePath);
29381
+ var isTodoCall = (u) => str2(u.title) === "todowrite" || str2(obj(u.rawInput)._toolName) === "updateTodos";
29382
+ var inputTarget = (input) => str2(input.command) || str2(input.path) || str2(input.filePath);
28527
29383
  var targetIn = (u) => {
28528
29384
  const locations = Array.isArray(u.locations) ? u.locations : [];
28529
- return targetOf(inputTarget(obj(u.rawInput)) || str(obj(locations[0]).path) || "");
29385
+ return targetOf(inputTarget(obj(u.rawInput)) || str2(obj(locations[0]).path) || "");
28530
29386
  };
28531
29387
  function createEventCollector() {
28532
29388
  let queue = [];
@@ -28539,39 +29395,39 @@ function createEventCollector() {
28539
29395
  said = "";
28540
29396
  };
28541
29397
  const release = (id, target) => {
28542
- const call = held.get(id);
28543
- if (!call) return;
29398
+ const call2 = held.get(id);
29399
+ if (!call2) return;
28544
29400
  held.delete(id);
28545
- queue.push({ kind: "tool_call", data: { ...call, ...target ? { target } : {} } });
29401
+ queue.push({ kind: "tool_call", data: { ...call2, ...target ? { target } : {} } });
28546
29402
  };
28547
29403
  return {
28548
29404
  /** One ACP `session/update`'s `update`. Thoughts and housekeeping updates yield nothing. */
28549
29405
  update(raw) {
28550
29406
  const u = obj(raw);
28551
29407
  if (u.sessionUpdate === "agent_message_chunk") {
28552
- said += str(obj(u.content).text);
29408
+ said += str2(obj(u.content).text);
28553
29409
  return;
28554
29410
  }
28555
- if (!["tool_call", "tool_call_update", "plan"].includes(str(u.sessionUpdate))) return;
29411
+ if (!["tool_call", "tool_call_update", "plan"].includes(str2(u.sessionUpdate))) return;
28556
29412
  close();
28557
29413
  switch (u.sessionUpdate) {
28558
29414
  case "tool_call": {
28559
- const id = str(u.toolCallId);
29415
+ const id = str2(u.toolCallId);
28560
29416
  if (isTodoCall(u)) {
28561
29417
  todoCalls.add(id);
28562
29418
  return;
28563
29419
  }
28564
29420
  const target = targetIn(u);
28565
- const data = { toolCallId: id, title: str(u.title) || "tool", kind: toolKind(u.kind), status: str(u.status) || "pending", ...target ? { target } : {} };
29421
+ const data = { toolCallId: id, title: str2(u.title) || "tool", kind: toolKind(u.kind), status: str2(u.status) || "pending", ...target ? { target } : {} };
28566
29422
  if (u.rawInput !== void 0 && !inputTarget(obj(u.rawInput))) held.set(id, data);
28567
29423
  else queue.push({ kind: "tool_call", data });
28568
29424
  return;
28569
29425
  }
28570
29426
  case "tool_call_update": {
28571
- const id = str(u.toolCallId);
29427
+ const id = str2(u.toolCallId);
28572
29428
  if (todoCalls.has(id)) {
28573
29429
  const list = obj(u.rawInput).todos;
28574
- if (Array.isArray(list) && !str(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list) } });
29430
+ if (Array.isArray(list) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list) } });
28575
29431
  return;
28576
29432
  }
28577
29433
  release(id, targetIn(u));
@@ -28579,7 +29435,7 @@ function createEventCollector() {
28579
29435
  if (!u.status && !result) return;
28580
29436
  queue.push({
28581
29437
  kind: "tool_call_update",
28582
- data: { toolCallId: str(u.toolCallId), status: str(u.status) || "in_progress", ...result ? { result } : {} }
29438
+ data: { toolCallId: str2(u.toolCallId), status: str2(u.status) || "in_progress", ...result ? { result } : {} }
28583
29439
  });
28584
29440
  return;
28585
29441
  }
@@ -28589,9 +29445,9 @@ function createEventCollector() {
28589
29445
  }
28590
29446
  },
28591
29447
  /** A whole message, for a source that never sends one in pieces. */
28592
- message(text2) {
29448
+ message(text3) {
28593
29449
  close();
28594
- if (text2.trim()) queue.push({ kind: "message", data: { text: text2.trim() } });
29450
+ if (text3.trim()) queue.push({ kind: "message", data: { text: text3.trim() } });
28595
29451
  },
28596
29452
  toolCall(toolCallId, title, kind, target) {
28597
29453
  close();
@@ -28616,7 +29472,7 @@ function createEventCollector() {
28616
29472
  close();
28617
29473
  const items = (Array.isArray(raw) ? raw : []).map(obj).flatMap((e) => {
28618
29474
  const [entry2] = entriesOf([e]);
28619
- return entry2 ? [{ ...entry2, id: str(e.id) }] : [];
29475
+ return entry2 ? [{ ...entry2, id: str2(e.id) }] : [];
28620
29476
  });
28621
29477
  const next = merge ? [...todos] : [];
28622
29478
  for (const item of items) {
@@ -28627,13 +29483,13 @@ function createEventCollector() {
28627
29483
  todos = next;
28628
29484
  queue.push({ kind: "plan", data: { entries: todos.map(({ id: _, ...e }) => e) } });
28629
29485
  },
28630
- log(text2) {
29486
+ log(text3) {
28631
29487
  close();
28632
- if (text2.trim()) queue.push({ kind: "log", data: { text: text2 } });
29488
+ if (text3.trim()) queue.push({ kind: "log", data: { text: text3 } });
28633
29489
  },
28634
- error(text2) {
29490
+ error(text3) {
28635
29491
  close();
28636
- if (text2.trim()) queue.push({ kind: "error", data: { text: text2.trim() } });
29492
+ if (text3.trim()) queue.push({ kind: "error", data: { text: text3.trim() } });
28637
29493
  },
28638
29494
  /** The turn is over: a half-held message is finished off. */
28639
29495
  end() {
@@ -28693,12 +29549,12 @@ var TOOL_KINDS2 = {
28693
29549
  var SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task"]);
28694
29550
  function targetOf2(input) {
28695
29551
  const args = obj(input);
28696
- for (const key of ARG_KEYS) if (str(args[key]).trim()) return str(args[key]);
29552
+ for (const key of ARG_KEYS) if (str2(args[key]).trim()) return str2(args[key]);
28697
29553
  return "";
28698
29554
  }
28699
29555
  function resultText(raw) {
28700
29556
  if (typeof raw === "string") return raw;
28701
- return (Array.isArray(raw) ? raw : []).map((b) => str(obj(b).text)).filter(Boolean).join("\n");
29557
+ return (Array.isArray(raw) ? raw : []).map((b) => str2(obj(b).text)).filter(Boolean).join("\n");
28702
29558
  }
28703
29559
  function eventModel(ev) {
28704
29560
  if (ev.type === "system" && ev.subtype === "init" && typeof ev.model === "string") {
@@ -28721,17 +29577,17 @@ var USER_FIXES = [
28721
29577
  [/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
28722
29578
  ];
28723
29579
  function failedWith(ev) {
28724
- const errors = Array.isArray(ev.errors) ? ev.errors.map(str).filter(Boolean) : [];
29580
+ const errors = Array.isArray(ev.errors) ? ev.errors.map(str2).filter(Boolean) : [];
28725
29581
  if (errors.length) return errors.join("; ");
28726
- const named = str(ev.subtype) || str(ev.terminal_reason);
29582
+ const named = str2(ev.subtype) || str2(ev.terminal_reason);
28727
29583
  if (named && named !== "error" && named !== "success") return named;
28728
- return str(ev.result).trim() || "the agent reported the session failed";
29584
+ return str2(ev.result).trim() || "the agent reported the session failed";
28729
29585
  }
28730
29586
  function denials(ev) {
28731
29587
  const list = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
28732
- const names = [...new Set(list.map((raw) => str(obj(raw).tool_name)).filter(Boolean))];
28733
- if (!names.length) return "";
28734
- return `[refused] ${list.length} tool call${list.length === 1 ? "" : "s"} were not allowed: ${names.join(", ")}
29588
+ const names2 = [...new Set(list.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
29589
+ if (!names2.length) return "";
29590
+ return `[refused] ${list.length} tool call${list.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
28735
29591
  `;
28736
29592
  }
28737
29593
  function promptSize(raw) {
@@ -28741,8 +29597,8 @@ function promptSize(raw) {
28741
29597
  }
28742
29598
  function windowOf(raw, model) {
28743
29599
  const entries = obj(raw);
28744
- const names = Object.keys(entries);
28745
- const name = model && names.includes(model) ? model : names.length === 1 ? names[0] : void 0;
29600
+ const names2 = Object.keys(entries);
29601
+ const name = model && names2.includes(model) ? model : names2.length === 1 ? names2[0] : void 0;
28746
29602
  return name ? num(obj(entries[name]).contextWindow) || void 0 : void 0;
28747
29603
  }
28748
29604
  function createStreamRenderer() {
@@ -28775,7 +29631,7 @@ function createStreamRenderer() {
28775
29631
  `;
28776
29632
  }
28777
29633
  if (model === void 0) model = eventModel(ev);
28778
- if (str(ev.parent_tool_use_id)) return "";
29634
+ if (str2(ev.parent_tool_use_id)) return "";
28779
29635
  switch (ev.type) {
28780
29636
  case "assistant": {
28781
29637
  const msg = ev.message;
@@ -28795,14 +29651,14 @@ function createStreamRenderer() {
28795
29651
  `);
28796
29652
  if (SUBAGENT_TOOLS.has(b.name)) {
28797
29653
  const input = obj(b.input);
28798
- subagents.set(str(b.id), false);
28799
- if (input.run_in_background === true) detached.add(str(b.id));
28800
- events.subagent(str(b.id), str(input.description) || str(input.subagent_type) || b.name);
29654
+ subagents.set(str2(b.id), false);
29655
+ if (input.run_in_background === true) detached.add(str2(b.id));
29656
+ events.subagent(str2(b.id), str2(input.description) || str2(input.subagent_type) || b.name);
28801
29657
  } else if (b.name === "TodoWrite") {
28802
- plans.add(str(b.id));
29658
+ plans.add(str2(b.id));
28803
29659
  events.plan(obj(b.input).todos);
28804
29660
  } else {
28805
- events.toolCall(str(b.id), b.name, TOOL_KINDS2[b.name] ?? "other", targetOf2(b.input));
29661
+ events.toolCall(str2(b.id), b.name, TOOL_KINDS2[b.name] ?? "other", targetOf2(b.input));
28806
29662
  }
28807
29663
  }
28808
29664
  }
@@ -28812,12 +29668,12 @@ function createStreamRenderer() {
28812
29668
  const content = obj(ev.message).content;
28813
29669
  for (const raw of Array.isArray(content) ? content : []) {
28814
29670
  const b = obj(raw);
28815
- if (b.type !== "tool_result" || plans.has(str(b.tool_use_id))) continue;
28816
- if (subagents.has(str(b.tool_use_id))) {
28817
- if (!detached.has(str(b.tool_use_id))) endSubagent(str(b.tool_use_id), b.is_error === true ? "failed" : "completed");
29671
+ if (b.type !== "tool_result" || plans.has(str2(b.tool_use_id))) continue;
29672
+ if (subagents.has(str2(b.tool_use_id))) {
29673
+ if (!detached.has(str2(b.tool_use_id))) endSubagent(str2(b.tool_use_id), b.is_error === true ? "failed" : "completed");
28818
29674
  continue;
28819
29675
  }
28820
- events.toolResult(str(b.tool_use_id), b.is_error === true ? "failed" : "completed", resultText(b.content));
29676
+ events.toolResult(str2(b.tool_use_id), b.is_error === true ? "failed" : "completed", resultText(b.content));
28821
29677
  }
28822
29678
  return "";
28823
29679
  }
@@ -28843,12 +29699,12 @@ function createStreamRenderer() {
28843
29699
  }
28844
29700
  case "system":
28845
29701
  if (ev.subtype === "background_tasks_changed" && Array.isArray(ev.tasks)) background = ev.tasks.length;
28846
- if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(str(ev.task_id));
28847
- if (ev.subtype === "task_notification" && subagents.has(str(ev.tool_use_id))) {
28848
- endSubagent(str(ev.tool_use_id), str(ev.status) === "completed" ? "completed" : "failed");
29702
+ if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(str2(ev.task_id));
29703
+ if (ev.subtype === "task_notification" && subagents.has(str2(ev.tool_use_id))) {
29704
+ endSubagent(str2(ev.tool_use_id), str2(ev.status) === "completed" ? "completed" : "failed");
28849
29705
  }
28850
- if (ev.subtype === "task_notification" && backgrounded.has(str(ev.task_id)) && str(ev.summary)) {
28851
- return `\u23FA ${str(ev.summary)}
29706
+ if (ev.subtype === "task_notification" && backgrounded.has(str2(ev.task_id)) && str2(ev.summary)) {
29707
+ return `\u23FA ${str2(ev.summary)}
28852
29708
  `;
28853
29709
  }
28854
29710
  return "";
@@ -28892,7 +29748,7 @@ var addUsage = (a, b) => ({
28892
29748
  import { readFileSync, readdirSync, statSync } from "node:fs";
28893
29749
  import { homedir } from "node:os";
28894
29750
  import { join } from "node:path";
28895
- function text(value) {
29751
+ function text2(value) {
28896
29752
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
28897
29753
  }
28898
29754
  function count(value) {
@@ -28927,34 +29783,34 @@ function contextIn(raw) {
28927
29783
  if (!used) return void 0;
28928
29784
  return { used, limit: count(info.model_context_window) };
28929
29785
  }
28930
- function dayDir(root, at) {
29786
+ function dayDir(root2, at) {
28931
29787
  const day = new Date(at);
28932
29788
  const pad = (n) => String(n).padStart(2, "0");
28933
- return join(root, String(day.getFullYear()), pad(day.getMonth() + 1), pad(day.getDate()));
29789
+ return join(root2, String(day.getFullYear()), pad(day.getMonth() + 1), pad(day.getDate()));
28934
29790
  }
28935
29791
  function findRollout(threadId) {
28936
29792
  const home3 = process.env.CODEX_HOME?.trim() || join(homedir(), ".codex");
28937
- const root = join(home3, "sessions");
29793
+ const root2 = join(home3, "sessions");
28938
29794
  const tail = `-${threadId}.jsonl`;
28939
29795
  const minted = parseInt(threadId.replace(/-/g, "").slice(0, 12), 16);
28940
29796
  const days = /* @__PURE__ */ new Set();
28941
29797
  for (const at of [Date.now(), ...Number.isFinite(minted) && minted > 0 ? [minted] : []]) {
28942
- for (const shift of [0, -1, 1]) days.add(dayDir(root, at + shift * 864e5));
29798
+ for (const shift of [0, -1, 1]) days.add(dayDir(root2, at + shift * 864e5));
28943
29799
  }
28944
29800
  let newest2;
28945
29801
  for (const dir of days) {
28946
- let names;
29802
+ let names2;
28947
29803
  try {
28948
- names = readdirSync(dir);
29804
+ names2 = readdirSync(dir);
28949
29805
  } catch {
28950
29806
  continue;
28951
29807
  }
28952
- for (const name of names) {
29808
+ for (const name of names2) {
28953
29809
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
28954
- const path26 = join(dir, name);
29810
+ const path31 = join(dir, name);
28955
29811
  try {
28956
- const at = statSync(path26).mtimeMs;
28957
- if (!newest2 || at > newest2.at) newest2 = { path: path26, at };
29812
+ const at = statSync(path31).mtimeMs;
29813
+ if (!newest2 || at > newest2.at) newest2 = { path: path31, at };
28958
29814
  } catch {
28959
29815
  }
28960
29816
  }
@@ -28962,11 +29818,11 @@ function findRollout(threadId) {
28962
29818
  return newest2?.path;
28963
29819
  }
28964
29820
  function readCodexRunFacts(threadId) {
28965
- const path26 = findRollout(threadId);
28966
- if (!path26) return void 0;
29821
+ const path31 = findRollout(threadId);
29822
+ if (!path31) return void 0;
28967
29823
  let raw;
28968
29824
  try {
28969
- raw = readFileSync(path26, "utf8");
29825
+ raw = readFileSync(path31, "utf8");
28970
29826
  } catch {
28971
29827
  return void 0;
28972
29828
  }
@@ -28986,8 +29842,8 @@ function readCodexRunFacts(threadId) {
28986
29842
  }
28987
29843
  const payload = entry2.payload;
28988
29844
  if (!payload) continue;
28989
- if (entry2.type === "session_meta") facts.provider ??= text(payload.model_provider);
28990
- if (entry2.type === "turn_context") facts.model = text(payload.model) ?? facts.model;
29845
+ if (entry2.type === "session_meta") facts.provider ??= text2(payload.model_provider);
29846
+ if (entry2.type === "turn_context") facts.model = text2(payload.model) ?? facts.model;
28991
29847
  if (payload.type === "token_count") {
28992
29848
  facts.context = contextIn(payload.info) ?? facts.context;
28993
29849
  const info = payload.info && typeof payload.info === "object" ? payload.info : {};
@@ -29050,13 +29906,13 @@ function priceUsd(provider, model, usage) {
29050
29906
  function renderStarted(item) {
29051
29907
  switch (item.type) {
29052
29908
  case "command_execution":
29053
- return `\u23FA Command${hint(str(item.command))}
29909
+ return `\u23FA Command${hint(str2(item.command))}
29054
29910
  `;
29055
29911
  case "mcp_tool_call":
29056
- return `\u23FA ${str(item.server)}.${str(item.tool)}
29912
+ return `\u23FA ${str2(item.server)}.${str2(item.tool)}
29057
29913
  `;
29058
29914
  case "web_search":
29059
- return `\u23FA WebSearch${hint(str(item.query))}
29915
+ return `\u23FA WebSearch${hint(str2(item.query))}
29060
29916
  `;
29061
29917
  default:
29062
29918
  return "";
@@ -29065,7 +29921,7 @@ function renderStarted(item) {
29065
29921
  function renderCompleted(item) {
29066
29922
  switch (item.type) {
29067
29923
  case "agent_message": {
29068
- const said = str(item.text).trim();
29924
+ const said = str2(item.text).trim();
29069
29925
  return said ? `${said}
29070
29926
 
29071
29927
  ` : "";
@@ -29074,17 +29930,17 @@ function renderCompleted(item) {
29074
29930
  const changes = Array.isArray(item.changes) ? item.changes : [];
29075
29931
  return changes.map((raw) => {
29076
29932
  const change = obj(raw);
29077
- const path26 = str(change.path);
29078
- return path26 ? `\u23FA ${str(change.kind) || "change"}(${path26})
29933
+ const path31 = str2(change.path);
29934
+ return path31 ? `\u23FA ${str2(change.kind) || "change"}(${path31})
29079
29935
  ` : "";
29080
29936
  }).join("");
29081
29937
  }
29082
29938
  case "error":
29083
- return `[error] ${str(item.message)}
29939
+ return `[error] ${str2(item.message)}
29084
29940
  `;
29085
29941
  case "mcp_tool_call": {
29086
- const error = str(obj(item.error).message);
29087
- return error ? `[MCP ${str(item.server)}.${str(item.tool)}] ${error}
29942
+ const error = str2(obj(item.error).message);
29943
+ return error ? `[MCP ${str2(item.server)}.${str2(item.tool)}] ${error}
29088
29944
  ` : "";
29089
29945
  }
29090
29946
  default:
@@ -29099,52 +29955,52 @@ function unwrapShell(command) {
29099
29955
  function callOf(item) {
29100
29956
  switch (item.type) {
29101
29957
  case "command_execution":
29102
- return { title: "Command", target: unwrapShell(str(item.command)) };
29958
+ return { title: "Command", target: unwrapShell(str2(item.command)) };
29103
29959
  case "mcp_tool_call":
29104
- return { title: `${str(item.server)}.${str(item.tool)}`, target: "" };
29960
+ return { title: `${str2(item.server)}.${str2(item.tool)}`, target: "" };
29105
29961
  case "web_search":
29106
- return { title: "WebSearch", target: str(item.query) };
29962
+ return { title: "WebSearch", target: str2(item.query) };
29107
29963
  default: {
29108
- const changes = (Array.isArray(item.changes) ? item.changes : []).map((c) => str(obj(c).path)).filter(Boolean);
29964
+ const changes = (Array.isArray(item.changes) ? item.changes : []).map((c) => str2(obj(c).path)).filter(Boolean);
29109
29965
  return { title: "Edit", target: changes.join(", ") };
29110
29966
  }
29111
29967
  }
29112
29968
  }
29113
29969
  function callResult(item) {
29114
- if (item.type === "command_execution") return str(item.aggregated_output);
29970
+ if (item.type === "command_execution") return str2(item.aggregated_output);
29115
29971
  if (item.type === "mcp_tool_call") {
29116
- const error = str(obj(item.error).message);
29972
+ const error = str2(obj(item.error).message);
29117
29973
  if (error) return error;
29118
29974
  const content = obj(item.result).content;
29119
- return (Array.isArray(content) ? content : []).map((b) => str(obj(b).text)).filter(Boolean).join("\n");
29975
+ return (Array.isArray(content) ? content : []).map((b) => str2(obj(b).text)).filter(Boolean).join("\n");
29120
29976
  }
29121
29977
  if (item.type === "file_change") {
29122
- return (Array.isArray(item.changes) ? item.changes : []).map((c) => `${str(obj(c).kind) || "change"} ${str(obj(c).path)}`).join("\n");
29978
+ return (Array.isArray(item.changes) ? item.changes : []).map((c) => `${str2(obj(c).kind) || "change"} ${str2(obj(c).path)}`).join("\n");
29123
29979
  }
29124
29980
  return "";
29125
29981
  }
29126
29982
  function itemEvents(events, started, item, done) {
29127
- const id = str(item.id);
29983
+ const id = str2(item.id);
29128
29984
  if (item.type === "agent_message") {
29129
- if (done) events.message(str(item.text));
29985
+ if (done) events.message(str2(item.text));
29130
29986
  return;
29131
29987
  }
29132
29988
  if (item.type === "todo_list") {
29133
29989
  const items = Array.isArray(item.items) ? item.items : [];
29134
- events.plan(items.map(obj).map((t2) => ({ content: str(t2.text), status: t2.completed === true ? "completed" : "pending" })));
29990
+ events.plan(items.map(obj).map((t2) => ({ content: str2(t2.text), status: t2.completed === true ? "completed" : "pending" })));
29135
29991
  return;
29136
29992
  }
29137
29993
  if (item.type === "error") {
29138
- if (done) events.log(`${str(item.message)}
29994
+ if (done) events.log(`${str2(item.message)}
29139
29995
  `);
29140
29996
  return;
29141
29997
  }
29142
- const kind = CALLS[str(item.type)];
29998
+ const kind = CALLS[str2(item.type)];
29143
29999
  if (!kind) return;
29144
30000
  if (!started.has(id)) {
29145
30001
  started.add(id);
29146
- const call = callOf(item);
29147
- events.toolCall(id, call.title, kind, call.target);
30002
+ const call2 = callOf(item);
30003
+ events.toolCall(id, call2.title, kind, call2.target);
29148
30004
  }
29149
30005
  if (done) {
29150
30006
  const failed = item.status === "failed" || typeof item.exit_code === "number" && item.exit_code !== 0;
@@ -29168,12 +30024,12 @@ function createCodexStreamRenderer(carried = false) {
29168
30024
  lookedAt = at;
29169
30025
  facts = readCodexRunFacts(threadId) ?? facts;
29170
30026
  };
29171
- const turn = () => {
30027
+ const turn2 = () => {
29172
30028
  look(false);
29173
30029
  return total && facts?.turns?.filter((t2) => sameUsage(t2.total, total)).pop();
29174
30030
  };
29175
30031
  const own2 = () => {
29176
- const t2 = turn();
30032
+ const t2 = turn2();
29177
30033
  if (t2) return t2.own;
29178
30034
  return carried ? void 0 : total;
29179
30035
  };
@@ -29184,7 +30040,7 @@ function createCodexStreamRenderer(carried = false) {
29184
30040
  `;
29185
30041
  switch (ev.type) {
29186
30042
  case "thread.started":
29187
- if (!threadId) threadId = str(ev.thread_id).trim() || void 0;
30043
+ if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
29188
30044
  return "";
29189
30045
  case "item.started":
29190
30046
  itemEvents(events, started, obj(ev.item), false);
@@ -29196,7 +30052,7 @@ function createCodexStreamRenderer(carried = false) {
29196
30052
  const item = obj(ev.item);
29197
30053
  itemEvents(events, started, item, true);
29198
30054
  if (item.type === "agent_message") {
29199
- const said = str(item.text).trim();
30055
+ const said = str2(item.text).trim();
29200
30056
  if (said) final = said;
29201
30057
  }
29202
30058
  return renderCompleted(item);
@@ -29207,14 +30063,14 @@ function createCodexStreamRenderer(carried = false) {
29207
30063
  return "";
29208
30064
  // 最终失败保留;连接提示只在没有后续成功完成时才作为失败。
29209
30065
  case "turn.failed": {
29210
- const said = str(obj(ev.error).message) || failure2 || "Codex \u6267\u884C\u5931\u8D25";
30066
+ const said = str2(obj(ev.error).message) || failure2 || "Codex \u6267\u884C\u5931\u8D25";
29211
30067
  failure2 = said;
29212
30068
  events.error(said);
29213
30069
  return `[error] ${said}
29214
30070
  `;
29215
30071
  }
29216
30072
  case "error": {
29217
- const said = str(ev.message);
30073
+ const said = str2(ev.message);
29218
30074
  failure2 = said || failure2;
29219
30075
  events.log(`[Codex] ${said}
29220
30076
  `);
@@ -29249,7 +30105,7 @@ function createCodexStreamRenderer(carried = false) {
29249
30105
  // Worked out here rather than reported: the turn's own tokens at the model's list
29250
30106
  // rate, and nothing at all unless both the provider and the model are ones
29251
30107
  // whose rates the board knows.
29252
- costUsd: () => priceUsd(facts?.provider, turn()?.model ?? facts?.model, own2()),
30108
+ costUsd: () => priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()),
29253
30109
  resumeId: () => threadId,
29254
30110
  failure: () => failure2,
29255
30111
  events: events.events
@@ -29281,14 +30137,14 @@ function readIndex() {
29281
30137
  } catch {
29282
30138
  continue;
29283
30139
  }
29284
- const sessionId = str(record.sessionId).trim();
30140
+ const sessionId = str2(record.sessionId).trim();
29285
30141
  if (!sessionId) continue;
29286
30142
  if (record.deleted === true) {
29287
30143
  entries.delete(sessionId);
29288
30144
  continue;
29289
30145
  }
29290
- const sessionDir = str(record.sessionDir).trim();
29291
- const workDir = str(record.workDir).trim();
30146
+ const sessionDir = str2(record.sessionDir).trim();
30147
+ const workDir = str2(record.workDir).trim();
29292
30148
  if (sessionDir && workDir) entries.set(sessionId, { sessionId, sessionDir, workDir });
29293
30149
  }
29294
30150
  return entries;
@@ -29311,13 +30167,13 @@ function findKimiSession(cwd, since) {
29311
30167
  }
29312
30168
  function wireFiles(sessionDir) {
29313
30169
  const agents = join2(sessionDir, "agents");
29314
- let names;
30170
+ let names2;
29315
30171
  try {
29316
- names = readdirSync2(agents);
30172
+ names2 = readdirSync2(agents);
29317
30173
  } catch {
29318
30174
  return [{ path: join2(sessionDir, "wire.jsonl"), main: true }];
29319
30175
  }
29320
- const ordered = names.sort((a, b) => Number(b === "main") - Number(a === "main"));
30176
+ const ordered = names2.sort((a, b) => Number(b === "main") - Number(a === "main"));
29321
30177
  return ordered.map((name) => ({ path: join2(agents, name, "wire.jsonl"), main: name === "main" }));
29322
30178
  }
29323
30179
  function readKimiRunFacts(sessionId) {
@@ -29326,10 +30182,10 @@ function readKimiRunFacts(sessionId) {
29326
30182
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
29327
30183
  let model;
29328
30184
  let holding = 0;
29329
- for (const { path: path26, main } of wireFiles(entry2.sessionDir)) {
30185
+ for (const { path: path31, main } of wireFiles(entry2.sessionDir)) {
29330
30186
  let raw;
29331
30187
  try {
29332
- raw = readFileSync2(path26, "utf8");
30188
+ raw = readFileSync2(path31, "utf8");
29333
30189
  } catch {
29334
30190
  continue;
29335
30191
  }
@@ -29344,7 +30200,7 @@ function readKimiRunFacts(sessionId) {
29344
30200
  continue;
29345
30201
  }
29346
30202
  if (record.type !== "usage.record") continue;
29347
- model ??= str(record.model).trim() || void 0;
30203
+ model ??= str2(record.model).trim() || void 0;
29348
30204
  const usage = obj(record.usage);
29349
30205
  total.input += num(usage.inputOther);
29350
30206
  total.cacheCreation += num(usage.inputCacheCreation);
@@ -29368,10 +30224,10 @@ function readKimiRunFacts(sessionId) {
29368
30224
  // ../cli/src/lib/agent/wire/kimi-stream.ts
29369
30225
  var ARG_KEYS2 = ["command", "path", "pattern", "query", "url", "prompt", "prompt_template", "description"];
29370
30226
  function callArgs(raw) {
29371
- const text2 = str(raw);
29372
- if (!text2.trim()) return {};
30227
+ const text3 = str2(raw);
30228
+ if (!text3.trim()) return {};
29373
30229
  try {
29374
- return JSON.parse(text2);
30230
+ return JSON.parse(text3);
29375
30231
  } catch {
29376
30232
  return {};
29377
30233
  }
@@ -29387,15 +30243,15 @@ var kindOf = (name) => TOOL_KINDS3.find(([re]) => re.test(name))?.[1] ?? "other"
29387
30243
  function toolCalls(row) {
29388
30244
  const calls = Array.isArray(row.tool_calls) ? row.tool_calls : [];
29389
30245
  return calls.map((raw) => {
29390
- const call = obj(raw);
29391
- const fn = obj(call.function);
29392
- const name = str(fn.name) || "tool";
30246
+ const call2 = obj(raw);
30247
+ const fn = obj(call2.function);
30248
+ const name = str2(fn.name) || "tool";
29393
30249
  return `\u23FA ${name}${argHint(callArgs(fn.arguments), ARG_KEYS2)}
29394
30250
  `;
29395
30251
  }).join("");
29396
30252
  }
29397
30253
  function retry(row) {
29398
- const why = str(row.error_message) || str(row.error_name) || "the provider failed";
30254
+ const why = str2(row.error_message) || str2(row.error_name) || "the provider failed";
29399
30255
  const attempt = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
29400
30256
  return `[retry ${attempt}] ${why}
29401
30257
  `;
@@ -29423,18 +30279,18 @@ function createKimiStreamRenderer(cwd) {
29423
30279
  `;
29424
30280
  switch (row.role) {
29425
30281
  case "assistant": {
29426
- const said = str(row.content).trim();
30282
+ const said = str2(row.content).trim();
29427
30283
  if (said) final = said;
29428
30284
  if (said) events.message(said);
29429
30285
  for (const raw of Array.isArray(row.tool_calls) ? row.tool_calls : []) {
29430
- const call = obj(raw);
29431
- const name = str(obj(call.function).name) || "tool";
29432
- const args = obj(callArgs(obj(call.function).arguments));
30286
+ const call2 = obj(raw);
30287
+ const name = str2(obj(call2.function).name) || "tool";
30288
+ const args = obj(callArgs(obj(call2.function).arguments));
29433
30289
  if (name === "Agent") {
29434
- subagents.add(str(call.id));
29435
- events.subagent(str(call.id), str(args.description) || name);
30290
+ subagents.add(str2(call2.id));
30291
+ events.subagent(str2(call2.id), str2(args.description) || name);
29436
30292
  } else {
29437
- events.toolCall(str(call.id), name, kindOf(name), ARG_KEYS2.map((k) => str(args[k])).find((v) => v.trim()));
30293
+ events.toolCall(str2(call2.id), name, kindOf(name), ARG_KEYS2.map((k) => str2(args[k])).find((v) => v.trim()));
29438
30294
  }
29439
30295
  }
29440
30296
  return `${said ? `${said}
@@ -29442,13 +30298,13 @@ function createKimiStreamRenderer(cwd) {
29442
30298
  ` : ""}${toolCalls(row)}`;
29443
30299
  }
29444
30300
  case "meta":
29445
- if (row.type === "session.resume_hint") sessionId ??= str(row.session_id).trim() || void 0;
30301
+ if (row.type === "session.resume_hint") sessionId ??= str2(row.session_id).trim() || void 0;
29446
30302
  return row.type === "turn.step.retrying" ? retry(row) : "";
29447
30303
  case "tool": {
29448
- const id = str(row.tool_call_id);
29449
- const text2 = str(row.content);
29450
- if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(text2) ? "completed" : "failed", "");
29451
- else events.toolResult(id, "completed", text2);
30304
+ const id = str2(row.tool_call_id);
30305
+ const text3 = str2(row.content);
30306
+ if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(text3) ? "completed" : "failed", "");
30307
+ else events.toolResult(id, "completed", text3);
29452
30308
  return "";
29453
30309
  }
29454
30310
  default:
@@ -29485,7 +30341,7 @@ function createKimiStreamRenderer(cwd) {
29485
30341
  }
29486
30342
 
29487
30343
  // ../cli/src/lib/agent/wire/acp.ts
29488
- import fs14 from "node:fs";
30344
+ import fs19 from "node:fs";
29489
30345
 
29490
30346
  // ../cli/src/lib/agent/wire/rpc.ts
29491
30347
  var RpcError = class extends Error {
@@ -29536,7 +30392,7 @@ function connect(stdout, stdin, onCall, dialect = {}) {
29536
30392
  if (!pending) continue;
29537
30393
  waiting2.delete(String(msg.id));
29538
30394
  if (msg.error) {
29539
- const said = [str(msg.error.message), str(obj(msg.error.data).message)].filter(Boolean).join(": ");
30395
+ const said = [str2(msg.error.message), str2(obj(msg.error.data).message)].filter(Boolean).join(": ");
29540
30396
  pending.fail(new RpcError(said || `the agent refused (${msg.error.code ?? "no code"})`, msg.error.code));
29541
30397
  } else pending.ok(obj(msg.result));
29542
30398
  }
@@ -29599,9 +30455,9 @@ function createTail(log) {
29599
30455
  log(chunk);
29600
30456
  },
29601
30457
  /** One line about something that isn't the agent talking. */
29602
- line(text2) {
30458
+ line(text3) {
29603
30459
  close();
29604
- log(`${text2}
30460
+ log(`${text3}
29605
30461
  `);
29606
30462
  },
29607
30463
  /** End of the turn: whatever is half-written is finished off. */
@@ -29615,8 +30471,8 @@ function createTail(log) {
29615
30471
  // ../cli/package.json
29616
30472
  var package_default = {
29617
30473
  name: "wildcrane",
29618
- version: "0.11.38",
29619
- akbContract: 9,
30474
+ version: "0.11.40",
30475
+ akbContract: 11,
29620
30476
  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.",
29621
30477
  keywords: [
29622
30478
  "kanban",
@@ -29687,33 +30543,33 @@ var CLIENT_CAPABILITIES = {
29687
30543
  };
29688
30544
  function whereHint(update3, title) {
29689
30545
  const locations = Array.isArray(update3.locations) ? update3.locations : [];
29690
- const path26 = str(obj(locations[0]).path);
29691
- return path26 && !title.includes(path26) ? hint(path26) : "";
30546
+ const path31 = str2(obj(locations[0]).path);
30547
+ return path31 && !title.includes(path31) ? hint(path31) : "";
29692
30548
  }
29693
30549
  function saidBy(update3) {
29694
30550
  const content = Array.isArray(update3.content) ? update3.content : [];
29695
30551
  for (const raw of content) {
29696
30552
  const part = obj(raw);
29697
- const text2 = str(obj(part.content).text) || str(part.text);
29698
- if (text2.trim()) return text2.trim();
30553
+ const text3 = str2(obj(part.content).text) || str2(part.text);
30554
+ if (text3.trim()) return text3.trim();
29699
30555
  }
29700
30556
  return "";
29701
30557
  }
29702
30558
  function modelOf(answer) {
29703
- const current2 = str(obj(answer.models).currentModelId).trim();
30559
+ const current2 = str2(obj(answer.models).currentModelId).trim();
29704
30560
  if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
29705
30561
  const list = Array.isArray(answer.configOptions) ? answer.configOptions : [];
29706
30562
  for (const raw of list) {
29707
30563
  const option = obj(raw);
29708
- if (option.id === "model") return str(option.currentValue).trim() || void 0;
30564
+ if (option.id === "model") return str2(option.currentValue).trim() || void 0;
29709
30565
  }
29710
30566
  return void 0;
29711
30567
  }
29712
30568
  function modelsIn(answer) {
29713
30569
  const list = obj(answer.models).availableModels;
29714
30570
  return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
29715
- const modelId = str(m.modelId);
29716
- return modelId ? [{ modelId, name: str(m.name) || modelId }] : [];
30571
+ const modelId = str2(m.modelId);
30572
+ return modelId ? [{ modelId, name: str2(m.name) || modelId }] : [];
29717
30573
  });
29718
30574
  }
29719
30575
  function pickedModel(answer, wanted) {
@@ -29742,7 +30598,7 @@ function sessionGone(e) {
29742
30598
  var RESTARTED = "[board] that conversation is gone \u2014 the task was restarted in a new session\n";
29743
30599
  async function newSession(rpc, cwd, mcpServers) {
29744
30600
  const opened = await rpc.call("session/new", { cwd, mcpServers });
29745
- const sessionId = str(opened.sessionId);
30601
+ const sessionId = str2(opened.sessionId);
29746
30602
  if (!sessionId) throw new Error("the agent opened a session without giving it an id");
29747
30603
  return { opened, sessionId };
29748
30604
  }
@@ -29758,12 +30614,12 @@ var STOPPED = {
29758
30614
  cancelled: "the turn was cancelled"
29759
30615
  };
29760
30616
  function mcpServersIn(file2) {
29761
- const servers = obj(obj(JSON.parse(fs14.readFileSync(file2, "utf8"))).mcpServers);
30617
+ const servers = obj(obj(JSON.parse(fs19.readFileSync(file2, "utf8"))).mcpServers);
29762
30618
  return Object.entries(servers).map(([name, raw]) => {
29763
30619
  const s = obj(raw);
29764
30620
  return {
29765
30621
  name,
29766
- command: str(s.command),
30622
+ command: str2(s.command),
29767
30623
  args: Array.isArray(s.args) ? s.args.map(String) : [],
29768
30624
  env: Object.entries(obj(s.env)).map(([key, value]) => ({ name: key, value: String(value) }))
29769
30625
  };
@@ -29857,7 +30713,7 @@ async function oneTurn(io, options) {
29857
30713
  });
29858
30714
  const result = tail.end();
29859
30715
  events.end();
29860
- const stopReason = str(done.stopReason);
30716
+ const stopReason = str2(done.stopReason);
29861
30717
  const spent = obj(obj(done._meta).usage);
29862
30718
  const usage = usageOf2(done.usage) ?? usageOf2(spent, true);
29863
30719
  costUsd ??= ticksUsd(spent.costUsdTicks);
@@ -29885,20 +30741,20 @@ function update2(raw, tail, gotCost, gotContext) {
29885
30741
  const change = obj(raw);
29886
30742
  switch (change.sessionUpdate) {
29887
30743
  case "agent_message_chunk":
29888
- tail.text(str(obj(change.content).text));
30744
+ tail.text(str2(obj(change.content).text));
29889
30745
  return;
29890
30746
  case "agent_thought_chunk":
29891
- tail.thought(str(obj(change.content).text));
30747
+ tail.thought(str2(obj(change.content).text));
29892
30748
  return;
29893
30749
  case "tool_call": {
29894
- const title = str(change.title) || str(change.name) || "tool";
30750
+ const title = str2(change.title) || str2(change.name) || "tool";
29895
30751
  tail.line(`\u23FA ${title}${whereHint(change, title)}`);
29896
30752
  return;
29897
30753
  }
29898
30754
  case "tool_call_update": {
29899
30755
  if (change.status !== "failed") return;
29900
30756
  const why = saidBy(change);
29901
- tail.line(`[error] ${str(change.title) || "that tool call"} failed${why ? `: ${why}` : ""}`);
30757
+ tail.line(`[error] ${str2(change.title) || "that tool call"} failed${why ? `: ${why}` : ""}`);
29902
30758
  return;
29903
30759
  }
29904
30760
  case "usage_update": {
@@ -29907,7 +30763,7 @@ function update2(raw, tail, gotCost, gotContext) {
29907
30763
  if (used > 0) gotContext({ used, ...size > 0 ? { limit: size } : {} });
29908
30764
  const cost = obj(change.cost);
29909
30765
  const amount = cost.amount;
29910
- if (str(cost.currency).toUpperCase() === "USD" && typeof amount === "number" && Number.isFinite(amount) && amount > 0) {
30766
+ if (str2(cost.currency).toUpperCase() === "USD" && typeof amount === "number" && Number.isFinite(amount) && amount > 0) {
29911
30767
  gotCost(amount);
29912
30768
  }
29913
30769
  return;
@@ -29918,8 +30774,8 @@ function update2(raw, tail, gotCost, gotContext) {
29918
30774
  }
29919
30775
  function decide(params, tail, events) {
29920
30776
  const options = Array.isArray(params.options) ? params.options : [];
29921
- const no = options.map(obj).find((option) => str(option.kind).startsWith("reject"));
29922
- const title = str(obj(params.toolCall).title) || "that";
30777
+ const no = options.map(obj).find((option) => str2(option.kind).startsWith("reject"));
30778
+ const title = str2(obj(params.toolCall).title) || "that";
29923
30779
  const said = `[refused] ${title} \u2014 a run reaches no further than this project`;
29924
30780
  tail.line(said);
29925
30781
  events.log(`${said}
@@ -29929,11 +30785,11 @@ function decide(params, tail, events) {
29929
30785
  }
29930
30786
 
29931
30787
  // ../cli/src/lib/agent/wire/zcode.ts
29932
- import path15 from "node:path";
30788
+ import path21 from "node:path";
29933
30789
  function whereHint2(input, title) {
29934
30790
  const named = obj(input);
29935
30791
  for (const key of ["command", "file_path", "path", "url", "pattern"]) {
29936
- const value = str(named[key]).trim();
30792
+ const value = str2(named[key]).trim();
29937
30793
  if (value && !title.includes(value)) return hint(value);
29938
30794
  }
29939
30795
  return "";
@@ -29957,20 +30813,20 @@ var STOPPED2 = {
29957
30813
  };
29958
30814
  function modelOf2(ref) {
29959
30815
  const model = obj(ref);
29960
- const id = str(model.modelId);
30816
+ const id = str2(model.modelId);
29961
30817
  if (!id) return "";
29962
- const provider = str(model.providerId);
30818
+ const provider = str2(model.providerId);
29963
30819
  return provider ? `${provider}/${id}` : id;
29964
30820
  }
29965
30821
  function createParts(tail) {
29966
30822
  const written = /* @__PURE__ */ new Map();
29967
30823
  const tools = /* @__PURE__ */ new Set();
29968
30824
  const named = /* @__PURE__ */ new Map();
29969
- const say = (partId, kind, text2) => {
30825
+ const say = (partId, kind, text3) => {
29970
30826
  const before = written.get(partId) ?? "";
29971
- const fresh = text2.startsWith(before) ? text2.slice(before.length) : text2;
30827
+ const fresh = text3.startsWith(before) ? text3.slice(before.length) : text3;
29972
30828
  if (!fresh) return;
29973
- written.set(partId, text2);
30829
+ written.set(partId, text3);
29974
30830
  if (kind === "reasoning" || kind === "thought") tail.thought(fresh);
29975
30831
  else tail.text(fresh);
29976
30832
  };
@@ -29978,32 +30834,32 @@ function createParts(tail) {
29978
30834
  /** A whole part, as `part.started` or `part.upserted` sends it. */
29979
30835
  upsert(raw) {
29980
30836
  const part = obj(raw);
29981
- const type = str(part.type);
29982
- const partId = str(part.partId);
30837
+ const type = str2(part.type);
30838
+ const partId = str2(part.partId);
29983
30839
  if (type === "text" || type === "reasoning" || type === "thought") {
29984
- if (partId) say(partId, type, str(part.text));
29985
- else tail.text(str(part.text));
30840
+ if (partId) say(partId, type, str2(part.text));
30841
+ else tail.text(str2(part.text));
29986
30842
  return;
29987
30843
  }
29988
30844
  if (type !== "tool") return;
29989
30845
  const state = obj(part.state);
29990
- const callId = str(part.callId) || partId;
29991
- const title = str(state.title) || str(part.tool) || "tool";
30846
+ const callId = str2(part.callId) || partId;
30847
+ const title = str2(state.title) || str2(part.tool) || "tool";
29992
30848
  if (callId && !tools.has(callId)) {
29993
30849
  tools.add(callId);
29994
30850
  tail.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
29995
30851
  }
29996
- if (str(state.status) === "error") {
29997
- const why = str(state.error).trim();
30852
+ if (str2(state.status) === "error") {
30853
+ const why = str2(state.error).trim();
29998
30854
  tail.line(`[error] ${title} failed${why ? `: ${why}` : ""}`);
29999
30855
  }
30000
30856
  },
30001
30857
  /** A piece of one part, as `part.delta` sends it. */
30002
30858
  delta(event2) {
30003
- const field = str(event2.field) || "text";
30859
+ const field = str2(event2.field) || "text";
30004
30860
  if (field !== "text" && field !== "reasoning") return;
30005
- const partId = str(event2.partId);
30006
- const delta = str(event2.delta);
30861
+ const partId = str2(event2.partId);
30862
+ const delta = str2(event2.delta);
30007
30863
  if (!delta) return;
30008
30864
  written.set(partId, (written.get(partId) ?? "") + delta);
30009
30865
  if (field === "reasoning") tail.thought(delta);
@@ -30011,12 +30867,12 @@ function createParts(tail) {
30011
30867
  },
30012
30868
  /** A piece of the turn, as `model.streaming` sends it. */
30013
30869
  streaming(payload) {
30014
- const kind = str(payload.kind);
30015
- if (kind === "text_delta") return tail.text(str(payload.delta));
30016
- if (kind === "reasoning_delta") return tail.thought(str(payload.delta));
30870
+ const kind = str2(payload.kind);
30871
+ if (kind === "text_delta") return tail.text(str2(payload.delta));
30872
+ if (kind === "reasoning_delta") return tail.thought(str2(payload.delta));
30017
30873
  if (kind !== "tool_call") return;
30018
- const callId = str(payload.toolCallId);
30019
- const name = str(payload.toolName) || "tool";
30874
+ const callId = str2(payload.toolCallId);
30875
+ const name = str2(payload.toolName) || "tool";
30020
30876
  named.set(callId, name);
30021
30877
  if (callId && tools.has(callId)) return;
30022
30878
  tools.add(callId);
@@ -30026,9 +30882,9 @@ function createParts(tail) {
30026
30882
  * `batch` are progress on a call that already has its line; only `error` is worth a
30027
30883
  * second one. */
30028
30884
  toolUpdate(payload) {
30029
- if (str(payload.kind) !== "error") return;
30030
- const name = named.get(str(payload.toolCallId)) ?? "tool";
30031
- const why = str(obj(payload.error).message).split("\n")[0].trim();
30885
+ if (str2(payload.kind) !== "error") return;
30886
+ const name = named.get(str2(payload.toolCallId)) ?? "tool";
30887
+ const why = str2(obj(payload.error).message).split("\n")[0].trim();
30032
30888
  tail.line(`[error] ${name} failed${why ? `: ${why.slice(0, 200)}` : ""}`);
30033
30889
  }
30034
30890
  };
@@ -30066,7 +30922,7 @@ async function oneTurn2(io, options) {
30066
30922
  (msg) => {
30067
30923
  if (msg.method === "session/event") {
30068
30924
  const envelope = obj(msg.params);
30069
- if (str(envelope.sessionId) === sessionId) event(envelope, parts, tail, live, ended);
30925
+ if (str2(envelope.sessionId) === sessionId) event(envelope, parts, tail, live, ended);
30070
30926
  return;
30071
30927
  }
30072
30928
  if (msg.id === void 0) return;
@@ -30095,7 +30951,7 @@ async function oneTurn2(io, options) {
30095
30951
  { stringIds: true }
30096
30952
  );
30097
30953
  try {
30098
- const workspacePath = path15.resolve(io.cwd);
30954
+ const workspacePath = path21.resolve(io.cwd);
30099
30955
  const workspace = { workspacePath, workspaceKey: workspacePath };
30100
30956
  let opened;
30101
30957
  if (io.resumeId) {
@@ -30113,13 +30969,13 @@ async function oneTurn2(io, options) {
30113
30969
  // The session's name is the board's business, not a model call of its own.
30114
30970
  titleGenerationEnabled: false
30115
30971
  });
30116
- sessionId = str(obj(opened.session).sessionId);
30972
+ sessionId = str2(obj(opened.session).sessionId);
30117
30973
  if (!sessionId) throw new Error("the agent opened a session without giving it an id");
30118
30974
  io.gotResumeId(sessionId);
30119
30975
  }
30120
30976
  let model = modelOf2(obj(opened.session).model);
30121
30977
  if (options.model) {
30122
- const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId: str(obj(obj(opened.session).model).providerId) || "zai", modelId: options.model };
30978
+ const wanted = options.model.includes("/") ? { providerId: options.model.split("/")[0], modelId: options.model.split("/").slice(1).join("/") } : { providerId: str2(obj(obj(opened.session).model).providerId) || "zai", modelId: options.model };
30123
30979
  await rpc.call("session/setModel", { sessionId, model: wanted });
30124
30980
  model = modelOf2(wanted);
30125
30981
  }
@@ -30169,7 +31025,7 @@ async function contextOf(rpc, sessionId) {
30169
31025
  }
30170
31026
  function event(envelope, parts, tail, live, ended) {
30171
31027
  const payload = obj(envelope.payload);
30172
- switch (str(envelope.type)) {
31028
+ switch (str2(envelope.type)) {
30173
31029
  case "part.started":
30174
31030
  case "part.upserted":
30175
31031
  if (live) parts.upsert(payload.part);
@@ -30185,23 +31041,23 @@ function event(envelope, parts, tail, live, ended) {
30185
31041
  return;
30186
31042
  case "turn.completed": {
30187
31043
  const usage = usageOf3(obj(payload.usage));
30188
- const response = str(payload.response);
30189
- const how = str(payload.resultType) || "success";
31044
+ const response = str2(payload.response);
31045
+ const how = str2(payload.resultType) || "success";
30190
31046
  if (how === "success") return ended({ ok: true, response, usage });
30191
31047
  return ended({ ok: false, error: STOPPED2[how] ?? `the agent stopped: ${how}`, response, usage });
30192
31048
  }
30193
31049
  case "turn.failed": {
30194
31050
  const error = obj(payload.error);
30195
- return ended({ ok: false, error: str(error.message) || "the turn failed" });
31051
+ return ended({ ok: false, error: str2(error.message) || "the turn failed" });
30196
31052
  }
30197
31053
  case "session.closed":
30198
- return ended({ ok: false, error: str(payload.reason) || "the agent closed the session" });
31054
+ return ended({ ok: false, error: str2(payload.reason) || "the agent closed the session" });
30199
31055
  default:
30200
31056
  return;
30201
31057
  }
30202
31058
  }
30203
31059
  function decide2(params, tail) {
30204
- const tool = str(params.toolName) || "that";
31060
+ const tool = str2(params.toolName) || "that";
30205
31061
  tail.line(`[refused] ${tool} \u2014 your own ZCode rules ask before this one, and a run has nobody to ask`);
30206
31062
  return { decision: "deny", reason: "this board run can't answer a permission question" };
30207
31063
  }
@@ -30219,7 +31075,7 @@ function obj2(value) {
30219
31075
  function arr(value) {
30220
31076
  return Array.isArray(value) ? value : [];
30221
31077
  }
30222
- function str2(value) {
31078
+ function str3(value) {
30223
31079
  return typeof value === "string" ? value : "";
30224
31080
  }
30225
31081
  function num2(value) {
@@ -30230,23 +31086,23 @@ function uniqueIds(list) {
30230
31086
  }
30231
31087
  var cached = /* @__PURE__ */ new Map();
30232
31088
  function modelsIn2(file2, pick2, salt = "") {
30233
- let stamp;
31089
+ let stamp2;
30234
31090
  try {
30235
31091
  const stat = statSync3(file2);
30236
- stamp = `${stat.mtimeMs}:${stat.size}:${salt}`;
31092
+ stamp2 = `${stat.mtimeMs}:${stat.size}:${salt}`;
30237
31093
  } catch {
30238
31094
  cached.delete(file2);
30239
31095
  return [];
30240
31096
  }
30241
31097
  const hit = cached.get(file2);
30242
- if (hit?.stamp === stamp) return hit.found;
31098
+ if (hit?.stamp === stamp2) return hit.found;
30243
31099
  let found = [];
30244
31100
  try {
30245
31101
  found = uniqueIds(pick2(JSON.parse(readFileSync3(file2, "utf8"))));
30246
31102
  } catch {
30247
31103
  found = [];
30248
31104
  }
30249
- cached.set(file2, { stamp, found });
31105
+ cached.set(file2, { stamp: stamp2, found });
30250
31106
  return found;
30251
31107
  }
30252
31108
 
@@ -30273,22 +31129,22 @@ var PASSING = [
30273
31129
  ];
30274
31130
  var RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
30275
31131
  var REASON_MAX = 140;
30276
- function reasonLine(text2, rule) {
30277
- const line = text2.split("\n").find((l) => rule.test(l.toLowerCase())) ?? text2;
31132
+ function reasonLine(text3, rule) {
31133
+ const line = text3.split("\n").find((l) => rule.test(l.toLowerCase())) ?? text3;
30278
31134
  const said = line.trim().replace(/\s+/g, " ");
30279
31135
  return said.length > REASON_MAX ? `${said.slice(0, REASON_MAX - 1)}\u2026` : said;
30280
31136
  }
30281
31137
  function providerBlip(...said) {
30282
- for (const text2 of said) {
30283
- if (!text2?.trim()) continue;
30284
- const lower = text2.toLowerCase();
31138
+ for (const text3 of said) {
31139
+ if (!text3?.trim()) continue;
31140
+ const lower = text3.toLowerCase();
30285
31141
  if (MANUAL.some((rule) => rule.test(lower))) return void 0;
30286
31142
  const hit = PASSING.find((rule) => rule.test(lower));
30287
31143
  if (!hit) continue;
30288
- const asked = RETRY_AFTER.exec(text2);
31144
+ const asked = RETRY_AFTER.exec(text3);
30289
31145
  const seconds = asked ? Number(asked[1]) : NaN;
30290
31146
  return {
30291
- reason: reasonLine(text2, hit),
31147
+ reason: reasonLine(text3, hit),
30292
31148
  ...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
30293
31149
  };
30294
31150
  }
@@ -30307,15 +31163,15 @@ var userMessage = (prompt) => `${JSON.stringify({ type: "user", message: { role:
30307
31163
  `;
30308
31164
  function claudeOnWindows() {
30309
31165
  const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
30310
- const packages = local ? path16.join(local, "Packages") : "";
31166
+ const packages = local ? path22.join(local, "Packages") : "";
30311
31167
  const data = [
30312
- ...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path16.join(packages, name, "LocalCache", "Roaming", "Claude")),
30313
- ...roaming ? [path16.join(roaming, "Claude")] : []
31168
+ ...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path22.join(packages, name, "LocalCache", "Roaming", "Claude")),
31169
+ ...roaming ? [path22.join(roaming, "Claude")] : []
30314
31170
  ];
30315
31171
  return data.flatMap(
30316
- (dir) => latestIn(path16.join(dir, "claude-code")).flatMap((version) => [
30317
- path16.join(version, "claude.exe"),
30318
- ...folders(version).map((build) => path16.join(version, build, "claude.exe"))
31172
+ (dir) => latestIn(path22.join(dir, "claude-code")).flatMap((version) => [
31173
+ path22.join(version, "claude.exe"),
31174
+ ...folders(version).map((build) => path22.join(version, build, "claude.exe"))
30319
31175
  ])
30320
31176
  );
30321
31177
  }
@@ -30348,11 +31204,11 @@ var CLAUDE_CODE = {
30348
31204
  return [...claudeStreamArgs(argv), "--resume", resumeId, "--fork-session", "--session-id", sessionId];
30349
31205
  },
30350
31206
  // 默认快照会忽略续跑传入的新规则;仅显式关闭快照的会话支持更新。
30351
- systemPrompt(text2, argv) {
31207
+ systemPrompt(text3, argv) {
30352
31208
  if (namesFlag(argv, ["--append-system-prompt", "--append-system-prompt-file"])) return {};
30353
31209
  const snapshot = argv.flatMap((arg, i) => arg === "--system-prompt-snapshot" ? [argv[i + 1]] : arg.startsWith("--system-prompt-snapshot=") ? [arg.slice("--system-prompt-snapshot=".length)] : []).at(-1);
30354
31210
  if (namesFlag(argv, ["--resume", "-r", "--continue", "-c"]) && snapshot !== "off") return {};
30355
- return { args: ["--append-system-prompt", text2] };
31211
+ return { args: ["--append-system-prompt", text3] };
30356
31212
  },
30357
31213
  // What Claude Code takes: who pays for the run, where that run goes, a model id, and how
30358
31214
  // hard that model thinks. The provider comes first because it decides the rest — which
@@ -30488,7 +31344,7 @@ var CLAUDE_CODE = {
30488
31344
  ...MODEL_ALIASES,
30489
31345
  ...modelsIn2(
30490
31346
  home2(".claude.json"),
30491
- (data) => arr(obj2(data).additionalModelOptionsCache).map((option) => str2(obj2(option).value))
31347
+ (data) => arr(obj2(data).additionalModelOptionsCache).map((option) => str3(obj2(option).value))
30492
31348
  )
30493
31349
  ];
30494
31350
  },
@@ -30573,116 +31429,15 @@ var CLAUDE_CODE = {
30573
31429
  ...latestIn(home2(".local", "share", "claude", "versions")),
30574
31430
  // The copy Claude Desktop carries.
30575
31431
  ...process.platform === "win32" ? claudeOnWindows() : latestIn(home2("Library", "Application Support", "Claude", "claude-code")).flatMap(
30576
- (version) => folders(version).map((build) => path16.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
31432
+ (version) => folders(version).map((build) => path22.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
30577
31433
  )
30578
31434
  ],
30579
31435
  install: "npm install -g @anthropic-ai/claude-code"
30580
31436
  };
30581
31437
 
30582
31438
  // ../cli/src/lib/agent/harnesses/codex.ts
30583
- import fs15 from "node:fs";
30584
- import path18 from "node:path";
30585
-
30586
- // ../cli/src/lib/paths.ts
30587
- import path17 from "node:path";
30588
- var REPO_ROOT = "";
30589
- var KANBAN = "";
30590
- var TODO = "";
30591
- var ARCHIVE = "";
30592
- var ARCHIVE_MD = "";
30593
- var README = "";
30594
- var MODULES_MD = "";
30595
- var CONFIG = "";
30596
- var KANBAN_GITIGNORE = "";
30597
- var RELEASES = "";
30598
- var RELEASE_SUMMARIES = "";
30599
- var AGENTS = "";
30600
- var WORKFLOWS = "";
30601
- var LEGACY_AGENTS = "";
30602
- var ASSETS = "";
30603
- var BOARD_STATE = "";
30604
- var MOCKUPS = "";
30605
- var MEMORY = "";
30606
- var AGENT_MEMORY = "";
30607
- var PROJECT_MD = "";
30608
- var LOCK = "";
30609
- var UI_CONFIG = "";
30610
- var LEGACY_UI_CONFIG = "";
30611
- var LOCAL_CONFIG = "";
30612
- var ENV_FILE = "";
30613
- var SESSIONS = "";
30614
- var SESSIONS_DIR = "";
30615
- var SESSIONS_LOCK2 = "";
30616
- var INDEX_LOCK2 = "";
30617
- var DELIVERIES = "";
30618
- var PLANS = "";
30619
- var PLANS_ARCHIVE = "";
30620
- var RULES = "";
30621
- var TRIAGE = "";
30622
- var SIGNALS_ARCHIVED = "";
30623
- var SIGNALS_DISMISSED = "";
30624
- var SIGNALS_FILES = "";
30625
- var SIGNALS_OLD_INBOX = "";
30626
- var SIGNALS_OLD_HANDLED = "";
30627
- var AKB_DIR = "";
30628
- var ROOT_GITIGNORE = "";
30629
- function boardLockName(kanban, root) {
30630
- const from = path17.relative(root, kanban);
30631
- const name = from && !from.startsWith("..") ? from : path17.basename(kanban);
30632
- return `${name.split(path17.sep).join("-")}.lock`;
30633
- }
30634
- var BOARD_FLAG = "";
30635
- function setBoard(kanban, root, flag) {
30636
- REPO_ROOT = path17.resolve(root);
30637
- KANBAN = path17.resolve(kanban);
30638
- BOARD_FLAG = flag;
30639
- TODO = path17.join(KANBAN, "todo");
30640
- ARCHIVE = path17.join(KANBAN, ".archive");
30641
- ARCHIVE_MD = path17.join(KANBAN, "archive.md");
30642
- README = path17.join(TODO, "README.md");
30643
- MODULES_MD = path17.join(KANBAN, "modules.md");
30644
- CONFIG = path17.join(KANBAN, "config.md");
30645
- KANBAN_GITIGNORE = path17.join(KANBAN, ".gitignore");
30646
- RELEASES = path17.join(KANBAN, "releases.md");
30647
- RELEASE_SUMMARIES = path17.join(KANBAN, ".release-summaries");
30648
- AGENTS = path17.join(KANBAN, "agents");
30649
- WORKFLOWS = path17.join(KANBAN, "workflows");
30650
- LEGACY_AGENTS = path17.join(KANBAN, "skills");
30651
- MEMORY = path17.join(KANBAN, "memory");
30652
- AGENT_MEMORY = path17.join(MEMORY, "agents");
30653
- PROJECT_MD = path17.join(MEMORY, "project.md");
30654
- LEGACY_UI_CONFIG = path17.join(KANBAN, UI_CONFIG_FILE);
30655
- LOCAL_CONFIG = path17.join(KANBAN, ".local.json");
30656
- ENV_FILE = path17.join(KANBAN, ".env");
30657
- const machine = projectStateDir(KANBAN, REPO_ROOT);
30658
- BOARD_STATE = machine;
30659
- UI_CONFIG = path17.join(machine, UI_CONFIG_FILE);
30660
- ASSETS = path17.join(machine, ASSETS_FOLDER);
30661
- MOCKUPS = path17.join(machine, MOCKUPS_FOLDER);
30662
- SESSIONS = path17.join(machine, SESSIONS_FILE);
30663
- SESSIONS_DIR = path17.join(machine, SESSIONS_FOLDER);
30664
- SESSIONS_LOCK2 = path17.join(machine, SESSIONS_LOCK);
30665
- INDEX_LOCK2 = path17.join(machine, INDEX_LOCK);
30666
- DELIVERIES = path17.join(KANBAN, "deliveries");
30667
- RULES = path17.join(KANBAN, "rules");
30668
- PLANS = path17.join(machine, "plans");
30669
- PLANS_ARCHIVE = path17.join(PLANS, "archive");
30670
- TRIAGE = path17.join(KANBAN, "triage");
30671
- SIGNALS_ARCHIVED = path17.join(TRIAGE, "archived");
30672
- SIGNALS_DISMISSED = path17.join(TRIAGE, "dismissed");
30673
- SIGNALS_FILES = path17.join(TRIAGE, "files");
30674
- SIGNALS_OLD_INBOX = path17.join(TRIAGE, "inbox");
30675
- SIGNALS_OLD_HANDLED = path17.join(TRIAGE, "handled.md");
30676
- AKB_DIR = path17.join(REPO_ROOT, ".akb");
30677
- ROOT_GITIGNORE = path17.join(REPO_ROOT, ".gitignore");
30678
- LOCK = path17.join(AKB_DIR, boardLockName(KANBAN, REPO_ROOT));
30679
- return REPO_ROOT;
30680
- }
30681
- function setBoardRoot(root, named = false) {
30682
- const project = path17.resolve(root);
30683
- return setBoard(path17.join(project, "docs", "kanban"), project, named ? ` --dir ${project}` : "");
30684
- }
30685
- setBoardRoot(process.cwd());
31439
+ import fs20 from "node:fs";
31440
+ import path23 from "node:path";
30686
31441
 
30687
31442
  // ../cli/src/lib/agent/worktree.ts
30688
31443
  import { spawnSync as spawnSync3 } from "node:child_process";
@@ -30729,10 +31484,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
30729
31484
  }
30730
31485
  const flags = [...argv, ...extra];
30731
31486
  const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
30732
- if (workspaceWrite && path18.resolve(cwd) !== path18.resolve(REPO_ROOT)) {
31487
+ if (workspaceWrite && path23.resolve(cwd) !== path23.resolve(REPO_ROOT)) {
30733
31488
  for (const dir of [KANBAN, AKB_DIR]) {
30734
- const relative = path18.relative(cwd, dir);
30735
- if (relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
31489
+ const relative = path23.relative(cwd, dir);
31490
+ if (relative === ".." || relative.startsWith(`..${path23.sep}`) || path23.isAbsolute(relative)) {
30736
31491
  extra.push("--add-dir", dir);
30737
31492
  }
30738
31493
  }
@@ -30755,7 +31510,7 @@ function envRoot(name) {
30755
31510
  }
30756
31511
  function modified(file2) {
30757
31512
  try {
30758
- return fs15.statSync(file2).mtimeMs;
31513
+ return fs20.statSync(file2).mtimeMs;
30759
31514
  } catch {
30760
31515
  return 0;
30761
31516
  }
@@ -30781,28 +31536,28 @@ function codexOnWindows() {
30781
31536
  const local = envRoot("LOCALAPPDATA");
30782
31537
  const profile = envRoot("USERPROFILE");
30783
31538
  const programs = envRoot("ProgramFiles");
30784
- const cache = local ? path18.join(local, "OpenAI", "Codex", "bin") : "";
30785
- const releases = profile ? path18.join(profile, ".codex", "packages", "standalone", "releases") : "";
30786
- const packages = programs ? path18.join(programs, "WindowsApps") : "";
31539
+ const cache = local ? path23.join(local, "OpenAI", "Codex", "bin") : "";
31540
+ const releases = profile ? path23.join(profile, ".codex", "packages", "standalone", "releases") : "";
31541
+ const packages = programs ? path23.join(programs, "WindowsApps") : "";
30787
31542
  return [
30788
31543
  // Desktop's relocated CLI cache: a folder per build hash, newest file first.
30789
- ...byNewest(folders(cache).map((name) => path18.join(cache, name, "codex.exe"))),
31544
+ ...byNewest(folders(cache).map((name) => path23.join(cache, name, "codex.exe"))),
30790
31545
  // The separate standalone launcher, at a path with nothing variable in it.
30791
- ...local ? [path18.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
31546
+ ...local ? [path23.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
30792
31547
  // That launcher's release payload: a folder per version and target.
30793
31548
  ...byVersion(folders(releases).filter(ourArch)).map(
30794
- (name) => path18.join(releases, name, "bin", "codex.exe")
31549
+ (name) => path23.join(releases, name, "bin", "codex.exe")
30795
31550
  ),
30796
31551
  // Desktop's own MSIX package.
30797
31552
  ...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
30798
- (name) => path18.join(packages, name, "app", "resources", "codex.exe")
31553
+ (name) => path23.join(packages, name, "app", "resources", "codex.exe")
30799
31554
  )
30800
31555
  ];
30801
31556
  }
30802
31557
  function codexInstalls() {
30803
31558
  const chosen = process.env.CODEX_INSTALL_DIR?.trim();
30804
31559
  return [
30805
- ...chosen ? [path18.join(chosen, "codex")] : [],
31560
+ ...chosen ? [path23.join(chosen, "codex")] : [],
30806
31561
  ...process.platform === "win32" ? codexOnWindows() : [
30807
31562
  // macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
30808
31563
  "/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
@@ -30844,14 +31599,14 @@ var CODEX = {
30844
31599
  return [...codexExtraArgs(argv, cwd), "fork", resumeId];
30845
31600
  },
30846
31601
  // 自设系统指令保持原样;无法追加时由调用方明确提示。
30847
- systemPrompt(text2, argv) {
31602
+ systemPrompt(text3, argv) {
30848
31603
  if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
30849
31604
  try {
30850
- const config = fs15.readFileSync(path18.join(process.env.CODEX_HOME || home2(".codex"), "config.toml"), "utf8");
31605
+ const config = fs20.readFileSync(path23.join(process.env.CODEX_HOME || home2(".codex"), "config.toml"), "utf8");
30851
31606
  if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
30852
31607
  } catch {
30853
31608
  }
30854
- return { args: ["-c", `developer_instructions=${JSON.stringify(text2)}`] };
31609
+ return { args: ["-c", `developer_instructions=${JSON.stringify(text3)}`] };
30855
31610
  },
30856
31611
  // What Codex takes, in the order Claude Code's dialog draws the same four: who pays for
30857
31612
  // the run and where it goes, that endpoint's address, the key, a model, and how hard that
@@ -30969,7 +31724,7 @@ var CODEX = {
30969
31724
  models() {
30970
31725
  return modelsIn2(
30971
31726
  home2(".codex", "models_cache.json"),
30972
- (data) => arr(obj2(data).models).map(obj2).filter((model) => str2(model.visibility) !== "hide").sort((a, b) => num2(a.priority) - num2(b.priority)).map((model) => str2(model.slug))
31727
+ (data) => arr(obj2(data).models).map(obj2).filter((model) => str3(model.visibility) !== "hide").sort((a, b) => num2(a.priority) - num2(b.priority)).map((model) => str3(model.slug))
30973
31728
  );
30974
31729
  },
30975
31730
  // Nothing extra. Claude Code gets CLAUDE_CODE_MAX_RETRIES=0 so a rate limit fails at
@@ -31093,24 +31848,24 @@ var CURSOR = {
31093
31848
  };
31094
31849
 
31095
31850
  // ../cli/src/lib/agent/harnesses/dsh.ts
31096
- import fs16 from "node:fs";
31097
- import path19 from "node:path";
31851
+ import fs21 from "node:fs";
31852
+ import path24 from "node:path";
31098
31853
  function dshHome(argv) {
31099
31854
  const binary = argv[0];
31100
31855
  if (!binary) return void 0;
31101
- const names = process.platform === "win32" && !path19.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
31102
- const candidates2 = binary.includes("/") || binary.includes("\\") ? names : (process.env.PATH ?? "").split(path19.delimiter).filter(Boolean).flatMap((dir2) => names.map((name) => path19.join(dir2, name)));
31856
+ const names2 = process.platform === "win32" && !path24.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
31857
+ const candidates2 = binary.includes("/") || binary.includes("\\") ? names2 : (process.env.PATH ?? "").split(path24.delimiter).filter(Boolean).flatMap((dir2) => names2.map((name) => path24.join(dir2, name)));
31103
31858
  let dir;
31104
31859
  try {
31105
- const found = candidates2.find((candidate) => fs16.existsSync(candidate));
31860
+ const found = candidates2.find((candidate) => fs21.existsSync(candidate));
31106
31861
  if (!found) return void 0;
31107
- const script = /\.cmd$/i.test(found) ? shimTarget(fs16.readFileSync(found, "utf8"), found)?.script : void 0;
31108
- dir = path19.dirname(fs16.realpathSync(script ?? found));
31862
+ const script = /\.cmd$/i.test(found) ? shimTarget(fs21.readFileSync(found, "utf8"), found)?.script : void 0;
31863
+ dir = path24.dirname(fs21.realpathSync(script ?? found));
31109
31864
  } catch {
31110
31865
  return void 0;
31111
31866
  }
31112
- for (let up = path19.dirname(dir); dir !== up; up = path19.dirname(dir)) {
31113
- if (fs16.existsSync(path19.join(dir, "package.json"))) return dir;
31867
+ for (let up = path24.dirname(dir); dir !== up; up = path24.dirname(dir)) {
31868
+ if (fs21.existsSync(path24.join(dir, "package.json"))) return dir;
31114
31869
  dir = up;
31115
31870
  }
31116
31871
  return void 0;
@@ -31174,11 +31929,11 @@ var DSH = {
31174
31929
  // dsh-acp's persona IS its system prompt, so the ask is added to the one in effect: the
31175
31930
  // user's own `DSH_SYSTEM_PROMPT`, else the bridge's default. A `--persona` on the command
31176
31931
  // line outranks both, and is left alone.
31177
- systemPrompt(text2, argv, env2) {
31932
+ systemPrompt(text3, argv, env2) {
31178
31933
  if (namesFlag(argv, ["--persona"])) return {};
31179
31934
  return { env: { DSH_SYSTEM_PROMPT: `${env2.DSH_SYSTEM_PROMPT || DSH_PERSONA}
31180
31935
 
31181
- ${text2}` } };
31936
+ ${text3}` } };
31182
31937
  },
31183
31938
  // ACP carries all three in the conversation itself (agent/wire/acp.ts), so a dsh run shows a
31184
31939
  // price, its tokens and the model the session opened on.
@@ -31229,8 +31984,8 @@ var GROK = {
31229
31984
  return [];
31230
31985
  },
31231
31986
  // `--rules` appends to Grok's system prompt. A top-level option, so it goes before `agent`.
31232
- systemPrompt(text2, argv) {
31233
- return namesFlag(argv, ["--rules"]) ? {} : { args: ["--rules", text2] };
31987
+ systemPrompt(text3, argv) {
31988
+ return namesFlag(argv, ["--rules"]) ? {} : { args: ["--rules", text3] };
31234
31989
  },
31235
31990
  // What Grok takes: a model, and the xAI key. Both boxes can stay empty — someone already
31236
31991
  // set up with grok has a login in `~/.grok` and a default model in its own
@@ -31337,7 +32092,7 @@ var KIMI = {
31337
32092
  },
31338
32093
  // An agent file wrapping Kimi's own prompt in `${base_prompt}`. Only a new session takes one;
31339
32094
  // a resumed one keeps the agent it opened with, and Kimi refuses the flag beside `--session`.
31340
- systemPrompt(text2, argv) {
32095
+ systemPrompt(text3, argv) {
31341
32096
  if (namesFlag(argv, ["--session", "-S", "--resume", "-r", "--continue", "-C", "--agent", "--agent-file"])) return {};
31342
32097
  const file2 = machineFile("kimi-language.md", `---
31343
32098
  name: akb-language
@@ -31346,7 +32101,7 @@ description: Kimi's default agent, told which language to write in
31346
32101
 
31347
32102
  \${base_prompt}
31348
32103
 
31349
- ${text2}
32104
+ ${text3}
31350
32105
  `);
31351
32106
  return { args: ["--agent-file", file2] };
31352
32107
  },
@@ -31567,8 +32322,8 @@ var OPENCODE = {
31567
32322
  env: () => ({ ...process.env }),
31568
32323
  // `instructions` files join the system prompt, and OpenCode adds this config's list to the
31569
32324
  // user's own rather than replacing it.
31570
- systemPrompt(text2, _argv, env2) {
31571
- const file2 = machineFile("opencode-language.md", `${text2}
32325
+ systemPrompt(text3, _argv, env2) {
32326
+ const file2 = machineFile("opencode-language.md", `${text3}
31572
32327
  `);
31573
32328
  let own2 = {};
31574
32329
  try {
@@ -31743,11 +32498,11 @@ async function detectRuntimes(quick = false, only) {
31743
32498
  const harness = HARNESSES2[name];
31744
32499
  const settings = harness.settings.map(declOf);
31745
32500
  await warm(harness);
31746
- const copy = locate(harness);
31747
- if (!copy) return { name, installed: false, settings };
31748
- const loggedIn = harness.login ? await probeLogin(spawnName(copy, splitCommand(harness.command)[0]), harness) : void 0;
32501
+ const copy2 = locate(harness);
32502
+ if (!copy2) return { name, installed: false, settings };
32503
+ const loggedIn = harness.login ? await probeLogin(spawnName(copy2, splitCommand(harness.command)[0]), harness) : void 0;
31749
32504
  const models = loggedIn === false || quick && SLOW.has(name) ? [] : await readModels(name);
31750
- return { name, installed: true, ...copy.version ? { version: copy.version } : {}, ...loggedIn === void 0 ? {} : { loggedIn }, ...models.length ? { models } : {}, settings };
32505
+ return { name, installed: true, ...copy2.version ? { version: copy2.version } : {}, ...loggedIn === void 0 ? {} : { loggedIn }, ...models.length ? { models } : {}, settings };
31751
32506
  })
31752
32507
  );
31753
32508
  }
@@ -31756,14 +32511,14 @@ var listed = (harness) => async () => (harness.models?.() ?? []).map((id) => ({
31756
32511
  var readModels = (name) => (MODELS[name] ?? listed(HARNESSES2[name]))().catch(() => []);
31757
32512
  var MODELS = {
31758
32513
  "claude-code": async () => {
31759
- const cached2 = claudeModels(path20.join(process.env.CLAUDE_CONFIG_DIR || path20.join(os5.homedir(), ".claude"), "cache", "model-catalog"));
32514
+ const cached2 = claudeModels(path25.join(process.env.CLAUDE_CONFIG_DIR || path25.join(os5.homedir(), ".claude"), "cache", "model-catalog"));
31760
32515
  return cached2.length ? cached2 : [
31761
32516
  { id: "opus", name: "Opus" },
31762
32517
  { id: "sonnet", name: "Sonnet" },
31763
32518
  { id: "haiku", name: "Haiku" }
31764
32519
  ];
31765
32520
  },
31766
- codex: async () => codexModels(path20.join(process.env.CODEX_HOME || path20.join(os5.homedir(), ".codex"), "models_cache.json")),
32521
+ codex: async () => codexModels(path25.join(process.env.CODEX_HOME || path25.join(os5.homedir(), ".codex"), "models_cache.json")),
31767
32522
  opencode: async () => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"])),
31768
32523
  cursor: () => cursorModels()
31769
32524
  };
@@ -31794,8 +32549,8 @@ function cursorModels() {
31794
32549
  function acpModels(opened) {
31795
32550
  const list = obj(opened.models).availableModels;
31796
32551
  return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
31797
- const id = str(m.modelId);
31798
- return id && id !== "default[]" ? [{ id, name: str(m.name) || id }] : [];
32552
+ const id = str2(m.modelId);
32553
+ return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
31799
32554
  });
31800
32555
  }
31801
32556
  function output(command, args) {
@@ -31819,7 +32574,7 @@ function output(command, args) {
31819
32574
  }
31820
32575
  function codexModels(file2) {
31821
32576
  try {
31822
- const cache = JSON.parse(fs17.readFileSync(file2, "utf8"));
32577
+ const cache = JSON.parse(fs22.readFileSync(file2, "utf8"));
31823
32578
  if (!Array.isArray(cache.models)) return [];
31824
32579
  return cache.models.flatMap(
31825
32580
  (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 }] : []
@@ -31831,15 +32586,15 @@ function codexModels(file2) {
31831
32586
  function claudeModels(dir) {
31832
32587
  let files;
31833
32588
  try {
31834
- files = fs17.readdirSync(dir).filter((f) => f.endsWith(".json"));
32589
+ files = fs22.readdirSync(dir).filter((f) => f.endsWith(".json"));
31835
32590
  } catch {
31836
32591
  return [];
31837
32592
  }
31838
32593
  const catalogs = files.flatMap((f) => {
31839
32594
  try {
31840
- const data = obj(JSON.parse(fs17.readFileSync(path20.join(dir, f), "utf8")));
32595
+ const data = obj(JSON.parse(fs22.readFileSync(path25.join(dir, f), "utf8")));
31841
32596
  const catalog = obj(data.catalog);
31842
- const surface = str(catalog.surface);
32597
+ const surface = str2(catalog.surface);
31843
32598
  return surface === "cc" || surface === "ccd" ? [{ surface, at: Number(data.fetchedAt) || 0, config: obj(catalog.config) }] : [];
31844
32599
  } catch {
31845
32600
  return [];
@@ -31850,11 +32605,11 @@ function claudeModels(dir) {
31850
32605
  const aliases = obj(newest2.config.provider_alias_targets);
31851
32606
  const models = Array.isArray(newest2.config.models) ? newest2.config.models : [];
31852
32607
  return models.map(obj).flatMap((m) => {
31853
- const id = str(m.id);
32608
+ const id = str2(m.id);
31854
32609
  if (!id || m.section !== "main") return [];
31855
- const family = str(obj(m.runtime).family);
31856
- const alias = family && str(obj(aliases[family]).default) === id ? family : "";
31857
- return [{ id: alias || id, name: str(m.short_name) || str(m.name) || id }];
32610
+ const family = str2(obj(m.runtime).family);
32611
+ const alias = family && str2(obj(aliases[family]).default) === id ? family : "";
32612
+ return [{ id: alias || id, name: str2(m.short_name) || str2(m.name) || id }];
31858
32613
  });
31859
32614
  }
31860
32615
  function probeLogin(binary, harness) {
@@ -31880,55 +32635,55 @@ function probeLogin(binary, harness) {
31880
32635
  }
31881
32636
 
31882
32637
  // src/akb.ts
31883
- import fs18 from "node:fs";
31884
- import path21 from "node:path";
31885
- import { fileURLToPath, pathToFileURL } from "node:url";
31886
- var akbHome = () => path21.join(runnerHome(), "bin", "akb");
32638
+ import fs23 from "node:fs";
32639
+ import path26 from "node:path";
32640
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
32641
+ var akbHome = () => path26.join(runnerHome(), "bin", "akb");
31887
32642
  var BUNDLED_SHIM = `bundled-${AKB_VERSION}`;
31888
- var HERE = path21.dirname(fileURLToPath(import.meta.url));
32643
+ var HERE = path26.dirname(fileURLToPath2(import.meta.url));
31889
32644
  function akbArgs(entry2, dist = HERE) {
31890
- const preload = path21.join(dist, "akb-proxy.mjs");
31891
- return fs18.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry2] : [entry2];
32645
+ const preload = path26.join(dist, "akb-proxy.mjs");
32646
+ return fs23.existsSync(preload) ? ["--import", pathToFileURL(preload).href, entry2] : [entry2];
31892
32647
  }
31893
32648
  var bundledAkb = (dist = HERE) => ({
31894
32649
  command: process.execPath,
31895
- args: akbArgs(path21.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
32650
+ args: akbArgs(path26.join(dist, "akb", "bin", "ai4kanban.mjs"), dist),
31896
32651
  version: AKB_VERSION,
31897
- shim: path21.join(akbHome(), BUNDLED_SHIM)
32652
+ shim: path26.join(akbHome(), BUNDLED_SHIM)
31898
32653
  });
31899
32654
  var quote = (s) => /^[\w./:@=-]+$/.test(s) ? s : `"${s}"`;
31900
32655
  function shimDir(akb) {
31901
32656
  const dir = akb.shim;
31902
32657
  const line = [akb.command, ...akb.args].map(quote).join(" ");
31903
- const [file2, text2] = process.platform === "win32" ? [path21.join(dir, "akb.cmd"), `@${line} %*\r
31904
- `] : [path21.join(dir, "akb"), `#!/bin/sh
32658
+ const [file2, text3] = process.platform === "win32" ? [path26.join(dir, "akb.cmd"), `@${line} %*\r
32659
+ `] : [path26.join(dir, "akb"), `#!/bin/sh
31905
32660
  exec ${line} "$@"
31906
32661
  `];
31907
32662
  if (process.platform === "win32") {
31908
- fs18.mkdirSync(dir, { recursive: true });
32663
+ fs23.mkdirSync(dir, { recursive: true });
31909
32664
  const shellLine = [akb.command, ...akb.args].map((s) => `'${s.replaceAll("\\", "/").replaceAll("'", "'\\''")}'`).join(" ");
31910
- fs18.writeFileSync(path21.join(dir, "akb"), `#!/bin/sh
32665
+ fs23.writeFileSync(path26.join(dir, "akb"), `#!/bin/sh
31911
32666
  exec ${shellLine} "$@"
31912
32667
  `, { mode: 493 });
31913
32668
  }
31914
32669
  try {
31915
- if (fs18.readFileSync(file2, "utf8") === text2) return dir;
32670
+ if (fs23.readFileSync(file2, "utf8") === text3) return dir;
31916
32671
  } catch {
31917
32672
  }
31918
- fs18.mkdirSync(dir, { recursive: true });
31919
- fs18.writeFileSync(file2, text2, { mode: 493 });
32673
+ fs23.mkdirSync(dir, { recursive: true });
32674
+ fs23.writeFileSync(file2, text3, { mode: 493 });
31920
32675
  return dir;
31921
32676
  }
31922
32677
  var KEEP2 = 256 * 1024;
31923
32678
 
31924
32679
  // src/lock.ts
31925
- import crypto6 from "node:crypto";
32680
+ import crypto7 from "node:crypto";
31926
32681
  import net from "node:net";
31927
- import path22 from "node:path";
32682
+ import path27 from "node:path";
31928
32683
  function lockPath() {
31929
32684
  const home3 = runnerHome();
31930
- if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${crypto6.createHash("sha256").update(home3).digest("hex").slice(0, 16)}`;
31931
- return path22.join(home3, "runner.sock");
32685
+ if (process.platform === "win32") return `\\\\.\\pipe\\wildcrane-${crypto7.createHash("sha256").update(home3).digest("hex").slice(0, 16)}`;
32686
+ return path27.join(home3, "runner.sock");
31932
32687
  }
31933
32688
  function runnerSettingsSupport() {
31934
32689
  return new Promise((resolve2) => {
@@ -31958,31 +32713,31 @@ function runnerSettingsSupport() {
31958
32713
 
31959
32714
  // src/signin.ts
31960
32715
  import { spawn as spawn6 } from "node:child_process";
31961
- import crypto7 from "node:crypto";
32716
+ import crypto8 from "node:crypto";
31962
32717
  import http2 from "node:http";
31963
32718
 
31964
32719
  // src/settings-control.ts
31965
- import fs19 from "node:fs";
31966
- import path23 from "node:path";
31967
- var directory = () => path23.join(runnerHome(), "executors");
31968
- var epochFile = () => path23.join(runnerHome(), "account-generation");
32720
+ import fs24 from "node:fs";
32721
+ import path28 from "node:path";
32722
+ var directory = () => path28.join(runnerHome(), "executors");
32723
+ var epochFile = () => path28.join(runnerHome(), "account-generation");
31969
32724
  function accountGeneration() {
31970
32725
  try {
31971
- return fs19.readFileSync(epochFile(), "utf8");
32726
+ return fs24.readFileSync(epochFile(), "utf8");
31972
32727
  } catch {
31973
32728
  return "";
31974
32729
  }
31975
32730
  }
31976
32731
  async function stopExecutors() {
31977
- fs19.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
31978
- fs19.writeFileSync(epochFile(), `${Date.now()}-${process.pid}`, { mode: 384 });
32732
+ fs24.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
32733
+ fs24.writeFileSync(epochFile(), `${Date.now()}-${process.pid}`, { mode: 384 });
31979
32734
  for (let n = 0; n < 160; n++) {
31980
- const active = fs19.existsSync(directory()) ? fs19.readdirSync(directory()).filter((name) => {
32735
+ const active = fs24.existsSync(directory()) ? fs24.readdirSync(directory()).filter((name) => {
31981
32736
  try {
31982
32737
  process.kill(Number(name.split(".")[0]), 0);
31983
32738
  return true;
31984
32739
  } catch {
31985
- fs19.rmSync(path23.join(directory(), name), { force: true });
32740
+ fs24.rmSync(path28.join(directory(), name), { force: true });
31986
32741
  return false;
31987
32742
  }
31988
32743
  }) : [];
@@ -32064,8 +32819,8 @@ var PAGE = (outcome, lang, links) => {
32064
32819
  };
32065
32820
  async function signIn(options = {}) {
32066
32821
  const generation = accountGeneration();
32067
- const verifier = base64url(crypto7.randomBytes(32));
32068
- const challenge = base64url(crypto7.createHash("sha256").update(verifier).digest());
32822
+ const verifier = base64url(crypto8.randomBytes(32));
32823
+ const challenge = base64url(crypto8.createHash("sha256").update(verifier).digest());
32069
32824
  let finish = () => {
32070
32825
  };
32071
32826
  const answered = new Promise((resolve2) => finish = resolve2);
@@ -32079,7 +32834,7 @@ async function signIn(options = {}) {
32079
32834
  return;
32080
32835
  }
32081
32836
  if (req.method === "POST" && (asked.pathname === "/send" || asked.pathname === "/verify") && !answering) {
32082
- const asks = await readJson(req);
32837
+ const asks = await readJson2(req);
32083
32838
  const answer = asked.pathname === "/send" ? await sendCode(asks.email ?? "", lang) : await verifyCode(asks.email ?? "", asks.code ?? "", generation, options.signal);
32084
32839
  const done = answer.ok && asked.pathname === "/verify";
32085
32840
  res.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
@@ -32145,9 +32900,9 @@ async function exchange(code, verifier, generation, signal) {
32145
32900
  writeSession(session);
32146
32901
  return null;
32147
32902
  }
32148
- var authCall = (path26, body) => {
32903
+ var authCall = (path31, body) => {
32149
32904
  const { api, anonKey } = cloudEndpoints();
32150
- return fetch(`${api}/auth/v1/${path26}`, {
32905
+ return fetch(`${api}/auth/v1/${path31}`, {
32151
32906
  method: "POST",
32152
32907
  headers: { apikey: anonKey, "content-type": "application/json" },
32153
32908
  body: JSON.stringify(body),
@@ -32177,14 +32932,14 @@ async function verifyCode(email, code, generation, signal) {
32177
32932
  writeSession(session);
32178
32933
  return { ok: true };
32179
32934
  }
32180
- async function readJson(req) {
32181
- let text2 = "";
32935
+ async function readJson2(req) {
32936
+ let text3 = "";
32182
32937
  for await (const chunk of req) {
32183
- text2 += chunk;
32184
- if (text2.length > 1e4) break;
32938
+ text3 += chunk;
32939
+ if (text3.length > 1e4) break;
32185
32940
  }
32186
32941
  try {
32187
- return JSON.parse(text2);
32942
+ return JSON.parse(text3);
32188
32943
  } catch {
32189
32944
  return {};
32190
32945
  }
@@ -32197,18 +32952,18 @@ function openBrowser2(url) {
32197
32952
  } catch {
32198
32953
  }
32199
32954
  }
32200
- var base64url = (bytes) => bytes.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
32955
+ var base64url = (bytes2) => bytes2.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
32201
32956
 
32202
32957
  // src/settings.ts
32203
- var failure = (call) => ({ error: call.code ?? "offline", message: call.error });
32958
+ var failure = (call2) => ({ error: call2.code ?? "offline", message: call2.error });
32204
32959
  var signing = null;
32205
32960
  var signAbort = null;
32206
32961
  var stopping = false;
32207
32962
  var callback = () => {
32208
32963
  };
32209
32964
  var notify = () => {
32210
- fs20.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
32211
- fs20.writeFileSync(path24.join(runnerHome(), "settings-refresh"), crypto8.randomUUID(), { mode: 384 });
32965
+ fs25.mkdirSync(runnerHome(), { recursive: true, mode: 448 });
32966
+ fs25.writeFileSync(path29.join(runnerHome(), "settings-refresh"), crypto9.randomUUID(), { mode: 384 });
32212
32967
  callback();
32213
32968
  };
32214
32969
  var onSettingsChange = (next) => {
@@ -32250,7 +33005,7 @@ async function folderOf(cwd) {
32250
33005
  if (!list.ok) return { ...failure(list), folders: [], folder: null };
32251
33006
  const real = (dir) => {
32252
33007
  try {
32253
- return fs20.realpathSync(dir);
33008
+ return fs25.realpathSync(dir);
32254
33009
  } catch {
32255
33010
  return dir;
32256
33011
  }
@@ -32263,13 +33018,13 @@ async function addFolder2(dir, bind, strict = false) {
32263
33018
  const subject = readSession().subject;
32264
33019
  const why = refusal(dir);
32265
33020
  if (why) return { error: why };
32266
- const real = fs20.realpathSync(dir);
33021
+ const real = fs25.realpathSync(dir);
32267
33022
  const found = await folderOf(real);
32268
33023
  if ("error" in found) return found;
32269
33024
  let project = found.folder?.project;
32270
33025
  if (found.folder && (bind ? bind !== project : strict)) return { error: "folder_taken", message: "taken", name: found.folder.name };
32271
33026
  if (!project) {
32272
- const added = await addFolder(machineId(), path24.basename(real) || real, real, bind);
33027
+ const added = await addFolder(machineId(), path29.basename(real) || real, real, bind);
32273
33028
  if (!added.ok) return failure(added);
32274
33029
  project = added.value.folder.project;
32275
33030
  }
@@ -32304,7 +33059,7 @@ async function removeFolder2(project) {
32304
33059
  }
32305
33060
  function akbFile() {
32306
33061
  try {
32307
- return path24.join(shimDir(bundledAkb()), process.platform === "win32" ? "akb.cmd" : "akb");
33062
+ return path29.join(shimDir(bundledAkb()), process.platform === "win32" ? "akb.cmd" : "akb");
32308
33063
  } catch {
32309
33064
  return null;
32310
33065
  }
@@ -32355,7 +33110,7 @@ async function settingsState(context) {
32355
33110
  account,
32356
33111
  connected: runner.ok && runner.value.runner?.connected,
32357
33112
  workspaces: workspaces.value,
32358
- projects: folders2.value.folders.map((f) => ({ ...f, ...metadata(f.project), busy: kept(f.path), missing: !fs20.existsSync(f.path) })),
33113
+ projects: folders2.value.folders.map((f) => ({ ...f, ...metadata(f.project), busy: kept(f.path), missing: !fs25.existsSync(f.path) })),
32359
33114
  elsewhere: projects.filter((p) => !p.general && !folders2.value.folders.some((f) => f.project === p.id)).map((p) => ({ project: p.id, name: p.name, ...metadata(p.id) })),
32360
33115
  ...context.project && !projects.some((p) => p.id === context.project) ? { error: "not_found" } : {}
32361
33116
  };
@@ -32387,9 +33142,9 @@ async function settingsAction(action, body, context) {
32387
33142
  if (!dir) return { cancelled: true };
32388
33143
  const why = refusal(dir);
32389
33144
  if (why) return { error: why };
32390
- const real = fs20.realpathSync(dir);
33145
+ const real = fs25.realpathSync(dir);
32391
33146
  selected.set(context, { path: real, subject: readSession().subject });
32392
- return { path: real, name: path24.basename(real) };
33147
+ return { path: real, name: path29.basename(real) };
32393
33148
  } catch {
32394
33149
  return { error: "picker_unavailable" };
32395
33150
  }
@@ -32416,7 +33171,7 @@ async function settingsAction(action, body, context) {
32416
33171
  if ("error" in found) return found;
32417
33172
  if (found.folder) return { error: "folder_taken" };
32418
33173
  if (choice.subject !== readSession()?.subject) return { error: "signed_out" };
32419
- if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key: crypto8.randomUUID(), name, workspace: body.workspace };
33174
+ if (!choice.creation || choice.creation.name !== name || choice.creation.workspace !== body.workspace) choice.creation = { key: crypto9.randomUUID(), name, workspace: body.workspace };
32420
33175
  const created = choice.creation.project ? { ok: true, value: { id: choice.creation.project } } : await createProject(name, body.workspace, choice.creation.key);
32421
33176
  if (!created.ok) return failure(created);
32422
33177
  project = created.value.id;
@@ -32463,7 +33218,7 @@ async function terminalSettings(entry2) {
32463
33218
 
32464
33219
  // src/launcher-main.ts
32465
33220
  useRunnerHome();
32466
- var entry = path25.join(path25.dirname(fileURLToPath2(import.meta.url)), "runner.mjs");
33221
+ var entry = path30.join(path30.dirname(fileURLToPath3(import.meta.url)), "runner.mjs");
32467
33222
  if (process.argv.includes("--settings")) {
32468
33223
  terminalSettings(entry).catch(() => {
32469
33224
  process.stderr.write("\u65E0\u6CD5\u6253\u5F00\u672C\u673A\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002\n");