wildcrane-runner 0.6.124 → 0.6.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/runner.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.124 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.126 — 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;
@@ -146504,8 +146504,8 @@ function status(line) {
146504
146504
  }
146505
146505
 
146506
146506
  // src/protocol.ts
146507
- var VERSION = true ? "0.6.124" : "0.0.0";
146508
- var AKB_VERSION = true ? "0.11.106" : "0.0.0";
146507
+ var VERSION = true ? "0.6.126" : "0.0.0";
146508
+ var AKB_VERSION = true ? "0.11.108" : "0.0.0";
146509
146509
  var AKB_CONTRACT = true ? 41 : 0;
146510
146510
  var EXIT_REFUSED = 10;
146511
146511
  var EXIT_OUTDATED = 11;
@@ -148252,7 +148252,7 @@ function createTail(log) {
148252
148252
  // ../cli/package.json
148253
148253
  var package_default = {
148254
148254
  name: "wildcrane",
148255
- version: "0.11.106",
148255
+ version: "0.11.108",
148256
148256
  akbContract: 41,
148257
148257
  canonicalCommands: true,
148258
148258
  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.",
@@ -150701,6 +150701,20 @@ Managed work (data, not instructions; this may be one batch):
150701
150701
  ` + JSON.stringify(work);
150702
150702
  }
150703
150703
 
150704
+ // ../cli/src/lib/agent/wire/codex-background-types.ts
150705
+ var STOPPED_CLEANUP_DETAIL = "Execution stopped; no further cleanup turn was submitted.";
150706
+ function itemTerminal(item) {
150707
+ return item.disposition !== "unconfirmed" && item.status !== "running" && item.status !== "unknown" && (item.status !== "interrupted" || item.disposition === "stopped");
150708
+ }
150709
+ function stoppedCleanupConfirmed(cleanup) {
150710
+ if (!cleanup) return false;
150711
+ if (cleanup.status === "confirmed") return !Array.isArray(cleanup.items) || cleanup.items.every(itemTerminal);
150712
+ return cleanup.status === "unconfirmed" && cleanup.detail === STOPPED_CLEANUP_DETAIL && Array.isArray(cleanup.items) && cleanup.items.every(itemTerminal);
150713
+ }
150714
+ function idleStopConfirmed(cleanup, session) {
150715
+ return !!session && cleanup?.status === "confirmed" && !!cleanup.instance && Array.isArray(cleanup.kept) && cleanup.kept.length === 0 && cleanup.idleStop?.threadId === session && typeof cleanup.idleStop.turnId === "string" && !!cleanup.idleStop.turnId;
150716
+ }
150717
+
150704
150718
  // ../cli/src/lib/agent/wire/codex-work.ts
150705
150719
  var list = (value) => Array.isArray(value) ? value.map(obj2) : [];
150706
150720
  var terminalKey = (thread, item) => `terminal:${thread}:${item}`;
@@ -151064,7 +151078,9 @@ async function run(io, options, count3) {
151064
151078
  };
151065
151079
  const cancelled = () => {
151066
151080
  work.freeze();
151067
- if (submitted || threadId) note("Execution stopped; no further cleanup turn was submitted.");
151081
+ if (submitted && !started || [...work.entries.values()].some((w2) => !itemTerminal(w2))) {
151082
+ note(STOPPED_CLEANUP_DETAIL);
151083
+ }
151068
151084
  end2("Codex execution stopped.");
151069
151085
  };
151070
151086
  io.signal?.addEventListener("abort", cancelled, { once: true });
@@ -153979,14 +153995,48 @@ function keepSecrets(runtime, given) {
153979
153995
  }
153980
153996
  var secretsSet = () => Object.fromEntries(Object.entries(readAll()).map(([id2, keys]) => [id2, Object.keys(keys)]));
153981
153997
 
153998
+ // src/sync-debug.ts
153999
+ import { monitorEventLoopDelay } from "node:perf_hooks";
154000
+ var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
154001
+ var counts = {};
154002
+ function countSync(name, amount = 1) {
154003
+ if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
154004
+ }
154005
+ function logSync(event2, fields2 = {}) {
154006
+ if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
154007
+ }
154008
+ if (syncDebug) {
154009
+ const delay5 = monitorEventLoopDelay({ resolution: 20 });
154010
+ delay5.enable();
154011
+ let cpu = process.cpuUsage();
154012
+ let at2 = performance.now();
154013
+ setInterval(() => {
154014
+ const now = performance.now();
154015
+ const used = process.cpuUsage(cpu);
154016
+ logSync("health", {
154017
+ cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
154018
+ delayMaxMs: Math.round(delay5.max / 1e6),
154019
+ delayP99Ms: Math.round(delay5.percentile(99) / 1e6),
154020
+ ...counts
154021
+ });
154022
+ for (const name of Object.keys(counts)) delete counts[name];
154023
+ cpu = process.cpuUsage();
154024
+ at2 = now;
154025
+ delay5.reset();
154026
+ }, 5e3).unref();
154027
+ }
154028
+
153982
154029
  // src/api.ts
153983
154030
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok", "antigravity"];
153984
154031
  var PROTOCOL = 33;
153985
154032
  var TIMEOUT_MS = 2e4;
153986
154033
  async function send(method, route, body, signedIn, ms, type, extra = {}) {
154034
+ const started = performance.now();
154035
+ const endpoint = route.split("?")[0];
153987
154036
  const headers = { accept: "application/json", ...extra };
153988
154037
  if (signedIn) {
153989
154038
  const token = await accessToken();
154039
+ logSync("http.auth", { method, endpoint, ms: Math.round(performance.now() - started), ok: token.ok });
153990
154040
  if (!token.ok) {
153991
154041
  return token.reason === "unreachable" ? { ok: false, error: token.error } : { ok: false, error: "Sign in again.", code: "unauthenticated" };
153992
154042
  }
@@ -154001,8 +154051,10 @@ async function send(method, route, body, signedIn, ms, type, extra = {}) {
154001
154051
  body: body === void 0 ? void 0 : raw ? body : JSON.stringify(body),
154002
154052
  signal: AbortSignal.timeout(ms)
154003
154053
  });
154054
+ logSync("http.headers", { method, endpoint, ms: Math.round(performance.now() - started), status: response.status });
154004
154055
  return { ok: true, value: response };
154005
154056
  } catch (e2) {
154057
+ logSync("http.failed", { method, endpoint, ms: Math.round(performance.now() - started) });
154006
154058
  return { ok: false, error: e2 instanceof Error ? e2.message : String(e2) };
154007
154059
  }
154008
154060
  }
@@ -154020,8 +154072,11 @@ async function answerOf(response) {
154020
154072
  };
154021
154073
  }
154022
154074
  async function request(method, route, body, signedIn = true) {
154075
+ const started = performance.now();
154023
154076
  const sent = await send(method, route, body, signedIn, TIMEOUT_MS);
154024
- return sent.ok ? answerOf(sent.value) : sent;
154077
+ const result = sent.ok ? await answerOf(sent.value) : sent;
154078
+ logSync("http.done", { method, endpoint: route.split("?")[0], ms: Math.round(performance.now() - started), ok: result.ok });
154079
+ return result;
154025
154080
  }
154026
154081
  var FILE_TIMEOUT_MS = 10 * 6e4;
154027
154082
  async function download(route, studioBytes) {
@@ -155482,6 +155537,11 @@ function numberOfCard(path90) {
155482
155537
  const n = ROOT.exec(path90)?.[1] ?? CARD.exec(path90)?.[1];
155483
155538
  return n ? Number(n) : null;
155484
155539
  }
155540
+ function groupOfCard(path90) {
155541
+ if (ROOT.test(path90) || !CARD.test(path90)) return null;
155542
+ const folder2 = /(?:^|\/)(\d+)-[^/]+\/[^/]+$/.exec(path90)?.[1];
155543
+ return folder2 ? Number(folder2) : null;
155544
+ }
155485
155545
  var assetsFile = (task) => `assets/${task}.json`;
155486
155546
  var taskOfAssets = (path90) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path90)?.[1] ?? null;
155487
155547
  var studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
@@ -157335,11 +157395,18 @@ function readLandArchiveOwner(file3) {
157335
157395
  const saved = fs40.readFileSync(file3, "utf8");
157336
157396
  if (/^[\w-]{1,100}$/.test(saved)) return { job: saved };
157337
157397
  const owner2 = JSON.parse(saved);
157338
- return typeof owner2?.job === "string" && owner2.job.trim() && Number.isSafeInteger(owner2.number) && owner2.number > 0 ? { job: owner2.job, number: owner2.number } : null;
157398
+ const validJob = owner2?.job === null || typeof owner2?.job === "string" && !!owner2.job.trim();
157399
+ return validJob && Number.isSafeInteger(owner2?.number) && owner2.number > 0 ? { job: owner2.job, number: owner2.number } : null;
157339
157400
  } catch {
157340
157401
  return null;
157341
157402
  }
157342
157403
  }
157404
+ function writeLandArchiveOwner(file3, owner2) {
157405
+ fs40.mkdirSync(path42.dirname(file3), { recursive: true });
157406
+ const tmp = `${file3}.${process.pid}.tmp`;
157407
+ fs40.writeFileSync(tmp, JSON.stringify(owner2));
157408
+ fs40.renameSync(tmp, file3);
157409
+ }
157343
157410
  function landArchiveOwners(board, pending) {
157344
157411
  const dir = markerDirectory(board);
157345
157412
  let entries;
@@ -158945,6 +159012,9 @@ var CSS = {
158945
159012
  references: [{ web: "css" }]
158946
159013
  };
158947
159014
  var fileManifest = (type, name) => type === "asset" && /\.css$/i.test(name) ? CSS : manifestOf(type);
159015
+ function encodeFileReferencePath(parts) {
159016
+ return parts.map((part) => encodeURIComponent(part).replace(/[!'()*]/g, (char) => "%" + char.charCodeAt(0).toString(16))).join("/");
159017
+ }
158948
159018
  function splitFileReference(src) {
158949
159019
  const end2 = src.search(/[?#]/);
158950
159020
  return end2 < 0 ? [src, ""] : [src.slice(0, end2), src.slice(end2)];
@@ -159286,7 +159356,7 @@ import path47 from "node:path";
159286
159356
  // ../cli/src/lib/agent/runtime-context.ts
159287
159357
  import { createHash as createHash8 } from "node:crypto";
159288
159358
 
159289
- // ../cli/node_modules/zod/v4/classic/external.js
159359
+ // node_modules/zod/v4/classic/external.js
159290
159360
  var external_exports = {};
159291
159361
  __export(external_exports, {
159292
159362
  $brand: () => $brand,
@@ -159549,7 +159619,7 @@ __export(external_exports, {
159549
159619
  xor: () => xor
159550
159620
  });
159551
159621
 
159552
- // ../cli/node_modules/zod/v4/core/index.js
159622
+ // node_modules/zod/v4/core/index.js
159553
159623
  var core_exports2 = {};
159554
159624
  __export(core_exports2, {
159555
159625
  $ZodAny: () => $ZodAny,
@@ -159866,7 +159936,7 @@ __export(core_exports2, {
159866
159936
  withParser: () => withParser
159867
159937
  });
159868
159938
 
159869
- // ../cli/node_modules/zod/v4/core/util.js
159939
+ // node_modules/zod/v4/core/util.js
159870
159940
  var util_exports = {};
159871
159941
  __export(util_exports, {
159872
159942
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
@@ -160722,7 +160792,7 @@ function constantCatch(value) {
160722
160792
  return fn2;
160723
160793
  }
160724
160794
 
160725
- // ../cli/node_modules/zod/v4/core/core.js
160795
+ // node_modules/zod/v4/core/core.js
160726
160796
  var _a;
160727
160797
  var NEVER = /* @__PURE__ */ Object.freeze({
160728
160798
  status: "aborted"
@@ -160844,7 +160914,7 @@ function config(newConfig) {
160844
160914
  return globalConfig;
160845
160915
  }
160846
160916
 
160847
- // ../cli/node_modules/zod/v4/core/errors.js
160917
+ // node_modules/zod/v4/core/errors.js
160848
160918
  function _getMessage() {
160849
160919
  const internals = this._zod;
160850
160920
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -161036,7 +161106,7 @@ function prettifyError(error62) {
161036
161106
  return lines.join("\n");
161037
161107
  }
161038
161108
 
161039
- // ../cli/node_modules/zod/v4/core/parse.js
161109
+ // node_modules/zod/v4/core/parse.js
161040
161110
  function finalizeParams(callee, params) {
161041
161111
  return { callee: params?.callee ?? callee, Err: params?.Err };
161042
161112
  }
@@ -161196,7 +161266,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
161196
161266
  };
161197
161267
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
161198
161268
 
161199
- // ../cli/node_modules/zod/v4/core/regexes.js
161269
+ // node_modules/zod/v4/core/regexes.js
161200
161270
  var regexes_exports = {};
161201
161271
  __export(regexes_exports, {
161202
161272
  anyString: () => anyString,
@@ -161368,7 +161438,7 @@ var sha512_hex = /^[0-9a-fA-F]{128}$/;
161368
161438
  var sha512_base64 = /* @__PURE__ */ fixedBase64(86, "==");
161369
161439
  var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
161370
161440
 
161371
- // ../cli/node_modules/zod/v4/core/checks.js
161441
+ // node_modules/zod/v4/core/checks.js
161372
161442
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
161373
161443
  var _a4;
161374
161444
  inst._zod ?? (inst._zod = {});
@@ -161844,7 +161914,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
161844
161914
  };
161845
161915
  });
161846
161916
 
161847
- // ../cli/node_modules/zod/v4/core/doc.js
161917
+ // node_modules/zod/v4/core/doc.js
161848
161918
  var Doc = class {
161849
161919
  constructor(args2 = [], closed = {}) {
161850
161920
  this.content = [];
@@ -161885,14 +161955,14 @@ ${content.join("\n")}
161885
161955
  }
161886
161956
  };
161887
161957
 
161888
- // ../cli/node_modules/zod/v4/core/versions.js
161958
+ // node_modules/zod/v4/core/versions.js
161889
161959
  var version = {
161890
161960
  major: 4,
161891
161961
  minor: 6,
161892
161962
  patch: 7
161893
161963
  };
161894
161964
 
161895
- // ../cli/node_modules/zod/v4/core/schemas.js
161965
+ // node_modules/zod/v4/core/schemas.js
161896
161966
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
161897
161967
  var _a4;
161898
161968
  inst ?? (inst = {});
@@ -164334,7 +164404,7 @@ function handleRefineResult(result, payload, input2, inst) {
164334
164404
  }
164335
164405
  }
164336
164406
 
164337
- // ../cli/node_modules/zod/v4/core/memoizer.js
164407
+ // node_modules/zod/v4/core/memoizer.js
164338
164408
  var $ZodCyclicError = class extends Error {
164339
164409
  constructor() {
164340
164410
  super(`Cannot parse a reference cycle that closes through a transform`);
@@ -164611,7 +164681,7 @@ function isBackEdge(ctx, value) {
164611
164681
  return backEdges !== void 0 && isRef(value) && backEdges.has(value);
164612
164682
  }
164613
164683
 
164614
- // ../cli/node_modules/zod/v4/locales/index.js
164684
+ // node_modules/zod/v4/locales/index.js
164615
164685
  var locales_exports = {};
164616
164686
  __export(locales_exports, {
164617
164687
  ar: () => ar_default,
@@ -164679,7 +164749,7 @@ __export(locales_exports, {
164679
164749
  zhTW: () => zh_TW_default
164680
164750
  });
164681
164751
 
164682
- // ../cli/node_modules/zod/v4/locales/ar.js
164752
+ // node_modules/zod/v4/locales/ar.js
164683
164753
  var error = () => {
164684
164754
  const Sizable = {
164685
164755
  string: { unit: "\u062D\u0631\u0641", verb: "\u0623\u0646 \u064A\u062D\u0648\u064A" },
@@ -164791,7 +164861,7 @@ function ar_default() {
164791
164861
  };
164792
164862
  }
164793
164863
 
164794
- // ../cli/node_modules/zod/v4/locales/az.js
164864
+ // node_modules/zod/v4/locales/az.js
164795
164865
  var error2 = () => {
164796
164866
  const Sizable = {
164797
164867
  string: { unit: "simvol", verb: "olmal\u0131d\u0131r" },
@@ -164902,7 +164972,7 @@ function az_default() {
164902
164972
  };
164903
164973
  }
164904
164974
 
164905
- // ../cli/node_modules/zod/v4/locales/be.js
164975
+ // node_modules/zod/v4/locales/be.js
164906
164976
  function getBelarusianPlural(count3, one, few, many) {
164907
164977
  const absCount = Math.abs(count3);
164908
164978
  const lastDigit = absCount % 10;
@@ -165071,7 +165141,7 @@ function be_default() {
165071
165141
  };
165072
165142
  }
165073
165143
 
165074
- // ../cli/node_modules/zod/v4/locales/bg.js
165144
+ // node_modules/zod/v4/locales/bg.js
165075
165145
  var error4 = () => {
165076
165146
  const Sizable = {
165077
165147
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0430", verb: "\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430" },
@@ -165197,7 +165267,7 @@ function bg_default() {
165197
165267
  };
165198
165268
  }
165199
165269
 
165200
- // ../cli/node_modules/zod/v4/locales/bn.js
165270
+ // node_modules/zod/v4/locales/bn.js
165201
165271
  var error5 = () => {
165202
165272
  const Sizable = {
165203
165273
  string: { unit: "\u0985\u0995\u09CD\u09B7\u09B0", verb: "\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7" },
@@ -165311,7 +165381,7 @@ function bn_default() {
165311
165381
  };
165312
165382
  }
165313
165383
 
165314
- // ../cli/node_modules/zod/v4/locales/ca.js
165384
+ // node_modules/zod/v4/locales/ca.js
165315
165385
  var error6 = () => {
165316
165386
  const Sizable = {
165317
165387
  string: { unit: "car\xE0cters", verb: "contenir" },
@@ -165425,7 +165495,7 @@ function ca_default() {
165425
165495
  };
165426
165496
  }
165427
165497
 
165428
- // ../cli/node_modules/zod/v4/locales/ckb.js
165498
+ // node_modules/zod/v4/locales/ckb.js
165429
165499
  var error7 = () => {
165430
165500
  const Sizable = {
165431
165501
  string: { unit: "\u067E\u06CC\u062A", verb: "\u0628\u06CE\u062A" },
@@ -165558,7 +165628,7 @@ function ckb_default() {
165558
165628
  };
165559
165629
  }
165560
165630
 
165561
- // ../cli/node_modules/zod/v4/locales/cs.js
165631
+ // node_modules/zod/v4/locales/cs.js
165562
165632
  var error8 = () => {
165563
165633
  const Sizable = {
165564
165634
  string: { unit: "znak\u016F", verb: "m\xEDt" },
@@ -165675,7 +165745,7 @@ function cs_default() {
165675
165745
  };
165676
165746
  }
165677
165747
 
165678
- // ../cli/node_modules/zod/v4/locales/da.js
165748
+ // node_modules/zod/v4/locales/da.js
165679
165749
  var error9 = () => {
165680
165750
  const Sizable = {
165681
165751
  string: { unit: "tegn", verb: "havde" },
@@ -165796,7 +165866,7 @@ function da_default() {
165796
165866
  };
165797
165867
  }
165798
165868
 
165799
- // ../cli/node_modules/zod/v4/locales/de.js
165869
+ // node_modules/zod/v4/locales/de.js
165800
165870
  var error10 = () => {
165801
165871
  const Sizable = {
165802
165872
  string: { unit: "Zeichen", verb: "zu haben" },
@@ -165910,7 +165980,7 @@ function de_default() {
165910
165980
  };
165911
165981
  }
165912
165982
 
165913
- // ../cli/node_modules/zod/v4/locales/el.js
165983
+ // node_modules/zod/v4/locales/el.js
165914
165984
  var error11 = () => {
165915
165985
  const Sizable = {
165916
165986
  string: { unit: "\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2", verb: "\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9" },
@@ -166023,7 +166093,7 @@ function el_default() {
166023
166093
  };
166024
166094
  }
166025
166095
 
166026
- // ../cli/node_modules/zod/v4/locales/en.js
166096
+ // node_modules/zod/v4/locales/en.js
166027
166097
  var error12 = () => {
166028
166098
  const Sizable = {
166029
166099
  string: { unit: "characters", verb: "to have" },
@@ -166148,7 +166218,7 @@ function en_default() {
166148
166218
  };
166149
166219
  }
166150
166220
 
166151
- // ../cli/node_modules/zod/v4/locales/eo.js
166221
+ // node_modules/zod/v4/locales/eo.js
166152
166222
  var error13 = () => {
166153
166223
  const Sizable = {
166154
166224
  string: { unit: "karaktrojn", verb: "havi" },
@@ -166263,7 +166333,7 @@ function eo_default() {
166263
166333
  };
166264
166334
  }
166265
166335
 
166266
- // ../cli/node_modules/zod/v4/locales/es.js
166336
+ // node_modules/zod/v4/locales/es.js
166267
166337
  var error14 = () => {
166268
166338
  const Sizable = {
166269
166339
  string: { unit: "caracteres", verb: "tener" },
@@ -166400,7 +166470,7 @@ function es_default() {
166400
166470
  };
166401
166471
  }
166402
166472
 
166403
- // ../cli/node_modules/zod/v4/locales/fa.js
166473
+ // node_modules/zod/v4/locales/fa.js
166404
166474
  var error15 = () => {
166405
166475
  const Sizable = {
166406
166476
  string: { unit: "\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631", verb: "\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F" },
@@ -166520,7 +166590,7 @@ function fa_default() {
166520
166590
  };
166521
166591
  }
166522
166592
 
166523
- // ../cli/node_modules/zod/v4/locales/fi.js
166593
+ // node_modules/zod/v4/locales/fi.js
166524
166594
  var error16 = () => {
166525
166595
  const Sizable = {
166526
166596
  string: { unit: "merkki\xE4", subject: "merkkijonon" },
@@ -166638,7 +166708,7 @@ function fi_default() {
166638
166708
  };
166639
166709
  }
166640
166710
 
166641
- // ../cli/node_modules/zod/v4/locales/fr.js
166711
+ // node_modules/zod/v4/locales/fr.js
166642
166712
  var error17 = () => {
166643
166713
  const Sizable = {
166644
166714
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -166768,7 +166838,7 @@ function fr_default() {
166768
166838
  };
166769
166839
  }
166770
166840
 
166771
- // ../cli/node_modules/zod/v4/locales/fr-CA.js
166841
+ // node_modules/zod/v4/locales/fr-CA.js
166772
166842
  var error18 = () => {
166773
166843
  const Sizable = {
166774
166844
  string: { unit: "caract\xE8res", verb: "avoir" },
@@ -166881,7 +166951,7 @@ function fr_CA_default() {
166881
166951
  };
166882
166952
  }
166883
166953
 
166884
- // ../cli/node_modules/zod/v4/locales/gu.js
166954
+ // node_modules/zod/v4/locales/gu.js
166885
166955
  var error19 = () => {
166886
166956
  const Sizable = {
166887
166957
  string: { unit: "\u0A85\u0A95\u0ACD\u0AB7\u0AB0", verb: "\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F" },
@@ -166995,7 +167065,7 @@ function gu_default() {
166995
167065
  };
166996
167066
  }
166997
167067
 
166998
- // ../cli/node_modules/zod/v4/locales/he.js
167068
+ // node_modules/zod/v4/locales/he.js
166999
167069
  var error20 = () => {
167000
167070
  const TypeNames = {
167001
167071
  string: { label: "\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA", gender: "f" },
@@ -167197,7 +167267,7 @@ function he_default() {
167197
167267
  };
167198
167268
  }
167199
167269
 
167200
- // ../cli/node_modules/zod/v4/locales/hi.js
167270
+ // node_modules/zod/v4/locales/hi.js
167201
167271
  var error21 = () => {
167202
167272
  const Sizable = {
167203
167273
  string: { unit: "\u0905\u0915\u094D\u0937\u0930", verb: "\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F" },
@@ -167309,7 +167379,7 @@ function hi_default() {
167309
167379
  };
167310
167380
  }
167311
167381
 
167312
- // ../cli/node_modules/zod/v4/locales/hr.js
167382
+ // node_modules/zod/v4/locales/hr.js
167313
167383
  var error22 = () => {
167314
167384
  const Sizable = {
167315
167385
  string: { unit: "znakova", verb: "imati" },
@@ -167436,7 +167506,7 @@ function hr_default() {
167436
167506
  };
167437
167507
  }
167438
167508
 
167439
- // ../cli/node_modules/zod/v4/locales/hu.js
167509
+ // node_modules/zod/v4/locales/hu.js
167440
167510
  var error23 = () => {
167441
167511
  const Sizable = {
167442
167512
  string: { unit: "karakter", verb: "legyen" },
@@ -167550,7 +167620,7 @@ function hu_default() {
167550
167620
  };
167551
167621
  }
167552
167622
 
167553
- // ../cli/node_modules/zod/v4/locales/hy.js
167623
+ // node_modules/zod/v4/locales/hy.js
167554
167624
  function getArmenianPlural(count3, one, many) {
167555
167625
  return Math.abs(count3) === 1 ? one : many;
167556
167626
  }
@@ -167709,7 +167779,7 @@ function hy_default() {
167709
167779
  };
167710
167780
  }
167711
167781
 
167712
- // ../cli/node_modules/zod/v4/locales/id.js
167782
+ // node_modules/zod/v4/locales/id.js
167713
167783
  var error25 = () => {
167714
167784
  const Sizable = {
167715
167785
  string: { unit: "karakter", verb: "memiliki" },
@@ -167821,7 +167891,7 @@ function id_default() {
167821
167891
  };
167822
167892
  }
167823
167893
 
167824
- // ../cli/node_modules/zod/v4/locales/is.js
167894
+ // node_modules/zod/v4/locales/is.js
167825
167895
  var error26 = () => {
167826
167896
  const Sizable = {
167827
167897
  string: { unit: "stafi", verb: "a\xF0 hafa" },
@@ -167936,7 +168006,7 @@ function is_default() {
167936
168006
  };
167937
168007
  }
167938
168008
 
167939
- // ../cli/node_modules/zod/v4/locales/it.js
168009
+ // node_modules/zod/v4/locales/it.js
167940
168010
  var error27 = () => {
167941
168011
  const Sizable = {
167942
168012
  string: { unit: "caratteri", verb: "avere" },
@@ -168050,7 +168120,7 @@ function it_default() {
168050
168120
  };
168051
168121
  }
168052
168122
 
168053
- // ../cli/node_modules/zod/v4/locales/ja.js
168123
+ // node_modules/zod/v4/locales/ja.js
168054
168124
  var error28 = () => {
168055
168125
  const Sizable = {
168056
168126
  string: { unit: "\u6587\u5B57", verb: "\u3067\u3042\u308B" },
@@ -168163,7 +168233,7 @@ function ja_default() {
168163
168233
  };
168164
168234
  }
168165
168235
 
168166
- // ../cli/node_modules/zod/v4/locales/ka.js
168236
+ // node_modules/zod/v4/locales/ka.js
168167
168237
  var error29 = () => {
168168
168238
  const Sizable = {
168169
168239
  string: { unit: "\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD", verb: "\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1" },
@@ -168281,7 +168351,7 @@ function ka_default() {
168281
168351
  };
168282
168352
  }
168283
168353
 
168284
- // ../cli/node_modules/zod/v4/locales/km.js
168354
+ // node_modules/zod/v4/locales/km.js
168285
168355
  var error30 = () => {
168286
168356
  const Sizable = {
168287
168357
  string: { unit: "\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A", verb: "\u1782\u17BD\u179A\u1798\u17B6\u1793" },
@@ -168397,12 +168467,12 @@ function km_default() {
168397
168467
  };
168398
168468
  }
168399
168469
 
168400
- // ../cli/node_modules/zod/v4/locales/kh.js
168470
+ // node_modules/zod/v4/locales/kh.js
168401
168471
  function kh_default() {
168402
168472
  return km_default();
168403
168473
  }
168404
168474
 
168405
- // ../cli/node_modules/zod/v4/locales/kn.js
168475
+ // node_modules/zod/v4/locales/kn.js
168406
168476
  var error31 = () => {
168407
168477
  const Sizable = {
168408
168478
  string: { unit: "\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1", verb: "\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1" },
@@ -168518,7 +168588,7 @@ function kn_default() {
168518
168588
  };
168519
168589
  }
168520
168590
 
168521
- // ../cli/node_modules/zod/v4/locales/ko.js
168591
+ // node_modules/zod/v4/locales/ko.js
168522
168592
  var error32 = () => {
168523
168593
  const Sizable = {
168524
168594
  string: { unit: "\uBB38\uC790", verb: "to have" },
@@ -168635,7 +168705,7 @@ function ko_default() {
168635
168705
  };
168636
168706
  }
168637
168707
 
168638
- // ../cli/node_modules/zod/v4/locales/lt.js
168708
+ // node_modules/zod/v4/locales/lt.js
168639
168709
  var capitalizeFirstCharacter = (text4) => {
168640
168710
  return text4.charAt(0).toUpperCase() + text4.slice(1);
168641
168711
  };
@@ -168843,7 +168913,7 @@ function lt_default() {
168843
168913
  };
168844
168914
  }
168845
168915
 
168846
- // ../cli/node_modules/zod/v4/locales/mk.js
168916
+ // node_modules/zod/v4/locales/mk.js
168847
168917
  var error34 = () => {
168848
168918
  const Sizable = {
168849
168919
  string: { unit: "\u0437\u043D\u0430\u0446\u0438", verb: "\u0434\u0430 \u0438\u043C\u0430\u0430\u0442" },
@@ -168958,7 +169028,7 @@ function mk_default() {
168958
169028
  };
168959
169029
  }
168960
169030
 
168961
- // ../cli/node_modules/zod/v4/locales/ms.js
169031
+ // node_modules/zod/v4/locales/ms.js
168962
169032
  var error35 = () => {
168963
169033
  const Sizable = {
168964
169034
  string: { unit: "aksara", verb: "mempunyai" },
@@ -169071,7 +169141,7 @@ function ms_default() {
169071
169141
  };
169072
169142
  }
169073
169143
 
169074
- // ../cli/node_modules/zod/v4/locales/ne.js
169144
+ // node_modules/zod/v4/locales/ne.js
169075
169145
  var error36 = () => {
169076
169146
  const Sizable = {
169077
169147
  string: { unit: "\u0905\u0915\u094D\u0937\u0930", verb: "\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B" },
@@ -169183,7 +169253,7 @@ function ne_default() {
169183
169253
  };
169184
169254
  }
169185
169255
 
169186
- // ../cli/node_modules/zod/v4/locales/nl.js
169256
+ // node_modules/zod/v4/locales/nl.js
169187
169257
  var error37 = () => {
169188
169258
  const Sizable = {
169189
169259
  string: { unit: "tekens", verb: "heeft" },
@@ -169299,7 +169369,7 @@ function nl_default() {
169299
169369
  };
169300
169370
  }
169301
169371
 
169302
- // ../cli/node_modules/zod/v4/locales/nn.js
169372
+ // node_modules/zod/v4/locales/nn.js
169303
169373
  var error38 = () => {
169304
169374
  const Sizable = {
169305
169375
  string: { unit: "teikn", verb: "\xE5 ha" },
@@ -169413,7 +169483,7 @@ function nn_default() {
169413
169483
  };
169414
169484
  }
169415
169485
 
169416
- // ../cli/node_modules/zod/v4/locales/no.js
169486
+ // node_modules/zod/v4/locales/no.js
169417
169487
  var error39 = () => {
169418
169488
  const Sizable = {
169419
169489
  string: { unit: "tegn", verb: "\xE5 ha" },
@@ -169527,7 +169597,7 @@ function no_default() {
169527
169597
  };
169528
169598
  }
169529
169599
 
169530
- // ../cli/node_modules/zod/v4/locales/ota.js
169600
+ // node_modules/zod/v4/locales/ota.js
169531
169601
  var error40 = () => {
169532
169602
  const Sizable = {
169533
169603
  string: { unit: "harf", verb: "olmal\u0131d\u0131r" },
@@ -169642,7 +169712,7 @@ function ota_default() {
169642
169712
  };
169643
169713
  }
169644
169714
 
169645
- // ../cli/node_modules/zod/v4/locales/ps.js
169715
+ // node_modules/zod/v4/locales/ps.js
169646
169716
  var error41 = () => {
169647
169717
  const Sizable = {
169648
169718
  string: { unit: "\u062A\u0648\u06A9\u064A", verb: "\u0648\u0644\u0631\u064A" },
@@ -169762,7 +169832,7 @@ function ps_default() {
169762
169832
  };
169763
169833
  }
169764
169834
 
169765
- // ../cli/node_modules/zod/v4/locales/pl.js
169835
+ // node_modules/zod/v4/locales/pl.js
169766
169836
  var error42 = () => {
169767
169837
  const Sizable = {
169768
169838
  string: { unit: "znak\xF3w", verb: "mie\u0107" },
@@ -169877,7 +169947,7 @@ function pl_default() {
169877
169947
  };
169878
169948
  }
169879
169949
 
169880
- // ../cli/node_modules/zod/v4/locales/pt.js
169950
+ // node_modules/zod/v4/locales/pt.js
169881
169951
  var error43 = () => {
169882
169952
  const Sizable = {
169883
169953
  string: { unit: "caracteres" },
@@ -170021,7 +170091,7 @@ function pt_default() {
170021
170091
  };
170022
170092
  }
170023
170093
 
170024
- // ../cli/node_modules/zod/v4/locales/pt-BR.js
170094
+ // node_modules/zod/v4/locales/pt-BR.js
170025
170095
  var error44 = () => {
170026
170096
  const Sizable = {
170027
170097
  string: { unit: "caracteres" },
@@ -170166,7 +170236,7 @@ function pt_BR_default() {
170166
170236
  };
170167
170237
  }
170168
170238
 
170169
- // ../cli/node_modules/zod/v4/locales/ro.js
170239
+ // node_modules/zod/v4/locales/ro.js
170170
170240
  var error45 = () => {
170171
170241
  const Sizable = {
170172
170242
  string: { unit: "caractere", verb: "s\u0103 aib\u0103" },
@@ -170289,7 +170359,7 @@ function ro_default() {
170289
170359
  };
170290
170360
  }
170291
170361
 
170292
- // ../cli/node_modules/zod/v4/locales/ru.js
170362
+ // node_modules/zod/v4/locales/ru.js
170293
170363
  function getRussianPlural(count3, one, few, many) {
170294
170364
  const absCount = Math.abs(count3);
170295
170365
  const lastDigit = absCount % 10;
@@ -170458,7 +170528,7 @@ function ru_default() {
170458
170528
  };
170459
170529
  }
170460
170530
 
170461
- // ../cli/node_modules/zod/v4/locales/sk.js
170531
+ // node_modules/zod/v4/locales/sk.js
170462
170532
  var error47 = () => {
170463
170533
  const Sizable = {
170464
170534
  string: { unit: "znakov", verb: "ma\u0165" },
@@ -170575,7 +170645,7 @@ function sk_default() {
170575
170645
  };
170576
170646
  }
170577
170647
 
170578
- // ../cli/node_modules/zod/v4/locales/sl.js
170648
+ // node_modules/zod/v4/locales/sl.js
170579
170649
  var error48 = () => {
170580
170650
  const Sizable = {
170581
170651
  string: { unit: "znakov", verb: "imeti" },
@@ -170690,7 +170760,7 @@ function sl_default() {
170690
170760
  };
170691
170761
  }
170692
170762
 
170693
- // ../cli/node_modules/zod/v4/locales/sv.js
170763
+ // node_modules/zod/v4/locales/sv.js
170694
170764
  var error49 = () => {
170695
170765
  const Sizable = {
170696
170766
  string: { unit: "tecken", verb: "att ha" },
@@ -170806,7 +170876,7 @@ function sv_default() {
170806
170876
  };
170807
170877
  }
170808
170878
 
170809
- // ../cli/node_modules/zod/v4/locales/ta.js
170879
+ // node_modules/zod/v4/locales/ta.js
170810
170880
  var error50 = () => {
170811
170881
  const Sizable = {
170812
170882
  string: { unit: "\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD", verb: "\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD" },
@@ -170922,7 +170992,7 @@ function ta_default() {
170922
170992
  };
170923
170993
  }
170924
170994
 
170925
- // ../cli/node_modules/zod/v4/locales/tg.js
170995
+ // node_modules/zod/v4/locales/tg.js
170926
170996
  var error51 = () => {
170927
170997
  const Sizable = {
170928
170998
  string: { unit: "\u0430\u043B\u043E\u043C\u0430\u0442", verb: "\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434" },
@@ -171039,7 +171109,7 @@ function tg_default() {
171039
171109
  };
171040
171110
  }
171041
171111
 
171042
- // ../cli/node_modules/zod/v4/locales/th.js
171112
+ // node_modules/zod/v4/locales/th.js
171043
171113
  var error52 = () => {
171044
171114
  const Sizable = {
171045
171115
  string: { unit: "\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23", verb: "\u0E04\u0E27\u0E23\u0E21\u0E35" },
@@ -171155,7 +171225,7 @@ function th_default() {
171155
171225
  };
171156
171226
  }
171157
171227
 
171158
- // ../cli/node_modules/zod/v4/locales/tk.js
171228
+ // node_modules/zod/v4/locales/tk.js
171159
171229
  var error53 = () => {
171160
171230
  const Sizable = {
171161
171231
  string: { unit: "simwol", verb: "bolmaly" },
@@ -171263,7 +171333,7 @@ function tk_default() {
171263
171333
  };
171264
171334
  }
171265
171335
 
171266
- // ../cli/node_modules/zod/v4/locales/tr.js
171336
+ // node_modules/zod/v4/locales/tr.js
171267
171337
  var error54 = () => {
171268
171338
  const Sizable = {
171269
171339
  string: { unit: "karakter", verb: "olmal\u0131" },
@@ -171374,7 +171444,7 @@ function tr_default() {
171374
171444
  };
171375
171445
  }
171376
171446
 
171377
- // ../cli/node_modules/zod/v4/locales/uk.js
171447
+ // node_modules/zod/v4/locales/uk.js
171378
171448
  var error55 = () => {
171379
171449
  const Sizable = {
171380
171450
  string: { unit: "\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432", verb: "\u043C\u0430\u0442\u0438\u043C\u0435" },
@@ -171488,12 +171558,12 @@ function uk_default() {
171488
171558
  };
171489
171559
  }
171490
171560
 
171491
- // ../cli/node_modules/zod/v4/locales/ua.js
171561
+ // node_modules/zod/v4/locales/ua.js
171492
171562
  function ua_default() {
171493
171563
  return uk_default();
171494
171564
  }
171495
171565
 
171496
- // ../cli/node_modules/zod/v4/locales/ur.js
171566
+ // node_modules/zod/v4/locales/ur.js
171497
171567
  var error56 = () => {
171498
171568
  const Sizable = {
171499
171569
  string: { unit: "\u062D\u0631\u0648\u0641", verb: "\u06C1\u0648\u0646\u0627" },
@@ -171609,7 +171679,7 @@ function ur_default() {
171609
171679
  };
171610
171680
  }
171611
171681
 
171612
- // ../cli/node_modules/zod/v4/locales/uz.js
171682
+ // node_modules/zod/v4/locales/uz.js
171613
171683
  var error57 = () => {
171614
171684
  const Sizable = {
171615
171685
  string: { unit: "belgi", verb: "bo\u2018lishi kerak" },
@@ -171723,7 +171793,7 @@ function uz_default() {
171723
171793
  };
171724
171794
  }
171725
171795
 
171726
- // ../cli/node_modules/zod/v4/locales/vi.js
171796
+ // node_modules/zod/v4/locales/vi.js
171727
171797
  var error58 = () => {
171728
171798
  const Sizable = {
171729
171799
  string: { unit: "k\xFD t\u1EF1", verb: "c\xF3" },
@@ -171837,7 +171907,7 @@ function vi_default() {
171837
171907
  };
171838
171908
  }
171839
171909
 
171840
- // ../cli/node_modules/zod/v4/locales/zh-CN.js
171910
+ // node_modules/zod/v4/locales/zh-CN.js
171841
171911
  var error59 = () => {
171842
171912
  const Sizable = {
171843
171913
  string: { unit: "\u5B57\u7B26", verb: "\u5305\u542B" },
@@ -171952,7 +172022,7 @@ function zh_CN_default() {
171952
172022
  };
171953
172023
  }
171954
172024
 
171955
- // ../cli/node_modules/zod/v4/locales/zh-TW.js
172025
+ // node_modules/zod/v4/locales/zh-TW.js
171956
172026
  var error60 = () => {
171957
172027
  const Sizable = {
171958
172028
  string: { unit: "\u5B57\u5143", verb: "\u64C1\u6709" },
@@ -172065,7 +172135,7 @@ function zh_TW_default() {
172065
172135
  };
172066
172136
  }
172067
172137
 
172068
- // ../cli/node_modules/zod/v4/locales/yo.js
172138
+ // node_modules/zod/v4/locales/yo.js
172069
172139
  var error61 = () => {
172070
172140
  const Sizable = {
172071
172141
  string: { unit: "\xE0mi", verb: "n\xED" },
@@ -172178,7 +172248,7 @@ function yo_default() {
172178
172248
  };
172179
172249
  }
172180
172250
 
172181
- // ../cli/node_modules/zod/v4/core/registries.js
172251
+ // node_modules/zod/v4/core/registries.js
172182
172252
  var _a2;
172183
172253
  var $output = /* @__PURE__ */ Symbol("ZodOutput");
172184
172254
  var $input = /* @__PURE__ */ Symbol("ZodInput");
@@ -172228,7 +172298,7 @@ function registry() {
172228
172298
  (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
172229
172299
  var globalRegistry = globalThis.__zod_globalRegistry;
172230
172300
 
172231
- // ../cli/node_modules/zod/v4/core/compile.js
172301
+ // node_modules/zod/v4/core/compile.js
172232
172302
  var INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
172233
172303
  var FALLBACK_FLAG = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
172234
172304
  var ZodCompileAsyncError = class extends Error {
@@ -173838,7 +173908,7 @@ function generateTransformCheck(doc, ctx, schema, accessor) {
173838
173908
  return accessor;
173839
173909
  }
173840
173910
 
173841
- // ../cli/node_modules/zod/v4/core/api.js
173911
+ // node_modules/zod/v4/core/api.js
173842
173912
  function snapshotChecks(def) {
173843
173913
  if (def.checks)
173844
173914
  def.checks = [...def.checks];
@@ -174897,7 +174967,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
174897
174967
  return inst;
174898
174968
  }
174899
174969
 
174900
- // ../cli/node_modules/zod/v4/core/to-json-schema.js
174970
+ // node_modules/zod/v4/core/to-json-schema.js
174901
174971
  function assignProps(target, ...sources3) {
174902
174972
  for (const source2 of sources3) {
174903
174973
  for (const key of Reflect.ownKeys(source2)) {
@@ -175427,7 +175497,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
175427
175497
  return finalize(ctx, schema);
175428
175498
  };
175429
175499
 
175430
- // ../cli/node_modules/zod/v4/core/json-schema-processors.js
175500
+ // node_modules/zod/v4/core/json-schema-processors.js
175431
175501
  var narrowMin = (agg, key, value) => {
175432
175502
  if (agg[key] === void 0 || value > agg[key])
175433
175503
  agg[key] = value;
@@ -176175,7 +176245,7 @@ function toJSONSchema(input2, params) {
176175
176245
  return finalize(ctx, input2);
176176
176246
  }
176177
176247
 
176178
- // ../cli/node_modules/zod/v4/core/json-schema-generator.js
176248
+ // node_modules/zod/v4/core/json-schema-generator.js
176179
176249
  var JSONSchemaGenerator = class {
176180
176250
  /** @deprecated Access via ctx instead */
176181
176251
  get metadataRegistry() {
@@ -176253,10 +176323,10 @@ var JSONSchemaGenerator = class {
176253
176323
  }
176254
176324
  };
176255
176325
 
176256
- // ../cli/node_modules/zod/v4/core/json-schema.js
176326
+ // node_modules/zod/v4/core/json-schema.js
176257
176327
  var json_schema_exports = {};
176258
176328
 
176259
- // ../cli/node_modules/zod/v4/classic/schemas.js
176329
+ // node_modules/zod/v4/classic/schemas.js
176260
176330
  var schemas_exports2 = {};
176261
176331
  __export(schemas_exports2, {
176262
176332
  ZodAny: () => ZodAny,
@@ -176437,7 +176507,7 @@ __export(schemas_exports2, {
176437
176507
  xor: () => xor
176438
176508
  });
176439
176509
 
176440
- // ../cli/node_modules/zod/v4/classic/checks.js
176510
+ // node_modules/zod/v4/classic/checks.js
176441
176511
  var checks_exports2 = {};
176442
176512
  __export(checks_exports2, {
176443
176513
  endsWith: () => _endsWith,
@@ -176472,7 +176542,7 @@ __export(checks_exports2, {
176472
176542
  uppercase: () => _uppercase
176473
176543
  });
176474
176544
 
176475
- // ../cli/node_modules/zod/v4/classic/errors.js
176545
+ // node_modules/zod/v4/classic/errors.js
176476
176546
  var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
176477
176547
  function _lazyMethod(proto, key, make) {
176478
176548
  Object.defineProperty(proto, key, {
@@ -176518,7 +176588,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
176518
176588
  Parent: Error
176519
176589
  });
176520
176590
 
176521
- // ../cli/node_modules/zod/v4/classic/parse.js
176591
+ // node_modules/zod/v4/classic/parse.js
176522
176592
  var parse3 = /* @__PURE__ */ _parse(ZodRealError);
176523
176593
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
176524
176594
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -176532,7 +176602,7 @@ var safeDecode2 = /* @__PURE__ */ _safeDecode(ZodRealError);
176532
176602
  var safeEncodeAsync2 = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
176533
176603
  var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
176534
176604
 
176535
- // ../cli/node_modules/zod/v4/classic/schemas.js
176605
+ // node_modules/zod/v4/classic/schemas.js
176536
176606
  function _ensureDefaultLocale() {
176537
176607
  if (!globalConfig.localeError)
176538
176608
  config(en_default());
@@ -177997,7 +178067,7 @@ function preprocess(fn2, schema) {
177997
178067
  });
177998
178068
  }
177999
178069
 
178000
- // ../cli/node_modules/zod/v4/classic/compat.js
178070
+ // node_modules/zod/v4/classic/compat.js
178001
178071
  var ZodIssueCode = {
178002
178072
  invalid_type: "invalid_type",
178003
178073
  too_big: "too_big",
@@ -178023,7 +178093,7 @@ var ZodFirstPartyTypeKind;
178023
178093
  /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
178024
178094
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
178025
178095
 
178026
- // ../cli/node_modules/zod/v4/classic/iso.js
178096
+ // node_modules/zod/v4/classic/iso.js
178027
178097
  var iso_exports = {};
178028
178098
  __export(iso_exports, {
178029
178099
  ZodISODate: () => ZodISODate,
@@ -178048,7 +178118,7 @@ function duration2(params) {
178048
178118
  return _isoDuration(ZodISODuration, params);
178049
178119
  }
178050
178120
 
178051
- // ../cli/node_modules/zod/v4/classic/from-json-schema.js
178121
+ // node_modules/zod/v4/classic/from-json-schema.js
178052
178122
  var z = {
178053
178123
  ...schemas_exports2,
178054
178124
  ...checks_exports2,
@@ -178781,7 +178851,7 @@ function fromJSONSchema(schema, params) {
178781
178851
  return convertSchema(normalized, ctx);
178782
178852
  }
178783
178853
 
178784
- // ../cli/node_modules/zod/v4/core/visit.js
178854
+ // node_modules/zod/v4/core/visit.js
178785
178855
  var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
178786
178856
  function visit(schema, fnOrHandlers) {
178787
178857
  const fn2 = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
@@ -178936,7 +179006,7 @@ function visit(schema, fnOrHandlers) {
178936
179006
  return run3(schema);
178937
179007
  }
178938
179008
 
178939
- // ../cli/node_modules/zod/v4/classic/deep-partial.js
179009
+ // node_modules/zod/v4/classic/deep-partial.js
178940
179010
  function deepPartial(schema) {
178941
179011
  return visit(schema, {
178942
179012
  object: (s) => s.partial(),
@@ -178948,7 +179018,7 @@ function deepPartial(schema) {
178948
179018
  });
178949
179019
  }
178950
179020
 
178951
- // ../cli/node_modules/zod/v4/classic/in-out.js
179021
+ // node_modules/zod/v4/classic/in-out.js
178952
179022
  function withChecks(side, checks) {
178953
179023
  if (!checks?.length)
178954
179024
  return side;
@@ -178978,7 +179048,7 @@ function output2(schema) {
178978
179048
  });
178979
179049
  }
178980
179050
 
178981
- // ../cli/node_modules/zod/v4/classic/coerce.js
179051
+ // node_modules/zod/v4/classic/coerce.js
178982
179052
  var coerce_exports = {};
178983
179053
  __export(coerce_exports, {
178984
179054
  bigint: () => bigint3,
@@ -179166,7 +179236,15 @@ function studioEntry(id2, name, version2, action, command = "akb studio file") {
179166
179236
  return ["studio", "Studio: " + name + ". Read `" + command + " " + studioName(id2) + " STUDIO.md`" + read6 + ".", void 0, JSON.stringify([id2, name, version2, command])];
179167
179237
  }
179168
179238
  function compactReview(review, assigned) {
179169
- if (isFlatReviewPlan(review.plan)) return taskReviewBoundary(review, assigned);
179239
+ if (isFlatReviewPlan(review.plan)) {
179240
+ const pending = (review.approvals ?? []).filter((approval) => "preview" in approval);
179241
+ return [
179242
+ "Review r" + review.revision + " \xB7 flat plan",
179243
+ "Selected Previews: " + (review.plan.previews.join(", ") || "none"),
179244
+ "Review rule: " + (review.plan.rule || "No extra approval."),
179245
+ ...pending.length ? ["Pending approvals:", ...pending.map(({ preview, stage, revision, question }) => `- ${preview} \xB7 ${stage} \xB7 r${revision}: ${question}`)] : []
179246
+ ].map((line) => line.replace(/[\r\n]+/g, " ")).join("\n");
179247
+ }
179170
179248
  const authorization = reviewAuthorization(review, assigned);
179171
179249
  if (authorization.kind === "changed") return "Review r" + review.revision + " \xB7 authorization changed. Read the task again.";
179172
179250
  const custom2 = review.preview_definitions?.length ? "\nCustom Previews: " + review.preview_definitions.map((d2) => d2.id).join(", ") : "";
@@ -185507,7 +185585,6 @@ function run2(script, context, name, deadline, lineOffset = 0) {
185507
185585
  if (left <= 0) throw new Error(`took longer than ${DRAW_MS / 1e3}s to draw`);
185508
185586
  return vm.runInContext(script, context, { timeout: left, filename: name, lineOffset });
185509
185587
  }
185510
- var cssPath = (file3) => file3.split(path49.sep).map((part) => encodeURIComponent(part).replace(/[!'()*]/g, (char) => "%" + char.charCodeAt(0).toString(16))).join("/");
185511
185588
  function rebaseCss(css, owner2, folder2) {
185512
185589
  let result = "";
185513
185590
  let last2 = 0;
@@ -185516,15 +185593,16 @@ function rebaseCss(css, owner2, folder2) {
185516
185593
  const [file3, suffix] = splitFileReference(ref.src);
185517
185594
  const decoded = decodeFilePath(file3);
185518
185595
  if (path49.posix.isAbsolute(decoded) || path49.win32.isAbsolute(decoded)) continue;
185519
- const relative = cssPath(ref.importToken ? decoded : path49.relative(folder2, path49.resolve(path49.dirname(owner2), decoded)));
185596
+ const relative = ref.importToken ? decoded : path49.relative(folder2, path49.resolve(path49.dirname(owner2), decoded));
185597
+ const url2 = encodeFileReferencePath(relative.split(path49.sep)) + suffix;
185520
185598
  const [start, end2] = ref.importToken ?? [ref.start, ref.end];
185521
- result += css.slice(last2, start) + (ref.importToken ? JSON.stringify(relative + suffix) : relative + suffix);
185599
+ result += css.slice(last2, start) + (ref.importToken ? JSON.stringify(url2) : url2);
185522
185600
  last2 = end2;
185523
185601
  }
185524
185602
  return result + css.slice(last2);
185525
185603
  }
185526
185604
  async function tailwindFor(markup, sheets, folder2) {
185527
- const source2 = sheets.length ? sheets.map((file3) => `@import "./${cssPath(path49.relative(folder2, file3))}";`).join("\n") : '@import "tailwindcss";';
185605
+ const source2 = sheets.length ? sheets.map((file3) => `@import "./${encodeFileReferencePath(path49.relative(folder2, file3).split(path49.sep))}";`).join("\n") : '@import "tailwindcss";';
185528
185606
  const root2 = fs46.realpathSync(folder2) + path49.sep;
185529
185607
  const compiler = await rc(source2, {
185530
185608
  base: folder2,
@@ -185648,37 +185726,6 @@ function retireKanbanSkill(dir) {
185648
185726
  }
185649
185727
  }
185650
185728
 
185651
- // src/sync-debug.ts
185652
- import { monitorEventLoopDelay } from "node:perf_hooks";
185653
- var syncDebug = process.env.WILDCRANE_DEBUG_SYNC === "1";
185654
- var counts = {};
185655
- function countSync(name, amount = 1) {
185656
- if (syncDebug) counts[name] = (counts[name] ?? 0) + amount;
185657
- }
185658
- function logSync(event2, fields2 = {}) {
185659
- if (syncDebug) console.error("[sync-debug]", JSON.stringify({ time: (/* @__PURE__ */ new Date()).toISOString(), pid: process.pid, event: event2, ...fields2 }));
185660
- }
185661
- if (syncDebug) {
185662
- const delay5 = monitorEventLoopDelay({ resolution: 20 });
185663
- delay5.enable();
185664
- let cpu = process.cpuUsage();
185665
- let at2 = performance.now();
185666
- setInterval(() => {
185667
- const now = performance.now();
185668
- const used = process.cpuUsage(cpu);
185669
- logSync("health", {
185670
- cpuPercent: Math.round((used.user + used.system) / (now - at2) / 10),
185671
- delayMaxMs: Math.round(delay5.max / 1e6),
185672
- delayP99Ms: Math.round(delay5.percentile(99) / 1e6),
185673
- ...counts
185674
- });
185675
- for (const name of Object.keys(counts)) delete counts[name];
185676
- cpu = process.cpuUsage();
185677
- at2 = now;
185678
- delay5.reset();
185679
- }, 5e3).unref();
185680
- }
185681
-
185682
185729
  // src/task-folder.ts
185683
185730
  var validationFailure = (reason, code = "validation_failed") => makeFailure("validation", reason, { code, detail: reason });
185684
185731
  var TASK_ID = /^[\w-]{1,100}$/;
@@ -186060,7 +186107,12 @@ function pull(ws, machineId2, stopped2, mode) {
186060
186107
  const taskChat = mode === "chat" ? ws.task : void 0;
186061
186108
  return whenPrepared(ws, { ok: false, code: "stopped", error: "Task preparation stopped." }, async () => {
186062
186109
  if (mode === "land") return prepareTask(ws, true, void 0, ws.task);
186063
- const sent = await sendBoard(boardFolder(ws), machineId2, { taskChat });
186110
+ const started = performance.now();
186111
+ const sent = await sendBoard(boardFolder(ws), machineId2, {
186112
+ taskChat,
186113
+ ...mode === "chat" && ws.number !== null ? { taskNumber: ws.number } : {}
186114
+ });
186115
+ logSync("board.push.done", { ms: Math.round(performance.now() - started), ok: sent.ok });
186064
186116
  let validation;
186065
186117
  if (!sent.ok) {
186066
186118
  const previews = sent.previews?.filter((p2) => numberOfCard(p2.file) === ws.number);
@@ -186075,12 +186127,17 @@ function pull(ws, machineId2, stopped2, mode) {
186075
186127
  return { ok: false, error: `This computer's board changes could not be sent: ${refused2.error}`, ...refused2.offline ? {} : { code: sent.conflict ? "board_content_conflict" : refused2.code ?? "version_conflict" } };
186076
186128
  }
186077
186129
  }
