@cloop/runner 0.3.43 → 0.3.46

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.
@@ -4,12 +4,12 @@ import {
4
4
  freshness,
5
5
  outcomeLine,
6
6
  runnerLog
7
- } from "./chunk-CVVYCLZ6.js";
7
+ } from "./chunk-BI2Y5ZCL.js";
8
8
  import {
9
9
  readRunnerState,
10
10
  runnerStatePath,
11
11
  threadsFilePath
12
- } from "./chunk-KFMO7ASY.js";
12
+ } from "./chunk-UXMDNJ3O.js";
13
13
  import {
14
14
  BoxToolError,
15
15
  CLOOP_THREAD_PREFIX,
@@ -21,6 +21,7 @@ import {
21
21
  T3Client,
22
22
  T3Driver,
23
23
  T3HttpError,
24
+ apiErrorWords,
24
25
  boxPath,
25
26
  cloopCommand,
26
27
  commandFor,
@@ -48,7 +49,7 @@ import {
48
49
  windowsExecutable,
49
50
  windowsPowerShellEnv,
50
51
  writeBoxConfig
51
- } from "./chunk-ABVM7DFO.js";
52
+ } from "./chunk-RRRV64ZB.js";
52
53
  import {
53
54
  CLAUDE_FLOOR,
54
55
  CODEX_FLOOR,
@@ -62,14 +63,14 @@ import {
62
63
  } from "./chunk-PKIEWBR7.js";
63
64
  import {
64
65
  connectWebhook
65
- } from "./chunk-3G3DFLOP.js";
66
+ } from "./chunk-NTUUR5CD.js";
66
67
  import {
67
68
  ConnectFailure,
68
69
  connectReport,
69
70
  deviceLogin,
70
71
  newAttempt,
71
72
  sendConnectReport
72
- } from "./chunk-OQWYXCLI.js";
73
+ } from "./chunk-A3YMWMAP.js";
73
74
  import {
74
75
  defaultDeviceName,
75
76
  getMachine,
@@ -77,7 +78,7 @@ import {
77
78
  } from "./chunk-SBYSVZ7J.js";
78
79
  import {
79
80
  VERSION
80
- } from "./chunk-NR6STR7Q.js";
81
+ } from "./chunk-2YAX6QVI.js";
81
82
  import {
82
83
  STAGING_ORIGIN,
83
84
  getOrigin,
@@ -89,15 +90,15 @@ import {
89
90
  import { execFileSync as execFileSync2, spawnSync } from "child_process";
90
91
  import { randomUUID } from "crypto";
91
92
  import {
92
- existsSync as existsSync5,
93
+ existsSync as existsSync6,
93
94
  mkdirSync as mkdirSync3,
94
95
  readdirSync as readdirSync4,
95
96
  rmSync as rmSync3,
96
97
  statSync as statSync2,
97
98
  writeFileSync as writeFileSync2
98
99
  } from "fs";
99
- import { homedir as homedir5, userInfo } from "os";
100
- import { basename as basename5, dirname as dirname3, join as join7, resolve as resolve2 } from "path";
100
+ import { homedir as homedir6, userInfo } from "os";
101
+ import { basename as basename5, dirname as dirname3, join as join8, resolve as resolve2 } from "path";
101
102
  import { createInterface } from "readline/promises";
102
103
  import { Writable } from "stream";
103
104
 
@@ -196,9 +197,9 @@ var POSIX_INSTALL = [
196
197
  'rm -rf "$1.old"',
197
198
  'rm -f "$7"'
198
199
  ].join(" && ");
199
- async function installCodex(home, run = runShown) {
200
+ async function installCodex(home, run2 = runShown) {
200
201
  const command = codexInstallCommand(home);
201
- if (!command || !await run(command)) return false;
202
+ if (!command || !await run2(command)) return false;
202
203
  findLocalCodex(home);
203
204
  return true;
204
205
  }
@@ -212,8 +213,8 @@ function claudeInstallCommand(platform = process.platform) {
212
213
  "irm https://claude.ai/install.ps1 | iex"
213
214
  ] : ["sh", "-c", "curl -fsSL https://claude.ai/install.sh | bash"];
214
215
  }
215
- async function installClaude(home, run = runShown) {
216
- if (!await run(claudeInstallCommand())) return false;
216
+ async function installClaude(home, run2 = runShown) {
217
+ if (!await run2(claudeInstallCommand())) return false;
217
218
  findLocalClaude(home);
218
219
  return true;
219
220
  }
@@ -264,6 +265,176 @@ function hasChatGptApp(home, platform = process.platform, env = process.env, fs
264
265
  return false;
265
266
  }
266
267
 
268
+ // src/chrome-cookies.ts
269
+ import { createDecipheriv, pbkdf2Sync } from "crypto";
270
+
271
+ // ../clo0p-app/contracts/site-jar.ts
272
+ var JAR_MAX_COOKIES = 300;
273
+ function onSite(domain, site) {
274
+ const host = domain.replace(/^\./, "").toLowerCase();
275
+ return host === site || host.endsWith(`.${site}`);
276
+ }
277
+
278
+ // src/chrome-cookies.ts
279
+ var KeychainRefused = class extends Error {
280
+ constructor() {
281
+ super("keychain_refused");
282
+ this.name = "KeychainRefused";
283
+ }
284
+ };
285
+ var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
286
+ var TLD = "(?:[a-z]{2,63}|xn--[a-z0-9-]{1,59})";
287
+ var SITE = new RegExp(`^(?:${LABEL}\\.)+${TLD}$`);
288
+ function parseSite(raw) {
289
+ return typeof raw === "string" && raw.length <= 253 && SITE.test(raw) ? raw : null;
290
+ }
291
+ var keyFrom = (password) => pbkdf2Sync(password, "saltysalt", 1003, 16, "sha1");
292
+ function decrypt(hex, key, version) {
293
+ const buf = Buffer.from(hex, "hex");
294
+ if (buf.subarray(0, 3).toString() !== "v10") return null;
295
+ const d = createDecipheriv("aes-128-cbc", key, Buffer.alloc(16, 32));
296
+ const plain = Buffer.concat([d.update(buf.subarray(3)), d.final()]);
297
+ return (version >= 24 ? plain.subarray(32) : plain).toString("utf8");
298
+ }
299
+ var SAME_SITE = { 0: "None", 1: "Lax", 2: "Strict" };
300
+ var CHROME_EPOCH_S = 11644473600;
301
+ function cookieOf(row, value) {
302
+ const us = Number(row.expires_utc);
303
+ const sameSite = SAME_SITE[row.samesite];
304
+ return {
305
+ name: row.name,
306
+ value,
307
+ domain: row.host_key,
308
+ path: row.path,
309
+ expires: us > 0 ? Math.floor(us / 1e6 - CHROME_EPOCH_S) : -1,
310
+ httpOnly: row.is_httponly === 1,
311
+ secure: row.is_secure === 1,
312
+ ...sameSite ? { sameSite } : {}
313
+ };
314
+ }
315
+ function pickProfile(dbs) {
316
+ let best = null;
317
+ for (const db of dbs) {
318
+ if (db.rows.length === 0) continue;
319
+ if (!best || db.rows.length > best.rows.length || db.rows.length === best.rows.length && db.profile === "Default")
320
+ best = db;
321
+ }
322
+ return best;
323
+ }
324
+ function jarOf(db, key, site) {
325
+ const jar = [];
326
+ for (const row of db.rows) {
327
+ if (!onSite(row.host_key, site)) continue;
328
+ const value = row.value || decrypt(row.ev, key, db.version);
329
+ if (value) jar.push(cookieOf(row, value));
330
+ }
331
+ return jar.slice(0, JAR_MAX_COOKIES);
332
+ }
333
+ function errorCode(err) {
334
+ const code = err?.code;
335
+ if (typeof code === "string" || typeof code === "number") return String(code);
336
+ return err instanceof Error ? err.name : "unknown";
337
+ }
338
+ async function importCookies(args, io) {
339
+ const site = parseSite(args.site);
340
+ const refuse = (because) => {
341
+ io.log(`[runner:cookies] site=${site ?? "-"} because=${because}`);
342
+ return { ok: false, because };
343
+ };
344
+ if (!site) return refuse("bad_site");
345
+ if (io.platform !== "darwin") return refuse("unsupported_os");
346
+ let step = "read";
347
+ try {
348
+ const dbs = await io.readSite(site);
349
+ if (!dbs) return refuse("no_chrome");
350
+ const best = pickProfile(dbs);
351
+ let cookies = [];
352
+ if (best) {
353
+ step = "keychain";
354
+ const key = keyFrom(await io.safeStoragePassword());
355
+ step = "decrypt";
356
+ cookies = jarOf(best, key, site);
357
+ }
358
+ if (!best || cookies.length === 0) {
359
+ if (args.open !== true) return refuse("not_signed_in");
360
+ step = "open";
361
+ await io.openChrome(`https://${site}`);
362
+ return refuse("opened_chrome");
363
+ }
364
+ io.log(`[runner:cookies] site=${site} profile=${best.profile} cookies=${cookies.length}`);
365
+ return { ok: true, profile: best.profile, cookies };
366
+ } catch (err) {
367
+ if (err instanceof KeychainRefused) return refuse("keychain_refused");
368
+ io.log(`[runner:cookies] site=${site} step=${step} error=${errorCode(err)}`);
369
+ return { ok: false, because: "failed" };
370
+ }
371
+ }
372
+
373
+ // src/chrome-mac.ts
374
+ import { execFile } from "child_process";
375
+ import { existsSync as existsSync2 } from "fs";
376
+ import { copyFile, mkdtemp, readdir, rm } from "fs/promises";
377
+ import { homedir, tmpdir } from "os";
378
+ import { join as join2 } from "path";
379
+ import { promisify } from "util";
380
+ var run = promisify(execFile);
381
+ var execText = async (file, args, opts) => (await run(file, args, { ...opts, maxBuffer: 16 * 1024 * 1024 })).stdout;
382
+ var CHROME = "Library/Application Support/Google/Chrome";
383
+ var JARS = ["Network/Cookies", "Cookies"];
384
+ function macChrome(over = {}) {
385
+ const root = join2(over.home ?? homedir(), CHROME);
386
+ const exec3 = over.exec ?? execText;
387
+ const sql = async (db, query) => JSON.parse(
388
+ await exec3("sqlite3", ["-readonly", "-json", db, query], { timeout: 15e3 }) || "[]"
389
+ );
390
+ async function readCopy(profile, file, site) {
391
+ const dir = await mkdtemp(join2(tmpdir(), "cloop-jar-"));
392
+ try {
393
+ const db = join2(dir, "Cookies");
394
+ await copyFile(file, db);
395
+ const rows = await sql(
396
+ db,
397
+ `select host_key, name, path, expires_utc, is_secure, is_httponly, samesite, value, hex(encrypted_value) as ev from cookies where host_key = '${site}' or host_key like '%.${site}'`
398
+ );
399
+ const meta = await sql(db, `select value from meta where key = 'version'`);
400
+ return { profile, version: Number(meta[0]?.value ?? 0), rows };
401
+ } finally {
402
+ await rm(dir, { recursive: true, force: true });
403
+ }
404
+ }
405
+ return {
406
+ platform: over.platform ?? process.platform,
407
+ async readSite(site) {
408
+ if (!existsSync2(root)) return null;
409
+ const profiles = (await readdir(root, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name).sort();
410
+ const dbs = [];
411
+ for (const profile of profiles)
412
+ for (const jar of JARS) {
413
+ const file = join2(root, profile, jar);
414
+ if (existsSync2(file)) dbs.push(await readCopy(profile, file, site));
415
+ }
416
+ return dbs;
417
+ },
418
+ async safeStoragePassword() {
419
+ try {
420
+ const out2 = await exec3(
421
+ "security",
422
+ ["find-generic-password", "-w", "-s", "Chrome Safe Storage"],
423
+ { timeout: 12e4 }
424
+ );
425
+ return out2.trim();
426
+ } catch (err) {
427
+ if (typeof err.code === "number") throw new KeychainRefused();
428
+ throw err;
429
+ }
430
+ },
431
+ async openChrome(url) {
432
+ await exec3("open", ["-a", "Google Chrome", url], { timeout: 15e3 });
433
+ },
434
+ log: (line2) => console.error(line2)
435
+ };
436
+ }
437
+
267
438
  // src/box-tools.ts
268
439
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
269
440
  function parseLaunchArgs(args) {
@@ -352,7 +523,9 @@ var BOX_TOOLS = {
352
523
  async "setup.share"({ setup }) {
353
524
  if (!setup) throw new BoxToolError("cannot_share");
354
525
  return setup.start();
355
- }
526
+ },
527
+ // One site's sign-in from the owner's Chrome, for the app to keep. Every refusal is an answer, not an error.
528
+ "cookies.import": ({ chrome }, args) => importCookies(args, chrome ?? macChrome())
356
529
  };
357
530
  function classifyError(err, driver = "t3") {
358
531
  if (err instanceof BoxToolError) return err.code;
@@ -433,7 +606,7 @@ async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
433
606
  }
434
607
 
435
608
  // src/drivers/claude-code.ts
436
- import { execFile } from "child_process";
609
+ import { execFile as execFile2 } from "child_process";
437
610
  import { readFileSync } from "fs";
438
611
  import { basename as basename2, extname, isAbsolute, relative, resolve } from "path";
439
612
  var SUBSCRIPTIONS = {
@@ -445,7 +618,7 @@ var SUBSCRIPTIONS = {
445
618
  function exec(bin, args) {
446
619
  const command = commandFor(bin, args);
447
620
  return new Promise(
448
- (resolve3) => execFile(
621
+ (resolve3) => execFile2(
449
622
  command.file,
450
623
  command.args,
451
624
  {
@@ -598,16 +771,16 @@ function imageBlock(path) {
598
771
  var IMAGE_TYPE_OF = Object.fromEntries(
599
772
  Object.entries(IMAGE_TYPES).map(([type, ext]) => [ext, type])
600
773
  );
601
- function userMessage(run, text, priority, images = []) {
774
+ function userMessage(run2, text, priority, images = []) {
602
775
  return {
603
776
  type: "user",
604
777
  message: { role: "user", content: [...images.flatMap(imageBlock), { type: "text", text }] },
605
778
  parent_tool_use_id: null,
606
- session_id: run.session_id ?? run.work_id,
779
+ session_id: run2.session_id ?? run2.work_id,
607
780
  ...priority ? { priority } : {}
608
781
  };
609
782
  }
610
- function parseClaudeLine(raw, run) {
783
+ function parseClaudeLine(raw, run2) {
611
784
  let msg;
612
785
  try {
613
786
  msg = JSON.parse(raw);
@@ -632,7 +805,7 @@ function parseClaudeLine(raw, run) {
632
805
  const path = pathOf(block.input);
633
806
  const description = block.input?.description;
634
807
  const summary = typeof description === "string" ? cut(description, 200) : TOOL_WORDS[block.name];
635
- const detail = toolDetail(block.name, block.input, run.repo);
808
+ const detail = toolDetail(block.name, block.input, run2.repo);
636
809
  return [
637
810
  {
638
811
  type: "tool",
@@ -657,7 +830,7 @@ function parseClaudeLine(raw, run) {
657
830
  request_id: msg.request_id,
658
831
  tool,
659
832
  input: request.input ?? {},
660
- summary: askSummary(tool, request.input, run.repo)
833
+ summary: askSummary(tool, request.input, run2.repo)
661
834
  }
662
835
  ];
663
836
  }
@@ -691,7 +864,7 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
691
864
  capabilities: ["view", "start", "steer", "report"],
692
865
  env: { CLAUDE_CODE_MCP_STARTUP_WAIT_MS: String(MCP_STARTUP_WAIT_MS) },
693
866
  keepsStdin: true,
694
- args(run, resume) {
867
+ args(run2, resume) {
695
868
  return [
696
869
  "--print",
697
870
  "--verbose",
@@ -710,20 +883,20 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
710
883
  JSON.stringify(readOnlySettings(askEverything))
711
884
  ],
712
885
  "--add-dir",
713
- run.repo,
714
- ...resume ? ["--resume", run.session_id ?? run.work_id] : ["--session-id", run.session_id ?? run.work_id],
715
- ...run.model ? ["--model", run.model] : fallback ? ["--fallback-model", fallback] : []
886
+ run2.repo,
887
+ ...resume ? ["--resume", run2.session_id ?? run2.work_id] : ["--session-id", run2.session_id ?? run2.work_id],
888
+ ...run2.model ? ["--model", run2.model] : fallback ? ["--fallback-model", fallback] : []
716
889
  ];
717
890
  },
718
- opening(run, prompt, images = []) {
891
+ opening(run2, prompt, images = []) {
719
892
  return line({
720
893
  type: "control_request",
721
894
  request_id: "cloop-init",
722
895
  request: { subtype: "initialize" }
723
- }) + line(userMessage(run, prompt, void 0, images));
896
+ }) + line(userMessage(run2, prompt, void 0, images));
724
897
  },
725
- userLine(run, text, mode) {
726
- return line(userMessage(run, text, mode === "steer" ? "now" : "next"));
898
+ userLine(run2, text, mode) {
899
+ return line(userMessage(run2, text, mode === "steer" ? "now" : "next"));
727
900
  },
728
901
  answerLine(ask, text) {
729
902
  const input = ask.input ?? {};
@@ -740,18 +913,18 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
740
913
  });
741
914
  },
742
915
  parse: parseClaudeLine,
743
- owns: (run, command) => command.includes(basename2(bin)) && [run.work_id, run.session_id].some((id) => id !== null && command.includes(id)),
916
+ owns: (run2, command) => command.includes(basename2(bin)) && [run2.work_id, run2.session_id].some((id) => id !== null && command.includes(id)),
744
917
  probe: () => probeClaude(bin)
745
918
  };
746
919
  }
747
920
 
748
921
  // src/drivers/codex.ts
749
- import { execFile as execFile2 } from "child_process";
922
+ import { execFile as execFile3 } from "child_process";
750
923
  import { basename as basename3 } from "path";
751
924
  function exec2(bin, args, timeout = 1e4) {
752
925
  const command = commandFor(bin, args);
753
926
  return new Promise(
754
- (resolve3) => execFile2(
927
+ (resolve3) => execFile3(
755
928
  command.file,
756
929
  command.args,
757
930
  {
@@ -798,14 +971,6 @@ async function codexModels(bin = "codex") {
798
971
  return [];
799
972
  }
800
973
  }
801
- function errorMessage(message) {
802
- try {
803
- const inner = JSON.parse(message).error?.message;
804
- return typeof inner === "string" ? inner : message;
805
- } catch {
806
- return message;
807
- }
808
- }
809
974
  function parseCodexLine(raw) {
810
975
  let msg;
811
976
  try {
@@ -840,7 +1005,7 @@ function parseCodexLine(raw) {
840
1005
  if (msg.type === "turn.completed") return [{ type: "result", ok: true }];
841
1006
  if (msg.type === "turn.failed") {
842
1007
  const message = msg.error?.message;
843
- const text = typeof message === "string" ? errorMessage(message) : void 0;
1008
+ const text = typeof message === "string" ? apiErrorWords(message) : void 0;
844
1009
  return [
845
1010
  { type: "result", ok: false, ...text ? { text } : {} },
846
1011
  ...text && HARNESS_SIGNED_OUT.test(text) ? [{ type: "signed_out" }] : []
@@ -857,38 +1022,38 @@ function codexDialect(bin = "codex") {
857
1022
  bin,
858
1023
  capabilities: ["view", "start", "report"],
859
1024
  keepsStdin: false,
860
- args(run, resume, images = []) {
861
- const model = run.model ? ["--model", run.model] : [];
1025
+ args(run2, resume, images = []) {
1026
+ const model = run2.model ? ["--model", run2.model] : [];
862
1027
  const attach = images.length ? [`--image=${images.join(",")}`] : [];
863
1028
  const policy = ["--dangerously-bypass-approvals-and-sandbox", "--skip-git-repo-check"];
864
- return resume && run.session_id ? ["exec", ...policy, "resume", run.session_id, "--json", ...model, "-"] : ["exec", "--cd", run.repo, "--json", ...policy, ...model, ...attach, "-"];
1029
+ return resume && run2.session_id ? ["exec", ...policy, "resume", run2.session_id, "--json", ...model, "-"] : ["exec", "--cd", run2.repo, "--json", ...policy, ...model, ...attach, "-"];
865
1030
  },
866
1031
  opening: (_run, prompt) => prompt,
867
1032
  models: () => codexModels(bin),
868
1033
  parse: parseCodexLine,
869
1034
  // A fresh run's command line names no id: Codex makes its session id after the start. So a run is also matched by its exact repository, which one open run per repository makes unique.
870
- owns: (run, command) => command.includes(basename3(bin)) && command.includes("exec") && command.includes("--json") && (run.session_id !== null && command.includes(run.session_id) || command.includes(`--cd ${run.repo} `)),
1035
+ owns: (run2, command) => command.includes(basename3(bin)) && command.includes("exec") && command.includes("--json") && (run2.session_id !== null && command.includes(run2.session_id) || command.includes(`--cd ${run2.repo} `)),
871
1036
  probe: () => probeCodex(bin)
872
1037
  };
873
1038
  }
874
1039
 
875
1040
  // src/legacy-staging.ts
876
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, renameSync as renameSync2, rmSync as rmSync2 } from "fs";
877
- import { homedir as homedir3 } from "os";
878
- import { join as join6 } from "path";
1041
+ import { existsSync as existsSync5, mkdirSync as mkdirSync2, renameSync as renameSync2, rmSync as rmSync2 } from "fs";
1042
+ import { homedir as homedir4 } from "os";
1043
+ import { join as join7 } from "path";
879
1044
 
880
1045
  // src/commands/disconnect.ts
881
1046
  import { execFileSync } from "child_process";
882
- import { existsSync as existsSync3, readFileSync as readFileSync3, rmSync } from "fs";
883
- import { homedir as homedir2 } from "os";
1047
+ import { existsSync as existsSync4, readFileSync as readFileSync3, rmSync } from "fs";
1048
+ import { homedir as homedir3 } from "os";
884
1049
  import { basename as basename4 } from "path";
885
1050
 
886
1051
  // src/existing-runner.ts
887
- import { existsSync as existsSync2 } from "fs";
1052
+ import { existsSync as existsSync3 } from "fs";
888
1053
  var ALL = Object.keys(ENVIRONMENTS);
889
1054
  function runnersOnThisComputer() {
890
1055
  if (legacyStagingRunner()) return ["staging"];
891
- return ALL.filter((env) => existsSync2(boxPath(env)));
1056
+ return ALL.filter((env) => existsSync3(boxPath(env)));
892
1057
  }
893
1058
  function existingRunnerEnvironment() {
894
1059
  const named = process.env.CLOOP_ORIGIN;
@@ -920,20 +1085,20 @@ import {
920
1085
  unlinkSync,
921
1086
  writeFileSync
922
1087
  } from "fs";
923
- import { dirname as dirname2, join as join5 } from "path";
1088
+ import { dirname as dirname2, join as join6 } from "path";
924
1089
 
925
1090
  // src/threads/claude-code.ts
926
1091
  import { readdirSync as readdirSync2 } from "fs";
927
- import { join as join3 } from "path";
1092
+ import { join as join4 } from "path";
928
1093
 
929
1094
  // src/harness-home.ts
930
- import { homedir } from "os";
931
- import { join as join2 } from "path";
1095
+ import { homedir as homedir2 } from "os";
1096
+ import { join as join3 } from "path";
932
1097
  function claudeHome() {
933
- return process.env.CLAUDE_CONFIG_DIR || join2(homedir(), ".claude");
1098
+ return process.env.CLAUDE_CONFIG_DIR || join3(homedir2(), ".claude");
934
1099
  }
935
1100
  function codexHome2() {
936
- return process.env.CODEX_HOME || join2(homedir(), ".codex");
1101
+ return process.env.CODEX_HOME || join3(homedir2(), ".codex");
937
1102
  }
938
1103
 
939
1104
  // src/threads/turns.ts
@@ -1012,14 +1177,14 @@ var EDIT_TOOLS = {
1012
1177
  NotebookEdit: "notebook_path"
1013
1178
  };
1014
1179
  function files(home) {
1015
- const root = join3(home, "projects");
1180
+ const root = join4(home, "projects");
1016
1181
  const out2 = [];
1017
1182
  for (const project of safeDir(root)) {
1018
1183
  if (!project.isDirectory()) continue;
1019
- for (const entry of safeDir(join3(root, project.name))) {
1184
+ for (const entry of safeDir(join4(root, project.name))) {
1020
1185
  if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
1021
1186
  const sessionId = entry.name.slice(0, -6);
1022
- if (UUID3.test(sessionId)) out2.push({ path: join3(root, project.name, entry.name), sessionId });
1187
+ if (UUID3.test(sessionId)) out2.push({ path: join4(root, project.name, entry.name), sessionId });
1023
1188
  }
1024
1189
  }
1025
1190
  return out2;
@@ -1127,7 +1292,7 @@ var claudeCodeLogs = { home: claudeHome, files, parse };
1127
1292
 
1128
1293
  // src/threads/codex.ts
1129
1294
  import { readdirSync as readdirSync3 } from "fs";
1130
- import { join as join4 } from "path";
1295
+ import { join as join5 } from "path";
1131
1296
  var ROLLOUT = /^rollout-.*([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\.jsonl$/i;
1132
1297
  var INJECTED = [
1133
1298
  "<environment_context",
@@ -1148,7 +1313,7 @@ function files2(home) {
1148
1313
  const out2 = [];
1149
1314
  const walk = (dir, depth) => {
1150
1315
  for (const entry of safeDir2(dir)) {
1151
- const path = join4(dir, entry.name);
1316
+ const path = join5(dir, entry.name);
1152
1317
  if (entry.isDirectory() && depth < 3) walk(path, depth + 1);
1153
1318
  else if (entry.isFile() && depth === 3) {
1154
1319
  const m = ROLLOUT.exec(entry.name);
@@ -1156,7 +1321,7 @@ function files2(home) {
1156
1321
  }
1157
1322
  }
1158
1323
  };
1159
- walk(join4(home, "sessions"), 0);
1324
+ walk(join5(home, "sessions"), 0);
1160
1325
  return out2;
1161
1326
  }
1162
1327
  function safeDir2(dir) {
@@ -1357,7 +1522,7 @@ var GATE_OFF_PAUSE_MS = 60 * 6e4;
1357
1522
  var BODY_BYTES_MAX = 512 * 1024;
1358
1523
  var READ_CHUNK = 1024 * 1024;
1359
1524
  function captureCursorPath(threadsFile) {
1360
- return join5(dirname2(threadsFile), "thread-capture.json");
1525
+ return join6(dirname2(threadsFile), "thread-capture.json");
1361
1526
  }
1362
1527
  var ThreadCapture = class {
1363
1528
  constructor(deps) {
@@ -1785,7 +1950,7 @@ function unitOrigin(contents) {
1785
1950
  return launcher ? launcher.replace(/%%/g, "%") : null;
1786
1951
  }
1787
1952
  function disconnectPlan(opts) {
1788
- const exists = opts.exists ?? existsSync3;
1953
+ const exists = opts.exists ?? existsSync4;
1789
1954
  const read = opts.read ?? ((path) => readFileSync3(path, "utf-8"));
1790
1955
  const installed = ["local", "workstation"].map((kind) => ({ kind, service: installedService({ ...opts, kind }) })).filter(({ service }) => exists(service.path));
1791
1956
  const services = installed.map(({ service }) => service);
@@ -1805,12 +1970,12 @@ function disconnectPlan(opts) {
1805
1970
  isBox: opts.platform !== "darwin" && opts.platform !== "win32" && installed.some(({ kind }) => kind === "workstation")
1806
1971
  };
1807
1972
  }
1808
- async function stopService(service, run, waitMs = 1e4) {
1809
- await runSteps(service.steps, run);
1973
+ async function stopService(service, run2, waitMs = 1e4) {
1974
+ await runSteps(service.steps, run2);
1810
1975
  const until = Date.now() + waitMs;
1811
1976
  for (; ; ) {
1812
1977
  try {
1813
- run(service.running);
1978
+ run2(service.running);
1814
1979
  } catch {
1815
1980
  return true;
1816
1981
  }
@@ -1843,7 +2008,7 @@ function revokeLine(revoke, origin, box) {
1843
2008
  async function disconnect(plan, opts) {
1844
2009
  const { say } = opts;
1845
2010
  const env = environmentOf(plan.origin);
1846
- const run = opts.run ?? ((command) => void execFileSync(command[0], command.slice(1), {
2011
+ const run2 = opts.run ?? ((command) => void execFileSync(command[0], command.slice(1), {
1847
2012
  stdio: "ignore",
1848
2013
  timeout: 15e3,
1849
2014
  ...command[0] === "powershell" ? { env: windowsPowerShellEnv() } : {}
@@ -1858,7 +2023,7 @@ async function disconnect(plan, opts) {
1858
2023
  return 1;
1859
2024
  }
1860
2025
  for (const service of plan.services) {
1861
- if (!await stopService(service, run, opts.stopWaitMs)) {
2026
+ if (!await stopService(service, run2, opts.stopWaitMs)) {
1862
2027
  say(
1863
2028
  `Could not stop the service in ${service.path}. Nothing was removed. Stop it with \`${service.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run \`${cloopCommand(env, "disconnect")}\` again.`
1864
2029
  );
@@ -1889,7 +2054,7 @@ function thisComputer(env, fallbackOrigin) {
1889
2054
  return {
1890
2055
  platform: process.platform,
1891
2056
  environment: env,
1892
- home: homedir2(),
2057
+ home: homedir3(),
1893
2058
  uid: process.getuid?.() ?? 0,
1894
2059
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {},
1895
2060
  box: boxPath(env),
@@ -1929,16 +2094,16 @@ var MOVED = [
1929
2094
  "box.json"
1930
2095
  ];
1931
2096
  function legacyStagingRunner() {
1932
- if (existsSync4(boxPath("staging"))) return false;
2097
+ if (existsSync5(boxPath("staging"))) return false;
1933
2098
  const origin = runnerOrigin("production");
1934
2099
  return origin !== void 0 && environmentOf(origin) === "staging";
1935
2100
  }
1936
2101
  function moveRunnerFiles(from, to) {
1937
2102
  mkdirSync2(to, { recursive: true, mode: 448 });
1938
2103
  for (const name of MOVED) {
1939
- const source = join6(from, name);
1940
- const target = join6(to, name);
1941
- if (existsSync4(source) && !existsSync4(target)) renameSync2(source, target);
2104
+ const source = join7(from, name);
2105
+ const target = join7(to, name);
2106
+ if (existsSync5(source) && !existsSync5(target)) renameSync2(source, target);
1942
2107
  }
1943
2108
  }
1944
2109
  function legacyServices(platform) {
@@ -1947,18 +2112,18 @@ function legacyServices(platform) {
1947
2112
  platform,
1948
2113
  kind,
1949
2114
  environment: "production",
1950
- home: homedir3(),
2115
+ home: homedir4(),
1951
2116
  uid: process.getuid?.() ?? 0,
1952
2117
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
1953
2118
  })
1954
- ).filter((service) => existsSync4(service.path));
2119
+ ).filter((service) => existsSync5(service.path));
1955
2120
  }
1956
2121
  async function moveLegacyStagingRunner(services) {
1957
2122
  if (!legacyStagingRunner()) return false;
1958
- const run = (command) => void services.run(command);
2123
+ const run2 = (command) => void services.run(command);
1959
2124
  const units = legacyServices(services.platform);
1960
2125
  for (const unit of units)
1961
- if (!await stopService(unit, run))
2126
+ if (!await stopService(unit, run2))
1962
2127
  throw new Error(
1963
2128
  `Could not stop the staging machine in ${unit.path}. Stop it with \`${unit.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run this again.`
1964
2129
  );
@@ -1973,8 +2138,8 @@ function movedLine(connecting) {
1973
2138
  }
1974
2139
 
1975
2140
  // src/mcp-registration.ts
1976
- import { execFile as execFile3, spawn as spawn2 } from "child_process";
1977
- import { homedir as homedir4 } from "os";
2141
+ import { execFile as execFile4, spawn as spawn2 } from "child_process";
2142
+ import { homedir as homedir5 } from "os";
1978
2143
  var MCP_HARNESS_NAME = {
1979
2144
  "claude-code": "Claude Code",
1980
2145
  codex: "Codex"
@@ -2016,12 +2181,12 @@ var systemMcpCli = {
2016
2181
  run: ([bin = "", ...args], env) => {
2017
2182
  const command = commandFor(bin, args);
2018
2183
  return new Promise(
2019
- (resolve3, reject) => execFile3(
2184
+ (resolve3, reject) => execFile4(
2020
2185
  command.file,
2021
2186
  command.args,
2022
2187
  {
2023
2188
  // A project's own MCP config under the folder connect ran in must not stand in for the user's.
2024
- cwd: homedir4(),
2189
+ cwd: homedir5(),
2025
2190
  timeout: 45e3,
2026
2191
  encoding: "utf-8",
2027
2192
  env: { ...process.env, ...env },
@@ -2038,7 +2203,7 @@ var systemMcpCli = {
2038
2203
  };
2039
2204
  process.on("SIGINT", ignore);
2040
2205
  const child = spawn2(command.file, command.args, {
2041
- cwd: homedir4(),
2206
+ cwd: homedir5(),
2042
2207
  stdio: "inherit",
2043
2208
  ...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
2044
2209
  });
@@ -2174,15 +2339,15 @@ function mcpByHand(harness, server, platform = process.platform, env = process.e
2174
2339
  }
2175
2340
  function mcpLine(result) {
2176
2341
  const name = MCP_HARNESS_NAME[result.harness];
2177
- const run = result.byHand.length ? ` Run: ${result.byHand.join(", then: ")}` : "";
2342
+ const run2 = result.byHand.length ? ` Run: ${result.byHand.join(", then: ")}` : "";
2178
2343
  if (!result.registered)
2179
- return `Could not add the Cloop MCP server to ${name} (${result.reason}).${run}`;
2344
+ return `Could not add the Cloop MCP server to ${name} (${result.reason}).${run2}`;
2180
2345
  if (result.found) {
2181
2346
  const head = `${name} already has the Cloop MCP server as ${result.as}`;
2182
- return result.signedIn ? `${head}, signed in.` : `${head}. It is not signed in.${run}`;
2347
+ return result.signedIn ? `${head}, signed in.` : `${head}. It is not signed in.${run2}`;
2183
2348
  }
2184
2349
  if (result.signedIn) return `${name} has the Cloop MCP server at ${result.url}, signed in.`;
2185
- return `${name} has the Cloop MCP server at ${result.url}. It is not signed in (${result.reason}).${run}`;
2350
+ return `${name} has the Cloop MCP server at ${result.url}. It is not signed in (${result.reason}).${run2}`;
2186
2351
  }
2187
2352
 
2188
2353
  // src/t3-pair-link.ts
@@ -2262,7 +2427,7 @@ function boxSession(t3Url, t3Bin, env, token) {
2262
2427
  }
2263
2428
  async function mintSession(t3Url, opts = {}) {
2264
2429
  const env = await workstationEnvironment(t3Url, opts.fetchFn);
2265
- const sources = opts.sources ?? defaultT3BinSources(homedir5(), opts.stored);
2430
+ const sources = opts.sources ?? defaultT3BinSources(homedir6(), opts.stored);
2266
2431
  try {
2267
2432
  const t3Bin = opts.bin ?? pickT3Bin(t3Candidates(env.serverVersion, sources), env.serverVersion);
2268
2433
  if (!t3Bin) throw new Error("no t3 binary found; pass --t3-bin or set T3_BIN");
@@ -2379,12 +2544,12 @@ function isWorkstation(previous, boxServiceInstalled2) {
2379
2544
  return boxServiceInstalled2 || Boolean(previous && !isLocal(previous));
2380
2545
  }
2381
2546
  function boxServiceInstalled() {
2382
- return existsSync5(
2547
+ return existsSync6(
2383
2548
  installedService({
2384
2549
  platform: process.platform,
2385
2550
  kind: "workstation",
2386
2551
  environment: runnerEnvironment(),
2387
- home: homedir5(),
2552
+ home: homedir6(),
2388
2553
  uid: process.getuid?.() ?? 0,
2389
2554
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
2390
2555
  }).path
@@ -2404,19 +2569,19 @@ async function revokeReplaced(previous, kind, revoke, say) {
2404
2569
  function fallbackLine(reason, driver) {
2405
2570
  return `T3 Code is running but would not pair (${reason}). Connecting ${HARNESS_NAME[driver]} instead. To use T3, create a pairing link in T3 Code (Settings, Connections) and run: cloop connect --t3-pair <link>`;
2406
2571
  }
2407
- async function connectChosen(driver, attempt, run) {
2572
+ async function connectChosen(driver, attempt, run2) {
2408
2573
  attempt.driver = driver;
2409
- if (driver !== "t3") return run.local(driver);
2574
+ if (driver !== "t3") return run2.local(driver);
2410
2575
  try {
2411
- await run.t3();
2576
+ await run2.t3();
2412
2577
  } catch (err) {
2413
2578
  if (!(err instanceof ConnectFailure) || err.code !== "t3_pair_failed") throw err;
2414
- const local = run.fallback();
2579
+ const local = run2.fallback();
2415
2580
  if (!local) throw err;
2416
- run.say(fallbackLine(err.message, local));
2581
+ run2.say(fallbackLine(err.message, local));
2417
2582
  attempt.fellBack = true;
2418
2583
  attempt.driver = local;
2419
- await run.local(local);
2584
+ await run2.local(local);
2420
2585
  }
2421
2586
  }
2422
2587
  function systemdAssignment(assignment) {
@@ -2483,8 +2648,8 @@ function programFor(script, node, npx, version) {
2483
2648
  }
2484
2649
  function findNpx() {
2485
2650
  const name = process.platform === "win32" ? "npx.cmd" : "npx";
2486
- const beside = join7(dirname3(process.execPath), name);
2487
- return existsSync5(beside) ? beside : which(name);
2651
+ const beside = join8(dirname3(process.execPath), name);
2652
+ return existsSync6(beside) ? beside : which(name);
2488
2653
  }
2489
2654
  var FIRST_CONNECT_MS = 9e4;
2490
2655
  async function awaitDaemon(since, read = readRunnerState, { timeoutMs = FIRST_CONNECT_MS, pollMs = 500 } = {}) {
@@ -2522,14 +2687,14 @@ function installedService(opts) {
2522
2687
  const { label, unit, task, file } = serviceIdentity(opts.kind, opts.environment);
2523
2688
  if (opts.platform === "darwin") {
2524
2689
  return {
2525
- path: join7(opts.dir ?? join7(opts.home, "Library", "LaunchAgents"), `${label}.plist`),
2690
+ path: join8(opts.dir ?? join8(opts.home, "Library", "LaunchAgents"), `${label}.plist`),
2526
2691
  steps: [{ command: ["launchctl", "bootout", `gui/${opts.uid}/${label}`], mayFail: true }],
2527
2692
  running: ["launchctl", "print", `gui/${opts.uid}/${label}`]
2528
2693
  };
2529
2694
  }
2530
2695
  if (opts.platform === "win32") {
2531
2696
  return {
2532
- path: join7(opts.dir ?? join7(opts.home, "AppData", "Local", "Cloop"), `${file}.cmd`),
2697
+ path: join8(opts.dir ?? join8(opts.home, "AppData", "Local", "Cloop"), `${file}.cmd`),
2533
2698
  steps: [
2534
2699
  { command: ["schtasks", "/end", "/tn", task], mayFail: true },
2535
2700
  endDaemonStep(opts.environment),
@@ -2539,7 +2704,7 @@ function installedService(opts) {
2539
2704
  };
2540
2705
  }
2541
2706
  return {
2542
- path: join7(opts.dir ?? join7(opts.home, ".config", "systemd", "user"), unit),
2707
+ path: join8(opts.dir ?? join8(opts.home, ".config", "systemd", "user"), unit),
2543
2708
  steps: [{ command: ["systemctl", "--user", "disable", "--now", unit], mayFail: true }],
2544
2709
  running: ["systemctl", "--user", "is-active", "--quiet", unit]
2545
2710
  };
@@ -2552,9 +2717,9 @@ function unitFor(opts) {
2552
2717
  kind: opts.kind === "workstation" ? "local" : "workstation"
2553
2718
  });
2554
2719
  if (opts.platform === "darwin") {
2555
- const agents = opts.dir ?? join7(opts.home, "Library", "LaunchAgents");
2556
- const path2 = join7(agents, `${label}.plist`);
2557
- const log = join7(opts.home, "Library", "Logs", `${file}.log`);
2720
+ const agents = opts.dir ?? join8(opts.home, "Library", "LaunchAgents");
2721
+ const path2 = join8(agents, `${label}.plist`);
2722
+ const log = join8(opts.home, "Library", "Logs", `${file}.log`);
2558
2723
  const xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2559
2724
  const contents2 = [
2560
2725
  '<?xml version="1.0" encoding="UTF-8"?>',
@@ -2591,9 +2756,9 @@ function unitFor(opts) {
2591
2756
  };
2592
2757
  }
2593
2758
  if (opts.platform === "win32") {
2594
- const dir = opts.dir ?? join7(opts.home, "AppData", "Local", "Cloop");
2595
- const path2 = join7(dir, `${file}.cmd`);
2596
- const log = join7(dir, `${file}.log`);
2759
+ const dir = opts.dir ?? join8(opts.home, "AppData", "Local", "Cloop");
2760
+ const path2 = join8(dir, `${file}.cmd`);
2761
+ const log = join8(dir, `${file}.log`);
2597
2762
  const psLog = log.replace(/'/g, "''");
2598
2763
  const contents2 = [
2599
2764
  "@echo off",
@@ -2633,8 +2798,8 @@ function unitFor(opts) {
2633
2798
  ]
2634
2799
  };
2635
2800
  }
2636
- const units = opts.dir ?? join7(opts.home, ".config", "systemd", "user");
2637
- const path = join7(units, unit);
2801
+ const units = opts.dir ?? join8(opts.home, ".config", "systemd", "user");
2802
+ const path = join8(units, unit);
2638
2803
  const contents = [
2639
2804
  "[Unit]",
2640
2805
  `Description=${task}: answers the Cloop Agent over the mesh`,
@@ -2705,13 +2870,13 @@ function findCheckouts(home, limit = 8) {
2705
2870
  for (const root of CHECKOUT_ROOTS) {
2706
2871
  let entries;
2707
2872
  try {
2708
- entries = readdirSync4(join7(home, root), { withFileTypes: true });
2873
+ entries = readdirSync4(join8(home, root), { withFileTypes: true });
2709
2874
  } catch {
2710
2875
  continue;
2711
2876
  }
2712
2877
  for (const entry of entries) {
2713
- const path = join7(home, root, entry.name);
2714
- if (!entry.isDirectory() || !existsSync5(join7(path, ".git"))) continue;
2878
+ const path = join8(home, root, entry.name);
2879
+ if (!entry.isDirectory() || !existsSync6(join8(path, ".git"))) continue;
2715
2880
  found.push({ repo: { label: entry.name, path }, at: lastCommitAt(path) });
2716
2881
  }
2717
2882
  }
@@ -2731,7 +2896,7 @@ function rerunCommand(argv, script = process.argv[1] ?? "") {
2731
2896
  return [base, "connect", ...staging, ...argv].join(" ");
2732
2897
  }
2733
2898
  function workFolder(home) {
2734
- return { label: "Cloop", path: join7(home, "Cloop") };
2899
+ return { label: "Cloop", path: join8(home, "Cloop") };
2735
2900
  }
2736
2901
  function workFolderLine(found, home, argv, terminal) {
2737
2902
  const rerun = rerunCommand(argv.filter((a) => a !== "--ask"));
@@ -2767,7 +2932,7 @@ async function reposFor(argv) {
2767
2932
  }
2768
2933
  const here = gitTop(process.cwd());
2769
2934
  if (here) return [{ label: basename5(here), path: here }];
2770
- const home = homedir5();
2935
+ const home = homedir6();
2771
2936
  const work = workFolder(home);
2772
2937
  const found = findCheckouts(home);
2773
2938
  let repos = [work];
@@ -2826,12 +2991,12 @@ function harnessLine(h) {
2826
2991
  const account = h.signedIn ? h.account ?? "signed in" : "signed out";
2827
2992
  return `${h.name}${version}, ${account}${h.experimental ? " (experimental)" : ""}`;
2828
2993
  }
2829
- async function runSteps(steps, run = (command) => void execFileSync2(command[0], command.slice(1), { stdio: "ignore", timeout: 15e3 }), wait = (ms) => new Promise((r) => setTimeout(r, ms))) {
2994
+ async function runSteps(steps, run2 = (command) => void execFileSync2(command[0], command.slice(1), { stdio: "ignore", timeout: 15e3 }), wait = (ms) => new Promise((r) => setTimeout(r, ms))) {
2830
2995
  for (const step of steps) {
2831
2996
  const tries = step.tries ?? 1;
2832
2997
  for (let attempt = 1; ; attempt++) {
2833
2998
  try {
2834
- run(step.command);
2999
+ run2(step.command);
2835
3000
  break;
2836
3001
  } catch (err) {
2837
3002
  if (step.mayFail) break;
@@ -2851,9 +3016,9 @@ var systemServices = {
2851
3016
  }),
2852
3017
  awaitUp: (since) => awaitDaemon(since)
2853
3018
  };
2854
- function ensureLinger(user, run) {
3019
+ function ensureLinger(user, run2) {
2855
3020
  try {
2856
- if (/Linger=yes/.test(run(["loginctl", "show-user", user, "-p", "Linger"]))) {
3021
+ if (/Linger=yes/.test(run2(["loginctl", "show-user", user, "-p", "Linger"]))) {
2857
3022
  return { ok: true, changed: false };
2858
3023
  }
2859
3024
  } catch {
@@ -2863,7 +3028,7 @@ function ensureLinger(user, run) {
2863
3028
  ["sudo", "-n", "loginctl", "enable-linger", user]
2864
3029
  ]) {
2865
3030
  try {
2866
- run(command);
3031
+ run2(command);
2867
3032
  return { ok: true, changed: true };
2868
3033
  } catch {
2869
3034
  }
@@ -2883,13 +3048,13 @@ async function installService(kind, argv, attempt, services = systemServices) {
2883
3048
  platform: services.platform,
2884
3049
  kind,
2885
3050
  environment,
2886
- home: homedir5(),
3051
+ home: homedir6(),
2887
3052
  program,
2888
3053
  env: serviceEnv(),
2889
3054
  uid: process.getuid?.() ?? 0,
2890
3055
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
2891
3056
  });
2892
- mkdirSync3(join7(unit.path, ".."), { recursive: true });
3057
+ mkdirSync3(join8(unit.path, ".."), { recursive: true });
2893
3058
  writeFileSync2(unit.path, unit.contents);
2894
3059
  if (argv.includes("--no-start")) {
2895
3060
  out(
@@ -2899,16 +3064,16 @@ async function installService(kind, argv, attempt, services = systemServices) {
2899
3064
  }
2900
3065
  attempt.step = "service_start";
2901
3066
  const since = Date.now();
2902
- const run = (command) => void services.run(command);
3067
+ const run2 = (command) => void services.run(command);
2903
3068
  try {
2904
- if (existsSync5(unit.retire.path)) {
3069
+ if (existsSync6(unit.retire.path)) {
2905
3070
  out(
2906
3071
  ` This computer is already a ${environment} machine, so connect stops and removes ${unit.retire.path}.`
2907
3072
  );
2908
- await runSteps(unit.retire.steps, run);
3073
+ await runSteps(unit.retire.steps, run2);
2909
3074
  rmSync3(unit.retire.path, { force: true });
2910
3075
  }
2911
- await runSteps(unit.start, run);
3076
+ await runSteps(unit.start, run2);
2912
3077
  } catch (err) {
2913
3078
  throw new ConnectFailure(
2914
3079
  "service_start_failed",
@@ -3040,7 +3205,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
3040
3205
  async function connectLocal(driver, found, argv, attempt, chosen, services) {
3041
3206
  attempt.step = "repos";
3042
3207
  const repos = await reposFor(argv);
3043
- const work = workFolder(homedir5()).path;
3208
+ const work = workFolder(homedir6()).path;
3044
3209
  attempt.workFolder = repos.every((r) => r.path === work);
3045
3210
  const harness = driver === "claude-code" ? found.claude : found.codex;
3046
3211
  const bin = which(driver === "claude-code" ? "claude" : "codex") ?? (driver === "claude-code" ? "claude" : "codex");
@@ -3134,8 +3299,8 @@ async function connect(argv, attempt, deps = {}) {
3134
3299
  );
3135
3300
  const t3Url = (flag(argv, "--t3-url") ?? DEFAULT_T3_URL).replace(/\/+$/, "");
3136
3301
  const harnessBin = (name) => process.platform === "win32" ? which(name) ?? name : name;
3137
- findLocalCodex(homedir5());
3138
- findLocalClaude(homedir5());
3302
+ findLocalCodex(homedir6());
3303
+ findLocalClaude(homedir6());
3139
3304
  const readCodex = deps.probes?.codex ?? (() => probeCodex(harnessBin("codex")));
3140
3305
  const readClaude = deps.probes?.claude ?? (() => probeClaude(harnessBin("claude")));
3141
3306
  const found = await detect(
@@ -3150,10 +3315,10 @@ async function connect(argv, attempt, deps = {}) {
3150
3315
  const machine = !deps.probes;
3151
3316
  const terminal = deps.terminal ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
3152
3317
  const current = await prepareAgents(found, forced, workstation, {
3153
- chatGptApp: deps.chatGptApp ?? (() => machine && hasChatGptApp(homedir5())),
3318
+ chatGptApp: deps.chatGptApp ?? (() => machine && hasChatGptApp(homedir6())),
3154
3319
  codexHostMissing: deps.codexHostMissing ?? (() => machine && codexHostMissing(which("codex"))),
3155
- installCodex: deps.installCodex ?? (async () => machine && installCodex(homedir5())),
3156
- installClaude: deps.installClaude ?? (async () => machine && installClaude(homedir5())),
3320
+ installCodex: deps.installCodex ?? (async () => machine && installCodex(homedir6())),
3321
+ installClaude: deps.installClaude ?? (async () => machine && installClaude(homedir6())),
3157
3322
  readCodex,
3158
3323
  readClaude,
3159
3324
  updateClaude: deps.updateClaude ?? updateClaude,
@@ -3322,13 +3487,13 @@ var WINGET_UPDATE = [
3322
3487
  "--accept-source-agreements",
3323
3488
  "--accept-package-agreements"
3324
3489
  ];
3325
- async function updateClaude(run = runShown2, probe = probeClaude) {
3326
- const update = run(["claude", "update"], false);
3490
+ async function updateClaude(run2 = runShown2, probe = probeClaude) {
3491
+ const update = run2(["claude", "update"], false);
3327
3492
  if (WINGET_MANAGED.test(update.output)) {
3328
3493
  out(
3329
3494
  `${bold("Cloop machine")} winget installed Claude Code, so connect updates it with winget.`
3330
3495
  );
3331
- if (run(WINGET_UPDATE, true).status !== 0) return null;
3496
+ if (run2(WINGET_UPDATE, true).status !== 0) return null;
3332
3497
  } else {
3333
3498
  process.stdout.write(update.output);
3334
3499
  if (update.status !== 0) return null;
@@ -3396,6 +3561,7 @@ export {
3396
3561
  DEFAULT_FALLBACK_MODEL,
3397
3562
  claudeDialect,
3398
3563
  probeCodex,
3564
+ codexModels,
3399
3565
  codexDialect,
3400
3566
  DEFAULT_T3_URL,
3401
3567
  which,