@cloop/runner 0.3.2 → 0.3.8

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.
@@ -13,7 +13,7 @@ var RESULT_INSTRUCTION = [
13
13
  '{"summary": "One or two sentences on what you did.", "outputs": [{"kind": "pr", "title": "fix: the thing", "url": "https://github.com/org/repo/pull/1"}], "checks": [{"name": "Tests", "outcome": "passed"}]}',
14
14
  "```",
15
15
  "An output kind is one of: pr or link (title, url), draft (title, body, optional to, optional url), doc (title, optional url or body), file (title, path). A check outcome is passed, failed or skipped.",
16
- "A draft's body is the message itself, as the recipient will read it; if you saved it somewhere (a Gmail draft), put that link in url, never in body. A doc's body is the whole page in Markdown; give every product, page or source you mention as a full https link.",
16
+ "A draft's body is the message itself, as the recipient will read it; if you saved it somewhere (a Gmail draft), put that link in url, never in body. A doc's body is the whole page in GitHub Markdown: headings, lists, bold and tables all show; a table suits one row per item. Give every product, page or source you mention as a full https link.",
17
17
  "List as outputs only what this run made. A PR or page you only read, checked or cited goes in the summary, never in outputs."
18
18
  ].join("\n");
19
19
  var text = (v, max) => typeof v === "string" && v.length <= max;
@@ -179,6 +179,17 @@ function isYes(reply) {
179
179
  reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
180
180
  );
181
181
  }
182
+ var HARNESS_LIMIT = /usage limit|reached your [\w .-]{0,40}limit|hit your [\w .-]{0,40}limit|out of (usage )?credits/i;
183
+ function limitedModel(said) {
184
+ const name = /reached your ([\w .-]{1,40}?) limit/i.exec(said ?? "")?.[1];
185
+ return name && !/usage|weekly|daily|session|hour|month/i.test(name) ? name : null;
186
+ }
187
+ var LIMIT_HOLD_MS = 60 * 6e4;
188
+ function handoverPrompt(prompt, from) {
189
+ return `${prompt}
190
+
191
+ ${from} started this work and stopped at its usage limit. Its changes, if any, are in this checkout. Read \`git status\` and \`git log\` first, and carry on from there.`;
192
+ }
182
193
 
183
194
  // src/run-log.ts