186078
- const read6 = await prepareTask(ws, !!validation, taskChat);
186079
- if (!read6.ok && read6.code === "board_content_conflict") {
186080
- const prepared = await prepareConflictTask(ws);
186081
- if (!prepared.ok) return prepared;
186130
+ const readAt = performance.now();
186131
+ try {
186132
+ const read6 = await prepareTask(ws, !!validation, taskChat);
186133
+ if (!read6.ok && read6.code === "board_content_conflict") {
186134
+ const prepared = await prepareConflictTask(ws);
186135
+ if (!prepared.ok) return prepared;
186136
+ }
186137
+ return read6.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read6;
186138
+ } finally {
186139
+ logSync("board.pull.done", { ms: Math.round(performance.now() - readAt) });
186082
186140
  }
186083
- return read6.ok && validation ? { ok: false, code: "bad_request", error: validation.summary, failure: validation } : read6;
186084
186141
  }, stopped2);
186085
186142
  }
186086
186143
  async function prepareConflictTask(ws) {
@@ -186234,7 +186291,15 @@ async function reconcileBoard(ws, base, board, shared, taskChat, landTask) {
186234
186291
  const held5 = pendingLandArchives(ws, base).filter(({ task }) => task !== landTask);
186235
186292
  const numbers = new Set(held5.map(({ number: number4 }) => number4));
186236
186293
  const manifests = new Set(held5.map(({ task }) => assetsFile(task)));
186237
- const privateArchive = (p2) => numbers.has(numberOfCard(p2) ?? 0) || manifests.has(p2);
186294
+ if (taskChat) {
186295
+ for (const p2 of filesUnder(path52.join(ws.board, ".archive"), ws.board)) {
186296
+ const n = numberOfCard(p2);
186297
+ if (n !== null && n !== ws.number && !base.files[root2 + p2] && archiveMeta(readText(path52.join(ws.board, p2)) ?? "")) {
186298
+ numbers.add(n);
186299
+ }
186300
+ }
186301
+ }
186302
+ const privateArchive = (p2) => numbers.has(numberOfCard(p2) ?? 0) || numbers.has(groupOfCard(p2) ?? 0) || manifests.has(p2);
186238
186303
  const snapshot = base.head_seq === null ? base.files : void 0;
186239
186304
  if (!snapshot && observeConflicts(ws, base, board.files, shared, privateArchive)) return conflict();
186240
186305
  if (snapshot) base.files = {};
@@ -186456,6 +186521,7 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
186456
186521
  if (data !== void 0) {
186457
186522
  let changed = false;
186458
186523
  const ownerName = name;
186524
+ const web = manifest?.references?.some((rule) => "web" in rule);
186459
186525
  const restored = mapReferences(manifest, data, (src, found) => {
186460
186526
  const [ref2, suffix] = found.text ? splitFileReference(src) : [src, ""];
186461
186527
  const name2 = Object.entries(assets).find(([, r2]) => r2.artifact === ref2)?.[0];
@@ -186468,7 +186534,7 @@ async function pullAssets(ws, record2, assets, preserve = false, stopped2) {
186468
186534
  if (!child) return src;
186469
186535
  dependencies.push(name2);
186470
186536
  const relative = path52.relative(path52.dirname(target), child).split(path52.sep);
186471
- const back = !found.text && isLegacyAssetRef(name2) && !isAssetRef(ownerName) ? name2 : (found.text ? relative.map(encodeURIComponent) : relative).join("/") + suffix;
186537
+ const back = found.text ? (web ? encodeFileReferencePath(relative) : relative.map(encodeURIComponent).join("/")) + suffix : isLegacyAssetRef(name2) && !isAssetRef(ownerName) ? name2 : relative.join("/");
186472
186538
  if (back !== src) changed = true;
186473
186539
  return back;
186474
186540
  });
@@ -186930,8 +186996,7 @@ function protectLandArchive(ws, job, stopped2) {
186930
186996
  if (stopped2() || !ws.number) return;
186931
186997
  const file3 = landArchiveMarker(ws.board, ws.task);
186932
186998
  if (!isDeepStrictEqual(readLandArchiveOwner(file3), { job, number: ws.number })) {
186933
- write(`${file3}.tmp`, JSON.stringify({ job, number: ws.number }));
186934
- fs48.renameSync(`${file3}.tmp`, file3);
186999
+ writeLandArchiveOwner(file3, { job, number: ws.number });
186935
187000
  }
186936
187001
  const base = readBase(ws);
186937
187002
  if (pendingLandArchives(ws, base).some((owner2) => owner2.task === ws.task)) {
@@ -186954,11 +187019,13 @@ async function sendBoard(ws, machineId2, scope) {
186954
187019
  }
186955
187020
  async function sendMarked(ws, job, scope = {}) {
186956
187021
  const fields2 = { stage: "push", task: ws.number, job: job.id };
187022
+ const fullBoardSync = !job.id && !ws.cloudTask && !scope.taskChat;
187023
+ const hadUnsent = !fullBoardSync && unsent(ws.cwd);
186957
187024
  try {
186958
187025
  const pushed = pendingConflicts(ws.board).length ? conflictFailure(ws) : await send2(ws, job, scope);
186959
187026
  if (!pushed.ok) logRunner("board", "failed", { ...fields2, code: pushed.code ?? (pushed.offline ? "unreachable" : "unknown_error"), status: pushed.status });
186960
187027
  const base = readBase(ws);
186961
- markUnsent(ws.cwd, !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length || pendingLandArchives(ws, base).length > 0);
187028
+ markUnsent(ws.cwd, hadUnsent || !pushed.ok || !!base.pendingAssets?.length || !!base.pendingPreviews?.length || !!Object.keys(base.pendingArchives ?? {}).length || !!base.pendingRemovals?.length || pendingLandArchives(ws, base).length > 0);
186962
187029
  return pushed;
186963
187030
  } catch (error62) {
186964
187031
  logRunner("board", "failed", { ...fields2, code: errno(error62) });
@@ -187034,24 +187101,29 @@ function affectedTasks(ws, paths) {
187034
187101
  }
187035
187102
  return tasks;
187036
187103
  }
187037
- async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187104
+ async function send2(ws, job, { paths, taskChat, taskNumber }, retryRestore = true) {
187038
187105
  const record2 = readRecord(ws);
187039
187106
  const base = readBase(ws);
187040
187107
  const fail = (error62, conflict = false, code, status2) => ({ ok: false, conflict, error: error62, code, ...status2 === void 0 ? {} : { status: status2 }, ...temporaryCloudFailure({ code, status: status2 }) ? { offline: true } : {} });
187041
187108
  const boardSync = !job.id && !ws.cloudTask;
187042
- const discoverArchives = boardSync && !syncIndex(ws)?.archivesReady;
187043
- if (!syncIndex(ws)?.ready || discoverArchives) paths = void 0;
187044
- const selected2 = paths && /* @__PURE__ */ new Set([...paths, ...base.pendingPreviews ?? []]);
187109
+ const singleTask = ws.cloudTask && ws.number !== null ? { task: ws.cloudTask, number: ws.number, chat: false } : taskChat && taskNumber !== void 0 ? { task: taskChat, number: taskNumber, chat: true } : null;
187110
+ const fullBoardSync = boardSync && !singleTask;
187111
+ const discoverArchives = fullBoardSync && !syncIndex(ws)?.archivesReady;
187112
+ if (fullBoardSync && (!syncIndex(ws)?.ready || discoverArchives)) paths = void 0;
187113
+ const heldTaskPreviews = (base.pendingPreviews ?? []).filter((p2) => !singleTask || numberOfCard(p2) === singleTask.number || groupOfCard(p2) === singleTask.number || taskOfAssets(p2) === singleTask.task);
187114
+ const selected2 = paths && /* @__PURE__ */ new Set([...paths, ...heldTaskPreviews]);
187045
187115
  const pendingArchives = new Map(Object.entries(base.pendingArchives ?? {}));
187046
- const names2 = selected2 ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...boardSync ? pendingArchives.keys() : []]) : null;
187116
+ const names2 = selected2 ? /* @__PURE__ */ new Set([...base.pendingAssets ?? [], ...fullBoardSync ? pendingArchives.keys() : []]) : null;
187047
187117
  if (selected2) for (const task of affectedTasks(ws, selected2)) names2.add(task);
187048
- const retired = await cleanRecords(ws, base, { tasks: names2 ?? void 0, taskChat });
187049
- if (retired.has(ws.task)) record2.deleted = true;
187050
- const records = ws.cloudTask ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
187118
+ const retired = await cleanRecords(ws, base, { tasks: singleTask ? [singleTask.task] : names2 ?? void 0, taskChat });
187119
+ const singleFolder = singleTask ? { ...ws, task: singleTask.task, cloudTask: singleTask.task, number: singleTask.number } : null;
187120
+ const singleRecord = singleFolder ? ws.cloudTask ? record2 : readRecord(singleFolder) : record2;
187121
+ if (retired.has(singleFolder?.task ?? ws.task)) singleRecord.deleted = true;
187122
+ const records = singleFolder ? [] : names2 ? [...names2].map((task) => `${task}.json`) : [.../* @__PURE__ */ new Set([
187051
187123
  ...filesUnder(path52.join(ws.board, ".sync")).filter((name) => name.endsWith(".json") && !taskOfRemoval(".sync/" + name)),
187052
187124
  ...[...syncIndex(ws)?.tasks.keys() ?? []].map((task) => `${task}.json`)
187053
187125
  ])];
187054
- const tasks = ws.cloudTask ? [{ folder: ws, record: record2 }] : records.flatMap((name) => {
187126
+ const tasks = singleFolder ? [{ folder: singleFolder, record: singleRecord }] : records.flatMap((name) => {
187055
187127
  let held5;
187056
187128
  try {
187057
187129
  held5 = JSON.parse(fs48.readFileSync(path52.join(ws.board, ".sync", name), "utf8"));
@@ -187074,10 +187146,10 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187074
187146
  const protectedLists = /* @__PURE__ */ new Set();
187075
187147
  const pendingBlockers = /* @__PURE__ */ new Set();
187076
187148
  for (const { task, file: file3, job: owner2, number: number4, archived } of pendingLandArchives(ws, base)) {
187077
- const ownsArchive = owner2 === job.id && ws.cloudTask === task;
187078
- if (!ownsArchive && boardSync && base.files[rootOf(ws) + archived]) {
187149
+ const ownsArchive = owner2 !== null && owner2 === job.id && singleTask?.task === task && !singleTask.chat;
187150
+ if (!ownsArchive && fullBoardSync && !task.startsWith("unowned-") && (owner2 === null || base.files[rootOf(ws) + archived])) {
187079
187151
  const current2 = await readTask(task);
187080
- if (current2.ok && current2.value.status === "done") {
187152
+ if (current2.ok && (current2.value.status === "done" || current2.value.status === "cancelled" && !!base.files[rootOf(ws) + archived])) {
187081
187153
  fs48.rmSync(file3, { force: true });
187082
187154
  continue;
187083
187155
  }
@@ -187093,7 +187165,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187093
187165
  const processed = /* @__PURE__ */ new Set();
187094
187166
  const assetLists = /* @__PURE__ */ new Map();
187095
187167
  const generatedAssets = /* @__PURE__ */ new Set();
187096
- const cards = !selected2 && !ws.cloudTask ? new Map(
187168
+ const cards = !selected2 && !singleFolder ? new Map(
187097
187169
  [".archive", "todo"].flatMap((dir) => filesUnder(path52.join(ws.board, dir), ws.board)).flatMap((p2) => {
187098
187170
  const number4 = numberOfCard(p2);
187099
187171
  return number4 ? [[number4, p2]] : [];
@@ -187119,7 +187191,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187119
187191
  return false;
187120
187192
  }
187121
187193
  });
187122
- const archive = boardSync && card.startsWith(".archive/") && !item.record.deleted;
187194
+ const archive = fullBoardSync && card.startsWith(".archive/") && !item.record.deleted;
187123
187195
  const listPath = assetsFile(item.folder.task);
187124
187196
  const archived = !selected2 && archive && !retryAssets.has(item.folder.task) && !Object.keys(item.record.pendingVersions ?? {}).length && readText(path52.join(ws.board, listPath)) === (base.files[rootOf(ws) + listPath]?.content ?? null) && readText(path52.join(ws.board, card)) === base.files[rootOf(ws) + card]?.content && !newer && clean();
187125
187197
  retryAssets.delete(item.folder.task);
@@ -187153,25 +187225,50 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187153
187225
  deferredCards.add(item.folder.number);
187154
187226
  deferredLists.add(listPath);
187155
187227
  }
187156
- if (!ws.cloudTask) syncIndex(ws).ready = true;
187228
+ if (fullBoardSync) syncIndex(ws).ready = true;
187157
187229
  const scoped = selected2 && [...new Set([...selected2].flatMap((p2) => {
187158
187230
  if (!isBoardPath(p2) && !fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isDirectory()) return [];
187159
187231
  const file3 = path52.join(ws.board, p2);
187160
187232
  return fs48.statSync(file3, { throwIfNoEntry: false })?.isDirectory() ? filesUnder(file3, ws.board).filter(kept3) : kept3(p2) ? [p2] : [];
187161
187233
  }))].filter((p2) => fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isFile());
187162
187234
  for (const p2 of scoped ?? []) rememberDirectories(syncIndex(ws).directories, p2);
187163
- proposeItems(ws, base, scoped);
187235
+ const ownCardPath = singleFolder ? path52.relative(ws.board, cardFile(singleFolder)).split(path52.sep).join("/") : null;
187236
+ const ownArchived = !!ownCardPath?.startsWith(".archive/");
187237
+ const ownGroup = singleTask ? (ownCardPath ? groupOfCard(ownCardPath) : null) ?? Object.keys(base.files).flatMap((k2) => {
187238
+ if (!k2.startsWith(rootOf(ws))) return [];
187239
+ const rel3 = k2.slice(rootOf(ws).length);
187240
+ return numberOfCard(rel3) === singleTask.number ? [groupOfCard(rel3)] : [];
187241
+ }).find((g3) => g3 !== null) ?? null : null;
187242
+ const outOfTaskScope = (p2) => {
187243
+ if (!singleTask) return false;
187244
+ const assetTask = taskOfAssets(p2);
187245
+ if (assetTask !== null) return assetTask !== singleTask.task;
187246
+ const cardNum = numberOfCard(p2), groupNum = groupOfCard(p2);
187247
+ if (cardNum === null) return false;
187248
+ if (cardNum === singleTask.number || groupNum === singleTask.number) return false;
187249
+ if (p2.startsWith(".archive/") || singleTask.chat) return true;
187250
+ if (!fs48.statSync(path52.join(ws.board, p2), { throwIfNoEntry: false })?.isFile()) return true;
187251
+ if (ownGroup !== null && cardNum === ownGroup) return false;
187252
+ if (ownArchived) {
187253
+ const before = base.files[rootOf(ws) + p2]?.content;
187254
+ const meta3 = before ? parseFrontmatter(before).meta : null;
187255
+ if (meta3 && (meta3.blocked_by.includes(singleTask.number) || meta3.related.includes(singleTask.number))) return false;
187256
+ }
187257
+ return true;
187258
+ };
187259
+ if (!singleTask?.chat) proposeItems(ws, base, scoped);
187164
187260
  const shared = sharedMemory(ws.board);
187165
187261
  const deferred = new Set((base.deferred ?? []).filter((p2) => !tasks.some((item) => processed.has(item.folder.task) && !deferredCards.has(item.folder.number) && (p2 === assetsFile(item.folder.task) || numberOfCard(p2) === item.folder.number))));
187166
187262
  const retiredCards = new Set(tasks.filter((item) => item.record.deleted).map((item) => item.folder.number));
187167
187263
  const retiredLists = new Set(tasks.filter((item) => item.record.deleted).map((item) => assetsFile(item.folder.task)));
187168
187264
  const defer = (p2) => {
187169
- if (protectedCards.has(numberOfCard(p2) ?? 0) || protectedLists.has(p2)) return true;
187170
- if (retiredCards.has(numberOfCard(p2)) || retiredLists.has(p2)) {
187265
+ if (outOfTaskScope(p2)) return true;
187266
+ if (protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2)) return true;
187267
+ if (retiredCards.has(numberOfCard(p2) ?? 0) || retiredLists.has(p2)) {
187171
187268
  deferred.add(p2);
187172
187269
  return true;
187173
187270
  }
187174
- if (!boardSync) return deferred.has(p2);
187271
+ if (!fullBoardSync) return deferred.has(p2);
187175
187272
  if (!deferredLists.has(p2) && !deferredCards.has(numberOfCard(p2) ?? 0)) return deferred.has(p2);
187176
187273
  deferred.add(p2);
187177
187274
  return true;
@@ -187185,12 +187282,13 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187185
187282
  const refreshPending = JSON.stringify(pendingAssets) !== JSON.stringify(base.pendingAssets ?? []);
187186
187283
  if (refreshDeferred) base.deferred = [...deferred];
187187
187284
  if (refreshPending) base.pendingAssets = pendingAssets;
187188
- const pendingPreviews = [.../* @__PURE__ */ new Set([...heldPreviews, ...(base.pendingPreviews ?? []).filter((p2) => deferred.has(p2))])];
187285
+ const keepPreview = (p2) => deferred.has(p2) || outOfTaskScope(p2) || protectedCards.has(numberOfCard(p2) ?? 0) || protectedCards.has(groupOfCard(p2) ?? 0) || protectedLists.has(p2) || selected2 !== void 0 && !selected2.has(p2);
187286
+ const pendingPreviews = [.../* @__PURE__ */ new Set([...heldPreviews, ...(base.pendingPreviews ?? []).filter(keepPreview)])];
187189
187287
  const refreshPreviews = !isDeepStrictEqual(pendingPreviews, base.pendingPreviews ?? []);
187190
187288
  if (refreshPreviews) base.pendingPreviews = pendingPreviews;
187191
187289
  if (changed || refreshDeferred || refreshPending || refreshPreviews) writeBase(ws, base);
187192
187290
  let operations = {};
187193
- if (boardSync) {
187291
+ if (fullBoardSync) {
187194
187292
  for (const task of processed) {
187195
187293
  if (!archives.has(task) && !assetErrors[task]) pendingArchives.delete(task);
187196
187294
  }
@@ -187200,7 +187298,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187200
187298
  const index = syncIndex(ws);
187201
187299
  if (index) index.archivesReady = true;
187202
187300
  }
187203
- const reported = !ws.number ? previews : previews.filter((p2) => numberOfCard(p2.file) === ws.number);
187301
+ const reported = !singleTask ? previews : previews.filter((p2) => numberOfCard(p2.file) === singleTask.number);
187204
187302
  const tasks2 = { ...assetErrors, ...operations };
187205
187303
  const firstError = Object.values(tasks2)[0];
187206
187304
  if (reported.length) {
@@ -187210,7 +187308,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187210
187308
  if (firstError && (boardSync || firstError.failure)) return { ok: false, conflict: false, ...firstError, tasks: tasks2 };
187211
187309
  return { ok: true, changed };
187212
187310
  };
187213
- const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(ws, base), ...assetLists.keys()]);
187311
+ const local = /* @__PURE__ */ new Set([...scoped ?? localFiles(singleFolder ?? ws, base), ...assetLists.keys()]);
187214
187312
  const localOf = /* @__PURE__ */ new Map();
187215
187313
  const localBefore = /* @__PURE__ */ new Map();
187216
187314
  const changes = [];
@@ -187234,7 +187332,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187234
187332
  if (Buffer.byteLength(content) > BOARD_FILE_LIMIT) {
187235
187333
  const error62 = `${p2}:1 \u2014 File exceeds ${BOARD_FILE_LIMIT / 1024} KB. Move large results to assets and link them from the card.`;
187236
187334
  const number4 = numberOfCard(p2);
187237
- if (number4 === null || number4 === ws.number) return { ok: false, conflict: false, error: error62, failure: validationFailure(error62, "card_too_large") };
187335
+ if (number4 === null || number4 === singleTask?.number) return { ok: false, conflict: false, error: error62, failure: validationFailure(error62, "card_too_large") };
187238
187336
  previews.push({ file: p2, line: 1, column: 1, code: "card_too_large", path: "", message: error62, hint: "Shorten the card." });
187239
187337
  oversize.add(number4);
187240
187338
  heldPreviews.add(p2);
@@ -187282,9 +187380,75 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187282
187380
  };
187283
187381
  if (oversize.size) holdCards(oversize);
187284
187382
  if (!changes.length) return success2(false);
187383
+ const taskOfCardNumber = (number4) => {
187384
+ const indexed = [...syncIndex(ws)?.tasks.values() ?? []].find((t2) => t2.number === number4)?.task;
187385
+ if (indexed) return indexed;
187386
+ for (const name of filesUnder(path52.join(ws.board, ".sync"))) {
187387
+ if (!name.endsWith(".json") || name.includes("/") || taskOfRemoval(".sync/" + name)) continue;
187388
+ try {
187389
+ const held5 = JSON.parse(fs48.readFileSync(path52.join(ws.board, ".sync", name), "utf8"));
187390
+ if (held5.number === number4 && held5.task && TASK_ID.test(held5.task)) return held5.task;
187391
+ } catch {
187392
+ }
187393
+ }
187394
+ };
187285
187395
  const commit = async () => {
187286
187396
  while (changes.length) {
187287
187397
  const sent2 = await commitBoard(ws.project, job.id, job.machineId, changes);
187398
+ if (!sent2.ok && sent2.code === "conflict" && sent2.error === "The current Land job must synchronize this archive.") {
187399
+ const candidates = [...new Set(changes.flatMap((c2) => {
187400
+ const p2 = localOf.get(c2.path);
187401
+ const n = p2?.startsWith(".archive/") ? numberOfCard(p2) : null;
187402
+ return n !== null && !(singleTask && !singleTask.chat && job.id && n === singleTask.number && readLandArchiveOwner(landArchiveMarker(ws.board, singleTask.task))?.job === job.id) ? [n] : [];
187403
+ }))];
187404
+ const isolatedNumbers = /* @__PURE__ */ new Set();
187405
+ const isolatedTasks = /* @__PURE__ */ new Set();
187406
+ for (const n of candidates) {
187407
+ const task = taskOfCardNumber(n);
187408
+ if (candidates.length > 1 && task) {
187409
+ const current2 = await readTask(task);
187410
+ if (current2.ok && current2.value.status === "done") continue;
187411
+ }
187412
+ writeLandArchiveOwner(landArchiveMarker(ws.board, task ?? `unowned-${n}`), { job: null, number: n });
187413
+ isolatedNumbers.add(n);
187414
+ protectedCards.add(n);
187415
+ if (task) {
187416
+ isolatedTasks.add(task);
187417
+ protectedLists.add(assetsFile(task));
187418
+ pendingArchives.delete(task);
187419
+ retryAssets.delete(task);
187420
+ }
187421
+ }
187422
+ if (isolatedNumbers.size) {
187423
+ const repaired = /* @__PURE__ */ new Set();
187424
+ repairLandBlockers(ws, base, isolatedNumbers, repaired);
187425
+ for (let i = changes.length - 1; i >= 0; i--) {
187426
+ const file3 = localOf.get(changes[i].path);
187427
+ if (!file3) continue;
187428
+ const assetTask = taskOfAssets(file3);
187429
+ const cardNum = numberOfCard(file3), groupNum = groupOfCard(file3);
187430
+ if (assetTask && isolatedTasks.has(assetTask) || cardNum !== null && isolatedNumbers.has(cardNum) || groupNum !== null && isolatedNumbers.has(groupNum)) {
187431
+ changes.splice(i, 1);
187432
+ }
187433
+ }
187434
+ for (const file3 of repaired) {
187435
+ if (defer(file3) || heldPreviews.has(file3)) continue;
187436
+ const content = readText(path52.join(ws.board, file3));
187437
+ if (content === null || Buffer.byteLength(content) > BOARD_FILE_LIMIT) continue;
187438
+ const remote3 = remoteOf(ws, shared, file3);
187439
+ const held5 = base.files[remote3];
187440
+ localOf.set(remote3, file3);
187441
+ localBefore.set(remote3, content);
187442
+ const entry = { path: remote3, content: normalizeCardFrontmatter(content), base_seq: held5?.seq ?? base.deleted?.[remote3] ?? 0 };
187443
+ const existing = changes.findIndex((c2) => c2.path === remote3);
187444
+ if (held5?.content === content) {
187445
+ if (existing >= 0) changes.splice(existing, 1);
187446
+ } else if (existing >= 0) changes[existing] = entry;
187447
+ else changes.push(entry);
187448
+ }
187449
+ continue;
187450
+ }
187451
+ }
187288
187452
  if (sent2.ok || !sent2.previewProblems?.length) return sent2;
187289
187453
  logRunner("board", "failed", { stage: "push", task: ws.number, job: job.id, code: sent2.code ?? "bad_request", status: sent2.status });
187290
187454
  const problems = sent2.previewProblems;
@@ -187293,7 +187457,7 @@ async function send2(ws, job, { paths, taskChat }, retryRestore = true) {
187293
187457
  const numbers = new Set(problems.map((p2) => numberOfCard(p2.file)));
187294
187458
  for (const problem2 of problems) previews.push(problem2);
187295
187459
  holdCards(numbers);
187296
- const own4 = previews.filter((p2) => numberOfCard(p2.file) === ws.number);
187460
+ const own4 = previews.filter((p2) => numberOfCard(p2.file) === singleTask?.number);
187297
187461
  if (job.id && own4.length) return { ...sent2, error: describeTaskPreviewProblems(own4) };
187298
187462
  }
187299
187463
  return null;
@@ -187991,11 +188155,6 @@ import os10 from "node:os";
187991
188155
  import path75 from "node:path";
187992
188156
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
187993
188157
 
187994
- // ../cli/src/lib/agent/wire/codex-background-types.ts
187995
- function idleStopConfirmed(cleanup, session) {
187996
- return !!session && cleanup?.status === "confirmed" && !!cleanup.instance && Array.isArray(cleanup.kept) && cleanup.kept.length === 0 && cleanup.idleStop?.threadId === session && typeof cleanup.idleStop.turnId === "string" && !!cleanup.idleStop.turnId;
187997
- }
187998
-
187999
188158
  // ../cli/src/lib/cloud/execution.ts
188000
188159
  var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
188001
188160
  function executionOf(value = process.env.AI4KANBAN_EXECUTION) {
@@ -191435,7 +191594,13 @@ function runCommand(akb, ws, args2) {
191435
191594
  return runAkb(akb, ["run", ...args2, "--board", ws.board, "--json"], { cwd: ws.cwd, board: ws.board });
191436
191595
  }
191437
191596
  async function boardRuns(akb, ws, scope) {
191438
- return answerOf2(await runCommand(akb, ws, ["list", "--all", ...scope]))?.runs;
191597
+ const ran = await runCommand(akb, ws, ["list", "--all", ...scope]);
191598
+ const parsed = answerOf2(ran);
191599
+ if (parsed?.runs) return parsed.runs;
191600
+ if (parsed?.error?.kind === "no-board" && !fs74.existsSync(path75.join(ws.board, "config.md")) && !fs74.existsSync(path75.join(ws.board, "todo")) && !fs74.existsSync(path75.join(projectStateDir(ws.board), "sessions.json"))) {
191601
+ return [];
191602
+ }
191603
+ return void 0;
191439
191604
  }
191440
191605
  var jobOwns = (run3, job, machine) => run3.cloudExecution?.job === job && run3.cloudExecution.machine === machine;
191441
191606
  var onTask = (run3, card) => run3.cardId === card && (run3.cloudExecution?.card === void 0 || run3.cloudExecution.card === card);
@@ -191632,12 +191797,15 @@ function runStopped(run3) {
191632
191797
  const root2 = run3.agentPid ? { pid: run3.agentPid, since: run3.agentStartedAt ?? run3.startedAt ?? 0, identity: run3.agentIdentity } : void 0;
191633
191798
  return run3.managedProcess ? connectionStopped(root2) : processesStopped(runMark(run3.sessionId, run3.agentStartedAt ?? run3.startedAt), root2);
191634
191799
  }
191635
- function failedRunResumeDiagnostic(run3, stopped2, zh) {
191800
+ function failedRunResumeDiagnostic(run3, stopped2, zh, manual = false) {
191636
191801
  const session = run3 && !isSessionMissingFailure(run3.failure) ? run3.resumeId ?? (run3.canResume ? run3.sessionId : void 0) : void 0;
191802
+ const exited = stopped2 && !!run3?.endedAt && (run3.status === "error" || run3.status === "stopped");
191803
+ const cleanupUnconfirmed = run3?.cleanup ? run3.status === "stopped" ? !stoppedCleanupConfirmed(run3.cleanup) : run3.cleanup.status === "unconfirmed" : false;
191804
+ const unconfirmedCleanup = run3?.managedProcess ? !!run3.pendingWrites || cleanupUnconfirmed || run3.failure?.code === "idle_timeout" && !idleStopConfirmed(run3.cleanup, session) : manual && run3?.failure?.code === "idle_timeout" && !run3.cleanup?.kept?.length ? false : !!run3?.pendingWrites || cleanupUnconfirmed;
191637
191805
  return resumeBlocked({
191638
- stopped: stopped2 && !!run3?.endedAt && run3.status === "error",
191806
+ stopped: exited,
191639
191807
  session,
191640
- unconfirmedCleanup: run3?.pendingWrites || run3?.cleanup?.status === "unconfirmed" || !!session && run3?.retryHistory?.at(-1)?.sessionAction !== "resume"
191808
+ unconfirmedCleanup
191641
191809
  }, zh);
191642
191810
  }
191643
191811
  function recoveryArgs(run3) {
@@ -191652,7 +191820,7 @@ function runsSpent(runs, since, job, io, machine, card) {
191652
191820
  async function runReview(job, ws, tasks, deps, io) {
191653
191821
  const since = Date.now();
191654
191822
  const failed = await setUp(job, ws, deps, io);
191655
- if (failed) return { ok: false, reason: failed };
191823
+ if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
191656
191824
  const akb = boardAkb(job, ws, deps, io);
191657
191825
  const args2 = io.flowRun ? recoveryArgs(io.flowRun) : ["memory", "review", "--task", ...tasks];
191658
191826
  const ran = await akb([...args2, "--follow", "--events", "--json"], true);
@@ -191701,7 +191869,7 @@ async function runAgent(job, ws, deps, io) {
191701
191869
  if (studio2) return { ok: false, reason: "Studio roles no longer run on their own." };
191702
191870
  const since = Date.now();
191703
191871
  const failed = await setUp(job, ws, deps, io);
191704
- if (failed) return { ok: false, reason: failed };
191872
+ if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
191705
191873
  if (io.flowRun) {
191706
191874
  const args3 = recoveryArgs(io.flowRun);
191707
191875
  const akb2 = boardAkb(job, ws, deps, io);
@@ -191852,7 +192020,7 @@ async function runFlow(job, ws, deps, io) {
191852
192020
  }
191853
192021
  }
191854
192022
  const failed = await setUp(job, ws, deps, io);
191855
- if (failed) return fail(failed);
192023
+ if (failed) return { ok: false, reason: failed, safeToRetry: !io.flowRun };
191856
192024
  let id2 = akbCardOf(ws);
191857
192025
  if (flow.phase === "land") {
191858
192026
  try {
@@ -191984,7 +192152,7 @@ ${pictures(job, ws, ws.number)}`);
191984
192152
  } };
191985
192153
  };
191986
192154
  const localArchive = () => isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws));
191987
- if (localArchive() && deliveryId && (observed.kind === "completed" || observed.kind === "resumable")) {
192155
+ if (localArchive() && (deliveryId ? observed.kind === "completed" || observed.kind === "resumable" : !flow.delivery_id && observed.kind === "none")) {
191988
192156
  if (observed.kind === "resumable") {
191989
192157
  const saved = await akb(["task", "archive", String(card), "--json"]);
191990
192158
  if (saved.code !== 0) return fail(refusal3(saved));
@@ -192040,8 +192208,8 @@ ${pictures(job, ws, ws.number)}`);
192040
192208
  if (flow.resume_execution && !io.flowRun) {
192041
192209
  const saved = await flowRunEvidence(ws, job, deps, flow.resume_execution);
192042
192210
  if (stopping(io)) return fail("");
192043
- if (!saved.run) return unverifiedResume(saved.diagnostic);
192044
- return await workOn(card, void 0, saved.run);
192211
+ if (!saved.stopped || saved.mismatched || saved.diagnostic) return unverifiedResume(saved.diagnostic);
192212
+ if (saved.run) return await workOn(card, void 0, saved.run);
192045
192213
  }
192046
192214
  const verification = flow.verify_delivery;
192047
192215
  if (verification) {
@@ -192091,6 +192259,9 @@ ${pictures(job, ws, ws.number)}`);
192091
192259
  if (io.lost()) return fail("");
192092
192260
  const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
192093
192261
  const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
192262
+ if (flow.phase === "implement") {
192263
+ return { ok: true, report: { ...spent, card, landReady: { deliveryId: reconciled.deliveryId } } };
192264
+ }
192094
192265
  return {
192095
192266
  ok: true,
192096
192267
  report: {
@@ -192102,6 +192273,14 @@ ${pictures(job, ws, ws.number)}`);
192102
192273
  }
192103
192274
  };
192104
192275
  }
192276
+ if (flow.phase === "implement" && verb === "implement" && (!reconciled || reconciled.kind === "none") && isArchived(ws, card) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws))) {
192277
+ const denied = await refreshReview("implement");
192278
+ if (denied) return fail(denied);
192279
+ if (io.lost()) return fail("");
192280
+ const runs2 = answerOf2(await akb(["run", "list", "--card", String(card), "--all", "--json"]))?.runs ?? [];
192281
+ const spent = spentBy([...learned, ...runsSpent(runs2, since, job, io, deps.machineId, card)], job);
192282
+ return { ok: true, report: { ...spent, card, landReady: {} } };
192283
+ }
192105
192284
  const runs = await boardRuns(deps.akb, ws, ["--card", String(card)]);
192106
192285
  if (!runs) return unverifiedResume(resumeBlocked({ stopped: false }, cloudLanguage(job) === "zh"));
192107
192286
  if (runs.some((run3) => !jobOwns(run3, job.id, deps.machineId) && !runStopped(run3))) return fail(`#${card} is already being worked on`);
@@ -192165,6 +192344,7 @@ ${pictures(job, ws, ws.number)}`);
192165
192344
  return fail(mismatchedReceipt);
192166
192345
  }
192167
192346
  if (restored.code === 0 && resumed?.landed && resumed.deliveryId) {
192347
+ if (flow.phase === "implement") return { ok: true, report: { card: id3, landReady: { deliveryId: resumed.deliveryId } } };
192168
192348
  return { ok: true, report: { card: id3, deliveryCompleted: true, deliveryId: resumed.deliveryId, ...landingOf(resumed.delivery) } };
192169
192349
  }
192170
192350
  const reason = restored.code === 0 ? void 0 : resumed?.error?.reason;
@@ -192185,7 +192365,8 @@ ${pictures(job, ws, ws.number)}`);
192185
192365
  } else if (deliveryId2) {
192186
192366
  const previous = answerOf2(await akb(["run", "list", "--card", String(id3), "--all", "--json"]))?.runs?.filter((r2) => ["implement", "conflict", "hook"].includes(r2.action ?? "") && r2.deliveryId === deliveryId2).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0))[0];
192187
192367
  if (previous) {
192188
- continuation = ["run", "resume", previous.sessionId, "--require-session"];
192368
+ const hasSession = !isSessionMissingFailure(previous.failure) && !!(previous.resumeId || previous.canResume);
192369
+ continuation = ["run", "resume", previous.sessionId, hasSession ? "--require-session" : "--new-session"];
192189
192370
  }
192190
192371
  }
192191
192372
  return void 0;
@@ -192260,6 +192441,13 @@ ${pictures(job, ws, ws.number)}`);
192260
192441
  const logged = continuation?.[1] === "log" ? continuation[2] : void 0;
192261
192442
  let answer = answerOf2(ran);
192262
192443
  let runs = await readRuns2();
192444
+ if (ran.code !== 0 && continuation?.[1] === "resume" && continuation.includes("--require-session") && !stopping(io) && runs.some((run3) => run3.sessionId === lastRun(answer) && isSessionMissingFailure(run3.failure))) {
192445
+ ran = await launch2(["run", "resume", continuation[2], "--new-session", "--follow", "--events", "--json"], true, void 0, effectiveVerb);
192446
+ if (ran.reviewRefused) return fail(ran.reviewRefused);
192447
+ if (io.lost()) return fail("");
192448
+ answer = answerOf2(ran);
192449
+ runs = await readRuns2();
192450
+ }
192263
192451
  if (ran.code !== 0 && !continuation && job.fork && job.transcript && !stopping(io) && runs.some((run3) => run3.sessionId === lastRun(answer) && run3.failure?.code === "codex_fork_source_missing")) {
192264
192452
  const failure3 = runs.find((run3) => run3.sessionId === lastRun(answer)).failure;
192265
192453
  if (io.recover) {
@@ -192356,7 +192544,15 @@ ${pictures(job, ws, ws.number)}`);
192356
192544
  report: { ...spent, ...tracked, failure: failureDetail }
192357
192545
  };
192358
192546
  }
192359
- if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting && !completed) {
192547
+ if (flow.phase === "implement" && effectiveVerb === "implement" && !rejected && !asked && !waiting) {
192548
+ if (completed) return { ok: true, report: {
192549
+ ...spent,
192550
+ card: id3,
192551
+ landReady: { deliveryId: completed },
192552
+ session: recent?.resumeId ?? answer?.agentSession,
192553
+ reply: recent?.result,
192554
+ ...history.length ? { retries: history } : {}
192555
+ } };
192360
192556
  if (!deliveryId || !recent || !runStopped(recent)) return fail("The implementation result or delivery workspace was not saved.");
192361
192557
  return { ok: true, report: {
192362
192558
  ...spent,
@@ -192454,18 +192650,29 @@ async function flowRunEvidence(ws, job, deps, execution = job.id, prior) {
192454
192650
  const candidates = owned.filter((run3) => !run3.parentId).sort((a2, b2) => (b2.startedAt ?? 0) - (a2.startedAt ?? 0));
192455
192651
  const previous = candidates.find((run3) => run3.cloudExecution?.job === execution) ?? candidates.find((run3) => run3.sessionId === prior?.id) ?? candidates[0];
192456
192652
  if (!previous || manual && previous.cloudExecution?.job !== execution) return { stopped: true, mismatched };
192457
- const resumeDiagnostic = failedRunResumeDiagnostic(previous, true, zh);
192653
+ if (manual && id2 && isArchived(ws, id2) && !asks(cardFile(ws)) && isSuccessfulArchive(cardFile(ws))) {
192654
+ return { stopped: true, mismatched };
192655
+ }
192656
+ const session = !isSessionMissingFailure(previous.failure) ? previous.resumeId ?? (previous.canResume ? previous.sessionId : void 0) : void 0;
192657
+ if (session && id2 && !await taskSessionMatches(ws, deps, session)) {
192658
+ return { stopped: true, mismatched: true, diagnostic: zh ? "\u539F\u4F1A\u8BDD\u5F52\u5C5E\u65E0\u6CD5\u6838\u5B9E\u3002" : "Could not verify that the session belongs to this task." };
192659
+ }
192660
+ const resumeDiagnostic = failedRunResumeDiagnostic(previous, true, zh, manual);
192458
192661
  if (manual) {
192662
+ if (!session && (!previous.managedProcess || stoppedCleanupConfirmed(previous.cleanup) || !previous.cleanup)) {
192663
+ return { stopped: true, mismatched };
192664
+ }
192459
192665
  if (resumeDiagnostic) return { stopped: true, diagnostic: resumeDiagnostic };
192460
192666
  return { stopped: true, mismatched, run: { id: previous.sessionId, finished: false, card: id2 || void 0, deliveryId: previous.deliveryId } };
192461
192667
  }
192462
192668
  const terminal = job.flow && previous.status === "error" && previous.retryPause ? previous.failure : void 0;
192463
192669
  const failure3 = terminal && previous.retryPause === "limit" ? { ...terminal, code: terminal.code ?? "retry_exhausted" } : terminal;
192670
+ const cleanupUnconfirmed = previous.cleanup ? previous.status === "stopped" ? !stoppedCleanupConfirmed(previous.cleanup) : previous.cleanup.status === "unconfirmed" : false;
192464
192671
  const recovery = agentRecovery({
192465
192672
  stopped: true,
192466
192673
  completed: previous.status === "done" || !!failure3,
192467
- session: previous.resumeId ?? (previous.canResume ? previous.sessionId : void 0),
192468
- unconfirmedCleanup: !!previous.retryPause || previous.pendingWrites || previous.cleanup?.status === "unconfirmed"
192674
+ session,
192675
+ unconfirmedCleanup: !!previous.retryPause || !!previous.pendingWrites || cleanupUnconfirmed
192469
192676
  });
192470
192677
  if (recovery === "unsafe") return { stopped: true, mismatched };
192471
192678
  const { sessionId, runtime, startedAt, usage, costUsd, costIncomplete, context } = previous;
@@ -193644,7 +193851,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
193644
193851
  saved.report = report2;
193645
193852
  }
193646
193853
  }
193647
- if (flow && previous && job.projectDir) {
193854
+ if (flow && (priorExecution || sourceId) && job.projectDir) {
193648
193855
  const folder3 = folderFor(job);
193649
193856
  if (folder3 && !("refused" in folder3)) {
193650
193857
  const ws2 = openTaskFolder(job, folder3.cwd);
@@ -194909,10 +195116,11 @@ ${body}` : body;
194909
195116
  if (stopped3) return finishClaimed("stopped", "", { ...result.report, ...proof });
194910
195117
  if (!result.ok) {
194911
195118
  const reason = result.exhausted || result.failure?.code === "retry_exhausted" ? "task_retry_exhausted: " + result.reason : result.reason;
195119
+ const safeToRetry = result.exhausted === true || result.safeToRetry === true;
194912
195120
  const failureDetail2 = result.report?.failure ?? buildFailureDetail(
194913
195121
  result.failure ?? makeFailure("runtime", result.reason || "The run failed."),
194914
- result.exhausted ? "limit" : "unsafe",
194915
- result.exhausted === true,
195122
+ result.exhausted ? "limit" : safeToRetry ? "manual" : "unsafe",
195123
+ safeToRetry,
194916
195124
  void 0,
194917
195125
  result.reason
194918
195126
  );