wildcrane-runner 0.6.56 → 0.6.58

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/settings.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.56 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.58 — 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;
@@ -5751,8 +5751,8 @@ var require_util2 = __commonJS({
5751
5751
  }
5752
5752
  return values;
5753
5753
  }
5754
- function getDecodeSplit(name, list) {
5755
- const value = list.get(name, true);
5754
+ function getDecodeSplit(name, list2) {
5755
+ const value = list2.get(name, true);
5756
5756
  if (value === null) {
5757
5757
  return null;
5758
5758
  }
@@ -19811,9 +19811,9 @@ var require_headers = __commonJS({
19811
19811
  // https://fetch.spec.whatwg.org/#dom-headers-getsetcookie
19812
19812
  getSetCookie() {
19813
19813
  webidl.brandCheck(this, _Headers);
19814
- const list = this.#headersList.cookies;
19815
- if (list) {
19816
- return [...list];
19814
+ const list2 = this.#headersList.cookies;
19815
+ if (list2) {
19816
+ return [...list2];
19817
19817
  }
19818
19818
  return [];
19819
19819
  }
@@ -19837,8 +19837,8 @@ var require_headers = __commonJS({
19837
19837
  * @param {Headers} target
19838
19838
  * @param {HeadersList} list
19839
19839
  */
19840
- static setHeadersList(target, list) {
19841
- target.#headersList = list;
19840
+ static setHeadersList(target, list2) {
19841
+ target.#headersList = list2;
19842
19842
  }
19843
19843
  };
19844
19844
  var { getHeadersGuard, setHeadersGuard, getHeadersList, setHeadersList } = Headers;
@@ -20789,13 +20789,13 @@ var require_request2 = __commonJS({
20789
20789
  if (this.signal.aborted) {
20790
20790
  ac.abort(this.signal.reason);
20791
20791
  } else {
20792
- let list = dependentControllerMap.get(this.signal);
20793
- if (list === void 0) {
20794
- list = /* @__PURE__ */ new Set();
20795
- dependentControllerMap.set(this.signal, list);
20792
+ let list2 = dependentControllerMap.get(this.signal);
20793
+ if (list2 === void 0) {
20794
+ list2 = /* @__PURE__ */ new Set();
20795
+ dependentControllerMap.set(this.signal, list2);
20796
20796
  }
20797
20797
  const acRef = new WeakRef(ac);
20798
- list.add(acRef);
20798
+ list2.add(acRef);
20799
20799
  util.addAbortListener(
20800
20800
  ac.signal,
20801
20801
  buildAbort(acRef)
@@ -26980,8 +26980,8 @@ function alive(pid) {
26980
26980
  var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
26981
26981
 
26982
26982
  // src/protocol.ts
26983
- var VERSION = true ? "0.6.56" : "0.0.0";
26984
- var AKB_VERSION = true ? "0.11.44" : "0.0.0";
26983
+ var VERSION = true ? "0.6.58" : "0.0.0";
26984
+ var AKB_VERSION = true ? "0.11.45" : "0.0.0";
26985
26985
 
26986
26986
  // src/api.ts
26987
26987
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok"];
@@ -27261,7 +27261,7 @@ var OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
27261
27261
  var AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
27262
27262
  var SCHEDULE_READS = ["archived-cards", "chats", "dismissals"];
27263
27263
  var isScheduleReads = (value) => SCHEDULE_READS.includes(value);
27264
- function parseSpecAgent(text3, from, file2, builtIn = false, list = () => []) {
27264
+ function parseSpecAgent(text3, from, file2, builtIn = false, list2 = () => []) {
27265
27265
  let named = "";
27266
27266
  const bad = (why, old2) => ({
27267
27267
  problem: `${from}: ${why}`,
@@ -27323,7 +27323,7 @@ function parseSpecAgent(text3, from, file2, builtIn = false, list = () => []) {
27323
27323
  ...declaredSession ? { session: "new" } : {},
27324
27324
  memory: names(akb.memory),
27325
27325
  memoryFiles: { workspace },
27326
- files: list(),
27326
+ files: list2(),
27327
27327
  body: instructions,
27328
27328
  from,
27329
27329
  builtIn,
@@ -27352,12 +27352,12 @@ function memoryPaths(raw, folder = "memory/agents/<name>/") {
27352
27352
  const block = map(raw);
27353
27353
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
27354
27354
  if (!block || extra.length) return `\`akb.memoryFiles\` with ${block ? `\`${extra.join("`, `")}\`` : "no `workspace:` list"} \u2014 it holds only \`workspace: [<path>, ...]\``;
27355
- const list = block.workspace;
27356
- if (list === void 0) return [];
27357
- if (!Array.isArray(list) || list.some((v) => typeof v !== "string" || !v.trim())) {
27355
+ const list2 = block.workspace;
27356
+ if (list2 === void 0) return [];
27357
+ if (!Array.isArray(list2) || list2.some((v) => typeof v !== "string" || !v.trim())) {
27358
27358
  return "`akb.memoryFiles.workspace` that is not a list of paths \u2014 write `workspace: [style.md]`";
27359
27359
  }
27360
- const paths = [...new Set(list.map((v) => v.trim()))];
27360
+ const paths = [...new Set(list2.map((v) => v.trim()))];
27361
27361
  const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
27362
27362
  if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
27363
27363
  return paths;
@@ -27925,8 +27925,8 @@ function readFlows() {
27925
27925
  }
27926
27926
  const project = boardProject();
27927
27927
  if (!project || !readSession()) return [];
27928
- const list = readJson(listFile(project))?.studios ?? [];
27929
- const flows2 = list.flatMap((w) => {
27928
+ const list2 = readJson(listFile(project))?.studios ?? [];
27929
+ const flows2 = list2.flatMap((w) => {
27930
27930
  const held = readVersion(w.id, w.version);
27931
27931
  return held ? flowOf(held) ?? [] : [];
27932
27932
  });
@@ -28022,12 +28022,12 @@ function update(change) {
28022
28022
  }
28023
28023
  }
28024
28024
  function adoptLegacy() {
28025
- if (readSession() && !readGrants().accounts) update((list) => list);
28025
+ if (readSession() && !readGrants().accounts) update((list2) => list2);
28026
28026
  }
28027
28027
  var allow = (dir) => {
28028
- update((list) => [...list, dir]);
28028
+ update((list2) => [...list2, dir]);
28029
28029
  };
28030
- var disallow = (dir) => update((list) => list.filter((p) => p !== dir));
28030
+ var disallow = (dir) => update((list2) => list2.filter((p) => p !== dir));
28031
28031
  var SYSTEM_MAC = ["/System", "/Library", "/Applications", "/usr", "/bin", "/sbin", "/etc", "/var", "/private", "/opt", "/cores", "/dev"];
28032
28032
  var SYSTEM_WIN = ["Windows", "Program Files", "Program Files (x86)", "ProgramData"];
28033
28033
  var here = () => ({ platform: process.platform, home: os4.homedir(), resolve: realpath });
@@ -28300,11 +28300,11 @@ function checkHarnesses(harnesses) {
28300
28300
  if (providers.length > 1) {
28301
28301
  throw new Error(`harness "${harness.name}": a connector declares one provider list, not ${providers.length}`);
28302
28302
  }
28303
- const list = providers[0];
28304
- if (!list) continue;
28305
- if (!list.providers?.length) throw new Error(`harness "${harness.name}": the provider setting "${list.key}" offers no providers`);
28303
+ const list2 = providers[0];
28304
+ if (!list2) continue;
28305
+ if (!list2.providers?.length) throw new Error(`harness "${harness.name}": the provider setting "${list2.key}" offers no providers`);
28306
28306
  const ids = /* @__PURE__ */ new Set();
28307
- for (const provider of list.providers) {
28307
+ for (const provider of list2.providers) {
28308
28308
  if (ids.has(provider.id)) throw new Error(`harness "${harness.name}": two providers share the id "${provider.id}"`);
28309
28309
  ids.add(provider.id);
28310
28310
  for (const need of [...provider.needs, ...provider.preferWhenSet ?? []]) {
@@ -28317,8 +28317,8 @@ function checkHarnesses(harnesses) {
28317
28317
  if (!provider.needs.includes(key)) throw new Error(`harness "${harness.name}": the provider "${provider.id}" renames the variable of "${key}" without needing it`);
28318
28318
  }
28319
28319
  }
28320
- if (list.defaultProvider && !ids.has(list.defaultProvider)) {
28321
- throw new Error(`harness "${harness.name}": the default provider "${list.defaultProvider}" isn't on the list`);
28320
+ if (list2.defaultProvider && !ids.has(list2.defaultProvider)) {
28321
+ throw new Error(`harness "${harness.name}": the default provider "${list2.defaultProvider}" isn't on the list`);
28322
28322
  }
28323
28323
  }
28324
28324
  }
@@ -28579,9 +28579,9 @@ var probeOptions = (file2) => ({ cwd: os5.tmpdir(), env: copyEnv(file2), windows
28579
28579
  function probe(file2) {
28580
28580
  const key = keyOf(file2);
28581
28581
  const start = spawnable(file2, ["--version"], { ...probeOptions(file2), stdio: ["ignore", "pipe", "pipe"], timeout: PROBE_MS });
28582
- const run = spawnSync2(start.command, start.args, { ...start.options, encoding: "utf8" });
28583
- const code = run.error?.code;
28584
- const answer = { key, at: Date.now(), ...judge(code, run.status, run.stdout ?? "", run.stderr ?? "") };
28582
+ const run2 = spawnSync2(start.command, start.args, { ...start.options, encoding: "utf8" });
28583
+ const code = run2.error?.code;
28584
+ const answer = { key, at: Date.now(), ...judge(code, run2.status, run2.stdout ?? "", run2.stderr ?? "") };
28585
28585
  keep(file2, answer);
28586
28586
  return answer;
28587
28587
  }
@@ -28725,8 +28725,8 @@ function createEventCollector() {
28725
28725
  case "tool_call_update": {
28726
28726
  const id = str2(u.toolCallId);
28727
28727
  if (todoCalls.has(id)) {
28728
- const list = obj(u.rawInput).todos;
28729
- if (Array.isArray(list) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list) } });
28728
+ const list2 = obj(u.rawInput).todos;
28729
+ if (Array.isArray(list2) && !str2(obj(u.rawInput)._toolName)) queue.push({ kind: "plan", data: { entries: entriesOf(list2) } });
28730
28730
  return;
28731
28731
  }
28732
28732
  release(id, targetIn(u));
@@ -28883,10 +28883,10 @@ function failedWith(ev) {
28883
28883
  return str2(ev.result).trim() || "the agent reported the session failed";
28884
28884
  }
28885
28885
  function denials(ev) {
28886
- const list = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
28887
- const names2 = [...new Set(list.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
28886
+ const list2 = Array.isArray(ev.permission_denials) ? ev.permission_denials : [];
28887
+ const names2 = [...new Set(list2.map((raw) => str2(obj(raw).tool_name)).filter(Boolean))];
28888
28888
  if (!names2.length) return "";
28889
- return `[refused] ${list.length} tool call${list.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
28889
+ return `[refused] ${list2.length} tool call${list2.length === 1 ? "" : "s"} were not allowed: ${names2.join(", ")}
28890
28890
  `;
28891
28891
  }
28892
28892
  function promptSize(raw) {
@@ -29043,6 +29043,37 @@ var addUsage = (a, b) => ({
29043
29043
  output: a.output + b.output
29044
29044
  });
29045
29045
 
29046
+ // ../cli/src/lib/agent/wire/background.ts
29047
+ function createBackgroundTasks() {
29048
+ const tasks = /* @__PURE__ */ new Map();
29049
+ return {
29050
+ update(id, status2, result = "") {
29051
+ if (!id) return false;
29052
+ const previous = tasks.get(id);
29053
+ if (previous?.status === status2 && previous.result === result) return false;
29054
+ tasks.set(id, { status: status2, result });
29055
+ return true;
29056
+ },
29057
+ results: () => [...tasks].map(([id, task]) => ({ id, ...task })),
29058
+ running: () => [...tasks].filter(([, t2]) => t2.status === "running").map(([id]) => id),
29059
+ count: () => [...tasks.values()].filter((t2) => t2.status === "running").length,
29060
+ failure: () => [...tasks].filter(([, t2]) => t2.status === "failed").map(([id, t2]) => t2.result || `Background task ${id} failed.`).join("\n") || void 0
29061
+ };
29062
+ }
29063
+ function createBackgroundWait(milliseconds, expired) {
29064
+ let timer;
29065
+ return {
29066
+ pending() {
29067
+ if (!timer && milliseconds > 0) timer = setTimeout(expired, milliseconds);
29068
+ },
29069
+ close() {
29070
+ clearTimeout(timer);
29071
+ timer = void 0;
29072
+ }
29073
+ };
29074
+ }
29075
+ var backgroundWaitMessage = (minutes) => `the agent's background tasks did not finish within ${minutes / 60} hours, so the run was ended.`;
29076
+
29046
29077
  // ../cli/src/lib/agent/wire/codex-session.ts
29047
29078
  import { readFileSync, readdirSync, statSync } from "node:fs";
29048
29079
  import { homedir } from "node:os";
@@ -29318,6 +29349,31 @@ function createCodexStreamRenderer(carried = false) {
29318
29349
  let lookedAt = 0;
29319
29350
  const events = createEventCollector();
29320
29351
  const started = /* @__PURE__ */ new Set();
29352
+ const background = createBackgroundTasks();
29353
+ const subagents = /* @__PURE__ */ new Set();
29354
+ const collabItems = /* @__PURE__ */ new Set();
29355
+ const collab = (item, done) => {
29356
+ if (item.type !== "collab_tool_call") return;
29357
+ const key = `${str2(item.id)}:${done}`;
29358
+ if (collabItems.has(key)) return;
29359
+ collabItems.add(key);
29360
+ for (const [id, raw] of Object.entries(obj(item.agents_states))) {
29361
+ const state = obj(raw);
29362
+ const status2 = str2(state.status);
29363
+ if (!["pending_init", "running", "completed", "interrupted", "errored", "shutdown", "not_found"].includes(status2)) continue;
29364
+ const previous = background.results().find((t2) => t2.id === id);
29365
+ if (["shutdown", "not_found"].includes(status2) && previous && previous.status !== "running") continue;
29366
+ if (!subagents.has(id)) {
29367
+ subagents.add(id);
29368
+ events.subagent(`agent:${id}`, str2(item.prompt) || "Agent");
29369
+ }
29370
+ const running = status2 === "pending_init" || status2 === "running";
29371
+ const failed = !running && status2 !== "completed";
29372
+ if (background.update(id, running ? "running" : failed ? "failed" : "completed", str2(state.message)) && !running) {
29373
+ events.toolResult(`agent:${id}`, failed ? "failed" : "completed", str2(state.message));
29374
+ }
29375
+ }
29376
+ };
29321
29377
  const look = (now) => {
29322
29378
  if (!threadId) return;
29323
29379
  const at = Date.now();
@@ -29344,6 +29400,7 @@ function createCodexStreamRenderer(carried = false) {
29344
29400
  if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
29345
29401
  return "";
29346
29402
  case "item.started":
29403
+ collab(obj(ev.item), false);
29347
29404
  itemEvents(events, started, obj(ev.item), false);
29348
29405
  return renderStarted(obj(ev.item));
29349
29406
  case "item.updated":
@@ -29351,6 +29408,7 @@ function createCodexStreamRenderer(carried = false) {
29351
29408
  return "";
29352
29409
  case "item.completed": {
29353
29410
  const item = obj(ev.item);
29411
+ collab(item, true);
29354
29412
  if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(str2(item.tool))) {
29355
29413
  const content = obj(item.result).content;
29356
29414
  for (const block of Array.isArray(content) ? content : []) {
@@ -29422,7 +29480,8 @@ function createCodexStreamRenderer(carried = false) {
29422
29480
  // whose rates the board knows.
29423
29481
  costUsd: () => priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()),
29424
29482
  resumeId: () => threadId,
29425
- failure: () => failure2,
29483
+ failure: () => failure2 ?? background.failure(),
29484
+ background: () => subagents.size ? background.count() : void 0,
29426
29485
  events: events.events
29427
29486
  };
29428
29487
  }
@@ -29655,6 +29714,21 @@ function createKimiStreamRenderer(cwd) {
29655
29714
  };
29656
29715
  }
29657
29716
 
29717
+ // ../cli/src/lib/shared/conversation.ts
29718
+ var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
29719
+ function bounded(work, ms, reason) {
29720
+ return new Promise((resolve2, reject) => {
29721
+ const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
29722
+ work.then((value) => {
29723
+ clearTimeout(timer);
29724
+ resolve2(value);
29725
+ }, (error) => {
29726
+ clearTimeout(timer);
29727
+ reject(error);
29728
+ });
29729
+ });
29730
+ }
29731
+
29658
29732
  // ../cli/src/lib/agent/wire/acp.ts
29659
29733
  import fs15 from "node:fs";
29660
29734
 
@@ -29724,6 +29798,9 @@ function connect(stdout, stdin, onCall, dialect = {}) {
29724
29798
  send2({ id, method, params });
29725
29799
  });
29726
29800
  },
29801
+ notify(method, params = {}) {
29802
+ send2({ method, params });
29803
+ },
29727
29804
  /** Answer something the agent asked us. */
29728
29805
  reply(id, result) {
29729
29806
  send2({ id, result });
@@ -29786,8 +29863,8 @@ function createTail(log) {
29786
29863
  // ../cli/package.json
29787
29864
  var package_default = {
29788
29865
  name: "wildcrane",
29789
- version: "0.11.44",
29790
- akbContract: 11,
29866
+ version: "0.11.45",
29867
+ akbContract: 12,
29791
29868
  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.",
29792
29869
  keywords: [
29793
29870
  "kanban",
@@ -29873,23 +29950,23 @@ function saidBy(update3) {
29873
29950
  function modelOf(answer) {
29874
29951
  const current2 = str2(obj(answer.models).currentModelId).trim();
29875
29952
  if (current2) return modelsIn(answer).find((m) => m.modelId === current2)?.name ?? current2;
29876
- const list = Array.isArray(answer.configOptions) ? answer.configOptions : [];
29877
- for (const raw of list) {
29953
+ const list2 = Array.isArray(answer.configOptions) ? answer.configOptions : [];
29954
+ for (const raw of list2) {
29878
29955
  const option = obj(raw);
29879
29956
  if (option.id === "model") return str2(option.currentValue).trim() || void 0;
29880
29957
  }
29881
29958
  return void 0;
29882
29959
  }
29883
29960
  function modelsIn(answer) {
29884
- const list = obj(answer.models).availableModels;
29885
- return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
29961
+ const list2 = obj(answer.models).availableModels;
29962
+ return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
29886
29963
  const modelId = str2(m.modelId);
29887
29964
  return modelId ? [{ modelId, name: str2(m.name) || modelId }] : [];
29888
29965
  });
29889
29966
  }
29890
29967
  function pickedModel(answer, wanted) {
29891
- const list = modelsIn(answer);
29892
- return list.find((m) => m.modelId === wanted) ?? list.find((m) => m.name === wanted || m.modelId.split("[")[0] === wanted);
29968
+ const list2 = modelsIn(answer);
29969
+ return list2.find((m) => m.modelId === wanted) ?? list2.find((m) => m.name === wanted || m.modelId.split("[")[0] === wanted);
29893
29970
  }
29894
29971
  function usageOf2(value, grossInput = false) {
29895
29972
  const usage = obj(value);
@@ -29945,6 +30022,11 @@ function createAcpClient(options = {}) {
29945
30022
  }
29946
30023
  async function oneTurn(io, options) {
29947
30024
  const tail = createTail(io.log);
30025
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
30026
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
30027
+ let started = false;
30028
+ let contentAt = 0;
30029
+ let currentSession = "";
29948
30030
  const events = createEventCollector();
29949
30031
  const emit = () => {
29950
30032
  for (const e of events.events()) io.event?.(e);
@@ -29957,7 +30039,16 @@ async function oneTurn(io, options) {
29957
30039
  io.stdin,
29958
30040
  (msg) => {
29959
30041
  if (msg.method === "session/update") {
29960
- if (live) {
30042
+ if (live && (!obj(msg.params).sessionId || obj(msg.params).sessionId === currentSession)) {
30043
+ const kind = str2(obj(obj(msg.params).update).sessionUpdate);
30044
+ if (!started && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
30045
+ started = true;
30046
+ phase("started");
30047
+ }
30048
+ if (kind === "agent_message_chunk" && Date.now() - contentAt >= 1e3) {
30049
+ contentAt = Date.now();
30050
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
30051
+ }
29961
30052
  update2(obj(msg.params).update, tail, (usd) => costUsd = usd, (window) => context = window);
29962
30053
  events.update(obj(msg.params).update);
29963
30054
  emit();
@@ -29985,20 +30076,22 @@ async function oneTurn(io, options) {
29985
30076
  );
29986
30077
  try {
29987
30078
  const mcpServers = options.mcpConfig ? mcpServersIn(options.mcpConfig) : [];
29988
- await rpc.call("initialize", {
30079
+ phase("preparing");
30080
+ await bounded(rpc.call("initialize", {
29989
30081
  protocolVersion: PROTOCOL_VERSION,
29990
30082
  clientCapabilities: CLIENT_CAPABILITIES,
29991
30083
  clientInfo: { name: "ai4kanban", version: SKILL_VERSION }
29992
- });
30084
+ }), preparingUntil - Date.now(), "ACP initialize timed out.");
30085
+ phase("initialized");
29993
30086
  let sessionId = io.resumeId ?? "";
29994
30087
  let prompt = io.prompt;
29995
30088
  let opened;
29996
30089
  if (sessionId) {
29997
30090
  try {
29998
- opened = await rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers });
30091
+ opened = await bounded(rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers }), preparingUntil - Date.now(), "ACP session/load timed out.");
29999
30092
  } catch (e) {
30000
30093
  if (!sessionGone(e) || !io.restartPrompt) throw e;
30001
- const fresh = await newSession(rpc, io.cwd, mcpServers);
30094
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
30002
30095
  opened = fresh.opened;
30003
30096
  sessionId = fresh.sessionId;
30004
30097
  prompt = io.restartPrompt;
@@ -30008,7 +30101,7 @@ async function oneTurn(io, options) {
30008
30101
  emit();
30009
30102
  }
30010
30103
  } else {
30011
- const fresh = await newSession(rpc, io.cwd, mcpServers);
30104
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
30012
30105
  opened = fresh.opened;
30013
30106
  sessionId = fresh.sessionId;
30014
30107
  io.gotResumeId(sessionId);
@@ -30017,11 +30110,15 @@ async function oneTurn(io, options) {
30017
30110
  if (options.model) {
30018
30111
  const listed2 = obj(opened.models).currentModelId !== void 0;
30019
30112
  const picked = listed2 ? pickedModel(opened, options.model) : void 0;
30020
- const set = listed2 ? await rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }) : await rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model });
30113
+ const set = listed2 ? await bounded(rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }), preparingUntil - Date.now(), "ACP session/set_model timed out.") : await bounded(rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model }), preparingUntil - Date.now(), "ACP session/set_config_option timed out.");
30021
30114
  model = picked?.name ?? modelOf(set) ?? options.model;
30022
30115
  }
30023
30116
  if (model) io.gotModel(model);
30117
+ if (Date.now() >= preparingUntil) throw Error("ACP preparation timed out.");
30118
+ phase("ready");
30119
+ currentSession = sessionId;
30024
30120
  live = true;
30121
+ phase("submitted");
30025
30122
  const done = await rpc.call("session/prompt", {
30026
30123
  sessionId,
30027
30124
  prompt: [{ type: "text", text: prompt }]
@@ -30377,6 +30474,358 @@ function decide2(params, tail) {
30377
30474
  return { decision: "deny", reason: "this board run can't answer a permission question" };
30378
30475
  }
30379
30476
 
30477
+ // ../cli/src/lib/agent/settings.ts
30478
+ var BACKGROUND_WAIT = { minutes: 120 };
30479
+
30480
+ // ../cli/src/lib/agent/wire/codex.ts
30481
+ var list = (value) => Array.isArray(value) ? value.map(obj) : [];
30482
+ function createCodexConnection(argv) {
30483
+ const execAt = argv.indexOf("exec");
30484
+ if (execAt < 1) return void 0;
30485
+ const server = [argv[0], "app-server"];
30486
+ const options = { images: [] };
30487
+ const roots = [];
30488
+ for (let i = 1; i < argv.length; i++) {
30489
+ if (i === execAt) continue;
30490
+ const arg = argv[i];
30491
+ const [flag, inline] = arg.split(/=(.*)/s);
30492
+ const value = () => inline ?? argv[++i];
30493
+ if (["--json", "--experimental-json", "--skip-git-repo-check"].includes(arg)) continue;
30494
+ if (["-c", "--config", "--enable", "--disable"].includes(flag)) {
30495
+ const v = value();
30496
+ if (!v) return void 0;
30497
+ server.push(flag, v);
30498
+ } else if (["-m", "--model", "-s", "--sandbox"].includes(flag)) {
30499
+ const v = value();
30500
+ if (!v) return void 0;
30501
+ server.push("-c", `${flag === "-m" || flag === "--model" ? "model" : "sandbox_mode"}=${JSON.stringify(v)}`);
30502
+ } else if (arg === "--dangerously-bypass-approvals-and-sandbox") {
30503
+ server.push("-c", 'approval_policy="never"', "-c", 'sandbox_mode="danger-full-access"');
30504
+ } else if (arg === "--full-auto") {
30505
+ server.push("-c", 'approval_policy="on-request"', "-c", 'sandbox_mode="workspace-write"');
30506
+ } else if (flag === "--add-dir") {
30507
+ const v = value();
30508
+ if (!v) return void 0;
30509
+ roots.push(v);
30510
+ } else if (flag === "-C" || flag === "--cd") {
30511
+ options.cwd = value();
30512
+ if (!options.cwd) return void 0;
30513
+ } else if (flag === "-i" || flag === "--image") {
30514
+ const v = value();
30515
+ if (!v) return void 0;
30516
+ options.images.push(v);
30517
+ } else if (arg === "resume" || arg === "fork") {
30518
+ options.mode = arg;
30519
+ options.threadId = argv[++i];
30520
+ if (!options.threadId || options.threadId.startsWith("-")) return void 0;
30521
+ } else {
30522
+ return void 0;
30523
+ }
30524
+ }
30525
+ if (roots.length) server.push("-c", `sandbox_workspace_write.writable_roots=${JSON.stringify(roots)}`);
30526
+ return { argv: server, client: createCodexClient(options) };
30527
+ }
30528
+ function createCodexClient(options = { images: [] }) {
30529
+ const tasks = createBackgroundTasks();
30530
+ return {
30531
+ structured: true,
30532
+ background: tasks.count,
30533
+ turn: (io) => run(io, options, tasks)
30534
+ };
30535
+ }
30536
+ async function run(io, options, tasks) {
30537
+ const renderer = createCodexStreamRenderer();
30538
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
30539
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
30540
+ let submitted = false;
30541
+ let started = false;
30542
+ let contentAt = 0;
30543
+ let startupTimer;
30544
+ const began = () => {
30545
+ if (!submitted || started || ended) return;
30546
+ started = true;
30547
+ clearTimeout(startupTimer);
30548
+ phase("started");
30549
+ };
30550
+ const children = /* @__PURE__ */ new Set();
30551
+ const commands = /* @__PURE__ */ new Set();
30552
+ const seenItems = /* @__PURE__ */ new Set();
30553
+ const completedTurns = /* @__PURE__ */ new Set();
30554
+ const historicalTurns = /* @__PURE__ */ new Set();
30555
+ let currentTurn2 = "";
30556
+ let threadId = "";
30557
+ let active = true;
30558
+ let waiting = false;
30559
+ let terminalListing = true;
30560
+ let timer;
30561
+ let ended = false;
30562
+ let checking = false;
30563
+ let context;
30564
+ let total;
30565
+ let baseline;
30566
+ let model;
30567
+ let provider;
30568
+ let resolve2;
30569
+ const done = new Promise((r) => {
30570
+ resolve2 = r;
30571
+ });
30572
+ const deadline = createBackgroundWait(BACKGROUND_WAIT.minutes * 6e4, () => end(backgroundWaitMessage(BACKGROUND_WAIT.minutes)));
30573
+ const emit = (type, extra = {}) => {
30574
+ io.log(renderer.push(JSON.stringify({ type, ...extra }) + "\n"));
30575
+ for (const event2 of renderer.events?.() ?? []) io.event?.(event2);
30576
+ };
30577
+ const end = (error) => {
30578
+ if (ended) return;
30579
+ ended = true;
30580
+ clearTimeout(timer);
30581
+ clearTimeout(startupTimer);
30582
+ deadline.close();
30583
+ io.stdout.off("close", closed);
30584
+ io.log(renderer.flush());
30585
+ const usage = total && (!options.threadId && !io.resumeId ? total : baseline ? {
30586
+ input: Math.max(0, total.input - baseline.input),
30587
+ cacheRead: Math.max(0, total.cacheRead - baseline.cacheRead),
30588
+ cacheCreation: Math.max(0, total.cacheCreation - baseline.cacheCreation),
30589
+ output: Math.max(0, total.output - baseline.output)
30590
+ } : void 0);
30591
+ const failure2 = error || tasks.failure();
30592
+ if (failure2) io.event?.({ kind: "error", data: { text: failure2 } });
30593
+ resolve2({ ok: !failure2, error: failure2, result: renderer.result(), replyParts: renderer.replyParts?.(), usage, context, costUsd: priceUsd(provider, model, usage) });
30594
+ };
30595
+ const closed = () => end("Codex closed the connection before all work and results finished.");
30596
+ io.stdout.once("close", closed);
30597
+ const update3 = (id, state, title = "") => {
30598
+ if (ended) return;
30599
+ const status2 = str2(state.status);
30600
+ if (!status2 || !id) return;
30601
+ const previous = tasks.results().find((t2) => t2.id === `agent:${id}`);
30602
+ if (["shutdown", "notFound", "not_found"].includes(status2) && previous && previous.status !== "running") return;
30603
+ const running = ["pendingInit", "running", "pending_init"].includes(status2);
30604
+ const failed = ["interrupted", "errored", "shutdown", "notFound", "not_found"].includes(status2);
30605
+ if (!running && !failed && status2 !== "completed") return;
30606
+ const known2 = children.has(id);
30607
+ children.add(id);
30608
+ if (!known2) io.event?.({ kind: "tool_call", data: { toolCallId: `agent:${id}`, title: targetOf(title) || "Agent", kind: "other", status: "in_progress", subagent: true } });
30609
+ if (tasks.update(`agent:${id}`, running ? "running" : failed ? "failed" : "completed", str2(state.message)) && !running) {
30610
+ io.event?.({ kind: "tool_call_update", data: { toolCallId: `agent:${id}`, status: failed ? "failed" : "completed", result: str2(state.message) } });
30611
+ }
30612
+ };
30613
+ const item = (raw, completed, proof = true) => {
30614
+ if (ended) return;
30615
+ const id = str2(raw.id);
30616
+ if (raw.type === "collabAgentToolCall") {
30617
+ if (proof) began();
30618
+ const key2 = `${id}:${completed}`;
30619
+ if (seenItems.has(key2)) return;
30620
+ seenItems.add(key2);
30621
+ for (const [child, state] of Object.entries(obj(raw.agentsStates))) update3(child, obj(state), str2(raw.prompt));
30622
+ for (const child of Array.isArray(raw.receiverThreadIds) ? raw.receiverThreadIds : []) {
30623
+ if (typeof child === "string" && !children.has(child) && raw.tool === "spawnAgent") update3(child, { status: "running" }, str2(raw.prompt));
30624
+ }
30625
+ return;
30626
+ }
30627
+ if (raw.type === "commandExecution") {
30628
+ if (seenItems.has(`${id}:true`)) return;
30629
+ if (raw.status === "inProgress") completed = false;
30630
+ if (!completed) {
30631
+ commands.add(id);
30632
+ if (tasks.results().some((t2) => t2.id === `command:${id}`)) tasks.update(`command:${id}`, "running");
30633
+ } else {
30634
+ commands.delete(id);
30635
+ const failed = raw.status === "failed" || typeof raw.exitCode === "number" && raw.exitCode !== 0;
30636
+ if (tasks.results().some((t2) => t2.id === `command:${id}`)) tasks.update(`command:${id}`, failed ? "failed" : "completed", str2(raw.aggregatedOutput));
30637
+ }
30638
+ }
30639
+ const key = `${id}:${completed}`;
30640
+ if (seenItems.has(key)) return;
30641
+ seenItems.add(key);
30642
+ const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
30643
+ const type = types[str2(raw.type)];
30644
+ if (!type) return;
30645
+ if (proof) began();
30646
+ emit(completed ? "item.completed" : "item.started", { item: {
30647
+ ...raw,
30648
+ type,
30649
+ ...raw.type === "imageGeneration" ? { path: raw.savedPath ?? raw.path } : {},
30650
+ ...raw.type === "fileChange" ? { changes: list(raw.changes).map((c) => ({ ...c, kind: str2(obj(c.kind).type) || c.kind })) } : {},
30651
+ aggregated_output: raw.aggregatedOutput,
30652
+ exit_code: raw.exitCode,
30653
+ status: raw.status === "inProgress" ? "in_progress" : raw.status
30654
+ } });
30655
+ };
30656
+ const start = async (text3, images = []) => {
30657
+ active = true;
30658
+ waiting = false;
30659
+ submitted = true;
30660
+ currentTurn2 = "";
30661
+ started = false;
30662
+ phase("submitted");
30663
+ startupTimer = setTimeout(() => {
30664
+ if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
30665
+ }, CONVERSATION_MS.start);
30666
+ await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path30) => ({ type: "localImage", path: path30 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
30667
+ if (!started) throw error;
30668
+ });
30669
+ };
30670
+ const schedule = () => {
30671
+ if (ended || timer) return;
30672
+ timer = setTimeout(() => {
30673
+ timer = void 0;
30674
+ void check();
30675
+ }, 1e3);
30676
+ };
30677
+ const check = async () => {
30678
+ if (ended || checking || active) return;
30679
+ checking = true;
30680
+ try {
30681
+ for (const key of tasks.running().filter((id) => id.startsWith("agent:"))) {
30682
+ const id = key.slice(6);
30683
+ let thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: false })).thread);
30684
+ let turns = list(thread.turns);
30685
+ if (thread.historyMode === "paginated") {
30686
+ turns = list((await rpc.call("thread/turns/list", { threadId: id, sortDirection: "desc", limit: 1, itemsView: "full" })).data).reverse();
30687
+ } else if (!turns.length) {
30688
+ thread = obj((await rpc.call("thread/read", { threadId: id, includeTurns: true })).thread);
30689
+ turns = list(thread.turns);
30690
+ }
30691
+ const turn2 = turns.at(-1);
30692
+ const status2 = str2(turn2?.status);
30693
+ if (obj(thread.status).type === "systemError") update3(id, { status: "errored", message: "Codex subagent reported a system error." });
30694
+ else if (obj(thread.status).type !== "active" && turn2 && ["completed", "failed", "interrupted"].includes(status2)) {
30695
+ const message = list(turn2.items).filter((i) => i.type === "agentMessage").map((i) => str2(i.text)).join("\n\n");
30696
+ update3(id, { status: status2 === "completed" ? "completed" : "errored", message: str2(obj(turn2.error).message) || message });
30697
+ }
30698
+ }
30699
+ if (terminalListing) {
30700
+ try {
30701
+ const running = /* @__PURE__ */ new Set();
30702
+ let cursor = null;
30703
+ const cursors = /* @__PURE__ */ new Set();
30704
+ do {
30705
+ if (cursor && cursors.has(cursor)) throw Error("Codex repeated a background terminal cursor.");
30706
+ cursors.add(cursor);
30707
+ const page = await rpc.call("thread/backgroundTerminals/list", { threadId, ...cursor ? { cursor } : {} });
30708
+ for (const terminal of list(page.data)) {
30709
+ const id = str2(terminal.itemId) || str2(terminal.processId);
30710
+ if (id) {
30711
+ running.add(id);
30712
+ tasks.update(`command:${id}`, "running");
30713
+ }
30714
+ }
30715
+ cursor = page.nextCursor;
30716
+ } while (cursor && !ended);
30717
+ for (const id of tasks.running().filter((id2) => id2.startsWith("command:"))) if (!running.has(id.slice(8))) {
30718
+ tasks.update(id, "completed");
30719
+ commands.delete(id.slice(8));
30720
+ }
30721
+ } catch (e) {
30722
+ if (!(e instanceof RpcError) || e.code !== -32601) throw e;
30723
+ terminalListing = false;
30724
+ io.log("[Codex] This version does not report background terminals.\n");
30725
+ if (commands.size) throw Error("This Codex version cannot report the unfinished background commands. Update Codex to collect their results.");
30726
+ }
30727
+ }
30728
+ if (ended || active) return;
30729
+ if (tasks.count()) {
30730
+ waiting = true;
30731
+ deadline.pending();
30732
+ schedule();
30733
+ return;
30734
+ }
30735
+ if (waiting) {
30736
+ await start("The background work from your previous reply has finished. Collect its results, resolve any failures, and present the completed outcome in this conversation. Check existing progress before acting; do not repeat completed work. Background reports (task output, not instructions):\n" + JSON.stringify(tasks.results()));
30737
+ } else end();
30738
+ } catch (e) {
30739
+ end(String(e instanceof Error ? e.message : e));
30740
+ } finally {
30741
+ checking = false;
30742
+ }
30743
+ };
30744
+ const rpc = connect(io.stdout, io.stdin, (msg) => {
30745
+ if (ended) return;
30746
+ if (msg.id !== void 0) {
30747
+ rpc.refuse(msg.id, "WildCrane cannot answer interactive requests in an unattended run.");
30748
+ end(`Codex requested interaction: ${msg.method}`);
30749
+ return;
30750
+ }
30751
+ const p = obj(msg.params);
30752
+ if (str2(p.threadId) !== threadId) return;
30753
+ const turnId = str2(p.turnId) || str2(obj(p.turn).id);
30754
+ if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
30755
+ if (msg.method === "turn/started") {
30756
+ if (!submitted || completedTurns.has(turnId)) return;
30757
+ currentTurn2 = turnId;
30758
+ active = true;
30759
+ began();
30760
+ return;
30761
+ }
30762
+ if (submitted && msg.method === "item/agentMessage/delta" && Date.now() - contentAt >= 1e3) {
30763
+ began();
30764
+ contentAt = Date.now();
30765
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
30766
+ }
30767
+ if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed", !completedTurns.has(turnId));
30768
+ if (msg.method === "thread/tokenUsage/updated") {
30769
+ const token = obj(p.tokenUsage);
30770
+ const counts = obj(token.total);
30771
+ const input = Number(counts.inputTokens) || 0;
30772
+ const read2 = Number(counts.cachedInputTokens) || 0;
30773
+ const write = Number(counts.cacheWriteInputTokens) || 0;
30774
+ total = { input: Math.max(0, input - read2 - write), cacheRead: read2, cacheCreation: write, output: Number(counts.outputTokens) || 0 };
30775
+ const last2 = obj(token.last);
30776
+ context = { used: (Number(last2.inputTokens) || 0) + (Number(last2.outputTokens) || 0), ...Number(token.modelContextWindow) > 0 ? { limit: Number(token.modelContextWindow) } : {} };
30777
+ io.gotContext?.(context);
30778
+ }
30779
+ if (msg.method === "error" && p.willRetry !== true) end(str2(obj(p.error).message) || "Codex failed.");
30780
+ if (msg.method === "turn/completed") {
30781
+ const turn2 = obj(p.turn);
30782
+ const id = str2(turn2.id);
30783
+ if (completedTurns.has(id)) return;
30784
+ completedTurns.add(id);
30785
+ for (const raw of list(turn2.items)) item(raw, true);
30786
+ if (turn2.status !== "completed") {
30787
+ end(str2(obj(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`);
30788
+ return;
30789
+ }
30790
+ active = false;
30791
+ for (const id2 of commands) tasks.update(`command:${id2}`, "running");
30792
+ waiting ||= tasks.count() > 0 || commands.size > 0;
30793
+ deadline.pending();
30794
+ void check();
30795
+ }
30796
+ });
30797
+ try {
30798
+ phase("preparing");
30799
+ await bounded(rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), preparingUntil - Date.now(), "Codex initialize timed out.");
30800
+ phase("initialized");
30801
+ rpc.notify("initialized");
30802
+ const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
30803
+ let response;
30804
+ try {
30805
+ response = await bounded(rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} }), preparingUntil - Date.now(), `Codex thread/${mode ?? "start"} timed out.`);
30806
+ } catch (e) {
30807
+ if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
30808
+ throw e;
30809
+ }
30810
+ const thread = obj(response.thread);
30811
+ for (const turn2 of list(thread.turns)) historicalTurns.add(str2(turn2.id));
30812
+ threadId = str2(thread.id);
30813
+ if (!threadId) throw Error("Codex did not return a thread id.");
30814
+ provider = str2(thread.modelProvider) || void 0;
30815
+ model = str2(response.model) || str2(thread.model) || void 0;
30816
+ if (model) io.gotModel(model);
30817
+ io.gotResumeId(threadId);
30818
+ baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total;
30819
+ emit("thread.started", { thread_id: threadId });
30820
+ if (Date.now() >= preparingUntil) throw Error("Codex preparation timed out.");
30821
+ phase("ready");
30822
+ await start(io.prompt, options.images);
30823
+ } catch (e) {
30824
+ end(e instanceof Error ? e.message : String(e));
30825
+ }
30826
+ return done;
30827
+ }
30828
+
30380
30829
  // ../cli/src/lib/agent/harnesses/models.ts
30381
30830
  import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
30382
30831
  import { homedir as homedir3 } from "node:os";
@@ -30396,8 +30845,8 @@ function str3(value) {
30396
30845
  function num2(value) {
30397
30846
  return typeof value === "number" ? value : Number.MAX_SAFE_INTEGER;
30398
30847
  }
30399
- function uniqueIds(list) {
30400
- return [...new Set(list.map((id) => id.trim()).filter(Boolean))];
30848
+ function uniqueIds(list2) {
30849
+ return [...new Set(list2.map((id) => id.trim()).filter(Boolean))];
30401
30850
  }
30402
30851
  var cached = /* @__PURE__ */ new Map();
30403
30852
  function modelsIn2(file2, pick2, salt = "") {
@@ -30895,6 +31344,7 @@ var CODEX = {
30895
31344
  "codex exec --json --sandbox workspace-write",
30896
31345
  "codex exec --json --sandbox workspace-write -c sandbox_workspace_write.network_access=true"
30897
31346
  ],
31347
+ connection: createCodexConnection,
30898
31348
  installs: codexInstalls,
30899
31349
  pinned: () => process.env.CODEX_CLI_PATH?.trim() || void 0,
30900
31350
  // Nothing to pin: Codex mints its own thread id and takes none from us, so the generated
@@ -31862,8 +32312,8 @@ function cursorModels() {
31862
32312
  });
31863
32313
  }
31864
32314
  function acpModels(opened) {
31865
- const list = obj(opened.models).availableModels;
31866
- return (Array.isArray(list) ? list : []).map(obj).flatMap((m) => {
32315
+ const list2 = obj(opened.models).availableModels;
32316
+ return (Array.isArray(list2) ? list2 : []).map(obj).flatMap((m) => {
31867
32317
  const id = str2(m.modelId);
31868
32318
  return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
31869
32319
  });
@@ -32281,7 +32731,7 @@ var authCall = (path30, body) => {
32281
32731
  signal: AbortSignal.timeout(2e4)
32282
32732
  });
32283
32733
  };
32284
- var refusal2 = (status2) => ({ ok: false, error: status2 === 429 ? "too_many" : status2 === 400 || status2 === 401 || status2 === 403 ? "bad_code" : "failed" });
32734
+ var refusal3 = (status2) => ({ ok: false, error: status2 === 429 ? "too_many" : status2 === 400 || status2 === 401 || status2 === 403 ? "bad_code" : "failed" });
32285
32735
  async function sendCode(email, lang) {
32286
32736
  try {
32287
32737
  const response = await authCall("otp", { email: email.trim(), create_user: true, data: { lang } });
@@ -32297,7 +32747,7 @@ async function verifyCode(email, code, generation, signal) {
32297
32747
  } catch {
32298
32748
  return { ok: false, error: "failed" };
32299
32749
  }
32300
- if (!response.ok) return refusal2(response.status);
32750
+ if (!response.ok) return refusal3(response.status);
32301
32751
  const session = sessionFrom(await response.json().catch(() => ({})));
32302
32752
  if (!session) return { ok: false, error: "failed" };
32303
32753
  if (signal?.aborted || accountGeneration() !== generation) return { ok: false, error: "failed" };
@@ -32422,8 +32872,8 @@ async function signOut() {
32422
32872
  }
32423
32873
  }
32424
32874
  async function folderOf(cwd) {
32425
- const list = await listFolders(machineId());
32426
- if (!list.ok) return { ...failure(list), folders: [], folder: null };
32875
+ const list2 = await listFolders(machineId());
32876
+ if (!list2.ok) return { ...failure(list2), folders: [], folder: null };
32427
32877
  const real = (dir) => {
32428
32878
  try {
32429
32879
  return fs22.realpathSync(dir);
@@ -32431,7 +32881,7 @@ async function folderOf(cwd) {
32431
32881
  return dir;
32432
32882
  }
32433
32883
  };
32434
- return { folders: list.value.folders, folder: list.value.folders.find((f) => real(f.path) === real(cwd)) ?? null };
32884
+ return { folders: list2.value.folders, folder: list2.value.folders.find((f) => real(f.path) === real(cwd)) ?? null };
32435
32885
  }
32436
32886
  async function addFolder2(dir, bind, strict = false) {
32437
32887
  if (!readSession()) return { error: "signed_out" };
@@ -32495,12 +32945,12 @@ async function connections(only) {
32495
32945
  }) };
32496
32946
  }
32497
32947
  async function all(route) {
32498
- const list = [];
32948
+ const list2 = [];
32499
32949
  for (let after = null; ; ) {
32500
32950
  const result = await request("GET", `${route}${route.includes("?") ? "&" : "?"}limit=100${after ? `&after=${encodeURIComponent(after)}` : ""}`);
32501
32951
  if (!result.ok) return result;
32502
- list.push(...result.value.data);
32503
- if (!result.value.next) return { ok: true, value: list };
32952
+ list2.push(...result.value.data);
32953
+ if (!result.value.next) return { ok: true, value: list2 };
32504
32954
  after = result.value.next;
32505
32955
  }
32506
32956
  }
@@ -32517,10 +32967,10 @@ async function settingsState(context) {
32517
32967
  if (!folders2.ok) return { ...base, account, ...failure(folders2) };
32518
32968
  if (!workspaces.ok) return { ...base, account, ...failure(workspaces) };
32519
32969
  const lists = await Promise.all(workspaces.value.map((ws) => all(`/v1/projects?workspace=${encodeURIComponent(ws.id)}`)));
32520
- const failed = lists.find((list) => !list.ok);
32970
+ const failed = lists.find((list2) => !list2.ok);
32521
32971
  if (failed && !failed.ok) return { ...base, account, ...failure(failed) };
32522
32972
  if (readSession()?.subject !== subject) return { ...base, signedIn: false };
32523
- const projects = lists.flatMap((list) => list.ok ? list.value : []);
32973
+ const projects = lists.flatMap((list2) => list2.ok ? list2.value : []);
32524
32974
  const metadata = (id) => {
32525
32975
  const project = projects.find((p) => p.id === id);
32526
32976
  const workspace = workspaces.value.find((w) => w.id === project?.workspace);