184
195
  import {
@@ -397,6 +408,7 @@ function whichAll(bin) {
397
408
 
398
409
  // src/drivers/t3.ts
399
410
  import { execFile, execFileSync as execFileSync2 } from "child_process";
411
+ import { randomUUID } from "crypto";
400
412
  function isUnsettled(t) {
401
413
  return !t.settledAt && !t.archivedAt && !isChild(t);
402
414
  }
@@ -406,6 +418,7 @@ function isChild(t) {
406
418
  var SESSIONS_TTL_MS = 5 * 6e4;
407
419
  var STATUS_TTL_MS = 3e4;
408
420
  var TERMINAL_RUN = /* @__PURE__ */ new Set(["completed", "interrupted", "failed", "cancelled", "rolled_back"]);
421
+ var STOPPED_IN_T3 = "You stopped this in T3.";
409
422
  var IDLE_SETTLE_MS = 20 * 6e4;
410
423
  var APPROVAL_WORDS = {
411
424
  command: "run a command",
@@ -486,6 +499,17 @@ function outcomeOf(p) {
486
499
  function permissionOf(runtimeMode) {
487
500
  return runtimeMode === "full-access" ? "full" : "ask";
488
501
  }
502
+ var CODEX_PROVIDER = "codex";
503
+ var PROVIDER_NAMES = { claudeAgent: "Claude Code", codex: "Codex" };
504
+ function providerName(instanceId) {
505
+ return instanceId && PROVIDER_NAMES[instanceId] || instanceId || "The harness";
506
+ }
507
+ function codexProvider(cfg) {
508
+ const p = cfg.providers.find((x) => (x.driver ?? x.instanceId) === CODEX_PROVIDER && x.enabled);
509
+ if (!p || p.auth && p.auth.status !== "authenticated") return null;
510
+ const model = p.models?.find((m) => m.isDefault)?.slug ?? p.models?.[0]?.slug;
511
+ return model ? { instanceId: p.instanceId, model } : null;
512
+ }
489
513
  function pickProject(projects, repository) {
490
514
  if (!repository) {
491
515
  const repos = projects.filter((p) => p.repositoryIdentity);
@@ -572,6 +596,10 @@ var T3Driver = class {
572
596
  name = "t3";
573
597
  /** Threads whose turn ended without a result block, by id: ends the held run on a stop. */
574
598
  held = /* @__PURE__ */ new Map();
599
+ /** Threads this daemon launched. A restart forgets them, and a forgotten thread is not moved. */
600
+ launched = /* @__PURE__ */ new Map();
601
+ /** Until then, a launch that names no harness starts on Codex: the Claude account is at its limit. */
602
+ limitedUntil = 0;
575
603
  get capabilities() {
576
604
  return boxCapabilities(this.deps.scope?.());
577
605
  }
@@ -670,7 +698,15 @@ var T3Driver = class {
670
698
  this.t3.http("/api/orchestration/shell", SHELL_HEADERS)
671
699
  ]);
672
700
  const project = pickProject(shell.projects ?? [], a.repository);
673
- const fallback = cfg.settings?.defaultModelSelection;
701
+ const runtimeMode = a.runtime_mode ?? cfg.settings?.defaultRuntimeMode;
702
+ if (!runtimeMode || !RUNTIME_MODES.has(runtimeMode))
703
+ throw new BoxToolError("runtime_mode_unknown");
704
+ const permission = permissionOf(runtimeMode);
705
+ const named = Boolean(a.harness || a.model);
706
+ const held = !named && permission === "full" && this.now() < this.limitedUntil;
707
+ const own = cfg.settings?.defaultModelSelection?.instanceId ?? "claudeAgent";
708
+ const codex = held && own !== CODEX_PROVIDER ? codexProvider(cfg) : null;
709
+ const fallback = codex ?? cfg.settings?.defaultModelSelection;
674
710
  const harness = a.harness ?? fallback?.instanceId ?? "claudeAgent";
675
711
  const provider = cfg.providers.find((p) => p.instanceId === harness && p.enabled);
676
712
  if (!provider) throw new BoxToolError("harness_unavailable");
@@ -679,9 +715,7 @@ var T3Driver = class {
679
715
  const model = a.model ?? (fallback?.instanceId === harness ? fallback.model : void 0) ?? provider.models?.find((m) => m.isDefault)?.slug;
680
716
  if (!model) throw new BoxToolError("harness_unavailable");
681
717
  const modelSelection = !a.model && fallback?.instanceId === harness ? fallback : { instanceId: harness, model };
682
- const runtimeMode = a.runtime_mode ?? cfg.settings?.defaultRuntimeMode;
683
- if (!runtimeMode || !RUNTIME_MODES.has(runtimeMode))
684
- throw new BoxToolError("runtime_mode_unknown");
718
+ if (codex) this.log(`limit hold: launch work=${a.work_id} starts on ${codex.instanceId}`);
685
719
  const launched = await this.t3.rpc(
686
720
  "orchestration.launchThread",
687
721
  {
@@ -701,11 +735,16 @@ var T3Driver = class {
701
735
  ${RESULT_INSTRUCTION}`, attachments: [] }
702
736
  }
703
737
  );
704
- return {
705
- thread_id: launched.threadId,
706
- resumed: launched.resumed,
707
- permission: permissionOf(runtimeMode)
708
- };
738
+ if (!this.launched.has(launched.threadId))
739
+ this.launched.set(launched.threadId, {
740
+ named,
741
+ permission,
742
+ ...codex ? {
743
+ movedFrom: "",
744
+ switched: `${providerName(own)} is at its usage limit, so Codex did this run.`
745
+ } : {}
746
+ });
747
+ return { thread_id: launched.threadId, resumed: launched.resumed, permission };
709
748
  }
710
749
  /**
711
750
  * Say something to a thread. While the thread waits on a question, only
@@ -961,23 +1000,45 @@ ${RESULT_INSTRUCTION}`, attachments: [] }
961
1000
  );
962
1001
  return;
963
1002
  }
1003
+ const entry = this.launched.get(threadId);
1004
+ if (turn && entry?.movedFrom === turn.id) {
1005
+ finishing = false;
1006
+ return;
1007
+ }
1008
+ if (outcome.kind === "failed" && turn && await this.moveToCodex(threadId, turn, outcome)) {
1009
+ finishing = false;
1010
+ if (stopped) return;
1011
+ onEvent({
1012
+ kind: "progress",
1013
+ summary: `${providerName(turn.providerInstanceId)} is at its usage limit, so I moved this to Codex`
1014
+ });
1015
+ if (!live) void follow();
1016
+ return;
1017
+ }
1018
+ if (stopped) return;
964
1019
  wake();
965
1020
  stopped = true;
966
1021
  live?.close();
967
1022
  const pr = outcome.pr_url ? { pr_url: outcome.pr_url } : {};
1023
+ const opening = entry?.switched ? `${entry.switched} ` : "";
968
1024
  if (outcome.kind === "failed") {
969
- onEvent({
970
- kind: "failed",
971
- summary: `The run ended ${outcome.status}.`,
972
- ...outcome.result ? pr : {}
973
- });
1025
+ const said = outcome.last_assistant_text?.replace(/\s+/g, " ").trim();
1026
+ const limited = outcome.status === "failed" && HARNESS_LIMIT.test(said ?? "");
1027
+ const end = limited ? {
1028
+ summary: `${opening}${providerName(turn?.providerInstanceId)} said: "${said}"`.slice(
1029
+ 0,
1030
+ RUN_TEXT_MAX
1031
+ ),
1032
+ error: "harness_limit"
1033
+ } : outcome.status === "interrupted" ? { summary: STOPPED_IN_T3, error: "interrupted" } : { summary: `${opening}The run ended ${outcome.status}.` };
1034
+ onEvent({ kind: "failed", ...end, ...outcome.result ? pr : {} });
974
1035
  } else {
975
1036
  const lost = outcome.dropped ? droppedLine(outcome.dropped, threadId) : null;
976
1037
  if (lost) this.log(lost);
977
1038
  onEvent({
978
1039
  kind: "settled",
979
1040
  ...outcome.result ? { result: outcome.result } : {},
980
- ...outcome.last_assistant_text ? { summary: outcome.last_assistant_text } : {},
1041
+ ...outcome.last_assistant_text ? { summary: `${opening}${outcome.last_assistant_text}`.slice(0, RUN_TEXT_MAX) } : {},
981
1042
  ...pr
982
1043
  });
983
1044
  }
@@ -1064,6 +1125,65 @@ ${RESULT_INSTRUCTION}`, attachments: [] }
1064
1125
  live?.close();
1065
1126
  };
1066
1127
  }
1128
+ /**
1129
+ * Once per thread: a run that failed at a Claude usage limit carries on in
1130
+ * the same thread on Codex. T3 switches the thread's provider and hands
1131
+ * Codex the thread so far; the worktree, with any edits, stays. A limit
1132
+ * that names no model holds the account, so launches start on Codex for
1133
+ * LIMIT_HOLD_MS. A thread whose Task named its harness or model stays, and
1134
+ * so does one without full access, because Codex asks nothing. So does a
1135
+ * thread this daemon did not launch: a restart forgets what the Task named.
1136
+ */
1137
+ async moveToCodex(threadId, turn, outcome) {
1138
+ const said = outcome.last_assistant_text ?? "";
1139
+ if (outcome.status !== "failed" || !HARNESS_LIMIT.test(said)) return false;
1140
+ const from = turn.providerInstanceId;
1141
+ if (from === CODEX_PROVIDER) return false;
1142
+ if (!limitedModel(said)) this.limitedUntil = this.now() + LIMIT_HOLD_MS;
1143
+ const entry = this.launched.get(threadId);
1144
+ if (!entry || entry.named || entry.permission !== "full" || entry.movedFrom !== void 0)
1145
+ return false;
1146
+ try {
1147
+ return await this.dispatchToCodex(threadId, turn, entry);
1148
+ } catch (err) {
1149
+ this.log(
1150
+ `fallback failed thread=${threadId}: ${err instanceof Error ? err.message : String(err)}`
1151
+ );
1152
+ return false;
1153
+ }
1154
+ }
1155
+ async dispatchToCodex(threadId, turn, entry) {
1156
+ const codex = codexProvider(await this.t3.rpc("server.getConfig", {}));
1157
+ if (!codex) {
1158
+ this.log(`limit thread=${threadId}: Codex is not on or not signed in; the run fails`);
1159
+ return false;
1160
+ }
1161
+ const name = providerName(turn.providerInstanceId);
1162
+ const id = randomUUID();
1163
+ await this.dispatch({
1164
+ type: "message.dispatch",
1165
+ commandId: id,
1166
+ threadId,
1167
+ messageId: id,
1168
+ text: handoverPrompt("Carry on with the task in this thread.", name).concat(
1169
+ `
1170
+
1171
+ ${RESULT_INSTRUCTION}`
1172
+ ),
1173
+ attachments: [],
1174
+ modelSelection: codex,
1175
+ dispatchMode: { type: "start_immediately" },
1176
+ createdBy: "user",
1177
+ creationSource: "mcp"
1178
+ });
1179
+ entry.movedFrom = turn.id;
1180
+ entry.switched = `${name} was at its usage limit, so Codex did this run.`;
1181
+ this.log(`fallback thread=${threadId} provider=${codex.instanceId} model=${codex.model}`);
1182
+ return true;
1183
+ }
1184
+ now() {
1185
+ return this.deps.now?.() ?? Date.now();
1186
+ }
1067
1187
  readProjection(threadId) {
1068
1188
  return this.t3.rpc("orchestration.getThreadProjection", { threadId });
1069
1189
  }
@@ -1137,13 +1257,80 @@ ${RESULT_INSTRUCTION}`, attachments: [] }
1137
1257
  }
1138
1258
  };
1139
1259
 
1260
+ // src/runner-config.ts
1261
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, writeFileSync } from "fs";
1262
+ import { homedir } from "os";
1263
+ import { dirname as dirname2, join as join3 } from "path";
1264
+ var BOX_FILE = "box.json";
1265
+ function boxPath() {
1266
+ return process.env.CLOOP_BOX_FILE ?? join3(homedir(), CONFIG_DIR, BOX_FILE);
1267
+ }
1268
+ function isLocal(cfg) {
1269
+ return cfg.driver === "claude-code" || cfg.driver === "codex";
1270
+ }
1271
+ function showsOtherThreads(cfg) {
1272
+ return cfg?.hideOtherThreads !== true;
1273
+ }
1274
+ function otherThreadsChoice(argv, previous) {
1275
+ if (argv.includes("--hide-other-threads")) return true;
1276
+ if (argv.includes("--show-other-threads")) return false;
1277
+ return previous?.hideOtherThreads === true;
1278
+ }
1279
+ function readRunnerConfig() {
1280
+ let parsed;
1281
+ try {
1282
+ parsed = JSON.parse(readFileSync(boxPath(), "utf-8"));
1283
+ } catch {
1284
+ return null;
1285
+ }
1286
+ if (parsed.driver === "claude-code" || parsed.driver === "codex") {
1287
+ const ok = typeof parsed.deviceToken === "string" && typeof parsed.environmentId === "string" && typeof parsed.bin === "string" && Array.isArray(parsed.repos);
1288
+ return ok ? parsed : null;
1289
+ }
1290
+ if (typeof parsed.t3Url !== "string" || typeof parsed.token !== "string") return null;
1291
+ return parsed;
1292
+ }
1293
+ function writeBoxConfig(cfg) {
1294
+ const path = boxPath();
1295
+ mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
1296
+ const temp = `${path}.${process.pid}.tmp`;
1297
+ writeFileSync(temp, `${JSON.stringify(cfg, null, 2)}
1298
+ `, { mode: 384 });
1299
+ chmodSync2(temp, 384);
1300
+ renameSync2(temp, path);
1301
+ }
1302
+
1140
1303
  // src/drivers/local.ts
1141
1304
  import { execFile as execFile2, execFileSync as execFileSync3, spawn } from "child_process";
1142
- import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, writeFileSync } from "fs";
1143
- import { homedir, hostname } from "os";
1144
- import { basename, dirname as dirname2, join as join3 } from "path";
1305
+ import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "fs";
1306
+ import { homedir as homedir2, hostname } from "os";
1307
+ import { basename, dirname as dirname3, join as join4 } from "path";
1145
1308
  import { createInterface } from "readline";
1146
1309
 
1310
+ // src/spawn-command.ts
1311
+ function commandFor(bin, args, platform = process.platform, comspec = process.env.ComSpec) {
1312
+ if (platform !== "win32" || !/\.(cmd|bat)$/i.test(bin)) return { file: bin, args };
1313
+ return {
1314
+ file: comspec ?? "cmd.exe",
1315
+ args: ["/d", "/s", "/c", `"${[bin, ...args].map(quoteWindowsArg).join(" ")}"`],
1316
+ windowsVerbatimArguments: true
1317
+ };
1318
+ }
1319
+ function quoteWindowsArg(arg) {
1320
+ if (arg && !/[ \t"]/.test(arg)) return arg;
1321
+ let quoted = '"';
1322
+ let backslashes = 0;
1323
+ for (const ch of arg) {
1324
+ if (ch === "\\") {
1325
+ backslashes++;
1326
+ continue;
1327
+ }
1328
+ quoted += "\\".repeat(ch === '"' ? backslashes * 2 + 1 : backslashes) + ch;
1329
+ backslashes = 0;
1330
+ }
1331
+ return `${quoted}${"\\".repeat(backslashes * 2)}"`;
1332
+ }
1333
+
1147
1334
  // src/drivers/harness-check.ts
1148
1335
  var HARNESS_STALE_MS = 5 * 6e4;
1149
1336
  var FIRST_CHECK_WAIT_MS = 3e3;
@@ -1196,17 +1383,6 @@ var SHARED_BRANCHES = /* @__PURE__ */ new Set(["staging", "main", "master", "HEA
1196
1383
  var COMMANDS_KEPT = 50;
1197
1384
  var SUMMARY_MAX2 = 200;
1198
1385
  var HARNESS_NAMES = { "claude-code": "Claude Code", codex: "Codex" };
1199
- var HARNESS_LIMIT = /usage limit|reached your [\w .-]{0,40}limit|hit your [\w .-]{0,40}limit|out of (usage )?credits/i;
1200
- function limitedModel(said) {
1201
- const name = /reached your ([\w .-]{1,40}?) limit/i.exec(said ?? "")?.[1];
1202
- return name && !/usage|weekly|daily|session|hour|month/i.test(name) ? name : null;
1203
- }
1204
- var LIMIT_HOLD_MS = 60 * 6e4;
1205
- function handoverPrompt(prompt, from) {
1206
- return `${prompt}
1207
-
1208
- ${from} started this work and stopped at its usage limit. Its changes, if any, are in this checkout. Read \`git status\` and \`git log\` first, and carry on from there.`;
1209
- }
1210
1386
  function failedEnd(harness, run2) {
1211
1387
  const said = run2.result?.text?.trim() || run2.lastText;
1212
1388
  const limited = HARNESS_LIMIT.test(run2.result?.text ?? "");
@@ -1224,7 +1400,7 @@ function failedEnd(harness, run2) {
1224
1400
  return { summary: `${lead}${quoted}"`, ...error };
1225
1401
  }
1226
1402
  function localRunsFilePath() {
1227
- return process.env.CLOOP_LOCAL_RUNS_FILE ?? join3(homedir(), CONFIG_DIR, "local-runs.json");
1403
+ return process.env.CLOOP_LOCAL_RUNS_FILE ?? join4(homedir2(), CONFIG_DIR, "local-runs.json");
1228
1404
  }
1229
1405
  function pickRepo(repos, repository) {
1230
1406
  if (!repository) {
@@ -1264,6 +1440,17 @@ var gitProbe = {
1264
1440
  }
1265
1441
  }
1266
1442
  };
1443
+ function processCommandLine(pid, platform = process.platform) {
1444
+ if (platform === "win32")
1445
+ return [
1446
+ "powershell",
1447
+ "-NoProfile",
1448
+ "-NonInteractive",
1449
+ "-Command",
1450
+ `(Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}').CommandLine`
1451
+ ];
1452
+ return ["ps", "-ww", "-o", "command=", "-p", String(pid)];
1453
+ }
1267
1454
  function harnessAlive(pid, r, dialect) {
1268
1455
  try {
1269
1456
  process.kill(pid, 0);
@@ -1271,7 +1458,8 @@ function harnessAlive(pid, r, dialect) {
1271
1458
  if (err.code !== "EPERM") return false;
1272
1459
  }
1273
1460
  try {
1274
- const command = execFileSync3("ps", ["-ww", "-o", "command=", "-p", String(pid)], {
1461
+ const [file, ...args] = processCommandLine(pid);
1462
+ const command = execFileSync3(file, args, {
1275
1463
  encoding: "utf-8",
1276
1464
  timeout: 2e3
1277
1465
  });
@@ -1622,10 +1810,12 @@ ${a.text}` : a.text;
1622
1810
  spawnRun(r, prompt, resume) {
1623
1811
  const dialect = this.dialectOf(r);
1624
1812
  r.used_permission = dialect.permission?.(r);
1625
- const child = spawn(dialect.bin, dialect.args(r, resume), {
1813
+ const command = commandFor(dialect.bin, dialect.args(r, resume));
1814
+ const child = spawn(command.file, command.args, {
1626
1815
  cwd: r.repo,
1627
1816
  stdio: ["pipe", "pipe", "pipe"],
1628
- env: process.env
1817
+ env: process.env,
1818
+ ...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
1629
1819
  });
1630
1820
  const live = {
1631
1821
  child,
@@ -1863,17 +2053,17 @@ ${RESULT_INSTRUCTION}`));
1863
2053
  return readRunRecords(this.file).filter((r) => !(r.end && Date.parse(r.end.at) < cutoff));
1864
2054
  }
1865
2055
  save() {
1866
- mkdirSync2(dirname2(this.file), { recursive: true, mode: 448 });
2056
+ mkdirSync3(dirname3(this.file), { recursive: true, mode: 448 });
1867
2057
  const tmp = `${this.file}.tmp`;
1868
- writeFileSync(tmp, `${JSON.stringify([...this.runs.values()], null, 2)}
2058
+ writeFileSync2(tmp, `${JSON.stringify([...this.runs.values()], null, 2)}
1869
2059
  `, { mode: 384 });
1870
- chmodSync2(tmp, 384);
1871
- renameSync2(tmp, this.file);
2060
+ chmodSync3(tmp, 384);
2061
+ renameSync3(tmp, this.file);
1872
2062
  }
1873
2063
  };
1874
2064
  function readRunRecords(file = localRunsFilePath()) {
1875
2065
  try {
1876
- const raw = JSON.parse(readFileSync(file, "utf-8"));
2066
+ const raw = JSON.parse(readFileSync2(file, "utf-8"));
1877
2067
  return Array.isArray(raw) ? raw.filter(
1878
2068
  (r) => typeof r?.work_id === "string" && typeof r?.repo === "string"
1879
2069
  ) : [];
@@ -1882,49 +2072,6 @@ function readRunRecords(file = localRunsFilePath()) {
1882
2072
  }
1883
2073
  }
1884
2074
 
1885
- // src/runner-config.ts
1886
- import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "fs";
1887
- import { homedir as homedir2 } from "os";
1888
- import { dirname as dirname3, join as join4 } from "path";
1889
- var BOX_FILE = "box.json";
1890
- function boxPath() {
1891
- return process.env.CLOOP_BOX_FILE ?? join4(homedir2(), CONFIG_DIR, BOX_FILE);
1892
- }
1893
- function isLocal(cfg) {
1894
- return cfg.driver === "claude-code" || cfg.driver === "codex";
1895
- }
1896
- function showsOtherThreads(cfg) {
1897
- return cfg?.hideOtherThreads !== true;
1898
- }
1899
- function otherThreadsChoice(argv, previous) {
1900
- if (argv.includes("--hide-other-threads")) return true;
1901
- if (argv.includes("--show-other-threads")) return false;
1902
- return previous?.hideOtherThreads === true;
1903
- }
1904
- function readRunnerConfig() {
1905
- let parsed;
1906
- try {
1907
- parsed = JSON.parse(readFileSync2(boxPath(), "utf-8"));
1908
- } catch {
1909
- return null;
1910
- }
1911
- if (parsed.driver === "claude-code" || parsed.driver === "codex") {
1912
- const ok = typeof parsed.deviceToken === "string" && typeof parsed.environmentId === "string" && typeof parsed.bin === "string" && Array.isArray(parsed.repos);
1913
- return ok ? parsed : null;
1914
- }
1915
- if (typeof parsed.t3Url !== "string" || typeof parsed.token !== "string") return null;
1916
- return parsed;
1917
- }
1918
- function writeBoxConfig(cfg) {
1919
- const path = boxPath();
1920
- mkdirSync3(dirname3(path), { recursive: true, mode: 448 });
1921
- const temp = `${path}.${process.pid}.tmp`;
1922
- writeFileSync2(temp, `${JSON.stringify(cfg, null, 2)}
1923
- `, { mode: 384 });
1924
- chmodSync3(temp, 384);
1925
- renameSync3(temp, path);
1926
- }
1927
-
1928
2075
  export {
1929
2076
  RUNTIME_MODES,
1930
2077
  BoxToolError,
@@ -1932,6 +2079,7 @@ export {
1932
2079
  questionLine,
1933
2080
  RUN_TEXT_MAX,
1934
2081
  isYes,
2082
+ commandFor,
1935
2083
  runLogDir,
1936
2084
  runLogPath,
1937
2085
  STOPPED_SUMMARY,
@@ -1942,14 +2090,14 @@ export {
1942
2090
  t3BaseDirArgs,
1943
2091
  runT3,
1944
2092
  T3Driver,
1945
- takeoverSummary,
1946
- localRunsFilePath,
1947
- LocalDriver,
1948
- readRunRecords,
1949
2093
  boxPath,
1950
2094
  isLocal,
1951
2095
  showsOtherThreads,
1952
2096
  otherThreadsChoice,
1953
2097
  readRunnerConfig,
1954
- writeBoxConfig
2098
+ writeBoxConfig,
2099
+ takeoverSummary,
2100
+ localRunsFilePath,
2101
+ LocalDriver,
2102
+ readRunRecords
1955
2103
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.2" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.8" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  RUN_TEXT_MAX
4
- } from "./chunk-NEGKYXHS.js";
4
+ } from "./chunk-3WD7S6VI.js";
5
5
  import {
6
6
  CONFIG_DIR
7
7
  } from "./chunk-IKCGVBHA.js";