wildcrane-runner 0.6.103 → 0.6.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.103 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.104 — 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;
@@ -1159,14 +1159,14 @@ var require_util = __commonJS({
1159
1159
  }
1160
1160
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
1161
1161
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
1162
- let path54 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
1162
+ let path55 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
1163
1163
  if (origin[origin.length - 1] === "/") {
1164
1164
  origin = origin.slice(0, origin.length - 1);
1165
1165
  }
1166
- if (path54 && path54[0] !== "/") {
1167
- path54 = `/${path54}`;
1166
+ if (path55 && path55[0] !== "/") {
1167
+ path55 = `/${path55}`;
1168
1168
  }
1169
- return new URL(`${origin}${path54}`);
1169
+ return new URL(`${origin}${path55}`);
1170
1170
  }
1171
1171
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
1172
1172
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -2001,9 +2001,9 @@ var require_diagnostics = __commonJS({
2001
2001
  "undici:client:sendHeaders",
2002
2002
  (evt) => {
2003
2003
  const {
2004
- request: { method, path: path54, origin }
2004
+ request: { method, path: path55, origin }
2005
2005
  } = evt;
2006
- debugLog("sending request to %s %s%s", method, origin, path54);
2006
+ debugLog("sending request to %s %s%s", method, origin, path55);
2007
2007
  }
2008
2008
  );
2009
2009
  }
@@ -2021,14 +2021,14 @@ var require_diagnostics = __commonJS({
2021
2021
  "undici:request:headers",
2022
2022
  (evt) => {
2023
2023
  const {
2024
- request: { method, path: path54, origin },
2024
+ request: { method, path: path55, origin },
2025
2025
  response: { statusCode }
2026
2026
  } = evt;
2027
2027
  debugLog(
2028
2028
  "received response to %s %s%s - HTTP %d",
2029
2029
  method,
2030
2030
  origin,
2031
- path54,
2031
+ path55,
2032
2032
  statusCode
2033
2033
  );
2034
2034
  }
@@ -2037,23 +2037,23 @@ var require_diagnostics = __commonJS({
2037
2037
  "undici:request:trailers",
2038
2038
  (evt) => {
2039
2039
  const {
2040
- request: { method, path: path54, origin }
2040
+ request: { method, path: path55, origin }
2041
2041
  } = evt;
2042
- debugLog("trailers received from %s %s%s", method, origin, path54);
2042
+ debugLog("trailers received from %s %s%s", method, origin, path55);
2043
2043
  }
2044
2044
  );
2045
2045
  diagnosticsChannel.subscribe(
2046
2046
  "undici:request:error",
2047
2047
  (evt) => {
2048
2048
  const {
2049
- request: { method, path: path54, origin },
2049
+ request: { method, path: path55, origin },
2050
2050
  error: error62
2051
2051
  } = evt;
2052
2052
  debugLog(
2053
2053
  "request to %s %s%s errored - %s",
2054
2054
  method,
2055
2055
  origin,
2056
- path54,
2056
+ path55,
2057
2057
  error62.message
2058
2058
  );
2059
2059
  }
@@ -2168,7 +2168,7 @@ var require_request = __commonJS({
2168
2168
  var kHandler = /* @__PURE__ */ Symbol("handler");
2169
2169
  var Request = class {
2170
2170
  constructor(origin, {
2171
- path: path54,
2171
+ path: path55,
2172
2172
  method,
2173
2173
  body,
2174
2174
  headers,
@@ -2185,11 +2185,11 @@ var require_request = __commonJS({
2185
2185
  maxRedirections,
2186
2186
  typeOfService
2187
2187
  }, handler) {
2188
- if (typeof path54 !== "string") {
2188
+ if (typeof path55 !== "string") {
2189
2189
  throw new InvalidArgumentError("path must be a string");
2190
- } else if (path54[0] !== "/" && !(path54.startsWith("http://") || path54.startsWith("https://")) && method !== "CONNECT") {
2190
+ } else if (path55[0] !== "/" && !(path55.startsWith("http://") || path55.startsWith("https://")) && method !== "CONNECT") {
2191
2191
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
2192
- } else if (invalidPathRegex.test(path54)) {
2192
+ } else if (invalidPathRegex.test(path55)) {
2193
2193
  throw new InvalidArgumentError("invalid request path");
2194
2194
  }
2195
2195
  if (typeof method !== "string") {
@@ -2264,7 +2264,7 @@ var require_request = __commonJS({
2264
2264
  this.completed = false;
2265
2265
  this.aborted = false;
2266
2266
  this.upgrade = upgrade || null;
2267
- this.path = query ? serializePathWithQuery(path54, query) : path54;
2267
+ this.path = query ? serializePathWithQuery(path55, query) : path55;
2268
2268
  this.origin = origin;
2269
2269
  this.protocol = getProtocolFromUrlString(origin);
2270
2270
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -7508,7 +7508,7 @@ var require_client_h1 = __commonJS({
7508
7508
  }
7509
7509
  }
7510
7510
  function writeH1(client, request2) {
7511
- const { method, path: path54, host, upgrade, blocking, reset } = request2;
7511
+ const { method, path: path55, host, upgrade, blocking, reset } = request2;
7512
7512
  let { body, headers, contentLength } = request2;
7513
7513
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
7514
7514
  if (util.isFormDataLike(body)) {
@@ -7584,7 +7584,7 @@ var require_client_h1 = __commonJS({
7584
7584
  socket[kBlocking] = true;
7585
7585
  }
7586
7586
  setTypeOfService(socket, request2);
7587
- let header = `${method} ${path54} HTTP/1.1\r
7587
+ let header = `${method} ${path55} HTTP/1.1\r
7588
7588
  `;
7589
7589
  if (typeof host === "string") {
7590
7590
  header += `host: ${host}\r
@@ -8261,7 +8261,7 @@ var require_client_h2 = __commonJS({
8261
8261
  const headersTimeout = request2.headersTimeout ?? client[kHeadersTimeout];
8262
8262
  const bodyTimeout = request2.bodyTimeout ?? client[kBodyTimeout];
8263
8263
  const session = client[kHTTP2Session];
8264
- const { method, path: path54, host, upgrade, expectContinue, signal: signal2, protocol, headers: reqHeaders } = request2;
8264
+ const { method, path: path55, host, upgrade, expectContinue, signal: signal2, protocol, headers: reqHeaders } = request2;
8265
8265
  let { body } = request2;
8266
8266
  if (upgrade != null && upgrade !== "websocket") {
8267
8267
  util.errorRequest(client, request2, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -8330,7 +8330,7 @@ var require_client_h2 = __commonJS({
8330
8330
  }
8331
8331
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
8332
8332
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
8333
- headers[HTTP2_HEADER_PATH] = path54;
8333
+ headers[HTTP2_HEADER_PATH] = path55;
8334
8334
  if (protocol === "ws:" || protocol === "wss:") {
8335
8335
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
8336
8336
  } else {
@@ -8382,7 +8382,7 @@ var require_client_h2 = __commonJS({
8382
8382
  stream.setTimeout(headersTimeout);
8383
8383
  return true;
8384
8384
  }
8385
- headers[HTTP2_HEADER_PATH] = path54;
8385
+ headers[HTTP2_HEADER_PATH] = path55;
8386
8386
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
8387
8387
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
8388
8388
  if (body && typeof body.read === "function") {
@@ -10738,10 +10738,10 @@ var require_proxy_agent = __commonJS({
10738
10738
  };
10739
10739
  const {
10740
10740
  origin,
10741
- path: path54 = "/",
10741
+ path: path55 = "/",
10742
10742
  headers = {}
10743
10743
  } = opts;
10744
- opts.path = origin + path54;
10744
+ opts.path = origin + path55;
10745
10745
  if (!("host" in headers) && !("Host" in headers)) {
10746
10746
  const { host } = new URL(origin);
10747
10747
  headers.host = host;
@@ -12901,20 +12901,20 @@ var require_mock_utils = __commonJS({
12901
12901
  }
12902
12902
  return normalizedQp;
12903
12903
  }
12904
- function safeUrl(path54) {
12905
- if (typeof path54 !== "string") {
12906
- return path54;
12904
+ function safeUrl(path55) {
12905
+ if (typeof path55 !== "string") {
12906
+ return path55;
12907
12907
  }
12908
- const pathSegments = path54.split("?", 3);
12908
+ const pathSegments = path55.split("?", 3);
12909
12909
  if (pathSegments.length !== 2) {
12910
- return path54;
12910
+ return path55;
12911
12911
  }
12912
12912
  const qp = new URLSearchParams(pathSegments.pop());
12913
12913
  qp.sort();
12914
12914
  return [...pathSegments, qp.toString()].join("?");
12915
12915
  }
12916
- function matchKey(mockDispatch2, { path: path54, method, body, headers }) {
12917
- const pathMatch = matchValue(mockDispatch2.path, path54);
12916
+ function matchKey(mockDispatch2, { path: path55, method, body, headers }) {
12917
+ const pathMatch = matchValue(mockDispatch2.path, path55);
12918
12918
  const methodMatch = matchValue(mockDispatch2.method, method);
12919
12919
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
12920
12920
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -12939,8 +12939,8 @@ var require_mock_utils = __commonJS({
12939
12939
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
12940
12940
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
12941
12941
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
12942
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path54, ignoreTrailingSlash }) => {
12943
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path54)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path54), resolvedPath);
12942
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path55, ignoreTrailingSlash }) => {
12943
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path55)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path55), resolvedPath);
12944
12944
  });
12945
12945
  if (matchedMockDispatches.length === 0) {
12946
12946
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -12979,19 +12979,19 @@ var require_mock_utils = __commonJS({
12979
12979
  mockDispatches.splice(index, 1);
12980
12980
  }
12981
12981
  }
12982
- function removeTrailingSlash(path54) {
12983
- while (path54.endsWith("/")) {
12984
- path54 = path54.slice(0, -1);
12982
+ function removeTrailingSlash(path55) {
12983
+ while (path55.endsWith("/")) {
12984
+ path55 = path55.slice(0, -1);
12985
12985
  }
12986
- if (path54.length === 0) {
12987
- path54 = "/";
12986
+ if (path55.length === 0) {
12987
+ path55 = "/";
12988
12988
  }
12989
- return path54;
12989
+ return path55;
12990
12990
  }
12991
12991
  function buildKey(opts) {
12992
- const { path: path54, method, body, headers, query } = opts;
12992
+ const { path: path55, method, body, headers, query } = opts;
12993
12993
  return {
12994
- path: path54,
12994
+ path: path55,
12995
12995
  method,
12996
12996
  body,
12997
12997
  headers,
@@ -13681,10 +13681,10 @@ var require_pending_interceptors_formatter = __commonJS({
13681
13681
  }
13682
13682
  format(pendingInterceptors) {
13683
13683
  const withPrettyHeaders = pendingInterceptors.map(
13684
- ({ method, path: path54, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13684
+ ({ method, path: path55, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13685
13685
  Method: method,
13686
13686
  Origin: origin,
13687
- Path: path54,
13687
+ Path: path55,
13688
13688
  "Status code": statusCode,
13689
13689
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
13690
13690
  Invocations: timesInvoked,
@@ -13766,9 +13766,9 @@ var require_mock_agent = __commonJS({
13766
13766
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
13767
13767
  const dispatchOpts = { ...opts };
13768
13768
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
13769
- const [path54, searchParams] = dispatchOpts.path.split("?");
13769
+ const [path55, searchParams] = dispatchOpts.path.split("?");
13770
13770
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
13771
- dispatchOpts.path = `${path54}?${normalizedSearchParams}`;
13771
+ dispatchOpts.path = `${path55}?${normalizedSearchParams}`;
13772
13772
  }
13773
13773
  return this[kAgent].dispatch(dispatchOpts, handler);
13774
13774
  }
@@ -14169,12 +14169,12 @@ var require_snapshot_recorder = __commonJS({
14169
14169
  * @return {Promise<void>} - Resolves when snapshots are loaded
14170
14170
  */
14171
14171
  async loadSnapshots(filePath) {
14172
- const path54 = filePath || this.#snapshotPath;
14173
- if (!path54) {
14172
+ const path55 = filePath || this.#snapshotPath;
14173
+ if (!path55) {
14174
14174
  throw new InvalidArgumentError("Snapshot path is required");
14175
14175
  }
14176
14176
  try {
14177
- const data = await readFile2(resolve2(path54), "utf8");
14177
+ const data = await readFile2(resolve2(path55), "utf8");
14178
14178
  const parsed = JSON.parse(data);
14179
14179
  if (Array.isArray(parsed)) {
14180
14180
  this.#snapshots.clear();
@@ -14188,7 +14188,7 @@ var require_snapshot_recorder = __commonJS({
14188
14188
  if (error62.code === "ENOENT") {
14189
14189
  this.#snapshots.clear();
14190
14190
  } else {
14191
- throw new UndiciError(`Failed to load snapshots from ${path54}`, { cause: error62 });
14191
+ throw new UndiciError(`Failed to load snapshots from ${path55}`, { cause: error62 });
14192
14192
  }
14193
14193
  }
14194
14194
  }
@@ -14199,11 +14199,11 @@ var require_snapshot_recorder = __commonJS({
14199
14199
  * @returns {Promise<void>} - Resolves when snapshots are saved
14200
14200
  */
14201
14201
  async saveSnapshots(filePath) {
14202
- const path54 = filePath || this.#snapshotPath;
14203
- if (!path54) {
14202
+ const path55 = filePath || this.#snapshotPath;
14203
+ if (!path55) {
14204
14204
  throw new InvalidArgumentError("Snapshot path is required");
14205
14205
  }
14206
- const resolvedPath = resolve2(path54);
14206
+ const resolvedPath = resolve2(path55);
14207
14207
  await mkdir2(dirname(resolvedPath), { recursive: true });
14208
14208
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
14209
14209
  hash: hash2,
@@ -14844,15 +14844,15 @@ var require_redirect_handler = __commonJS({
14844
14844
  receivedAt: Date.now()
14845
14845
  });
14846
14846
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
14847
- const path54 = search ? `${pathname}${search}` : pathname;
14848
- const redirectUrlString = `${origin}${path54}`;
14847
+ const path55 = search ? `${pathname}${search}` : pathname;
14848
+ const redirectUrlString = `${origin}${path55}`;
14849
14849
  for (const historyUrl of this.history) {
14850
14850
  if (historyUrl.toString() === redirectUrlString) {
14851
14851
  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.`);
14852
14852
  }
14853
14853
  }
14854
14854
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
14855
- this.opts.path = path54;
14855
+ this.opts.path = path55;
14856
14856
  this.opts.origin = origin;
14857
14857
  this.opts.query = null;
14858
14858
  }
@@ -16669,10 +16669,10 @@ var require_cache_handler = __commonJS({
16669
16669
  }
16670
16670
  return locationUrl.pathname + locationUrl.search;
16671
16671
  }
16672
- function deleteCachedUri(store, cacheKey, path54) {
16672
+ function deleteCachedUri(store, cacheKey, path55) {
16673
16673
  deleteCachedValue(store, {
16674
16674
  ...cacheKey,
16675
- path: path54
16675
+ path: path55
16676
16676
  });
16677
16677
  for (let i = 0; i < util.safeHTTPMethods.length; i++) {
16678
16678
  const method = util.safeHTTPMethods[i];
@@ -16680,7 +16680,7 @@ var require_cache_handler = __commonJS({
16680
16680
  deleteCachedValue(store, {
16681
16681
  ...cacheKey,
16682
16682
  method,
16683
- path: path54
16683
+ path: path55
16684
16684
  });
16685
16685
  }
16686
16686
  }
@@ -16691,9 +16691,9 @@ var require_cache_handler = __commonJS({
16691
16691
  }
16692
16692
  const values = Array.isArray(headerValue) ? headerValue : [headerValue];
16693
16693
  for (let i = 0; i < values.length; i++) {
16694
- const path54 = getSameOriginPath(cacheKey, values[i]);
16695
- if (path54 !== void 0) {
16696
- deleteCachedUri(store, cacheKey, path54);
16694
+ const path55 = getSameOriginPath(cacheKey, values[i]);
16695
+ if (path55 !== void 0) {
16696
+ deleteCachedUri(store, cacheKey, path55);
16697
16697
  }
16698
16698
  }
16699
16699
  }
@@ -22181,11 +22181,11 @@ var require_fetch = __commonJS({
22181
22181
  function dispatch({ body }) {
22182
22182
  const url2 = requestCurrentURL(request2);
22183
22183
  const agent = fetchParams.controller.dispatcher;
22184
- const path54 = url2.pathname + url2.search;
22184
+ const path55 = url2.pathname + url2.search;
22185
22185
  const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
22186
22186
  return new Promise((resolve2, reject) => agent.dispatch(
22187
22187
  {
22188
- path: hasTrailingQuestionMark ? `${path54}?` : path54,
22188
+ path: hasTrailingQuestionMark ? `${path55}?` : path55,
22189
22189
  origin: url2.origin,
22190
22190
  method: request2.method,
22191
22191
  body: agent.isMockActive ? request2.body && (request2.body.source || request2.body.stream) : body,
@@ -23132,9 +23132,9 @@ var require_util4 = __commonJS({
23132
23132
  }
23133
23133
  }
23134
23134
  }
23135
- function validateCookiePath(path54) {
23136
- for (let i = 0; i < path54.length; ++i) {
23137
- const code = path54.charCodeAt(i);
23135
+ function validateCookiePath(path55) {
23136
+ for (let i = 0; i < path55.length; ++i) {
23137
+ const code = path55.charCodeAt(i);
23138
23138
  if (code < 32 || // exclude CTLs (0-31)
23139
23139
  code > 126 || // exclude DEL and non-ascii
23140
23140
  code === 59) {
@@ -26570,11 +26570,11 @@ var require_undici = __commonJS({
26570
26570
  if (typeof opts.path !== "string") {
26571
26571
  throw new InvalidArgumentError("invalid opts.path");
26572
26572
  }
26573
- let path54 = opts.path;
26573
+ let path55 = opts.path;
26574
26574
  if (!opts.path.startsWith("/")) {
26575
- path54 = `/${path54}`;
26575
+ path55 = `/${path55}`;
26576
26576
  }
26577
- url2 = new URL(util.parseOrigin(url2).origin + path54);
26577
+ url2 = new URL(util.parseOrigin(url2).origin + path55);
26578
26578
  } else {
26579
26579
  if (!opts) {
26580
26580
  opts = typeof url2 === "object" ? url2 : {};
@@ -26760,17 +26760,17 @@ var require_visit = __commonJS({
26760
26760
  visit2.BREAK = BREAK;
26761
26761
  visit2.SKIP = SKIP;
26762
26762
  visit2.REMOVE = REMOVE;
26763
- function visit_(key, node2, visitor, path54) {
26764
- const ctrl = callVisitor(key, node2, visitor, path54);
26763
+ function visit_(key, node2, visitor, path55) {
26764
+ const ctrl = callVisitor(key, node2, visitor, path55);
26765
26765
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
26766
- replaceNode(key, path54, ctrl);
26767
- return visit_(key, ctrl, visitor, path54);
26766
+ replaceNode(key, path55, ctrl);
26767
+ return visit_(key, ctrl, visitor, path55);
26768
26768
  }
26769
26769
  if (typeof ctrl !== "symbol") {
26770
26770
  if (identity.isCollection(node2)) {
26771
- path54 = Object.freeze(path54.concat(node2));
26771
+ path55 = Object.freeze(path55.concat(node2));
26772
26772
  for (let i = 0; i < node2.items.length; ++i) {
26773
- const ci2 = visit_(i, node2.items[i], visitor, path54);
26773
+ const ci2 = visit_(i, node2.items[i], visitor, path55);
26774
26774
  if (typeof ci2 === "number")
26775
26775
  i = ci2 - 1;
26776
26776
  else if (ci2 === BREAK)
@@ -26781,13 +26781,13 @@ var require_visit = __commonJS({
26781
26781
  }
26782
26782
  }
26783
26783
  } else if (identity.isPair(node2)) {
26784
- path54 = Object.freeze(path54.concat(node2));
26785
- const ck = visit_("key", node2.key, visitor, path54);
26784
+ path55 = Object.freeze(path55.concat(node2));
26785
+ const ck = visit_("key", node2.key, visitor, path55);
26786
26786
  if (ck === BREAK)
26787
26787
  return BREAK;
26788
26788
  else if (ck === REMOVE)
26789
26789
  node2.key = null;
26790
- const cv = visit_("value", node2.value, visitor, path54);
26790
+ const cv = visit_("value", node2.value, visitor, path55);
26791
26791
  if (cv === BREAK)
26792
26792
  return BREAK;
26793
26793
  else if (cv === REMOVE)
@@ -26808,17 +26808,17 @@ var require_visit = __commonJS({
26808
26808
  visitAsync.BREAK = BREAK;
26809
26809
  visitAsync.SKIP = SKIP;
26810
26810
  visitAsync.REMOVE = REMOVE;
26811
- async function visitAsync_(key, node2, visitor, path54) {
26812
- const ctrl = await callVisitor(key, node2, visitor, path54);
26811
+ async function visitAsync_(key, node2, visitor, path55) {
26812
+ const ctrl = await callVisitor(key, node2, visitor, path55);
26813
26813
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
26814
- replaceNode(key, path54, ctrl);
26815
- return visitAsync_(key, ctrl, visitor, path54);
26814
+ replaceNode(key, path55, ctrl);
26815
+ return visitAsync_(key, ctrl, visitor, path55);
26816
26816
  }
26817
26817
  if (typeof ctrl !== "symbol") {
26818
26818
  if (identity.isCollection(node2)) {
26819
- path54 = Object.freeze(path54.concat(node2));
26819
+ path55 = Object.freeze(path55.concat(node2));
26820
26820
  for (let i = 0; i < node2.items.length; ++i) {
26821
- const ci2 = await visitAsync_(i, node2.items[i], visitor, path54);
26821
+ const ci2 = await visitAsync_(i, node2.items[i], visitor, path55);
26822
26822
  if (typeof ci2 === "number")
26823
26823
  i = ci2 - 1;
26824
26824
  else if (ci2 === BREAK)
@@ -26829,13 +26829,13 @@ var require_visit = __commonJS({
26829
26829
  }
26830
26830
  }
26831
26831
  } else if (identity.isPair(node2)) {
26832
- path54 = Object.freeze(path54.concat(node2));
26833
- const ck = await visitAsync_("key", node2.key, visitor, path54);
26832
+ path55 = Object.freeze(path55.concat(node2));
26833
+ const ck = await visitAsync_("key", node2.key, visitor, path55);
26834
26834
  if (ck === BREAK)
26835
26835
  return BREAK;
26836
26836
  else if (ck === REMOVE)
26837
26837
  node2.key = null;
26838
- const cv = await visitAsync_("value", node2.value, visitor, path54);
26838
+ const cv = await visitAsync_("value", node2.value, visitor, path55);
26839
26839
  if (cv === BREAK)
26840
26840
  return BREAK;
26841
26841
  else if (cv === REMOVE)
@@ -26862,23 +26862,23 @@ var require_visit = __commonJS({
26862
26862
  }
26863
26863
  return visitor;
26864
26864
  }
26865
- function callVisitor(key, node2, visitor, path54) {
26865
+ function callVisitor(key, node2, visitor, path55) {
26866
26866
  if (typeof visitor === "function")
26867
- return visitor(key, node2, path54);
26867
+ return visitor(key, node2, path55);
26868
26868
  if (identity.isMap(node2))
26869
- return visitor.Map?.(key, node2, path54);
26869
+ return visitor.Map?.(key, node2, path55);
26870
26870
  if (identity.isSeq(node2))
26871
- return visitor.Seq?.(key, node2, path54);
26871
+ return visitor.Seq?.(key, node2, path55);
26872
26872
  if (identity.isPair(node2))
26873
- return visitor.Pair?.(key, node2, path54);
26873
+ return visitor.Pair?.(key, node2, path55);
26874
26874
  if (identity.isScalar(node2))
26875
- return visitor.Scalar?.(key, node2, path54);
26875
+ return visitor.Scalar?.(key, node2, path55);
26876
26876
  if (identity.isAlias(node2))
26877
- return visitor.Alias?.(key, node2, path54);
26877
+ return visitor.Alias?.(key, node2, path55);
26878
26878
  return void 0;
26879
26879
  }
26880
- function replaceNode(key, path54, node2) {
26881
- const parent = path54[path54.length - 1];
26880
+ function replaceNode(key, path55, node2) {
26881
+ const parent = path55[path55.length - 1];
26882
26882
  if (identity.isCollection(parent)) {
26883
26883
  parent.items[key] = node2;
26884
26884
  } else if (identity.isPair(parent)) {
@@ -27490,10 +27490,10 @@ var require_Collection = __commonJS({
27490
27490
  var createNode = require_createNode();
27491
27491
  var identity = require_identity();
27492
27492
  var Node = require_Node();
27493
- function collectionFromPath(schema, path54, value) {
27493
+ function collectionFromPath(schema, path55, value) {
27494
27494
  let v = value;
27495
- for (let i = path54.length - 1; i >= 0; --i) {
27496
- const k2 = path54[i];
27495
+ for (let i = path55.length - 1; i >= 0; --i) {
27496
+ const k2 = path55[i];
27497
27497
  if (typeof k2 === "number" && Number.isInteger(k2) && k2 >= 0) {
27498
27498
  const a2 = [];
27499
27499
  a2[k2] = v;
@@ -27512,7 +27512,7 @@ var require_Collection = __commonJS({
27512
27512
  sourceObjects: /* @__PURE__ */ new Map()
27513
27513
  });
27514
27514
  }
27515
- var isEmptyPath = (path54) => path54 == null || typeof path54 === "object" && !!path54[Symbol.iterator]().next().done;
27515
+ var isEmptyPath = (path55) => path55 == null || typeof path55 === "object" && !!path55[Symbol.iterator]().next().done;
27516
27516
  var Collection = class extends Node.NodeBase {
27517
27517
  constructor(type, schema) {
27518
27518
  super(type);
@@ -27542,11 +27542,11 @@ var require_Collection = __commonJS({
27542
27542
  * be a Pair instance or a `{ key, value }` object, which may not have a key
27543
27543
  * that already exists in the map.
27544
27544
  */
27545
- addIn(path54, value) {
27546
- if (isEmptyPath(path54))
27545
+ addIn(path55, value) {
27546
+ if (isEmptyPath(path55))
27547
27547
  this.add(value);
27548
27548
  else {
27549
- const [key, ...rest] = path54;
27549
+ const [key, ...rest] = path55;
27550
27550
  const node2 = this.get(key, true);
27551
27551
  if (identity.isCollection(node2))
27552
27552
  node2.addIn(rest, value);
@@ -27560,8 +27560,8 @@ var require_Collection = __commonJS({
27560
27560
  * Removes a value from the collection.
27561
27561
  * @returns `true` if the item was found and removed.
27562
27562
  */
27563
- deleteIn(path54) {
27564
- const [key, ...rest] = path54;
27563
+ deleteIn(path55) {
27564
+ const [key, ...rest] = path55;
27565
27565
  if (rest.length === 0)
27566
27566
  return this.delete(key);
27567
27567
  const node2 = this.get(key, true);
@@ -27575,8 +27575,8 @@ var require_Collection = __commonJS({
27575
27575
  * scalar values from their surrounding node; to disable set `keepScalar` to
27576
27576
  * `true` (collections are always returned intact).
27577
27577
  */
27578
- getIn(path54, keepScalar) {
27579
- const [key, ...rest] = path54;
27578
+ getIn(path55, keepScalar) {
27579
+ const [key, ...rest] = path55;
27580
27580
  const node2 = this.get(key, true);
27581
27581
  if (rest.length === 0)
27582
27582
  return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
@@ -27594,8 +27594,8 @@ var require_Collection = __commonJS({
27594
27594
  /**
27595
27595
  * Checks if the collection includes a value with the key `key`.
27596
27596
  */
27597
- hasIn(path54) {
27598
- const [key, ...rest] = path54;
27597
+ hasIn(path55) {
27598
+ const [key, ...rest] = path55;
27599
27599
  if (rest.length === 0)
27600
27600
  return this.has(key);
27601
27601
  const node2 = this.get(key, true);
@@ -27605,8 +27605,8 @@ var require_Collection = __commonJS({
27605
27605
  * Sets a value in this collection. For `!!set`, `value` needs to be a
27606
27606
  * boolean to add/remove the item from the set.
27607
27607
  */
27608
- setIn(path54, value) {
27609
- const [key, ...rest] = path54;
27608
+ setIn(path55, value) {
27609
+ const [key, ...rest] = path55;
27610
27610
  if (rest.length === 0) {
27611
27611
  this.set(key, value);
27612
27612
  } else {
@@ -30121,9 +30121,9 @@ var require_Document = __commonJS({
30121
30121
  this.contents.add(value);
30122
30122
  }
30123
30123
  /** Adds a value to the document. */
30124
- addIn(path54, value) {
30124
+ addIn(path55, value) {
30125
30125
  if (assertCollection(this.contents))
30126
- this.contents.addIn(path54, value);
30126
+ this.contents.addIn(path55, value);
30127
30127
  }
30128
30128
  /**
30129
30129
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -30198,14 +30198,14 @@ var require_Document = __commonJS({
30198
30198
  * Removes a value from the document.
30199
30199
  * @returns `true` if the item was found and removed.
30200
30200
  */
30201
- deleteIn(path54) {
30202
- if (Collection.isEmptyPath(path54)) {
30201
+ deleteIn(path55) {
30202
+ if (Collection.isEmptyPath(path55)) {
30203
30203
  if (this.contents == null)
30204
30204
  return false;
30205
30205
  this.contents = null;
30206
30206
  return true;
30207
30207
  }
30208
- return assertCollection(this.contents) ? this.contents.deleteIn(path54) : false;
30208
+ return assertCollection(this.contents) ? this.contents.deleteIn(path55) : false;
30209
30209
  }
30210
30210
  /**
30211
30211
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -30220,10 +30220,10 @@ var require_Document = __commonJS({
30220
30220
  * scalar values from their surrounding node; to disable set `keepScalar` to
30221
30221
  * `true` (collections are always returned intact).
30222
30222
  */
30223
- getIn(path54, keepScalar) {
30224
- if (Collection.isEmptyPath(path54))
30223
+ getIn(path55, keepScalar) {
30224
+ if (Collection.isEmptyPath(path55))
30225
30225
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
30226
- return identity.isCollection(this.contents) ? this.contents.getIn(path54, keepScalar) : void 0;
30226
+ return identity.isCollection(this.contents) ? this.contents.getIn(path55, keepScalar) : void 0;
30227
30227
  }
30228
30228
  /**
30229
30229
  * Checks if the document includes a value with the key `key`.
@@ -30234,10 +30234,10 @@ var require_Document = __commonJS({
30234
30234
  /**
30235
30235
  * Checks if the document includes a value at `path`.
30236
30236
  */
30237
- hasIn(path54) {
30238
- if (Collection.isEmptyPath(path54))
30237
+ hasIn(path55) {
30238
+ if (Collection.isEmptyPath(path55))
30239
30239
  return this.contents !== void 0;
30240
- return identity.isCollection(this.contents) ? this.contents.hasIn(path54) : false;
30240
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path55) : false;
30241
30241
  }
30242
30242
  /**
30243
30243
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -30254,13 +30254,13 @@ var require_Document = __commonJS({
30254
30254
  * Sets a value in this document. For `!!set`, `value` needs to be a
30255
30255
  * boolean to add/remove the item from the set.
30256
30256
  */
30257
- setIn(path54, value) {
30258
- if (Collection.isEmptyPath(path54)) {
30257
+ setIn(path55, value) {
30258
+ if (Collection.isEmptyPath(path55)) {
30259
30259
  this.contents = value;
30260
30260
  } else if (this.contents == null) {
30261
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path54), value);
30261
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path55), value);
30262
30262
  } else if (assertCollection(this.contents)) {
30263
- this.contents.setIn(path54, value);
30263
+ this.contents.setIn(path55, value);
30264
30264
  }
30265
30265
  }
30266
30266
  /**
@@ -32221,9 +32221,9 @@ var require_cst_visit = __commonJS({
32221
32221
  visit2.BREAK = BREAK;
32222
32222
  visit2.SKIP = SKIP;
32223
32223
  visit2.REMOVE = REMOVE;
32224
- visit2.itemAtPath = (cst, path54) => {
32224
+ visit2.itemAtPath = (cst, path55) => {
32225
32225
  let item = cst;
32226
- for (const [field, index] of path54) {
32226
+ for (const [field, index] of path55) {
32227
32227
  const tok = item?.[field];
32228
32228
  if (tok && "items" in tok) {
32229
32229
  item = tok.items[index];
@@ -32232,23 +32232,23 @@ var require_cst_visit = __commonJS({
32232
32232
  }
32233
32233
  return item;
32234
32234
  };
32235
- visit2.parentCollection = (cst, path54) => {
32236
- const parent = visit2.itemAtPath(cst, path54.slice(0, -1));
32237
- const field = path54[path54.length - 1][0];
32235
+ visit2.parentCollection = (cst, path55) => {
32236
+ const parent = visit2.itemAtPath(cst, path55.slice(0, -1));
32237
+ const field = path55[path55.length - 1][0];
32238
32238
  const coll = parent?.[field];
32239
32239
  if (coll && "items" in coll)
32240
32240
  return coll;
32241
32241
  throw new Error("Parent collection not found");
32242
32242
  };
32243
- function _visit(path54, item, visitor) {
32244
- let ctrl = visitor(item, path54);
32243
+ function _visit(path55, item, visitor) {
32244
+ let ctrl = visitor(item, path55);
32245
32245
  if (typeof ctrl === "symbol")
32246
32246
  return ctrl;
32247
32247
  for (const field of ["key", "value"]) {
32248
32248
  const token = item[field];
32249
32249
  if (token && "items" in token) {
32250
32250
  for (let i = 0; i < token.items.length; ++i) {
32251
- const ci2 = _visit(Object.freeze(path54.concat([[field, i]])), token.items[i], visitor);
32251
+ const ci2 = _visit(Object.freeze(path55.concat([[field, i]])), token.items[i], visitor);
32252
32252
  if (typeof ci2 === "number")
32253
32253
  i = ci2 - 1;
32254
32254
  else if (ci2 === BREAK)
@@ -32259,10 +32259,10 @@ var require_cst_visit = __commonJS({
32259
32259
  }
32260
32260
  }
32261
32261
  if (typeof ctrl === "function" && field === "key")
32262
- ctrl = ctrl(item, path54);
32262
+ ctrl = ctrl(item, path55);
32263
32263
  }
32264
32264
  }
32265
- return typeof ctrl === "function" ? ctrl(item, path54) : ctrl;
32265
+ return typeof ctrl === "function" ? ctrl(item, path55) : ctrl;
32266
32266
  }
32267
32267
  exports.visit = visit2;
32268
32268
  }
@@ -33564,14 +33564,14 @@ var require_parser = __commonJS({
33564
33564
  case "scalar":
33565
33565
  case "single-quoted-scalar":
33566
33566
  case "double-quoted-scalar": {
33567
- const fs49 = this.flowScalar(this.type);
33567
+ const fs50 = this.flowScalar(this.type);
33568
33568
  if (atNextItem || it2.value) {
33569
- map3.items.push({ start, key: fs49, sep: [] });
33569
+ map3.items.push({ start, key: fs50, sep: [] });
33570
33570
  this.onKeyLine = true;
33571
33571
  } else if (it2.sep) {
33572
- this.stack.push(fs49);
33572
+ this.stack.push(fs50);
33573
33573
  } else {
33574
- Object.assign(it2, { key: fs49, sep: [] });
33574
+ Object.assign(it2, { key: fs50, sep: [] });
33575
33575
  this.onKeyLine = true;
33576
33576
  }
33577
33577
  return;
@@ -33699,13 +33699,13 @@ var require_parser = __commonJS({
33699
33699
  case "scalar":
33700
33700
  case "single-quoted-scalar":
33701
33701
  case "double-quoted-scalar": {
33702
- const fs49 = this.flowScalar(this.type);
33702
+ const fs50 = this.flowScalar(this.type);
33703
33703
  if (!it2 || it2.value)
33704
- fc.items.push({ start: [], key: fs49, sep: [] });
33704
+ fc.items.push({ start: [], key: fs50, sep: [] });
33705
33705
  else if (it2.sep)
33706
- this.stack.push(fs49);
33706
+ this.stack.push(fs50);
33707
33707
  else
33708
- Object.assign(it2, { key: fs49, sep: [] });
33708
+ Object.assign(it2, { key: fs50, sep: [] });
33709
33709
  return;
33710
33710
  }
33711
33711
  case "flow-map-end":
@@ -37252,8 +37252,8 @@ var require_utils2 = __commonJS({
37252
37252
  }
37253
37253
  return ind;
37254
37254
  }
37255
- function removeDotSegments(path54) {
37256
- let input2 = path54;
37255
+ function removeDotSegments(path55) {
37256
+ let input2 = path55;
37257
37257
  const output3 = [];
37258
37258
  let nextSlash = -1;
37259
37259
  let len = 0;
@@ -37327,11 +37327,11 @@ var require_utils2 = __commonJS({
37327
37327
  }
37328
37328
  return output3.join("");
37329
37329
  }
37330
- function removeDotSegmentsRelative(path54) {
37331
- if (path54 === "" || path54[0] === "/") {
37332
- return removeDotSegments(path54);
37330
+ function removeDotSegmentsRelative(path55) {
37331
+ if (path55 === "" || path55[0] === "/") {
37332
+ return removeDotSegments(path55);
37333
37333
  }
37334
- const segments = path54.split("/");
37334
+ const segments = path55.split("/");
37335
37335
  const last = segments.length - 1;
37336
37336
  const output3 = [];
37337
37337
  let trailingDirectory = false;
@@ -37694,8 +37694,8 @@ var require_schemes = __commonJS({
37694
37694
  }
37695
37695
  if (wsComponent.resourceName) {
37696
37696
  const queryIndex = wsComponent.resourceName.indexOf("?");
37697
- const path54 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
37698
- wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
37697
+ const path55 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
37698
+ wsComponent.path = path55 && path55 !== "/" ? path55 : void 0;
37699
37699
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
37700
37700
  wsComponent.resourceName = void 0;
37701
37701
  }
@@ -40929,16 +40929,16 @@ var require_ajv = __commonJS({
40929
40929
  });
40930
40930
 
40931
40931
  // ../cli/src/lib/dress-page.ts
40932
- import fs29 from "node:fs";
40933
- import path34 from "node:path";
40932
+ import fs30 from "node:fs";
40933
+ import path35 from "node:path";
40934
40934
  function dressPage(file3) {
40935
- const folder2 = path34.dirname(file3);
40936
- const html = fs29.readFileSync(file3, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
40935
+ const folder2 = path35.dirname(file3);
40936
+ const html = fs30.readFileSync(file3, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
40937
40937
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
40938
40938
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
40939
- const at3 = path34.resolve(folder2, href);
40940
- if (!at3.startsWith(folder2 + path34.sep) || !fs29.existsSync(at3)) return tag;
40941
- const css = fs29.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path34.relative(folder2, path34.resolve(path34.dirname(at3), src)).split(path34.sep).join("/")}${quote2})`);
40939
+ const at3 = path35.resolve(folder2, href);
40940
+ if (!at3.startsWith(folder2 + path35.sep) || !fs30.existsSync(at3)) return tag;
40941
+ const css = fs30.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole, quote2, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole : `url(${quote2}${path35.relative(folder2, path35.resolve(path35.dirname(at3), src)).split(path35.sep).join("/")}${quote2})`);
40942
40942
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
40943
40943
  });
40944
40944
  const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -40951,7 +40951,7 @@ var init_dress_page = __esm({
40951
40951
  isHtmlFile = (file3) => /\.html?$/i.test(file3);
40952
40952
  CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
40953
40953
  head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
40954
- referenceText = (file3) => isHtmlFile(file3) ? dressPage(file3) : fs29.readFileSync(file3, "utf8");
40954
+ referenceText = (file3) => isHtmlFile(file3) ? dressPage(file3) : fs30.readFileSync(file3, "utf8");
40955
40955
  }
40956
40956
  });
40957
40957
 
@@ -82162,8 +82162,8 @@ var require_JSXTransformer = __commonJS({
82162
82162
  }
82163
82163
  if (this.isAutomaticRuntime) {
82164
82164
  if (this.importProcessor) {
82165
- for (const [path54, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
82166
- prefix += `var ${resolvedName} = require("${path54}");`;
82165
+ for (const [path55, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
82166
+ prefix += `var ${resolvedName} = require("${path55}");`;
82167
82167
  }
82168
82168
  } else {
82169
82169
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -82356,11 +82356,11 @@ var require_JSXTransformer = __commonJS({
82356
82356
  }
82357
82357
  claimAutoImportedName(funcName, importPathSuffix) {
82358
82358
  if (this.importProcessor) {
82359
- const path54 = this.jsxImportSource + importPathSuffix;
82360
- if (!this.cjsAutomaticModuleNameResolutions[path54]) {
82361
- this.cjsAutomaticModuleNameResolutions[path54] = this.importProcessor.getFreeIdentifierForPath(path54);
82359
+ const path55 = this.jsxImportSource + importPathSuffix;
82360
+ if (!this.cjsAutomaticModuleNameResolutions[path55]) {
82361
+ this.cjsAutomaticModuleNameResolutions[path55] = this.importProcessor.getFreeIdentifierForPath(path55);
82362
82362
  }
82363
- return `${this.cjsAutomaticModuleNameResolutions[path54]}.${funcName}`;
82363
+ return `${this.cjsAutomaticModuleNameResolutions[path55]}.${funcName}`;
82364
82364
  } else {
82365
82365
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
82366
82366
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -82796,7 +82796,7 @@ var require_CJSImportProcessor = __commonJS({
82796
82796
  */
82797
82797
  pruneTypeOnlyImports() {
82798
82798
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
82799
- for (const [path54, importInfo] of this.importInfoByPath.entries()) {
82799
+ for (const [path55, importInfo] of this.importInfoByPath.entries()) {
82800
82800
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
82801
82801
  continue;
82802
82802
  }
@@ -82806,7 +82806,7 @@ var require_CJSImportProcessor = __commonJS({
82806
82806
  ...importInfo.namedImports.map(({ localName }) => localName)
82807
82807
  ];
82808
82808
  if (names2.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
82809
- this.importsToReplace.set(path54, "");
82809
+ this.importsToReplace.set(path55, "");
82810
82810
  }
82811
82811
  }
82812
82812
  }
@@ -82814,7 +82814,7 @@ var require_CJSImportProcessor = __commonJS({
82814
82814
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
82815
82815
  }
82816
82816
  generateImportReplacements() {
82817
- for (const [path54, importInfo] of this.importInfoByPath.entries()) {
82817
+ for (const [path55, importInfo] of this.importInfoByPath.entries()) {
82818
82818
  const {
82819
82819
  defaultNames,
82820
82820
  wildcardNames,
@@ -82824,17 +82824,17 @@ var require_CJSImportProcessor = __commonJS({
82824
82824
  hasStarExport
82825
82825
  } = importInfo;
82826
82826
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
82827
- this.importsToReplace.set(path54, `require('${path54}');`);
82827
+ this.importsToReplace.set(path55, `require('${path55}');`);
82828
82828
  continue;
82829
82829
  }
82830
- const primaryImportName = this.getFreeIdentifierForPath(path54);
82830
+ const primaryImportName = this.getFreeIdentifierForPath(path55);
82831
82831
  let secondaryImportName;
82832
82832
  if (this.enableLegacyTypeScriptModuleInterop) {
82833
82833
  secondaryImportName = primaryImportName;
82834
82834
  } else {
82835
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path54);
82835
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path55);
82836
82836
  }
82837
- let requireCode = `var ${primaryImportName} = require('${path54}');`;
82837
+ let requireCode = `var ${primaryImportName} = require('${path55}');`;
82838
82838
  if (wildcardNames.length > 0) {
82839
82839
  for (const wildcardName of wildcardNames) {
82840
82840
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -82862,7 +82862,7 @@ var require_CJSImportProcessor = __commonJS({
82862
82862
  "createStarExport"
82863
82863
  )}(${primaryImportName});`;
82864
82864
  }
82865
- this.importsToReplace.set(path54, requireCode);
82865
+ this.importsToReplace.set(path55, requireCode);
82866
82866
  for (const defaultName of defaultNames) {
82867
82867
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
82868
82868
  }
@@ -82871,8 +82871,8 @@ var require_CJSImportProcessor = __commonJS({
82871
82871
  }
82872
82872
  }
82873
82873
  }
82874
- getFreeIdentifierForPath(path54) {
82875
- const components = path54.split("/");
82874
+ getFreeIdentifierForPath(path55) {
82875
+ const components = path55.split("/");
82876
82876
  const lastComponent = components[components.length - 1];
82877
82877
  const baseName = lastComponent.replace(/\W/g, "");
82878
82878
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -82917,8 +82917,8 @@ var require_CJSImportProcessor = __commonJS({
82917
82917
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
82918
82918
  throw new Error("Expected string token at the end of import statement.");
82919
82919
  }
82920
- const path54 = this.tokens.stringValueAtIndex(index);
82921
- const importInfo = this.getImportInfo(path54);
82920
+ const path55 = this.tokens.stringValueAtIndex(index);
82921
+ const importInfo = this.getImportInfo(path55);
82922
82922
  importInfo.defaultNames.push(...defaultNames);
82923
82923
  importInfo.wildcardNames.push(...wildcardNames);
82924
82924
  importInfo.namedImports.push(...namedImports);
@@ -82985,8 +82985,8 @@ var require_CJSImportProcessor = __commonJS({
82985
82985
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
82986
82986
  throw new Error("Expected string token at the end of import statement.");
82987
82987
  }
82988
- const path54 = this.tokens.stringValueAtIndex(index);
82989
- const importInfo = this.getImportInfo(path54);
82988
+ const path55 = this.tokens.stringValueAtIndex(index);
82989
+ const importInfo = this.getImportInfo(path55);
82990
82990
  importInfo.namedExports.push(...namedImports);
82991
82991
  }
82992
82992
  preprocessExportStarAtIndex(index) {
@@ -83001,8 +83001,8 @@ var require_CJSImportProcessor = __commonJS({
83001
83001
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
83002
83002
  throw new Error("Expected string token at the end of star export statement.");
83003
83003
  }
83004
- const path54 = this.tokens.stringValueAtIndex(index);
83005
- const importInfo = this.getImportInfo(path54);
83004
+ const path55 = this.tokens.stringValueAtIndex(index);
83005
+ const importInfo = this.getImportInfo(path55);
83006
83006
  if (exportedName !== null) {
83007
83007
  importInfo.exportStarNames.push(exportedName);
83008
83008
  } else {
@@ -83042,8 +83042,8 @@ var require_CJSImportProcessor = __commonJS({
83042
83042
  * Get a mutable import info object for this path, creating one if it doesn't
83043
83043
  * exist yet.
83044
83044
  */
83045
- getImportInfo(path54) {
83046
- const existingInfo = this.importInfoByPath.get(path54);
83045
+ getImportInfo(path55) {
83046
+ const existingInfo = this.importInfoByPath.get(path55);
83047
83047
  if (existingInfo) {
83048
83048
  return existingInfo;
83049
83049
  }
@@ -83056,7 +83056,7 @@ var require_CJSImportProcessor = __commonJS({
83056
83056
  exportStarNames: [],
83057
83057
  hasStarExport: false
83058
83058
  };
83059
- this.importInfoByPath.set(path54, newInfo);
83059
+ this.importInfoByPath.set(path55, newInfo);
83060
83060
  return newInfo;
83061
83061
  }
83062
83062
  addExportBinding(localName, exportedName) {
@@ -83636,16 +83636,16 @@ var require_resolve_uri_umd = __commonJS({
83636
83636
  }
83637
83637
  function parseFileUrl(input2) {
83638
83638
  const match = fileRegex.exec(input2);
83639
- const path54 = match[2];
83640
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path54) ? path54 : "/" + path54, match[3] || "", match[4] || "");
83639
+ const path55 = match[2];
83640
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path55) ? path55 : "/" + path55, match[3] || "", match[4] || "");
83641
83641
  }
83642
- function makeUrl(scheme, user, host, port, path54, query, hash2) {
83642
+ function makeUrl(scheme, user, host, port, path55, query, hash2) {
83643
83643
  return {
83644
83644
  scheme,
83645
83645
  user,
83646
83646
  host,
83647
83647
  port,
83648
- path: path54,
83648
+ path: path55,
83649
83649
  query,
83650
83650
  hash: hash2,
83651
83651
  type: 7
@@ -83675,11 +83675,11 @@ var require_resolve_uri_umd = __commonJS({
83675
83675
  url2.type = input2 ? input2.startsWith("?") ? 3 : input2.startsWith("#") ? 2 : 4 : 1;
83676
83676
  return url2;
83677
83677
  }
83678
- function stripPathFilename(path54) {
83679
- if (path54.endsWith("/.."))
83680
- return path54;
83681
- const index = path54.lastIndexOf("/");
83682
- return path54.slice(0, index + 1);
83678
+ function stripPathFilename(path55) {
83679
+ if (path55.endsWith("/.."))
83680
+ return path55;
83681
+ const index = path55.lastIndexOf("/");
83682
+ return path55.slice(0, index + 1);
83683
83683
  }
83684
83684
  function mergePaths(url2, base) {
83685
83685
  normalizePath(base, base.type);
@@ -83717,14 +83717,14 @@ var require_resolve_uri_umd = __commonJS({
83717
83717
  pieces[pointer++] = piece;
83718
83718
  positive++;
83719
83719
  }
83720
- let path54 = "";
83720
+ let path55 = "";
83721
83721
  for (let i = 1; i < pointer; i++) {
83722
- path54 += "/" + pieces[i];
83722
+ path55 += "/" + pieces[i];
83723
83723
  }
83724
- if (!path54 || addTrailingSlash && !path54.endsWith("/..")) {
83725
- path54 += "/";
83724
+ if (!path55 || addTrailingSlash && !path55.endsWith("/..")) {
83725
+ path55 += "/";
83726
83726
  }
83727
- url2.path = path54;
83727
+ url2.path = path55;
83728
83728
  }
83729
83729
  function resolve2(input2, base) {
83730
83730
  if (!input2 && !base)
@@ -83765,13 +83765,13 @@ var require_resolve_uri_umd = __commonJS({
83765
83765
  case 3:
83766
83766
  return queryHash;
83767
83767
  case 4: {
83768
- const path54 = url2.path.slice(1);
83769
- if (!path54)
83768
+ const path55 = url2.path.slice(1);
83769
+ if (!path55)
83770
83770
  return queryHash || ".";
83771
- if (isRelative(base || input2) && !isRelative(path54)) {
83772
- return "./" + path54 + queryHash;
83771
+ if (isRelative(base || input2) && !isRelative(path55)) {
83772
+ return "./" + path55 + queryHash;
83773
83773
  }
83774
- return path54 + queryHash;
83774
+ return path55 + queryHash;
83775
83775
  }
83776
83776
  case 5:
83777
83777
  return url2.path + queryHash;
@@ -83870,10 +83870,10 @@ var require_trace_mapping_umd = __commonJS({
83870
83870
  module2.exports = __toCommonJS2(trace_mapping_exports);
83871
83871
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
83872
83872
  var import_resolve_uri = __toESM2(require_resolve_uri());
83873
- function stripFilename(path54) {
83874
- if (!path54) return "";
83875
- const index = path54.lastIndexOf("/");
83876
- return path54.slice(0, index + 1);
83873
+ function stripFilename(path55) {
83874
+ if (!path55) return "";
83875
+ const index = path55.lastIndexOf("/");
83876
+ return path55.slice(0, index + 1);
83877
83877
  }
83878
83878
  function resolver(mapUrl, sourceRoot) {
83879
83879
  const from = stripFilename(mapUrl);
@@ -85081,9 +85081,9 @@ var require_util9 = __commonJS({
85081
85081
  /** @class */
85082
85082
  (function(_super) {
85083
85083
  __extends2(VError2, _super);
85084
- function VError2(path54, message) {
85084
+ function VError2(path55, message) {
85085
85085
  var _this = _super.call(this, message) || this;
85086
- _this.path = path54;
85086
+ _this.path = path55;
85087
85087
  Object.setPrototypeOf(_this, VError2.prototype);
85088
85088
  return _this;
85089
85089
  }
@@ -85143,26 +85143,26 @@ var require_util9 = __commonJS({
85143
85143
  (_b = this._messages).push.apply(_b, best._messages);
85144
85144
  }
85145
85145
  };
85146
- DetailContext2.prototype.getError = function(path54) {
85146
+ DetailContext2.prototype.getError = function(path55) {
85147
85147
  var msgParts = [];
85148
85148
  for (var i = this._propNames.length - 1; i >= 0; i--) {
85149
85149
  var p2 = this._propNames[i];
85150
- path54 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
85150
+ path55 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
85151
85151
  var m = this._messages[i];
85152
85152
  if (m) {
85153
- msgParts.push(path54 + " " + m);
85153
+ msgParts.push(path55 + " " + m);
85154
85154
  }
85155
85155
  }
85156
- return new VError(path54, msgParts.join("; "));
85156
+ return new VError(path55, msgParts.join("; "));
85157
85157
  };
85158
- DetailContext2.prototype.getErrorDetail = function(path54) {
85158
+ DetailContext2.prototype.getErrorDetail = function(path55) {
85159
85159
  var details = [];
85160
85160
  for (var i = this._propNames.length - 1; i >= 0; i--) {
85161
85161
  var p2 = this._propNames[i];
85162
- path54 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
85162
+ path55 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
85163
85163
  var message = this._messages[i];
85164
85164
  if (message) {
85165
- details.push({ path: path54, message });
85165
+ details.push({ path: path55, message });
85166
85166
  }
85167
85167
  }
85168
85168
  var detail = null;
@@ -85975,8 +85975,8 @@ var require_dist2 = __commonJS({
85975
85975
  this.checkerPlain = this.ttype.getChecker(suite, false);
85976
85976
  this.checkerStrict = this.ttype.getChecker(suite, true);
85977
85977
  }
85978
- Checker2.prototype.setReportedPath = function(path54) {
85979
- this._path = path54;
85978
+ Checker2.prototype.setReportedPath = function(path55) {
85979
+ this._path = path55;
85980
85980
  };
85981
85981
  Checker2.prototype.check = function(value) {
85982
85982
  return this._doCheck(this.checkerPlain, value);
@@ -91409,9 +91409,9 @@ var require_CJSImportTransformer = __commonJS({
91409
91409
  if (shouldElideImport) {
91410
91410
  this.tokens.removeToken();
91411
91411
  } else {
91412
- const path54 = this.tokens.stringValue();
91413
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
91414
- this.tokens.appendCode(this.importProcessor.claimImportCode(path54));
91412
+ const path55 = this.tokens.stringValue();
91413
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path55));
91414
+ this.tokens.appendCode(this.importProcessor.claimImportCode(path55));
91415
91415
  }
91416
91416
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
91417
91417
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -91991,8 +91991,8 @@ var require_CJSImportTransformer = __commonJS({
91991
91991
  }
91992
91992
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
91993
91993
  this.tokens.removeToken();
91994
- const path54 = this.tokens.stringValue();
91995
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
91994
+ const path55 = this.tokens.stringValue();
91995
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path55));
91996
91996
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
91997
91997
  } else {
91998
91998
  this.tokens.appendCode(exportStatements.join(" "));
@@ -92006,8 +92006,8 @@ var require_CJSImportTransformer = __commonJS({
92006
92006
  while (!this.tokens.matches1(_types.TokenType.string)) {
92007
92007
  this.tokens.removeToken();
92008
92008
  }
92009
- const path54 = this.tokens.stringValue();
92010
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path54));
92009
+ const path55 = this.tokens.stringValue();
92010
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path55));
92011
92011
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
92012
92012
  if (this.tokens.matches1(_types.TokenType.semi)) {
92013
92013
  this.tokens.removeToken();
@@ -121861,9 +121861,9 @@ var init_bundle_mjs = __esm({
121861
121861
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
121862
121862
  }
121863
121863
  };
121864
- getPart = (classPartObject, path54) => {
121864
+ getPart = (classPartObject, path55) => {
121865
121865
  let current2 = classPartObject;
121866
- const parts = path54.split(CLASS_PART_SEPARATOR);
121866
+ const parts = path55.split(CLASS_PART_SEPARATOR);
121867
121867
  const len = parts.length;
121868
121868
  for (let i = 0; i < len; i++) {
121869
121869
  const part = parts[i];
@@ -125113,8 +125113,8 @@ var init_dist = __esm({
125113
125113
  });
125114
125114
 
125115
125115
  // ../cli/src/lib/draw-mockup.ts
125116
- import fs31 from "node:fs";
125117
- import path36 from "node:path";
125116
+ import fs32 from "node:fs";
125117
+ import path37 from "node:path";
125118
125118
  import vm from "node:vm";
125119
125119
  async function loadPackage(id2) {
125120
125120
  if (id2 === "react") return import_react3.default;
@@ -125127,23 +125127,23 @@ async function loadPackage(id2) {
125127
125127
  return { __esModule: true, ...await load() };
125128
125128
  }
125129
125129
  function resolveFile(id2, from, folder2) {
125130
- const at2 = path36.resolve(path36.dirname(from), id2);
125131
- if (at2 !== folder2 && !at2.startsWith(folder2 + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125132
- const tries = path36.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path36.join(at2, `index${e2}`))];
125133
- const file3 = tries.find((f2) => fs31.statSync(f2, { throwIfNoEntry: false })?.isFile());
125130
+ const at2 = path37.resolve(path37.dirname(from), id2);
125131
+ if (at2 !== folder2 && !at2.startsWith(folder2 + path37.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125132
+ const tries = path37.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path37.join(at2, `index${e2}`))];
125133
+ const file3 = tries.find((f2) => fs32.statSync(f2, { throwIfNoEntry: false })?.isFile());
125134
125134
  if (!file3) throw new Error(`no such file: ${id2}`);
125135
- if (!fs31.realpathSync(file3).startsWith(fs31.realpathSync(folder2) + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125135
+ if (!fs32.realpathSync(file3).startsWith(fs32.realpathSync(folder2) + path37.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125136
125136
  return file3;
125137
125137
  }
125138
125138
  async function readGraph(entry) {
125139
- const folder2 = path36.dirname(entry);
125139
+ const folder2 = path37.dirname(entry);
125140
125140
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
125141
125141
  const walk = async (file3) => {
125142
125142
  if (graph.code.has(file3)) return;
125143
125143
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
125144
125144
  let location = file3;
125145
125145
  try {
125146
- const js = (0, import_sucrase.transform)(fs31.readFileSync(file3, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file3 }).code;
125146
+ const js = (0, import_sucrase.transform)(fs32.readFileSync(file3, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file3 }).code;
125147
125147
  graph.code.set(file3, js);
125148
125148
  const link = /* @__PURE__ */ new Map();
125149
125149
  graph.links.set(file3, link);
@@ -125157,7 +125157,7 @@ async function readGraph(entry) {
125157
125157
  const target = resolveFile(id2, file3, folder2);
125158
125158
  link.set(id2, target);
125159
125159
  if (!target.endsWith(".css")) await walk(target);
125160
- else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs31.readFileSync(target, "utf8") });
125160
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs32.readFileSync(target, "utf8") });
125161
125161
  }
125162
125162
  } catch (error62) {
125163
125163
  throw new Error(`${location}: ${error62 instanceof Error ? error62.message : String(error62)}`);
@@ -125174,13 +125174,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
125174
125174
  async function tailwindFor(markup, sheets, folder2) {
125175
125175
  const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
125176
125176
  const compiler = await rc(source2, {
125177
- base: sheets.length ? path36.dirname(sheets[0].path) : "/",
125177
+ base: sheets.length ? path37.dirname(sheets[0].path) : "/",
125178
125178
  loadStylesheet: async (id2, from) => {
125179
125179
  if (id2 === "tailwindcss" || id2.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
125180
125180
  if (!id2.startsWith(".")) throw new Error(`a mockup cannot import ${id2}`);
125181
- const at2 = path36.resolve(from, id2);
125182
- if (!fs31.realpathSync(at2).startsWith(fs31.realpathSync(folder2) + path36.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125183
- return { path: at2, base: path36.dirname(at2), content: fs31.readFileSync(at2, "utf8") };
125181
+ const at2 = path37.resolve(from, id2);
125182
+ if (!fs32.realpathSync(at2).startsWith(fs32.realpathSync(folder2) + path37.sep)) throw new Error(`${id2} is outside the mockup's folder`);
125183
+ return { path: at2, base: path37.dirname(at2), content: fs32.readFileSync(at2, "utf8") };
125184
125184
  }
125185
125185
  });
125186
125186
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
@@ -125229,7 +125229,7 @@ ${graph.code.get(file3)}
125229
125229
  if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
125230
125230
  sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
125231
125231
  const markup = run2("__draw()", context, entry, deadline);
125232
- const css = (await tailwindFor(markup, graph.sheets, path36.dirname(entry))).replace(/<\/style/gi, "<\\/style");
125232
+ const css = (await tailwindFor(markup, graph.sheets, path37.dirname(entry))).replace(/<\/style/gi, "<\\/style");
125233
125233
  return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
125234
125234
  }
125235
125235
  var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, MOCKUP_IMPORTS;
@@ -144279,14 +144279,14 @@ var require_svgPath = __commonJS({
144279
144279
  ["Z", 0],
144280
144280
  ["z", 0]
144281
144281
  ]);
144282
- var parse4 = function(path54) {
144282
+ var parse4 = function(path55) {
144283
144283
  var cmd;
144284
144284
  var ret = [];
144285
144285
  var args2 = [];
144286
144286
  var curArg = "";
144287
144287
  var foundDecimal = false;
144288
144288
  var params = 0;
144289
- for (var _i2 = 0, path_1 = path54; _i2 < path_1.length; _i2++) {
144289
+ for (var _i2 = 0, path_1 = path55; _i2 < path_1.length; _i2++) {
144290
144290
  var c2 = path_1[_i2];
144291
144291
  if (parameters.has(c2)) {
144292
144292
  params = parameters.get(c2);
@@ -144600,8 +144600,8 @@ var require_svgPath = __commonJS({
144600
144600
  ];
144601
144601
  return result;
144602
144602
  };
144603
- exports.svgPathToOperators = function(path54) {
144604
- return apply(parse4(path54));
144603
+ exports.svgPathToOperators = function(path55) {
144604
+ return apply(parse4(path55));
144605
144605
  };
144606
144606
  }
144607
144607
  });
@@ -144784,7 +144784,7 @@ var require_operations = __commonJS({
144784
144784
  operators_1.popGraphicsState()
144785
144785
  ]).filter(Boolean);
144786
144786
  };
144787
- exports.drawSvgPath = function(path54, options) {
144787
+ exports.drawSvgPath = function(path55, options) {
144788
144788
  var _a4, _b, _c;
144789
144789
  return tslib_1.__spreadArrays([
144790
144790
  operators_1.pushGraphicsState(),
@@ -144798,7 +144798,7 @@ var require_operations = __commonJS({
144798
144798
  options.borderWidth && operators_1.setLineWidth(options.borderWidth),
144799
144799
  options.borderLineCap && operators_1.setLineCap(options.borderLineCap),
144800
144800
  operators_1.setDashPattern((_b = options.borderDashArray) !== null && _b !== void 0 ? _b : [], (_c = options.borderDashPhase) !== null && _c !== void 0 ? _c : 0)
144801
- ], svgPath_1.svgPathToOperators(path54), [
144801
+ ], svgPath_1.svgPathToOperators(path55), [
144802
144802
  // prettier-ignore
144803
144803
  options.color && options.borderWidth ? operators_1.fillAndStroke() : options.color ? operators_1.fill() : options.borderColor ? operators_1.stroke() : operators_1.closePath(),
144804
144804
  operators_1.popGraphicsState()
@@ -149096,12 +149096,12 @@ var require_PDFPage = __commonJS({
149096
149096
  graphicsState: graphicsStateKey
149097
149097
  }));
149098
149098
  };
149099
- PDFPage2.prototype.drawSvgPath = function(path54, options) {
149099
+ PDFPage2.prototype.drawSvgPath = function(path55, options) {
149100
149100
  var _a4, _b, _c, _d, _e2, _f, _g, _h, _j;
149101
149101
  if (options === void 0) {
149102
149102
  options = {};
149103
149103
  }
149104
- utils_1.assertIs(path54, "path", ["string"]);
149104
+ utils_1.assertIs(path55, "path", ["string"]);
149105
149105
  utils_1.assertOrUndefined(options.x, "options.x", ["number"]);
149106
149106
  utils_1.assertOrUndefined(options.y, "options.y", ["number"]);
149107
149107
  utils_1.assertOrUndefined(options.scale, "options.scale", ["number"]);
@@ -149130,7 +149130,7 @@ var require_PDFPage = __commonJS({
149130
149130
  options.borderColor = colors_1.rgb(0, 0, 0);
149131
149131
  }
149132
149132
  var contentStream = this.getContentStream();
149133
- contentStream.push.apply(contentStream, operations_1.drawSvgPath(path54, {
149133
+ contentStream.push.apply(contentStream, operations_1.drawSvgPath(path55, {
149134
149134
  x: (_a4 = options.x) !== null && _a4 !== void 0 ? _a4 : this.x,
149135
149135
  y: (_b = options.y) !== null && _b !== void 0 ? _b : this.y,
149136
149136
  scale: options.scale,
@@ -151540,13 +151540,13 @@ import { spawn as spawn4 } from "node:child_process";
151540
151540
  import { existsSync as existsSync2 } from "node:fs";
151541
151541
  import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
151542
151542
  import { tmpdir } from "node:os";
151543
- import path37 from "node:path";
151543
+ import path38 from "node:path";
151544
151544
  import { pathToFileURL as pathToFileURL2 } from "node:url";
151545
151545
  function installedOffice() {
151546
151546
  const programs = [process.env.ProgramFiles, process.env["ProgramFiles(x86)"]];
151547
- const candidates = process.platform === "darwin" ? ["/Applications/LibreOffice.app/Contents/MacOS/soffice"] : process.platform === "win32" ? programs.flatMap((dir) => dir ? [path37.join(dir, "LibreOffice", "program", "soffice.com")] : []) : [];
151547
+ const candidates = process.platform === "darwin" ? ["/Applications/LibreOffice.app/Contents/MacOS/soffice"] : process.platform === "win32" ? programs.flatMap((dir) => dir ? [path38.join(dir, "LibreOffice", "program", "soffice.com")] : []) : [];
151548
151548
  const executable = process.platform === "win32" ? "soffice.com" : "soffice";
151549
- const onPath2 = (process.env.PATH ?? "").split(path37.delimiter).filter(Boolean).map((dir) => path37.join(dir, executable));
151549
+ const onPath2 = (process.env.PATH ?? "").split(path38.delimiter).filter(Boolean).map((dir) => path38.join(dir, executable));
151550
151550
  return [...onPath2, ...candidates].find((file3) => existsSync2(file3)) ?? executable;
151551
151551
  }
151552
151552
  function checkPackage(bytes2, mainPart) {
@@ -151603,14 +151603,14 @@ function convert(command, args2, timeout) {
151603
151603
  async function renderOfficePdf(bytes2, ext, command = installedOffice(), timeout = 3e4) {
151604
151604
  const format = formats[ext];
151605
151605
  checkPackage(bytes2, format.part);
151606
- const dir = await mkdtemp(path37.join(tmpdir(), "wildcrane-document-"));
151606
+ const dir = await mkdtemp(path38.join(tmpdir(), "wildcrane-document-"));
151607
151607
  try {
151608
- const user = path37.join(dir, "profile", "user");
151609
- const input2 = path37.join(dir, `source${ext}`);
151608
+ const user = path38.join(dir, "profile", "user");
151609
+ const input2 = path38.join(dir, `source${ext}`);
151610
151610
  await mkdir(user, { recursive: true });
151611
- await Promise.all([writeFile(input2, bytes2), writeFile(path37.join(user, "registrymodifications.xcu"), profile)]);
151611
+ await Promise.all([writeFile(input2, bytes2), writeFile(path38.join(user, "registrymodifications.xcu"), profile)]);
151612
151612
  await convert(command, [
151613
- `-env:UserInstallation=${pathToFileURL2(path37.dirname(user)).href}`,
151613
+ `-env:UserInstallation=${pathToFileURL2(path38.dirname(user)).href}`,
151614
151614
  "--headless",
151615
151615
  "--norestore",
151616
151616
  `--infilter=${format.input}`,
@@ -151620,7 +151620,7 @@ async function renderOfficePdf(bytes2, ext, command = installedOffice(), timeout
151620
151620
  dir,
151621
151621
  input2
151622
151622
  ], timeout);
151623
- const output3 = path37.join(dir, "source.pdf");
151623
+ const output3 = path38.join(dir, "source.pdf");
151624
151624
  const { size } = await stat(output3);
151625
151625
  if (!size || size > ASSET_FILE_LIMIT) throw Error("Invalid Office preview size");
151626
151626
  const pdf = await readFile(output3);
@@ -151764,8 +151764,8 @@ function useRunnerHome() {
151764
151764
 
151765
151765
  // src/flow-worker.ts
151766
151766
  import { spawn as spawn6 } from "node:child_process";
151767
- import fs48 from "node:fs";
151768
- import path53 from "node:path";
151767
+ import fs49 from "node:fs";
151768
+ import path54 from "node:path";
151769
151769
  import { fileURLToPath as fileURLToPath4 } from "node:url";
151770
151770
 
151771
151771
  // ../cli/src/lib/cloud/session.ts
@@ -151804,25 +151804,35 @@ var sessionFile = () => path3.join(machineHome(), "session.json");
151804
151804
  var lockDir = () => path3.join(machineHome(), "session.lock");
151805
151805
  var lockOwner = () => path3.join(lockDir(), "owner");
151806
151806
  var retryFile = () => path3.join(machineHome(), "session-refresh.json");
151807
+ var transportRetry;
151807
151808
  var refreshKey = (session) => createHash("sha256").update(JSON.stringify([cloudEndpoints().api, session.subject, session.refreshToken])).digest("hex");
151808
151809
  function readRetry(session) {
151809
151810
  try {
151810
151811
  const retry2 = JSON.parse(fs2.readFileSync(retryFile(), "utf8"));
151812
+ if (!retry2.source && ["fetch failed", "The operation was aborted due to timeout"].includes(retry2.error)) return;
151811
151813
  if (retry2.key === refreshKey(session) && Number.isFinite(retry2.until) && Number.isInteger(retry2.attempt) && retry2.attempt > 0 && typeof retry2.error === "string") return retry2;
151812
151814
  } catch {
151813
151815
  }
151814
151816
  }
151815
- function deferRefresh(session, error62, after) {
151817
+ function readTransportRetry(session) {
151818
+ if (transportRetry?.file === retryFile() && transportRetry.key === refreshKey(session)) return transportRetry;
151819
+ }
151820
+ function deferRefresh(session, error62, { after, transport = false } = {}) {
151816
151821
  const current2 = readSession();
151817
151822
  if (current2?.subject === session.subject && current2.refreshToken === session.refreshToken) {
151818
- const attempt = Math.min((readRetry(session)?.attempt ?? 0) + 1, 4);
151823
+ const previous = transport ? readTransportRetry(session) : readRetry(session);
151824
+ const attempt = Math.min((previous?.attempt ?? 0) + 1, 4);
151819
151825
  const seconds = after?.trim() ? Number(after) : NaN;
151820
151826
  const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after ?? "") - Date.now();
151821
- const delay3 = Math.max(Math.min(REFRESH_BACKOFF_MS * 2 ** (attempt - 1), 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
151827
+ const backoff = (transport ? 5e3 : REFRESH_BACKOFF_MS) * 2 ** (attempt - 1);
151828
+ const delay3 = Math.max(Math.min(backoff, transport ? 3e4 : 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
151822
151829
  const retry2 = { key: refreshKey(session), until: Date.now() + delay3, attempt, error: error62 };
151823
- const temporary = `${retryFile()}.${process.pid}.tmp`;
151824
- fs2.writeFileSync(temporary, JSON.stringify(retry2), { mode: 384 });
151825
- fs2.renameSync(temporary, retryFile());
151830
+ if (transport) transportRetry = { ...retry2, file: retryFile() };
151831
+ else {
151832
+ const temporary = `${retryFile()}.${process.pid}.tmp`;
151833
+ fs2.writeFileSync(temporary, JSON.stringify({ ...retry2, source: "cloud" }), { mode: 384 });
151834
+ fs2.renameSync(temporary, retryFile());
151835
+ }
151826
151836
  }
151827
151837
  return { ok: false, reason: "unreachable", error: error62 };
151828
151838
  }
@@ -151849,15 +151859,16 @@ function writeSession(session) {
151849
151859
  `, { mode: 384 });
151850
151860
  fs2.renameSync(tmp, sessionFile());
151851
151861
  if (!expiringSoon(session) || !readRetry(session)) fs2.rmSync(retryFile(), { force: true });
151862
+ if (transportRetry?.file === retryFile() && (!expiringSoon(session) || !readTransportRetry(session))) transportRetry = void 0;
151852
151863
  }
151853
- async function accessToken() {
151864
+ async function accessToken({ retryTransport = false } = {}) {
151854
151865
  const held5 = readSession();
151855
151866
  if (!held5) return { ok: false, reason: "signed-out" };
151856
151867
  if (!expiringSoon(held5)) return { ok: true, token: held5.accessToken, session: held5 };
151857
- return refresh();
151868
+ return refresh(retryTransport);
151858
151869
  }
151859
151870
  var expiringSoon = (session) => session.expiresAt - REFRESH_MARGIN_MS <= Date.now();
151860
- async function refresh() {
151871
+ async function refresh(retryTransport) {
151861
151872
  const lock = await takeLock();
151862
151873
  if (!lock) return { ok: false, reason: "unreachable", error: "Cloud sign-in refresh is busy. Try again shortly." };
151863
151874
  try {
@@ -151866,6 +151877,8 @@ async function refresh() {
151866
151877
  if (!expiringSoon(now)) return { ok: true, token: now.accessToken, session: now };
151867
151878
  const retry2 = readRetry(now);
151868
151879
  if (retry2 && retry2.until > Date.now()) return { ok: false, reason: "unreachable", error: retry2.error };
151880
+ const localRetry = retryTransport ? void 0 : readTransportRetry(now);
151881
+ if (localRetry && localRetry.until > Date.now()) return { ok: false, reason: "unreachable", error: localRetry.error };
151869
151882
  const { api, anonKey } = cloudEndpoints();
151870
151883
  let response;
151871
151884
  try {
@@ -151876,12 +151889,12 @@ async function refresh() {
151876
151889
  signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS)
151877
151890
  });
151878
151891
  } catch (e2) {
151879
- return deferRefresh(now, e2 instanceof Error ? e2.message : String(e2));
151892
+ return deferRefresh(now, e2 instanceof Error ? e2.message : String(e2), { transport: true });
151880
151893
  }
151881
151894
  if (!response.ok) {
151882
151895
  const body = await response.json().catch(() => null);
151883
151896
  const error62 = body?.error_description ?? body?.msg ?? body?.message;
151884
- if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error62 ?? `Cloud answered ${response.status}`, response.headers.get("retry-after"));
151897
+ if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error62 ?? `Cloud answered ${response.status}`, { after: response.headers.get("retry-after") });
151885
151898
  return { ok: false, reason: "expired", error: error62 };
151886
151899
  }
151887
151900
  const fresh = sessionFrom(await response.json().catch(() => null), now);
@@ -152397,6 +152410,7 @@ __export(api_exports, {
152397
152410
  answerDiff: () => answerDiff,
152398
152411
  approveReply: () => approveReply,
152399
152412
  cancelReplyApproval: () => cancelReplyApproval,
152413
+ cancelTask: () => cancelTask,
152400
152414
  claimJob: () => claimJob,
152401
152415
  commitBoard: () => commitBoard,
152402
152416
  completeArchives: () => completeArchives,
@@ -153266,10 +153280,10 @@ function mergeDefs(...defs) {
153266
153280
  function cloneDef(schema) {
153267
153281
  return mergeDefs(schema._zod.def);
153268
153282
  }
153269
- function getElementAtPath(obj3, path54) {
153270
- if (!path54)
153283
+ function getElementAtPath(obj3, path55) {
153284
+ if (!path55)
153271
153285
  return obj3;
153272
- return path54.reduce((acc, key) => acc?.[key], obj3);
153286
+ return path55.reduce((acc, key) => acc?.[key], obj3);
153273
153287
  }
153274
153288
  function promiseAllObject(promisesObj) {
153275
153289
  const keys = Object.keys(promisesObj);
@@ -153609,11 +153623,11 @@ function explicitlyAborted(x2, startIndex = 0) {
153609
153623
  }
153610
153624
  return false;
153611
153625
  }
153612
- function prefixIssues(path54, issues) {
153626
+ function prefixIssues(path55, issues) {
153613
153627
  return issues.map((iss) => {
153614
153628
  var _a4;
153615
153629
  (_a4 = iss).path ?? (_a4.path = []);
153616
- iss.path.unshift(path54);
153630
+ iss.path.unshift(path55);
153617
153631
  return iss;
153618
153632
  });
153619
153633
  }
@@ -154075,16 +154089,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
154075
154089
  }
154076
154090
  function formatError(error62, mapper = (issue2) => issue2.message) {
154077
154091
  const fieldErrors = { _errors: [] };
154078
- const processError = (error63, path54 = []) => {
154092
+ const processError = (error63, path55 = []) => {
154079
154093
  for (const issue2 of error63.issues) {
154080
154094
  if (issue2.code === "invalid_union" && issue2.errors.length) {
154081
- issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
154095
+ issue2.errors.map((issues) => processError({ issues }, [...path55, ...issue2.path]));
154082
154096
  } else if (issue2.code === "invalid_key") {
154083
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154097
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154084
154098
  } else if (issue2.code === "invalid_element") {
154085
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154099
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154086
154100
  } else {
154087
- const fullpath = [...path54, ...issue2.path];
154101
+ const fullpath = [...path55, ...issue2.path];
154088
154102
  if (fullpath.length === 0) {
154089
154103
  fieldErrors._errors.push(mapper(issue2));
154090
154104
  } else {
@@ -154123,17 +154137,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
154123
154137
  }
154124
154138
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
154125
154139
  const result = { errors: [] };
154126
- const processError = (error63, path54 = []) => {
154140
+ const processError = (error63, path55 = []) => {
154127
154141
  var _a4;
154128
154142
  for (const issue2 of error63.issues) {
154129
154143
  if (issue2.code === "invalid_union" && issue2.errors.length) {
154130
- issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
154144
+ issue2.errors.map((issues) => processError({ issues }, [...path55, ...issue2.path]));
154131
154145
  } else if (issue2.code === "invalid_key") {
154132
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154146
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154133
154147
  } else if (issue2.code === "invalid_element") {
154134
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154148
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154135
154149
  } else {
154136
- const fullpath = [...path54, ...issue2.path];
154150
+ const fullpath = [...path55, ...issue2.path];
154137
154151
  if (fullpath.length === 0) {
154138
154152
  result.errors.push(mapper(issue2));
154139
154153
  continue;
@@ -154172,8 +154186,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
154172
154186
  }
154173
154187
  function toDotPath(_path) {
154174
154188
  const segs = [];
154175
- const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
154176
- for (const seg of path54) {
154189
+ const path55 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
154190
+ for (const seg of path55) {
154177
154191
  if (typeof seg === "number")
154178
154192
  segs.push(`[${seg}]`);
154179
154193
  else if (typeof seg === "symbol")
@@ -171311,13 +171325,13 @@ function resolveRef(ref, ctx) {
171311
171325
  if (!ref.startsWith("#")) {
171312
171326
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
171313
171327
  }
171314
- const path54 = ref.slice(1).split("/").filter(Boolean);
171315
- if (path54.length === 0) {
171328
+ const path55 = ref.slice(1).split("/").filter(Boolean);
171329
+ if (path55.length === 0) {
171316
171330
  return ctx.rootSchema;
171317
171331
  }
171318
171332
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
171319
- if (path54[0] === defsKey) {
171320
- const key = path54[1] === void 0 ? void 0 : decodeJSONPointerSegment(path54[1]);
171333
+ if (path55[0] === defsKey) {
171334
+ const key = path55[1] === void 0 ? void 0 : decodeJSONPointerSegment(path55[1]);
171321
171335
  if (!key || !ctx.defs[key]) {
171322
171336
  throw new Error(`Reference not found: ${ref}`);
171323
171337
  }
@@ -172208,7 +172222,6 @@ function readReviewPlan(plan2) {
172208
172222
  return plan2?.map(({ id: id2, after, previews, kind }) => ({ id: id2, after, previews, ...kind && { kind } })) ?? null;
172209
172223
  }
172210
172224
  function reviewAuthorization(review, assigned, dispatchRevision) {
172211
- if (review.pending_plan) return { kind: "waiting" };
172212
172225
  const states = new Map(review.stages.map((stage) => [stage.id, stage]));
172213
172226
  const nodes = (review.plan ?? []).filter((node2) => {
172214
172227
  const stage = states.get(node2.id);
@@ -172287,9 +172300,29 @@ function goalRoute(discussion, goal, field) {
172287
172300
  return `/v1/discussions/${encodeURIComponent(discussion)}/${field}/${encodeURIComponent(goal)}`;
172288
172301
  }
172289
172302
 
172303
+ // ../cli/src/lib/cloud/response.ts
172304
+ var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
172305
+ var hasText = (value) => typeof value === "string" && !!value.trim();
172306
+ function temporaryCloudFailure({ code, status }) {
172307
+ if (code && ["unauthenticated", "machine_offline", "quota_exceeded", "daily_write_budget_reached", "storage_limit_reached"].includes(code)) return false;
172308
+ return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable"].includes(code ?? "") || status === 408 || (status !== void 0 ? status >= 500 : !code);
172309
+ }
172310
+ var invalidResponse = (expected) => ({ code: "invalid_response", message: `Cloud did not return ${expected}.`, retryable: true });
172311
+ async function readCloudJson(response) {
172312
+ return response.json().catch(() => void 0);
172313
+ }
172314
+ function cloudProblem(response, body) {
172315
+ const error62 = isRecord(body) && isRecord(body.error) ? body.error : null;
172316
+ if (response.ok && !error62) return null;
172317
+ const status = response.status;
172318
+ const code = hasText(error62?.code) ? error62.code : status === 401 ? "unauthenticated" : status >= 500 ? "service_unavailable" : "refused";
172319
+ const message = hasText(error62?.message) ? error62.message : `Cloud answered ${status}.`;
172320
+ return { code, message, status, retryable: temporaryCloudFailure({ code, status }) };
172321
+ }
172322
+
172290
172323
  // src/protocol.ts
172291
- var AKB_VERSION = true ? "0.11.83" : "0.0.0";
172292
- var AKB_CONTRACT = true ? 27 : 0;
172324
+ var AKB_VERSION = true ? "0.11.84" : "0.0.0";
172325
+ var AKB_CONTRACT = true ? 28 : 0;
172293
172326
 
172294
172327
  // src/secrets.ts
172295
172328
  import fs6 from "node:fs";
@@ -172322,10 +172355,6 @@ function keepSecrets(runtime, given) {
172322
172355
  var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id2, keys]) => [id2, Object.keys(keys)]));
172323
172356
 
172324
172357
  // src/api.ts
172325
- function temporaryCloudFailure(error62) {
172326
- if (error62.code && ["unauthenticated", "machine_offline", "quota_exceeded", "daily_write_budget_reached", "storage_limit_reached"].includes(error62.code)) return false;
172327
- return error62.code === "idempotency_in_progress" || error62.code === "service_unavailable" || error62.code === "artifacts_unavailable" || error62.status === 408 || (error62.status !== void 0 ? error62.status >= 500 : !error62.code);
172328
- }
172329
172358
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
172330
172359
  var PROTOCOL = 30;
172331
172360
  var TIMEOUT_MS = 2e4;
@@ -172353,20 +172382,16 @@ async function send(method, route, body, signedIn, ms, type, extra = {}) {
172353
172382
  }
172354
172383
  }
172355
172384
  async function answerOf(response) {
172356
- let answer;
172357
- try {
172358
- answer = await response.json();
172359
- } catch (error62) {
172360
- if (response.ok) return { ok: false, error: error62 instanceof Error ? error62.message : String(error62) };
172361
- answer = null;
172362
- }
172363
- if (response.ok) return { ok: true, value: answer };
172385
+ const answer = await readCloudJson(response);
172386
+ const problem = cloudProblem(response, answer) ?? (answer === void 0 ? invalidResponse("valid JSON") : null);
172387
+ if (!problem) return { ok: true, value: answer };
172388
+ const error62 = isRecord(answer) && isRecord(answer.error) ? answer.error : null;
172364
172389
  return {
172365
172390
  ok: false,
172366
- error: answer?.error?.message ?? `Cloud answered ${response.status}`,
172367
- code: answer?.error?.code ?? (response.status === 401 ? "unauthenticated" : response.status >= 500 ? void 0 : "refused"),
172368
- status: response.status,
172369
- ...answer?.error?.project ? { project: answer.error.project } : {}
172391
+ error: problem.message,
172392
+ code: problem.code,
172393
+ status: problem.status,
172394
+ ...typeof error62?.project === "string" ? { project: error62.project } : {}
172370
172395
  };
172371
172396
  }
172372
172397
  async function request(method, route, body, signedIn = true) {
@@ -172471,7 +172496,7 @@ var listFolders = (machineId) => request("GET", `/v1/runner/folders?machine=${q(
172471
172496
  var listElsewhere = (machineId) => request("GET", `/v1/runner/folders?machine=${q(machineId)}&elsewhere=1`);
172472
172497
  var listMachineTasks = (machineId) => request("GET", `/v1/runner/tasks?machine=${q(machineId)}`);
172473
172498
  var stopTask = (task, how) => request("POST", how === "chat" ? `/v1/tasks/${q(task)}/chat/stop` : `/v1/tasks/${q(task)}/stop`, {});
172474
- var addFolder = (machineId, name, path54, project) => request("POST", "/v1/runner/folders", { machineId, name, path: path54, ...project ? { project } : {} });
172499
+ var addFolder = (machineId, name, path55, project) => request("POST", "/v1/runner/folders", { machineId, name, path: path55, ...project ? { project } : {} });
172475
172500
  async function createProject(name, workspace, key) {
172476
172501
  const sent = await send("POST", "/v1/projects", { name, workspace }, true, TIMEOUT_MS, void 0, { "idempotency-key": key });
172477
172502
  return sent.ok ? answerOf(sent.value) : sent;
@@ -172496,6 +172521,7 @@ async function commitBoard(project, job, machine, files) {
172496
172521
  }
172497
172522
  var readTaskStudio = (task) => request("GET", `/v1/tasks/${q(task)}/studio`);
172498
172523
  var listStudios = (workspace, after) => request("GET", `/v1/studios?workspace=${q(workspace)}&limit=100${after ? `&after=${q(after)}` : ""}`);
172524
+ var cancelTask = (task, reason, discard) => request("POST", `/v1/tasks/${q(task)}/cancel`, { ...reason ? { reason } : {}, discard });
172499
172525
  var readTask = (task) => request("GET", `/v1/tasks/${q(task)}`);
172500
172526
  var readProject = (project) => request("GET", `/v1/projects/${q(project)}`);
172501
172527
  var readArtifact = (artifact) => request("GET", `/v1/artifacts/${q(artifact)}`);
@@ -172551,25 +172577,25 @@ import path12 from "node:path";
172551
172577
  init_file_limits();
172552
172578
  var ROOTS = ["todo/", ".archive/", "memory/", "studios/", "triage/", "assets/", "rules/"];
172553
172579
  var SETTINGS = ["modules.md", "config.md"];
172554
- var isSettingsPath = (path54) => SETTINGS.includes(path54) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path54);
172555
- function isBoardPath(path54) {
172556
- if (!path54 || path54.length > 500 || path54.startsWith("/") || path54.includes("\\") || path54.includes("\0")) return false;
172557
- if (path54.split("/").some((part) => !part || part === "." || part === "..")) return false;
172558
- if (path54 === "todo/README.md" || path54.split("/").includes(".sync")) return false;
172559
- if (path54.startsWith("studios/")) return true;
172560
- if (SETTINGS.includes(path54)) return true;
172561
- if (path54.startsWith("rules/")) return isSettingsPath(path54);
172562
- if (path54.startsWith("assets/")) return taskOfAssets(path54) !== null;
172563
- return ROOTS.some((root2) => path54.startsWith(root2)) && path54.endsWith(".md");
172580
+ var isSettingsPath = (path55) => SETTINGS.includes(path55) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path55);
172581
+ function isBoardPath(path55) {
172582
+ if (!path55 || path55.length > 500 || path55.startsWith("/") || path55.includes("\\") || path55.includes("\0")) return false;
172583
+ if (path55.split("/").some((part) => !part || part === "." || part === "..")) return false;
172584
+ if (path55 === "todo/README.md" || path55.split("/").includes(".sync")) return false;
172585
+ if (path55.startsWith("studios/")) return true;
172586
+ if (SETTINGS.includes(path55)) return true;
172587
+ if (path55.startsWith("rules/")) return isSettingsPath(path55);
172588
+ if (path55.startsWith("assets/")) return taskOfAssets(path55) !== null;
172589
+ return ROOTS.some((root2) => path55.startsWith(root2)) && path55.endsWith(".md");
172564
172590
  }
172565
172591
  var CARD = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]*\.md$/;
172566
172592
  var ROOT = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]+\/root\.md$/;
172567
- function numberOfCard(path54) {
172568
- const n = ROOT.exec(path54)?.[1] ?? CARD.exec(path54)?.[1];
172593
+ function numberOfCard(path55) {
172594
+ const n = ROOT.exec(path55)?.[1] ?? CARD.exec(path55)?.[1];
172569
172595
  return n ? Number(n) : null;
172570
172596
  }
172571
172597
  var assetsFile = (task) => `assets/${task}.json`;
172572
- var taskOfAssets = (path54) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path54)?.[1] ?? null;
172598
+ var taskOfAssets = (path55) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path55)?.[1] ?? null;
172573
172599
  var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
172574
172600
  var studioName = (id2) => id2.startsWith("wf_builtin_") ? id2.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id2);
172575
172601
  var studioRuleFile = (id2) => `rules/studios/${studioName(id2)}.md`;
@@ -172831,7 +172857,7 @@ function landSections(body, previews) {
172831
172857
  }
172832
172858
  function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
172833
172859
  const problems = [];
172834
- const fail = (offset, path54, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path54, code, message, hint: hint2 });
172860
+ const fail = (offset, path55, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path55, code, message, hint: hint2 });
172835
172861
  const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
172836
172862
  if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
172837
172863
  const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
@@ -174043,9 +174069,9 @@ async function stopConnection(root2, timeout) {
174043
174069
  }
174044
174070
 
174045
174071
  // src/flow.ts
174046
- import fs36 from "node:fs";
174072
+ import fs37 from "node:fs";
174047
174073
  import os6 from "node:os";
174048
- import path42 from "node:path";
174074
+ import path43 from "node:path";
174049
174075
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
174050
174076
 
174051
174077
  // ../cli/src/lib/agent/approved-ui.ts
@@ -174879,10 +174905,10 @@ function findRollout(threadId) {
174879
174905
  }
174880
174906
  for (const name of names2) {
174881
174907
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
174882
- const path54 = join(dir, name);
174908
+ const path55 = join(dir, name);
174883
174909
  try {
174884
- const at2 = statSync(path54).mtimeMs;
174885
- if (!newest2 || at2 > newest2.at) newest2 = { path: path54, at: at2 };
174910
+ const at2 = statSync(path55).mtimeMs;
174911
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path55, at: at2 };
174886
174912
  } catch {
174887
174913
  }
174888
174914
  }
@@ -174890,11 +174916,11 @@ function findRollout(threadId) {
174890
174916
  return newest2?.path;
174891
174917
  }
174892
174918
  function readCodexRunFacts(threadId) {
174893
- const path54 = findRollout(threadId);
174894
- if (!path54) return void 0;
174919
+ const path55 = findRollout(threadId);
174920
+ if (!path55) return void 0;
174895
174921
  let raw;
174896
174922
  try {
174897
- raw = readFileSync(path54, "utf8");
174923
+ raw = readFileSync(path55, "utf8");
174898
174924
  } catch {
174899
174925
  return void 0;
174900
174926
  }
@@ -175006,8 +175032,8 @@ function renderCompleted(item) {
175006
175032
  const changes = Array.isArray(item.changes) ? item.changes : [];
175007
175033
  return changes.map((raw) => {
175008
175034
  const change = obj(raw);
175009
- const path54 = str2(change.path);
175010
- return path54 ? `\u23FA ${str2(change.kind) || "change"}(${path54})
175035
+ const path55 = str2(change.path);
175036
+ return path55 ? `\u23FA ${str2(change.kind) || "change"}(${path55})
175011
175037
  ` : "";
175012
175038
  }).join("");
175013
175039
  }
@@ -175325,10 +175351,10 @@ function readKimiRunFacts(sessionId) {
175325
175351
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
175326
175352
  let model;
175327
175353
  let holding = 0;
175328
- for (const { path: path54, main } of wireFiles(entry.sessionDir)) {
175354
+ for (const { path: path55, main } of wireFiles(entry.sessionDir)) {
175329
175355
  let raw;
175330
175356
  try {
175331
- raw = readFileSync2(path54, "utf8");
175357
+ raw = readFileSync2(path55, "utf8");
175332
175358
  } catch {
175333
175359
  continue;
175334
175360
  }
@@ -175666,8 +175692,8 @@ function createTail(log) {
175666
175692
  // ../cli/package.json
175667
175693
  var package_default = {
175668
175694
  name: "wildcrane",
175669
- version: "0.11.83",
175670
- akbContract: 27,
175695
+ version: "0.11.84",
175696
+ akbContract: 28,
175671
175697
  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.",
175672
175698
  keywords: [
175673
175699
  "kanban",
@@ -175743,8 +175769,8 @@ var CLIENT_CAPABILITIES = {
175743
175769
  };
175744
175770
  function whereHint(update2, title) {
175745
175771
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
175746
- const path54 = str2(obj(locations[0]).path);
175747
- return path54 && !title.includes(path54) ? hint(path54) : "";
175772
+ const path55 = str2(obj(locations[0]).path);
175773
+ return path55 && !title.includes(path55) ? hint(path55) : "";
175748
175774
  }
175749
175775
  function saidBy(update2) {
175750
175776
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -176870,7 +176896,7 @@ async function run(io, options, count2) {
176870
176896
  startupTimer = setTimeout(() => {
176871
176897
  if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
176872
176898
  }, CONVERSATION_MS.start);
176873
- await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path54) => ({ type: "localImage", path: path54 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error62) => {
176899
+ await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path55) => ({ type: "localImage", path: path55 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error62) => {
176874
176900
  if (!started) throw error62;
176875
176901
  });
176876
176902
  };
@@ -179995,6 +180021,26 @@ function probeLogin(binary, harness) {
179995
180021
  // ../cli/src/lib/shared/delivery-evidence.ts
179996
180022
  var ARCHIVE_COMPLETION_BATCH = 100;
179997
180023
 
180024
+ // ../cli/src/lib/cloud/task-operation.ts
180025
+ import fs27 from "node:fs";
180026
+ import path32 from "node:path";
180027
+ var removalFile = (board, task) => path32.join(board, ".sync", `${task}.removal.json`);
180028
+ var taskOfRemoval = (file3) => /^\.sync\/(task_[\w-]+)\.removal\.json$/.exec(file3)?.[1];
180029
+ function readRemoval(board, task) {
180030
+ try {
180031
+ const value = JSON.parse(fs27.readFileSync(removalFile(board, task), "utf8"));
180032
+ if (["pending", "confirmed", "rejected"].includes(value.status) && typeof value.reason === "string" && typeof value.discard === "boolean") return value;
180033
+ } catch {
180034
+ }
180035
+ return null;
180036
+ }
180037
+ function writeRemoval(board, task, removal) {
180038
+ const file3 = removalFile(board, task);
180039
+ const temp = `${file3}.${process.pid}.tmp`;
180040
+ fs27.writeFileSync(temp, JSON.stringify(removal) + "\n");
180041
+ fs27.renameSync(temp, file3);
180042
+ }
180043
+
179998
180044
  // ../cli/src/components/Asset.md
179999
180045
  var Asset_default = '# Asset\n\nShow a file as a Preview with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` or `.htm` `src` loads only the relative paths named in its tags and styles.\n- **Mermaid**: a `.mmd` or `.mermaid` `src` draws a diagram and shows its source if it cannot render.\n- **Documents**: PDF, DOCX, and PPTX open in a read-only viewer with page and zoom controls. DOCX and PPTX previews use LibreOffice and the fonts installed on the Runner. The original remains downloadable.\n- **Excel**: a `.xlsx` draws a read-only workbook with sheet tabs, formulas, and saved results.\n- **Text**: code and other text files show as highlighted text; a `.diff` or `.patch` shows its added and removed lines.\n';
180000
180046
 
@@ -180023,8 +180069,8 @@ function formatStamp(d2) {
180023
180069
  }
180024
180070
 
180025
180071
  // ../cli/src/lib/agents/catalog.ts
180026
- import fs27 from "node:fs";
180027
- import path32 from "node:path";
180072
+ import fs28 from "node:fs";
180073
+ import path33 from "node:path";
180028
180074
  var specAgentCatalog = memoByFiles(() => [AGENTS, ...cloudStudioSources()], readCatalog);
180029
180075
  function readCatalog() {
180030
180076
  const agents = [];
@@ -180083,7 +180129,7 @@ function readBundled(folder2) {
180083
180129
  function projectFolders(root2) {
180084
180130
  let entries;
180085
180131
  try {
180086
- entries = fs27.readdirSync(root2, { withFileTypes: true });
180132
+ entries = fs28.readdirSync(root2, { withFileTypes: true });
180087
180133
  } catch {
180088
180134
  return [];
180089
180135
  }
@@ -180091,12 +180137,12 @@ function projectFolders(root2) {
180091
180137
  }
180092
180138
  function agentFileReader(dir) {
180093
180139
  return (relative) => {
180094
- const target = path32.resolve(dir, relative);
180095
- if (target !== dir && !target.startsWith(dir + path32.sep)) return null;
180140
+ const target = path33.resolve(dir, relative);
180141
+ if (target !== dir && !target.startsWith(dir + path33.sep)) return null;
180096
180142
  try {
180097
- const real = fs27.realpathSync(target);
180098
- if (!real.startsWith(fs27.realpathSync(dir) + path32.sep)) return null;
180099
- return fs27.readFileSync(real, "utf8");
180143
+ const real = fs28.realpathSync(target);
180144
+ if (!real.startsWith(fs28.realpathSync(dir) + path33.sep)) return null;
180145
+ return fs28.readFileSync(real, "utf8");
180100
180146
  } catch {
180101
180147
  return null;
180102
180148
  }
@@ -180106,20 +180152,20 @@ var ownFiles = (paths) => paths.filter((p2) => p2 !== "AGENT.md" && !p2.split("/
180106
180152
  function walkFolder(dir, prefix) {
180107
180153
  let entries;
180108
180154
  try {
180109
- entries = fs27.readdirSync(dir, { withFileTypes: true });
180155
+ entries = fs28.readdirSync(dir, { withFileTypes: true });
180110
180156
  } catch {
180111
180157
  return [];
180112
180158
  }
180113
180159
  return entries.flatMap((e2) => {
180114
180160
  const here = prefix ? `${prefix}/${e2.name}` : e2.name;
180115
- return e2.isDirectory() ? walkFolder(path32.join(dir, e2.name), here) : [here];
180161
+ return e2.isDirectory() ? walkFolder(path33.join(dir, e2.name), here) : [here];
180116
180162
  });
180117
180163
  }
180118
180164
  function readProject2(root2, folder2) {
180119
- const dir = path32.join(root2, folder2);
180165
+ const dir = path33.join(root2, folder2);
180120
180166
  const file3 = agentFileReader(dir);
180121
180167
  const text3 = file3("AGENT.md");
180122
- const missing = rel(path32.join(dir, "AGENT.md"));
180168
+ const missing = rel(path33.join(dir, "AGENT.md"));
180123
180169
  if (text3 === null) return { problem: `${missing} is missing`, file: missing, missing: true };
180124
180170
  const from = missing;
180125
180171
  const read5 = parseSpecAgent(text3, from, file3, false, () => ownFiles(walkFolder(dir, "")));
@@ -180129,8 +180175,8 @@ function readProject2(root2, folder2) {
180129
180175
  }
180130
180176
 
180131
180177
  // ../cli/src/lib/memory.ts
180132
- import fs28 from "node:fs";
180133
- import path33 from "node:path";
180178
+ import fs29 from "node:fs";
180179
+ import path34 from "node:path";
180134
180180
 
180135
180181
  // ../cli/src/lib/slug.ts
180136
180182
  function slugify2(s) {
@@ -180143,25 +180189,25 @@ var PLANNER = "planner";
180143
180189
  var PLANNER_MEMORY_FILES = ["decisions.md", "rejected.md", "redesign.md"];
180144
180190
  var RESERVED_MODULE_NAMES = PLANNER_MEMORY_FILES.map((name) => name.replace(/\.md$/, ""));
180145
180191
  function memoryDirectories(board) {
180146
- const root2 = board ? path33.join(board, "memory") : MEMORY;
180192
+ const root2 = board ? path34.join(board, "memory") : MEMORY;
180147
180193
  const walk = (dir, depth, scoped = true) => {
180148
180194
  let entries;
180149
180195
  try {
180150
- entries = fs28.readdirSync(dir, { withFileTypes: true });
180196
+ entries = fs29.readdirSync(dir, { withFileTypes: true });
180151
180197
  } catch {
180152
180198
  return [];
180153
180199
  }
180154
180200
  return entries.filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).flatMap((e2) => {
180155
- const target = path33.join(dir, e2.name);
180201
+ const target = path34.join(dir, e2.name);
180156
180202
  return depth === 1 ? !scoped || ["project", "workspace"].includes(e2.name) ? [target] : [] : walk(target, depth - 1, scoped);
180157
180203
  });
180158
180204
  };
180159
180205
  return [
180160
180206
  root2,
180161
- ...walk(path33.join(root2, "previews"), 3),
180162
- ...walk(path33.join(root2, "studios"), 1, false),
180163
- path33.join(root2, "agents", PLANNER)
180164
- ].filter((dir) => fs28.existsSync(dir)).map((dir) => `${dir}/`);
180207
+ ...walk(path34.join(root2, "previews"), 3),
180208
+ ...walk(path34.join(root2, "studios"), 1, false),
180209
+ path34.join(root2, "agents", PLANNER)
180210
+ ].filter((dir) => fs29.existsSync(dir)).map((dir) => `${dir}/`);
180165
180211
  }
180166
180212
 
180167
180213
  // ../cli/src/lib/agent/flows.ts
@@ -180592,14 +180638,14 @@ function collectSources(sources3, card, host) {
180592
180638
  const active = /* @__PURE__ */ new Set();
180593
180639
  const out = [];
180594
180640
  const visit2 = (src, types, owner2, partial2 = false) => {
180595
- const path54 = src.replace(/[?#].*$/, "");
180641
+ const path55 = src.replace(/[?#].*$/, "");
180596
180642
  let resolved;
180597
180643
  try {
180598
- resolved = host.resolve(path54, owner2);
180644
+ resolved = host.resolve(path55, owner2);
180599
180645
  } catch (error62) {
180600
180646
  if (owner2 !== card) return { key: null, error: why(error62) };
180601
180647
  if (!nodes.has(src)) {
180602
- const node3 = { key: src, file: null, kind: kindAt(path54, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
180648
+ const node3 = { key: src, file: null, kind: kindAt(path55, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
180603
180649
  nodes.set(src, node3);
180604
180650
  out.push(node3);
180605
180651
  }
@@ -180693,8 +180739,8 @@ function documentPreviewKey(artifact, version2) {
180693
180739
  init_file_limits();
180694
180740
  import { setTimeout as delay2 } from "node:timers/promises";
180695
180741
  import crypto4 from "node:crypto";
180696
- import fs32 from "node:fs";
180697
- import path38 from "node:path";
180742
+ import fs33 from "node:fs";
180743
+ import path39 from "node:path";
180698
180744
  import { isDeepStrictEqual } from "node:util";
180699
180745
 
180700
180746
  // node_modules/node-diff3/dist/diff3.mjs
@@ -180958,8 +181004,8 @@ ${groups.get(id2).join("\n\n")}
180958
181004
 
180959
181005
  // ../cli/src/lib/shared/triage-files.ts
180960
181006
  var ITEM = /^triage\/(?:(dismissed|archived)\/)?([^/]+)\.md$/;
180961
- function itemAt(path54) {
180962
- const m = ITEM.exec(path54);
181007
+ function itemAt(path55) {
181008
+ const m = ITEM.exec(path55);
180963
181009
  if (!m) return null;
180964
181010
  return { state: m[1] === "dismissed" ? "dismissed" : m[1] === "archived" ? "carded" : "open", name: m[2] };
180965
181011
  }
@@ -180989,29 +181035,29 @@ init_dress_page();
180989
181035
 
180990
181036
  // src/kanban-skill.ts
180991
181037
  import { spawnSync as spawnSync6 } from "node:child_process";
180992
- import fs30 from "node:fs";
180993
- import path35 from "node:path";
181038
+ import fs31 from "node:fs";
181039
+ import path36 from "node:path";
180994
181040
  var SKILL_FOLDERS = [".claude/skills/kanban", ".agents/skills/kanban"];
180995
181041
  var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
180996
181042
  function removeLegacyKanbanSkill(root2) {
180997
181043
  for (const folder2 of SKILL_FOLDERS) {
180998
181044
  try {
180999
181045
  let at2 = root2;
181000
- if (!fs30.lstatSync(at2, { throwIfNoEntry: false })?.isDirectory()) continue;
181046
+ if (!fs31.lstatSync(at2, { throwIfNoEntry: false })?.isDirectory()) continue;
181001
181047
  let safe3 = true;
181002
181048
  const parts = `${folder2}/SKILL.md`.split("/");
181003
181049
  for (const [i, name] of parts.entries()) {
181004
- at2 = path35.join(at2, name);
181005
- const stat2 = fs30.lstatSync(at2, { throwIfNoEntry: false });
181050
+ at2 = path36.join(at2, name);
181051
+ const stat2 = fs31.lstatSync(at2, { throwIfNoEntry: false });
181006
181052
  if (!stat2 || stat2.isSymbolicLink() || (i < parts.length - 1 ? !stat2.isDirectory() : !stat2.isFile())) {
181007
181053
  safe3 = false;
181008
181054
  break;
181009
181055
  }
181010
181056
  }
181011
- if (!safe3 || !MANAGED.test(fs30.readFileSync(at2, "utf8"))) continue;
181012
- fs30.unlinkSync(at2);
181013
- const dir = path35.dirname(at2);
181014
- if (fs30.readdirSync(dir).length === 0) fs30.rmdirSync(dir);
181057
+ if (!safe3 || !MANAGED.test(fs31.readFileSync(at2, "utf8"))) continue;
181058
+ fs31.unlinkSync(at2);
181059
+ const dir = path36.dirname(at2);
181060
+ if (fs31.readdirSync(dir).length === 0) fs31.rmdirSync(dir);
181015
181061
  } catch (e2) {
181016
181062
  process.stderr.write(`wildcrane: \u65E0\u6CD5\u6E05\u7406 ${folder2}\uFF1A${e2 instanceof Error ? e2.message : String(e2)}
181017
181063
  `);
@@ -181024,10 +181070,10 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
181024
181070
  if (inside2.status !== 0) return;
181025
181071
  const missing = [".akb/", ...folders2.map((f2) => `${f2}/`)].filter((p2) => git2("check-ignore", "-q", p2).status !== 0);
181026
181072
  if (!missing.length) return;
181027
- const exclude = path35.resolve(dir, inside2.stdout.trim());
181028
- fs30.mkdirSync(path35.dirname(exclude), { recursive: true });
181029
- const held5 = fs30.existsSync(exclude) ? fs30.readFileSync(exclude, "utf8") : "";
181030
- fs30.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
181073
+ const exclude = path36.resolve(dir, inside2.stdout.trim());
181074
+ fs31.mkdirSync(path36.dirname(exclude), { recursive: true });
181075
+ const held5 = fs31.existsSync(exclude) ? fs31.readFileSync(exclude, "utf8") : "";
181076
+ fs31.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
181031
181077
  `);
181032
181078
  }
181033
181079
 
@@ -181074,16 +181120,16 @@ function openTaskFolder(job, projectDir) {
181074
181120
  if (!projectDir) throw new Error(NO_FOLDER);
181075
181121
  keepOutOfGit(projectDir);
181076
181122
  markUsed(projectDir);
181077
- const board = path38.join(projectDir, ".akb", "kanban");
181078
- fs32.mkdirSync(board, { recursive: true });
181123
+ const board = path39.join(projectDir, ".akb", "kanban");
181124
+ fs33.mkdirSync(board, { recursive: true });
181079
181125
  return { task, cloudTask: task, board, cwd: projectDir, project: job.project, number: job.number ?? null, studio: job.studio ?? job.flow?.studio ?? null };
181080
181126
  }
181081
181127
  function openAgentFolder(job, projectDir) {
181082
181128
  if (!job.project || !job.agent) throw new Error("This job names no project.");
181083
181129
  keepOutOfGit(projectDir);
181084
181130
  markUsed(projectDir);
181085
- const board = path38.join(projectDir, ".akb", "kanban");
181086
- fs32.mkdirSync(board, { recursive: true });
181131
+ const board = path39.join(projectDir, ".akb", "kanban");
181132
+ fs33.mkdirSync(board, { recursive: true });
181087
181133
  const recordKey = job.agent.studio ? `${job.agent.studio}-${job.agent.name}` : job.agent.name;
181088
181134
  return {
181089
181135
  task: `agent-${safe2(recordKey)}`,
@@ -181099,8 +181145,8 @@ function openDiscussionFolder(job, projectDir) {
181099
181145
  if (!job.project) throw new Error("This job names no project.");
181100
181146
  keepOutOfGit(projectDir);
181101
181147
  markUsed(projectDir);
181102
- const board = path38.join(projectDir, ".akb", "kanban");
181103
- fs32.mkdirSync(board, { recursive: true });
181148
+ const board = path39.join(projectDir, ".akb", "kanban");
181149
+ fs33.mkdirSync(board, { recursive: true });
181104
181150
  return { task: "discussion", cloudTask: null, board, cwd: projectDir, project: job.project, number: null, studio: null };
181105
181151
  }
181106
181152
  var boardFolder = (ws) => ({ task: "board", cloudTask: null, board: ws.board, cwd: ws.cwd, project: ws.project, number: null, studio: null });
@@ -181111,7 +181157,7 @@ function inFolder(dir, work) {
181111
181157
  const started = performance.now();
181112
181158
  logSync("board.start", { dir, waitMs: Math.round(started - queued) });
181113
181159
  try {
181114
- return await withSyncLock(path38.join(dir, ".akb", "kanban"), work);
181160
+ return await withSyncLock(path39.join(dir, ".akb", "kanban"), work);
181115
181161
  } finally {
181116
181162
  logSync("board.end", { dir, ms: Math.round(performance.now() - started) });
181117
181163
  }
@@ -181125,37 +181171,37 @@ function inFolder(dir, work) {
181125
181171
  }
181126
181172
  var safe2 = (name) => name.replace(/[^\w.-]/g, "_") || "default";
181127
181173
  var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
181128
- var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path38.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
181174
+ var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path39.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
181129
181175
  function findCard(board, number4) {
181130
181176
  const named = new RegExp(`^${number4}-`);
181131
181177
  const walk = (dir) => {
181132
181178
  let entries;
181133
181179
  try {
181134
- entries = fs32.readdirSync(dir, { withFileTypes: true });
181180
+ entries = fs33.readdirSync(dir, { withFileTypes: true });
181135
181181
  } catch {
181136
181182
  return null;
181137
181183
  }
181138
181184
  for (const e2 of entries) {
181139
181185
  if (!named.test(e2.name)) continue;
181140
- if (e2.isFile() && e2.name.endsWith(".md")) return path38.join(dir, e2.name);
181141
- const root2 = path38.join(dir, e2.name, "root.md");
181142
- if (e2.isDirectory() && fs32.existsSync(root2)) return root2;
181186
+ if (e2.isFile() && e2.name.endsWith(".md")) return path39.join(dir, e2.name);
181187
+ const root2 = path39.join(dir, e2.name, "root.md");
181188
+ if (e2.isDirectory() && fs33.existsSync(root2)) return root2;
181143
181189
  }
181144
181190
  for (const e2 of entries) if (e2.isDirectory() && !e2.name.startsWith(".")) {
181145
- const hit = walk(path38.join(dir, e2.name));
181191
+ const hit = walk(path39.join(dir, e2.name));
181146
181192
  if (hit) return hit;
181147
181193
  }
181148
181194
  return null;
181149
181195
  };
181150
- return walk(path38.join(board, "todo")) ?? walk(path38.join(board, ".archive"));
181196
+ return walk(path39.join(board, "todo")) ?? walk(path39.join(board, ".archive"));
181151
181197
  }
181152
181198
  function akbCardOf(ws) {
181153
181199
  return ws.number && findCard(ws.board, ws.number) ? ws.number : void 0;
181154
181200
  }
181155
- var recordFile = (ws) => path38.join(ws.board, ".sync", `${ws.task}.json`);
181201
+ var recordFile = (ws) => path39.join(ws.board, ".sync", `${ws.task}.json`);
181156
181202
  function readRecord(ws) {
181157
181203
  try {
181158
- return { ...EMPTY, ...JSON.parse(fs32.readFileSync(recordFile(ws), "utf8")) };
181204
+ return { ...EMPTY, ...JSON.parse(fs33.readFileSync(recordFile(ws), "utf8")) };
181159
181205
  } catch {
181160
181206
  return structuredClone(EMPTY);
181161
181207
  }
@@ -181166,10 +181212,10 @@ function writeRecord(ws, record2) {
181166
181212
  if (readText(recordFile(ws)) === content) return;
181167
181213
  countSync("recordWrites");
181168
181214
  if (syncDebug) countSync("recordBytes", Buffer.byteLength(content));
181169
- fs32.mkdirSync(path38.dirname(recordFile(ws)), { recursive: true });
181215
+ fs33.mkdirSync(path39.dirname(recordFile(ws)), { recursive: true });
181170
181216
  const file3 = recordFile(ws);
181171
- fs32.writeFileSync(`${file3}.tmp`, content);
181172
- fs32.renameSync(`${file3}.tmp`, file3);
181217
+ fs33.writeFileSync(`${file3}.tmp`, content);
181218
+ fs33.renameSync(`${file3}.tmp`, file3);
181173
181219
  }
181174
181220
  async function cleanRecords(ws, base, options = {}) {
181175
181221
  const { removed = [], tasks, taskChat } = options;
@@ -181178,11 +181224,11 @@ async function cleanRecords(ws, base, options = {}) {
181178
181224
  const removedPaths = new Set(removed);
181179
181225
  const numbers = new Set(Object.keys(base.files).filter((p2) => p2.startsWith(root2) && !removedPaths.has(p2)).map((p2) => numberOfCard(p2.slice(root2.length))));
181180
181226
  const deleted = new Map(removed.filter((p2) => p2.startsWith(root2 + ".archive/")).map((p2) => [numberOfCard(p2.slice(root2.length)), p2.slice(root2.length)]));
181181
- for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path38.join(ws.board, ".sync"))) {
181227
+ for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path39.join(ws.board, ".sync"))) {
181182
181228
  if (!name.endsWith(".json") || name.includes("/")) continue;
181183
181229
  let record2;
181184
181230
  try {
181185
- record2 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
181231
+ record2 = JSON.parse(fs33.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
181186
181232
  } catch {
181187
181233
  continue;
181188
181234
  }
@@ -181198,7 +181244,7 @@ async function cleanRecords(ws, base, options = {}) {
181198
181244
  const folder2 = { ...ws, task: record2.task, cloudTask: record2.task, number: record2.number };
181199
181245
  const list3 = assetsFile(record2.task);
181200
181246
  const before = base.files[root2 + list3]?.content ?? null;
181201
- if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(path38.join(ws.board, list3)) === before) continue;
181247
+ if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(path39.join(ws.board, list3)) === before) continue;
181202
181248
  const card = findCard(ws.board, record2.number);
181203
181249
  if (!record2.deleted && deleted.has(record2.number)) {
181204
181250
  record2.deleted = deleted.get(record2.number);
@@ -181216,13 +181262,13 @@ async function cleanRecords(ws, base, options = {}) {
181216
181262
  taskIndexes.set(ws.cwd, index);
181217
181263
  index.retiring.add(record2.task);
181218
181264
  if (card || kept(ws.cwd) || base.pendingAssets?.includes(record2.task)) continue;
181219
- const here = readText(path38.join(ws.board, list3));
181265
+ const here = readText(path39.join(ws.board, list3));
181220
181266
  if (here !== null && here !== before) continue;
181221
181267
  let changed = false;
181222
181268
  for (const [name2, entry] of Object.entries(record2.assets ?? {})) {
181223
181269
  let file3;
181224
181270
  try {
181225
- file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ? path38.join(ws.board, record2.deleted) : cardFile(folder2));
181271
+ file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ? path39.join(ws.board, record2.deleted) : cardFile(folder2));
181226
181272
  } catch {
181227
181273
  changed = true;
181228
181274
  break;
@@ -181235,16 +181281,16 @@ async function cleanRecords(ws, base, options = {}) {
181235
181281
  }
181236
181282
  }
181237
181283
  if (!changed) {
181238
- fs32.rmSync(recordFile(folder2), { force: true });
181284
+ fs33.rmSync(recordFile(folder2), { force: true });
181239
181285
  forgetTask(index, record2.task);
181240
181286
  }
181241
181287
  }
181242
181288
  return retired;
181243
181289
  }
181244
- var baseFile = (ws) => path38.join(ws.cwd, ".akb", "base.json");
181290
+ var baseFile = (ws) => path39.join(ws.cwd, ".akb", "base.json");
181245
181291
  function readBase(ws) {
181246
181292
  try {
181247
- const base = JSON.parse(fs32.readFileSync(baseFile(ws), "utf8"));
181293
+ const base = JSON.parse(fs33.readFileSync(baseFile(ws), "utf8"));
181248
181294
  if (base.layout === "workspace") return base;
181249
181295
  } catch {
181250
181296
  }
@@ -181256,30 +181302,30 @@ function archiveMeta(content) {
181256
181302
  }
181257
181303
  function writeBase(ws, base) {
181258
181304
  const root2 = rootOf(ws);
181259
- for (const [task, version2] of Object.entries(base.reconciledArchives ?? {})) {
181260
- const archive = base.files[root2 + version2.path];
181261
- if (!archive || archive.seq !== version2.seq && !archiveMeta(archive.content)) delete base.reconciledArchives[task];
181305
+ for (const [task, receipt] of Object.entries(base.archiveReceipts ?? {})) {
181306
+ const archive = base.files[root2 + receipt.path];
181307
+ if (!archive || archive.seq !== receipt.seq && !archiveMeta(archive.content)) delete base.archiveReceipts[task];
181262
181308
  }
181263
181309
  const file3 = baseFile(ws);
181264
- fs32.mkdirSync(path38.dirname(file3), { recursive: true });
181265
- fs32.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
181266
- fs32.renameSync(`${file3}.tmp`, file3);
181310
+ fs33.mkdirSync(path39.dirname(file3), { recursive: true });
181311
+ fs33.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
181312
+ fs33.renameSync(`${file3}.tmp`, file3);
181267
181313
  }
181268
181314
  var hashOf2 = (bytes2) => crypto4.createHash("sha256").update(bytes2).digest("hex");
181269
181315
  function hashFile(file3) {
181270
181316
  try {
181271
- return hashOf2(fs32.readFileSync(file3));
181317
+ return hashOf2(fs33.readFileSync(file3));
181272
181318
  } catch {
181273
181319
  return null;
181274
181320
  }
181275
181321
  }
181276
181322
  function write(file3, bytes2) {
181277
- fs32.mkdirSync(path38.dirname(file3), { recursive: true });
181278
- fs32.writeFileSync(file3, bytes2);
181323
+ fs33.mkdirSync(path39.dirname(file3), { recursive: true });
181324
+ fs33.writeFileSync(file3, bytes2);
181279
181325
  }
181280
181326
  function readText(file3) {
181281
181327
  try {
181282
- return fs32.readFileSync(file3, "utf8");
181328
+ return fs33.readFileSync(file3, "utf8");
181283
181329
  } catch {
181284
181330
  return null;
181285
181331
  }
@@ -181288,14 +181334,14 @@ function filesUnder(dir, base = dir, skipDirectory) {
181288
181334
  if (dir === skipDirectory) return [];
181289
181335
  let entries;
181290
181336
  try {
181291
- entries = fs32.readdirSync(dir, { withFileTypes: true });
181337
+ entries = fs33.readdirSync(dir, { withFileTypes: true });
181292
181338
  } catch {
181293
181339
  return [];
181294
181340
  }
181295
181341
  return entries.flatMap((e2) => {
181296
- const full = path38.join(dir, e2.name);
181342
+ const full = path39.join(dir, e2.name);
181297
181343
  if (e2.isDirectory()) return filesUnder(full, base, skipDirectory);
181298
- return e2.isFile() ? [path38.relative(base, full).split(path38.sep).join("/")] : [];
181344
+ return e2.isFile() ? [path39.relative(base, full).split(path39.sep).join("/")] : [];
181299
181345
  });
181300
181346
  }
181301
181347
  var kept3 = (file3) => isBoardPath(file3) && !/^memory\/agents\/(?!planner\/)/.test(file3);
@@ -181317,18 +181363,18 @@ function assetFiles(ws, list3, card = cardFile(ws)) {
181317
181363
  return null;
181318
181364
  }
181319
181365
  };
181320
- return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path38.relative(ws.board, f2).split(path38.sep).join("/")));
181366
+ return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path39.relative(ws.board, f2).split(path39.sep).join("/")));
181321
181367
  }
181322
181368
  var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
181323
181369
  var localFiles = (ws, base) => {
181324
- const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path38.join(ws.board, assetsFile(ws.task))))]);
181325
- return filesUnder(ws.board, ws.board, path38.join(ws.board, "deliveries")).filter((p2) => kept3(p2) && !assets.has(p2));
181370
+ const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path39.join(ws.board, assetsFile(ws.task))))]);
181371
+ return filesUnder(ws.board, ws.board, path39.join(ws.board, "deliveries")).filter((p2) => kept3(p2) && !assets.has(p2));
181326
181372
  };
181327
181373
  var SKILL_PATH = /^skills\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?:[\w.-]+\/)*[\w.-]+)$/;
181328
181374
  function pullTools(ws, record2, files) {
181329
181375
  const held5 = record2.tools?.skills ?? {};
181330
181376
  const ours = new Set(Object.keys(held5).map((name) => name.split("/")[1]));
181331
- const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs32.existsSync(path38.join(ws.cwd, root2, skill)));
181377
+ const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs33.existsSync(path39.join(ws.cwd, root2, skill)));
181332
181378
  const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
181333
181379
  const skills = {};
181334
181380
  for (const [name, text3] of Object.entries(files)) {
@@ -181336,7 +181382,7 @@ function pullTools(ws, record2, files) {
181336
181382
  if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
181337
181383
  skills[name] = hashOf2(text3);
181338
181384
  for (const root2 of SKILL_ROOTS) {
181339
- const file3 = path38.join(ws.cwd, root2, at2[1], at2[2]);
181385
+ const file3 = path39.join(ws.cwd, root2, at2[1], at2[2]);
181340
181386
  if (held5[name] !== skills[name] || hashFile(file3) !== skills[name]) write(file3, text3);
181341
181387
  }
181342
181388
  }
@@ -181345,8 +181391,8 @@ function pullTools(ws, record2, files) {
181345
181391
  const [, skill, rest] = SKILL_PATH.exec(name) ?? [];
181346
181392
  if (!skill || !rest) continue;
181347
181393
  for (const root2 of SKILL_ROOTS) {
181348
- fs32.rmSync(path38.join(ws.cwd, root2, skill, rest), { force: true });
181349
- if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs32.rmSync(path38.join(ws.cwd, root2, skill), { recursive: true, force: true });
181394
+ fs33.rmSync(path39.join(ws.cwd, root2, skill, rest), { force: true });
181395
+ if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs33.rmSync(path39.join(ws.cwd, root2, skill), { recursive: true, force: true });
181350
181396
  }
181351
181397
  }
181352
181398
  const names2 = [...new Set(Object.keys(skills).map((name) => name.split("/")[1]))];
@@ -181376,46 +181422,46 @@ async function pullStudio(ws, record2) {
181376
181422
  if (files.ok) pullTools(ws, record2, files.value);
181377
181423
  }
181378
181424
  dropPlacedAgents(ws);
181379
- for (const name of Object.keys(record2.agents ?? {})) fs32.rmSync(path38.join(ws.board, name), { force: true });
181425
+ for (const name of Object.keys(record2.agents ?? {})) fs33.rmSync(path39.join(ws.board, name), { force: true });
181380
181426
  record2.agents = {};
181381
181427
  return { ok: true, value: void 0 };
181382
181428
  }
181383
- var agentsRecord = (ws) => path38.join(ws.board, ".sync", "agents.json");
181429
+ var agentsRecord = (ws) => path39.join(ws.board, ".sync", "agents.json");
181384
181430
  function readPlaced(ws) {
181385
181431
  try {
181386
- return JSON.parse(fs32.readFileSync(agentsRecord(ws), "utf8"));
181432
+ return JSON.parse(fs33.readFileSync(agentsRecord(ws), "utf8"));
181387
181433
  } catch {
181388
181434
  return {};
181389
181435
  }
181390
181436
  }
181391
181437
  function dropPlacedAgents(ws) {
181392
181438
  const placed = readPlaced(ws);
181393
- for (const name of Object.keys(placed)) if (hashFile(path38.join(ws.board, name)) === placed[name]) fs32.rmSync(path38.join(ws.board, name), { force: true });
181394
- fs32.rmSync(agentsRecord(ws), { force: true });
181439
+ for (const name of Object.keys(placed)) if (hashFile(path39.join(ws.board, name)) === placed[name]) fs33.rmSync(path39.join(ws.board, name), { force: true });
181440
+ fs33.rmSync(agentsRecord(ws), { force: true });
181395
181441
  }
181396
181442
  function assetPath(ws, name, owner2) {
181397
181443
  if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
181398
- if (path38.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
181444
+ if (path39.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
181399
181445
  const held5 = /^\.assets\//.exec(name);
181400
181446
  const state = stateDir(ws);
181401
- const root2 = held5 && state ? path38.join(state, "assets") : ws.board;
181402
- const file3 = held5 && state ? path38.resolve(root2, name.slice(held5[0].length)) : path38.resolve(path38.dirname(owner2), name);
181403
- const roots = [ws.board, ...state ? ["assets"].map((folder2) => path38.join(state, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181404
- const inside2 = (file4, root3) => file4.startsWith(root3 + path38.sep);
181447
+ const root2 = held5 && state ? path39.join(state, "assets") : ws.board;
181448
+ const file3 = held5 && state ? path39.resolve(root2, name.slice(held5[0].length)) : path39.resolve(path39.dirname(owner2), name);
181449
+ const roots = [ws.board, ...state ? ["assets"].map((folder2) => path39.join(state, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181450
+ const inside2 = (file4, root3) => file4.startsWith(root3 + path39.sep);
181405
181451
  if (!roots.some((root3) => inside2(file3, root3))) throw new Error(`outside the board: ${name}`);
181406
181452
  let existing = file3;
181407
- while (!fs32.existsSync(existing) && path38.dirname(existing) !== existing) existing = path38.dirname(existing);
181408
- const real = path38.join(fs32.realpathSync(existing), path38.relative(existing, file3));
181453
+ while (!fs33.existsSync(existing) && path39.dirname(existing) !== existing) existing = path39.dirname(existing);
181454
+ const real = path39.join(fs33.realpathSync(existing), path39.relative(existing, file3));
181409
181455
  let stateParent = state;
181410
- while (stateParent && !fs32.existsSync(stateParent) && path38.dirname(stateParent) !== stateParent) stateParent = path38.dirname(stateParent);
181411
- const realState = state && stateParent ? path38.resolve(fs32.realpathSync(stateParent), path38.relative(stateParent, state)) : null;
181412
- const realRoots = [fs32.realpathSync(ws.board), ...realState ? ["assets"].map((folder2) => path38.join(realState, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181456
+ while (stateParent && !fs33.existsSync(stateParent) && path39.dirname(stateParent) !== stateParent) stateParent = path39.dirname(stateParent);
181457
+ const realState = state && stateParent ? path39.resolve(fs33.realpathSync(stateParent), path39.relative(stateParent, state)) : null;
181458
+ const realRoots = [fs33.realpathSync(ws.board), ...realState ? ["assets"].map((folder2) => path39.join(realState, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181413
181459
  if (!realRoots.some((root3) => real === root3 || inside2(real, root3))) throw new Error(`link outside the board: ${name}`);
181414
181460
  return file3;
181415
181461
  }
181416
181462
  function cardAssetsDir(ws, id2) {
181417
181463
  const state = stateDir(ws);
181418
- return state && path38.join(state, "assets", String(id2));
181464
+ return state && path39.join(state, "assets", String(id2));
181419
181465
  }
181420
181466
  function stateDir(ws) {
181421
181467
  try {
@@ -181486,8 +181532,8 @@ async function prepareConflictTask(ws) {
181486
181532
  const p2 = f2.path.slice(root2.length);
181487
181533
  if (!kept3(p2)) continue;
181488
181534
  if (!(missing && cards.includes(f2)) && p2 !== assetsFile(ws.task)) continue;
181489
- if (protectedPaths.has(p2) || readText(path38.join(ws.board, p2)) !== null || base.files[f2.path]) continue;
181490
- write(path38.join(ws.board, p2), f2.content);
181535
+ if (protectedPaths.has(p2) || readText(path39.join(ws.board, p2)) !== null || base.files[f2.path]) continue;
181536
+ write(path39.join(ws.board, p2), f2.content);
181491
181537
  base.files[f2.path] = { seq: f2.seq, content: f2.content };
181492
181538
  changed = true;
181493
181539
  }
@@ -181496,7 +181542,7 @@ async function prepareConflictTask(ws) {
181496
181542
  const record2 = readRecord(ws);
181497
181543
  const studio = await pullStudio(ws, record2);
181498
181544
  if (!studio.ok) return studio;
181499
- const assets = await pullAssets(ws, record2, assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))) ?? assetsListOf(ws, base)), true);
181545
+ const assets = await pullAssets(ws, record2, assetsOf(readText(path39.join(ws.board, assetsFile(ws.task))) ?? assetsListOf(ws, base)), true);
181500
181546
  if (!assets.ok) return assets;
181501
181547
  writeRecord(ws, record2);
181502
181548
  return { ok: true, value: void 0 };
@@ -181520,16 +181566,16 @@ function applyRestorations(ws, base, files) {
181520
181566
  if (number4 === null || !stamp3 || base.files[f2.path]?.content === f2.content) continue;
181521
181567
  const old = Object.entries(base.files).find(([name]) => name.startsWith(root2) && numberOfCard(name.slice(root2.length)) === number4);
181522
181568
  if (old && old[0] === f2.path && /^restored:\s*(.+)$/m.exec(old[1].content)?.[1] === stamp3) continue;
181523
- for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board))) {
181569
+ for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path39.join(ws.board, dir), ws.board))) {
181524
181570
  if (numberOfCard(local) !== number4) continue;
181525
- const here = readText(path38.join(ws.board, local));
181571
+ const here = readText(path39.join(ws.board, local));
181526
181572
  if (here !== null && here !== base.files[root2 + local]?.content && here !== f2.content) {
181527
- write(path38.join(ws.board, ".sync", "restored", String(f2.seq), local), here);
181573
+ write(path39.join(ws.board, ".sync", "restored", String(f2.seq), local), here);
181528
181574
  }
181529
181575
  restored.add(local);
181530
- if (local !== p2) fs32.rmSync(path38.join(ws.board, local), { force: true });
181576
+ if (local !== p2) fs33.rmSync(path39.join(ws.board, local), { force: true });
181531
181577
  }
181532
- write(path38.join(ws.board, p2), f2.content);
181578
+ write(path39.join(ws.board, p2), f2.content);
181533
181579
  restored.add(p2);
181534
181580
  }
181535
181581
  return restored;
@@ -181542,7 +181588,7 @@ function observeConflicts(ws, base, files) {
181542
181588
  const own2 = f2.path.startsWith(root2);
181543
181589
  const p2 = own2 ? f2.path.slice(root2.length) : f2.path;
181544
181590
  if (pending.has(p2) || !kept3(p2) || (p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length))) !== !own2) return false;
181545
- return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path38.join(ws.board, p2)), f2.content).conflict;
181591
+ return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path39.join(ws.board, p2)), f2.content).conflict;
181546
181592
  });
181547
181593
  if (!conflicting) return false;
181548
181594
  const changed = new Map(files.map((f2) => [f2.path, f2]));
@@ -181552,7 +181598,7 @@ function observeConflicts(ws, base, files) {
181552
181598
  if (pending.has(p2)) continue;
181553
181599
  const remotePath = remoteOf(ws, shared, p2);
181554
181600
  const before = base.files[remotePath]?.content ?? null;
181555
- const here = readText(path38.join(ws.board, p2));
181601
+ const here = readText(path39.join(ws.board, p2));
181556
181602
  if (here === before) continue;
181557
181603
  const there = changed.get(remotePath) ?? { content: before, seq: base.files[remotePath]?.seq ?? base.deleted?.[remotePath] ?? 0 };
181558
181604
  const merged = mergeFile(before, here, there.content);
@@ -181577,7 +181623,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
181577
181623
  const base = readBase(ws);
181578
181624
  const previous = { ...base.files };
181579
181625
  const known2 = new Set(Object.keys(base.files));
181580
- const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path38.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
181626
+ const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path39.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
181581
181627
  if (base.workspace === void 0) {
181582
181628
  const project = await readProject(ws.project);
181583
181629
  if (!project.ok) return project;
@@ -181587,7 +181633,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
181587
181633
  if (!read5.ok) return read5;
181588
181634
  const restored = applyRestorations(ws, base, read5.value.files);
181589
181635
  if (base.head_seq !== null && observeConflicts(ws, base, read5.value.files)) return { ok: false, code: "board_content_conflict", error: "Resolve the saved board content conflicts before refreshing." };
181590
- const dirty = new Set(base.head_seq === null ? [] : [.../* @__PURE__ */ new Set([...localFiles(ws, base), ...viewOf(ws, base, sharedMemory(ws.board)).keys()])].filter((p2) => !restored.has(p2) && readText(path38.join(ws.board, p2)) !== (previous[remoteOf(ws, sharedMemory(ws.board), p2)]?.content ?? null)));
181636
+ const dirty = new Set(base.head_seq === null ? [] : [.../* @__PURE__ */ new Set([...localFiles(ws, base), ...viewOf(ws, base, sharedMemory(ws.board)).keys()])].filter((p2) => !restored.has(p2) && readText(path39.join(ws.board, p2)) !== (previous[remoteOf(ws, sharedMemory(ws.board), p2)]?.content ?? null)));
181591
181637
  for (const p2 of dirty) keepDraft.add(p2);
181592
181638
  if (base.head_seq === null) base.files = {};
181593
181639
  for (const f2 of read5.value.files) {
@@ -181605,20 +181651,20 @@ async function readCloud(ws, preserveAssets, taskChat) {
181605
181651
  const removed = [...known2].filter((p2) => !base.files[p2]);
181606
181652
  for (const p2 of removed) {
181607
181653
  const local = p2.startsWith(rootOf(ws)) ? p2.slice(rootOf(ws).length) : p2;
181608
- if (local.startsWith(".archive/") && readText(path38.join(ws.board, local)) !== null && readText(path38.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
181654
+ if (local.startsWith(".archive/") && readText(path39.join(ws.board, local)) !== null && readText(path39.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
181609
181655
  }
181610
181656
  if (!dirty.size) base.head_seq = read5.value.head_seq;
181611
181657
  base.project = ws.project;
181612
181658
  writeBase(ws, base);
181613
181659
  const reset = (view2) => {
181614
181660
  for (const [p2, content] of view2) {
181615
- const file3 = path38.join(ws.board, p2);
181661
+ const file3 = path39.join(ws.board, p2);
181616
181662
  if (!keepDraft.has(p2) && kept3(p2) && readText(file3) !== content) write(file3, content);
181617
181663
  }
181618
181664
  };
181619
181665
  const view = viewOf(ws, base, sharedMemory(ws.board));
181620
181666
  const first = (p2) => isSettingsPath(p2) && !known2.has(rootOf(ws) + p2);
181621
- for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs32.rmSync(path38.join(ws.board, p2), { force: true });
181667
+ for (const p2 of localFiles(ws, base)) if (!keepDraft.has(p2) && !view.has(p2) && !first(p2)) fs33.rmSync(path39.join(ws.board, p2), { force: true });
181622
181668
  reset(view);
181623
181669
  const retired = await cleanRecords(ws, base, { removed, taskChat });
181624
181670
  if (retired.has(ws.task)) {
@@ -181636,18 +181682,18 @@ async function readCloud(ws, preserveAssets, taskChat) {
181636
181682
  return { ok: true, value: void 0 };
181637
181683
  }
181638
181684
  function writeIndex(board) {
181639
- const todo = path38.join(board, "todo");
181685
+ const todo = path39.join(board, "todo");
181640
181686
  const cards = [];
181641
181687
  let entries = [];
181642
181688
  try {
181643
- entries = fs32.readdirSync(todo, { withFileTypes: true });
181689
+ entries = fs33.readdirSync(todo, { withFileTypes: true });
181644
181690
  } catch {
181645
181691
  }
181646
181692
  for (const e2 of entries) {
181647
181693
  const id2 = /^(\d+)-/.exec(e2.name)?.[1];
181648
181694
  if (!id2) continue;
181649
181695
  const link = e2.isDirectory() ? `${e2.name}/root.md` : e2.name.endsWith(".md") ? e2.name : null;
181650
- const text4 = link && readText(path38.join(todo, link));
181696
+ const text4 = link && readText(path39.join(todo, link));
181651
181697
  if (text4 === null || !link) continue;
181652
181698
  cards.push({ id: Number(id2), title: cardFront(text4).title ?? e2.name.replace(/\.md$/, ""), link });
181653
181699
  }
@@ -181662,7 +181708,7 @@ the number at the front of a filename is the task id.
181662
181708
 
181663
181709
  ${list3}
181664
181710
  `;
181665
- if (readText(path38.join(todo, "README.md")) !== text3) write(path38.join(todo, "README.md"), text3);
181711
+ if (readText(path39.join(todo, "README.md")) !== text3) write(path39.join(todo, "README.md"), text3);
181666
181712
  }
181667
181713
  var workspaceOf = (ws) => readBase(ws).workspace ?? null;
181668
181714
  async function pullAssets(ws, record2, assets, preserve = false) {
@@ -181750,7 +181796,7 @@ async function pullAssets(ws, record2, assets, preserve = false) {
181750
181796
  }
181751
181797
  if (!child) return src;
181752
181798
  dependencies.push(name2);
181753
- const back = !found.text && /^\.assets\//.test(name2) ? name2 : path38.relative(path38.dirname(target), child).split(path38.sep).join("/");
181799
+ const back = !found.text && /^\.assets\//.test(name2) ? name2 : path39.relative(path39.dirname(target), child).split(path39.sep).join("/");
181754
181800
  if (back !== src) changed = true;
181755
181801
  return back;
181756
181802
  });
@@ -181787,20 +181833,20 @@ async function readAsset(artifact, version2) {
181787
181833
  return { ok: true, value: Buffer.from(typeof content === "string" ? content : JSON.stringify(content)) };
181788
181834
  }
181789
181835
  async function sentOf(file3, kind) {
181790
- const ext = path38.extname(file3).toLowerCase();
181836
+ const ext = path39.extname(file3).toLowerCase();
181791
181837
  if (kind !== "html") {
181792
181838
  const office = officeExtension(file3);
181793
181839
  const type = office ? OFFICE_TYPES[office] : kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext];
181794
- return { bytes: fs32.readFileSync(file3), type: type ?? "application/octet-stream", kind };
181840
+ return { bytes: fs33.readFileSync(file3), type: type ?? "application/octet-stream", kind };
181795
181841
  }
181796
181842
  const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file3);
181797
181843
  return { bytes: Buffer.from(page), type: "text/html", kind };
181798
181844
  }
181799
- var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
181845
+ var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path39.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
181800
181846
  function undrawn(ws, reason) {
181801
181847
  const state = stateDir(ws);
181802
- for (const [root2, shown] of [...state ? [[path38.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
181803
- reason = reason.split(`file://${root2}${path38.sep}`).join(shown && `${shown}/`).split(`${root2}${path38.sep}`).join(shown && `${shown}/`);
181848
+ for (const [root2, shown] of [...state ? [[path39.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
181849
+ reason = reason.split(`file://${root2}${path39.sep}`).join(shown && `${shown}/`).split(`${root2}${path39.sep}`).join(shown && `${shown}/`);
181804
181850
  }
181805
181851
  return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
181806
181852
  }
@@ -181876,14 +181922,14 @@ async function pushAssets(ws, record2, before) {
181876
181922
  if (body === null) return { ok: true, value: void 0 };
181877
181923
  const refs = {};
181878
181924
  const canonical = (target) => {
181879
- const real = (file4) => fs32.existsSync(file4) ? fs32.realpathSync(file4) : path38.dirname(file4) === file4 ? file4 : path38.join(real(path38.dirname(file4)), path38.basename(file4));
181925
+ const real = (file4) => fs33.existsSync(file4) ? fs33.realpathSync(file4) : path39.dirname(file4) === file4 ? file4 : path39.join(real(path39.dirname(file4)), path39.basename(file4));
181880
181926
  target = real(target);
181881
181927
  const state = stateDir(ws);
181882
181928
  for (const folder2 of ["assets"]) {
181883
- const root2 = state && real(path38.join(state, folder2));
181884
- if (root2 && target.startsWith(root2 + path38.sep)) return `.${folder2}/${path38.relative(root2, target).split(path38.sep).join("/")}`;
181929
+ const root2 = state && real(path39.join(state, folder2));
181930
+ if (root2 && target.startsWith(root2 + path39.sep)) return `.${folder2}/${path39.relative(root2, target).split(path39.sep).join("/")}`;
181885
181931
  }
181886
- return path38.relative(real(path38.dirname(file3)), target).split(path38.sep).join("/");
181932
+ return path39.relative(real(path39.dirname(file3)), target).split(path39.sep).join("/");
181887
181933
  };
181888
181934
  const required2 = new Map(parsePreviewBlocks(body).blocks.flatMap((block) => bodyReferences(block.instructions).filter((ref) => ref.types.length).map((ref) => [ref.src, sourcePosition(body, block.start).line])));
181889
181935
  try {
@@ -181895,11 +181941,11 @@ async function pushAssets(ws, record2, before) {
181895
181941
  const target = assetPath(ws, src, owner2);
181896
181942
  if (!target) return null;
181897
181943
  const key = owner2 === file3 && before[src] ? src : canonical(target);
181898
- if (!fs32.statSync(target, { throwIfNoEntry: false })?.isFile()) {
181944
+ if (!fs33.statSync(target, { throwIfNoEntry: false })?.isFile()) {
181899
181945
  if (before[key]) return { key, file: null };
181900
181946
  throw new Error(`file not found: ${target}`);
181901
181947
  }
181902
- return { key: canonical(fs32.realpathSync(target)), file: target };
181948
+ return { key: canonical(fs33.realpathSync(target)), file: target };
181903
181949
  },
181904
181950
  read: referenceText,
181905
181951
  retained: (key, types) => {
@@ -181923,7 +181969,7 @@ async function pushAssets(ws, record2, before) {
181923
181969
  let why2 = node2.error ?? (partialStudio ? void 0 : [...node2.dependencies.values()].map((key) => refs[key]?.error).find(Boolean));
181924
181970
  if (!why2 && node2.file) {
181925
181971
  try {
181926
- if (fs32.statSync(node2.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
181972
+ if (fs33.statSync(node2.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
181927
181973
  out = await sentOf(node2.file, kind);
181928
181974
  } catch (error62) {
181929
181975
  why2 = renderError(error62);
@@ -181933,7 +181979,7 @@ async function pushAssets(ws, record2, before) {
181933
181979
  if (why2) {
181934
181980
  const key = [...node2.aliases].find((alias) => required2.has(alias));
181935
181981
  if (key) {
181936
- const error62 = `${path38.relative(ws.board, file3)}:${required2.get(key)} \u2014 ${key}: ${undrawn(ws, why2)}`;
181982
+ const error62 = `${path39.relative(ws.board, file3)}:${required2.get(key)} \u2014 ${key}: ${undrawn(ws, why2)}`;
181937
181983
  return { ok: false, code: "bad_request", error: error62, failure: validationFailure(error62, "preview_attachment") };
181938
181984
  }
181939
181985
  let pin = old ? { ...old } : previous?.version ? { artifact: previous.artifact, version: previous.version, ...previous.dependencies ? { dependencies: previous.dependencies } : {} } : null;
@@ -181989,7 +182035,7 @@ async function pushAssets(ws, record2, before) {
181989
182035
  const unchanged = restored && previous && (previous.kind ?? out.kind) === out.kind && localHash === (previous.localHash ?? previous.hash) && [...node2.dependencies.values()].every((key) => refs[key]?.artifact === before[key]?.artifact);
181990
182036
  if (!entry || !unchanged && entry.hash !== hash2 || entry.kind && entry.kind !== out.kind) {
181991
182037
  if (!ws.cloudTask) continue;
181992
- let artifact = previous && (previous.kind ?? kindOf(path38.extname(node2.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
182038
+ let artifact = previous && (previous.kind ?? kindOf(path39.extname(node2.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
181993
182039
  if (!artifact) {
181994
182040
  const made = await createArtifact(ws.cloudTask, node2.key.slice(0, 200), out.kind, artifactKey(ws.cloudTask, node2.key, out.kind, previous?.artifact));
181995
182041
  if (!made.ok) return { ...made, error: `${node2.key}: ${made.error}` };
@@ -182046,8 +182092,8 @@ function proposeItems(ws, base, paths) {
182046
182092
  const root2 = rootOf(ws);
182047
182093
  for (const p2 of paths ?? localFiles(ws, base)) {
182048
182094
  if (itemAt(p2)?.state !== "open" || base.files[root2 + p2]) continue;
182049
- const file3 = path38.join(ws.board, p2);
182050
- const content = fs32.readFileSync(file3, "utf8");
182095
+ const file3 = path39.join(ws.board, p2);
182096
+ const content = fs33.readFileSync(file3, "utf8");
182051
182097
  const said = (key) => new RegExp(`^${key}:`, "m").test(content.split(/\n---/)[0] ?? "");
182052
182098
  const fields2 = {
182053
182099
  ...ws.cloudTask && !said("source_task") ? { source_task: ws.cloudTask } : {},
@@ -182079,7 +182125,7 @@ var push = (ws, job, stopped2) => inFolder(ws.cwd, async () => {
182079
182125
  if (busy(preparationKey(ws))) return { ok: false, conflict: false, offline: true, error: "Task content is still being prepared." };
182080
182126
  return sendMarked(ws, job);
182081
182127
  });
182082
- var preparationKey = (ws) => path38.join(projectStateDir(ws.board), "preparing");
182128
+ var preparationKey = (ws) => path39.join(projectStateDir(ws.board), "preparing");
182083
182129
  async function whenPrepared(ws, cancelled, work, stopped2 = () => false) {
182084
182130
  while (!stopped2()) {
182085
182131
  const result = await inFolder(ws.cwd, async () => {
@@ -182124,15 +182170,15 @@ async function sendBoard(ws, machineId, scope) {
182124
182170
  async function sendMarked(ws, job, scope = {}) {
182125
182171
  const pushed = pendingConflicts(ws.board).length ? conflictFailure(ws) : await send2(ws, job, scope);
182126
182172
  const base = readBase(ws);
182127
- markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length);
182173
+ markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length);
182128
182174
  return pushed;
182129
182175
  }
182130
182176
  var boardIdentity = (ws) => {
182131
- const stat2 = fs32.statSync(ws.board);
182177
+ const stat2 = fs33.statSync(ws.board);
182132
182178
  return `${stat2.dev}:${stat2.ino}:${stat2.birthtimeMs}`;
182133
182179
  };
182134
182180
  function rememberDirectories(directories, file3) {
182135
- for (let dir = path38.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path38.posix.dirname(dir)) directories.add(dir);
182181
+ for (let dir = path39.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path39.posix.dirname(dir)) directories.add(dir);
182136
182182
  }
182137
182183
  function newIndex(ws) {
182138
182184
  const directories = /* @__PURE__ */ new Set();
@@ -182161,7 +182207,7 @@ function forgetTask(index, task) {
182161
182207
  }
182162
182208
  function indexTask(ws, record2, card = cardFile(ws)) {
182163
182209
  if (!ws.cloudTask || !ws.number) return;
182164
- const paths = /* @__PURE__ */ new Set([card, path38.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
182210
+ const paths = /* @__PURE__ */ new Set([card, path39.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
182165
182211
  for (const name of Object.keys(record2.assets)) {
182166
182212
  try {
182167
182213
  const file3 = assetPath(ws, name, card);
@@ -182170,7 +182216,7 @@ function indexTask(ws, record2, card = cardFile(ws)) {
182170
182216
  }
182171
182217
  }
182172
182218
  for (const file3 of [...paths]) {
182173
- for (let dir = path38.dirname(file3); dir.startsWith(ws.cwd + path38.sep); dir = path38.dirname(dir)) paths.add(dir);
182219
+ for (let dir = path39.dirname(file3); dir.startsWith(ws.cwd + path39.sep); dir = path39.dirname(dir)) paths.add(dir);
182174
182220
  }
182175
182221
  const index = syncIndex(ws) ?? newIndex(ws);
182176
182222
  for (const file3 of index.tasks.get(ws.task)?.paths ?? []) {
@@ -182190,8 +182236,8 @@ function affectedTasks(ws, paths) {
182190
182236
  const index = syncIndex(ws);
182191
182237
  const tasks = new Set(index?.retiring);
182192
182238
  for (const p2 of paths) {
182193
- for (const task2 of index?.files.get(path38.resolve(ws.board, p2)) ?? []) tasks.add(task2);
182194
- const task = /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
182239
+ for (const task2 of index?.files.get(path39.resolve(ws.board, p2)) ?? []) tasks.add(task2);
182240
+ const task = taskOfRemoval(p2) ?? /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
182195
182241
  if (task) tasks.add(task);
182196
182242
  }
182197
182243
  return tasks;
@@ -182210,13 +182256,13 @@ async function send2(ws, job, { paths, taskChat }) {
182210
182256
  const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
182211
182257
  if (retired.has(ws.task)) record2.deleted = true;
182212
182258
  const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
182213
- ...filesUnder(path38.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
182259
+ ...filesUnder(path39.join(ws.board, ".sync")).filter((name) => name.endsWith(".json") && !taskOfRemoval(".sync/" + name)),
182214
182260
  ...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
182215
182261
  ])];
182216
182262
  const tasks = ws.cloudTask ? [{ folder: ws, record: record2 }] : records.flatMap((name) => {
182217
182263
  let held5;
182218
182264
  try {
182219
- held5 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
182265
+ held5 = JSON.parse(fs33.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
182220
182266
  } catch {
182221
182267
  const known2 = syncIndex(ws)?.tasks.get(name.replace(/\.json$/, ""));
182222
182268
  if (!known2) return [];
@@ -182237,7 +182283,7 @@ async function send2(ws, job, { paths, taskChat }) {
182237
182283
  const assetLists = /* @__PURE__ */ new Map();
182238
182284
  const generatedAssets = /* @__PURE__ */ new Set();
182239
182285
  const cards = !selected && !ws.cloudTask ? new Map(
182240
- [".archive", "todo"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board)).flatMap((p2) => {
182286
+ [".archive", "todo"].flatMap((dir) => filesUnder(path39.join(ws.board, dir), ws.board)).flatMap((p2) => {
182241
182287
  const number4 = numberOfCard(p2);
182242
182288
  return number4 ? [[number4, p2]] : [];
182243
182289
  })
@@ -182245,8 +182291,8 @@ async function send2(ws, job, { paths, taskChat }) {
182245
182291
  for (const item of tasks) {
182246
182292
  processed.add(item.folder.task);
182247
182293
  if (processed.size === 1 || processed.size % 25 === 0) logSync("board.progress", { project: ws.project, processed: processed.size, total: tasks.length });
182248
- const card = cards?.get(item.folder.number) ?? path38.relative(ws.board, cardFile(item.folder)).split(path38.sep).join("/");
182249
- indexTask(item.folder, item.record, path38.join(ws.board, card));
182294
+ const card = cards?.get(item.folder.number) ?? path39.relative(ws.board, cardFile(item.folder)).split(path39.sep).join("/");
182295
+ indexTask(item.folder, item.record, path39.join(ws.board, card));
182250
182296
  selected?.add(card);
182251
182297
  const before = assetsOf(assetsListOf(item.folder, base));
182252
182298
  const newer = Object.entries(before).some(([name, ref]) => {
@@ -182255,7 +182301,7 @@ async function send2(ws, job, { paths, taskChat }) {
182255
182301
  });
182256
182302
  const clean = () => Object.entries(item.record.assets).every(([name, entry]) => {
182257
182303
  try {
182258
- const file3 = assetPath(item.folder, name, path38.join(ws.board, card));
182304
+ const file3 = assetPath(item.folder, name, path39.join(ws.board, card));
182259
182305
  return !file3 || hashFile(file3) === (entry.localHash ?? entry.hash);
182260
182306
  } catch {
182261
182307
  return false;
@@ -182263,7 +182309,7 @@ async function send2(ws, job, { paths, taskChat }) {
182263
182309
  });
182264
182310
  const archive = boardSync && card.startsWith(".archive/") && !item.record.deleted;
182265
182311
  const listPath = assetsFile(item.folder.task);
182266
- const archived = !selected && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path38.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path38.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
182312
+ const archived = !selected && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path39.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path39.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
182267
182313
  if (!archived && !item.record.deleted) {
182268
182314
  const refreshed = newer && clean() ? await pullAssets(item.folder, item.record, before, true) : { ok: true, value: void 0 };
182269
182315
  const assets = refreshed.ok ? await pushAssets(item.folder, item.record, before) : refreshed;
@@ -182272,11 +182318,11 @@ async function send2(ws, job, { paths, taskChat }) {
182272
182318
  indexTask(item.folder, item.record);
182273
182319
  if (archive) archives.set(item.folder.task, card);
182274
182320
  const list3 = listPath;
182275
- const local2 = readText(path38.join(ws.board, list3));
182321
+ const local2 = readText(path39.join(ws.board, list3));
182276
182322
  if (assets.value && (local2 !== null || Object.keys(assets.value).length)) {
182277
182323
  const content = isDeepStrictEqual(assetsOf(local2), assets.value) && local2 !== null ? local2 : assetsText(assets.value);
182278
182324
  assetLists.set(list3, { local: local2, content });
182279
- for (const file3 of assetFiles(item.folder, content, path38.join(ws.board, card))) generatedAssets.add(file3);
182325
+ for (const file3 of assetFiles(item.folder, content, path39.join(ws.board, card))) generatedAssets.add(file3);
182280
182326
  }
182281
182327
  selected?.add(list3);
182282
182328
  continue;
@@ -182293,10 +182339,10 @@ async function send2(ws, job, { paths, taskChat }) {
182293
182339
  }
182294
182340
  if (!ws.cloudTask) syncIndex(ws).ready = true;
182295
182341
  const scoped = selected && [...new Set([...selected].flatMap((p2) => {
182296
- if (!isBoardPath(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182297
- const file3 = path38.join(ws.board, p2);
182298
- return fs32.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
182299
- }))].filter((p2) => fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
182342
+ if (!isBoardPath(p2) && !fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182343
+ const file3 = path39.join(ws.board, p2);
182344
+ return fs33.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
182345
+ }))].filter((p2) => fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
182300
182346
  for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
182301
182347
  proposeItems(ws, base, scoped);
182302
182348
  const shared = sharedMemory(ws.board);
@@ -182326,20 +182372,24 @@ async function send2(ws, job, { paths, taskChat }) {
182326
182372
  const refreshPreviews = !isDeepStrictEqual(pendingPreviews, base.pendingPreviews ?? []);
182327
182373
  if (refreshPreviews) base.pendingPreviews = pendingPreviews;
182328
182374
  if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
182375
+ let operations = {};
182329
182376
  if (boardSync) {
182330
182377
  for (const task of processed) {
182331
182378
  if (!archives.has(task) && !assetErrors[task]) pendingArchives.delete(task);
182332
182379
  }
182333
- await reconcileArchives(ws, base, archives, pendingArchives, job.machineId);
182380
+ const archived = await reconcileArchives(ws, base, archives, pendingArchives, job.machineId);
182381
+ const removed = await reconcileRemovals(ws, base, selected);
182382
+ operations = { ...archived, ...removed };
182334
182383
  syncIndex(ws).archivesReady = true;
182335
182384
  }
182336
182385
  const reported = !ws.number ? previews : previews.filter((p2) => numberOfCard(p2.file) === ws.number);
182337
- const firstError = Object.values(assetErrors)[0];
182386
+ const tasks2 = { ...assetErrors, ...operations };
182387
+ const firstError = Object.values(tasks2)[0];
182338
182388
  if (reported.length) {
182339
182389
  const error62 = describeTaskPreviewProblems(reported);
182340
182390
  return { ok: false, conflict: false, error: error62, failure: validationFailure(error62), previews: reported, tasks: assetErrors };
182341
182391
  }
182342
- if (firstError && (boardSync || firstError.failure)) return { ok: false, conflict: false, ...firstError, tasks: assetErrors };
182392
+ if (firstError && (boardSync || firstError.failure)) return { ok: false, conflict: false, ...firstError, tasks: tasks2 };
182343
182393
  return { ok: true, changed };
182344
182394
  };
182345
182395
  const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(ws, base), ...assetLists.keys()]);
@@ -182351,14 +182401,14 @@ async function send2(ws, job, { paths, taskChat }) {
182351
182401
  if (defer(p2) || owed(p2) || generatedAssets.has(p2)) continue;
182352
182402
  if (selected && tasks.some((item) => assetFiles(item.folder, assetsListOf(item.folder, base)).has(p2))) continue;
182353
182403
  const list3 = assetLists.get(p2);
182354
- const original = list3?.content ?? fs32.readFileSync(path38.join(ws.board, p2), "utf8");
182404
+ const original = list3?.content ?? fs33.readFileSync(path39.join(ws.board, p2), "utf8");
182355
182405
  const remote2 = remoteOf(ws, shared, p2);
182356
182406
  const held5 = base.files[remote2];
182357
182407
  const content = migratedArchive(p2, original, held5?.content);
182358
- if (content !== original && readText(path38.join(ws.board, p2)) === original) {
182359
- const backup = path38.join(ws.board, ".sync", "legacy-previews", hashOf2(Buffer.from(original)), p2);
182408
+ if (content !== original && readText(path39.join(ws.board, p2)) === original) {
182409
+ const backup = path39.join(ws.board, ".sync", "legacy-previews", hashOf2(Buffer.from(original)), p2);
182360
182410
  write(backup, original);
182361
- write(path38.join(ws.board, p2), content);
182411
+ write(path39.join(ws.board, p2), content);
182362
182412
  }
182363
182413
  localOf.set(remote2, p2);
182364
182414
  localBefore.set(remote2, list3 ? list3.local : content);
@@ -182376,7 +182426,7 @@ async function send2(ws, job, { paths, taskChat }) {
182376
182426
  }
182377
182427
  const previous = selected ? new Set([...selected].flatMap((p2) => {
182378
182428
  if (base.files[remoteOf(ws, shared, p2)]) return [p2];
182379
- if (!syncIndex(ws)?.directories.has(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182429
+ if (!syncIndex(ws)?.directories.has(p2) && !fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182380
182430
  return [...viewOf(ws, base, shared).keys()].filter((file3) => file3.startsWith(p2 + "/"));
182381
182431
  })) : viewOf(ws, base, shared).keys();
182382
182432
  for (const p2 of previous) {
@@ -182457,7 +182507,7 @@ async function send2(ws, job, { paths, taskChat }) {
182457
182507
  return conflictFailure(ws);
182458
182508
  }
182459
182509
  for (const [i, f2] of facts.entries()) changes[i] = { path: f2.remotePath, content: f2.automatic.content, base_seq: f2.remote.seq };
182460
- if (facts.some((f2) => readText(path38.join(ws.board, f2.path)) !== f2.local.content)) return fail("Local files changed during synchronization. Try again.", false, "local_changed");
182510
+ if (facts.some((f2) => readText(path39.join(ws.board, f2.path)) !== f2.local.content)) return fail("Local files changed during synchronization. Try again.", false, "local_changed");
182461
182511
  sent = await commit();
182462
182512
  if (sent === null) return success2(false);
182463
182513
  if (!sent.ok && sent.files) {
@@ -182476,8 +182526,14 @@ async function send2(ws, job, { paths, taskChat }) {
182476
182526
  }
182477
182527
  if (!sent.ok && sent.previewProblems?.length) return { ok: false, conflict: false, error: sent.error, failure: validationFailure(sent.error), previews: sent.previewProblems };
182478
182528
  if (!sent.ok) return fail(sent.error, sent.code === "version_conflict", sent.code, sent.status);
182529
+ const committed = sent.value;
182530
+ const versions = new Map(Array.isArray(committed?.files) ? committed.files.filter((f2) => f2 && Number.isSafeInteger(f2.seq) && f2.seq >= 0).map((f2) => [f2.path, f2.seq]) : []);
182531
+ if (!Number.isSafeInteger(committed?.head_seq) || changes.some((c2) => !versions.has(c2.path) || versions.get(c2.path) === 0 && c2.content !== null)) {
182532
+ const problem = invalidResponse("a board write receipt for every file");
182533
+ return fail(problem.message, false, problem.code);
182534
+ }
182479
182535
  for (const c2 of changes) {
182480
- const seq = sent.value.files.find((f2) => f2.path === c2.path)?.seq ?? c2.base_seq;
182536
+ const seq = versions.get(c2.path);
182481
182537
  base.deleted ??= {};
182482
182538
  if (c2.content === null) {
182483
182539
  delete base.files[c2.path];
@@ -182487,19 +182543,55 @@ async function send2(ws, job, { paths, taskChat }) {
182487
182543
  delete base.deleted[c2.path];
182488
182544
  }
182489
182545
  const p2 = localOf.get(c2.path);
182490
- if (p2 && readText(path38.join(ws.board, p2)) === localBefore.get(c2.path)) {
182491
- if (c2.content === null) fs32.rmSync(path38.join(ws.board, p2), { force: true });
182492
- else write(path38.join(ws.board, p2), c2.content);
182546
+ if (p2 && readText(path39.join(ws.board, p2)) === localBefore.get(c2.path)) {
182547
+ if (c2.content === null) fs33.rmSync(path39.join(ws.board, p2), { force: true });
182548
+ else write(path39.join(ws.board, p2), c2.content);
182493
182549
  }
182494
182550
  }
182495
182551
  return success2(true);
182496
182552
  }
182553
+ async function reconcileRemovals(ws, base, selected) {
182554
+ const paths = selected ?? filesUnder(path39.join(ws.board, ".sync"), ws.board);
182555
+ const tasks = /* @__PURE__ */ new Set([...base.pendingRemovals ?? [], ...Array.from(paths, taskOfRemoval).filter((task) => !!task)]);
182556
+ const pending = [];
182557
+ const errors = {};
182558
+ for (const task of tasks) {
182559
+ const held5 = readRemoval(ws.board, task);
182560
+ if (held5?.status !== "pending") continue;
182561
+ const record2 = readRecord({ ...ws, task });
182562
+ const sent = record2.task === task && !record2.deleted ? await cancelTask(task, held5.reason, held5.discard) : { ok: false, code: "not_found", error: "This task is no longer linked to the board." };
182563
+ const current2 = !sent.ok && sent.code === "conflict" ? await readTask(task) : null;
182564
+ if (sent.ok && sent.value?.id === task && sent.value.status === "cancelled" || current2?.ok && current2.value?.status === "cancelled" && (current2.value.cancel_reason ?? "") === held5.reason) {
182565
+ writeRemoval(ws.board, task, { status: "confirmed", reason: held5.reason, discard: held5.discard });
182566
+ continue;
182567
+ }
182568
+ const problem = sent.ok ? { error: invalidResponse("confirmation that the task was removed").message, code: "invalid_response" } : sent;
182569
+ const retry2 = temporaryCloudFailure(problem) || !!current2 && !current2.ok && temporaryCloudFailure(current2);
182570
+ if (retry2) pending.push(task);
182571
+ writeRemoval(ws.board, task, {
182572
+ reason: held5.reason,
182573
+ discard: held5.discard,
182574
+ status: retry2 ? "pending" : "rejected",
182575
+ code: problem.code ?? "unreachable",
182576
+ message: problem.error
182577
+ });
182578
+ if (held5.code !== problem.code || held5.message !== problem.error || !retry2) {
182579
+ errors[task] = { error: `Remove ${task}: ${problem.error}`, code: problem.code ?? "unreachable", offline: retry2, blocking: false };
182580
+ }
182581
+ }
182582
+ if (!isDeepStrictEqual(base.pendingRemovals ?? [], pending)) {
182583
+ base.pendingRemovals = pending;
182584
+ writeBase(ws, base);
182585
+ }
182586
+ return errors;
182587
+ }
182497
182588
  async function reconcileArchives(ws, base, archives, pending, machine) {
182498
182589
  const root2 = rootOf(ws);
182499
- const reconciled = base.reconciledArchives ?? {};
182590
+ const receipts = base.archiveReceipts ?? {};
182591
+ const errors = {};
182500
182592
  for (const [task, p2] of archives) {
182501
- const version2 = reconciled[task];
182502
- if (version2?.path === p2 && version2.seq === base.files[root2 + p2]?.seq && version2.assets_seq === (base.files[root2 + assetsFile(task)]?.seq ?? 0) && !pending.has(task)) continue;
182593
+ const receipt = receipts[task];
182594
+ if (receipt && receipt.status !== "pending" && receipt.path === p2 && receipt.seq === base.files[root2 + p2]?.seq && receipt.assets_seq === (base.files[root2 + assetsFile(task)]?.seq ?? 0) && !pending.has(task)) continue;
182503
182595
  pending.set(task, p2);
182504
182596
  }
182505
182597
  const cards = [];
@@ -182509,20 +182601,21 @@ async function reconcileArchives(ws, base, archives, pending, machine) {
182509
182601
  const list3 = assetsFile(task);
182510
182602
  if (held5.has(p2) || held5.has(list3) || pendingAssets.has(task)) continue;
182511
182603
  const archive = base.files[root2 + p2];
182512
- const local = readText(path38.join(ws.board, p2));
182513
- const meta3 = local === null ? null : archiveMeta(local);
182514
- if (!meta3) {
182604
+ const local = readText(path39.join(ws.board, p2));
182605
+ if (local === null || !archiveMeta(local)) {
182515
182606
  pending.delete(task);
182516
182607
  continue;
182517
182608
  }
182518
182609
  const manifest = base.files[root2 + list3];
182519
- if (!archive || archive.content !== local || readText(path38.join(ws.board, list3)) !== (manifest?.content ?? null)) continue;
182610
+ if (!archive || archive.content !== local || readText(path39.join(ws.board, list3)) !== (manifest?.content ?? null)) continue;
182520
182611
  cards.push({ task, path: p2, seq: archive.seq, assets_seq: manifest?.seq ?? 0 });
182521
182612
  }
182522
182613
  const save3 = (changed) => {
182523
182614
  const next = Object.fromEntries(pending);
182524
182615
  if (!changed && isDeepStrictEqual(next, base.pendingArchives ?? {})) return;
182525
182616
  base.pendingArchives = next;
182617
+ base.archiveReceipts = receipts;
182618
+ delete base.reconciledArchives;
182526
182619
  writeBase(ws, base);
182527
182620
  };
182528
182621
  save3(false);
@@ -182530,19 +182623,37 @@ async function reconcileArchives(ws, base, archives, pending, machine) {
182530
182623
  const batch2 = cards.slice(i, i + ARCHIVE_COMPLETION_BATCH);
182531
182624
  const result = await completeArchives(ws.project, machine, batch2);
182532
182625
  if (!result.ok) {
182533
- logSync("board.archive_completion", { project: ws.project, code: result.code, pending: pending.size });
182626
+ const retry2 = temporaryCloudFailure(result);
182627
+ const code = result.code ?? "unreachable";
182628
+ for (const card of cards.slice(i)) {
182629
+ receipts[card.task] = { ...card, status: retry2 ? "pending" : "rejected", code, message: result.error };
182630
+ if (!retry2) pending.delete(card.task);
182631
+ errors[card.task] = { error: `Archive ${card.task}: ${result.error}`, code, offline: retry2, blocking: false };
182632
+ }
182633
+ logSync("board.archive_completion", { project: ws.project, code, pending: pending.size });
182634
+ save3(true);
182534
182635
  break;
182535
182636
  }
182536
- if (!Array.isArray(result.value?.retry)) break;
182537
- const retry2 = new Set(result.value.retry);
182538
- for (const { task, path: path54, seq, assets_seq } of batch2) {
182539
- if (retry2.has(task)) continue;
182540
- reconciled[task] = { path: path54, seq, assets_seq };
182541
- pending.delete(task);
182637
+ const received = /* @__PURE__ */ new Map();
182638
+ const repeated = /* @__PURE__ */ new Set();
182639
+ for (const receipt of Array.isArray(result.value?.receipts) ? result.value.receipts : []) {
182640
+ if (!isRecord(receipt) || !hasText(receipt.task)) continue;
182641
+ if (received.has(receipt.task)) repeated.add(receipt.task);
182642
+ if (receipt.status === "confirmed" || ["pending", "rejected"].includes(receipt.status) && "code" in receipt && hasText(receipt.code) && hasText(receipt.message)) received.set(receipt.task, receipt);
182643
+ }
182644
+ for (const card of batch2) {
182645
+ const { task, ...version2 } = card;
182646
+ const found = received.get(task);
182647
+ const receipt = !found || repeated.has(task) ? { task, status: "pending", code: "invalid_response", message: invalidResponse("an archive receipt for this task").message } : found;
182648
+ receipts[task] = { ...version2, ...receipt };
182649
+ if (receipt.status !== "pending") pending.delete(task);
182650
+ if (receipt.status === "rejected" || receipt.status === "pending" && receipt.code === "invalid_response") {
182651
+ errors[task] = { error: `Archive ${task}: ${receipt.message}`, code: receipt.code, offline: receipt.status === "pending", blocking: false };
182652
+ }
182542
182653
  }
182543
- base.reconciledArchives = reconciled;
182544
- save3(false);
182654
+ save3(true);
182545
182655
  }
182656
+ return errors;
182546
182657
  }
182547
182658
  function taskStudioContext(ws, docs = true) {
182548
182659
  if (!ws.cloudTask) return "";
@@ -182551,7 +182662,7 @@ function taskStudioContext(ws, docs = true) {
182551
182662
  const read5 = parseStudioFile(studioName(held5.id), held5.files["STUDIO.md"] ?? "", "STUDIO.md");
182552
182663
  if ("problem" in read5) throw new Error(read5.problem);
182553
182664
  const def = read5.def;
182554
- const notes = readText(path38.join(ws.board, studioRuleFile(held5.id)))?.trim();
182665
+ const notes = readText(path39.join(ws.board, studioRuleFile(held5.id)))?.trim();
182555
182666
  return [
182556
182667
  "<studio>",
182557
182668
  def.rules,
@@ -182570,8 +182681,8 @@ ${notes}
182570
182681
  }
182571
182682
 
182572
182683
  // src/saved-previews.ts
182573
- import fs33 from "node:fs";
182574
- import path39 from "node:path";
182684
+ import fs34 from "node:fs";
182685
+ import path40 from "node:path";
182575
182686
 
182576
182687
  // src/sync-retry.ts
182577
182688
  var SYNC_RETRY_MAX_MS = 5 * 6e4;
@@ -182634,10 +182745,10 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
182634
182745
  const version2 = asset2.version;
182635
182746
  const bytes2 = await readAsset(asset2.artifact, version2);
182636
182747
  if (!bytes2.ok) return { ...bytes2, error: `${source2} (saved version ${version2}): ${bytes2.error}` };
182637
- const extension = path39.posix.extname(source2).toLowerCase();
182748
+ const extension = path40.posix.extname(source2).toLowerCase();
182638
182749
  const suffix = extension === ".tsx" && /^\s*(?:<!doctype html|<html)\b/i.test(Buffer.from(bytes2.value.subarray(0, 256)).toString()) ? ".html" : /^\.[a-z0-9]+$/.test(extension) ? extension : "";
182639
- const file3 = path39.join(directory3, `${files.size + 1}-${asset2.artifact}-${version2}${suffix}`);
182640
- fs33.writeFileSync(file3, bytes2.value);
182750
+ const file3 = path40.join(directory3, `${files.size + 1}-${asset2.artifact}-${version2}${suffix}`);
182751
+ fs34.writeFileSync(file3, bytes2.value);
182641
182752
  savedFile = { artifact: asset2.artifact, version: version2, file: file3 };
182642
182753
  files.set(source2, savedFile);
182643
182754
  }
@@ -182647,14 +182758,14 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
182647
182758
 
182648
182759
  ${section.body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : ""}`);
182649
182760
  }
182650
- const manifest = path39.join(directory3, "previews.md");
182651
- fs33.writeFileSync(manifest, sections.join("\n\n") + "\n");
182761
+ const manifest = path40.join(directory3, "previews.md");
182762
+ fs34.writeFileSync(manifest, sections.join("\n\n") + "\n");
182652
182763
  return { ok: true, value: manifest };
182653
182764
  }
182654
182765
 
182655
182766
  // src/triage.ts
182656
- import fs34 from "node:fs";
182657
- import path40 from "node:path";
182767
+ import fs35 from "node:fs";
182768
+ import path41 from "node:path";
182658
182769
 
182659
182770
  // ../cli/src/lib/signals/identity.ts
182660
182771
  import { createHash as createHash5 } from "node:crypto";
@@ -182662,8 +182773,8 @@ var DERIVED = "derived-";
182662
182773
  var derivedSourceId = (seed) => `${DERIVED}${createHash5("sha256").update(seed).digest("hex").slice(0, 16)}`;
182663
182774
 
182664
182775
  // src/triage.ts
182665
- var triageDir = (board) => path40.join(board, "triage");
182666
- var rejectedDir = (board) => path40.join(board, ".archive", REJECTIONS_TO_REVIEW);
182776
+ var triageDir = (board) => path41.join(board, "triage");
182777
+ var rejectedDir = (board) => path41.join(board, ".archive", REJECTIONS_TO_REVIEW);
182667
182778
  var stamp2 = (at2) => formatStamp(at2 ? new Date(at2) : /* @__PURE__ */ new Date());
182668
182779
  function slugOf(title) {
182669
182780
  return title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "") || "item";
@@ -182671,7 +182782,7 @@ function slugOf(title) {
182671
182782
  function freeName(dir, title) {
182672
182783
  const stem = slugOf(title);
182673
182784
  let name = `${stem}.md`;
182674
- for (let n = 2; fs34.existsSync(path40.join(dir, name)); n++) name = `${stem}-${n}.md`;
182785
+ for (let n = 2; fs35.existsSync(path41.join(dir, name)); n++) name = `${stem}-${n}.md`;
182675
182786
  return name;
182676
182787
  }
182677
182788
  function itemText(item, fields2 = {}) {
@@ -182691,16 +182802,16 @@ ${item.text.trim()}
182691
182802
  `;
182692
182803
  }
182693
182804
  function writeItem(dir, item, fields2 = {}) {
182694
- fs34.mkdirSync(dir, { recursive: true });
182805
+ fs35.mkdirSync(dir, { recursive: true });
182695
182806
  const name = freeName(dir, item.title);
182696
- fs34.writeFileSync(path40.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields2 } : fields2));
182807
+ fs35.writeFileSync(path41.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields2 } : fields2));
182697
182808
  return name;
182698
182809
  }
182699
182810
  function layOut(board, rejections) {
182700
182811
  const dir = rejectedDir(board);
182701
- fs34.mkdirSync(dir, { recursive: true });
182812
+ fs35.mkdirSync(dir, { recursive: true });
182702
182813
  for (const t of rejections.tasks) {
182703
- fs34.writeFileSync(path40.join(dir, `${t.number}-${slugify2(t.title)}.md`), [
182814
+ fs35.writeFileSync(path41.join(dir, `${t.number}-${slugify2(t.title)}.md`), [
182704
182815
  "---",
182705
182816
  `title: ${yamlScalar(t.title)}`,
182706
182817
  "status: todo",
@@ -182715,7 +182826,7 @@ function layOut(board, rejections) {
182715
182826
  ].join("\n"));
182716
182827
  }
182717
182828
  for (const item of rejections.triage) {
182718
- const sub = path40.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
182829
+ const sub = path41.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
182719
182830
  const fields2 = item.state === "dismissed" ? { dismissed_at: stamp2(item.dismissed_at), dismissed_by: "user", ...item.dismissed_reason ? { dismissed_reason: item.dismissed_reason } : {} } : {};
182720
182831
  writeItem(sub, item, fields2);
182721
182832
  }
@@ -182724,12 +182835,12 @@ function layOut(board, rejections) {
182724
182835
 
182725
182836
  // ../cli/src/lib/skill/hook.ts
182726
182837
  import { spawnSync as spawnSync7 } from "node:child_process";
182727
- import fs35 from "node:fs";
182728
- import path41 from "node:path";
182838
+ import fs36 from "node:fs";
182839
+ import path42 from "node:path";
182729
182840
  var MARKER_LINE = /^# ai4kanban commit guard\b/m;
182730
182841
  var read3 = (file3) => {
182731
182842
  try {
182732
- return fs35.readFileSync(file3, "utf8");
182843
+ return fs36.readFileSync(file3, "utf8");
182733
182844
  } catch {
182734
182845
  return null;
182735
182846
  }
@@ -182741,15 +182852,15 @@ function hooksDir(root2) {
182741
182852
  windowsHide: true
182742
182853
  });
182743
182854
  if (out.error || out.status !== 0 || !out.stdout.trim()) return null;
182744
- return path41.resolve(root2, out.stdout.trim());
182855
+ return path42.resolve(root2, out.stdout.trim());
182745
182856
  }
182746
182857
  function installCommitHook(root2, _board) {
182747
182858
  const dir = hooksDir(root2);
182748
182859
  if (!dir) return {};
182749
- const file3 = path41.join(dir, "pre-commit");
182750
- if (fs35.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
182860
+ const file3 = path42.join(dir, "pre-commit");
182861
+ if (fs36.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
182751
182862
  const source2 = read3(file3);
182752
- if (source2 && MARKER_LINE.test(source2)) fs35.unlinkSync(file3);
182863
+ if (source2 && MARKER_LINE.test(source2)) fs36.unlinkSync(file3);
182753
182864
  return {};
182754
182865
  }
182755
182866
 
@@ -182793,7 +182904,7 @@ function runtimeCosts(runs, job) {
182793
182904
  }
182794
182905
  function reviewOf2(file3, questionsOnly = false) {
182795
182906
  try {
182796
- const meta3 = parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta;
182907
+ const meta3 = parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta;
182797
182908
  return meta3 && (!questionsOnly || meta3.questions?.length) ? reviewOf(meta3) : null;
182798
182909
  } catch {
182799
182910
  return null;
@@ -182801,15 +182912,15 @@ function reviewOf2(file3, questionsOnly = false) {
182801
182912
  }
182802
182913
  function asks(file3) {
182803
182914
  try {
182804
- return (parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
182915
+ return (parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
182805
182916
  } catch {
182806
182917
  return false;
182807
182918
  }
182808
182919
  }
182809
182920
  function mcpConfig(servers, file3) {
182810
182921
  if (!Object.keys(servers).length) return null;
182811
- fs36.mkdirSync(path42.dirname(file3), { recursive: true });
182812
- fs36.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
182922
+ fs37.mkdirSync(path43.dirname(file3), { recursive: true });
182923
+ fs37.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
182813
182924
  `);
182814
182925
  return file3;
182815
182926
  }
@@ -182840,16 +182951,16 @@ async function stopRuns(akb, ws, id2, since, ms) {
182840
182951
  var working = /* @__PURE__ */ new Map();
182841
182952
  var workKey = (ws, id2) => `${ws.board}#${id2}`;
182842
182953
  function checkoutsOf(ws, id2) {
182843
- const dir = path42.join(ws.board, "deliveries");
182954
+ const dir = path43.join(ws.board, "deliveries");
182844
182955
  let names2;
182845
182956
  try {
182846
- names2 = fs36.readdirSync(dir).filter((n) => n.endsWith(".json"));
182957
+ names2 = fs37.readdirSync(dir).filter((n) => n.endsWith(".json"));
182847
182958
  } catch {
182848
182959
  return [];
182849
182960
  }
182850
182961
  return names2.flatMap((n) => {
182851
182962
  try {
182852
- const held5 = JSON.parse(fs36.readFileSync(path42.join(dir, n), "utf8"));
182963
+ const held5 = JSON.parse(fs37.readFileSync(path43.join(dir, n), "utf8"));
182853
182964
  return held5.cardId === id2 && held5.deliveryId ? [held5.deliveryId] : [];
182854
182965
  } catch {
182855
182966
  return [];
@@ -182863,7 +182974,7 @@ var RESUME_REFUSED = {
182863
182974
  deliveryRunGoing: "\u4E0A\u6B21\u7684\u8FD0\u884C\u8FD8\u6CA1\u505C\u4E0B\uFF0C\u8BF7\u7A0D\u540E\u518D\u70B9\u300C\u7EED\u8DD1\u300D\u3002",
182864
182975
  deliveryCardGone: "\u8FD9\u5F20\u5361\u5DF2\u4E0D\u5728\u770B\u677F\u4E0A\uFF0C\u6CA1\u6709\u53EF\u7EED\u8DD1\u7684\u5185\u5BB9\uFF0C\u8BF7\u70B9\u300C\u91CD\u65B0\u53D1\u8D77\u300D\u3002"
182865
182976
  };
182866
- var isArchived = (ws, id2) => path42.relative(ws.board, findCard(ws.board, id2) ?? ws.board).split(path42.sep)[0] === ".archive";
182977
+ var isArchived = (ws, id2) => path43.relative(ws.board, findCard(ws.board, id2) ?? ws.board).split(path43.sep)[0] === ".archive";
182867
182978
  var refusal2 = (ran) => ran.last.replace(/^akb( raw)?: /, "").slice(0, 300) || "akb stopped with an error.";
182868
182979
  var reasonOf = (text3) => (text3 ?? "").split("\n").map((l2) => l2.trim()).filter((l2) => l2 && !/^at\s/.test(l2)).join("\n").slice(0, 300) || void 0;
182869
182980
  function logLines(show, event2) {
@@ -182925,7 +183036,7 @@ async function setUp(job, ws, deps, io) {
182925
183036
  const runtime = job.runtime;
182926
183037
  const missing = io.flowRun?.finished ? void 0 : unavailable(runtime, await deps.runtimes());
182927
183038
  if (missing) return missing;
182928
- if (!fs36.existsSync(path42.join(ws.board, "config.md"))) {
183039
+ if (!fs37.existsSync(path43.join(ws.board, "config.md"))) {
182929
183040
  const init = await akb(["raw", "init"]);
182930
183041
  if (init.code !== 0) return refusal2(init);
182931
183042
  }
@@ -182942,7 +183053,7 @@ async function setUp(job, ws, deps, io) {
182942
183053
  const used = await akb(["raw", "agent", "use", runtime]);
182943
183054
  if (used.code !== 0) return refusal2(used);
182944
183055
  const servers = mcpServersOf(ws);
182945
- const mcpFile = path42.join(ws.board, ".sync", `${ws.task}.mcp.json`);
183056
+ const mcpFile = path43.join(ws.board, ".sync", `${ws.task}.mcp.json`);
182946
183057
  const takes = new Set(settingKeys(runtime));
182947
183058
  const given = job.settings ?? {};
182948
183059
  const values = valuesOf(runtime, job.model, given, servers, mcpFile);
@@ -183022,9 +183133,9 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
183022
183133
  if (!read5.value.tasks.length && !read5.value.triage.length || stopping(io)) return { runs: [] };
183023
183134
  const since = Date.now();
183024
183135
  const akb = boardAkb(job, ws, deps, io);
183025
- const directory3 = path42.join(ws.board, ".sync");
183026
- fs36.mkdirSync(directory3, { recursive: true });
183027
- const scratch = fs36.mkdtempSync(path42.join(directory3, "rejection-review-"));
183136
+ const directory3 = path43.join(ws.board, ".sync");
183137
+ fs37.mkdirSync(directory3, { recursive: true });
183138
+ const scratch = fs37.mkdtempSync(path43.join(directory3, "rejection-review-"));
183028
183139
  try {
183029
183140
  const laid = layOut(scratch, read5.value);
183030
183141
  const denied = await refreshReview?.();
@@ -183035,7 +183146,7 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
183035
183146
  if (ran.code !== 0) return { runs, failure: refusal2(ran) };
183036
183147
  return { runs, laid, session: answerOf2(ran)?.agentSession };
183037
183148
  } finally {
183038
- fs36.rmSync(scratch, { recursive: true, force: true });
183149
+ fs37.rmSync(scratch, { recursive: true, force: true });
183039
183150
  }
183040
183151
  }
183041
183152
  async function learnRejections(job, ws, deps, io, refreshReview) {
@@ -183085,19 +183196,19 @@ async function runAgent(job, ws, deps, io) {
183085
183196
  }
183086
183197
  function writeTranscript(job, dir) {
183087
183198
  if (!job.transcript) return "";
183088
- const file3 = path42.join(dir, "discussion.md");
183089
- fs36.mkdirSync(dir, { recursive: true });
183090
- fs36.writeFileSync(file3, `${job.transcript}
183199
+ const file3 = path43.join(dir, "discussion.md");
183200
+ fs37.mkdirSync(dir, { recursive: true });
183201
+ fs37.writeFileSync(file3, `${job.transcript}
183091
183202
  `);
183092
183203
  return file3;
183093
183204
  }
183094
183205
  function pictures(job, ws, id2) {
183095
183206
  const dir = cardAssetsDir(ws, id2);
183096
183207
  if (!job.attachments.length || !dir) return "";
183097
- fs36.mkdirSync(dir, { recursive: true });
183208
+ fs37.mkdirSync(dir, { recursive: true });
183098
183209
  return job.attachments.map((a2, i) => {
183099
- const file3 = `${i + 1}-${path42.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
183100
- fs36.writeFileSync(path42.join(dir, file3), Buffer.from(a2.content, "base64"));
183210
+ const file3 = `${i + 1}-${path43.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
183211
+ fs37.writeFileSync(path43.join(dir, file3), Buffer.from(a2.content, "base64"));
183101
183212
  return `
183102
183213
  <Asset src=".assets/${id2}/${file3}" label="${a2.name.replace(/["<>]/g, "") || file3}" />
183103
183214
  `;
@@ -183105,7 +183216,7 @@ function pictures(job, ws, id2) {
183105
183216
  }
183106
183217
  function cardFlags(ws, fields2) {
183107
183218
  if (!fields2) return [];
183108
- const open2 = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path42.join(ws.board, "todo") + path42.sep));
183219
+ const open2 = (keys) => (keys ?? []).map((k2) => Number(/(\d+)$/.exec(k2)?.[1])).filter((n) => n > 0 && n !== ws.number && findCard(ws.board, n)?.startsWith(path43.join(ws.board, "todo") + path43.sep));
183109
183220
  const lists = [["--modules", fields2.modules ?? []], ["--related", open2(fields2.related)], ["--blocked-by", open2(fields2.blocked_by)]];
183110
183221
  return [
183111
183222
  ...fields2.priority ? ["--priority", fields2.priority] : [],
@@ -183159,7 +183270,7 @@ async function runFlow(job, ws, deps, io) {
183159
183270
  const startsDelivery = ["delivery resume", "run resume", "card implement"].includes(args2.slice(1, 3).join(" "));
183160
183271
  if (review && task?.preview_inputs && verb === "implement" && startsDelivery) {
183161
183272
  const inputs = task.preview_inputs;
183162
- previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-saved-previews-"));
183273
+ previewDirectory ??= fs37.mkdtempSync(path43.join(os6.tmpdir(), "wildcrane-saved-previews-"));
183163
183274
  const directory3 = previewDirectory;
183164
183275
  const staged = await attemptSync(io, "review", () => stageSavedPreviews(
183165
183276
  directory3,
@@ -183178,16 +183289,16 @@ async function runFlow(job, ws, deps, io) {
183178
183289
  } else if (review && verb === "implement" && startsDelivery && studioName(ws.studio ?? flow.studio ?? "") === "coding") {
183179
183290
  const files = approvedUiPreviews(review);
183180
183291
  if (files.length) {
183181
- previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-approved-ui-"));
183292
+ previewDirectory ??= fs37.mkdtempSync(path43.join(os6.tmpdir(), "wildcrane-approved-ui-"));
183182
183293
  const directory3 = previewDirectory;
183183
183294
  const staged = await attemptSync(io, "review", async () => {
183184
183295
  for (const file3 of files) {
183185
183296
  if (stopping(io)) return syncStopped;
183186
183297
  const target = approvedUiFile(directory3, file3);
183187
- if (fs36.existsSync(target)) continue;
183298
+ if (fs37.existsSync(target)) continue;
183188
183299
  const fetched = await readAsset(file3.artifact, file3.version);
183189
183300
  if (!fetched.ok) return { ...fetched, error: `${file3.src} (approved revision ${file3.revision}): ${fetched.error}` };
183190
- fs36.writeFileSync(target, fetched.value);
183301
+ fs37.writeFileSync(target, fetched.value);
183191
183302
  }
183192
183303
  return { ok: true, value: void 0 };
183193
183304
  });
@@ -183213,13 +183324,13 @@ async function runFlow(job, ws, deps, io) {
183213
183324
  said = { title: task.value.title?.trim() ?? "", request: task.value.request?.trim() ?? "" };
183214
183325
  }
183215
183326
  const title = said.title || "Untitled";
183216
- const body = path42.join(ws.board, ".sync", `${ws.task}.request.md`);
183217
- fs36.mkdirSync(path42.dirname(body), { recursive: true });
183327
+ const body = path43.join(ws.board, ".sync", `${ws.task}.request.md`);
183328
+ fs37.mkdirSync(path43.dirname(body), { recursive: true });
183218
183329
  if (!ws.number) return fail("This task has no number yet.");
183219
183330
  const created = await withBoard(ws, async () => {
183220
183331
  const existing = akbCardOf(ws);
183221
183332
  if (existing) return { ok: true, value: existing };
183222
- fs36.writeFileSync(body, `${said.request || title}
183333
+ fs37.writeFileSync(body, `${said.request || title}
183223
183334
  ${pictures(job, ws, ws.number)}`);
183224
183335
  return akb([
183225
183336
  "raw",
@@ -183234,7 +183345,7 @@ ${pictures(job, ws, ws.number)}`);
183234
183345
  String(ws.number),
183235
183346
  ...cardFlags(ws, flow.metadata),
183236
183347
  "--json"
183237
- ]).then(made).finally(() => fs36.rmSync(body, { force: true }));
183348
+ ]).then(made).finally(() => fs37.rmSync(body, { force: true }));
183238
183349
  }, () => stopping(io));
183239
183350
  if (!created || stopping(io)) return fail("");
183240
183351
  if (!created.ok) return fail(created.error);
@@ -183330,8 +183441,8 @@ ${pictures(job, ws, ws.number)}`);
183330
183441
  if (ended.ok && !coding && flow.verb === "create" && verb === "implement" && job.taskReview && reviewAuthorization(job.taskReview).kind === "unreviewed" && !ended.report.review) ended.report.deliveryCompleted = true;
183331
183442
  return ended;
183332
183443
  } finally {
183333
- if (previewDirectory) fs36.rmSync(previewDirectory, { recursive: true, force: true });
183334
- fs36.rmSync(path42.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
183444
+ if (previewDirectory) fs37.rmSync(previewDirectory, { recursive: true, force: true });
183445
+ fs37.rmSync(path43.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
183335
183446
  const left = working.get(key) - 1;
183336
183447
  if (left) working.set(key, left);
183337
183448
  else working.delete(key);
@@ -183343,7 +183454,7 @@ ${pictures(job, ws, ws.number)}`);
183343
183454
  });
183344
183455
  const text3 = flow.verb === "create" ? "" : (flow.text ?? "").trim();
183345
183456
  const archived = !io.flowRun && flow.resume && isArchived(ws, id3);
183346
- if (archived && (!coding || parseFrontmatter(fs36.readFileSync(cardFile(ws), "utf8")).meta?.rejected)) {
183457
+ if (archived && (!coding || parseFrontmatter(fs37.readFileSync(cardFile(ws), "utf8")).meta?.rejected)) {
183347
183458
  return { ok: true, report: { card: id3, ...coding ? { deliveryCompleted: false } : {} } };
183348
183459
  }
183349
183460
  if (!io.flowRun && flow.resume && verb === "refine" && !hasReview && (!reconciled || reconciled.kind === "none")) {
@@ -183351,7 +183462,7 @@ ${pictures(job, ws, ws.number)}`);
183351
183462
  if (review2) return { ok: true, report: { card: id3, ...review2 === true ? {} : { review: review2 } } };
183352
183463
  }
183353
183464
  let note = verb === "resolve" || verb === "revise" ? text3 : "";
183354
- const isRejected = () => isArchived(ws, id3) && parseFrontmatter(fs36.readFileSync(cardFile(ws), "utf8")).meta?.rejected === true;
183465
+ const isRejected = () => isArchived(ws, id3) && parseFrontmatter(fs37.readFileSync(cardFile(ws), "utf8")).meta?.rejected === true;
183355
183466
  let ran;
183356
183467
  let continuation;
183357
183468
  let expectedDelivery;
@@ -183486,11 +183597,11 @@ ${pictures(job, ws, ws.number)}`);
183486
183597
  function carryArgs(verb2) {
183487
183598
  if (flow.replan) return ["--new-session"];
183488
183599
  if (verb2 === "implement" && flow.verb === "create") {
183489
- const transcript2 = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
183600
+ const transcript2 = writeTranscript(job, path43.join(ws.board, ".sync", `${ws.task}.discussion`));
183490
183601
  return transcript2 ? ["--transcript", transcript2] : [];
183491
183602
  }
183492
183603
  if (!["refine", "resolve", "revise"].includes(verb2)) return [];
183493
- const transcript = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
183604
+ const transcript = writeTranscript(job, path43.join(ws.board, ".sync", `${ws.task}.discussion`));
183494
183605
  return [
183495
183606
  ...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
183496
183607
  ...transcript ? ["--transcript", transcript] : []
@@ -183549,8 +183660,8 @@ async function flowRunEvidence(ws, job, deps, execution = job.id, prior) {
183549
183660
  }
183550
183661
 
183551
183662
  // src/recovery.ts
183552
- import fs37 from "node:fs";
183553
- import path43 from "node:path";
183663
+ import fs38 from "node:fs";
183664
+ import path44 from "node:path";
183554
183665
 
183555
183666
  // ../cli/src/lib/agent/wire/codex-background-types.ts
183556
183667
  function idleStopConfirmed(cleanup, session) {
@@ -183559,10 +183670,10 @@ function idleStopConfirmed(cleanup, session) {
183559
183670
 
183560
183671
  // src/recovery.ts
183561
183672
  var recoveryBlocked = (job) => cloudLanguage(job) === "zh" ? "\u65E0\u6CD5\u6838\u5BF9\u4E0A\u6B21\u6267\u884C\uFF0C\u5DF2\u6709\u6210\u679C\u5DF2\u4FDD\u7559\u3002" : "The previous execution could not be verified. Saved work was preserved.";
183562
- var fileOf2 = (id2) => path43.join(runnerHome(), "checkpoints", `${encodeURIComponent(id2)}.json`);
183673
+ var fileOf2 = (id2) => path44.join(runnerHome(), "checkpoints", `${encodeURIComponent(id2)}.json`);
183563
183674
  function readCheckpoint(id2) {
183564
183675
  try {
183565
- const held5 = JSON.parse(fs37.readFileSync(fileOf2(id2), "utf8"));
183676
+ const held5 = JSON.parse(fs38.readFileSync(fileOf2(id2), "utf8"));
183566
183677
  if (!held5 || !Array.isArray(held5.pending) || !held5.pending.every((id3) => typeof id3 === "string")) throw new Error("\u8FDB\u5EA6\u683C\u5F0F\u9519\u8BEF");
183567
183678
  if (held5.syncRetry && (!Number.isSafeInteger(held5.syncRetry.attempt) || held5.syncRetry.attempt < 1 || !Number.isFinite(held5.syncRetry.at))) {
183568
183679
  delete held5.syncRetry;
@@ -183581,12 +183692,12 @@ function readCheckpoint(id2) {
183581
183692
  }
183582
183693
  function saveCheckpoint(id2, checkpoint) {
183583
183694
  const file3 = fileOf2(id2);
183584
- fs37.mkdirSync(path43.dirname(file3), { recursive: true, mode: 448 });
183585
- fs37.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
183586
- fs37.renameSync(`${file3}.tmp`, file3);
183695
+ fs38.mkdirSync(path44.dirname(file3), { recursive: true, mode: 448 });
183696
+ fs38.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
183697
+ fs38.renameSync(`${file3}.tmp`, file3);
183587
183698
  }
183588
183699
  function clearCheckpoint(id2) {
183589
- fs37.rmSync(fileOf2(id2), { force: true });
183700
+ fs38.rmSync(fileOf2(id2), { force: true });
183590
183701
  }
183591
183702
  function checkpointEvent(checkpoint, event2) {
183592
183703
  if (event2.kind === "phase" && event2.data.phase === "submitted" || event2.kind === "message" && event2.data.text.trim() || event2.kind === "tool_call" || event2.kind === "plan") {
@@ -183794,32 +183905,32 @@ function conversationProgress(attempt, send3, valid, unconfirmed) {
183794
183905
  }
183795
183906
 
183796
183907
  // src/settings-control.ts
183797
- import fs38 from "node:fs";
183798
- import path44 from "node:path";
183908
+ import fs39 from "node:fs";
183909
+ import path45 from "node:path";
183799
183910
 
183800
183911
  // src/codex-native.ts
183801
183912
  var import_undici2 = __toESM(require_undici(), 1);
183802
183913
 
183803
183914
  // src/settings-control.ts
183804
- var directory = () => path44.join(runnerHome(), "executors");
183805
- var epochFile = () => path44.join(runnerHome(), "account-generation");
183915
+ var directory = () => path45.join(runnerHome(), "executors");
183916
+ var epochFile = () => path45.join(runnerHome(), "account-generation");
183806
183917
  function accountGeneration() {
183807
183918
  try {
183808
- return fs38.readFileSync(epochFile(), "utf8");
183919
+ return fs39.readFileSync(epochFile(), "utf8");
183809
183920
  } catch {
183810
183921
  return "";
183811
183922
  }
183812
183923
  }
183813
183924
  function executorRecord() {
183814
- fs38.mkdirSync(directory(), { recursive: true, mode: 448 });
183815
- const file3 = path44.join(directory(), `${process.pid}.json`);
183816
- fs38.writeFileSync(file3, "{}", { mode: 384 });
183817
- return () => fs38.rmSync(file3, { force: true });
183925
+ fs39.mkdirSync(directory(), { recursive: true, mode: 448 });
183926
+ const file3 = path45.join(directory(), `${process.pid}.json`);
183927
+ fs39.writeFileSync(file3, "{}", { mode: 384 });
183928
+ return () => fs39.rmSync(file3, { force: true });
183818
183929
  }
183819
183930
 
183820
183931
  // src/reply-images.ts
183821
- import fs39 from "node:fs";
183822
- import path45 from "node:path";
183932
+ import fs40 from "node:fs";
183933
+ import path46 from "node:path";
183823
183934
  import os7 from "node:os";
183824
183935
  import { fileURLToPath as fileURLToPath3 } from "node:url";
183825
183936
  import { createHash as createHash6 } from "node:crypto";
@@ -183838,16 +183949,16 @@ function imageMime(bytes2) {
183838
183949
  // src/reply-images.ts
183839
183950
  init_file_limits();
183840
183951
  var inside = (root2, file3) => {
183841
- const p2 = path45.relative(root2, file3);
183842
- return p2 !== ".." && !p2.startsWith(`..${path45.sep}`) && !path45.isAbsolute(p2);
183952
+ const p2 = path46.relative(root2, file3);
183953
+ return p2 !== ".." && !p2.startsWith(`..${path46.sep}`) && !path46.isAbsolute(p2);
183843
183954
  };
183844
183955
  function collectReplyImages(parts, cwd) {
183845
183956
  const files = /* @__PURE__ */ new Map();
183846
183957
  const tools = [];
183847
183958
  const output3 = [];
183848
- const roots = [cwd, path45.join(process.env.CODEX_HOME?.trim() || path45.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
183959
+ const roots = [cwd, path46.join(process.env.CODEX_HOME?.trim() || path46.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
183849
183960
  try {
183850
- return [fs39.realpathSync(p2)];
183961
+ return [fs40.realpathSync(p2)];
183851
183962
  } catch {
183852
183963
  return [];
183853
183964
  }
@@ -183855,17 +183966,17 @@ function collectReplyImages(parts, cwd) {
183855
183966
  const registered = new Set(parts.flatMap((p2) => {
183856
183967
  if (p2.type !== "image" || !p2.registered || !p2.path) return [];
183857
183968
  try {
183858
- const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path45.resolve(cwd, p2.path);
183859
- if (!fs39.lstatSync(file3).isFile()) return [];
183860
- const real = fs39.realpathSync(file3);
183861
- const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
183969
+ const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path46.resolve(cwd, p2.path);
183970
+ if (!fs40.lstatSync(file3).isFile()) return [];
183971
+ const real = fs40.realpathSync(file3);
183972
+ const fd = fs40.openSync(real, fs40.constants.O_RDONLY | (fs40.constants.O_NOFOLLOW ?? 0));
183862
183973
  try {
183863
- const stat2 = fs39.fstatSync(fd);
183974
+ const stat2 = fs40.fstatSync(fd);
183864
183975
  if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) return [];
183865
- const mime = imageMime(fs39.readFileSync(fd));
183976
+ const mime = imageMime(fs40.readFileSync(fd));
183866
183977
  return mime && (!p2.mime || p2.mime === mime) ? [real] : [];
183867
183978
  } finally {
183868
- fs39.closeSync(fd);
183979
+ fs40.closeSync(fd);
183869
183980
  }
183870
183981
  } catch {
183871
183982
  return [];
@@ -183881,16 +183992,16 @@ function collectReplyImages(parts, cwd) {
183881
183992
  if (!p2.path) throw Error();
183882
183993
  const source2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : decodeURIComponent(p2.path);
183883
183994
  if (/^[a-z][a-z0-9+.-]*:/i.test(source2) && !/^[A-Za-z]:[\\/]/.test(source2)) throw Error();
183884
- const real = fs39.realpathSync(path45.resolve(cwd, source2));
183995
+ const real = fs40.realpathSync(path46.resolve(cwd, source2));
183885
183996
  if (!/\.(png|jpe?g|gif|webp)$/i.test(source2) && !registered.has(real)) throw Error();
183886
183997
  if (!roots.some((root2) => inside(root2, real)) && !registered.has(real)) throw Error();
183887
- const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
183998
+ const fd = fs40.openSync(real, fs40.constants.O_RDONLY | (fs40.constants.O_NOFOLLOW ?? 0));
183888
183999
  try {
183889
- const stat2 = fs39.fstatSync(fd);
184000
+ const stat2 = fs40.fstatSync(fd);
183890
184001
  if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) throw Error();
183891
- bytes2 = fs39.readFileSync(fd);
184002
+ bytes2 = fs40.readFileSync(fd);
183892
184003
  } finally {
183893
- fs39.closeSync(fd);
184004
+ fs40.closeSync(fd);
183894
184005
  }
183895
184006
  }
183896
184007
  return bytes2;
@@ -183976,8 +184087,8 @@ async function saveReplyImages(parts, cwd, upload2) {
183976
184087
  // src/handoff.ts
183977
184088
  import { execFileSync as execFileSync2 } from "node:child_process";
183978
184089
  import crypto5 from "node:crypto";
183979
- import fs40 from "node:fs";
183980
- import path46 from "node:path";
184090
+ import fs41 from "node:fs";
184091
+ import path47 from "node:path";
183981
184092
  var gitRead = (cwd, args2) => {
183982
184093
  try {
183983
184094
  return execFileSync2("git", ["-C", cwd, ...args2], {
@@ -183994,8 +184105,8 @@ var digest = (value) => crypto5.createHash("sha256").update(value).digest("hex")
183994
184105
  function authorizedFolder(folder2) {
183995
184106
  if (!folder2) return null;
183996
184107
  try {
183997
- const real = fs40.realpathSync(folder2);
183998
- return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path46.sep)) ? real : null;
184108
+ const real = fs41.realpathSync(folder2);
184109
+ return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path47.sep)) ? real : null;
183999
184110
  } catch {
184000
184111
  return null;
184001
184112
  }
@@ -184005,9 +184116,9 @@ function progressFolder(job, folder2) {
184005
184116
  if (!token) return folder2;
184006
184117
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) return null;
184007
184118
  try {
184008
- const dir = fs40.realpathSync(path46.join(folder2, ".akb", "handoffs", token));
184009
- if (!dir.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
184010
- const marker = JSON.parse(fs40.readFileSync(path46.join(dir, ".akb", "handoff.json"), "utf8"));
184119
+ const dir = fs41.realpathSync(path47.join(folder2, ".akb", "handoffs", token));
184120
+ if (!dir.startsWith(fs41.realpathSync(folder2) + path47.sep)) return null;
184121
+ const marker = JSON.parse(fs41.readFileSync(path47.join(dir, ".akb", "handoff.json"), "utf8"));
184011
184122
  return marker.task === job.task && marker.isolation === token ? dir : null;
184012
184123
  } catch {
184013
184124
  return null;
@@ -184015,38 +184126,38 @@ function progressFolder(job, folder2) {
184015
184126
  }
184016
184127
  function progressEvidence(job, folder2) {
184017
184128
  try {
184018
- const board = path46.join(folder2, ".akb", "kanban");
184019
- const deliveries = path46.join(board, "deliveries");
184020
- const rows = fs40.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs40.readFileSync(path46.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
184129
+ const board = path47.join(folder2, ".akb", "kanban");
184130
+ const deliveries = path47.join(board, "deliveries");
184131
+ const rows = fs41.readdirSync(deliveries).filter((name) => name.endsWith(".json")).map((name) => JSON.parse(fs41.readFileSync(path47.join(deliveries, name), "utf8"))).filter((row2) => row2.cardId === job.number).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
184021
184132
  const row = rows[0];
184022
184133
  if (!row?.deliveryId) return null;
184023
- const tree = fs40.realpathSync(path46.resolve(folder2, row.worktree ?? "."));
184024
- if (tree !== fs40.realpathSync(folder2) && !tree.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
184134
+ const tree = fs41.realpathSync(path47.resolve(folder2, row.worktree ?? "."));
184135
+ if (tree !== fs41.realpathSync(folder2) && !tree.startsWith(fs41.realpathSync(folder2) + path47.sep)) return null;
184025
184136
  const inventory = gitRead(tree, ["worktree", "list", "--porcelain"]);
184026
184137
  const related = (inventory ?? "").split("\n\n").flatMap((entry) => {
184027
184138
  const branch = /^branch refs\/heads\/(.+)$/m.exec(entry)?.[1];
184028
184139
  const dir = /^worktree (.+)$/m.exec(entry)?.[1];
184029
- return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs40.realpathSync(folder2) + path46.sep) ? [dir] : [];
184140
+ return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs41.realpathSync(folder2) + path47.sep) ? [dir] : [];
184030
184141
  });
184031
184142
  const filesIn = (tree2) => {
184032
184143
  const changed = [];
184033
184144
  const walk = (dir, prefix = "") => {
184034
- for (const entry of fs40.readdirSync(dir, { withFileTypes: true })) {
184145
+ for (const entry of fs41.readdirSync(dir, { withFileTypes: true })) {
184035
184146
  if ([".git", ".akb", "node_modules", ".claude", ".agents"].includes(entry.name)) continue;
184036
184147
  const name = prefix + entry.name;
184037
- if (entry.isDirectory()) walk(path46.join(dir, entry.name), name + "/");
184148
+ if (entry.isDirectory()) walk(path47.join(dir, entry.name), name + "/");
184038
184149
  else changed.push(name);
184039
184150
  }
184040
184151
  };
184041
184152
  walk(tree2);
184042
184153
  changed.sort();
184043
184154
  return changed.map((name) => {
184044
- const file3 = path46.join(tree2, name);
184155
+ const file3 = path47.join(tree2, name);
184045
184156
  try {
184046
- const stat2 = fs40.lstatSync(file3);
184047
- if (stat2.isSymbolicLink()) return [name, "link", digest(fs40.readlinkSync(file3))];
184157
+ const stat2 = fs41.lstatSync(file3);
184158
+ if (stat2.isSymbolicLink()) return [name, "link", digest(fs41.readlinkSync(file3))];
184048
184159
  if (!stat2.isFile()) throw new Error("\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B");
184049
- return [name, stat2.mode & 511, digest(fs40.readFileSync(file3))];
184160
+ return [name, stat2.mode & 511, digest(fs41.readFileSync(file3))];
184050
184161
  } catch (e2) {
184051
184162
  if (e2.code === "ENOENT") return [name, "deleted"];
184052
184163
  throw e2;
@@ -184083,61 +184194,61 @@ function progressEvidence(job, folder2) {
184083
184194
  function restartFolder(job, folder2) {
184084
184195
  const token = job.handoff?.isolation ?? job.id;
184085
184196
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) throw new Error("\u9694\u79BB\u76EE\u5F55\u7F16\u53F7\u65E0\u6548\u3002");
184086
- const dir = path46.join(folder2, ".akb", "handoffs", token);
184087
- const marker = path46.join(dir, ".akb", "handoff.json");
184088
- for (const parent of [path46.join(folder2, ".akb"), path46.dirname(dir), dir]) {
184089
- if (fs40.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
184197
+ const dir = path47.join(folder2, ".akb", "handoffs", token);
184198
+ const marker = path47.join(dir, ".akb", "handoff.json");
184199
+ for (const parent of [path47.join(folder2, ".akb"), path47.dirname(dir), dir]) {
184200
+ if (fs41.lstatSync(parent, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u76EE\u5F55\u4E0D\u80FD\u901A\u8FC7\u7B26\u53F7\u94FE\u63A5\u521B\u5EFA\u3002");
184090
184201
  }
184091
- if (fs40.existsSync(dir)) {
184202
+ if (fs41.existsSync(dir)) {
184092
184203
  if (job.handoff?.recovering) {
184093
184204
  try {
184094
- const saved = JSON.parse(fs40.readFileSync(marker, "utf8"));
184205
+ const saved = JSON.parse(fs41.readFileSync(marker, "utf8"));
184095
184206
  if (saved.task === job.task && saved.isolation === token) return dir;
184096
184207
  } catch {
184097
184208
  }
184098
184209
  }
184099
184210
  throw new Error("\u91CD\u542F\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u3002");
184100
184211
  }
184101
- fs40.mkdirSync(path46.dirname(dir), { recursive: true });
184102
- fs40.mkdirSync(dir);
184103
- for (const entry of fs40.readdirSync(folder2)) {
184212
+ fs41.mkdirSync(path47.dirname(dir), { recursive: true });
184213
+ fs41.mkdirSync(dir);
184214
+ for (const entry of fs41.readdirSync(folder2)) {
184104
184215
  if ([".akb", ".git", "node_modules", ".claude", ".agents"].includes(entry)) continue;
184105
- fs40.cpSync(path46.join(folder2, entry), path46.join(dir, entry), { recursive: true, verbatimSymlinks: true });
184216
+ fs41.cpSync(path47.join(folder2, entry), path47.join(dir, entry), { recursive: true, verbatimSymlinks: true });
184106
184217
  }
184107
- if (fs40.lstatSync(path46.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
184108
- fs40.mkdirSync(path46.dirname(marker), { recursive: true });
184109
- fs40.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
184218
+ if (fs41.lstatSync(path47.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
184219
+ fs41.mkdirSync(path47.dirname(marker), { recursive: true });
184220
+ fs41.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
184110
184221
  return dir;
184111
184222
  }
184112
184223
 
184113
184224
  // src/jobs.ts
184114
184225
  import { spawn as spawn5 } from "node:child_process";
184115
- import fs47 from "node:fs";
184116
- import path52 from "node:path";
184226
+ import fs48 from "node:fs";
184227
+ import path53 from "node:path";
184117
184228
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
184118
184229
 
184119
184230
  // ../cli/src/lib/agent/catalog.ts
184120
- import fs41 from "node:fs";
184121
- import path47 from "node:path";
184231
+ import fs42 from "node:fs";
184232
+ import path48 from "node:path";
184122
184233
  var CATALOGUE = "https://models.dev/api.json";
184123
184234
  var FRESH_FOR_MS = 24 * 60 * 6e4;
184124
184235
  var ANSWER_BY_MS = 2e4;
184125
184236
  function cacheFile() {
184126
- return path47.join(machineHome(), "models-dev.json");
184237
+ return path48.join(machineHome(), "models-dev.json");
184127
184238
  }
184128
184239
  var held3;
184129
184240
  function readCache() {
184130
184241
  const file3 = cacheFile();
184131
184242
  let stamp3;
184132
184243
  try {
184133
- const stat2 = fs41.statSync(file3);
184244
+ const stat2 = fs42.statSync(file3);
184134
184245
  stamp3 = `${stat2.mtimeMs}:${stat2.size}`;
184135
184246
  } catch {
184136
184247
  return void 0;
184137
184248
  }
184138
184249
  if (held3?.stamp === stamp3) return held3.cached;
184139
184250
  try {
184140
- const data = JSON.parse(fs41.readFileSync(file3, "utf8"));
184251
+ const data = JSON.parse(fs42.readFileSync(file3, "utf8"));
184141
184252
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
184142
184253
  const cached3 = {
184143
184254
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -184176,8 +184287,8 @@ function refreshCatalog() {
184176
184287
  const limits = limitsIn(await answer.json());
184177
184288
  if (Object.keys(limits).length === 0) return;
184178
184289
  const file3 = cacheFile();
184179
- fs41.mkdirSync(path47.dirname(file3), { recursive: true });
184180
- fs41.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
184290
+ fs42.mkdirSync(path48.dirname(file3), { recursive: true });
184291
+ fs42.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
184181
184292
  } catch {
184182
184293
  }
184183
184294
  })();
@@ -184270,14 +184381,14 @@ async function replyApprovalBridge(task, number4, approve) {
184270
184381
  }
184271
184382
 
184272
184383
  // src/akb-version.ts
184273
- import fs42 from "node:fs";
184274
- import path48 from "node:path";
184275
- var stateFile = () => path48.join(akbHome(), "state.json");
184276
- var akbVersionDir = (version2) => path48.join(akbHome(), version2);
184277
- var entryOf = (dir) => path48.join(dir, "bin", "ai4kanban.mjs");
184384
+ import fs43 from "node:fs";
184385
+ import path49 from "node:path";
184386
+ var stateFile = () => path49.join(akbHome(), "state.json");
184387
+ var akbVersionDir = (version2) => path49.join(akbHome(), version2);
184388
+ var entryOf = (dir) => path49.join(dir, "bin", "ai4kanban.mjs");
184278
184389
  function readAkbState() {
184279
184390
  try {
184280
- const held5 = JSON.parse(fs42.readFileSync(stateFile(), "utf8"));
184391
+ const held5 = JSON.parse(fs43.readFileSync(stateFile(), "utf8"));
184281
184392
  return { current: held5.current ?? null, bad: held5.bad ?? [] };
184282
184393
  } catch {
184283
184394
  return { current: null, bad: [] };
@@ -184285,12 +184396,12 @@ function readAkbState() {
184285
184396
  }
184286
184397
  function contractOf(dir) {
184287
184398
  try {
184288
- return JSON.parse(fs42.readFileSync(path48.join(dir, "package.json"), "utf8")).akbContract ?? null;
184399
+ return JSON.parse(fs43.readFileSync(path49.join(dir, "package.json"), "utf8")).akbContract ?? null;
184289
184400
  } catch {
184290
184401
  return null;
184291
184402
  }
184292
184403
  }
184293
- var usable = (dir) => fs42.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
184404
+ var usable = (dir) => fs43.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
184294
184405
  function currentAkb() {
184295
184406
  const { current: current2 } = readAkbState();
184296
184407
  if (!current2) return bundledAkb();
@@ -184298,32 +184409,32 @@ function currentAkb() {
184298
184409
  if (!usable(dir)) return bundledAkb();
184299
184410
  try {
184300
184411
  const now = /* @__PURE__ */ new Date();
184301
- fs42.utimesSync(dir, now, now);
184412
+ fs43.utimesSync(dir, now, now);
184302
184413
  } catch {
184303
184414
  }
184304
- return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path48.join(dir, "shim") };
184415
+ return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path49.join(dir, "shim") };
184305
184416
  }
184306
184417
 
184307
184418
  // src/chats.ts
184308
- import fs44 from "node:fs";
184309
- import path50 from "node:path";
184419
+ import fs45 from "node:fs";
184420
+ import path51 from "node:path";
184310
184421
 
184311
184422
  // ../cli/src/lib/shared/chats.ts
184312
184423
  var CHAT_KEEP_DAYS = 30;
184313
184424
 
184314
184425
  // ../cli/src/lib/agent/task-chats.ts
184315
- import fs43 from "node:fs";
184316
- import path49 from "node:path";
184426
+ import fs44 from "node:fs";
184427
+ import path50 from "node:path";
184317
184428
  var TASK = /^[\w-]{1,100}$/;
184318
- var taskChatsDir = (home4 = machineHome()) => path49.join(home4, "chats");
184429
+ var taskChatsDir = (home4 = machineHome()) => path50.join(home4, "chats");
184319
184430
  function taskChatFile(task, home4) {
184320
184431
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
184321
- return path49.join(taskChatsDir(home4), `${task}.jsonl`);
184432
+ return path50.join(taskChatsDir(home4), `${task}.jsonl`);
184322
184433
  }
184323
184434
  function readTaskChat(task, home4) {
184324
184435
  let text3;
184325
184436
  try {
184326
- text3 = fs43.readFileSync(taskChatFile(task, home4), "utf8");
184437
+ text3 = fs44.readFileSync(taskChatFile(task, home4), "utf8");
184327
184438
  } catch {
184328
184439
  return [];
184329
184440
  }
@@ -184343,18 +184454,18 @@ function readTaskChat(task, home4) {
184343
184454
  var DAY_MS = 24 * 60 * 6e4;
184344
184455
  var KEEP_MS2 = CHAT_KEEP_DAYS * DAY_MS;
184345
184456
  var home3 = () => runnerHome();
184346
- var reviewedFile = () => path50.join(taskChatsDir(home3()), "reviewed.json");
184457
+ var reviewedFile = () => path51.join(taskChatsDir(home3()), "reviewed.json");
184347
184458
  function readReviewed() {
184348
184459
  try {
184349
- const held5 = JSON.parse(fs44.readFileSync(reviewedFile(), "utf8"));
184460
+ const held5 = JSON.parse(fs45.readFileSync(reviewedFile(), "utf8"));
184350
184461
  return { checkedAt: Number(held5.checkedAt) || 0, tasks: held5.tasks ?? {} };
184351
184462
  } catch {
184352
184463
  return { checkedAt: 0, tasks: {} };
184353
184464
  }
184354
184465
  }
184355
184466
  function writeReviewed(reviewed) {
184356
- fs44.mkdirSync(path50.dirname(reviewedFile()), { recursive: true });
184357
- fs44.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
184467
+ fs45.mkdirSync(path51.dirname(reviewedFile()), { recursive: true });
184468
+ fs45.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
184358
184469
  `);
184359
184470
  }
184360
184471
  function keepChat(job, reply, at2 = Date.now()) {
@@ -184364,16 +184475,16 @@ function keepChat(job, reply, at2 = Date.now()) {
184364
184475
  { id: job.id, role: "agent", text: reply, at: at2, runtime: job.runtime, model: job.model ?? null }
184365
184476
  ];
184366
184477
  const file3 = taskChatFile(job.task, home3());
184367
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184368
- fs44.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184478
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184479
+ fs45.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184369
184480
  `).join(""));
184370
184481
  }
184371
184482
  function keepCloudChat(task, messages) {
184372
184483
  const file3 = taskChatFile(task, home3());
184373
- if (!messages.length) return fs44.rmSync(file3, { force: true });
184484
+ if (!messages.length) return fs45.rmSync(file3, { force: true });
184374
184485
  const lines = messages.map((m) => ({ id: m.id, role: m.role, text: m.body, at: Date.parse(m.created_at) || Date.now() }));
184375
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184376
- fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184486
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184487
+ fs45.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184377
184488
  `).join(""));
184378
184489
  }
184379
184490
  async function keepDecisions(task, read5) {
@@ -184391,8 +184502,8 @@ async function keepDecisions(task, read5) {
184391
184502
  const ids = new Set(comments.map((c2) => c2.id));
184392
184503
  const lines = [...readTaskChat(task, home3()).filter((l2) => !ids.has(l2.id)), ...comments].sort((a2, b2) => a2.at - b2.at);
184393
184504
  const file3 = taskChatFile(task, home3());
184394
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184395
- fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184505
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184506
+ fs45.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184396
184507
  `).join(""));
184397
184508
  return true;
184398
184509
  }
@@ -184407,36 +184518,36 @@ function markReviewed2(marks) {
184407
184518
  }
184408
184519
 
184409
184520
  // src/goals.ts
184410
- import fs46 from "node:fs";
184411
- import path51 from "node:path";
184521
+ import fs47 from "node:fs";
184522
+ import path52 from "node:path";
184412
184523
 
184413
184524
  // ../cli/src/lib/goal-draft.ts
184414
- import fs45 from "node:fs";
184525
+ import fs46 from "node:fs";
184415
184526
  import { randomUUID as randomUUID5 } from "node:crypto";
184416
184527
  var goalDraftEnv = (file3) => ({ KANBAN_GOALS: file3, KANBAN_IDEAS: file3 });
184417
184528
  function readGoalDraft(file3) {
184418
- return decodeGoals(JSON.parse(fs45.readFileSync(file3, "utf8")));
184529
+ return decodeGoals(JSON.parse(fs46.readFileSync(file3, "utf8")));
184419
184530
  }
184420
184531
  function writeGoalDraft(file3, { goals, ...draft }, field) {
184421
184532
  const entries = field === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
184422
184533
  const temporary = `${file3}.${randomUUID5()}.tmp`;
184423
184534
  try {
184424
- fs45.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field]: entries }, null, 2)}
184535
+ fs46.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field]: entries }, null, 2)}
184425
184536
  `, { mode: 384, flag: "wx" });
184426
- fs45.renameSync(temporary, file3);
184537
+ fs46.renameSync(temporary, file3);
184427
184538
  } finally {
184428
- fs45.rmSync(temporary, { force: true });
184539
+ fs46.rmSync(temporary, { force: true });
184429
184540
  }
184430
184541
  }
184431
184542
 
184432
184543
  // src/goals.ts
184433
- var goalsFileOf = (job) => path51.join(runnerHome(), "ideas", `${job.id}.json`);
184544
+ var goalsFileOf = (job) => path52.join(runnerHome(), "ideas", `${job.id}.json`);
184434
184545
  async function writeGoals(job, list3, preserveGoals = false) {
184435
184546
  const file3 = goalsFileOf(job);
184436
184547
  try {
184437
- const goals = preserveGoals && fs46.existsSync(file3) ? readGoalDraft(file3).value.goals : job.discussion.goals;
184548
+ const goals = preserveGoals && fs47.existsSync(file3) ? readGoalDraft(file3).value.goals : job.discussion.goals;
184438
184549
  const studios = await studioSnapshot(job.discussion.workspace, job.discussion.catalog, list3);
184439
- fs46.mkdirSync(path51.dirname(file3), { recursive: true });
184550
+ fs47.mkdirSync(path52.dirname(file3), { recursive: true });
184440
184551
  writeGoalDraft(file3, { workspace: job.discussion.workspace, studios, goals }, "ideas");
184441
184552
  return { file: file3 };
184442
184553
  } catch (e2) {
@@ -184449,7 +184560,7 @@ function readGoals(file3) {
184449
184560
  } catch {
184450
184561
  return void 0;
184451
184562
  } finally {
184452
- fs46.rmSync(file3, { force: true });
184563
+ fs47.rmSync(file3, { force: true });
184453
184564
  }
184454
184565
  }
184455
184566
  var owner = "";
@@ -184562,32 +184673,32 @@ var defaultDeps = (machineId) => ({
184562
184673
  akb: currentAkb,
184563
184674
  runtimes: detectRuntimes
184564
184675
  });
184565
- var ownFolder = () => path52.join(runnerHome(), "work");
184676
+ var ownFolder = () => path53.join(runnerHome(), "work");
184566
184677
  function folderFor(job) {
184567
184678
  if (!job.projectDir) {
184568
- const cwd = path52.join(ownFolder(), job.id);
184569
- fs47.mkdirSync(cwd, { recursive: true });
184679
+ const cwd = path53.join(ownFolder(), job.id);
184680
+ fs48.mkdirSync(cwd, { recursive: true });
184570
184681
  return { cwd };
184571
184682
  }
184572
184683
  const real = realpath2(job.projectDir);
184573
- if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path52.sep))) return { cwd: real };
184684
+ if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path53.sep))) return { cwd: real };
184574
184685
  return { refused: `This Runner is not allowed to work in ${job.projectDir}.` };
184575
184686
  }
184576
184687
  function realpath2(p2) {
184577
184688
  try {
184578
- return fs47.realpathSync(p2);
184689
+ return fs48.realpathSync(p2);
184579
184690
  } catch {
184580
184691
  return null;
184581
184692
  }
184582
184693
  }
184583
- var attachmentsOf = (job) => path52.join(runnerHome(), "attachments", job.id);
184694
+ var attachmentsOf = (job) => path53.join(runnerHome(), "attachments", job.id);
184584
184695
  function writeAttachments(job) {
184585
184696
  if (!job.attachments.length) return { text: "", files: [] };
184586
184697
  const dir = attachmentsOf(job);
184587
- fs47.mkdirSync(dir, { recursive: true });
184698
+ fs48.mkdirSync(dir, { recursive: true });
184588
184699
  const files = job.attachments.map((a2) => {
184589
- const file3 = path52.join(dir, path52.basename(a2.name));
184590
- fs47.writeFileSync(file3, Buffer.from(a2.content, "base64"));
184700
+ const file3 = path53.join(dir, path53.basename(a2.name));
184701
+ fs48.writeFileSync(file3, Buffer.from(a2.content, "base64"));
184591
184702
  return file3;
184592
184703
  });
184593
184704
  return { text: `
@@ -184884,12 +184995,12 @@ async function runJob(id2, deps, track = () => {
184884
184995
  const releases = [];
184885
184996
  try {
184886
184997
  const akb = deps.akb();
184887
- releases.push(hold(path52.dirname(akb.shim)));
184998
+ releases.push(hold(path53.dirname(akb.shim)));
184888
184999
  releases.push(hold(akb.shim));
184889
185000
  await runClaimed(job, { ...deps, akb }, track, (dir) => releases.push(hold(dir)), lease);
184890
185001
  } finally {
184891
185002
  for (const release2 of releases) release2();
184892
- fs47.rmSync(attachmentsOf(job), { recursive: true, force: true });
185003
+ fs48.rmSync(attachmentsOf(job), { recursive: true, force: true });
184893
185004
  }
184894
185005
  return "changed";
184895
185006
  }
@@ -185955,8 +186066,8 @@ async function runTest(job, deps, lease) {
185955
186066
  const report2 = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
185956
186067
  if (!report2?.installed) return finish2("failed", "not_installed");
185957
186068
  if (report2.loggedIn === false) return finish2("failed", "signed_out");
185958
- const cwd = path52.join(ownFolder(), "test");
185959
- fs47.mkdirSync(cwd, { recursive: true });
186069
+ const cwd = path53.join(ownFolder(), "test");
186070
+ fs48.mkdirSync(cwd, { recursive: true });
185960
186071
  const run3 = deps.plan(job.runtime, job.prompt, cwd, null, job.model, settingsOf(job));
185961
186072
  const startedAt = Date.now();
185962
186073
  if (run3.converse) {
@@ -186045,22 +186156,22 @@ ${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
186045
186156
 
186046
186157
  // src/flow-worker.ts
186047
186158
  var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
186048
- var directory2 = () => path53.join(runnerHome(), "flow-workers");
186049
- var fileOf3 = (id2) => path53.join(directory2(), `${encodeURIComponent(id2)}.json`);
186159
+ var directory2 = () => path54.join(runnerHome(), "flow-workers");
186160
+ var fileOf3 = (id2) => path54.join(directory2(), `${encodeURIComponent(id2)}.json`);
186050
186161
  var stopFile = (id2) => `${fileOf3(id2)}.stop`;
186051
186162
  var flowWorkerEntry = fileURLToPath4(new URL("./flow-worker-main.mjs", import.meta.url));
186052
186163
  var canKeepFlow = (job) => !!job.task && !!job.flow && ["create", "refine", "implement", "preview"].includes(job.flow.verb) && !job.agent && !job.review && !job.discussion && !job.test && !job.secret;
186053
186164
  function read4(id2) {
186054
186165
  try {
186055
- return JSON.parse(fs48.readFileSync(fileOf3(id2), "utf8"));
186166
+ return JSON.parse(fs49.readFileSync(fileOf3(id2), "utf8"));
186056
186167
  } catch {
186057
186168
  return null;
186058
186169
  }
186059
186170
  }
186060
186171
  function save2(worker) {
186061
186172
  const file3 = fileOf3(worker.id);
186062
- fs48.writeFileSync(`${file3}.${process.pid}.tmp`, JSON.stringify(worker), { mode: 384 });
186063
- fs48.renameSync(`${file3}.${process.pid}.tmp`, file3);
186173
+ fs49.writeFileSync(`${file3}.${process.pid}.tmp`, JSON.stringify(worker), { mode: 384 });
186174
+ fs49.renameSync(`${file3}.${process.pid}.tmp`, file3);
186064
186175
  }
186065
186176
  function writerStopped(worker) {
186066
186177
  if (!Number.isSafeInteger(worker.pid) || worker.pid <= 0 || pidAlive(worker.pid)) return false;
@@ -186117,7 +186228,7 @@ async function reclaimFlowWorkers(machine, given, only) {
186117
186228
  const sweep = async () => {
186118
186229
  let names2;
186119
186230
  try {
186120
- names2 = only ? [`${encodeURIComponent(only)}.json`] : fs48.readdirSync(directory2());
186231
+ names2 = only ? [`${encodeURIComponent(only)}.json`] : fs49.readdirSync(directory2());
186121
186232
  } catch {
186122
186233
  return;
186123
186234
  }
@@ -186125,8 +186236,8 @@ async function reclaimFlowWorkers(machine, given, only) {
186125
186236
  if (!valid()) break;
186126
186237
  if (!name.endsWith(".json")) continue;
186127
186238
  try {
186128
- const file3 = path53.join(directory2(), name);
186129
- const original = fs48.readFileSync(file3, "utf8");
186239
+ const file3 = path54.join(directory2(), name);
186240
+ const original = fs49.readFileSync(file3, "utf8");
186130
186241
  const worker = JSON.parse(original);
186131
186242
  if (!worker || typeof worker.id !== "string" || name !== `${encodeURIComponent(worker.id)}.json` || typeof worker.token !== "string" || !worker.token || worker.machine !== machine || worker.account !== account || typeof worker.generation !== "string" || !Number.isFinite(worker.at)) continue;
186132
186243
  if (!writerStopped(worker)) {
@@ -186136,8 +186247,8 @@ async function reclaimFlowWorkers(machine, given, only) {
186136
186247
  const release2 = tryLock(`${file3}.lock`);
186137
186248
  if (!release2) continue;
186138
186249
  try {
186139
- if (fs48.readFileSync(file3, "utf8") !== original) continue;
186140
- const queried = tryLock(path53.join(directory2(), ".lookup.lock"));
186250
+ if (fs49.readFileSync(file3, "utf8") !== original) continue;
186251
+ const queried = tryLock(path54.join(directory2(), ".lookup.lock"));
186141
186252
  if (!queried) continue;
186142
186253
  const remote2 = await readJob(worker.id).finally(queried);
186143
186254
  if (!valid()) break;
@@ -186163,10 +186274,10 @@ async function reclaimFlowWorkers(machine, given, only) {
186163
186274
  } else if (job.state !== "finished" && !(job.state === "waiting" && readCheckpoint(job.id)?.updating)) continue;
186164
186275
  if (!worker.markedAt) {
186165
186276
  const job2 = remote2.value.job;
186166
- const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path53.join(runnerHome(), "work", job2.id) };
186277
+ const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path54.join(runnerHome(), "work", job2.id) };
186167
186278
  if ("refused" in folder2 || !job2.task || !job2.project) continue;
186168
- const board = path53.join(folder2.cwd, ".akb", "kanban");
186169
- if (!fs48.existsSync(board)) continue;
186279
+ const board = path54.join(folder2.cwd, ".akb", "kanban");
186280
+ if (!fs49.existsSync(board)) continue;
186170
186281
  const deps = given ?? defaultDeps(machine);
186171
186282
  if (!await confirmFlowStopped(
186172
186283
  {
@@ -186184,10 +186295,10 @@ async function reclaimFlowWorkers(machine, given, only) {
186184
186295
  const checkpoint = readCheckpoint(worker.id);
186185
186296
  if (checkpoint && (!checkpoint.mark || !processesStopped(checkpoint.mark, checkpoint.process))) continue;
186186
186297
  }
186187
- if (!writerStopped(worker) || !valid() || fs48.readFileSync(file3, "utf8") !== original) continue;
186188
- fs48.rmSync(`${file3}.log`, { force: true });
186189
- fs48.rmSync(`${file3}.stop`, { force: true });
186190
- fs48.unlinkSync(file3);
186298
+ if (!writerStopped(worker) || !valid() || fs49.readFileSync(file3, "utf8") !== original) continue;
186299
+ fs49.rmSync(`${file3}.log`, { force: true });
186300
+ fs49.rmSync(`${file3}.stop`, { force: true });
186301
+ fs49.unlinkSync(file3);
186191
186302
  if (job.state === "finished" && job.outcome === "done") clearCheckpoint(job.id);
186192
186303
  } finally {
186193
186304
  release2();
@@ -186212,14 +186323,14 @@ async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
186212
186323
  await halt?.();
186213
186324
  };
186214
186325
  const release2 = executorRecord();
186215
- const keepVersion = hold(path53.resolve(path53.dirname(fileURLToPath4(import.meta.url)), ".."));
186326
+ const keepVersion = hold(path54.resolve(path54.dirname(fileURLToPath4(import.meta.url)), ".."));
186216
186327
  worker.pid = process.pid;
186217
186328
  worker.processAt = Date.now();
186218
186329
  save2(worker);
186219
186330
  const timer = setInterval(() => {
186220
186331
  let asked = false;
186221
186332
  try {
186222
- asked = fs48.readFileSync(stopFile(id2), "utf8") === token;
186333
+ asked = fs49.readFileSync(stopFile(id2), "utf8") === token;
186223
186334
  } catch {
186224
186335
  }
186225
186336
  if (!valid() || asked) void stop2();