wildcrane-runner 0.6.99 → 0.6.101

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.99 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.101 — 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);
@@ -151778,8 +151778,8 @@ function loadProxyFile() {
151778
151778
 
151779
151779
  // src/flow-worker.ts
151780
151780
  import { spawn as spawn6 } from "node:child_process";
151781
- import fs48 from "node:fs";
151782
- import path53 from "node:path";
151781
+ import fs49 from "node:fs";
151782
+ import path54 from "node:path";
151783
151783
  import { fileURLToPath as fileURLToPath4 } from "node:url";
151784
151784
 
151785
151785
  // ../cli/src/lib/cloud/session.ts
@@ -152314,21 +152314,27 @@ function killMarked(mark, agent) {
152314
152314
  }
152315
152315
  signal(marked(mark), "SIGKILL");
152316
152316
  }
152317
- function processesStopped(mark, root2) {
152317
+ function probeProcesses(mark, root2) {
152318
152318
  try {
152319
152319
  if (WINDOWS) {
152320
152320
  const list3 = procsOnWindows();
152321
- if (!list3 || !root2) return false;
152321
+ if (!list3) return { ok: false, error: "\u65E0\u6CD5\u67E5\u8BE2\u8FDB\u7A0B\u5217\u8868\u3002" };
152322
+ if (!root2) return { ok: false, error: "\u7F3A\u5C11\u8FDB\u7A0B\u8D77\u70B9\uFF0C\u65E0\u6CD5\u6838\u5BF9\u9000\u51FA\u72B6\u6001\u3002" };
152322
152323
  const current2 = list3.procs.find((p2) => p2.pid === root2.pid);
152323
- if (current2 && current2.startedAt > root2.since) return false;
152324
- return startedUnder(list3, root2.pid, root2.since).length === 0;
152324
+ if (current2 && current2.startedAt > root2.since) return { ok: false, error: "\u8FDB\u7A0B\u53F7\u5DF2\u88AB\u590D\u7528\u3002" };
152325
+ return { ok: true, alive: startedUnder(list3, root2.pid, root2.since).length > 0 };
152325
152326
  }
152326
152327
  const entry = `${mark.name}=${mark.value}`;
152327
- return (process.platform === "linux" ? markedInProc(entry, true, mark.since) : markedInPs(entry, root2 ? [root2.pid] : [])).length === 0;
152328
- } catch {
152329
- return false;
152328
+ const pids = process.platform === "linux" ? markedInProc(entry, true, mark.since) : markedInPs(entry, root2 ? [root2.pid] : []);
152329
+ return { ok: true, alive: pids.length > 0 };
152330
+ } catch (e2) {
152331
+ return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
152330
152332
  }
152331
152333
  }
152334
+ function processesStopped(mark, root2) {
152335
+ const probed = probeProcesses(mark, root2);
152336
+ return probed.ok && !probed.alive;
152337
+ }
152332
152338
 
152333
152339
  // ../cli/src/lib/lock.ts
152334
152340
  import { randomUUID as randomUUID2 } from "node:crypto";
@@ -152407,6 +152413,7 @@ __export(api_exports, {
152407
152413
  cancelReplyApproval: () => cancelReplyApproval,
152408
152414
  claimJob: () => claimJob,
152409
152415
  commitBoard: () => commitBoard,
152416
+ completeArchives: () => completeArchives,
152410
152417
  completeUpload: () => completeUpload,
152411
152418
  createArtifact: () => createArtifact,
152412
152419
  createProject: () => createProject,
@@ -153273,10 +153280,10 @@ function mergeDefs(...defs) {
153273
153280
  function cloneDef(schema) {
153274
153281
  return mergeDefs(schema._zod.def);
153275
153282
  }
153276
- function getElementAtPath(obj3, path54) {
153277
- if (!path54)
153283
+ function getElementAtPath(obj3, path55) {
153284
+ if (!path55)
153278
153285
  return obj3;
153279
- return path54.reduce((acc, key) => acc?.[key], obj3);
153286
+ return path55.reduce((acc, key) => acc?.[key], obj3);
153280
153287
  }
153281
153288
  function promiseAllObject(promisesObj) {
153282
153289
  const keys = Object.keys(promisesObj);
@@ -153616,11 +153623,11 @@ function explicitlyAborted(x2, startIndex = 0) {
153616
153623
  }
153617
153624
  return false;
153618
153625
  }
153619
- function prefixIssues(path54, issues) {
153626
+ function prefixIssues(path55, issues) {
153620
153627
  return issues.map((iss) => {
153621
153628
  var _a4;
153622
153629
  (_a4 = iss).path ?? (_a4.path = []);
153623
- iss.path.unshift(path54);
153630
+ iss.path.unshift(path55);
153624
153631
  return iss;
153625
153632
  });
153626
153633
  }
@@ -154082,16 +154089,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
154082
154089
  }
154083
154090
  function formatError(error62, mapper = (issue2) => issue2.message) {
154084
154091
  const fieldErrors = { _errors: [] };
154085
- const processError = (error63, path54 = []) => {
154092
+ const processError = (error63, path55 = []) => {
154086
154093
  for (const issue2 of error63.issues) {
154087
154094
  if (issue2.code === "invalid_union" && issue2.errors.length) {
154088
- issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
154095
+ issue2.errors.map((issues) => processError({ issues }, [...path55, ...issue2.path]));
154089
154096
  } else if (issue2.code === "invalid_key") {
154090
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154097
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154091
154098
  } else if (issue2.code === "invalid_element") {
154092
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154099
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154093
154100
  } else {
154094
- const fullpath = [...path54, ...issue2.path];
154101
+ const fullpath = [...path55, ...issue2.path];
154095
154102
  if (fullpath.length === 0) {
154096
154103
  fieldErrors._errors.push(mapper(issue2));
154097
154104
  } else {
@@ -154130,17 +154137,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
154130
154137
  }
154131
154138
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
154132
154139
  const result = { errors: [] };
154133
- const processError = (error63, path54 = []) => {
154140
+ const processError = (error63, path55 = []) => {
154134
154141
  var _a4;
154135
154142
  for (const issue2 of error63.issues) {
154136
154143
  if (issue2.code === "invalid_union" && issue2.errors.length) {
154137
- issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
154144
+ issue2.errors.map((issues) => processError({ issues }, [...path55, ...issue2.path]));
154138
154145
  } else if (issue2.code === "invalid_key") {
154139
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154146
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154140
154147
  } else if (issue2.code === "invalid_element") {
154141
- processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
154148
+ processError({ issues: issue2.issues }, [...path55, ...issue2.path]);
154142
154149
  } else {
154143
- const fullpath = [...path54, ...issue2.path];
154150
+ const fullpath = [...path55, ...issue2.path];
154144
154151
  if (fullpath.length === 0) {
154145
154152
  result.errors.push(mapper(issue2));
154146
154153
  continue;
@@ -154179,8 +154186,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
154179
154186
  }
154180
154187
  function toDotPath(_path) {
154181
154188
  const segs = [];
154182
- const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
154183
- for (const seg of path54) {
154189
+ const path55 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
154190
+ for (const seg of path55) {
154184
154191
  if (typeof seg === "number")
154185
154192
  segs.push(`[${seg}]`);
154186
154193
  else if (typeof seg === "symbol")
@@ -171318,13 +171325,13 @@ function resolveRef(ref, ctx) {
171318
171325
  if (!ref.startsWith("#")) {
171319
171326
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
171320
171327
  }
171321
- const path54 = ref.slice(1).split("/").filter(Boolean);
171322
- if (path54.length === 0) {
171328
+ const path55 = ref.slice(1).split("/").filter(Boolean);
171329
+ if (path55.length === 0) {
171323
171330
  return ctx.rootSchema;
171324
171331
  }
171325
171332
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
171326
- if (path54[0] === defsKey) {
171327
- 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]);
171328
171335
  if (!key || !ctx.defs[key]) {
171329
171336
  throw new Error(`Reference not found: ${ref}`);
171330
171337
  }
@@ -172244,7 +172251,7 @@ function reviewInstruction(authorization) {
172244
172251
  case "stages":
172245
172252
  return [
172246
172253
  "Work only on these unlocked stages: " + authorization.nodes.map((node2) => node2.id).join(", "),
172247
- ...authorization.nodes.map((node2) => `- ${node2.id}: ${node2.previews.length ? node2.previews.join(", ") : "card body"}`)
172254
+ ...authorization.nodes.map((node2) => `- ${node2.id}: ${node2.previews.length ? node2.previews.join(", ") : "no Preview"}`)
172248
172255
  ].join("\n");
172249
172256
  case "delivery":
172250
172257
  return "Stages complete. Follow Studio delivery checks.";
@@ -172295,7 +172302,7 @@ function goalRoute(discussion, goal, field) {
172295
172302
  }
172296
172303
 
172297
172304
  // src/protocol.ts
172298
- var AKB_VERSION = true ? "0.11.80" : "0.0.0";
172305
+ var AKB_VERSION = true ? "0.11.81" : "0.0.0";
172299
172306
  var AKB_CONTRACT = true ? 27 : 0;
172300
172307
 
172301
172308
  // src/secrets.ts
@@ -172334,7 +172341,7 @@ function temporaryCloudFailure(error62) {
172334
172341
  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);
172335
172342
  }
172336
172343
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
172337
- var PROTOCOL = 29;
172344
+ var PROTOCOL = 30;
172338
172345
  var TIMEOUT_MS = 2e4;
172339
172346
  async function send(method, route, body, signedIn, ms, type, extra = {}) {
172340
172347
  const headers = { accept: "application/json", ...extra };
@@ -172478,13 +172485,14 @@ var listFolders = (machineId) => request("GET", `/v1/runner/folders?machine=${q(
172478
172485
  var listElsewhere = (machineId) => request("GET", `/v1/runner/folders?machine=${q(machineId)}&elsewhere=1`);
172479
172486
  var listMachineTasks = (machineId) => request("GET", `/v1/runner/tasks?machine=${q(machineId)}`);
172480
172487
  var stopTask = (task, how) => request("POST", how === "chat" ? `/v1/tasks/${q(task)}/chat/stop` : `/v1/tasks/${q(task)}/stop`, {});
172481
- var addFolder = (machineId, name, path54, project) => request("POST", "/v1/runner/folders", { machineId, name, path: path54, ...project ? { project } : {} });
172488
+ var addFolder = (machineId, name, path55, project) => request("POST", "/v1/runner/folders", { machineId, name, path: path55, ...project ? { project } : {} });
172482
172489
  async function createProject(name, workspace, key) {
172483
172490
  const sent = await send("POST", "/v1/projects", { name, workspace }, true, TIMEOUT_MS, void 0, { "idempotency-key": key });
172484
172491
  return sent.ok ? answerOf(sent.value) : sent;
172485
172492
  }
172486
172493
  var removeFolder = (machineId, project) => request("POST", `/v1/runner/folders/${q(project)}/remove`, { machineId });
172487
172494
  var readBoard = (project, since) => request("GET", `/v1/projects/${q(project)}/board${since === null ? "" : `?since=${since}`}`);
172495
+ var completeArchives = (project, machine, cards) => request("POST", `/v1/projects/${q(project)}/board/archive-completions`, { machine, cards });
172488
172496
  async function commitBoard(project, job, machine, files) {
172489
172497
  const sent = await send("POST", `/v1/projects/${q(project)}/board/commits`, { job, machine, files }, true, TIMEOUT_MS);
172490
172498
  if (!sent.ok) return sent;
@@ -172557,25 +172565,25 @@ import path12 from "node:path";
172557
172565
  init_file_limits();
172558
172566
  var ROOTS = ["todo/", ".archive/", "memory/", "studios/", "triage/", "assets/", "rules/"];
172559
172567
  var SETTINGS = ["modules.md", "config.md"];
172560
- var isSettingsPath = (path54) => SETTINGS.includes(path54) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path54);
172561
- function isBoardPath(path54) {
172562
- if (!path54 || path54.length > 500 || path54.startsWith("/") || path54.includes("\\") || path54.includes("\0")) return false;
172563
- if (path54.split("/").some((part) => !part || part === "." || part === "..")) return false;
172564
- if (path54 === "todo/README.md" || path54.split("/").includes(".sync")) return false;
172565
- if (path54.startsWith("studios/")) return true;
172566
- if (SETTINGS.includes(path54)) return true;
172567
- if (path54.startsWith("rules/")) return isSettingsPath(path54);
172568
- if (path54.startsWith("assets/")) return taskOfAssets(path54) !== null;
172569
- return ROOTS.some((root2) => path54.startsWith(root2)) && path54.endsWith(".md");
172568
+ var isSettingsPath = (path55) => SETTINGS.includes(path55) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path55);
172569
+ function isBoardPath(path55) {
172570
+ if (!path55 || path55.length > 500 || path55.startsWith("/") || path55.includes("\\") || path55.includes("\0")) return false;
172571
+ if (path55.split("/").some((part) => !part || part === "." || part === "..")) return false;
172572
+ if (path55 === "todo/README.md" || path55.split("/").includes(".sync")) return false;
172573
+ if (path55.startsWith("studios/")) return true;
172574
+ if (SETTINGS.includes(path55)) return true;
172575
+ if (path55.startsWith("rules/")) return isSettingsPath(path55);
172576
+ if (path55.startsWith("assets/")) return taskOfAssets(path55) !== null;
172577
+ return ROOTS.some((root2) => path55.startsWith(root2)) && path55.endsWith(".md");
172570
172578
  }
172571
172579
  var CARD = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]*\.md$/;
172572
172580
  var ROOT = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]+\/root\.md$/;
172573
- function numberOfCard(path54) {
172574
- const n = ROOT.exec(path54)?.[1] ?? CARD.exec(path54)?.[1];
172581
+ function numberOfCard(path55) {
172582
+ const n = ROOT.exec(path55)?.[1] ?? CARD.exec(path55)?.[1];
172575
172583
  return n ? Number(n) : null;
172576
172584
  }
172577
172585
  var assetsFile = (task) => `assets/${task}.json`;
172578
- var taskOfAssets = (path54) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path54)?.[1] ?? null;
172586
+ var taskOfAssets = (path55) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path55)?.[1] ?? null;
172579
172587
  var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
172580
172588
  var studioName = (id2) => id2.startsWith("wf_builtin_") ? id2.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id2);
172581
172589
  var studioRuleFile = (id2) => `rules/studios/${studioName(id2)}.md`;
@@ -172837,7 +172845,7 @@ function landSections(body, previews) {
172837
172845
  }
172838
172846
  function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
172839
172847
  const problems = [];
172840
- const fail = (offset, path54, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path54, code, message, hint: hint2 });
172848
+ const fail = (offset, path55, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path55, code, message, hint: hint2 });
172841
172849
  const result = () => ({ problem: problems.map((p2) => `${p2.file}:${p2.line}:${p2.column} ${p2.path}: ${p2.code} \u2014 ${p2.message}. ${p2.hint}`).join("\n"), problems });
172842
172850
  if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
172843
172851
  const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
@@ -173963,14 +173971,15 @@ function backoffMs(attempt, random = Math.random) {
173963
173971
  const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt - 2));
173964
173972
  return Math.round(step * (1 - 0.25 * random()));
173965
173973
  }
173966
- function planRetry(failure2, attempt, now = Date.now(), backoff = backoffMs) {
173974
+ function planRetry(failure2, attempt, now = Date.now(), backoff = backoffMs, task = false) {
173967
173975
  if (!Number.isSafeInteger(attempt) || attempt < 1 || failure2.level === 3) return { pause: "needs-review" };
173968
173976
  const of = failure2.level === 1 ? 2 : 4;
173969
173977
  if (attempt >= of) return { pause: "limit" };
173970
173978
  const delay3 = failure2.retryAfterMs;
173971
173979
  const valid = delay3 !== void 0 && !Number.isNaN(delay3) && delay3 >= 0;
173972
173980
  const wait3 = valid ? delay3 : failure2.level === 1 ? 0 : backoff(attempt + 1);
173973
- if (wait3 > CAP_MS) return { pause: "wait-too-long" };
173981
+ const cap = task && failure2.code === "rate_limited" && valid ? 24 * 60 * 6e4 : CAP_MS;
173982
+ if (wait3 > cap) return { pause: "wait-too-long" };
173974
173983
  return { plan: { at: now + wait3, of, failure: failure2 } };
173975
173984
  }
173976
173985
  function readFailure(raw) {
@@ -173979,12 +173988,12 @@ function readFailure(raw) {
173979
173988
  if (typeof code !== "string" || !code || typeof reason !== "string" || level !== 1 && level !== 2 && level !== 3) return;
173980
173989
  return { code, level, reason, ...["validation", "provider", "harness", "invariant"].some((value) => value === source2) ? { source: source2 } : {}, ...typeof retryAfterMs2 === "number" && retryAfterMs2 >= 0 ? { retryAfterMs: retryAfterMs2 } : {} };
173981
173990
  }
173982
- function readRetryPlan(raw, attempt) {
173991
+ function readRetryPlan(raw, attempt, task = false) {
173983
173992
  if (!raw || typeof raw !== "object") return;
173984
173993
  const { at: at2, of, failure: rawFailure } = raw;
173985
173994
  const failure2 = readFailure(rawFailure);
173986
173995
  if (!failure2 || typeof at2 !== "number" || !Number.isFinite(at2)) return;
173987
- const decision = planRetry(failure2, attempt);
173996
+ const decision = planRetry(failure2, attempt, Date.now(), backoffMs, task);
173988
173997
  if ("plan" in decision && of === decision.plan.of) return { at: at2, of, failure: failure2 };
173989
173998
  }
173990
173999
  function pauseLine(pause, zh = translating()) {
@@ -174048,9 +174057,9 @@ async function stopConnection(root2, timeout) {
174048
174057
  }
174049
174058
 
174050
174059
  // src/flow.ts
174051
- import fs36 from "node:fs";
174060
+ import fs37 from "node:fs";
174052
174061
  import os6 from "node:os";
174053
- import path42 from "node:path";
174062
+ import path43 from "node:path";
174054
174063
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
174055
174064
 
174056
174065
  // ../cli/src/lib/agent/approved-ui.ts
@@ -174801,6 +174810,7 @@ function antigravityPrices(at2) {
174801
174810
  return {
174802
174811
  "gemini-4-carbon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
174803
174812
  "gemini-4-argon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
174813
+ "gemini-4-neon": { input: 3, cachedInput: 0.15, output: 15 },
174804
174814
  "gemini-4-hydrogen": { input: 1.5, cachedInput: 0.075, output: 7.5 },
174805
174815
  "gemini-3.8-flash": { input: flash, cachedInput: flash / 10, output: flash * 5 }
174806
174816
  };
@@ -174883,10 +174893,10 @@ function findRollout(threadId) {
174883
174893
  }
174884
174894
  for (const name of names2) {
174885
174895
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
174886
- const path54 = join(dir, name);
174896
+ const path55 = join(dir, name);
174887
174897
  try {
174888
- const at2 = statSync(path54).mtimeMs;
174889
- if (!newest2 || at2 > newest2.at) newest2 = { path: path54, at: at2 };
174898
+ const at2 = statSync(path55).mtimeMs;
174899
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path55, at: at2 };
174890
174900
  } catch {
174891
174901
  }
174892
174902
  }
@@ -174894,11 +174904,11 @@ function findRollout(threadId) {
174894
174904
  return newest2?.path;
174895
174905
  }
174896
174906
  function readCodexRunFacts(threadId) {
174897
- const path54 = findRollout(threadId);
174898
- if (!path54) return void 0;
174907
+ const path55 = findRollout(threadId);
174908
+ if (!path55) return void 0;
174899
174909
  let raw;
174900
174910
  try {
174901
- raw = readFileSync(path54, "utf8");
174911
+ raw = readFileSync(path55, "utf8");
174902
174912
  } catch {
174903
174913
  return void 0;
174904
174914
  }
@@ -175010,8 +175020,8 @@ function renderCompleted(item) {
175010
175020
  const changes = Array.isArray(item.changes) ? item.changes : [];
175011
175021
  return changes.map((raw) => {
175012
175022
  const change = obj(raw);
175013
- const path54 = str2(change.path);
175014
- return path54 ? `\u23FA ${str2(change.kind) || "change"}(${path54})
175023
+ const path55 = str2(change.path);
175024
+ return path55 ? `\u23FA ${str2(change.kind) || "change"}(${path55})
175015
175025
  ` : "";
175016
175026
  }).join("");
175017
175027
  }
@@ -175329,10 +175339,10 @@ function readKimiRunFacts(sessionId) {
175329
175339
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
175330
175340
  let model;
175331
175341
  let holding = 0;
175332
- for (const { path: path54, main } of wireFiles(entry.sessionDir)) {
175342
+ for (const { path: path55, main } of wireFiles(entry.sessionDir)) {
175333
175343
  let raw;
175334
175344
  try {
175335
- raw = readFileSync2(path54, "utf8");
175345
+ raw = readFileSync2(path55, "utf8");
175336
175346
  } catch {
175337
175347
  continue;
175338
175348
  }
@@ -175670,7 +175680,7 @@ function createTail(log) {
175670
175680
  // ../cli/package.json
175671
175681
  var package_default = {
175672
175682
  name: "wildcrane",
175673
- version: "0.11.80",
175683
+ version: "0.11.81",
175674
175684
  akbContract: 27,
175675
175685
  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.",
175676
175686
  keywords: [
@@ -175747,8 +175757,8 @@ var CLIENT_CAPABILITIES = {
175747
175757
  };
175748
175758
  function whereHint(update2, title) {
175749
175759
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
175750
- const path54 = str2(obj(locations[0]).path);
175751
- return path54 && !title.includes(path54) ? hint(path54) : "";
175760
+ const path55 = str2(obj(locations[0]).path);
175761
+ return path55 && !title.includes(path55) ? hint(path55) : "";
175752
175762
  }
175753
175763
  function saidBy(update2) {
175754
175764
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -176874,7 +176884,7 @@ async function run(io, options, count2) {
176874
176884
  startupTimer = setTimeout(() => {
176875
176885
  if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
176876
176886
  }, CONVERSATION_MS.start);
176877
- 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) => {
176887
+ 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) => {
176878
176888
  if (!started) throw error62;
176879
176889
  });
176880
176890
  };
@@ -177728,9 +177738,37 @@ function bytesField(data, field) {
177728
177738
  if (number4 === field && value instanceof Uint8Array) return value;
177729
177739
  }
177730
177740
  }
177741
+ function varintField(data, field) {
177742
+ if (!(data instanceof Uint8Array)) return;
177743
+ for (const [number4, value] of fields(data)) {
177744
+ if (number4 === field && typeof value === "number") return value;
177745
+ }
177746
+ }
177747
+ function stepIndices(data) {
177748
+ const out = [];
177749
+ for (const [field, value] of fields(data)) {
177750
+ if (field !== 2) continue;
177751
+ if (typeof value === "number") out.push(value);
177752
+ else {
177753
+ const offset = { value: 0 };
177754
+ while (offset.value < value.length) out.push(varint(value, offset));
177755
+ }
177756
+ }
177757
+ return out;
177758
+ }
177759
+ function recordedContextLimit(data) {
177760
+ const limit = varintField(bytesField(bytesField(bytesField(data, 1), 9), 10), 4);
177761
+ return limit !== void 0 && Number.isSafeInteger(limit) && limit > 0 ? limit : void 0;
177762
+ }
177731
177763
  var utf8 = (bytes2) => bytes2 && Buffer.from(bytes2).toString("utf8");
177764
+ function stepUuid(stepRow, index) {
177765
+ if (!Number.isSafeInteger(index) || index < 0) return;
177766
+ const id2 = bytesField(stepRow.get(index)?.metadata, 12);
177767
+ return id2?.length === 36 ? id2 : void 0;
177768
+ }
177732
177769
  function antigravityRecordedModels(session, steps) {
177733
177770
  const found = /* @__PURE__ */ new Map();
177771
+ if (!steps.size) return found;
177734
177772
  const file3 = antigravityConversationFile(session);
177735
177773
  if (!file3 || !existsSync(file3)) return found;
177736
177774
  try {
@@ -177738,26 +177776,31 @@ function antigravityRecordedModels(session, steps) {
177738
177776
  if (!sqlite) return found;
177739
177777
  const db = new sqlite.DatabaseSync(file3, { readOnly: true });
177740
177778
  try {
177741
- const prompt = db.prepare("SELECT metadata FROM steps WHERE idx = ?");
177779
+ const stepRow = db.prepare("SELECT metadata FROM steps WHERE idx = ?");
177780
+ const promptIds = /* @__PURE__ */ new Map();
177781
+ const promptUuid = (prompt) => {
177782
+ if (!promptIds.has(prompt)) promptIds.set(prompt, stepUuid(stepRow, prompt));
177783
+ return promptIds.get(prompt);
177784
+ };
177785
+ const groups = /* @__PURE__ */ new Map();
177786
+ for (const [index, { prompt }] of steps) {
177787
+ if (!Number.isSafeInteger(index) || index < 0) continue;
177788
+ const id2 = stepUuid(stepRow, index) ?? promptUuid(prompt);
177789
+ if (!id2) continue;
177790
+ const uuid3 = utf8(id2);
177791
+ let group = groups.get(uuid3);
177792
+ if (!group) groups.set(uuid3, group = { id: id2, steps: /* @__PURE__ */ new Set() });
177793
+ group.steps.add(index);
177794
+ }
177742
177795
  const generations = db.prepare("SELECT data FROM gen_metadata WHERE instr(data, ?) > 0");
177743
- for (const index of new Set([...steps.values()].map((step) => step.prompt))) {
177744
- const id2 = bytesField(prompt.get(index)?.metadata, 12);
177745
- if (id2?.length !== 36) continue;
177796
+ for (const [uuid3, { id: id2, steps: groupSteps }] of groups) {
177746
177797
  const key = Buffer.concat([Buffer.from([34, 36]), id2]);
177747
177798
  for (const { data } of generations.iterate(key)) {
177748
- if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !== utf8(id2)) continue;
177799
+ if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !== uuid3) continue;
177749
177800
  const model = utf8(bytesField(bytesField(data, 1), 19)) || void 0;
177750
- const record2 = (step) => {
177751
- if (steps.get(step)?.prompt !== index) return;
177801
+ for (const step of stepIndices(data)) {
177802
+ if (!groupSteps.has(step)) continue;
177752
177803
  found.set(step, found.has(step) && found.get(step) !== model ? void 0 : model);
177753
- };
177754
- for (const [field, value] of fields(data)) {
177755
- if (field !== 2) continue;
177756
- if (typeof value === "number") record2(value);
177757
- else {
177758
- const offset = { value: 0 };
177759
- while (offset.value < value.length) record2(varint(value, offset));
177760
- }
177761
177804
  }
177762
177805
  }
177763
177806
  }
@@ -177769,8 +177812,41 @@ function antigravityRecordedModels(session, steps) {
177769
177812
  return /* @__PURE__ */ new Map();
177770
177813
  }
177771
177814
  }
177815
+ function antigravityRecordedContextLimit(session, step, prompt) {
177816
+ if (!Number.isSafeInteger(step) || step < 0) return;
177817
+ const file3 = antigravityConversationFile(session);
177818
+ if (!file3 || !existsSync(file3)) return;
177819
+ try {
177820
+ const sqlite = process.getBuiltinModule?.("node:sqlite");
177821
+ if (!sqlite) return;
177822
+ const db = new sqlite.DatabaseSync(file3, { readOnly: true });
177823
+ try {
177824
+ const stepRow = db.prepare("SELECT metadata FROM steps WHERE idx = ?");
177825
+ const id2 = stepUuid(stepRow, step) ?? stepUuid(stepRow, prompt);
177826
+ if (!id2) return;
177827
+ const key = Buffer.concat([Buffer.from([34, 36]), id2]);
177828
+ const generations = db.prepare("SELECT data FROM gen_metadata WHERE instr(data, ?) > 0");
177829
+ let found;
177830
+ let matched = false;
177831
+ for (const { data } of generations.iterate(key)) {
177832
+ if (!(data instanceof Uint8Array) || utf8(bytesField(data, 4)) !== utf8(id2)) continue;
177833
+ if (!stepIndices(data).includes(step)) continue;
177834
+ const limit = recordedContextLimit(data);
177835
+ if (matched && found !== limit) return;
177836
+ found = limit;
177837
+ matched = true;
177838
+ }
177839
+ return found;
177840
+ } finally {
177841
+ db.close();
177842
+ }
177843
+ } catch {
177844
+ return;
177845
+ }
177846
+ }
177772
177847
 
177773
177848
  // ../cli/src/lib/agent/wire/antigravity.ts
177849
+ var CONTEXT_LOOK_EVERY_MS = 250;
177774
177850
  var KINDS = {
177775
177851
  run_command: "execute",
177776
177852
  command_status: "execute",
@@ -177817,6 +177893,20 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
177817
177893
  let stderr = "";
177818
177894
  let context;
177819
177895
  let contextStep = -1;
177896
+ let contextPrompt = -1;
177897
+ let contextLimitStep = -1;
177898
+ let contextLimitLookedAt = 0;
177899
+ const resolveContextLimit = (now) => {
177900
+ if (!context || !session || contextStep < 0 || contextLimitStep === contextStep) return;
177901
+ const at2 = Date.now();
177902
+ if (!now && at2 - contextLimitLookedAt < CONTEXT_LOOK_EVERY_MS) return;
177903
+ contextLimitLookedAt = at2;
177904
+ const limit = antigravityRecordedContextLimit(session, contextStep, contextPrompt);
177905
+ if (limit !== void 0) {
177906
+ context = { used: context.used, limit };
177907
+ contextLimitStep = contextStep;
177908
+ }
177909
+ };
177820
177910
  const started = Date.now();
177821
177911
  let cost;
177822
177912
  let incomplete = false;
@@ -177882,10 +177972,13 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
177882
177972
  const index = num(step.step_index);
177883
177973
  if (step.state === "DONE" && Number.isSafeInteger(index) && step.step_index === index && index > contextStep) {
177884
177974
  contextStep = index;
177975
+ contextPrompt = prompt;
177976
+ contextLimitStep = -1;
177977
+ contextLimitLookedAt = 0;
177885
177978
  const u2 = obj(step.usage);
177886
177979
  const counts2 = [u2.input_tokens, u2.cache_read_tokens];
177887
- const prompt2 = counts2.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0) ? num(u2.input_tokens) + num(u2.cache_read_tokens) : 0;
177888
- context = prompt2 > 0 && Number.isFinite(prompt2) ? { used: prompt2 } : void 0;
177980
+ const promptTokens = counts2.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0) ? num(u2.input_tokens) + num(u2.cache_read_tokens) : 0;
177981
+ context = promptTokens > 0 && Number.isFinite(promptTokens) ? { used: promptTokens } : void 0;
177889
177982
  }
177890
177983
  if (step.state === "DONE" && step.usage && !counted.has(index)) {
177891
177984
  counted.add(index);
@@ -177938,6 +178031,7 @@ ${imageError(target, reason || str2(step.state))}
177938
178031
  return "";
177939
178032
  }
177940
178033
  session ||= str2(result.conversation_id) || void 0;
178034
+ resolveContextLimit(true);
177941
178035
  terminal = true;
177942
178036
  final = typeof result.response === "string" ? result.response : void 0;
177943
178037
  const total = usageOf4(result.usage);
@@ -177969,6 +178063,7 @@ ${imageError(target, reason || str2(step.state))}
177969
178063
  },
177970
178064
  flush() {
177971
178065
  const text3 = reader.flush();
178066
+ resolveContextLimit(true);
177972
178067
  if (pendingCosts.size) {
177973
178068
  const models = session ? antigravityRecordedModels(session, pendingCosts) : void 0;
177974
178069
  for (const [index, { usage }] of pendingCosts) estimate(models?.get(index), usage);
@@ -177991,7 +178086,10 @@ ${imageError(target, reason || str2(step.state))}
177991
178086
  usage: () => used,
177992
178087
  costUsd: () => cost,
177993
178088
  costIncomplete: () => incomplete || void 0,
177994
- context: () => context,
178089
+ context: () => {
178090
+ resolveContextLimit(false);
178091
+ return context;
178092
+ },
177995
178093
  failure: () => failure2 || imageFailure,
177996
178094
  terminalFailure: () => terminal && !!classified,
177997
178095
  executionFailure: () => classified ?? (imageFailure ? { code: "image_read_failed", level: 3, reason: imageFailure } : void 0),
@@ -179908,6 +180006,103 @@ function probeLogin(binary, harness) {
179908
180006
  });
179909
180007
  }
179910
180008
 
180009
+ // src/archive-completion.ts
180010
+ import { execFileSync as execFileSync2 } from "node:child_process";
180011
+ import fs27 from "node:fs";
180012
+ import path32 from "node:path";
180013
+
180014
+ // ../cli/src/lib/cloud/execution.ts
180015
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
180016
+ function executionOf(value = process.env.AI4KANBAN_EXECUTION) {
180017
+ try {
180018
+ const held5 = typeof value === "string" ? JSON.parse(value) : value;
180019
+ if (held5 && UUID.test(held5.job) && UUID.test(held5.machine)) return { job: held5.job, machine: held5.machine };
180020
+ } catch {
180021
+ }
180022
+ return void 0;
180023
+ }
180024
+
180025
+ // ../cli/src/lib/shared/delivery-evidence.ts
180026
+ var APPROVED = [
180027
+ /^##\s+Worth noting\s*$/i,
180028
+ /^##\s+Scope\s*$/i,
180029
+ /^##\s+Scope out\s*$/i,
180030
+ // `skill` is the word a spec section carries now; `agent` is the word it carried before
180031
+ // #403, and a card written by an older release still has to travel whole.
180032
+ /^##\s+By\s+`[^`]+`\s+(skill|agent)\s*$/i
180033
+ ];
180034
+ var isApproved = (heading) => APPROVED.some((re3) => re3.test(heading));
180035
+ function approvedCardRequirements(text3) {
180036
+ const { meta: meta3, body } = parseFrontmatter(text3);
180037
+ const out = [];
180038
+ if (meta3?.title) out.push(`# ${meta3.title}`, "");
180039
+ const opening = [];
180040
+ const sections = [];
180041
+ let keeping = false;
180042
+ let started = false;
180043
+ for (const line of body.split("\n")) {
180044
+ if (/^##(?!#)\s/.test(line)) {
180045
+ started = true;
180046
+ keeping = isApproved(line);
180047
+ if (keeping) sections.push("", line);
180048
+ continue;
180049
+ }
180050
+ if (line.trim() === "<!-- agent -->") continue;
180051
+ if (!started) opening.push(line);
180052
+ else if (keeping) sections.push(line);
180053
+ }
180054
+ out.push(opening.join("\n").trim());
180055
+ out.push(sections.join("\n").trim());
180056
+ return out.filter(Boolean).join("\n\n").replace(/\n{3,}/g, "\n\n").trim() + "\n";
180057
+ }
180058
+ var ARCHIVE_COMPLETION_BATCH = 100;
180059
+
180060
+ // src/archive-completion.ts
180061
+ function archivedDeliveries(board, numbers, machine) {
180062
+ const dir = path32.join(board, "deliveries");
180063
+ const deliveries = /* @__PURE__ */ new Map();
180064
+ if (!numbers.size) return deliveries;
180065
+ let files;
180066
+ try {
180067
+ files = fs27.readdirSync(dir);
180068
+ } catch {
180069
+ return deliveries;
180070
+ }
180071
+ for (const name of files) {
180072
+ if (!/^[a-z0-9]{1,64}\.json$/.test(name)) continue;
180073
+ try {
180074
+ const row = JSON.parse(fs27.readFileSync(path32.join(dir, name), "utf8"));
180075
+ if (row.cardId === null || !numbers.has(row.cardId) || row.deliveryId + ".json" !== name || executionOf(row.cloudExecution ?? null)?.machine !== machine || !Number.isFinite(row.startedAt)) continue;
180076
+ if ((deliveries.get(row.cardId)?.startedAt ?? -1) < row.startedAt) deliveries.set(row.cardId, row);
180077
+ } catch {
180078
+ }
180079
+ }
180080
+ return deliveries;
180081
+ }
180082
+ function archiveReceipt(row, archive, content, cwd) {
180083
+ if (row?.status !== "finished" || !row.cloudExecution || !row.approved || row.approved !== approvedCardRequirements(content)) return;
180084
+ const completions = Array.isArray(row.completions) ? row.completions : [];
180085
+ const end = completions.at(-1);
180086
+ const archived = end?.handoff?.archived_to;
180087
+ const target = end?.archiveSource?.kind === "group" && archive.endsWith("/root.md") ? archive.slice(0, -"/root.md".length) : archive;
180088
+ if (!end?.finished || typeof archived !== "string" || !(archived === target || archived.endsWith("/" + target))) return;
180089
+ const code = [...completions].reverse().find((step) => step.commit);
180090
+ const job = row.cloudExecution.job;
180091
+ if (!code?.commit) return row.landing?.commit || row.base && !row.scheduled ? void 0 : { id: row.deliveryId, job };
180092
+ const { commit, branch } = code;
180093
+ if (!branch || branch !== row.targetBranch || row.landing?.commit !== commit || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(commit)) return;
180094
+ try {
180095
+ execFileSync2(
180096
+ "git",
180097
+ ["merge-base", "--is-ancestor", commit, "refs/heads/" + branch],
180098
+ { cwd, stdio: "ignore", timeout: 5e3 }
180099
+ );
180100
+ return { id: row.deliveryId, job, commit, branch };
180101
+ } catch {
180102
+ return;
180103
+ }
180104
+ }
180105
+
179911
180106
  // ../cli/src/components/Asset.md
179912
180107
  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';
179913
180108
 
@@ -179936,8 +180131,8 @@ function formatStamp(d2) {
179936
180131
  }
179937
180132
 
179938
180133
  // ../cli/src/lib/agents/catalog.ts
179939
- import fs27 from "node:fs";
179940
- import path32 from "node:path";
180134
+ import fs28 from "node:fs";
180135
+ import path33 from "node:path";
179941
180136
  var specAgentCatalog = memoByFiles(() => [AGENTS, ...cloudStudioSources()], readCatalog);
179942
180137
  function readCatalog() {
179943
180138
  const agents = [];
@@ -179996,7 +180191,7 @@ function readBundled(folder2) {
179996
180191
  function projectFolders(root2) {
179997
180192
  let entries;
179998
180193
  try {
179999
- entries = fs27.readdirSync(root2, { withFileTypes: true });
180194
+ entries = fs28.readdirSync(root2, { withFileTypes: true });
180000
180195
  } catch {
180001
180196
  return [];
180002
180197
  }
@@ -180004,12 +180199,12 @@ function projectFolders(root2) {
180004
180199
  }
180005
180200
  function agentFileReader(dir) {
180006
180201
  return (relative) => {
180007
- const target = path32.resolve(dir, relative);
180008
- if (target !== dir && !target.startsWith(dir + path32.sep)) return null;
180202
+ const target = path33.resolve(dir, relative);
180203
+ if (target !== dir && !target.startsWith(dir + path33.sep)) return null;
180009
180204
  try {
180010
- const real = fs27.realpathSync(target);
180011
- if (!real.startsWith(fs27.realpathSync(dir) + path32.sep)) return null;
180012
- return fs27.readFileSync(real, "utf8");
180205
+ const real = fs28.realpathSync(target);
180206
+ if (!real.startsWith(fs28.realpathSync(dir) + path33.sep)) return null;
180207
+ return fs28.readFileSync(real, "utf8");
180013
180208
  } catch {
180014
180209
  return null;
180015
180210
  }
@@ -180019,20 +180214,20 @@ var ownFiles = (paths) => paths.filter((p2) => p2 !== "AGENT.md" && !p2.split("/
180019
180214
  function walkFolder(dir, prefix) {
180020
180215
  let entries;
180021
180216
  try {
180022
- entries = fs27.readdirSync(dir, { withFileTypes: true });
180217
+ entries = fs28.readdirSync(dir, { withFileTypes: true });
180023
180218
  } catch {
180024
180219
  return [];
180025
180220
  }
180026
180221
  return entries.flatMap((e2) => {
180027
180222
  const here = prefix ? `${prefix}/${e2.name}` : e2.name;
180028
- return e2.isDirectory() ? walkFolder(path32.join(dir, e2.name), here) : [here];
180223
+ return e2.isDirectory() ? walkFolder(path33.join(dir, e2.name), here) : [here];
180029
180224
  });
180030
180225
  }
180031
180226
  function readProject2(root2, folder2) {
180032
- const dir = path32.join(root2, folder2);
180227
+ const dir = path33.join(root2, folder2);
180033
180228
  const file3 = agentFileReader(dir);
180034
180229
  const text3 = file3("AGENT.md");
180035
- const missing = rel(path32.join(dir, "AGENT.md"));
180230
+ const missing = rel(path33.join(dir, "AGENT.md"));
180036
180231
  if (text3 === null) return { problem: `${missing} is missing`, file: missing, missing: true };
180037
180232
  const from = missing;
180038
180233
  const read5 = parseSpecAgent(text3, from, file3, false, () => ownFiles(walkFolder(dir, "")));
@@ -180042,8 +180237,8 @@ function readProject2(root2, folder2) {
180042
180237
  }
180043
180238
 
180044
180239
  // ../cli/src/lib/memory.ts
180045
- import fs28 from "node:fs";
180046
- import path33 from "node:path";
180240
+ import fs29 from "node:fs";
180241
+ import path34 from "node:path";
180047
180242
 
180048
180243
  // ../cli/src/lib/slug.ts
180049
180244
  function slugify2(s) {
@@ -180056,25 +180251,25 @@ var PLANNER = "planner";
180056
180251
  var PLANNER_MEMORY_FILES = ["decisions.md", "rejected.md", "redesign.md"];
180057
180252
  var RESERVED_MODULE_NAMES = PLANNER_MEMORY_FILES.map((name) => name.replace(/\.md$/, ""));
180058
180253
  function memoryDirectories(board) {
180059
- const root2 = board ? path33.join(board, "memory") : MEMORY;
180254
+ const root2 = board ? path34.join(board, "memory") : MEMORY;
180060
180255
  const walk = (dir, depth, scoped = true) => {
180061
180256
  let entries;
180062
180257
  try {
180063
- entries = fs28.readdirSync(dir, { withFileTypes: true });
180258
+ entries = fs29.readdirSync(dir, { withFileTypes: true });
180064
180259
  } catch {
180065
180260
  return [];
180066
180261
  }
180067
180262
  return entries.filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).flatMap((e2) => {
180068
- const target = path33.join(dir, e2.name);
180263
+ const target = path34.join(dir, e2.name);
180069
180264
  return depth === 1 ? !scoped || ["project", "workspace"].includes(e2.name) ? [target] : [] : walk(target, depth - 1, scoped);
180070
180265
  });
180071
180266
  };
180072
180267
  return [
180073
180268
  root2,
180074
- ...walk(path33.join(root2, "previews"), 3),
180075
- ...walk(path33.join(root2, "studios"), 1, false),
180076
- path33.join(root2, "agents", PLANNER)
180077
- ].filter((dir) => fs28.existsSync(dir)).map((dir) => `${dir}/`);
180269
+ ...walk(path34.join(root2, "previews"), 3),
180270
+ ...walk(path34.join(root2, "studios"), 1, false),
180271
+ path34.join(root2, "agents", PLANNER)
180272
+ ].filter((dir) => fs29.existsSync(dir)).map((dir) => `${dir}/`);
180078
180273
  }
180079
180274
 
180080
180275
  // ../cli/src/lib/agent/flows.ts
@@ -180505,14 +180700,14 @@ function collectSources(sources3, card, host) {
180505
180700
  const active = /* @__PURE__ */ new Set();
180506
180701
  const out = [];
180507
180702
  const visit2 = (src, types, owner2, partial2 = false) => {
180508
- const path54 = src.replace(/[?#].*$/, "");
180703
+ const path55 = src.replace(/[?#].*$/, "");
180509
180704
  let resolved;
180510
180705
  try {
180511
- resolved = host.resolve(path54, owner2);
180706
+ resolved = host.resolve(path55, owner2);
180512
180707
  } catch (error62) {
180513
180708
  if (owner2 !== card) return { key: null, error: why(error62) };
180514
180709
  if (!nodes.has(src)) {
180515
- const node3 = { key: src, file: null, kind: kindAt(path54, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
180710
+ const node3 = { key: src, file: null, kind: kindAt(path55, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
180516
180711
  nodes.set(src, node3);
180517
180712
  out.push(node3);
180518
180713
  }
@@ -180606,8 +180801,8 @@ function documentPreviewKey(artifact, version2) {
180606
180801
  init_file_limits();
180607
180802
  import { setTimeout as delay2 } from "node:timers/promises";
180608
180803
  import crypto4 from "node:crypto";
180609
- import fs32 from "node:fs";
180610
- import path38 from "node:path";
180804
+ import fs33 from "node:fs";
180805
+ import path39 from "node:path";
180611
180806
  import { isDeepStrictEqual } from "node:util";
180612
180807
 
180613
180808
  // node_modules/node-diff3/dist/diff3.mjs
@@ -180871,8 +181066,8 @@ ${groups.get(id2).join("\n\n")}
180871
181066
 
180872
181067
  // ../cli/src/lib/shared/triage-files.ts
180873
181068
  var ITEM = /^triage\/(?:(dismissed|archived)\/)?([^/]+)\.md$/;
180874
- function itemAt(path54) {
180875
- const m = ITEM.exec(path54);
181069
+ function itemAt(path55) {
181070
+ const m = ITEM.exec(path55);
180876
181071
  if (!m) return null;
180877
181072
  return { state: m[1] === "dismissed" ? "dismissed" : m[1] === "archived" ? "carded" : "open", name: m[2] };
180878
181073
  }
@@ -180902,29 +181097,29 @@ init_dress_page();
180902
181097
 
180903
181098
  // src/kanban-skill.ts
180904
181099
  import { spawnSync as spawnSync6 } from "node:child_process";
180905
- import fs30 from "node:fs";
180906
- import path35 from "node:path";
181100
+ import fs31 from "node:fs";
181101
+ import path36 from "node:path";
180907
181102
  var SKILL_FOLDERS = [".claude/skills/kanban", ".agents/skills/kanban"];
180908
181103
  var MANAGED = /^<!-- ai4kanban \S+ -->$/m;
180909
181104
  function removeLegacyKanbanSkill(root2) {
180910
181105
  for (const folder2 of SKILL_FOLDERS) {
180911
181106
  try {
180912
181107
  let at2 = root2;
180913
- if (!fs30.lstatSync(at2, { throwIfNoEntry: false })?.isDirectory()) continue;
181108
+ if (!fs31.lstatSync(at2, { throwIfNoEntry: false })?.isDirectory()) continue;
180914
181109
  let safe3 = true;
180915
181110
  const parts = `${folder2}/SKILL.md`.split("/");
180916
181111
  for (const [i, name] of parts.entries()) {
180917
- at2 = path35.join(at2, name);
180918
- const stat2 = fs30.lstatSync(at2, { throwIfNoEntry: false });
181112
+ at2 = path36.join(at2, name);
181113
+ const stat2 = fs31.lstatSync(at2, { throwIfNoEntry: false });
180919
181114
  if (!stat2 || stat2.isSymbolicLink() || (i < parts.length - 1 ? !stat2.isDirectory() : !stat2.isFile())) {
180920
181115
  safe3 = false;
180921
181116
  break;
180922
181117
  }
180923
181118
  }
180924
- if (!safe3 || !MANAGED.test(fs30.readFileSync(at2, "utf8"))) continue;
180925
- fs30.unlinkSync(at2);
180926
- const dir = path35.dirname(at2);
180927
- if (fs30.readdirSync(dir).length === 0) fs30.rmdirSync(dir);
181119
+ if (!safe3 || !MANAGED.test(fs31.readFileSync(at2, "utf8"))) continue;
181120
+ fs31.unlinkSync(at2);
181121
+ const dir = path36.dirname(at2);
181122
+ if (fs31.readdirSync(dir).length === 0) fs31.rmdirSync(dir);
180928
181123
  } catch (e2) {
180929
181124
  process.stderr.write(`wildcrane: \u65E0\u6CD5\u6E05\u7406 ${folder2}\uFF1A${e2 instanceof Error ? e2.message : String(e2)}
180930
181125
  `);
@@ -180937,10 +181132,10 @@ function keepOutOfGit(dir, folders2 = SKILL_FOLDERS) {
180937
181132
  if (inside2.status !== 0) return;
180938
181133
  const missing = [".akb/", ...folders2.map((f2) => `${f2}/`)].filter((p2) => git2("check-ignore", "-q", p2).status !== 0);
180939
181134
  if (!missing.length) return;
180940
- const exclude = path35.resolve(dir, inside2.stdout.trim());
180941
- fs30.mkdirSync(path35.dirname(exclude), { recursive: true });
180942
- const held5 = fs30.existsSync(exclude) ? fs30.readFileSync(exclude, "utf8") : "";
180943
- fs30.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
181135
+ const exclude = path36.resolve(dir, inside2.stdout.trim());
181136
+ fs31.mkdirSync(path36.dirname(exclude), { recursive: true });
181137
+ const held5 = fs31.existsSync(exclude) ? fs31.readFileSync(exclude, "utf8") : "";
181138
+ fs31.writeFileSync(exclude, `${held5}${held5 && !held5.endsWith("\n") ? "\n" : ""}${missing.join("\n")}
180944
181139
  `);
180945
181140
  }
180946
181141
 
@@ -180987,16 +181182,16 @@ function openTaskFolder(job, projectDir) {
180987
181182
  if (!projectDir) throw new Error(NO_FOLDER);
180988
181183
  keepOutOfGit(projectDir);
180989
181184
  markUsed(projectDir);
180990
- const board = path38.join(projectDir, ".akb", "kanban");
180991
- fs32.mkdirSync(board, { recursive: true });
181185
+ const board = path39.join(projectDir, ".akb", "kanban");
181186
+ fs33.mkdirSync(board, { recursive: true });
180992
181187
  return { task, cloudTask: task, board, cwd: projectDir, project: job.project, number: job.number ?? null, studio: job.studio ?? job.flow?.studio ?? null };
180993
181188
  }
180994
181189
  function openAgentFolder(job, projectDir) {
180995
181190
  if (!job.project || !job.agent) throw new Error("This job names no project.");
180996
181191
  keepOutOfGit(projectDir);
180997
181192
  markUsed(projectDir);
180998
- const board = path38.join(projectDir, ".akb", "kanban");
180999
- fs32.mkdirSync(board, { recursive: true });
181193
+ const board = path39.join(projectDir, ".akb", "kanban");
181194
+ fs33.mkdirSync(board, { recursive: true });
181000
181195
  const recordKey = job.agent.studio ? `${job.agent.studio}-${job.agent.name}` : job.agent.name;
181001
181196
  return {
181002
181197
  task: `agent-${safe2(recordKey)}`,
@@ -181012,8 +181207,8 @@ function openDiscussionFolder(job, projectDir) {
181012
181207
  if (!job.project) throw new Error("This job names no project.");
181013
181208
  keepOutOfGit(projectDir);
181014
181209
  markUsed(projectDir);
181015
- const board = path38.join(projectDir, ".akb", "kanban");
181016
- fs32.mkdirSync(board, { recursive: true });
181210
+ const board = path39.join(projectDir, ".akb", "kanban");
181211
+ fs33.mkdirSync(board, { recursive: true });
181017
181212
  return { task: "discussion", cloudTask: null, board, cwd: projectDir, project: job.project, number: null, studio: null };
181018
181213
  }
181019
181214
  var boardFolder = (ws) => ({ task: "board", cloudTask: null, board: ws.board, cwd: ws.cwd, project: ws.project, number: null, studio: null });
@@ -181024,7 +181219,7 @@ function inFolder(dir, work) {
181024
181219
  const started = performance.now();
181025
181220
  logSync("board.start", { dir, waitMs: Math.round(started - queued) });
181026
181221
  try {
181027
- return await withSyncLock(path38.join(dir, ".akb", "kanban"), work);
181222
+ return await withSyncLock(path39.join(dir, ".akb", "kanban"), work);
181028
181223
  } finally {
181029
181224
  logSync("board.end", { dir, ms: Math.round(performance.now() - started) });
181030
181225
  }
@@ -181038,37 +181233,37 @@ function inFolder(dir, work) {
181038
181233
  }
181039
181234
  var safe2 = (name) => name.replace(/[^\w.-]/g, "_") || "default";
181040
181235
  var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
181041
- var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path38.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
181236
+ var cardFile = (ws) => (ws.number ? findCard(ws.board, ws.number) : null) ?? path39.join(ws.board, "todo", `${ws.number ?? 0}-task.md`);
181042
181237
  function findCard(board, number4) {
181043
181238
  const named = new RegExp(`^${number4}-`);
181044
181239
  const walk = (dir) => {
181045
181240
  let entries;
181046
181241
  try {
181047
- entries = fs32.readdirSync(dir, { withFileTypes: true });
181242
+ entries = fs33.readdirSync(dir, { withFileTypes: true });
181048
181243
  } catch {
181049
181244
  return null;
181050
181245
  }
181051
181246
  for (const e2 of entries) {
181052
181247
  if (!named.test(e2.name)) continue;
181053
- if (e2.isFile() && e2.name.endsWith(".md")) return path38.join(dir, e2.name);
181054
- const root2 = path38.join(dir, e2.name, "root.md");
181055
- if (e2.isDirectory() && fs32.existsSync(root2)) return root2;
181248
+ if (e2.isFile() && e2.name.endsWith(".md")) return path39.join(dir, e2.name);
181249
+ const root2 = path39.join(dir, e2.name, "root.md");
181250
+ if (e2.isDirectory() && fs33.existsSync(root2)) return root2;
181056
181251
  }
181057
181252
  for (const e2 of entries) if (e2.isDirectory() && !e2.name.startsWith(".")) {
181058
- const hit = walk(path38.join(dir, e2.name));
181253
+ const hit = walk(path39.join(dir, e2.name));
181059
181254
  if (hit) return hit;
181060
181255
  }
181061
181256
  return null;
181062
181257
  };
181063
- return walk(path38.join(board, "todo")) ?? walk(path38.join(board, ".archive"));
181258
+ return walk(path39.join(board, "todo")) ?? walk(path39.join(board, ".archive"));
181064
181259
  }
181065
181260
  function akbCardOf(ws) {
181066
181261
  return ws.number && findCard(ws.board, ws.number) ? ws.number : void 0;
181067
181262
  }
181068
- var recordFile = (ws) => path38.join(ws.board, ".sync", `${ws.task}.json`);
181263
+ var recordFile = (ws) => path39.join(ws.board, ".sync", `${ws.task}.json`);
181069
181264
  function readRecord(ws) {
181070
181265
  try {
181071
- return { ...EMPTY, ...JSON.parse(fs32.readFileSync(recordFile(ws), "utf8")) };
181266
+ return { ...EMPTY, ...JSON.parse(fs33.readFileSync(recordFile(ws), "utf8")) };
181072
181267
  } catch {
181073
181268
  return structuredClone(EMPTY);
181074
181269
  }
@@ -181079,10 +181274,10 @@ function writeRecord(ws, record2) {
181079
181274
  if (readText(recordFile(ws)) === content) return;
181080
181275
  countSync("recordWrites");
181081
181276
  if (syncDebug) countSync("recordBytes", Buffer.byteLength(content));
181082
- fs32.mkdirSync(path38.dirname(recordFile(ws)), { recursive: true });
181277
+ fs33.mkdirSync(path39.dirname(recordFile(ws)), { recursive: true });
181083
181278
  const file3 = recordFile(ws);
181084
- fs32.writeFileSync(`${file3}.tmp`, content);
181085
- fs32.renameSync(`${file3}.tmp`, file3);
181279
+ fs33.writeFileSync(`${file3}.tmp`, content);
181280
+ fs33.renameSync(`${file3}.tmp`, file3);
181086
181281
  }
181087
181282
  async function cleanRecords(ws, base, options = {}) {
181088
181283
  const { removed = [], tasks, taskChat } = options;
@@ -181091,11 +181286,11 @@ async function cleanRecords(ws, base, options = {}) {
181091
181286
  const removedPaths = new Set(removed);
181092
181287
  const numbers = new Set(Object.keys(base.files).filter((p2) => p2.startsWith(root2) && !removedPaths.has(p2)).map((p2) => numberOfCard(p2.slice(root2.length))));
181093
181288
  const deleted = new Map(removed.filter((p2) => p2.startsWith(root2 + ".archive/")).map((p2) => [numberOfCard(p2.slice(root2.length)), p2.slice(root2.length)]));
181094
- for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path38.join(ws.board, ".sync"))) {
181289
+ for (const name of tasks ? [...tasks].map((task) => `${task}.json`) : filesUnder(path39.join(ws.board, ".sync"))) {
181095
181290
  if (!name.endsWith(".json") || name.includes("/")) continue;
181096
181291
  let record2;
181097
181292
  try {
181098
- record2 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
181293
+ record2 = JSON.parse(fs33.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
181099
181294
  } catch {
181100
181295
  continue;
181101
181296
  }
@@ -181111,7 +181306,7 @@ async function cleanRecords(ws, base, options = {}) {
181111
181306
  const folder2 = { ...ws, task: record2.task, cloudTask: record2.task, number: record2.number };
181112
181307
  const list3 = assetsFile(record2.task);
181113
181308
  const before = base.files[root2 + list3]?.content ?? null;
181114
- if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(path38.join(ws.board, list3)) === before) continue;
181309
+ if (taskChat && record2.task !== taskChat && !record2.deleted && !deleted.has(record2.number) && readText(path39.join(ws.board, list3)) === before) continue;
181115
181310
  const card = findCard(ws.board, record2.number);
181116
181311
  if (!record2.deleted && deleted.has(record2.number)) {
181117
181312
  record2.deleted = deleted.get(record2.number);
@@ -181129,13 +181324,13 @@ async function cleanRecords(ws, base, options = {}) {
181129
181324
  taskIndexes.set(ws.cwd, index);
181130
181325
  index.retiring.add(record2.task);
181131
181326
  if (card || kept(ws.cwd) || base.pendingAssets?.includes(record2.task)) continue;
181132
- const here = readText(path38.join(ws.board, list3));
181327
+ const here = readText(path39.join(ws.board, list3));
181133
181328
  if (here !== null && here !== before) continue;
181134
181329
  let changed = false;
181135
181330
  for (const [name2, entry] of Object.entries(record2.assets ?? {})) {
181136
181331
  let file3;
181137
181332
  try {
181138
- file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ? path38.join(ws.board, record2.deleted) : cardFile(folder2));
181333
+ file3 = assetPath(folder2, name2, typeof record2.deleted === "string" ? path39.join(ws.board, record2.deleted) : cardFile(folder2));
181139
181334
  } catch {
181140
181335
  changed = true;
181141
181336
  break;
@@ -181148,16 +181343,16 @@ async function cleanRecords(ws, base, options = {}) {
181148
181343
  }
181149
181344
  }
181150
181345
  if (!changed) {
181151
- fs32.rmSync(recordFile(folder2), { force: true });
181346
+ fs33.rmSync(recordFile(folder2), { force: true });
181152
181347
  forgetTask(index, record2.task);
181153
181348
  }
181154
181349
  }
181155
181350
  return retired;
181156
181351
  }
181157
- var baseFile = (ws) => path38.join(ws.cwd, ".akb", "base.json");
181352
+ var baseFile = (ws) => path39.join(ws.cwd, ".akb", "base.json");
181158
181353
  function readBase(ws) {
181159
181354
  try {
181160
- const base = JSON.parse(fs32.readFileSync(baseFile(ws), "utf8"));
181355
+ const base = JSON.parse(fs33.readFileSync(baseFile(ws), "utf8"));
181161
181356
  if (base.layout === "workspace") return base;
181162
181357
  } catch {
181163
181358
  }
@@ -181165,25 +181360,25 @@ function readBase(ws) {
181165
181360
  }
181166
181361
  function writeBase(ws, base) {
181167
181362
  const file3 = baseFile(ws);
181168
- fs32.mkdirSync(path38.dirname(file3), { recursive: true });
181169
- fs32.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
181170
- fs32.renameSync(`${file3}.tmp`, file3);
181363
+ fs33.mkdirSync(path39.dirname(file3), { recursive: true });
181364
+ fs33.writeFileSync(`${file3}.tmp`, JSON.stringify(base));
181365
+ fs33.renameSync(`${file3}.tmp`, file3);
181171
181366
  }
181172
181367
  var hashOf2 = (bytes2) => crypto4.createHash("sha256").update(bytes2).digest("hex");
181173
181368
  function hashFile(file3) {
181174
181369
  try {
181175
- return hashOf2(fs32.readFileSync(file3));
181370
+ return hashOf2(fs33.readFileSync(file3));
181176
181371
  } catch {
181177
181372
  return null;
181178
181373
  }
181179
181374
  }
181180
181375
  function write(file3, bytes2) {
181181
- fs32.mkdirSync(path38.dirname(file3), { recursive: true });
181182
- fs32.writeFileSync(file3, bytes2);
181376
+ fs33.mkdirSync(path39.dirname(file3), { recursive: true });
181377
+ fs33.writeFileSync(file3, bytes2);
181183
181378
  }
181184
181379
  function readText(file3) {
181185
181380
  try {
181186
- return fs32.readFileSync(file3, "utf8");
181381
+ return fs33.readFileSync(file3, "utf8");
181187
181382
  } catch {
181188
181383
  return null;
181189
181384
  }
@@ -181191,14 +181386,14 @@ function readText(file3) {
181191
181386
  function filesUnder(dir, base = dir) {
181192
181387
  let entries;
181193
181388
  try {
181194
- entries = fs32.readdirSync(dir, { withFileTypes: true });
181389
+ entries = fs33.readdirSync(dir, { withFileTypes: true });
181195
181390
  } catch {
181196
181391
  return [];
181197
181392
  }
181198
181393
  return entries.flatMap((e2) => {
181199
- const full = path38.join(dir, e2.name);
181394
+ const full = path39.join(dir, e2.name);
181200
181395
  if (e2.isDirectory()) return filesUnder(full, base);
181201
- return e2.isFile() ? [path38.relative(base, full).split(path38.sep).join("/")] : [];
181396
+ return e2.isFile() ? [path39.relative(base, full).split(path39.sep).join("/")] : [];
181202
181397
  });
181203
181398
  }
181204
181399
  var kept3 = (file3) => isBoardPath(file3) && !/^memory\/agents\/(?!planner\/)/.test(file3);
@@ -181220,18 +181415,18 @@ function assetFiles(ws, list3, card = cardFile(ws)) {
181220
181415
  return null;
181221
181416
  }
181222
181417
  };
181223
- return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path38.relative(ws.board, f2).split(path38.sep).join("/")));
181418
+ return new Set(Object.keys(assetsOf(list3)).map(at2).filter((f2) => !!f2).map((f2) => path39.relative(ws.board, f2).split(path39.sep).join("/")));
181224
181419
  }
181225
181420
  var assetsListOf = (ws, base) => base.files[rootOf(ws) + assetsFile(ws.task)]?.content;
181226
181421
  var localFiles = (ws, base) => {
181227
- const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path38.join(ws.board, assetsFile(ws.task))))]);
181422
+ const assets = /* @__PURE__ */ new Set([...assetFiles(ws, assetsListOf(ws, base)), ...assetFiles(ws, readText(path39.join(ws.board, assetsFile(ws.task))))]);
181228
181423
  return filesUnder(ws.board).filter((p2) => kept3(p2) && !assets.has(p2));
181229
181424
  };
181230
181425
  var SKILL_PATH = /^skills\/([a-z0-9]+(?:-[a-z0-9]+)*)\/((?:[\w.-]+\/)*[\w.-]+)$/;
181231
181426
  function pullTools(ws, record2, files) {
181232
181427
  const held5 = record2.tools?.skills ?? {};
181233
181428
  const ours = new Set(Object.keys(held5).map((name) => name.split("/")[1]));
181234
- const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs32.existsSync(path38.join(ws.cwd, root2, skill)));
181429
+ const theirs = (skill) => !ours.has(skill) && SKILL_ROOTS.some((root2) => fs33.existsSync(path39.join(ws.cwd, root2, skill)));
181235
181430
  const kept4 = Object.keys(files).map((name) => SKILL_PATH.exec(name)?.[1]).filter((skill) => skill && !theirs(skill));
181236
181431
  const skills = {};
181237
181432
  for (const [name, text3] of Object.entries(files)) {
@@ -181239,7 +181434,7 @@ function pullTools(ws, record2, files) {
181239
181434
  if (!at2 || at2[1] === "kanban" || !kept4.includes(at2[1]) || at2[2].split("/").includes("..")) continue;
181240
181435
  skills[name] = hashOf2(text3);
181241
181436
  for (const root2 of SKILL_ROOTS) {
181242
- const file3 = path38.join(ws.cwd, root2, at2[1], at2[2]);
181437
+ const file3 = path39.join(ws.cwd, root2, at2[1], at2[2]);
181243
181438
  if (held5[name] !== skills[name] || hashFile(file3) !== skills[name]) write(file3, text3);
181244
181439
  }
181245
181440
  }
@@ -181248,8 +181443,8 @@ function pullTools(ws, record2, files) {
181248
181443
  const [, skill, rest] = SKILL_PATH.exec(name) ?? [];
181249
181444
  if (!skill || !rest) continue;
181250
181445
  for (const root2 of SKILL_ROOTS) {
181251
- fs32.rmSync(path38.join(ws.cwd, root2, skill, rest), { force: true });
181252
- if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs32.rmSync(path38.join(ws.cwd, root2, skill), { recursive: true, force: true });
181446
+ fs33.rmSync(path39.join(ws.cwd, root2, skill, rest), { force: true });
181447
+ if (!Object.keys(skills).some((n) => n.startsWith(`skills/${skill}/`))) fs33.rmSync(path39.join(ws.cwd, root2, skill), { recursive: true, force: true });
181253
181448
  }
181254
181449
  }
181255
181450
  const names2 = [...new Set(Object.keys(skills).map((name) => name.split("/")[1]))];
@@ -181279,46 +181474,46 @@ async function pullStudio(ws, record2) {
181279
181474
  if (files.ok) pullTools(ws, record2, files.value);
181280
181475
  }
181281
181476
  dropPlacedAgents(ws);
181282
- for (const name of Object.keys(record2.agents ?? {})) fs32.rmSync(path38.join(ws.board, name), { force: true });
181477
+ for (const name of Object.keys(record2.agents ?? {})) fs33.rmSync(path39.join(ws.board, name), { force: true });
181283
181478
  record2.agents = {};
181284
181479
  return { ok: true, value: void 0 };
181285
181480
  }
181286
- var agentsRecord = (ws) => path38.join(ws.board, ".sync", "agents.json");
181481
+ var agentsRecord = (ws) => path39.join(ws.board, ".sync", "agents.json");
181287
181482
  function readPlaced(ws) {
181288
181483
  try {
181289
- return JSON.parse(fs32.readFileSync(agentsRecord(ws), "utf8"));
181484
+ return JSON.parse(fs33.readFileSync(agentsRecord(ws), "utf8"));
181290
181485
  } catch {
181291
181486
  return {};
181292
181487
  }
181293
181488
  }
181294
181489
  function dropPlacedAgents(ws) {
181295
181490
  const placed = readPlaced(ws);
181296
- 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 });
181297
- fs32.rmSync(agentsRecord(ws), { force: true });
181491
+ 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 });
181492
+ fs33.rmSync(agentsRecord(ws), { force: true });
181298
181493
  }
181299
181494
  function assetPath(ws, name, owner2) {
181300
181495
  if (/^[a-z][\w+.-]*:/i.test(name) || name.startsWith("#") || name.startsWith("//")) return null;
181301
- if (path38.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
181496
+ if (path39.isAbsolute(name)) throw new Error(`absolute path: ${name}`);
181302
181497
  const held5 = /^\.assets\//.exec(name);
181303
181498
  const state = stateDir(ws);
181304
- const root2 = held5 && state ? path38.join(state, "assets") : ws.board;
181305
- const file3 = held5 && state ? path38.resolve(root2, name.slice(held5[0].length)) : path38.resolve(path38.dirname(owner2), name);
181306
- const roots = [ws.board, ...state ? ["assets"].map((folder2) => path38.join(state, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181307
- const inside2 = (file4, root3) => file4.startsWith(root3 + path38.sep);
181499
+ const root2 = held5 && state ? path39.join(state, "assets") : ws.board;
181500
+ const file3 = held5 && state ? path39.resolve(root2, name.slice(held5[0].length)) : path39.resolve(path39.dirname(owner2), name);
181501
+ const roots = [ws.board, ...state ? ["assets"].map((folder2) => path39.join(state, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181502
+ const inside2 = (file4, root3) => file4.startsWith(root3 + path39.sep);
181308
181503
  if (!roots.some((root3) => inside2(file3, root3))) throw new Error(`outside the board: ${name}`);
181309
181504
  let existing = file3;
181310
- while (!fs32.existsSync(existing) && path38.dirname(existing) !== existing) existing = path38.dirname(existing);
181311
- const real = path38.join(fs32.realpathSync(existing), path38.relative(existing, file3));
181505
+ while (!fs33.existsSync(existing) && path39.dirname(existing) !== existing) existing = path39.dirname(existing);
181506
+ const real = path39.join(fs33.realpathSync(existing), path39.relative(existing, file3));
181312
181507
  let stateParent = state;
181313
- while (stateParent && !fs32.existsSync(stateParent) && path38.dirname(stateParent) !== stateParent) stateParent = path38.dirname(stateParent);
181314
- const realState = state && stateParent ? path38.resolve(fs32.realpathSync(stateParent), path38.relative(stateParent, state)) : null;
181315
- const realRoots = [fs32.realpathSync(ws.board), ...realState ? ["assets"].map((folder2) => path38.join(realState, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181508
+ while (stateParent && !fs33.existsSync(stateParent) && path39.dirname(stateParent) !== stateParent) stateParent = path39.dirname(stateParent);
181509
+ const realState = state && stateParent ? path39.resolve(fs33.realpathSync(stateParent), path39.relative(stateParent, state)) : null;
181510
+ const realRoots = [fs33.realpathSync(ws.board), ...realState ? ["assets"].map((folder2) => path39.join(realState, folder2, ...ws.number ? [String(ws.number)] : [])) : []];
181316
181511
  if (!realRoots.some((root3) => real === root3 || inside2(real, root3))) throw new Error(`link outside the board: ${name}`);
181317
181512
  return file3;
181318
181513
  }
181319
181514
  function cardAssetsDir(ws, id2) {
181320
181515
  const state = stateDir(ws);
181321
- return state && path38.join(state, "assets", String(id2));
181516
+ return state && path39.join(state, "assets", String(id2));
181322
181517
  }
181323
181518
  function stateDir(ws) {
181324
181519
  try {
@@ -181389,8 +181584,8 @@ async function prepareConflictTask(ws) {
181389
181584
  const p2 = f2.path.slice(root2.length);
181390
181585
  if (!kept3(p2)) continue;
181391
181586
  if (!(missing && cards.includes(f2)) && p2 !== assetsFile(ws.task)) continue;
181392
- if (protectedPaths.has(p2) || readText(path38.join(ws.board, p2)) !== null || base.files[f2.path]) continue;
181393
- write(path38.join(ws.board, p2), f2.content);
181587
+ if (protectedPaths.has(p2) || readText(path39.join(ws.board, p2)) !== null || base.files[f2.path]) continue;
181588
+ write(path39.join(ws.board, p2), f2.content);
181394
181589
  base.files[f2.path] = { seq: f2.seq, content: f2.content };
181395
181590
  changed = true;
181396
181591
  }
@@ -181399,7 +181594,7 @@ async function prepareConflictTask(ws) {
181399
181594
  const record2 = readRecord(ws);
181400
181595
  const studio = await pullStudio(ws, record2);
181401
181596
  if (!studio.ok) return studio;
181402
- const assets = await pullAssets(ws, record2, assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))) ?? assetsListOf(ws, base)), true);
181597
+ const assets = await pullAssets(ws, record2, assetsOf(readText(path39.join(ws.board, assetsFile(ws.task))) ?? assetsListOf(ws, base)), true);
181403
181598
  if (!assets.ok) return assets;
181404
181599
  writeRecord(ws, record2);
181405
181600
  return { ok: true, value: void 0 };
@@ -181423,16 +181618,16 @@ function applyRestorations(ws, base, files) {
181423
181618
  if (number4 === null || !stamp3 || base.files[f2.path]?.content === f2.content) continue;
181424
181619
  const old = Object.entries(base.files).find(([name]) => name.startsWith(root2) && numberOfCard(name.slice(root2.length)) === number4);
181425
181620
  if (old && old[0] === f2.path && /^restored:\s*(.+)$/m.exec(old[1].content)?.[1] === stamp3) continue;
181426
- for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board))) {
181621
+ for (const local of ["todo", ".archive"].flatMap((dir) => filesUnder(path39.join(ws.board, dir), ws.board))) {
181427
181622
  if (numberOfCard(local) !== number4) continue;
181428
- const here = readText(path38.join(ws.board, local));
181623
+ const here = readText(path39.join(ws.board, local));
181429
181624
  if (here !== null && here !== base.files[root2 + local]?.content && here !== f2.content) {
181430
- write(path38.join(ws.board, ".sync", "restored", String(f2.seq), local), here);
181625
+ write(path39.join(ws.board, ".sync", "restored", String(f2.seq), local), here);
181431
181626
  }
181432
181627
  restored.add(local);
181433
- if (local !== p2) fs32.rmSync(path38.join(ws.board, local), { force: true });
181628
+ if (local !== p2) fs33.rmSync(path39.join(ws.board, local), { force: true });
181434
181629
  }
181435
- write(path38.join(ws.board, p2), f2.content);
181630
+ write(path39.join(ws.board, p2), f2.content);
181436
181631
  restored.add(p2);
181437
181632
  }
181438
181633
  return restored;
@@ -181445,7 +181640,7 @@ function observeConflicts(ws, base, files) {
181445
181640
  const own2 = f2.path.startsWith(root2);
181446
181641
  const p2 = own2 ? f2.path.slice(root2.length) : f2.path;
181447
181642
  if (pending.has(p2) || !kept3(p2) || (p2.startsWith(MEMORY2) && shared(p2.slice(MEMORY2.length))) !== !own2) return false;
181448
- return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path38.join(ws.board, p2)), f2.content).conflict;
181643
+ return !!mergeFile(base.files[f2.path]?.content ?? null, readText(path39.join(ws.board, p2)), f2.content).conflict;
181449
181644
  });
181450
181645
  if (!conflicting) return false;
181451
181646
  const changed = new Map(files.map((f2) => [f2.path, f2]));
@@ -181455,7 +181650,7 @@ function observeConflicts(ws, base, files) {
181455
181650
  if (pending.has(p2)) continue;
181456
181651
  const remotePath = remoteOf(ws, shared, p2);
181457
181652
  const before = base.files[remotePath]?.content ?? null;
181458
- const here = readText(path38.join(ws.board, p2));
181653
+ const here = readText(path39.join(ws.board, p2));
181459
181654
  if (here === before) continue;
181460
181655
  const there = changed.get(remotePath) ?? { content: before, seq: base.files[remotePath]?.seq ?? base.deleted?.[remotePath] ?? 0 };
181461
181656
  const merged = mergeFile(before, here, there.content);
@@ -181480,7 +181675,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
181480
181675
  const base = readBase(ws);
181481
181676
  const previous = { ...base.files };
181482
181677
  const known2 = new Set(Object.keys(base.files));
181483
- const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path38.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
181678
+ const keepDraft = new Set((base.deferred ?? []).filter((p2) => readText(path39.join(ws.board, p2)) !== (base.files[rootOf(ws) + p2]?.content ?? null)));
181484
181679
  if (base.workspace === void 0) {
181485
181680
  const project = await readProject(ws.project);
181486
181681
  if (!project.ok) return project;
@@ -181490,7 +181685,7 @@ async function readCloud(ws, preserveAssets, taskChat) {
181490
181685
  if (!read5.ok) return read5;
181491
181686
  const restored = applyRestorations(ws, base, read5.value.files);
181492
181687
  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." };
181493
- 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)));
181688
+ 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)));
181494
181689
  for (const p2 of dirty) keepDraft.add(p2);
181495
181690
  if (base.head_seq === null) base.files = {};
181496
181691
  for (const f2 of read5.value.files) {
@@ -181508,20 +181703,20 @@ async function readCloud(ws, preserveAssets, taskChat) {
181508
181703
  const removed = [...known2].filter((p2) => !base.files[p2]);
181509
181704
  for (const p2 of removed) {
181510
181705
  const local = p2.startsWith(rootOf(ws)) ? p2.slice(rootOf(ws).length) : p2;
181511
- if (local.startsWith(".archive/") && readText(path38.join(ws.board, local)) !== null && readText(path38.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
181706
+ if (local.startsWith(".archive/") && readText(path39.join(ws.board, local)) !== null && readText(path39.join(ws.board, local)) !== previous[p2]?.content) keepDraft.add(local);
181512
181707
  }
181513
181708
  if (!dirty.size) base.head_seq = read5.value.head_seq;
181514
181709
  base.project = ws.project;
181515
181710
  writeBase(ws, base);
181516
181711
  const reset = (view2) => {
181517
181712
  for (const [p2, content] of view2) {
181518
- const file3 = path38.join(ws.board, p2);
181713
+ const file3 = path39.join(ws.board, p2);
181519
181714
  if (!keepDraft.has(p2) && kept3(p2) && readText(file3) !== content) write(file3, content);
181520
181715
  }
181521
181716
  };
181522
181717
  const view = viewOf(ws, base, sharedMemory(ws.board));
181523
181718
  const first = (p2) => isSettingsPath(p2) && !known2.has(rootOf(ws) + p2);
181524
- 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 });
181719
+ 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 });
181525
181720
  reset(view);
181526
181721
  const retired = await cleanRecords(ws, base, { removed, taskChat });
181527
181722
  if (retired.has(ws.task)) {
@@ -181539,18 +181734,18 @@ async function readCloud(ws, preserveAssets, taskChat) {
181539
181734
  return { ok: true, value: void 0 };
181540
181735
  }
181541
181736
  function writeIndex(board) {
181542
- const todo = path38.join(board, "todo");
181737
+ const todo = path39.join(board, "todo");
181543
181738
  const cards = [];
181544
181739
  let entries = [];
181545
181740
  try {
181546
- entries = fs32.readdirSync(todo, { withFileTypes: true });
181741
+ entries = fs33.readdirSync(todo, { withFileTypes: true });
181547
181742
  } catch {
181548
181743
  }
181549
181744
  for (const e2 of entries) {
181550
181745
  const id2 = /^(\d+)-/.exec(e2.name)?.[1];
181551
181746
  if (!id2) continue;
181552
181747
  const link = e2.isDirectory() ? `${e2.name}/root.md` : e2.name.endsWith(".md") ? e2.name : null;
181553
- const text4 = link && readText(path38.join(todo, link));
181748
+ const text4 = link && readText(path39.join(todo, link));
181554
181749
  if (text4 === null || !link) continue;
181555
181750
  cards.push({ id: Number(id2), title: cardFront(text4).title ?? e2.name.replace(/\.md$/, ""), link });
181556
181751
  }
@@ -181565,7 +181760,7 @@ the number at the front of a filename is the task id.
181565
181760
 
181566
181761
  ${list3}
181567
181762
  `;
181568
- if (readText(path38.join(todo, "README.md")) !== text3) write(path38.join(todo, "README.md"), text3);
181763
+ if (readText(path39.join(todo, "README.md")) !== text3) write(path39.join(todo, "README.md"), text3);
181569
181764
  }
181570
181765
  var workspaceOf = (ws) => readBase(ws).workspace ?? null;
181571
181766
  async function pullAssets(ws, record2, assets, preserve = false) {
@@ -181653,7 +181848,7 @@ async function pullAssets(ws, record2, assets, preserve = false) {
181653
181848
  }
181654
181849
  if (!child) return src;
181655
181850
  dependencies.push(name2);
181656
- const back = !found.text && /^\.assets\//.test(name2) ? name2 : path38.relative(path38.dirname(target), child).split(path38.sep).join("/");
181851
+ const back = !found.text && /^\.assets\//.test(name2) ? name2 : path39.relative(path39.dirname(target), child).split(path39.sep).join("/");
181657
181852
  if (back !== src) changed = true;
181658
181853
  return back;
181659
181854
  });
@@ -181690,20 +181885,20 @@ async function readAsset(artifact, version2) {
181690
181885
  return { ok: true, value: Buffer.from(typeof content === "string" ? content : JSON.stringify(content)) };
181691
181886
  }
181692
181887
  async function sentOf(file3, kind) {
181693
- const ext = path38.extname(file3).toLowerCase();
181888
+ const ext = path39.extname(file3).toLowerCase();
181694
181889
  if (kind !== "html") {
181695
181890
  const office = officeExtension(file3);
181696
181891
  const type = office ? OFFICE_TYPES[office] : kind === "tiled" && ext === ".tsx" ? "application/xml" : TYPES[ext];
181697
- return { bytes: fs32.readFileSync(file3), type: type ?? "application/octet-stream", kind };
181892
+ return { bytes: fs33.readFileSync(file3), type: type ?? "application/octet-stream", kind };
181698
181893
  }
181699
181894
  const page = await (await Promise.resolve().then(() => (init_mockup(), mockup_exports))).drawMockup(file3);
181700
181895
  return { bytes: Buffer.from(page), type: "text/html", kind };
181701
181896
  }
181702
- var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path38.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
181897
+ var undrawnPreviews = (ws) => Object.entries(assetsOf(readText(path39.join(ws.board, assetsFile(ws.task))))).flatMap(([key, ref]) => ref.error ? [`${key}: ${ref.error}`] : []);
181703
181898
  function undrawn(ws, reason) {
181704
181899
  const state = stateDir(ws);
181705
- for (const [root2, shown] of [...state ? [[path38.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
181706
- reason = reason.split(`file://${root2}${path38.sep}`).join(shown && `${shown}/`).split(`${root2}${path38.sep}`).join(shown && `${shown}/`);
181900
+ for (const [root2, shown] of [...state ? [[path39.join(state, "assets"), ".assets"]] : [], [ws.board, ""]]) {
181901
+ reason = reason.split(`file://${root2}${path39.sep}`).join(shown && `${shown}/`).split(`${root2}${path39.sep}`).join(shown && `${shown}/`);
181707
181902
  }
181708
181903
  return reason.replace(/ \(at [^)]*file:\/\/[^)]*\)$/, "").slice(0, 500);
181709
181904
  }
@@ -181779,14 +181974,14 @@ async function pushAssets(ws, record2, before) {
181779
181974
  if (body === null) return { ok: true, value: void 0 };
181780
181975
  const refs = {};
181781
181976
  const canonical = (target) => {
181782
- const real = (file4) => fs32.existsSync(file4) ? fs32.realpathSync(file4) : path38.dirname(file4) === file4 ? file4 : path38.join(real(path38.dirname(file4)), path38.basename(file4));
181977
+ const real = (file4) => fs33.existsSync(file4) ? fs33.realpathSync(file4) : path39.dirname(file4) === file4 ? file4 : path39.join(real(path39.dirname(file4)), path39.basename(file4));
181783
181978
  target = real(target);
181784
181979
  const state = stateDir(ws);
181785
181980
  for (const folder2 of ["assets"]) {
181786
- const root2 = state && real(path38.join(state, folder2));
181787
- if (root2 && target.startsWith(root2 + path38.sep)) return `.${folder2}/${path38.relative(root2, target).split(path38.sep).join("/")}`;
181981
+ const root2 = state && real(path39.join(state, folder2));
181982
+ if (root2 && target.startsWith(root2 + path39.sep)) return `.${folder2}/${path39.relative(root2, target).split(path39.sep).join("/")}`;
181788
181983
  }
181789
- return path38.relative(real(path38.dirname(file3)), target).split(path38.sep).join("/");
181984
+ return path39.relative(real(path39.dirname(file3)), target).split(path39.sep).join("/");
181790
181985
  };
181791
181986
  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])));
181792
181987
  try {
@@ -181798,11 +181993,11 @@ async function pushAssets(ws, record2, before) {
181798
181993
  const target = assetPath(ws, src, owner2);
181799
181994
  if (!target) return null;
181800
181995
  const key = owner2 === file3 && before[src] ? src : canonical(target);
181801
- if (!fs32.statSync(target, { throwIfNoEntry: false })?.isFile()) {
181996
+ if (!fs33.statSync(target, { throwIfNoEntry: false })?.isFile()) {
181802
181997
  if (before[key]) return { key, file: null };
181803
181998
  throw new Error(`file not found: ${target}`);
181804
181999
  }
181805
- return { key: canonical(fs32.realpathSync(target)), file: target };
182000
+ return { key: canonical(fs33.realpathSync(target)), file: target };
181806
182001
  },
181807
182002
  read: referenceText,
181808
182003
  retained: (key, types) => {
@@ -181826,7 +182021,7 @@ async function pushAssets(ws, record2, before) {
181826
182021
  let why2 = node2.error ?? (partialStudio ? void 0 : [...node2.dependencies.values()].map((key) => refs[key]?.error).find(Boolean));
181827
182022
  if (!why2 && node2.file) {
181828
182023
  try {
181829
- if (fs32.statSync(node2.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
182024
+ if (fs33.statSync(node2.file).size > ASSET_FILE_LIMIT) throw new Error("This asset is over 100 MiB.");
181830
182025
  out = await sentOf(node2.file, kind);
181831
182026
  } catch (error62) {
181832
182027
  why2 = renderError(error62);
@@ -181836,7 +182031,7 @@ async function pushAssets(ws, record2, before) {
181836
182031
  if (why2) {
181837
182032
  const key = [...node2.aliases].find((alias) => required2.has(alias));
181838
182033
  if (key) {
181839
- const error62 = `${path38.relative(ws.board, file3)}:${required2.get(key)} \u2014 ${key}: ${undrawn(ws, why2)}`;
182034
+ const error62 = `${path39.relative(ws.board, file3)}:${required2.get(key)} \u2014 ${key}: ${undrawn(ws, why2)}`;
181840
182035
  return { ok: false, code: "bad_request", error: error62, failure: validationFailure(error62, "preview_attachment") };
181841
182036
  }
181842
182037
  let pin = old ? { ...old } : previous?.version ? { artifact: previous.artifact, version: previous.version, ...previous.dependencies ? { dependencies: previous.dependencies } : {} } : null;
@@ -181892,7 +182087,7 @@ async function pushAssets(ws, record2, before) {
181892
182087
  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);
181893
182088
  if (!entry || !unchanged && entry.hash !== hash2 || entry.kind && entry.kind !== out.kind) {
181894
182089
  if (!ws.cloudTask) continue;
181895
- let artifact = previous && (previous.kind ?? kindOf(path38.extname(node2.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
182090
+ let artifact = previous && (previous.kind ?? kindOf(path39.extname(node2.file).toLowerCase())) === out.kind ? previous.artifact : void 0;
181896
182091
  if (!artifact) {
181897
182092
  const made = await createArtifact(ws.cloudTask, node2.key.slice(0, 200), out.kind, artifactKey(ws.cloudTask, node2.key, out.kind, previous?.artifact));
181898
182093
  if (!made.ok) return { ...made, error: `${node2.key}: ${made.error}` };
@@ -181949,8 +182144,8 @@ function proposeItems(ws, base, paths) {
181949
182144
  const root2 = rootOf(ws);
181950
182145
  for (const p2 of paths ?? localFiles(ws, base)) {
181951
182146
  if (itemAt(p2)?.state !== "open" || base.files[root2 + p2]) continue;
181952
- const file3 = path38.join(ws.board, p2);
181953
- const content = fs32.readFileSync(file3, "utf8");
182147
+ const file3 = path39.join(ws.board, p2);
182148
+ const content = fs33.readFileSync(file3, "utf8");
181954
182149
  const said = (key) => new RegExp(`^${key}:`, "m").test(content.split(/\n---/)[0] ?? "");
181955
182150
  const fields2 = {
181956
182151
  ...ws.cloudTask && !said("source_task") ? { source_task: ws.cloudTask } : {},
@@ -181982,7 +182177,7 @@ var push = (ws, job, stopped2) => inFolder(ws.cwd, async () => {
181982
182177
  if (busy(preparationKey(ws))) return { ok: false, conflict: false, offline: true, error: "Task content is still being prepared." };
181983
182178
  return sendMarked(ws, job);
181984
182179
  });
181985
- var preparationKey = (ws) => path38.join(projectStateDir(ws.board), "preparing");
182180
+ var preparationKey = (ws) => path39.join(projectStateDir(ws.board), "preparing");
181986
182181
  async function whenPrepared(ws, cancelled, work, stopped2 = () => false) {
181987
182182
  while (!stopped2()) {
181988
182183
  const result = await inFolder(ws.cwd, async () => {
@@ -182027,22 +182222,22 @@ async function sendBoard(ws, machineId, scope) {
182027
182222
  async function sendMarked(ws, job, scope = {}) {
182028
182223
  const pushed = pendingConflicts(ws.board).length ? conflictFailure(ws) : await send2(ws, job, scope);
182029
182224
  const base = readBase(ws);
182030
- markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length);
182225
+ markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length);
182031
182226
  return pushed;
182032
182227
  }
182033
182228
  var boardIdentity = (ws) => {
182034
- const stat2 = fs32.statSync(ws.board);
182229
+ const stat2 = fs33.statSync(ws.board);
182035
182230
  return `${stat2.dev}:${stat2.ino}:${stat2.birthtimeMs}`;
182036
182231
  };
182037
182232
  function rememberDirectories(directories, file3) {
182038
- for (let dir = path38.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path38.posix.dirname(dir)) directories.add(dir);
182233
+ for (let dir = path39.posix.dirname(file3); dir !== "." && dir !== "/"; dir = path39.posix.dirname(dir)) directories.add(dir);
182039
182234
  }
182040
182235
  function newIndex(ws) {
182041
182236
  const directories = /* @__PURE__ */ new Set();
182042
182237
  for (const p2 of Object.keys(readBase(ws).files)) {
182043
182238
  if (p2.startsWith(rootOf(ws))) rememberDirectories(directories, p2.slice(rootOf(ws).length));
182044
182239
  }
182045
- return { identity: boardIdentity(ws), directories, ready: false, retiring: /* @__PURE__ */ new Set(), tasks: /* @__PURE__ */ new Map(), files: /* @__PURE__ */ new Map() };
182240
+ return { identity: boardIdentity(ws), directories, ready: false, archivesReady: false, retiring: /* @__PURE__ */ new Set(), tasks: /* @__PURE__ */ new Map(), files: /* @__PURE__ */ new Map() };
182046
182241
  }
182047
182242
  var taskIndexes = /* @__PURE__ */ new Map();
182048
182243
  function syncIndex(ws) {
@@ -182064,7 +182259,7 @@ function forgetTask(index, task) {
182064
182259
  }
182065
182260
  function indexTask(ws, record2, card = cardFile(ws)) {
182066
182261
  if (!ws.cloudTask || !ws.number) return;
182067
- const paths = /* @__PURE__ */ new Set([card, path38.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
182262
+ const paths = /* @__PURE__ */ new Set([card, path39.join(ws.board, assetsFile(ws.task)), recordFile(ws)]);
182068
182263
  for (const name of Object.keys(record2.assets)) {
182069
182264
  try {
182070
182265
  const file3 = assetPath(ws, name, card);
@@ -182073,7 +182268,7 @@ function indexTask(ws, record2, card = cardFile(ws)) {
182073
182268
  }
182074
182269
  }
182075
182270
  for (const file3 of [...paths]) {
182076
- for (let dir = path38.dirname(file3); dir.startsWith(ws.cwd + path38.sep); dir = path38.dirname(dir)) paths.add(dir);
182271
+ for (let dir = path39.dirname(file3); dir.startsWith(ws.cwd + path39.sep); dir = path39.dirname(dir)) paths.add(dir);
182077
182272
  }
182078
182273
  const index = syncIndex(ws) ?? newIndex(ws);
182079
182274
  for (const file3 of index.tasks.get(ws.task)?.paths ?? []) {
@@ -182093,7 +182288,7 @@ function affectedTasks(ws, paths) {
182093
182288
  const index = syncIndex(ws);
182094
182289
  const tasks = new Set(index?.retiring);
182095
182290
  for (const p2 of paths) {
182096
- for (const task2 of index?.files.get(path38.resolve(ws.board, p2)) ?? []) tasks.add(task2);
182291
+ for (const task2 of index?.files.get(path39.resolve(ws.board, p2)) ?? []) tasks.add(task2);
182097
182292
  const task = /^\.sync\/([\w-]+)\.json$/.exec(p2)?.[1];
182098
182293
  if (task) tasks.add(task);
182099
182294
  }
@@ -182103,20 +182298,23 @@ async function send2(ws, job, { paths, taskChat }) {
182103
182298
  const record2 = readRecord(ws);
182104
182299
  const base = readBase(ws);
182105
182300
  const fail = (error62, conflict = false, code, status) => ({ ok: false, conflict, error: error62, code, ...temporaryCloudFailure({ code, status }) ? { offline: true } : {} });
182106
- if (!syncIndex(ws)?.ready) paths = void 0;
182301
+ const boardSync = !job.id && !ws.cloudTask;
182302
+ const discoverArchives = boardSync && !syncIndex(ws)?.archivesReady;
182303
+ if (!syncIndex(ws)?.ready || discoverArchives) paths = void 0;
182107
182304
  const selected = paths && /* @__PURE__ */ new Set([...paths, ...base.pendingPreviews ?? []]);
182108
- const names2 = selected ? new Set(base.pendingAssets ?? []) : null;
182305
+ const pendingArchives = new Map(Object.entries(base.pendingArchives ?? {}));
182306
+ const names2 = selected ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...boardSync ? pendingArchives.keys() : []]) : null;
182109
182307
  if (selected) for (const task of affectedTasks(ws, selected)) names2.add(task);
182110
182308
  const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
182111
182309
  if (retired.has(ws.task)) record2.deleted = true;
182112
182310
  const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
182113
- ...filesUnder(path38.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
182311
+ ...filesUnder(path39.join(ws.board, ".sync")).filter((name) => name.endsWith(".json")),
182114
182312
  ...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
182115
182313
  ])];
182116
182314
  const tasks = ws.cloudTask ? [{ folder: ws, record: record2 }] : records.flatMap((name) => {
182117
182315
  let held5;
182118
182316
  try {
182119
- held5 = JSON.parse(fs32.readFileSync(path38.join(ws.board, ".sync", name), "utf8"));
182317
+ held5 = JSON.parse(fs33.readFileSync(path39.join(ws.board, ".sync", name), "utf8"));
182120
182318
  } catch {
182121
182319
  const known2 = syncIndex(ws)?.tasks.get(name.replace(/\.json$/, ""));
182122
182320
  if (!known2) return [];
@@ -182128,7 +182326,8 @@ async function send2(ws, job, { paths, taskChat }) {
182128
182326
  return [{ folder: { ...ws, task: held5.task, cloudTask: held5.task, number: held5.number }, record: held5 }];
182129
182327
  });
182130
182328
  if (!syncIndex(ws)) taskIndexes.set(ws.cwd, newIndex(ws));
182131
- const boardSync = !job.id && !ws.cloudTask;
182329
+ const archives = /* @__PURE__ */ new Map();
182330
+ const retryAssets = new Set(base.pendingAssets);
182132
182331
  const deferredCards = /* @__PURE__ */ new Set();
182133
182332
  const deferredLists = /* @__PURE__ */ new Set();
182134
182333
  const assetErrors = {};
@@ -182136,7 +182335,7 @@ async function send2(ws, job, { paths, taskChat }) {
182136
182335
  const assetLists = /* @__PURE__ */ new Map();
182137
182336
  const generatedAssets = /* @__PURE__ */ new Set();
182138
182337
  const cards = !selected && !ws.cloudTask ? new Map(
182139
- [".archive", "todo"].flatMap((dir) => filesUnder(path38.join(ws.board, dir), ws.board)).flatMap((p2) => {
182338
+ [".archive", "todo"].flatMap((dir) => filesUnder(path39.join(ws.board, dir), ws.board)).flatMap((p2) => {
182140
182339
  const number4 = numberOfCard(p2);
182141
182340
  return number4 ? [[number4, p2]] : [];
182142
182341
  })
@@ -182144,8 +182343,8 @@ async function send2(ws, job, { paths, taskChat }) {
182144
182343
  for (const item of tasks) {
182145
182344
  processed.add(item.folder.task);
182146
182345
  if (processed.size === 1 || processed.size % 25 === 0) logSync("board.progress", { project: ws.project, processed: processed.size, total: tasks.length });
182147
- const card = cards?.get(item.folder.number) ?? path38.relative(ws.board, cardFile(item.folder)).split(path38.sep).join("/");
182148
- indexTask(item.folder, item.record, path38.join(ws.board, card));
182346
+ const card = cards?.get(item.folder.number) ?? path39.relative(ws.board, cardFile(item.folder)).split(path39.sep).join("/");
182347
+ indexTask(item.folder, item.record, path39.join(ws.board, card));
182149
182348
  selected?.add(card);
182150
182349
  const before = assetsOf(assetsListOf(item.folder, base));
182151
182350
  const newer = Object.entries(before).some(([name, ref]) => {
@@ -182154,25 +182353,28 @@ async function send2(ws, job, { paths, taskChat }) {
182154
182353
  });
182155
182354
  const clean = () => Object.entries(item.record.assets).every(([name, entry]) => {
182156
182355
  try {
182157
- const file3 = assetPath(item.folder, name, path38.join(ws.board, card));
182356
+ const file3 = assetPath(item.folder, name, path39.join(ws.board, card));
182158
182357
  return !file3 || hashFile(file3) === (entry.localHash ?? entry.hash);
182159
182358
  } catch {
182160
182359
  return false;
182161
182360
  }
182162
182361
  });
182163
- const archived = !selected && boardSync && card.startsWith(".archive/") && readText(path38.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
182362
+ const archive = boardSync && card.startsWith(".archive/") && !item.record.deleted;
182363
+ const listPath = assetsFile(item.folder.task);
182364
+ 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();
182164
182365
  if (!archived && !item.record.deleted) {
182165
182366
  const refreshed = newer && clean() ? await pullAssets(item.folder, item.record, before, true) : { ok: true, value: void 0 };
182166
182367
  const assets = refreshed.ok ? await pushAssets(item.folder, item.record, before) : refreshed;
182167
182368
  if (assets.ok) {
182168
182369
  writeRecord(item.folder, item.record);
182169
182370
  indexTask(item.folder, item.record);
182170
- const list3 = assetsFile(item.folder.task);
182171
- const local2 = readText(path38.join(ws.board, list3));
182371
+ if (archive) archives.set(item.folder.task, card);
182372
+ const list3 = listPath;
182373
+ const local2 = readText(path39.join(ws.board, list3));
182172
182374
  if (assets.value && (local2 !== null || Object.keys(assets.value).length)) {
182173
182375
  const content = isDeepStrictEqual(assetsOf(local2), assets.value) && local2 !== null ? local2 : assetsText(assets.value);
182174
182376
  assetLists.set(list3, { local: local2, content });
182175
- for (const file3 of assetFiles(item.folder, content, path38.join(ws.board, card))) generatedAssets.add(file3);
182377
+ for (const file3 of assetFiles(item.folder, content, path39.join(ws.board, card))) generatedAssets.add(file3);
182176
182378
  }
182177
182379
  selected?.add(list3);
182178
182380
  continue;
@@ -182183,15 +182385,16 @@ async function send2(ws, job, { paths, taskChat }) {
182183
182385
  assetErrors[item.folder.task] = { error: assets.error, failure: assets.failure, code: assets.code, ...temporaryCloudFailure(assets) ? { offline: true } : {} };
182184
182386
  }
182185
182387
  }
182388
+ if (archived) archives.set(item.folder.task, card);
182186
182389
  deferredCards.add(item.folder.number);
182187
- deferredLists.add(assetsFile(item.folder.task));
182390
+ deferredLists.add(listPath);
182188
182391
  }
182189
182392
  if (!ws.cloudTask) syncIndex(ws).ready = true;
182190
182393
  const scoped = selected && [...new Set([...selected].flatMap((p2) => {
182191
- if (!isBoardPath(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182192
- const file3 = path38.join(ws.board, p2);
182193
- return fs32.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
182194
- }))].filter((p2) => fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
182394
+ if (!isBoardPath(p2) && !fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182395
+ const file3 = path39.join(ws.board, p2);
182396
+ return fs33.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
182397
+ }))].filter((p2) => fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
182195
182398
  for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
182196
182399
  proposeItems(ws, base, scoped);
182197
182400
  const shared = sharedMemory(ws.board);
@@ -182211,7 +182414,7 @@ async function send2(ws, job, { paths, taskChat }) {
182211
182414
  const previews = [];
182212
182415
  const heldPreviews = /* @__PURE__ */ new Set();
182213
182416
  const oversize = /* @__PURE__ */ new Set();
182214
- const success2 = (changed) => {
182417
+ const success2 = async (changed) => {
182215
182418
  const refreshDeferred = deferred.size !== (base.deferred?.length ?? 0) || base.deferred?.some((p2) => !deferred.has(p2));
182216
182419
  const pendingAssets = [.../* @__PURE__ */ new Set([...(base.pendingAssets ?? []).filter((task) => !processed.has(task)), ...Object.keys(assetErrors)])];
182217
182420
  const refreshPending = JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
@@ -182221,6 +182424,18 @@ async function send2(ws, job, { paths, taskChat }) {
182221
182424
  const refreshPreviews = !isDeepStrictEqual(pendingPreviews, base.pendingPreviews ?? []);
182222
182425
  if (refreshPreviews) base.pendingPreviews = pendingPreviews;
182223
182426
  if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
182427
+ if (boardSync) {
182428
+ for (const task of processed) {
182429
+ const card = archives.get(task);
182430
+ if (card && !heldPreviews.has(card) && (discoverArchives || selected || pendingArchives.has(task) || changedArchives.has(card) || changedArchives.has(assetsFile(task)))) {
182431
+ pendingArchives.set(task, card);
182432
+ } else if (!assetErrors[task] && !heldPreviews.has(card ?? pendingArchives.get(task) ?? "")) {
182433
+ pendingArchives.delete(task);
182434
+ }
182435
+ }
182436
+ await reconcileArchives(ws, base, pendingArchives, heldPreviews, job.machineId);
182437
+ syncIndex(ws).archivesReady = true;
182438
+ }
182224
182439
  const reported = !ws.number ? previews : previews.filter((p2) => numberOfCard(p2.file) === ws.number);
182225
182440
  const firstError = Object.values(assetErrors)[0];
182226
182441
  if (reported.length) {
@@ -182234,19 +182449,20 @@ async function send2(ws, job, { paths, taskChat }) {
182234
182449
  const localOf = /* @__PURE__ */ new Map();
182235
182450
  const localBefore = /* @__PURE__ */ new Map();
182236
182451
  const changes = [];
182452
+ const changedArchives = /* @__PURE__ */ new Set();
182237
182453
  const owed = (p2) => !job.id && busy(ws.cwd) && itemAt(p2)?.state === "open" && !base.files[rootOf(ws) + p2];
182238
182454
  for (const p2 of local) {
182239
182455
  if (defer(p2) || owed(p2) || generatedAssets.has(p2)) continue;
182240
182456
  if (selected && tasks.some((item) => assetFiles(item.folder, assetsListOf(item.folder, base)).has(p2))) continue;
182241
182457
  const list3 = assetLists.get(p2);
182242
- const original = list3?.content ?? fs32.readFileSync(path38.join(ws.board, p2), "utf8");
182458
+ const original = list3?.content ?? fs33.readFileSync(path39.join(ws.board, p2), "utf8");
182243
182459
  const remote2 = remoteOf(ws, shared, p2);
182244
182460
  const held5 = base.files[remote2];
182245
182461
  const content = migratedArchive(p2, original, held5?.content);
182246
- if (content !== original && readText(path38.join(ws.board, p2)) === original) {
182247
- const backup = path38.join(ws.board, ".sync", "legacy-previews", hashOf2(Buffer.from(original)), p2);
182462
+ if (content !== original && readText(path39.join(ws.board, p2)) === original) {
182463
+ const backup = path39.join(ws.board, ".sync", "legacy-previews", hashOf2(Buffer.from(original)), p2);
182248
182464
  write(backup, original);
182249
- write(path38.join(ws.board, p2), content);
182465
+ write(path39.join(ws.board, p2), content);
182250
182466
  }
182251
182467
  localOf.set(remote2, p2);
182252
182468
  localBefore.set(remote2, list3 ? list3.local : content);
@@ -182264,7 +182480,7 @@ async function send2(ws, job, { paths, taskChat }) {
182264
182480
  }
182265
182481
  const previous = selected ? new Set([...selected].flatMap((p2) => {
182266
182482
  if (base.files[remoteOf(ws, shared, p2)]) return [p2];
182267
- if (!syncIndex(ws)?.directories.has(p2) && !fs32.statSync(path38.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182483
+ if (!syncIndex(ws)?.directories.has(p2) && !fs33.statSync(path39.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
182268
182484
  return [...viewOf(ws, base, shared).keys()].filter((file3) => file3.startsWith(p2 + "/"));
182269
182485
  })) : viewOf(ws, base, shared).keys();
182270
182486
  for (const p2 of previous) {
@@ -182345,7 +182561,7 @@ async function send2(ws, job, { paths, taskChat }) {
182345
182561
  return conflictFailure(ws);
182346
182562
  }
182347
182563
  for (const [i, f2] of facts.entries()) changes[i] = { path: f2.remotePath, content: f2.automatic.content, base_seq: f2.remote.seq };
182348
- 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");
182564
+ 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");
182349
182565
  sent = await commit();
182350
182566
  if (sent === null) return success2(false);
182351
182567
  if (!sent.ok && sent.files) {
@@ -182375,13 +182591,60 @@ async function send2(ws, job, { paths, taskChat }) {
182375
182591
  delete base.deleted[c2.path];
182376
182592
  }
182377
182593
  const p2 = localOf.get(c2.path);
182378
- if (p2 && readText(path38.join(ws.board, p2)) === localBefore.get(c2.path)) {
182379
- if (c2.content === null) fs32.rmSync(path38.join(ws.board, p2), { force: true });
182380
- else write(path38.join(ws.board, p2), c2.content);
182594
+ if (p2 && boardSync && (p2.startsWith(".archive/") || taskOfAssets(p2))) changedArchives.add(p2);
182595
+ if (p2 && readText(path39.join(ws.board, p2)) === localBefore.get(c2.path)) {
182596
+ if (c2.content === null) fs33.rmSync(path39.join(ws.board, p2), { force: true });
182597
+ else write(path39.join(ws.board, p2), c2.content);
182381
182598
  }
182382
182599
  }
182383
182600
  return success2(true);
182384
182601
  }
182602
+ async function reconcileArchives(ws, base, pending, held5, machine) {
182603
+ const root2 = rootOf(ws);
182604
+ const cards = [];
182605
+ const content = /* @__PURE__ */ new Map();
182606
+ for (const [task, p2] of pending) {
182607
+ const list3 = assetsFile(task);
182608
+ if (held5.has(p2) || held5.has(list3) || base.pendingAssets?.includes(task)) continue;
182609
+ const archive = base.files[root2 + p2];
182610
+ const local = readText(path39.join(ws.board, p2));
182611
+ const meta3 = local === null ? null : parseFrontmatter(local).meta;
182612
+ if (!meta3?.archived || meta3.rejected) {
182613
+ pending.delete(task);
182614
+ continue;
182615
+ }
182616
+ const manifest = base.files[root2 + list3];
182617
+ if (!archive || archive.content !== local || readText(path39.join(ws.board, list3)) !== (manifest?.content ?? null)) continue;
182618
+ cards.push({ task, path: p2, seq: archive.seq, assets_seq: manifest?.seq ?? 0 });
182619
+ if (!meta3.studio || meta3.studio === "coding") content.set(task, archive.content);
182620
+ }
182621
+ const save3 = () => {
182622
+ const next = Object.fromEntries(pending);
182623
+ if (isDeepStrictEqual(next, base.pendingArchives ?? {})) return;
182624
+ base.pendingArchives = next;
182625
+ writeBase(ws, base);
182626
+ };
182627
+ save3();
182628
+ const receipts = archivedDeliveries(ws.board, new Set(cards.filter((c2) => content.has(c2.task)).map((c2) => numberOfCard(c2.path))), machine);
182629
+ for (let i = 0; i < cards.length; i += ARCHIVE_COMPLETION_BATCH) {
182630
+ const batch2 = cards.slice(i, i + ARCHIVE_COMPLETION_BATCH);
182631
+ for (const card of batch2) {
182632
+ const body = content.get(card.task);
182633
+ if (!body) continue;
182634
+ const delivery = archiveReceipt(receipts.get(numberOfCard(card.path)), card.path, body, ws.cwd);
182635
+ if (delivery) card.delivery = delivery;
182636
+ }
182637
+ const result = await completeArchives(ws.project, machine, batch2);
182638
+ if (!result.ok) {
182639
+ logSync("board.archive_completion", { project: ws.project, code: result.code, pending: pending.size });
182640
+ break;
182641
+ }
182642
+ if (!Array.isArray(result.value.retry)) break;
182643
+ const retry2 = new Set(result.value.retry);
182644
+ for (const card of batch2) if (!retry2.has(card.task)) pending.delete(card.task);
182645
+ save3();
182646
+ }
182647
+ }
182385
182648
  function taskStudioContext(ws, docs = true) {
182386
182649
  if (!ws.cloudTask) return "";
182387
182650
  const pin = readPin(ws.cloudTask), held5 = pin && readVersion2(pin.studio, pin.version);
@@ -182389,7 +182652,7 @@ function taskStudioContext(ws, docs = true) {
182389
182652
  const read5 = parseStudioFile(studioName(held5.id), held5.files["STUDIO.md"] ?? "", "STUDIO.md");
182390
182653
  if ("problem" in read5) throw new Error(read5.problem);
182391
182654
  const def = read5.def;
182392
- const notes = readText(path38.join(ws.board, studioRuleFile(held5.id)))?.trim();
182655
+ const notes = readText(path39.join(ws.board, studioRuleFile(held5.id)))?.trim();
182393
182656
  return [
182394
182657
  "<studio>",
182395
182658
  def.rules,
@@ -182408,8 +182671,8 @@ ${notes}
182408
182671
  }
182409
182672
 
182410
182673
  // src/saved-previews.ts
182411
- import fs33 from "node:fs";
182412
- import path39 from "node:path";
182674
+ import fs34 from "node:fs";
182675
+ import path40 from "node:path";
182413
182676
 
182414
182677
  // src/sync-retry.ts
182415
182678
  var SYNC_RETRY_MAX_MS = 5 * 6e4;
@@ -182419,25 +182682,29 @@ function syncRefusal(job, failure2) {
182419
182682
  const zh = cloudLanguage(job) === "zh";
182420
182683
  switch (failure2.code) {
182421
182684
  case "unauthenticated":
182422
- return zh ? "\u8BF7\u5728\u8FD0\u884C\u7535\u8111\u4E0A\u91CD\u65B0\u767B\u5F55 WildCrane\uFF0C\u518D\u7EED\u8DD1\u3002" : "Sign in to WildCrane on the Runner computer, then resume.";
182685
+ return zh ? "\u8BF7\u5728\u8FD0\u884C\u7535\u8111\u4E0A\u91CD\u65B0\u767B\u5F55 WildCrane\uFF0C\u3002" : "Sign in to WildCrane on the Runner computer.";
182423
182686
  case "machine_offline":
182424
- return zh ? "\u8BF7\u8FDE\u63A5\u8FD0\u884C\u7535\u8111\uFF0C\u518D\u7EED\u8DD1\u3002" : "Connect the Runner computer, then resume.";
182687
+ return zh ? "\u8BF7\u8FDE\u63A5\u8FD0\u884C\u7535\u8111\uFF0C\u3002" : "Connect the Runner computer.";
182425
182688
  case "quota_exceeded":
182426
- return /takes files up to/i.test(failure2.error) ? zh ? "\u8BF7\u7F29\u5C0F\u8D85\u51FA\u989D\u5EA6\u7684\u9644\u4EF6\uFF0C\u518D\u7EED\u8DD1\u3002" : "Reduce the size of the attachment, then resume." : zh ? "\u8BF7\u91CA\u653E\u9644\u4EF6\u7A7A\u95F4\u6216\u5347\u7EA7\u989D\u5EA6\uFF0C\u518D\u7EED\u8DD1\u3002" : "Free up attachment storage or upgrade your plan, then resume.";
182689
+ return /takes files up to/i.test(failure2.error) ? zh ? "\u8BF7\u7F29\u5C0F\u8D85\u51FA\u989D\u5EA6\u7684\u9644\u4EF6\uFF0C\u3002" : "Reduce the size of the attachment." : zh ? "\u8BF7\u91CA\u653E\u9644\u4EF6\u7A7A\u95F4\u6216\u5347\u7EA7\u989D\u5EA6\uFF0C\u3002" : "Free up attachment storage or upgrade your plan.";
182427
182690
  case "storage_limit_reached":
182428
- return zh ? "\u8BF7\u91CA\u653E Cloud \u5B58\u50A8\u7A7A\u95F4\uFF0C\u518D\u7EED\u8DD1\u3002" : "Free up Cloud storage, then resume.";
182691
+ return zh ? "\u8BF7\u91CA\u653E Cloud \u5B58\u50A8\u7A7A\u95F4\uFF0C\u3002" : "Free up Cloud storage.";
182429
182692
  case "daily_write_budget_reached":
182430
- return zh ? "\u8BF7\u5728\u6BCF\u65E5\u5199\u5165\u989D\u5EA6\u4E8E UTC \u96F6\u70B9\u6062\u590D\u540E\u7EED\u8DD1\u3002" : "Resume after the daily write allowance resets at midnight UTC.";
182693
+ return zh ? "\u6BCF\u65E5\u5199\u5165\u989D\u5EA6\u4E8E UTC \u96F6\u70B9\u6062\u590D\u3002" : "The daily write allowance resets at midnight UTC.";
182431
182694
  case "bad_request":
182432
- return failure2.failure?.level === 1 ? failure2.error : zh ? "\u8BF7\u68C0\u67E5\u5361\u7247\u5185\u5BB9\u548C\u9884\u89C8\u9644\u4EF6\uFF0C\u518D\u7EED\u8DD1\u3002" : "Check the card and its preview attachments, then resume.";
182695
+ return failure2.failure?.level === 1 ? failure2.error : zh ? "\u8BF7\u68C0\u67E5\u5361\u7247\u5185\u5BB9\u548C\u9884\u89C8\u9644\u4EF6\uFF0C\u3002" : "Check the card and its preview attachments.";
182433
182696
  case "board_content_conflict":
182434
182697
  case "version_conflict":
182435
- return zh ? "\u8BF7\u5904\u7406\u770B\u677F\u540C\u6B65\u51B2\u7A81\uFF0C\u518D\u7EED\u8DD1\u3002" : "Resolve the board sync conflict, then resume.";
182698
+ return zh ? "\u8BF7\u5904\u7406\u770B\u677F\u540C\u6B65\u51B2\u7A81\uFF0C\u3002" : "Resolve the board sync conflict.";
182436
182699
  default:
182437
- return failure2.failure?.level === 1 ? failure2.error : zh ? "\u540C\u6B65\u672A\u5B8C\u6210\u3002\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u7EED\u8DD1\u3002" : "Sync could not finish. Check the task status, then resume.";
182700
+ return failure2.failure?.level === 1 ? failure2.error : zh ? "\u540C\u6B65\u672A\u5B8C\u6210\u3002\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u6062\u590D\u3002" : "Sync could not finish. Check the task status.";
182438
182701
  }
182439
182702
  }
182440
182703
  var retryableSync = (failure2) => !failure2.failure && temporaryCloudFailure(failure2);
182704
+ function syncWaitCode(failure2) {
182705
+ if (failure2.code === "daily_write_budget_reached") return "allowance";
182706
+ if (failure2.code === "storage_limit_reached" || failure2.code === "quota_exceeded" && !/takes files up to/i.test(failure2.error)) return "storage";
182707
+ }
182441
182708
 
182442
182709
  // src/saved-previews.ts
182443
182710
  async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 = []) {
@@ -182468,10 +182735,10 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
182468
182735
  const version2 = asset2.version;
182469
182736
  const bytes2 = await readAsset(asset2.artifact, version2);
182470
182737
  if (!bytes2.ok) return { ...bytes2, error: `${source2} (saved version ${version2}): ${bytes2.error}` };
182471
- const extension = path39.posix.extname(source2).toLowerCase();
182738
+ const extension = path40.posix.extname(source2).toLowerCase();
182472
182739
  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 : "";
182473
- const file3 = path39.join(directory3, `${files.size + 1}-${asset2.artifact}-${version2}${suffix}`);
182474
- fs33.writeFileSync(file3, bytes2.value);
182740
+ const file3 = path40.join(directory3, `${files.size + 1}-${asset2.artifact}-${version2}${suffix}`);
182741
+ fs34.writeFileSync(file3, bytes2.value);
182475
182742
  savedFile = { artifact: asset2.artifact, version: version2, file: file3 };
182476
182743
  files.set(source2, savedFile);
182477
182744
  }
@@ -182481,14 +182748,14 @@ async function stageSavedPreviews(directory3, inputs, plan2, stopped2, custom2 =
182481
182748
 
182482
182749
  ${section.body}${attachments.length ? "\n\nPinned files:\n" + attachments.join("\n") : ""}`);
182483
182750
  }
182484
- const manifest = path39.join(directory3, "previews.md");
182485
- fs33.writeFileSync(manifest, sections.join("\n\n") + "\n");
182751
+ const manifest = path40.join(directory3, "previews.md");
182752
+ fs34.writeFileSync(manifest, sections.join("\n\n") + "\n");
182486
182753
  return { ok: true, value: manifest };
182487
182754
  }
182488
182755
 
182489
182756
  // src/triage.ts
182490
- import fs34 from "node:fs";
182491
- import path40 from "node:path";
182757
+ import fs35 from "node:fs";
182758
+ import path41 from "node:path";
182492
182759
 
182493
182760
  // ../cli/src/lib/signals/identity.ts
182494
182761
  import { createHash as createHash5 } from "node:crypto";
@@ -182496,8 +182763,8 @@ var DERIVED = "derived-";
182496
182763
  var derivedSourceId = (seed) => `${DERIVED}${createHash5("sha256").update(seed).digest("hex").slice(0, 16)}`;
182497
182764
 
182498
182765
  // src/triage.ts
182499
- var triageDir = (board) => path40.join(board, "triage");
182500
- var rejectedDir = (board) => path40.join(board, ".archive", REJECTIONS_TO_REVIEW);
182766
+ var triageDir = (board) => path41.join(board, "triage");
182767
+ var rejectedDir = (board) => path41.join(board, ".archive", REJECTIONS_TO_REVIEW);
182501
182768
  var stamp2 = (at2) => formatStamp(at2 ? new Date(at2) : /* @__PURE__ */ new Date());
182502
182769
  function slugOf(title) {
182503
182770
  return title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "") || "item";
@@ -182505,7 +182772,7 @@ function slugOf(title) {
182505
182772
  function freeName(dir, title) {
182506
182773
  const stem = slugOf(title);
182507
182774
  let name = `${stem}.md`;
182508
- for (let n = 2; fs34.existsSync(path40.join(dir, name)); n++) name = `${stem}-${n}.md`;
182775
+ for (let n = 2; fs35.existsSync(path41.join(dir, name)); n++) name = `${stem}-${n}.md`;
182509
182776
  return name;
182510
182777
  }
182511
182778
  function itemText(item, fields2 = {}) {
@@ -182525,16 +182792,16 @@ ${item.text.trim()}
182525
182792
  `;
182526
182793
  }
182527
182794
  function writeItem(dir, item, fields2 = {}) {
182528
- fs34.mkdirSync(dir, { recursive: true });
182795
+ fs35.mkdirSync(dir, { recursive: true });
182529
182796
  const name = freeName(dir, item.title);
182530
- fs34.writeFileSync(path40.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields2 } : fields2));
182797
+ fs35.writeFileSync(path41.join(dir, name), itemText(item, item.studio ? { studio: studioName(item.studio), ...fields2 } : fields2));
182531
182798
  return name;
182532
182799
  }
182533
182800
  function layOut(board, rejections) {
182534
182801
  const dir = rejectedDir(board);
182535
- fs34.mkdirSync(dir, { recursive: true });
182802
+ fs35.mkdirSync(dir, { recursive: true });
182536
182803
  for (const t of rejections.tasks) {
182537
- fs34.writeFileSync(path40.join(dir, `${t.number}-${slugify2(t.title)}.md`), [
182804
+ fs35.writeFileSync(path41.join(dir, `${t.number}-${slugify2(t.title)}.md`), [
182538
182805
  "---",
182539
182806
  `title: ${yamlScalar(t.title)}`,
182540
182807
  "status: todo",
@@ -182549,7 +182816,7 @@ function layOut(board, rejections) {
182549
182816
  ].join("\n"));
182550
182817
  }
182551
182818
  for (const item of rejections.triage) {
182552
- const sub = path40.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
182819
+ const sub = path41.join(triageDir(board), item.state === "dismissed" ? "dismissed" : "archived");
182553
182820
  const fields2 = item.state === "dismissed" ? { dismissed_at: stamp2(item.dismissed_at), dismissed_by: "user", ...item.dismissed_reason ? { dismissed_reason: item.dismissed_reason } : {} } : {};
182554
182821
  writeItem(sub, item, fields2);
182555
182822
  }
@@ -182558,12 +182825,12 @@ function layOut(board, rejections) {
182558
182825
 
182559
182826
  // ../cli/src/lib/skill/hook.ts
182560
182827
  import { spawnSync as spawnSync7 } from "node:child_process";
182561
- import fs35 from "node:fs";
182562
- import path41 from "node:path";
182828
+ import fs36 from "node:fs";
182829
+ import path42 from "node:path";
182563
182830
  var MARKER_LINE = /^# ai4kanban commit guard\b/m;
182564
182831
  var read3 = (file3) => {
182565
182832
  try {
182566
- return fs35.readFileSync(file3, "utf8");
182833
+ return fs36.readFileSync(file3, "utf8");
182567
182834
  } catch {
182568
182835
  return null;
182569
182836
  }
@@ -182575,15 +182842,15 @@ function hooksDir(root2) {
182575
182842
  windowsHide: true
182576
182843
  });
182577
182844
  if (out.error || out.status !== 0 || !out.stdout.trim()) return null;
182578
- return path41.resolve(root2, out.stdout.trim());
182845
+ return path42.resolve(root2, out.stdout.trim());
182579
182846
  }
182580
182847
  function installCommitHook(root2, _board) {
182581
182848
  const dir = hooksDir(root2);
182582
182849
  if (!dir) return {};
182583
- const file3 = path41.join(dir, "pre-commit");
182584
- if (fs35.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
182850
+ const file3 = path42.join(dir, "pre-commit");
182851
+ if (fs36.lstatSync(file3, { throwIfNoEntry: false })?.isSymbolicLink()) return {};
182585
182852
  const source2 = read3(file3);
182586
- if (source2 && MARKER_LINE.test(source2)) fs35.unlinkSync(file3);
182853
+ if (source2 && MARKER_LINE.test(source2)) fs36.unlinkSync(file3);
182587
182854
  return {};
182588
182855
  }
182589
182856
 
@@ -182627,7 +182894,7 @@ function runtimeCosts(runs, job) {
182627
182894
  }
182628
182895
  function reviewOf2(file3, questionsOnly = false) {
182629
182896
  try {
182630
- const meta3 = parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta;
182897
+ const meta3 = parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta;
182631
182898
  return meta3 && (!questionsOnly || meta3.questions?.length) ? reviewOf(meta3) : null;
182632
182899
  } catch {
182633
182900
  return null;
@@ -182635,15 +182902,15 @@ function reviewOf2(file3, questionsOnly = false) {
182635
182902
  }
182636
182903
  function asks(file3) {
182637
182904
  try {
182638
- return (parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
182905
+ return (parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta?.questions ?? []).length > 0;
182639
182906
  } catch {
182640
182907
  return false;
182641
182908
  }
182642
182909
  }
182643
182910
  function mcpConfig(servers, file3) {
182644
182911
  if (!Object.keys(servers).length) return null;
182645
- fs36.mkdirSync(path42.dirname(file3), { recursive: true });
182646
- fs36.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
182912
+ fs37.mkdirSync(path43.dirname(file3), { recursive: true });
182913
+ fs37.writeFileSync(file3, `${JSON.stringify({ mcpServers: servers }, null, 2)}
182647
182914
  `);
182648
182915
  return file3;
182649
182916
  }
@@ -182674,16 +182941,16 @@ async function stopRuns(akb, ws, id2, since, ms) {
182674
182941
  var working = /* @__PURE__ */ new Map();
182675
182942
  var workKey = (ws, id2) => `${ws.board}#${id2}`;
182676
182943
  function checkoutsOf(ws, id2) {
182677
- const dir = path42.join(ws.board, "deliveries");
182944
+ const dir = path43.join(ws.board, "deliveries");
182678
182945
  let names2;
182679
182946
  try {
182680
- names2 = fs36.readdirSync(dir).filter((n) => n.endsWith(".json"));
182947
+ names2 = fs37.readdirSync(dir).filter((n) => n.endsWith(".json"));
182681
182948
  } catch {
182682
182949
  return [];
182683
182950
  }
182684
182951
  return names2.flatMap((n) => {
182685
182952
  try {
182686
- const held5 = JSON.parse(fs36.readFileSync(path42.join(dir, n), "utf8"));
182953
+ const held5 = JSON.parse(fs37.readFileSync(path43.join(dir, n), "utf8"));
182687
182954
  return held5.cardId === id2 && held5.deliveryId ? [held5.deliveryId] : [];
182688
182955
  } catch {
182689
182956
  return [];
@@ -182697,7 +182964,7 @@ var RESUME_REFUSED = {
182697
182964
  deliveryRunGoing: "\u4E0A\u6B21\u7684\u8FD0\u884C\u8FD8\u6CA1\u505C\u4E0B\uFF0C\u8BF7\u7A0D\u540E\u518D\u70B9\u300C\u7EED\u8DD1\u300D\u3002",
182698
182965
  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"
182699
182966
  };
182700
- var isArchived = (ws, id2) => path42.relative(ws.board, findCard(ws.board, id2) ?? ws.board).split(path42.sep)[0] === ".archive";
182967
+ var isArchived = (ws, id2) => path43.relative(ws.board, findCard(ws.board, id2) ?? ws.board).split(path43.sep)[0] === ".archive";
182701
182968
  var refusal2 = (ran) => ran.last.replace(/^akb( raw)?: /, "").slice(0, 300) || "akb stopped with an error.";
182702
182969
  var reasonOf = (text3) => (text3 ?? "").split("\n").map((l2) => l2.trim()).filter((l2) => l2 && !/^at\s/.test(l2)).join("\n").slice(0, 300) || void 0;
182703
182970
  function logLines(show, event2) {
@@ -182747,7 +183014,8 @@ function boardAkb(job, ws, deps, io, task) {
182747
183014
  const at2 = args2.includes("--") ? args2.indexOf("--") : args2.length;
182748
183015
  const full = [...args2.slice(0, at2), "--board", ws.board, ...args2.slice(at2)];
182749
183016
  const log = show ? logLines(io.show, io.event) : void 0;
182750
- if (show) io.starting?.();
183017
+ if (show) await io.starting?.();
183018
+ if (stopping(io)) return refused("Task preparation stopped.");
182751
183019
  const ran = await runAkb(deps.akb, full, { cwd: ws.cwd, board: ws.board, task, language: cloudLanguage(job), env: { ...env2, AI4KANBAN_SYNC_DIAGNOSTIC: io.diagnostic, AI4KANBAN_REVIEW_STAGES: job.flow?.review_stages ? JSON.stringify(job.flow.review_stages) : void 0, AI4KANBAN_TASK_REVIEW: job.taskReview ? JSON.stringify(job.taskReview) : void 0, AI4KANBAN_EXECUTION: JSON.stringify({ job: job.id, machine: deps.machineId }) }, show: log?.push, track: io.track });
182752
183020
  log?.end();
182753
183021
  return ran;
@@ -182758,7 +183026,7 @@ async function setUp(job, ws, deps, io) {
182758
183026
  const runtime = job.runtime;
182759
183027
  const missing = io.flowRun?.finished ? void 0 : unavailable(runtime, await deps.runtimes());
182760
183028
  if (missing) return missing;
182761
- if (!fs36.existsSync(path42.join(ws.board, "config.md"))) {
183029
+ if (!fs37.existsSync(path43.join(ws.board, "config.md"))) {
182762
183030
  const init = await akb(["raw", "init"]);
182763
183031
  if (init.code !== 0) return refusal2(init);
182764
183032
  }
@@ -182775,7 +183043,7 @@ async function setUp(job, ws, deps, io) {
182775
183043
  const used = await akb(["raw", "agent", "use", runtime]);
182776
183044
  if (used.code !== 0) return refusal2(used);
182777
183045
  const servers = mcpServersOf(ws);
182778
- const mcpFile = path42.join(ws.board, ".sync", `${ws.task}.mcp.json`);
183046
+ const mcpFile = path43.join(ws.board, ".sync", `${ws.task}.mcp.json`);
182779
183047
  const takes = new Set(settingKeys(runtime));
182780
183048
  const given = job.settings ?? {};
182781
183049
  const values = valuesOf(runtime, job.model, given, servers, mcpFile);
@@ -182830,9 +183098,9 @@ function recoveryArgs(run3) {
182830
183098
  return run3.finished ? ["raw", "run", "log", run3.id] : ["raw", "run", "resume", run3.id, "--require-session"];
182831
183099
  }
182832
183100
  function runsSpent(runs, since, job, io) {
182833
- const source2 = job.flow?.sync_recovery_of ?? job.syncRecoveryOf ?? io.flowRun?.from;
182834
- const current2 = runs.filter((r2) => r2.cloudExecution?.job === job.id || !!source2 && r2.cloudExecution?.job === source2 || r2.sessionId === io.flowRun?.id || !r2.cloudExecution && (r2.startedAt ?? 0) >= since);
182835
- return [...new Map([...io.flowRun?.priorSpend ?? [], ...current2].map((run3) => [run3.sessionId, run3])).values()];
183101
+ const source2 = job.flow?.historical_recovery ? void 0 : job.flow?.sync_recovery_of ?? job.syncRecoveryOf ?? io.flowRun?.from;
183102
+ const current2 = runs.filter((r2) => r2.cloudExecution?.job === job.id || !!source2 && r2.cloudExecution?.job === source2 || !job.flow?.historical_recovery && r2.sessionId === io.flowRun?.id || !r2.cloudExecution && (r2.startedAt ?? 0) >= since);
183103
+ return [...new Map([...job.flow?.historical_recovery ? [] : io.flowRun?.priorSpend ?? [], ...current2].map((run3) => [run3.sessionId, run3])).values()];
182836
183104
  }
182837
183105
  async function runReview(job, ws, tasks, deps, io) {
182838
183106
  const since = Date.now();
@@ -182855,9 +183123,9 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
182855
183123
  if (!read5.value.tasks.length && !read5.value.triage.length || stopping(io)) return { runs: [] };
182856
183124
  const since = Date.now();
182857
183125
  const akb = boardAkb(job, ws, deps, io);
182858
- const directory3 = path42.join(ws.board, ".sync");
182859
- fs36.mkdirSync(directory3, { recursive: true });
182860
- const scratch = fs36.mkdtempSync(path42.join(directory3, "rejection-review-"));
183126
+ const directory3 = path43.join(ws.board, ".sync");
183127
+ fs37.mkdirSync(directory3, { recursive: true });
183128
+ const scratch = fs37.mkdtempSync(path43.join(directory3, "rejection-review-"));
182861
183129
  try {
182862
183130
  const laid = layOut(scratch, read5.value);
182863
183131
  const denied = await refreshReview?.();
@@ -182868,7 +183136,7 @@ async function reviewRejections(job, ws, deps, io, refreshReview) {
182868
183136
  if (ran.code !== 0) return { runs, failure: refusal2(ran) };
182869
183137
  return { runs, laid, session: answerOf2(ran)?.agentSession };
182870
183138
  } finally {
182871
- fs36.rmSync(scratch, { recursive: true, force: true });
183139
+ fs37.rmSync(scratch, { recursive: true, force: true });
182872
183140
  }
182873
183141
  }
182874
183142
  async function learnRejections(job, ws, deps, io, refreshReview) {
@@ -182918,19 +183186,19 @@ async function runAgent(job, ws, deps, io) {
182918
183186
  }
182919
183187
  function writeTranscript(job, dir) {
182920
183188
  if (!job.transcript) return "";
182921
- const file3 = path42.join(dir, "discussion.md");
182922
- fs36.mkdirSync(dir, { recursive: true });
182923
- fs36.writeFileSync(file3, `${job.transcript}
183189
+ const file3 = path43.join(dir, "discussion.md");
183190
+ fs37.mkdirSync(dir, { recursive: true });
183191
+ fs37.writeFileSync(file3, `${job.transcript}
182924
183192
  `);
182925
183193
  return file3;
182926
183194
  }
182927
183195
  function pictures(job, ws, id2) {
182928
183196
  const dir = cardAssetsDir(ws, id2);
182929
183197
  if (!job.attachments.length || !dir) return "";
182930
- fs36.mkdirSync(dir, { recursive: true });
183198
+ fs37.mkdirSync(dir, { recursive: true });
182931
183199
  return job.attachments.map((a2, i) => {
182932
- const file3 = `${i + 1}-${path42.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
182933
- fs36.writeFileSync(path42.join(dir, file3), Buffer.from(a2.content, "base64"));
183200
+ const file3 = `${i + 1}-${path43.basename(a2.name).replace(/[^\w.-]+/g, "-")}`;
183201
+ fs37.writeFileSync(path43.join(dir, file3), Buffer.from(a2.content, "base64"));
182934
183202
  return `
182935
183203
  <Asset src=".assets/${id2}/${file3}" label="${a2.name.replace(/["<>]/g, "") || file3}" />
182936
183204
  `;
@@ -182938,7 +183206,7 @@ function pictures(job, ws, id2) {
182938
183206
  }
182939
183207
  function cardFlags(ws, fields2) {
182940
183208
  if (!fields2) return [];
182941
- 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));
183209
+ 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));
182942
183210
  const lists = [["--modules", fields2.modules ?? []], ["--related", open2(fields2.related)], ["--blocked-by", open2(fields2.blocked_by)]];
182943
183211
  return [
182944
183212
  ...fields2.priority ? ["--priority", fields2.priority] : [],
@@ -182956,6 +183224,10 @@ async function runFlow(job, ws, deps, io) {
182956
183224
  return ran.code === 0 && answer?.id ? { ok: true, value: answer.id } : { ok: false, error: answer?.error?.message ?? refusal2(ran), code: answer?.error?.kind };
182957
183225
  };
182958
183226
  if (flow.verb === "discard") return discardBuilds();
183227
+ if (io.flowRun?.failure) {
183228
+ const failure2 = io.flowRun.failure;
183229
+ return { ok: false, reason: failure2.reason, failure: failure2, report: spentBy(runsSpent([], since, job, io), job) };
183230
+ }
182959
183231
  const hasReview = !!job.taskReview || flow.review_stages !== void 0;
182960
183232
  const initial = job.taskReview && reviewAuthorization(job.taskReview, flow.review_stages);
182961
183233
  const skipPlan = initial ? initial.kind === "unreviewed" : flow.skip_plan;
@@ -182988,7 +183260,7 @@ async function runFlow(job, ws, deps, io) {
182988
183260
  const startsDelivery = ["delivery resume", "run resume", "card implement"].includes(args2.slice(1, 3).join(" "));
182989
183261
  if (review && task?.preview_inputs && verb === "implement" && startsDelivery) {
182990
183262
  const inputs = task.preview_inputs;
182991
- previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-saved-previews-"));
183263
+ previewDirectory ??= fs37.mkdtempSync(path43.join(os6.tmpdir(), "wildcrane-saved-previews-"));
182992
183264
  const directory3 = previewDirectory;
182993
183265
  const staged = await attemptSync(io, "review", () => stageSavedPreviews(
182994
183266
  directory3,
@@ -183007,16 +183279,16 @@ async function runFlow(job, ws, deps, io) {
183007
183279
  } else if (review && verb === "implement" && startsDelivery && studioName(ws.studio ?? flow.studio ?? "") === "coding") {
183008
183280
  const files = approvedUiPreviews(review);
183009
183281
  if (files.length) {
183010
- previewDirectory ??= fs36.mkdtempSync(path42.join(os6.tmpdir(), "wildcrane-approved-ui-"));
183282
+ previewDirectory ??= fs37.mkdtempSync(path43.join(os6.tmpdir(), "wildcrane-approved-ui-"));
183011
183283
  const directory3 = previewDirectory;
183012
183284
  const staged = await attemptSync(io, "review", async () => {
183013
183285
  for (const file3 of files) {
183014
183286
  if (stopping(io)) return syncStopped;
183015
183287
  const target = approvedUiFile(directory3, file3);
183016
- if (fs36.existsSync(target)) continue;
183288
+ if (fs37.existsSync(target)) continue;
183017
183289
  const fetched = await readAsset(file3.artifact, file3.version);
183018
183290
  if (!fetched.ok) return { ...fetched, error: `${file3.src} (approved revision ${file3.revision}): ${fetched.error}` };
183019
- fs36.writeFileSync(target, fetched.value);
183291
+ fs37.writeFileSync(target, fetched.value);
183020
183292
  }
183021
183293
  return { ok: true, value: void 0 };
183022
183294
  });
@@ -183031,6 +183303,7 @@ async function runFlow(job, ws, deps, io) {
183031
183303
  const failed = await setUp(job, ws, deps, io);
183032
183304
  if (failed) return fail(failed);
183033
183305
  let id2 = akbCardOf(ws);
183306
+ const existedBeforeCreate = flow.verb !== "create" || !!id2;
183034
183307
  const learned = flow.verb === "create" && !id2 && !skipPlan ? await learnRejections(job, ws, deps, io, refreshReview) : [];
183035
183308
  if (io.lost()) return fail("");
183036
183309
  if (flow.verb === "create" && !id2) {
@@ -183041,13 +183314,13 @@ async function runFlow(job, ws, deps, io) {
183041
183314
  said = { title: task.value.title?.trim() ?? "", request: task.value.request?.trim() ?? "" };
183042
183315
  }
183043
183316
  const title = said.title || "Untitled";
183044
- const body = path42.join(ws.board, ".sync", `${ws.task}.request.md`);
183045
- fs36.mkdirSync(path42.dirname(body), { recursive: true });
183317
+ const body = path43.join(ws.board, ".sync", `${ws.task}.request.md`);
183318
+ fs37.mkdirSync(path43.dirname(body), { recursive: true });
183046
183319
  if (!ws.number) return fail("This task has no number yet.");
183047
183320
  const created = await withBoard(ws, async () => {
183048
183321
  const existing = akbCardOf(ws);
183049
183322
  if (existing) return { ok: true, value: existing };
183050
- fs36.writeFileSync(body, `${said.request || title}
183323
+ fs37.writeFileSync(body, `${said.request || title}
183051
183324
  ${pictures(job, ws, ws.number)}`);
183052
183325
  return akb([
183053
183326
  "raw",
@@ -183062,7 +183335,7 @@ ${pictures(job, ws, ws.number)}`);
183062
183335
  String(ws.number),
183063
183336
  ...cardFlags(ws, flow.metadata),
183064
183337
  "--json"
183065
- ]).then(made).finally(() => fs36.rmSync(body, { force: true }));
183338
+ ]).then(made).finally(() => fs37.rmSync(body, { force: true }));
183066
183339
  }, () => stopping(io));
183067
183340
  if (!created || stopping(io)) return fail("");
183068
183341
  if (!created.ok) return fail(created.error);
@@ -183087,54 +183360,111 @@ ${pictures(job, ws, ws.number)}`);
183087
183360
  if (stopping(io)) return fail("");
183088
183361
  if (!id2) return fail("This task has no card on this computer.");
183089
183362
  return onCard(id2);
183363
+ async function reconcileDelivery(card) {
183364
+ const MAX_ATTEMPTS = 3;
183365
+ let attempt = io.reconcileRetry?.get()?.attempt ?? 0;
183366
+ for (; ; ) {
183367
+ const ran = await akb(["raw", "delivery", "reconcile", String(card), "--json"]);
183368
+ if (stopping(io)) return { kind: "none" };
183369
+ const parsed = answerOf2(ran);
183370
+ if (ran.code === 0 && parsed?.kind && ["running", "completed", "resumable", "none"].includes(parsed.kind)) {
183371
+ io.reconcileRetry?.set(void 0);
183372
+ return parsed;
183373
+ }
183374
+ const diagnostic = parsed?.diagnostic ?? parsed?.error?.message ?? refusal2(ran);
183375
+ attempt += 1;
183376
+ if (attempt >= MAX_ATTEMPTS) {
183377
+ io.reconcileRetry?.set(void 0);
183378
+ return { kind: "unverified", deliveryId: parsed?.deliveryId, diagnostic };
183379
+ }
183380
+ const delay3 = Math.min(5e3, (io.syncBackoff ?? syncBackoff)(attempt));
183381
+ const at2 = Date.now() + delay3;
183382
+ io.reconcileRetry?.set({ attempt, at: at2 });
183383
+ if (delay3 > 0) await wait(delay3);
183384
+ if (stopping(io)) return { kind: "none" };
183385
+ }
183386
+ }
183090
183387
  async function onCard(card) {
183091
183388
  const key = workKey(ws, card);
183092
183389
  const held5 = working.get(key) ?? 0;
183093
183390
  working.set(key, held5 + 1);
183094
183391
  try {
183095
- if (!held5 && !await stopRuns(deps.akb, ws, card, 0, deps.stopMs)) {
183392
+ const reconciled = !io.flowRun && !held5 && existedBeforeCreate ? await reconcileDelivery(card) : void 0;
183393
+ if (io.lost()) return fail("");
183394
+ if (reconciled?.kind === "unverified") {
183395
+ io.show(`[recovery] delivery reconciliation unverified${reconciled.deliveryId ? ` (delivery ${reconciled.deliveryId})` : ""}: ${reconciled.diagnostic}
183396
+ `);
183397
+ const runs = answerOf2(await akb(["raw", "run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
183398
+ return {
183399
+ ok: false,
183400
+ reason: "task_recovery_unverified",
183401
+ failure: { code: "task_recovery_unverified", level: 1, source: "validation", reason: "task_recovery_unverified" },
183402
+ report: spentBy([...new Map([...learned, ...runsSpent(runs, since, job, io)].map((r2) => [r2.sessionId, r2])).values()], job)
183403
+ };
183404
+ }
183405
+ if (reconciled?.kind === "completed") {
183406
+ const denied = await refreshReview();
183407
+ if (denied) return fail(denied);
183408
+ if (io.lost()) return fail("");
183409
+ const runs = answerOf2(await akb(["raw", "run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
183410
+ const spent = spentBy([...new Map([...learned, ...runsSpent(runs, since, job, io)].map((r2) => [r2.sessionId, r2])).values()], job);
183411
+ return {
183412
+ ok: true,
183413
+ report: {
183414
+ ...spent,
183415
+ card,
183416
+ deliveryCompleted: true,
183417
+ deliveryId: reconciled.deliveryId,
183418
+ ...reconciled.commit ? { landing: { commit: reconciled.commit, branch: reconciled.branch ?? "" } } : {}
183419
+ }
183420
+ };
183421
+ }
183422
+ if (reconciled?.kind === "running") {
183423
+ const denied = await refreshReview();
183424
+ if (denied) return fail(denied);
183425
+ if (io.lost()) return fail("");
183426
+ } else if (!held5 && !await stopRuns(deps.akb, ws, card, 0, deps.stopMs)) {
183096
183427
  return fail("\u672A\u80FD\u505C\u6B62\u4E0A\u6B21\u8FD0\u884C\uFF0C\u8BF7\u7B49\u5F85\u5176\u505C\u6B62\u540E\u7EED\u8DD1\u3002");
183097
183428
  }
183098
183429
  if (io.lost()) return fail("");
183099
- const ended2 = await workOn(card);
183430
+ const ended2 = await workOn(card, reconciled);
183100
183431
  if (ended2.ok && !coding && flow.verb === "create" && verb === "implement" && job.taskReview && reviewAuthorization(job.taskReview).kind === "unreviewed" && !ended2.report.review) ended2.report.deliveryCompleted = true;
183101
183432
  return ended2;
183102
183433
  } finally {
183103
- if (previewDirectory) fs36.rmSync(previewDirectory, { recursive: true, force: true });
183104
- fs36.rmSync(path42.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
183434
+ if (previewDirectory) fs37.rmSync(previewDirectory, { recursive: true, force: true });
183435
+ fs37.rmSync(path43.join(ws.board, ".sync", `${ws.task}.discussion`), { recursive: true, force: true });
183105
183436
  const left = working.get(key) - 1;
183106
183437
  if (left) working.set(key, left);
183107
183438
  else working.delete(key);
183108
183439
  }
183109
183440
  }
183110
- async function workOn(id3) {
183441
+ async function workOn(id3, reconciled) {
183111
183442
  io.onStop(async () => {
183112
183443
  if (!await stopRuns(deps.akb, ws, id3, since, deps.stopMs)) throw new Error("\u672A\u80FD\u786E\u8BA4\u539F\u6267\u884C\u5DF2\u505C\u6B62\u3002");
183113
183444
  });
183114
183445
  const text3 = flow.verb === "create" ? "" : (flow.text ?? "").trim();
183115
183446
  const archived = !io.flowRun && flow.resume && isArchived(ws, id3);
183116
- if (archived && (!coding || parseFrontmatter(fs36.readFileSync(cardFile(ws), "utf8")).meta?.rejected)) {
183447
+ if (archived && (!coding || parseFrontmatter(fs37.readFileSync(cardFile(ws), "utf8")).meta?.rejected)) {
183117
183448
  return { ok: true, report: { card: id3, ...coding ? { deliveryCompleted: false } : {} } };
183118
183449
  }
183119
- if (!io.flowRun && flow.resume && verb === "refine" && !hasReview) {
183450
+ if (!io.flowRun && flow.resume && verb === "refine" && !hasReview && (!reconciled || reconciled.kind === "none")) {
183120
183451
  const review2 = reviewOf2(cardFile(ws));
183121
183452
  if (review2) return { ok: true, report: { card: id3, ...review2 === true ? {} : { review: review2 } } };
183122
183453
  }
183123
- if (verb === "revise" && !text3) return fail("Say what to change.");
183124
183454
  let note = verb === "resolve" || verb === "revise" ? text3 : "";
183125
183455
  let rejected = false;
183126
183456
  let ran;
183127
183457
  let continuation;
183128
183458
  let expectedDelivery;
183129
- if (io.flowRun) {
183130
- continuation = recoveryArgs(io.flowRun);
183131
- } else if (verb === "implement" && flow.resume) {
183459
+ let effectiveVerb = verb;
183460
+ let effectiveCoding = coding;
183461
+ const resumeExistingDelivery = async () => {
183132
183462
  const restored = await launch2(["raw", "delivery", "resume", String(id3), "--json"]);
183133
183463
  if (restored.reviewRefused) return fail(restored.reviewRefused);
183134
183464
  const resumed = answerOf2(restored);
183135
183465
  if (io.lost()) return fail("");
183136
183466
  if (restored.code === 0 && resumed?.landed && resumed.deliveryId) {
183137
- return { ok: true, report: { card: id3, ...coding ? { deliveryCompleted: true, deliveryId: resumed.deliveryId, ...landingOf(resumed.delivery) } : {} } };
183467
+ return { ok: true, report: { card: id3, ...effectiveCoding ? { deliveryCompleted: true, deliveryId: resumed.deliveryId, ...landingOf(resumed.delivery) } : {} } };
183138
183468
  }
183139
183469
  const reason = restored.code === 0 ? void 0 : resumed?.error?.reason;
183140
183470
  if (reason && reason !== "deliveryActive" && !FRESH_BUILD.has(reason)) {
@@ -183151,12 +183481,45 @@ ${pictures(job, ws, ws.number)}`);
183151
183481
  continuation = ["raw", "run", "resume", previous.sessionId, "--require-session"];
183152
183482
  }
183153
183483
  }
183484
+ return void 0;
183485
+ };
183486
+ if (io.flowRun) {
183487
+ continuation = io.repairDelivery ? ["raw", "run", "resume", io.flowRun.id, "--require-session"] : recoveryArgs(io.flowRun);
183488
+ } else if (reconciled?.kind === "running") {
183489
+ expectedDelivery = reconciled.deliveryId;
183490
+ continuation = ["raw", "run", "log", reconciled.sessionId];
183491
+ } else if (reconciled?.kind === "resumable") {
183492
+ const denied = hasReview ? await refreshReview() : void 0;
183493
+ if (denied) return fail(denied);
183494
+ const reviewAllowsImplement = !hasReview || !!currentTask?.review && reviewAllows(reviewAuthorization(currentTask.review, flow.review_stages, flow.review_revision), "implement");
183495
+ const hasOpenQuestions = asks(cardFile(ws));
183496
+ const continueDelivery = verb === "implement" || !flow.replan && ["refine", "revise", "create"].includes(verb) && reviewAllowsImplement && !hasOpenQuestions;
183497
+ if (continueDelivery) {
183498
+ effectiveVerb = "implement";
183499
+ effectiveCoding = studioName(ws.studio ?? flow.studio ?? "") === "coding";
183500
+ const done = await resumeExistingDelivery();
183501
+ if (done) return done;
183502
+ } else {
183503
+ const released = await akb(["raw", "delivery", "release", String(id3), "--json"]);
183504
+ if (released.code !== 0) {
183505
+ io.show(`[recovery] failed to release delivery lock${reconciled.deliveryId ? ` (delivery ${reconciled.deliveryId})` : ""}: ${refusal2(released)}
183506
+ `);
183507
+ return {
183508
+ ok: false,
183509
+ reason: "task_recovery_unverified",
183510
+ failure: { code: "task_recovery_unverified", level: 1, source: "validation", reason: "task_recovery_unverified" }
183511
+ };
183512
+ }
183513
+ }
183514
+ } else if (verb === "implement" && flow.resume) {
183515
+ const done = await resumeExistingDelivery();
183516
+ if (done) return done;
183154
183517
  } else if (verb === "implement" && text3) {
183155
183518
  const resolved = await launch2(["raw", "card", "resolve", String(id3), "--follow", "--events", "--json", "--", text3], true);
183156
183519
  if (resolved.reviewRefused) return fail(resolved.reviewRefused);
183157
183520
  if (io.lost()) return fail("");
183158
183521
  const file3 = findCard(ws.board, id3);
183159
- rejected = !!file3 && path42.relative(ws.board, file3).split(path42.sep)[0] === ".archive" && parseFrontmatter(fs36.readFileSync(file3, "utf8")).meta?.rejected === true;
183522
+ rejected = !!file3 && path43.relative(ws.board, file3).split(path43.sep)[0] === ".archive" && parseFrontmatter(fs37.readFileSync(file3, "utf8")).meta?.rejected === true;
183160
183523
  if (rejected) ran = resolved;
183161
183524
  else if (resolved.code !== 0) note = text3;
183162
183525
  else if (asks(cardFile(ws))) {
@@ -183164,10 +183527,11 @@ ${pictures(job, ws, ws.number)}`);
183164
183527
  return { ok: true, report: { card: id3, ...coding ? { deliveryCompleted: false } : {}, ...review2 && review2 !== true ? { review: review2 } : {} } };
183165
183528
  }
183166
183529
  }
183530
+ if (effectiveVerb === "revise" && !text3) return fail("Say what to change.");
183167
183531
  const fresh = () => {
183168
- const carry = carryArgs(verb);
183532
+ const carry = carryArgs(effectiveVerb);
183169
183533
  const costFrom = carry.includes("--session") && typeof job.resumeCostUsd === "number" ? { [SESSION_COST_ENV]: String(job.resumeCostUsd) } : void 0;
183170
- return launch2(["raw", "card", verb, String(id3), "--follow", "--events", "--json", ...carry, ...note ? ["--", note] : []], true, costFrom);
183534
+ return launch2(["raw", "card", effectiveVerb, String(id3), "--follow", "--events", "--json", ...carry, ...note ? ["--", note] : []], true, costFrom);
183171
183535
  };
183172
183536
  ran ??= await (continuation ? launch2([...continuation, "--follow", "--events", "--json"], true) : fresh());
183173
183537
  if (ran.reviewRefused) return fail(ran.reviewRefused);
@@ -183177,25 +183541,36 @@ ${pictures(job, ws, ws.number)}`);
183177
183541
  if (expectedDelivery && delivery?.id && delivery.id !== expectedDelivery) {
183178
183542
  return fail("\u7EED\u8DD1\u8FD4\u56DE\u4E86\u5176\u4ED6\u4EA4\u4ED8\u7684\u7ED3\u679C\uFF0C\u539F\u4EA4\u4ED8\u4FDD\u6301\u672A\u5B8C\u6210\u3002");
183179
183543
  }
183180
- if (verb === "implement" && !rejected) {
183544
+ const last = answer?.lastSessionId ?? answer?.error?.lastSessionId;
183545
+ const runs = answerOf2(await akb(["raw", "run", "list", "--card", String(id3), "--all", "--json"]))?.runs ?? [];
183546
+ const recent = runs.find((r2) => r2.sessionId === last) ?? runs.filter((r2) => !r2.parentId && r2.cloudExecution?.job === job.id).at(-1);
183547
+ const spent = spentBy([...new Map([...learned, ...runsSpent(runs, since, job, io)].map((run3) => [run3.sessionId, run3])).values()], job);
183548
+ if (effectiveVerb === "implement" && !rejected) {
183181
183549
  const ending = delivery?.ending;
183182
183550
  if (ending?.kind === "stopped") return { ok: false, reason: "", stopped: true };
183183
183551
  if (ending?.kind === "discarded") return fail("The build was discarded.");
183184
- if (ending?.kind === "blocked") return fail(ending.reason);
183552
+ if (ending?.kind === "blocked") return { ok: false, reason: ending.reason, report: spent };
183185
183553
  }
183186
- const asked = verb === "implement" && !rejected && asks(cardFile(ws));
183554
+ const asked = effectiveVerb === "implement" && !rejected && asks(cardFile(ws));
183187
183555
  const completed = !rejected && !asked && delivery?.status === "finished" ? delivery.id : void 0;
183188
183556
  const waiting = rejected ? null : reviewOf2(cardFile(ws), hasReview);
183189
183557
  const review = waiting && waiting !== true ? waiting : void 0;
183190
- if (!rejected && ran.code !== 0 && !(coding && completed) && !(verb === "refine" && waiting) && !(answer?.error && asked)) {
183191
- return fail(reasonOf(answer?.error?.message?.replace(/^run \S+ ended \w+: /, "")) ?? refusal2(ran));
183558
+ if (!rejected && ran.code !== 0 && !(effectiveCoding && completed) && !(effectiveVerb === "refine" && waiting) && !(answer?.error && asked)) {
183559
+ const failure2 = recent?.failure;
183560
+ return {
183561
+ ok: false,
183562
+ reason: failure2?.reason ?? reasonOf(answer?.error?.message?.replace(/^run \S+ ended \w+: /, "")) ?? refusal2(ran),
183563
+ failure: recent?.retryPause === "limit" && failure2?.level === 2 ? { ...failure2, code: "retry_exhausted" } : failure2,
183564
+ report: spent
183565
+ };
183566
+ }
183567
+ if (effectiveCoding && !rejected && !completed && !asked && !waiting && delivery) {
183568
+ const reason = "The Coding run exited without a delivery receipt. Verify the saved work and finish the original delivery.";
183569
+ return { ok: false, reason, failure: { code: "delivery_incomplete", level: 1, source: "validation", reason }, report: spent };
183192
183570
  }
183193
- const last = answer?.lastSessionId ?? answer?.error?.lastSessionId;
183194
- const runs = answerOf2(await akb(["raw", "run", "list", "--card", String(id3), "--all", "--json"]))?.runs ?? [];
183195
183571
  const said = ((last ? runs.find((r2) => r2.sessionId === last)?.result : void 0) ?? answer?.result ?? answer?.error?.result)?.trim();
183196
- const spent = spentBy([...new Map([...learned, ...runsSpent(runs, since, job, io)].map((run3) => [run3.sessionId, run3])).values()], job);
183197
- const state = coding ? { deliveryCompleted: !!completed, ...completed ? { deliveryId: completed } : {} } : verb === "implement" && delivery?.status === "active" ? { review: {} } : {};
183198
- const landing = (coding ? completed : !rejected && ran.code === 0) ? landingOf(delivery) : {};
183572
+ const state = effectiveCoding ? { deliveryCompleted: !!completed, ...completed ? { deliveryId: completed } : {} } : effectiveVerb === "implement" && delivery?.status === "active" ? { review: {} } : {};
183573
+ const landing = (effectiveCoding ? completed : !rejected && ran.code === 0) ? landingOf(delivery) : {};
183199
183574
  const session = answer?.agentSession ?? answer?.error?.agentSession;
183200
183575
  return { ok: true, report: { ...said ? { reply: said } : {}, ...session ? { session } : {}, ...spent, card: id3, ...state, ...review ? { review } : {}, ...landing } };
183201
183576
  }
@@ -183213,11 +183588,11 @@ ${pictures(job, ws, ws.number)}`);
183213
183588
  function carryArgs(verb2) {
183214
183589
  if (flow.replan) return ["--new-session"];
183215
183590
  if (verb2 === "implement" && flow.verb === "create") {
183216
- const transcript2 = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
183591
+ const transcript2 = writeTranscript(job, path43.join(ws.board, ".sync", `${ws.task}.discussion`));
183217
183592
  return transcript2 ? ["--transcript", transcript2] : [];
183218
183593
  }
183219
183594
  if (!["refine", "resolve", "revise"].includes(verb2)) return [];
183220
- const transcript = writeTranscript(job, path42.join(ws.board, ".sync", `${ws.task}.discussion`));
183595
+ const transcript = writeTranscript(job, path43.join(ws.board, ".sync", `${ws.task}.discussion`));
183221
183596
  return [
183222
183597
  ...job.resume ? ["--session", job.resume, ...job.fork ? ["--fork"] : []] : [],
183223
183598
  ...transcript ? ["--transcript", transcript] : []
@@ -183254,27 +183629,30 @@ async function flowRunEvidence(ws, job, deps, execution = job.id, prior) {
183254
183629
  const candidates = runs.filter((run3) => !run3.parentId && (job.agent || job.review || run3.action === job.flow?.verb || job.flow?.verb === "create" && ["implement", "refine", "spec"].includes(run3.action ?? "") || !!run3.deliveryId && (job.flow?.verb === "create" || job.flow?.verb === "implement") && ["conflict", "hook"].includes(run3.action ?? "") || job.flow?.verb === "refine" && run3.action === "spec")).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
183255
183630
  const previous = candidates.find((run3) => run3.cloudExecution?.job === execution) ?? candidates.find((run3) => run3.sessionId === prior?.id);
183256
183631
  if (!previous) return { stopped: true };
183632
+ const terminal = job.flow && previous.status === "error" && previous.retryPause ? previous.failure : void 0;
183633
+ const failure2 = terminal?.level === 2 && previous.retryPause === "limit" ? { ...terminal, code: "retry_exhausted" } : terminal;
183257
183634
  const recovery = agentRecovery({
183258
183635
  stopped: true,
183259
- completed: previous.status === "done",
183636
+ completed: previous.status === "done" || !!failure2,
183260
183637
  session: previous.resumeId,
183261
- unconfirmedCleanup: previous.cleanup?.status === "unconfirmed"
183638
+ unconfirmedCleanup: previous.pendingWrites || previous.cleanup?.status === "unconfirmed"
183262
183639
  });
183263
183640
  if (recovery === "unsafe") return { stopped: true };
183264
183641
  const { sessionId, runtime, startedAt, usage, costUsd, costIncomplete, context } = previous;
183265
183642
  const priorSpend = new Map(prior?.priorSpend?.map((spend) => [spend.sessionId, spend]));
183266
- if (recovery === "resume") priorSpend.set(sessionId, { sessionId, runtime, startedAt, usage, costUsd, costIncomplete, context });
183643
+ priorSpend.set(sessionId, { sessionId, runtime, startedAt, usage, costUsd, costIncomplete, context });
183267
183644
  return { stopped: true, run: {
183268
183645
  id: sessionId,
183269
183646
  finished: recovery === "report",
183270
183647
  from: previous.cloudExecution?.job,
183271
- ...priorSpend.size ? { priorSpend: [...priorSpend.values()] } : {}
183648
+ ...failure2 ? { failure: failure2 } : {},
183649
+ priorSpend: [...priorSpend.values()]
183272
183650
  } };
183273
183651
  }
183274
183652
 
183275
183653
  // src/recovery.ts
183276
- import fs37 from "node:fs";
183277
- import path43 from "node:path";
183654
+ import fs38 from "node:fs";
183655
+ import path44 from "node:path";
183278
183656
 
183279
183657
  // ../cli/src/lib/agent/wire/codex-background-types.ts
183280
183658
  function idleStopConfirmed(cleanup, session) {
@@ -183283,10 +183661,10 @@ function idleStopConfirmed(cleanup, session) {
183283
183661
 
183284
183662
  // src/recovery.ts
183285
183663
  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.";
183286
- var fileOf2 = (id2) => path43.join(runnerHome(), "checkpoints", `${encodeURIComponent(id2)}.json`);
183664
+ var fileOf2 = (id2) => path44.join(runnerHome(), "checkpoints", `${encodeURIComponent(id2)}.json`);
183287
183665
  function readCheckpoint(id2) {
183288
183666
  try {
183289
- const held5 = JSON.parse(fs37.readFileSync(fileOf2(id2), "utf8"));
183667
+ const held5 = JSON.parse(fs38.readFileSync(fileOf2(id2), "utf8"));
183290
183668
  if (!held5 || !Array.isArray(held5.pending) || !held5.pending.every((id3) => typeof id3 === "string")) throw new Error("\u8FDB\u5EA6\u683C\u5F0F\u9519\u8BEF");
183291
183669
  if (held5.syncRetry && (!Number.isSafeInteger(held5.syncRetry.attempt) || held5.syncRetry.attempt < 1 || !Number.isFinite(held5.syncRetry.at))) {
183292
183670
  delete held5.syncRetry;
@@ -183305,12 +183683,12 @@ function readCheckpoint(id2) {
183305
183683
  }
183306
183684
  function saveCheckpoint(id2, checkpoint) {
183307
183685
  const file3 = fileOf2(id2);
183308
- fs37.mkdirSync(path43.dirname(file3), { recursive: true, mode: 448 });
183309
- fs37.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
183310
- fs37.renameSync(`${file3}.tmp`, file3);
183686
+ fs38.mkdirSync(path44.dirname(file3), { recursive: true, mode: 448 });
183687
+ fs38.writeFileSync(`${file3}.tmp`, JSON.stringify(checkpoint), { mode: 384 });
183688
+ fs38.renameSync(`${file3}.tmp`, file3);
183311
183689
  }
183312
183690
  function clearCheckpoint(id2) {
183313
- fs37.rmSync(fileOf2(id2), { force: true });
183691
+ fs38.rmSync(fileOf2(id2), { force: true });
183314
183692
  }
183315
183693
  function checkpointEvent(checkpoint, event2) {
183316
183694
  if (event2.kind === "phase" && event2.data.phase === "submitted" || event2.kind === "message" && event2.data.text.trim() || event2.kind === "tool_call" || event2.kind === "plan") {
@@ -183350,7 +183728,7 @@ function checkpointRecovery(job, checkpoint, stopped2, failure2) {
183350
183728
  completed: !!checkpoint.completed || board && checkpoint.flowRun?.finished,
183351
183729
  session: board ? checkpoint.flowRun?.id : checkpoint.opaque && !checkpoint.boardContinuation ? void 0 : checkpoint.session,
183352
183730
  replayable: replayable(checkpoint) && (!board || checkpoint.started === false) && (job.runtime !== "antigravity" || checkpoint.started === false) && failure2?.level !== 1,
183353
- unconfirmedCleanup: checkpoint.cleanup?.status === "unconfirmed" || checkpoint.managedProcess && failure2?.code === "idle_timeout" && !idleStopConfirmed(checkpoint.cleanup, checkpoint.session)
183731
+ unconfirmedCleanup: !!checkpoint.boardContinuation && checkpoint.pending.length > 0 || checkpoint.cleanup?.status === "unconfirmed" || checkpoint.managedProcess && failure2?.code === "idle_timeout" && !idleStopConfirmed(checkpoint.cleanup, checkpoint.session)
183354
183732
  });
183355
183733
  }
183356
183734
  function replyRecovery(job, checkpoint, stopped2) {
@@ -183518,32 +183896,32 @@ function conversationProgress(attempt, send3, valid, unconfirmed) {
183518
183896
  }
183519
183897
 
183520
183898
  // src/settings-control.ts
183521
- import fs38 from "node:fs";
183522
- import path44 from "node:path";
183899
+ import fs39 from "node:fs";
183900
+ import path45 from "node:path";
183523
183901
 
183524
183902
  // src/codex-native.ts
183525
183903
  var import_undici2 = __toESM(require_undici(), 1);
183526
183904
 
183527
183905
  // src/settings-control.ts
183528
- var directory = () => path44.join(runnerHome(), "executors");
183529
- var epochFile = () => path44.join(runnerHome(), "account-generation");
183906
+ var directory = () => path45.join(runnerHome(), "executors");
183907
+ var epochFile = () => path45.join(runnerHome(), "account-generation");
183530
183908
  function accountGeneration() {
183531
183909
  try {
183532
- return fs38.readFileSync(epochFile(), "utf8");
183910
+ return fs39.readFileSync(epochFile(), "utf8");
183533
183911
  } catch {
183534
183912
  return "";
183535
183913
  }
183536
183914
  }
183537
183915
  function executorRecord() {
183538
- fs38.mkdirSync(directory(), { recursive: true, mode: 448 });
183539
- const file3 = path44.join(directory(), `${process.pid}.json`);
183540
- fs38.writeFileSync(file3, "{}", { mode: 384 });
183541
- return () => fs38.rmSync(file3, { force: true });
183916
+ fs39.mkdirSync(directory(), { recursive: true, mode: 448 });
183917
+ const file3 = path45.join(directory(), `${process.pid}.json`);
183918
+ fs39.writeFileSync(file3, "{}", { mode: 384 });
183919
+ return () => fs39.rmSync(file3, { force: true });
183542
183920
  }
183543
183921
 
183544
183922
  // src/reply-images.ts
183545
- import fs39 from "node:fs";
183546
- import path45 from "node:path";
183923
+ import fs40 from "node:fs";
183924
+ import path46 from "node:path";
183547
183925
  import os7 from "node:os";
183548
183926
  import { fileURLToPath as fileURLToPath3 } from "node:url";
183549
183927
  import { createHash as createHash6 } from "node:crypto";
@@ -183562,16 +183940,16 @@ function imageMime(bytes2) {
183562
183940
  // src/reply-images.ts
183563
183941
  init_file_limits();
183564
183942
  var inside = (root2, file3) => {
183565
- const p2 = path45.relative(root2, file3);
183566
- return p2 !== ".." && !p2.startsWith(`..${path45.sep}`) && !path45.isAbsolute(p2);
183943
+ const p2 = path46.relative(root2, file3);
183944
+ return p2 !== ".." && !p2.startsWith(`..${path46.sep}`) && !path46.isAbsolute(p2);
183567
183945
  };
183568
183946
  function collectReplyImages(parts, cwd) {
183569
183947
  const files = /* @__PURE__ */ new Map();
183570
183948
  const tools = [];
183571
183949
  const output3 = [];
183572
- const roots = [cwd, path45.join(process.env.CODEX_HOME?.trim() || path45.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
183950
+ const roots = [cwd, path46.join(process.env.CODEX_HOME?.trim() || path46.join(os7.homedir(), ".codex"), "generated_images")].flatMap((p2) => {
183573
183951
  try {
183574
- return [fs39.realpathSync(p2)];
183952
+ return [fs40.realpathSync(p2)];
183575
183953
  } catch {
183576
183954
  return [];
183577
183955
  }
@@ -183579,17 +183957,17 @@ function collectReplyImages(parts, cwd) {
183579
183957
  const registered = new Set(parts.flatMap((p2) => {
183580
183958
  if (p2.type !== "image" || !p2.registered || !p2.path) return [];
183581
183959
  try {
183582
- const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path45.resolve(cwd, p2.path);
183583
- if (!fs39.lstatSync(file3).isFile()) return [];
183584
- const real = fs39.realpathSync(file3);
183585
- const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
183960
+ const file3 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : path46.resolve(cwd, p2.path);
183961
+ if (!fs40.lstatSync(file3).isFile()) return [];
183962
+ const real = fs40.realpathSync(file3);
183963
+ const fd = fs40.openSync(real, fs40.constants.O_RDONLY | (fs40.constants.O_NOFOLLOW ?? 0));
183586
183964
  try {
183587
- const stat2 = fs39.fstatSync(fd);
183965
+ const stat2 = fs40.fstatSync(fd);
183588
183966
  if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) return [];
183589
- const mime = imageMime(fs39.readFileSync(fd));
183967
+ const mime = imageMime(fs40.readFileSync(fd));
183590
183968
  return mime && (!p2.mime || p2.mime === mime) ? [real] : [];
183591
183969
  } finally {
183592
- fs39.closeSync(fd);
183970
+ fs40.closeSync(fd);
183593
183971
  }
183594
183972
  } catch {
183595
183973
  return [];
@@ -183605,16 +183983,16 @@ function collectReplyImages(parts, cwd) {
183605
183983
  if (!p2.path) throw Error();
183606
183984
  const source2 = p2.path.startsWith("file:") ? fileURLToPath3(p2.path) : decodeURIComponent(p2.path);
183607
183985
  if (/^[a-z][a-z0-9+.-]*:/i.test(source2) && !/^[A-Za-z]:[\\/]/.test(source2)) throw Error();
183608
- const real = fs39.realpathSync(path45.resolve(cwd, source2));
183986
+ const real = fs40.realpathSync(path46.resolve(cwd, source2));
183609
183987
  if (!/\.(png|jpe?g|gif|webp)$/i.test(source2) && !registered.has(real)) throw Error();
183610
183988
  if (!roots.some((root2) => inside(root2, real)) && !registered.has(real)) throw Error();
183611
- const fd = fs39.openSync(real, fs39.constants.O_RDONLY | (fs39.constants.O_NOFOLLOW ?? 0));
183989
+ const fd = fs40.openSync(real, fs40.constants.O_RDONLY | (fs40.constants.O_NOFOLLOW ?? 0));
183612
183990
  try {
183613
- const stat2 = fs39.fstatSync(fd);
183991
+ const stat2 = fs40.fstatSync(fd);
183614
183992
  if (!stat2.isFile() || stat2.size > ASSET_FILE_LIMIT) throw Error();
183615
- bytes2 = fs39.readFileSync(fd);
183993
+ bytes2 = fs40.readFileSync(fd);
183616
183994
  } finally {
183617
- fs39.closeSync(fd);
183995
+ fs40.closeSync(fd);
183618
183996
  }
183619
183997
  }
183620
183998
  return bytes2;
@@ -183698,13 +184076,13 @@ async function saveReplyImages(parts, cwd, upload2) {
183698
184076
  }
183699
184077
 
183700
184078
  // src/handoff.ts
183701
- import { execFileSync as execFileSync2 } from "node:child_process";
184079
+ import { execFileSync as execFileSync3 } from "node:child_process";
183702
184080
  import crypto5 from "node:crypto";
183703
- import fs40 from "node:fs";
183704
- import path46 from "node:path";
184081
+ import fs41 from "node:fs";
184082
+ import path47 from "node:path";
183705
184083
  var gitRead = (cwd, args2) => {
183706
184084
  try {
183707
- return execFileSync2("git", ["-C", cwd, ...args2], {
184085
+ return execFileSync3("git", ["-C", cwd, ...args2], {
183708
184086
  encoding: "utf8",
183709
184087
  timeout: 15e3,
183710
184088
  maxBuffer: 16 * 1024 * 1024,
@@ -183718,8 +184096,8 @@ var digest = (value) => crypto5.createHash("sha256").update(value).digest("hex")
183718
184096
  function authorizedFolder(folder2) {
183719
184097
  if (!folder2) return null;
183720
184098
  try {
183721
- const real = fs40.realpathSync(folder2);
183722
- return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path46.sep)) ? real : null;
184099
+ const real = fs41.realpathSync(folder2);
184100
+ return allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path47.sep)) ? real : null;
183723
184101
  } catch {
183724
184102
  return null;
183725
184103
  }
@@ -183729,9 +184107,9 @@ function progressFolder(job, folder2) {
183729
184107
  if (!token) return folder2;
183730
184108
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) return null;
183731
184109
  try {
183732
- const dir = fs40.realpathSync(path46.join(folder2, ".akb", "handoffs", token));
183733
- if (!dir.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
183734
- const marker = JSON.parse(fs40.readFileSync(path46.join(dir, ".akb", "handoff.json"), "utf8"));
184110
+ const dir = fs41.realpathSync(path47.join(folder2, ".akb", "handoffs", token));
184111
+ if (!dir.startsWith(fs41.realpathSync(folder2) + path47.sep)) return null;
184112
+ const marker = JSON.parse(fs41.readFileSync(path47.join(dir, ".akb", "handoff.json"), "utf8"));
183735
184113
  return marker.task === job.task && marker.isolation === token ? dir : null;
183736
184114
  } catch {
183737
184115
  return null;
@@ -183739,38 +184117,38 @@ function progressFolder(job, folder2) {
183739
184117
  }
183740
184118
  function progressEvidence(job, folder2) {
183741
184119
  try {
183742
- const board = path46.join(folder2, ".akb", "kanban");
183743
- const deliveries = path46.join(board, "deliveries");
183744
- 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));
184120
+ const board = path47.join(folder2, ".akb", "kanban");
184121
+ const deliveries = path47.join(board, "deliveries");
184122
+ 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));
183745
184123
  const row = rows[0];
183746
184124
  if (!row?.deliveryId) return null;
183747
- const tree = fs40.realpathSync(path46.resolve(folder2, row.worktree ?? "."));
183748
- if (tree !== fs40.realpathSync(folder2) && !tree.startsWith(fs40.realpathSync(folder2) + path46.sep)) return null;
184125
+ const tree = fs41.realpathSync(path47.resolve(folder2, row.worktree ?? "."));
184126
+ if (tree !== fs41.realpathSync(folder2) && !tree.startsWith(fs41.realpathSync(folder2) + path47.sep)) return null;
183749
184127
  const inventory = gitRead(tree, ["worktree", "list", "--porcelain"]);
183750
184128
  const related = (inventory ?? "").split("\n\n").flatMap((entry) => {
183751
184129
  const branch = /^branch refs\/heads\/(.+)$/m.exec(entry)?.[1];
183752
184130
  const dir = /^worktree (.+)$/m.exec(entry)?.[1];
183753
- return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs40.realpathSync(folder2) + path46.sep) ? [dir] : [];
184131
+ return branch?.startsWith(`card/${job.number}/`) && dir && dir !== tree && dir.startsWith(fs41.realpathSync(folder2) + path47.sep) ? [dir] : [];
183754
184132
  });
183755
184133
  const filesIn = (tree2) => {
183756
184134
  const changed = [];
183757
184135
  const walk = (dir, prefix = "") => {
183758
- for (const entry of fs40.readdirSync(dir, { withFileTypes: true })) {
184136
+ for (const entry of fs41.readdirSync(dir, { withFileTypes: true })) {
183759
184137
  if ([".git", ".akb", "node_modules", ".claude", ".agents"].includes(entry.name)) continue;
183760
184138
  const name = prefix + entry.name;
183761
- if (entry.isDirectory()) walk(path46.join(dir, entry.name), name + "/");
184139
+ if (entry.isDirectory()) walk(path47.join(dir, entry.name), name + "/");
183762
184140
  else changed.push(name);
183763
184141
  }
183764
184142
  };
183765
184143
  walk(tree2);
183766
184144
  changed.sort();
183767
184145
  return changed.map((name) => {
183768
- const file3 = path46.join(tree2, name);
184146
+ const file3 = path47.join(tree2, name);
183769
184147
  try {
183770
- const stat2 = fs40.lstatSync(file3);
183771
- if (stat2.isSymbolicLink()) return [name, "link", digest(fs40.readlinkSync(file3))];
184148
+ const stat2 = fs41.lstatSync(file3);
184149
+ if (stat2.isSymbolicLink()) return [name, "link", digest(fs41.readlinkSync(file3))];
183772
184150
  if (!stat2.isFile()) throw new Error("\u65E0\u6CD5\u9A8C\u8BC1\u6587\u4EF6\u7C7B\u578B");
183773
- return [name, stat2.mode & 511, digest(fs40.readFileSync(file3))];
184151
+ return [name, stat2.mode & 511, digest(fs41.readFileSync(file3))];
183774
184152
  } catch (e2) {
183775
184153
  if (e2.code === "ENOENT") return [name, "deleted"];
183776
184154
  throw e2;
@@ -183807,60 +184185,60 @@ function progressEvidence(job, folder2) {
183807
184185
  function restartFolder(job, folder2) {
183808
184186
  const token = job.handoff?.isolation ?? job.id;
183809
184187
  if (!/^[a-zA-Z0-9-]{1,80}$/.test(token)) throw new Error("\u9694\u79BB\u76EE\u5F55\u7F16\u53F7\u65E0\u6548\u3002");
183810
- const dir = path46.join(folder2, ".akb", "handoffs", token);
183811
- const marker = path46.join(dir, ".akb", "handoff.json");
183812
- for (const parent of [path46.join(folder2, ".akb"), path46.dirname(dir), dir]) {
183813
- 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");
184188
+ const dir = path47.join(folder2, ".akb", "handoffs", token);
184189
+ const marker = path47.join(dir, ".akb", "handoff.json");
184190
+ for (const parent of [path47.join(folder2, ".akb"), path47.dirname(dir), dir]) {
184191
+ 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");
183814
184192
  }
183815
- if (fs40.existsSync(dir)) {
184193
+ if (fs41.existsSync(dir)) {
183816
184194
  if (job.handoff?.recovering) {
183817
184195
  try {
183818
- const saved = JSON.parse(fs40.readFileSync(marker, "utf8"));
184196
+ const saved = JSON.parse(fs41.readFileSync(marker, "utf8"));
183819
184197
  if (saved.task === job.task && saved.isolation === token) return dir;
183820
184198
  } catch {
183821
184199
  }
183822
184200
  }
183823
184201
  throw new Error("\u91CD\u542F\u76EE\u5F55\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u3002");
183824
184202
  }
183825
- fs40.mkdirSync(path46.dirname(dir), { recursive: true });
183826
- fs40.mkdirSync(dir);
183827
- for (const entry of fs40.readdirSync(folder2)) {
184203
+ fs41.mkdirSync(path47.dirname(dir), { recursive: true });
184204
+ fs41.mkdirSync(dir);
184205
+ for (const entry of fs41.readdirSync(folder2)) {
183828
184206
  if ([".akb", ".git", "node_modules", ".claude", ".agents"].includes(entry)) continue;
183829
- fs40.cpSync(path46.join(folder2, entry), path46.join(dir, entry), { recursive: true, verbatimSymlinks: true });
184207
+ fs41.cpSync(path47.join(folder2, entry), path47.join(dir, entry), { recursive: true, verbatimSymlinks: true });
183830
184208
  }
183831
- if (fs40.lstatSync(path46.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
183832
- fs40.mkdirSync(path46.dirname(marker), { recursive: true });
183833
- fs40.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
184209
+ if (fs41.lstatSync(path47.dirname(marker), { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error("\u9694\u79BB\u6807\u8BB0\u76EE\u5F55\u65E0\u6548\u3002");
184210
+ fs41.mkdirSync(path47.dirname(marker), { recursive: true });
184211
+ fs41.writeFileSync(marker, JSON.stringify({ task: job.task, isolation: token }), { flag: "wx" });
183834
184212
  return dir;
183835
184213
  }
183836
184214
 
183837
184215
  // src/jobs.ts
183838
184216
  import { spawn as spawn5 } from "node:child_process";
183839
- import fs47 from "node:fs";
183840
- import path52 from "node:path";
184217
+ import fs48 from "node:fs";
184218
+ import path53 from "node:path";
183841
184219
 
183842
184220
  // ../cli/src/lib/agent/catalog.ts
183843
- import fs41 from "node:fs";
183844
- import path47 from "node:path";
184221
+ import fs42 from "node:fs";
184222
+ import path48 from "node:path";
183845
184223
  var CATALOGUE = "https://models.dev/api.json";
183846
184224
  var FRESH_FOR_MS = 24 * 60 * 6e4;
183847
184225
  var ANSWER_BY_MS = 2e4;
183848
184226
  function cacheFile() {
183849
- return path47.join(machineHome(), "models-dev.json");
184227
+ return path48.join(machineHome(), "models-dev.json");
183850
184228
  }
183851
184229
  var held3;
183852
184230
  function readCache() {
183853
184231
  const file3 = cacheFile();
183854
184232
  let stamp3;
183855
184233
  try {
183856
- const stat2 = fs41.statSync(file3);
184234
+ const stat2 = fs42.statSync(file3);
183857
184235
  stamp3 = `${stat2.mtimeMs}:${stat2.size}`;
183858
184236
  } catch {
183859
184237
  return void 0;
183860
184238
  }
183861
184239
  if (held3?.stamp === stamp3) return held3.cached;
183862
184240
  try {
183863
- const data = JSON.parse(fs41.readFileSync(file3, "utf8"));
184241
+ const data = JSON.parse(fs42.readFileSync(file3, "utf8"));
183864
184242
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
183865
184243
  const cached3 = {
183866
184244
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -183899,8 +184277,8 @@ function refreshCatalog() {
183899
184277
  const limits = limitsIn(await answer.json());
183900
184278
  if (Object.keys(limits).length === 0) return;
183901
184279
  const file3 = cacheFile();
183902
- fs41.mkdirSync(path47.dirname(file3), { recursive: true });
183903
- fs41.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
184280
+ fs42.mkdirSync(path48.dirname(file3), { recursive: true });
184281
+ fs42.writeFileSync(file3, JSON.stringify({ fetchedAt: Date.now(), limits }));
183904
184282
  } catch {
183905
184283
  }
183906
184284
  })();
@@ -183993,14 +184371,14 @@ async function replyApprovalBridge(task, number4, approve) {
183993
184371
  }
183994
184372
 
183995
184373
  // src/akb-version.ts
183996
- import fs42 from "node:fs";
183997
- import path48 from "node:path";
183998
- var stateFile = () => path48.join(akbHome(), "state.json");
183999
- var akbVersionDir = (version2) => path48.join(akbHome(), version2);
184000
- var entryOf = (dir) => path48.join(dir, "bin", "ai4kanban.mjs");
184374
+ import fs43 from "node:fs";
184375
+ import path49 from "node:path";
184376
+ var stateFile = () => path49.join(akbHome(), "state.json");
184377
+ var akbVersionDir = (version2) => path49.join(akbHome(), version2);
184378
+ var entryOf = (dir) => path49.join(dir, "bin", "ai4kanban.mjs");
184001
184379
  function readAkbState() {
184002
184380
  try {
184003
- const held5 = JSON.parse(fs42.readFileSync(stateFile(), "utf8"));
184381
+ const held5 = JSON.parse(fs43.readFileSync(stateFile(), "utf8"));
184004
184382
  return { current: held5.current ?? null, bad: held5.bad ?? [] };
184005
184383
  } catch {
184006
184384
  return { current: null, bad: [] };
@@ -184008,12 +184386,12 @@ function readAkbState() {
184008
184386
  }
184009
184387
  function contractOf(dir) {
184010
184388
  try {
184011
- return JSON.parse(fs42.readFileSync(path48.join(dir, "package.json"), "utf8")).akbContract ?? null;
184389
+ return JSON.parse(fs43.readFileSync(path49.join(dir, "package.json"), "utf8")).akbContract ?? null;
184012
184390
  } catch {
184013
184391
  return null;
184014
184392
  }
184015
184393
  }
184016
- var usable = (dir) => fs42.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
184394
+ var usable = (dir) => fs43.existsSync(entryOf(dir)) && contractOf(dir) === AKB_CONTRACT;
184017
184395
  function currentAkb() {
184018
184396
  const { current: current2 } = readAkbState();
184019
184397
  if (!current2) return bundledAkb();
@@ -184021,32 +184399,32 @@ function currentAkb() {
184021
184399
  if (!usable(dir)) return bundledAkb();
184022
184400
  try {
184023
184401
  const now = /* @__PURE__ */ new Date();
184024
- fs42.utimesSync(dir, now, now);
184402
+ fs43.utimesSync(dir, now, now);
184025
184403
  } catch {
184026
184404
  }
184027
- return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path48.join(dir, "shim") };
184405
+ return { command: process.execPath, args: akbArgs(entryOf(dir)), version: current2, shim: path49.join(dir, "shim") };
184028
184406
  }
184029
184407
 
184030
184408
  // src/chats.ts
184031
- import fs44 from "node:fs";
184032
- import path50 from "node:path";
184409
+ import fs45 from "node:fs";
184410
+ import path51 from "node:path";
184033
184411
 
184034
184412
  // ../cli/src/lib/shared/chats.ts
184035
184413
  var CHAT_KEEP_DAYS = 30;
184036
184414
 
184037
184415
  // ../cli/src/lib/agent/task-chats.ts
184038
- import fs43 from "node:fs";
184039
- import path49 from "node:path";
184416
+ import fs44 from "node:fs";
184417
+ import path50 from "node:path";
184040
184418
  var TASK = /^[\w-]{1,100}$/;
184041
- var taskChatsDir = (home4 = machineHome()) => path49.join(home4, "chats");
184419
+ var taskChatsDir = (home4 = machineHome()) => path50.join(home4, "chats");
184042
184420
  function taskChatFile(task, home4) {
184043
184421
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
184044
- return path49.join(taskChatsDir(home4), `${task}.jsonl`);
184422
+ return path50.join(taskChatsDir(home4), `${task}.jsonl`);
184045
184423
  }
184046
184424
  function readTaskChat(task, home4) {
184047
184425
  let text3;
184048
184426
  try {
184049
- text3 = fs43.readFileSync(taskChatFile(task, home4), "utf8");
184427
+ text3 = fs44.readFileSync(taskChatFile(task, home4), "utf8");
184050
184428
  } catch {
184051
184429
  return [];
184052
184430
  }
@@ -184066,18 +184444,18 @@ function readTaskChat(task, home4) {
184066
184444
  var DAY_MS = 24 * 60 * 6e4;
184067
184445
  var KEEP_MS2 = CHAT_KEEP_DAYS * DAY_MS;
184068
184446
  var home3 = () => runnerHome();
184069
- var reviewedFile = () => path50.join(taskChatsDir(home3()), "reviewed.json");
184447
+ var reviewedFile = () => path51.join(taskChatsDir(home3()), "reviewed.json");
184070
184448
  function readReviewed() {
184071
184449
  try {
184072
- const held5 = JSON.parse(fs44.readFileSync(reviewedFile(), "utf8"));
184450
+ const held5 = JSON.parse(fs45.readFileSync(reviewedFile(), "utf8"));
184073
184451
  return { checkedAt: Number(held5.checkedAt) || 0, tasks: held5.tasks ?? {} };
184074
184452
  } catch {
184075
184453
  return { checkedAt: 0, tasks: {} };
184076
184454
  }
184077
184455
  }
184078
184456
  function writeReviewed(reviewed) {
184079
- fs44.mkdirSync(path50.dirname(reviewedFile()), { recursive: true });
184080
- fs44.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
184457
+ fs45.mkdirSync(path51.dirname(reviewedFile()), { recursive: true });
184458
+ fs45.writeFileSync(reviewedFile(), `${JSON.stringify(reviewed, null, 2)}
184081
184459
  `);
184082
184460
  }
184083
184461
  function keepChat(job, reply, at2 = Date.now()) {
@@ -184087,16 +184465,16 @@ function keepChat(job, reply, at2 = Date.now()) {
184087
184465
  { id: job.id, role: "agent", text: reply, at: at2, runtime: job.runtime, model: job.model ?? null }
184088
184466
  ];
184089
184467
  const file3 = taskChatFile(job.task, home3());
184090
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184091
- fs44.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184468
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184469
+ fs45.appendFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184092
184470
  `).join(""));
184093
184471
  }
184094
184472
  function keepCloudChat(task, messages) {
184095
184473
  const file3 = taskChatFile(task, home3());
184096
- if (!messages.length) return fs44.rmSync(file3, { force: true });
184474
+ if (!messages.length) return fs45.rmSync(file3, { force: true });
184097
184475
  const lines = messages.map((m) => ({ id: m.id, role: m.role, text: m.body, at: Date.parse(m.created_at) || Date.now() }));
184098
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184099
- fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184476
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184477
+ fs45.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184100
184478
  `).join(""));
184101
184479
  }
184102
184480
  async function keepDecisions(task, read5) {
@@ -184114,8 +184492,8 @@ async function keepDecisions(task, read5) {
184114
184492
  const ids = new Set(comments.map((c2) => c2.id));
184115
184493
  const lines = [...readTaskChat(task, home3()).filter((l2) => !ids.has(l2.id)), ...comments].sort((a2, b2) => a2.at - b2.at);
184116
184494
  const file3 = taskChatFile(task, home3());
184117
- fs44.mkdirSync(path50.dirname(file3), { recursive: true });
184118
- fs44.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184495
+ fs45.mkdirSync(path51.dirname(file3), { recursive: true });
184496
+ fs45.writeFileSync(file3, lines.map((l2) => `${JSON.stringify(l2)}
184119
184497
  `).join(""));
184120
184498
  return true;
184121
184499
  }
@@ -184130,29 +184508,29 @@ function markReviewed2(marks) {
184130
184508
  }
184131
184509
 
184132
184510
  // src/goals.ts
184133
- import fs46 from "node:fs";
184134
- import path51 from "node:path";
184511
+ import fs47 from "node:fs";
184512
+ import path52 from "node:path";
184135
184513
 
184136
184514
  // ../cli/src/lib/goal-draft.ts
184137
- import fs45 from "node:fs";
184515
+ import fs46 from "node:fs";
184138
184516
  var goalDraftEnv = (file3) => ({ KANBAN_GOALS: file3, KANBAN_IDEAS: file3 });
184139
184517
  function readGoalDraft(file3) {
184140
- return decodeGoals(JSON.parse(fs45.readFileSync(file3, "utf8")));
184518
+ return decodeGoals(JSON.parse(fs46.readFileSync(file3, "utf8")));
184141
184519
  }
184142
184520
  function writeGoalDraft(file3, { goals, ...draft }, field) {
184143
184521
  const entries = field === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
184144
- fs45.writeFileSync(file3, `${JSON.stringify({ ...draft, [field]: entries }, null, 2)}
184522
+ fs46.writeFileSync(file3, `${JSON.stringify({ ...draft, [field]: entries }, null, 2)}
184145
184523
  `);
184146
184524
  }
184147
184525
 
184148
184526
  // src/goals.ts
184149
- var goalsFileOf = (job) => path51.join(runnerHome(), "ideas", `${job.id}.json`);
184527
+ var goalsFileOf = (job) => path52.join(runnerHome(), "ideas", `${job.id}.json`);
184150
184528
  async function writeGoals(job, list3, preserveGoals = false) {
184151
184529
  const file3 = goalsFileOf(job);
184152
184530
  try {
184153
- const goals = preserveGoals && fs46.existsSync(file3) ? readGoalDraft(file3).value.goals : job.discussion.goals;
184531
+ const goals = preserveGoals && fs47.existsSync(file3) ? readGoalDraft(file3).value.goals : job.discussion.goals;
184154
184532
  const studios = await studioSnapshot(job.discussion.workspace, job.discussion.catalog, list3);
184155
- fs46.mkdirSync(path51.dirname(file3), { recursive: true });
184533
+ fs47.mkdirSync(path52.dirname(file3), { recursive: true });
184156
184534
  writeGoalDraft(file3, { workspace: job.discussion.workspace, studios, goals }, "ideas");
184157
184535
  return { file: file3 };
184158
184536
  } catch (e2) {
@@ -184165,7 +184543,7 @@ function readGoals(file3) {
184165
184543
  } catch {
184166
184544
  return void 0;
184167
184545
  } finally {
184168
- fs46.rmSync(file3, { force: true });
184546
+ fs47.rmSync(file3, { force: true });
184169
184547
  }
184170
184548
  }
184171
184549
  var owner = "";
@@ -184278,32 +184656,32 @@ var defaultDeps = (machineId) => ({
184278
184656
  akb: currentAkb,
184279
184657
  runtimes: detectRuntimes
184280
184658
  });
184281
- var ownFolder = () => path52.join(runnerHome(), "work");
184659
+ var ownFolder = () => path53.join(runnerHome(), "work");
184282
184660
  function folderFor(job) {
184283
184661
  if (!job.projectDir) {
184284
- const cwd = path52.join(ownFolder(), job.id);
184285
- fs47.mkdirSync(cwd, { recursive: true });
184662
+ const cwd = path53.join(ownFolder(), job.id);
184663
+ fs48.mkdirSync(cwd, { recursive: true });
184286
184664
  return { cwd };
184287
184665
  }
184288
184666
  const real = realpath2(job.projectDir);
184289
- if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path52.sep))) return { cwd: real };
184667
+ if (real && allowedProjects().some((root2) => real === root2 || real.startsWith(root2 + path53.sep))) return { cwd: real };
184290
184668
  return { refused: `This Runner is not allowed to work in ${job.projectDir}.` };
184291
184669
  }
184292
184670
  function realpath2(p2) {
184293
184671
  try {
184294
- return fs47.realpathSync(p2);
184672
+ return fs48.realpathSync(p2);
184295
184673
  } catch {
184296
184674
  return null;
184297
184675
  }
184298
184676
  }
184299
- var attachmentsOf = (job) => path52.join(runnerHome(), "attachments", job.id);
184677
+ var attachmentsOf = (job) => path53.join(runnerHome(), "attachments", job.id);
184300
184678
  function writeAttachments(job) {
184301
184679
  if (!job.attachments.length) return { text: "", files: [] };
184302
184680
  const dir = attachmentsOf(job);
184303
- fs47.mkdirSync(dir, { recursive: true });
184681
+ fs48.mkdirSync(dir, { recursive: true });
184304
184682
  const files = job.attachments.map((a2) => {
184305
- const file3 = path52.join(dir, path52.basename(a2.name));
184306
- fs47.writeFileSync(file3, Buffer.from(a2.content, "base64"));
184683
+ const file3 = path53.join(dir, path53.basename(a2.name));
184684
+ fs48.writeFileSync(file3, Buffer.from(a2.content, "base64"));
184307
184685
  return file3;
184308
184686
  });
184309
184687
  return { text: `
@@ -184600,12 +184978,12 @@ async function runJob(id2, deps, track = () => {
184600
184978
  const releases = [];
184601
184979
  try {
184602
184980
  const akb = deps.akb();
184603
- releases.push(hold(path52.dirname(akb.shim)));
184981
+ releases.push(hold(path53.dirname(akb.shim)));
184604
184982
  releases.push(hold(akb.shim));
184605
184983
  await runClaimed(job, { ...deps, akb }, track, (dir) => releases.push(hold(dir)), lease);
184606
184984
  } finally {
184607
184985
  for (const release2 of releases) release2();
184608
- fs47.rmSync(attachmentsOf(job), { recursive: true, force: true });
184986
+ fs48.rmSync(attachmentsOf(job), { recursive: true, force: true });
184609
184987
  }
184610
184988
  return "changed";
184611
184989
  }
@@ -184649,7 +185027,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184649
185027
  };
184650
185028
  const manual = job.manualRecovery === true;
184651
185029
  const updating = checkpoint.updating === true;
184652
- const recovering = updating || !!sourceId || manual || !!checkpoint.retry?.pending || !!previous?.boardContinuation;
185030
+ const recovering = updating || !!checkpoint.taskRecovery || !!sourceId || manual || !!checkpoint.retry?.pending || !!previous?.boardContinuation;
184653
185031
  const persist = () => {
184654
185032
  checkpoint.updating ||= readCheckpoint(id2)?.updating;
184655
185033
  saveCheckpoint(id2, checkpoint);
@@ -184748,6 +185126,17 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184748
185126
  track(stream2.stop);
184749
185127
  return stream2;
184750
185128
  };
185129
+ const recoveryState = async (state) => {
185130
+ if (state) checkpoint.taskRecovery = state;
185131
+ else delete checkpoint.taskRecovery;
185132
+ persist();
185133
+ const stream2 = watching();
185134
+ const sentAt = leaseNow();
185135
+ const renewed = await deps.api.renewJob(deps.machineId, id2, { taskRecovery: state });
185136
+ if (renewed.ok && renewed.value.renewed && state?.code !== "allowance") Object.assign(lease, sentAt);
185137
+ if (renewed.ok && renewed.value.stop) stream2.requestStop();
185138
+ if (renewed.ok && renewed.value.projectDir && !job.projectDir) job = { ...job, projectDir: renewed.value.projectDir };
185139
+ };
184751
185140
  const sync = async (step, operation) => {
184752
185141
  const stream2 = watching();
184753
185142
  let waiting = false;
@@ -184764,6 +185153,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184764
185153
  }), stream2.whenAsked]);
184765
185154
  clearTimeout(timer);
184766
185155
  if (stream2.asked() || stream2.lost()) break;
185156
+ if (checkpoint.taskRecovery?.code === "allowance" && retry3.at > Date.now()) continue;
184767
185157
  const requestedAt = leaseNow();
184768
185158
  const hold2 = await deps.api.renewJob(deps.machineId, id2);
184769
185159
  if (stream2.lost()) break;
@@ -184781,18 +185171,24 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184781
185171
  }
184782
185172
  const result = renewed ?? await operation();
184783
185173
  if (stream2.asked() || stream2.lost()) break;
184784
- if (result.ok || !retryableSync(result)) {
185174
+ const blocker = job.flow && !result.ok ? syncWaitCode(result) : void 0;
185175
+ if (result.ok || !blocker && !retryableSync(result)) {
184785
185176
  if (waiting) stream2.event({ kind: "status", data: { state: "running", source: "sync" } });
184786
185177
  if (retry3) {
184787
185178
  delete checkpoint.syncRetry;
184788
185179
  persist();
184789
185180
  }
185181
+ if (checkpoint.taskRecovery && step !== "authorize" && ["storage", "allowance"].includes(checkpoint.taskRecovery.code)) {
185182
+ await recoveryState(null);
185183
+ }
184790
185184
  return result;
184791
185185
  }
184792
185186
  console.error("runner: task sync", { job: id2, code: result.code, error: result.error });
184793
185187
  const attempt2 = (checkpoint.syncRetry?.attempt ?? 0) + 1;
184794
- checkpoint.syncRetry = { step, attempt: attempt2, at: Date.now() + (deps.syncBackoff ?? syncBackoff)(attempt2) };
184795
- persist();
185188
+ const at2 = blocker === "allowance" ? (Math.floor(Date.now() / 864e5) + 1) * 864e5 : Date.now() + (deps.syncBackoff ?? syncBackoff)(attempt2);
185189
+ checkpoint.syncRetry = { step, attempt: attempt2, at: at2 };
185190
+ if (blocker && checkpoint.taskRecovery?.code !== blocker) await recoveryState({ code: blocker, at: at2 });
185191
+ else persist();
184796
185192
  }
184797
185193
  return syncStopped;
184798
185194
  };
@@ -184807,7 +185203,26 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184807
185203
  if (stream2?.asked()) return finishClaimed("stopped");
184808
185204
  return finishClaimed("failed", allowed2.ok ? "\u9879\u76EE\u76EE\u5F55\u6388\u6743\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u786E\u8BA4\u540E\u91CD\u8BD5\u3002" : syncRefusal(job, allowed2));
184809
185205
  };
184810
- const allowed = await authorize();
185206
+ let allowed = await authorize();
185207
+ if (job.flow && job.flow.verb !== "discard") {
185208
+ const stream2 = watching();
185209
+ let code;
185210
+ while (!stream2.asked() && !stream2.lost()) {
185211
+ if (allowed.ok && (!allowed.value || job.task && (!job.projectDir || "refused" in folderFor(job)))) code = "folder";
185212
+ else if (allowed.ok && !checkpoint.completed && !checkpoint.flowRun?.finished && (await deps.runtimes()).some((r2) => r2.name === job.runtime && r2.installed && r2.loggedIn === false)) code = "login";
185213
+ else break;
185214
+ if (checkpoint.taskRecovery?.code !== code || code === "folder" && !job.projectDir) await recoveryState({ code });
185215
+ let timer;
185216
+ await Promise.race([new Promise((resolve2) => {
185217
+ timer = setTimeout(resolve2, (deps.syncBackoff ?? syncBackoff)(6));
185218
+ }), stream2.whenAsked]);
185219
+ clearTimeout(timer);
185220
+ if (stream2.asked() || stream2.lost()) break;
185221
+ allowed = await authorize();
185222
+ }
185223
+ if (stream2.asked() || stream2.lost()) return unauthorized(allowed);
185224
+ if (code) await recoveryState(null);
185225
+ }
184811
185226
  if (!allowed.ok || !allowed.value) return unauthorized(allowed);
184812
185227
  if (job.secret) return runSecret(job, deps);
184813
185228
  if (job.test) return runTest(job, deps, lease);
@@ -184845,6 +185260,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184845
185260
  Object.assign(lease, requestedAt);
184846
185261
  }
184847
185262
  if (recovering && !pendingRetry) {
185263
+ if (job.flow && !checkpoint.syncRetry) await recoveryState({ code: "recovering", attempt: checkpoint.boardRepair ? 2 : 1 });
184848
185264
  let requestedAt = leaseNow();
184849
185265
  const renewed = await sync("authorize", () => {
184850
185266
  requestedAt = leaseNow();
@@ -184883,7 +185299,9 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184883
185299
  return finishClaimed("failed", pushed.conflict ? `Board content conflicts remain unresolved: ${records.map((r2) => r2.id).join(", ")}. Contents and resolution drafts are preserved.` : pushed.error, completed);
184884
185300
  }
184885
185301
  const session = report2.session ?? checkpoint.session;
184886
- if (job.review && !session) return finishClaimed("failed", pushed.error, completed);
185302
+ if ((job.review || checkpoint.completed && job.flow) && !session) {
185303
+ return finishClaimed("failed", pushed.conflict ? "Board content conflicts could not be resolved. Saved work was preserved." : pushed.error, completed);
185304
+ }
184887
185305
  const requestedAt = leaseNow();
184888
185306
  const renewed = await deps.api.renewJob(deps.machineId, id2);
184889
185307
  if (!renewed.ok || !renewed.value.renewed || !held4(deps, lease)) return;
@@ -184940,7 +185358,9 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
184940
185358
  ws = openTaskFolder({ ...job, task }, folder2?.cwd ?? null);
184941
185359
  cwd = ws.cwd;
184942
185360
  keep2(cwd);
184943
- if (usesBoardRun(job, checkpoint) && !await recoverBoard(ws)) return finishClaimed("failed", recoveryBlocked(job));
185361
+ if (usesBoardRun(job, checkpoint) && !await recoverBoard(ws)) {
185362
+ return finishClaimed("failed", job.flow?.historical_conflict ? "Board content conflicts could not be resolved. Saved work was preserved." : recoveryBlocked(job));
185363
+ }
184944
185364
  if (!job.flow && !job.review && !checkpoint.completed) {
184945
185365
  const pulled = await sync("prepare", () => pull(
184946
185366
  ws,
@@ -185160,7 +185580,31 @@ ${prompt}` : prompt;
185160
185580
  return savedGoals ? { ...said2, goals: savedGoals, goalsVersion: job.discussion?.version } : said2;
185161
185581
  };
185162
185582
  track(stream.stop);
185163
- const io = { show: stream.out, event: remember, track: stream.adopt, onStop: stream.onStop, lost: stream.lost, asked: stream.asked, sync, starting, flowRun: checkpoint.flowRun };
185583
+ const io = {
185584
+ repairDelivery: !!checkpoint.boardRepair && checkpoint.boardRepair.run === checkpoint.flowRun?.id,
185585
+ diagnostic: checkpoint.boardRepair?.reason,
185586
+ show: stream.out,
185587
+ event: remember,
185588
+ track: stream.adopt,
185589
+ onStop: stream.onStop,
185590
+ lost: stream.lost,
185591
+ asked: stream.asked,
185592
+ sync,
185593
+ syncBackoff: deps.syncBackoff,
185594
+ reconcileRetry: {
185595
+ get: () => checkpoint.reconcileRetry,
185596
+ set: (next) => {
185597
+ if (next) checkpoint.reconcileRetry = next;
185598
+ else delete checkpoint.reconcileRetry;
185599
+ persist();
185600
+ }
185601
+ },
185602
+ starting: async () => {
185603
+ if (checkpoint.taskRecovery?.code === "recovering") await recoveryState(null);
185604
+ if (!stream.lost() && !stream.asked()) starting();
185605
+ },
185606
+ flowRun: checkpoint.flowRun
185607
+ };
185164
185608
  if (job.review) {
185165
185609
  for (const task2 of job.review.tasks) {
185166
185610
  const chat = await sync("prepare", () => deps.api.readChat(task2));
@@ -185194,19 +185638,40 @@ ${prompt}` : prompt;
185194
185638
  return !stream.lost() ? sendResult(ended3.report, () => markReviewed2(marks)) : void 0;
185195
185639
  }
185196
185640
  if (!run3) {
185197
- const ended3 = await runFlow(job, ws, deps, io);
185198
- if (ended3.ok) complete("done", ended3.report);
185199
- const stopped3 = !ended3.ok && (stream.asked() || ended3.stopped === true);
185641
+ let result = await runFlow(job, ws, deps, io);
185642
+ if (!result.ok && result.failure?.code === "delivery_incomplete" && !checkpoint.boardRepair && !stream.asked() && !stream.lost()) {
185643
+ const saved = await flowRunEvidence(ws, job, deps, id2, checkpoint.flowRun);
185644
+ if (saved.stopped && saved.run?.finished && await stream.confirmed()) {
185645
+ checkpoint.flowRun = saved.run;
185646
+ checkpoint.boardRepair = { reason: result.failure.reason, run: saved.run.id };
185647
+ await recoveryState({ code: "recovering", attempt: 2 });
185648
+ io.flowRun = saved.run;
185649
+ io.repairDelivery = true;
185650
+ io.diagnostic = checkpoint.boardRepair.reason;
185651
+ result = await runFlow(job, ws, deps, io);
185652
+ }
185653
+ }
185654
+ if (result.ok) complete("done", result.report);
185655
+ const stopped3 = !result.ok && (stream.asked() || result.stopped === true);
185200
185656
  if (stopped3 && stream.asked()) await stream.halted();
185201
- if (!ended3.ok) await stream.end();
185657
+ if (!result.ok) {
185658
+ if (result.failure?.code === "retry_exhausted") stream.event({ kind: "error", data: { text: result.reason } });
185659
+ await stream.end();
185660
+ }
185202
185661
  if (stream.lost()) return;
185203
185662
  const boardStopped = await confirmFlowStopped(ws, job, deps);
185204
185663
  const evidence2 = job.handoff?.action === "continue" || job.handoff?.action === "restart" ? progressEvidence(job, ws.cwd) : null;
185205
185664
  const proof = boardStopped && await stream.confirmed() ? { processesStopped: true, ...evidence2 ? { evidence: evidence2 } : {} } : {};
185206
- if (ended3.ok) complete("done", { ...ended3.report, ...proof });
185207
- if (stopped3) return finishClaimed("stopped", "", proof);
185208
- if (!ended3.ok) return finishClaimed("failed", ended3.reason, proof);
185209
- return sendResult({ ...ended3.report, ...proof }, () => keepChat(job, ended3.report.reply));
185665
+ if (result.ok) complete("done", { ...result.report, ...proof });
185666
+ if (stopped3) return finishClaimed("stopped", "", { ...result.report, ...proof });
185667
+ if (!result.ok) {
185668
+ const reason = result.failure?.code === "retry_exhausted" ? "task_retry_exhausted: " + result.reason : result.reason;
185669
+ const report3 = { ...result.report, ...proof };
185670
+ complete("failed", report3, reason);
185671
+ return finishClaimed("failed", reason, report3);
185672
+ }
185673
+ const report2 = result.report;
185674
+ return sendResult({ ...report2, ...proof }, () => keepChat(job, report2.reply));
185210
185675
  }
185211
185676
  const launchAttempt = (plan3) => {
185212
185677
  checkpoint.managedProcess = plan3.managedProcess;
@@ -185523,6 +185988,7 @@ async function finish(deps, id2, lease, outcome, reason = "", report2) {
185523
185988
  async function sendBack(job, deps, lease, ws, report2, sync, stream, landed, repair, confirm) {
185524
185989
  const result = await sync("publish", async () => {
185525
185990
  const pushed2 = await push(ws, { id: job.id, machineId: deps.machineId }, () => stream.asked() || stream.lost());
185991
+ if (!pushed2.ok && job.flow && syncWaitCode(pushed2)) return pushed2;
185526
185992
  return !pushed2.ok && pushed2.offline ? { ok: false, error: pushed2.error } : { ok: true, value: pushed2 };
185527
185993
  });
185528
185994
  const pushed = result.ok ? result.value : result;
@@ -185559,8 +186025,8 @@ async function runTest(job, deps, lease) {
185559
186025
  const report2 = (await deps.runtimes()).find((r2) => r2.name === job.runtime);
185560
186026
  if (!report2?.installed) return finish2("failed", "not_installed");
185561
186027
  if (report2.loggedIn === false) return finish2("failed", "signed_out");
185562
- const cwd = path52.join(ownFolder(), "test");
185563
- fs47.mkdirSync(cwd, { recursive: true });
186028
+ const cwd = path53.join(ownFolder(), "test");
186029
+ fs48.mkdirSync(cwd, { recursive: true });
185564
186030
  const run3 = deps.plan(job.runtime, job.prompt, cwd, null, job.model, settingsOf(job));
185565
186031
  const startedAt = Date.now();
185566
186032
  if (run3.converse) {
@@ -185649,22 +186115,22 @@ ${undrawn2.map((l2) => `- ${l2}`).join("\n")}` : "");
185649
186115
 
185650
186116
  // src/flow-worker.ts
185651
186117
  var FLOW_MARK = "WILDCRANE_FLOW_WORKER";
185652
- var directory2 = () => path53.join(runnerHome(), "flow-workers");
185653
- var fileOf3 = (id2) => path53.join(directory2(), `${encodeURIComponent(id2)}.json`);
186118
+ var directory2 = () => path54.join(runnerHome(), "flow-workers");
186119
+ var fileOf3 = (id2) => path54.join(directory2(), `${encodeURIComponent(id2)}.json`);
185654
186120
  var stopFile = (id2) => `${fileOf3(id2)}.stop`;
185655
186121
  var flowWorkerEntry = fileURLToPath4(new URL("./flow-worker-main.mjs", import.meta.url));
185656
186122
  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;
185657
186123
  function read4(id2) {
185658
186124
  try {
185659
- return JSON.parse(fs48.readFileSync(fileOf3(id2), "utf8"));
186125
+ return JSON.parse(fs49.readFileSync(fileOf3(id2), "utf8"));
185660
186126
  } catch {
185661
186127
  return null;
185662
186128
  }
185663
186129
  }
185664
186130
  function save2(worker) {
185665
186131
  const file3 = fileOf3(worker.id);
185666
- fs48.writeFileSync(`${file3}.${process.pid}.tmp`, JSON.stringify(worker), { mode: 384 });
185667
- fs48.renameSync(`${file3}.${process.pid}.tmp`, file3);
186132
+ fs49.writeFileSync(`${file3}.${process.pid}.tmp`, JSON.stringify(worker), { mode: 384 });
186133
+ fs49.renameSync(`${file3}.${process.pid}.tmp`, file3);
185668
186134
  }
185669
186135
  function writerStopped(worker) {
185670
186136
  if (!Number.isSafeInteger(worker.pid) || worker.pid <= 0 || pidAlive(worker.pid)) return false;
@@ -185721,7 +186187,7 @@ async function reclaimFlowWorkers(machine, given, only) {
185721
186187
  const sweep = async () => {
185722
186188
  let names2;
185723
186189
  try {
185724
- names2 = only ? [`${encodeURIComponent(only)}.json`] : fs48.readdirSync(directory2());
186190
+ names2 = only ? [`${encodeURIComponent(only)}.json`] : fs49.readdirSync(directory2());
185725
186191
  } catch {
185726
186192
  return;
185727
186193
  }
@@ -185729,8 +186195,8 @@ async function reclaimFlowWorkers(machine, given, only) {
185729
186195
  if (!valid()) break;
185730
186196
  if (!name.endsWith(".json")) continue;
185731
186197
  try {
185732
- const file3 = path53.join(directory2(), name);
185733
- const original = fs48.readFileSync(file3, "utf8");
186198
+ const file3 = path54.join(directory2(), name);
186199
+ const original = fs49.readFileSync(file3, "utf8");
185734
186200
  const worker = JSON.parse(original);
185735
186201
  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;
185736
186202
  if (!writerStopped(worker)) {
@@ -185740,8 +186206,8 @@ async function reclaimFlowWorkers(machine, given, only) {
185740
186206
  const release2 = tryLock(`${file3}.lock`);
185741
186207
  if (!release2) continue;
185742
186208
  try {
185743
- if (fs48.readFileSync(file3, "utf8") !== original) continue;
185744
- const queried = tryLock(path53.join(directory2(), ".lookup.lock"));
186209
+ if (fs49.readFileSync(file3, "utf8") !== original) continue;
186210
+ const queried = tryLock(path54.join(directory2(), ".lookup.lock"));
185745
186211
  if (!queried) continue;
185746
186212
  const remote2 = await readJob(worker.id).finally(queried);
185747
186213
  if (!valid()) break;
@@ -185767,10 +186233,10 @@ async function reclaimFlowWorkers(machine, given, only) {
185767
186233
  } else if (job.state !== "finished" && !(job.state === "waiting" && readCheckpoint(job.id)?.updating)) continue;
185768
186234
  if (!worker.markedAt) {
185769
186235
  const job2 = remote2.value.job;
185770
- const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path53.join(runnerHome(), "work", job2.id) };
186236
+ const folder2 = job2.projectDir ? folderFor(job2) : { cwd: path54.join(runnerHome(), "work", job2.id) };
185771
186237
  if ("refused" in folder2 || !job2.task || !job2.project) continue;
185772
- const board = path53.join(folder2.cwd, ".akb", "kanban");
185773
- if (!fs48.existsSync(board)) continue;
186238
+ const board = path54.join(folder2.cwd, ".akb", "kanban");
186239
+ if (!fs49.existsSync(board)) continue;
185774
186240
  const deps = given ?? defaultDeps(machine);
185775
186241
  if (!await confirmFlowStopped(
185776
186242
  {
@@ -185788,10 +186254,10 @@ async function reclaimFlowWorkers(machine, given, only) {
185788
186254
  const checkpoint = readCheckpoint(worker.id);
185789
186255
  if (checkpoint && (!checkpoint.mark || !processesStopped(checkpoint.mark, checkpoint.process))) continue;
185790
186256
  }
185791
- if (!writerStopped(worker) || !valid() || fs48.readFileSync(file3, "utf8") !== original) continue;
185792
- fs48.rmSync(`${file3}.log`, { force: true });
185793
- fs48.rmSync(`${file3}.stop`, { force: true });
185794
- fs48.unlinkSync(file3);
186257
+ if (!writerStopped(worker) || !valid() || fs49.readFileSync(file3, "utf8") !== original) continue;
186258
+ fs49.rmSync(`${file3}.log`, { force: true });
186259
+ fs49.rmSync(`${file3}.stop`, { force: true });
186260
+ fs49.unlinkSync(file3);
185795
186261
  if (job.state === "finished" && job.outcome === "done") clearCheckpoint(job.id);
185796
186262
  } finally {
185797
186263
  release2();
@@ -185816,14 +186282,14 @@ async function runFlowWorker(id2, token, given, entry = flowWorkerEntry) {
185816
186282
  await halt?.();
185817
186283
  };
185818
186284
  const release2 = executorRecord();
185819
- const keepVersion = hold(path53.resolve(path53.dirname(fileURLToPath4(import.meta.url)), ".."));
186285
+ const keepVersion = hold(path54.resolve(path54.dirname(fileURLToPath4(import.meta.url)), ".."));
185820
186286
  worker.pid = process.pid;
185821
186287
  worker.processAt = Date.now();
185822
186288
  save2(worker);
185823
186289
  const timer = setInterval(() => {
185824
186290
  let asked = false;
185825
186291
  try {
185826
- asked = fs48.readFileSync(stopFile(id2), "utf8") === token;
186292
+ asked = fs49.readFileSync(stopFile(id2), "utf8") === token;
185827
186293
  } catch {
185828
186294
  }
185829
186295
  if (!valid() || asked) void stop2();