@cloop/runner 0.3.24 → 0.3.28

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.
Files changed (27) hide show
  1. package/README.md +2 -2
  2. package/dist/{box-OGT2NRPJ.js → box-AKPKKX5S.js} +234 -64
  3. package/dist/{chunk-YEO27QQP.js → chunk-365HFCQQ.js} +1 -1
  4. package/dist/{chunk-VH7XVQFJ.js → chunk-3I6NDELL.js} +1 -1
  5. package/dist/{chunk-NVESLEXA.js → chunk-3S2ECJTO.js} +275 -73
  6. package/dist/{chunk-MHKSBXUD.js → chunk-7GLIYYIB.js} +6 -6
  7. package/dist/{chunk-F4UQ2H5F.js → chunk-EGO3GOXI.js} +1 -1
  8. package/dist/{chunk-6F2ZM5H3.js → chunk-EKLBEP32.js} +2 -1
  9. package/dist/{chunk-PQPWITU3.js → chunk-ER5JS3RP.js} +232 -64
  10. package/dist/{chunk-IJH4O27H.js → chunk-KYGYU5G2.js} +65 -2
  11. package/dist/{chunk-UVB722OW.js → chunk-MVMKRRE2.js} +1 -1
  12. package/dist/{chunk-R3CLO2FB.js → chunk-PKIEWBR7.js} +2 -0
  13. package/dist/{chunk-IXG4H623.js → chunk-W4QJS3GR.js} +5 -5
  14. package/dist/{connect-7DUV7BMO.js → connect-OC5OH33U.js} +9 -8
  15. package/dist/{disconnect-IWGVQ2GZ.js → disconnect-6WIOMOCW.js} +9 -8
  16. package/dist/existing-runner-KN37YN7Y.js +21 -0
  17. package/dist/index.js +23 -23
  18. package/dist/{login-J3N7TYDI.js → login-YB3JV5WY.js} +2 -2
  19. package/dist/{mcp-server-HPMJRI6J.js → mcp-server-MD6X5AWJ.js} +5 -5
  20. package/dist/{read-permissions-SPOKGVLO.js → read-permissions-EGSGI4HL.js} +1 -1
  21. package/dist/{runner-TMR3BBL5.js → runner-VU7TITZM.js} +3 -3
  22. package/dist/{runs-S3QKEWHY.js → runs-LM2JFG3P.js} +2 -2
  23. package/dist/{statusline-UIG25UUX.js → statusline-2DBKYHJA.js} +1 -1
  24. package/dist/{takeover-3U5V2KXY.js → takeover-ANPJB6JG.js} +4 -4
  25. package/dist/{use-I2KUA64A.js → use-JIQY32FQ.js} +10 -9
  26. package/package.json +2 -2
  27. package/dist/existing-runner-4UYED6LY.js +0 -20
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ freshness
4
+ } from "./chunk-KYGYU5G2.js";
2
5
  import {
3
6
  readRunnerState,
4
7
  runnerStatePath,
5
8
  threadsFilePath
6
- } from "./chunk-6F2ZM5H3.js";
9
+ } from "./chunk-EKLBEP32.js";
7
10
  import {
8
11
  BoxToolError,
9
12
  CLOOP_THREAD_PREFIX,
10
13
  ENVIRONMENTS,
14
+ IMAGE_TYPES,
11
15
  MIN_PROTOCOL,
12
16
  RUNTIME_MODES,
13
17
  T3Client,
@@ -24,6 +28,7 @@ import {
24
28
  isYes,
25
29
  localRunsFilePath,
26
30
  otherThreadsChoice,
31
+ parseAttachments,
27
32
  pickT3Bin,
28
33
  questionLine,
29
34
  quoteWindowsArg,
@@ -38,7 +43,7 @@ import {
38
43
  windowsExecutable,
39
44
  windowsPowerShellEnv,
40
45
  writeBoxConfig
41
- } from "./chunk-NVESLEXA.js";
46
+ } from "./chunk-3S2ECJTO.js";
42
47
  import {
43
48
  getMachine,
44
49
  shortMachineName
@@ -49,24 +54,24 @@ import {
49
54
  claudeTooOld,
50
55
  codexTooOld,
51
56
  olderThan
52
- } from "./chunk-YEO27QQP.js";
57
+ } from "./chunk-365HFCQQ.js";
53
58
  import {
54
59
  READ_TOOLS,
55
60
  readOnlySettings
56
- } from "./chunk-R3CLO2FB.js";
61
+ } from "./chunk-PKIEWBR7.js";
57
62
  import {
58
63
  connectWebhook
59
- } from "./chunk-IXG4H623.js";
64
+ } from "./chunk-W4QJS3GR.js";
60
65
  import {
61
66
  ConnectFailure,
62
67
  connectReport,
63
68
  deviceLogin,
64
69
  newAttempt,
65
70
  sendConnectReport
66
- } from "./chunk-UVB722OW.js";
71
+ } from "./chunk-MVMKRRE2.js";
67
72
  import {
68
73
  VERSION
69
- } from "./chunk-VH7XVQFJ.js";
74
+ } from "./chunk-3I6NDELL.js";
70
75
  import {
71
76
  STAGING_ORIGIN,
72
77
  getOrigin,
@@ -253,14 +258,118 @@ function hasChatGptApp(home, platform = process.platform, env = process.env, fs
253
258
  return false;
254
259
  }
255
260
 
256
- // src/box-tools.ts
261
+ // src/runner-log.ts
262
+ var RUNNER_TOOLS = [
263
+ "status",
264
+ "threads.list",
265
+ "thread.read",
266
+ "thread.launch",
267
+ "thread.send",
268
+ "thread.interrupt",
269
+ "setup.share",
270
+ "diag"
271
+ ];
272
+ var RUNNER_ERRORS = [
273
+ "expired",
274
+ "bad_args",
275
+ "no_project",
276
+ "harness_unavailable",
277
+ "harness_signed_out",
278
+ "runtime_mode_unknown",
279
+ "already_finished",
280
+ "repo_busy",
281
+ "repo_unreachable",
282
+ "cannot_steer",
283
+ "cannot_share",
284
+ "t3_unauthorized",
285
+ "t3_unreachable",
286
+ "t3_error",
287
+ "harness_error",
288
+ "unknown_tool",
289
+ "registry_unreachable",
290
+ "fetch_failed",
291
+ "npx_missing",
292
+ "handover_failed"
293
+ ];
294
+ var HARNESS_IDS = ["claude-code", "codex", "claudeAgent", "opencode"];
257
295
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
296
+ var VERSION2 = /^\d{1,4}\.\d{1,4}\.\d{1,4}$/;
297
+ var oneOf = (list) => (value) => list.includes(value) ? value : void 0;
298
+ var toolCode = oneOf(RUNNER_TOOLS);
299
+ var uuid = (value) => typeof value === "string" && UUID.test(value) ? value : void 0;
300
+ var count = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e12 ? value : void 0;
301
+ var version = (value) => typeof value === "string" && VERSION2.test(value) ? value : void 0;
302
+ function errorCode(value) {
303
+ const code = typeof value === "string" && value.startsWith("unknown_tool:") ? "unknown_tool" : value;
304
+ return oneOf(RUNNER_ERRORS)(code);
305
+ }
306
+ function runnerLog(code, fields = {}) {
307
+ const shaped = {
308
+ call: uuid(fields.call),
309
+ work: uuid(fields.work),
310
+ tool: toolCode(fields.tool),
311
+ ms: count(fields.ms),
312
+ error: errorCode(fields.error),
313
+ n: count(fields.n),
314
+ ver: version(fields.ver)
315
+ };
316
+ const frame = { type: "log", code };
317
+ for (const [key, value] of Object.entries(shaped)) {
318
+ if (value !== void 0) Object.assign(frame, { [key]: value });
319
+ }
320
+ return frame;
321
+ }
322
+ function callOutcome(input) {
323
+ return {
324
+ at: new Date(input.at).toISOString(),
325
+ tool: toolCode(input.tool) ?? "other",
326
+ call: uuid(input.call) ?? null,
327
+ work: uuid(input.work) ?? null,
328
+ ms: count(Math.round(input.ms)) ?? 0,
329
+ ok: input.ok,
330
+ error: input.ok ? null : errorCode(input.error) ?? "other"
331
+ };
332
+ }
333
+ function outcomeLine(o) {
334
+ return `call tool=${o.tool} call=${o.call ?? "-"} work=${o.work ?? "-"} ms=${o.ms} ok=${o.ok}${o.error ? ` error=${o.error}` : ""}`;
335
+ }
336
+ var PLATFORMS = ["darwin", "linux", "win32", "freebsd", "openbsd", "aix", "sunos"];
337
+ var ARCHES = ["arm64", "x64", "arm", "ia32", "ppc64", "s390x"];
338
+ var iso = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && /^\d{4}-\d\d-\d\dT[\d:.]+Z$/.test(value) ? value : null;
339
+ function buildDiag(input) {
340
+ return {
341
+ version: version(input.version) ?? null,
342
+ platform: oneOf(PLATFORMS)(input.platform) ?? "other",
343
+ arch: oneOf(ARCHES)(input.arch) ?? "other",
344
+ uptime_ms: count(Math.round(input.uptimeMs)) ?? 0,
345
+ last_beat_at: iso(input.lastBeatAt),
346
+ last_wake: input.lastWake && iso(input.lastWake.woke_at) ? { slept_ms: count(input.lastWake.slept_ms) ?? 0, woke_at: input.lastWake.woke_at } : null,
347
+ harnesses: input.harnesses.map((h) => ({
348
+ id: oneOf(HARNESS_IDS)(h.id) ?? "other",
349
+ version: typeof h.version === "string" ? h.version.match(/\b\d{1,4}\.\d{1,4}\.\d{1,4}\b/)?.[0] ?? null : null,
350
+ ready: h.ready === true,
351
+ signed_in: h.signedIn === true
352
+ })),
353
+ update: {
354
+ checked_at: iso(input.update.checked_at),
355
+ latest: version(input.update.latest) ?? null,
356
+ error: errorCode(input.update.error) ?? null
357
+ },
358
+ unacked_results: count(input.unacked) ?? 0,
359
+ clock_offset_ms: typeof input.clockOffsetMs === "number" && Number.isInteger(input.clockOffsetMs) && Math.abs(input.clockOffsetMs) <= 1e12 ? input.clockOffsetMs : null,
360
+ // Already shaped: callOutcome is the only way to make one.
361
+ calls: input.calls
362
+ };
363
+ }
364
+
365
+ // src/box-tools.ts
366
+ var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
258
367
  function parseLaunchArgs(args) {
259
368
  const str = (v, max) => typeof v === "string" && v.trim() && v.length <= max ? v.trim() : void 0;
260
369
  const work_id = str(args.work_id, 36);
261
370
  const title = str(args.title, 200);
262
371
  const prompt = str(args.prompt, 1e5);
263
- if (!work_id || !UUID.test(work_id) || !title || !prompt) throw new BoxToolError("bad_args");
372
+ if (!work_id || !UUID2.test(work_id) || !title || !prompt) throw new BoxToolError("bad_args");
264
373
  const runtime_mode = str(args.runtime_mode, 40);
265
374
  if (runtime_mode && !RUNTIME_MODES.has(runtime_mode)) throw new BoxToolError("bad_args");
266
375
  return {
@@ -270,7 +379,8 @@ function parseLaunchArgs(args) {
270
379
  repository: str(args.repository, 200),
271
380
  harness: str(args.harness, 80),
272
381
  model: str(args.model, 120),
273
- runtime_mode
382
+ runtime_mode,
383
+ attachments: parseAttachments(args.attachments)
274
384
  };
275
385
  }
276
386
  function parseThreadId(args) {
@@ -280,7 +390,7 @@ function parseThreadId(args) {
280
390
  }
281
391
  function parseCommandId(args) {
282
392
  const id = args.command_id;
283
- if (typeof id !== "string" || !UUID.test(id)) throw new BoxToolError("bad_args");
393
+ if (typeof id !== "string" || !UUID2.test(id)) throw new BoxToolError("bad_args");
284
394
  return id;
285
395
  }
286
396
  function parseSendArgs(args) {
@@ -327,6 +437,8 @@ var BOX_TOOLS = {
327
437
  return result;
328
438
  },
329
439
  "thread.interrupt": ({ driver }, args) => driver.interrupt(parseThreadId(args), parseCommandId(args)),
440
+ // Codes, ids, versions and counts only (runner-log.ts), so ops can read it without the owner.
441
+ diag: async ({ diag }) => diag ? diag() : null,
330
442
  // Packs the skills before it answers, so an empty or oversized set is refused now; the upload runs on.
331
443
  async "setup.share"({ setup }) {
332
444
  if (!setup) throw new BoxToolError("cannot_share");
@@ -357,6 +469,37 @@ async function runBoxTool(ctx, tool, args) {
357
469
  };
358
470
  }
359
471
  }
472
+ async function answerCall(ctx, frame, io) {
473
+ const now = io.now ?? Date.now;
474
+ const started = now();
475
+ const offset = io.offset();
476
+ const fresh = freshness(frame.deadline, started, offset);
477
+ if (fresh !== "fresh") {
478
+ io.send(
479
+ runnerLog(fresh === "expired" ? "call_expired" : "call_late", {
480
+ call: frame.id,
481
+ tool: frame.tool,
482
+ work: frame.args.work_id,
483
+ ms: started + (offset ?? 0) - (frame.deadline ?? started)
484
+ })
485
+ );
486
+ }
487
+ const result = fresh === "expired" ? { ok: false, error: "expired" } : await runBoxTool(ctx, frame.tool, frame.args);
488
+ io.send({ type: "result", id: frame.id, ...result });
489
+ const outcome = callOutcome({
490
+ at: started,
491
+ tool: frame.tool,
492
+ call: frame.id,
493
+ work: frame.args.work_id,
494
+ ms: now() - started,
495
+ ok: result.ok,
496
+ error: result.ok ? void 0 : result.error
497
+ });
498
+ io.log(outcomeLine(outcome));
499
+ if (!result.ok && "detail" in result && result.detail)
500
+ io.log(`call_detail call=${frame.id} ${result.detail.slice(0, 300)}`);
501
+ return outcome;
502
+ }
360
503
 
361
504
  // src/device-revoke.ts
362
505
  function tokenGone(revoke) {
@@ -382,7 +525,8 @@ async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
382
525
 
383
526
  // src/drivers/claude-code.ts
384
527
  import { execFile } from "child_process";
385
- import { basename as basename2, isAbsolute, relative, resolve } from "path";
528
+ import { readFileSync } from "fs";
529
+ import { basename as basename2, extname, isAbsolute, relative, resolve } from "path";
386
530
  var SUBSCRIPTIONS = {
387
531
  max: "Claude Max",
388
532
  pro: "Claude Pro",
@@ -429,13 +573,13 @@ async function probeClaude(bin = "claude") {
429
573
  exec(bin, ["--version"]),
430
574
  exec(bin, ["auth", "status", "--json"])
431
575
  ]);
432
- const version = versionOut?.trim().split(/\s+/)[0];
433
- if (!version) return null;
576
+ const version2 = versionOut?.trim().split(/\s+/)[0];
577
+ if (!version2) return null;
434
578
  const { signedIn, account } = claudeAccount(auth);
435
579
  return {
436
580
  id: "claude-code",
437
581
  name: "Claude Code",
438
- version,
582
+ version: version2,
439
583
  ready: signedIn,
440
584
  signedIn,
441
585
  account,
@@ -525,10 +669,30 @@ function line(value) {
525
669
  return `${JSON.stringify(value)}
526
670
  `;
527
671
  }
528
- function userMessage(run, text, priority) {
672
+ function imageBlock(path) {
673
+ const type = IMAGE_TYPE_OF[extname(path).slice(1)];
674
+ try {
675
+ return type ? [
676
+ {
677
+ type: "image",
678
+ source: {
679
+ type: "base64",
680
+ media_type: type,
681
+ data: readFileSync(path).toString("base64")
682
+ }
683
+ }
684
+ ] : [];
685
+ } catch {
686
+ return [];
687
+ }
688
+ }
689
+ var IMAGE_TYPE_OF = Object.fromEntries(
690
+ Object.entries(IMAGE_TYPES).map(([type, ext]) => [ext, type])
691
+ );
692
+ function userMessage(run, text, priority, images = []) {
529
693
  return {
530
694
  type: "user",
531
- message: { role: "user", content: [{ type: "text", text }] },
695
+ message: { role: "user", content: [...images.flatMap(imageBlock), { type: "text", text }] },
532
696
  parent_tool_use_id: null,
533
697
  session_id: run.session_id ?? run.work_id,
534
698
  ...priority ? { priority } : {}
@@ -640,12 +804,12 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
640
804
  ...run.model ? ["--model", run.model] : fallback ? ["--fallback-model", fallback] : []
641
805
  ];
642
806
  },
643
- opening(run, prompt) {
807
+ opening(run, prompt, images = []) {
644
808
  return line({
645
809
  type: "control_request",
646
810
  request_id: "cloop-init",
647
811
  request: { subtype: "initialize" }
648
- }) + line(userMessage(run, prompt));
812
+ }) + line(userMessage(run, prompt, void 0, images));
649
813
  },
650
814
  userLine(run, text, mode) {
651
815
  return line(userMessage(run, text, mode === "steer" ? "now" : "next"));
@@ -695,16 +859,16 @@ function codexAccount(ok, out2) {
695
859
  return { signedIn: true, account: /chatgpt/i.test(out2) ? "ChatGPT" : "API key" };
696
860
  }
697
861
  async function probeCodex(bin = "codex") {
698
- const [version, status] = await Promise.all([
862
+ const [version2, status] = await Promise.all([
699
863
  exec2(bin, ["--version"]),
700
864
  exec2(bin, ["login", "status"])
701
865
  ]);
702
- if (!version.ok) return null;
866
+ if (!version2.ok) return null;
703
867
  const { signedIn, account } = codexAccount(status.ok, status.out);
704
868
  return {
705
869
  id: "codex",
706
870
  name: "Codex",
707
- version: version.out.trim().split(/\s+/).at(-1) ?? null,
871
+ version: version2.out.trim().split(/\s+/).at(-1) ?? null,
708
872
  ready: signedIn,
709
873
  signedIn,
710
874
  account,
@@ -784,10 +948,11 @@ function codexDialect(bin = "codex") {
784
948
  bin,
785
949
  capabilities: ["view", "start", "report"],
786
950
  keepsStdin: false,
787
- args(run, resume) {
951
+ args(run, resume, images = []) {
788
952
  const model = run.model ? ["--model", run.model] : [];
953
+ const attach = images.length ? [`--image=${images.join(",")}`] : [];
789
954
  const policy = ["--dangerously-bypass-approvals-and-sandbox", "--skip-git-repo-check"];
790
- return resume && run.session_id ? ["exec", ...policy, "resume", run.session_id, "--json", ...model, "-"] : ["exec", "--cd", run.repo, "--json", ...policy, ...model, "-"];
955
+ return resume && run.session_id ? ["exec", ...policy, "resume", run.session_id, "--json", ...model, "-"] : ["exec", "--cd", run.repo, "--json", ...policy, ...model, ...attach, "-"];
791
956
  },
792
957
  opening: (_run, prompt) => prompt,
793
958
  models: () => codexModels(bin),
@@ -805,7 +970,7 @@ import { join as join2 } from "path";
805
970
 
806
971
  // src/commands/disconnect.ts
807
972
  import { execFileSync } from "child_process";
808
- import { existsSync as existsSync3, readFileSync, rmSync } from "fs";
973
+ import { existsSync as existsSync3, readFileSync as readFileSync2, rmSync } from "fs";
809
974
  import { homedir } from "os";
810
975
  import { basename as basename4 } from "path";
811
976
 
@@ -822,7 +987,7 @@ function existingRunnerEnvironment() {
822
987
  const found = runnersOnThisComputer();
823
988
  return found.length === 1 && found[0] ? found[0] : "production";
824
989
  }
825
- var BOTH_RUNNERS_LINE = "This computer has a production runner and a staging runner. This acts on the production runner. Add --staging for the staging runner.";
990
+ var BOTH_RUNNERS_LINE = "This computer is a production machine and a staging machine. This acts on the production machine. Add --staging for the staging machine.";
826
991
  function pinExistingRunner() {
827
992
  const named = Boolean(process.env.CLOOP_ORIGIN);
828
993
  const environment = existingRunnerEnvironment();
@@ -835,7 +1000,7 @@ function pinExistingRunner() {
835
1000
 
836
1001
  // src/commands/disconnect.ts
837
1002
  function doneLine(env) {
838
- return `This computer is no longer a ${env} Cloop runner. To connect it again: ${["npx -y @cloop/runner@latest connect", ENVIRONMENTS[env].flag].filter(Boolean).join(" ")}`;
1003
+ return `This computer is no longer a ${env} Cloop machine. To connect it again: ${["npx -y @cloop/runner@latest connect", ENVIRONMENTS[env].flag].filter(Boolean).join(" ")}`;
839
1004
  }
840
1005
  function unitOrigin(contents) {
841
1006
  const plist = /<key>CLOOP_ORIGIN<\/key><string>([^<]+)<\/string>/.exec(contents)?.[1];
@@ -847,7 +1012,7 @@ function unitOrigin(contents) {
847
1012
  }
848
1013
  function disconnectPlan(opts) {
849
1014
  const exists = opts.exists ?? existsSync3;
850
- const read = opts.read ?? ((path) => readFileSync(path, "utf-8"));
1015
+ const read = opts.read ?? ((path) => readFileSync2(path, "utf-8"));
851
1016
  const installed = ["local", "workstation"].map((kind) => ({ kind, service: installedService({ ...opts, kind }) })).filter(({ service }) => exists(service.path));
852
1017
  const services = installed.map(({ service }) => service);
853
1018
  const fromUnit = services.map((service) => {
@@ -888,11 +1053,11 @@ function revokeLine(revoke, origin, box) {
888
1053
  case "already_revoked":
889
1054
  return [`Cloop (${origin}) had already revoked this computer.`];
890
1055
  case "no_device":
891
- return ["No runner device on this computer to revoke."];
1056
+ return ["No machine device on this computer to revoke."];
892
1057
  case "unknown_device":
893
1058
  return [
894
1059
  `Cloop at ${origin} never issued this computer's device token, so it belongs to the other environment.${keep}`,
895
- "Run `cloop disconnect --staging` for a staging runner, or `cloop disconnect` for production."
1060
+ "Run `cloop disconnect --staging` for a staging machine, or `cloop disconnect` for production."
896
1061
  ];
897
1062
  case "failed":
898
1063
  return [
@@ -913,7 +1078,7 @@ async function disconnect(plan, opts) {
913
1078
  const unit = plan.services.map((s) => basename4(s.path)).find((n) => n.startsWith("cloop-box"));
914
1079
  say(`This computer runs ${unit}, the ${env} Cloop box with T3 Code. Disconnect would:`);
915
1080
  for (const s of plan.services) say(` stop and remove ${s.path}`);
916
- if (plan.deviceToken) say(` revoke its runner device on Cloop (${plan.origin})`);
1081
+ if (plan.deviceToken) say(` revoke its machine device on Cloop (${plan.origin})`);
917
1082
  for (const f of [...plan.box ? [plan.box] : [], ...plan.files]) say(` delete ${f}`);
918
1083
  say(`Run \`${cloopCommand(env, "disconnect --yes")}\` to do this.`);
919
1084
  return 1;
@@ -1016,7 +1181,7 @@ async function moveLegacyStagingRunner(services) {
1016
1181
  for (const unit of units)
1017
1182
  if (!await stopService(unit, run))
1018
1183
  throw new Error(
1019
- `Could not stop the staging runner in ${unit.path}. Stop it with \`${unit.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run this again.`
1184
+ `Could not stop the staging machine in ${unit.path}. Stop it with \`${unit.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run this again.`
1020
1185
  );
1021
1186
  for (const unit of units) rmSync2(unit.path, { force: true });
1022
1187
  moveRunnerFiles(runnerDir("production"), runnerDir("staging"));
@@ -1024,7 +1189,7 @@ async function moveLegacyStagingRunner(services) {
1024
1189
  return true;
1025
1190
  }
1026
1191
  function movedLine(connecting) {
1027
- const line2 = "Moved the staging runner from ~/.cloop to ~/.cloop/staging, so a production runner can run beside it.";
1192
+ const line2 = "Moved the staging machine from ~/.cloop to ~/.cloop/staging, so a production machine can run beside it.";
1028
1193
  return connecting === "staging" ? line2 : `${line2} It is stopped. Start it again with: cloop connect --staging`;
1029
1194
  }
1030
1195
 
@@ -1393,7 +1558,7 @@ async function connectBox(steps) {
1393
1558
  steps.writeBoxConfig(cfg);
1394
1559
  return cfg;
1395
1560
  }
1396
- var NONE = "No coding agent found on this machine. Install Claude Code or Codex, sign in, then run `cloop connect` again.";
1561
+ var NONE = "No coding agent found on this machine. Install Claude Code or the ChatGPT desktop app, sign in, then run `cloop connect` again.";
1397
1562
  var SIGNED_OUT = {
1398
1563
  "claude-code": "Claude Code is installed but not signed in. Run `claude` once and sign in, then run `cloop connect` again.",
1399
1564
  codex: "Codex is installed but not signed in. Run `codex login`, then run `cloop connect` again."
@@ -1446,12 +1611,12 @@ function boxServiceInstalled() {
1446
1611
  }).path
1447
1612
  );
1448
1613
  }
1449
- var KIND_NAME = { workstation: "a Cloop box with T3 Code", local: "a Local runner" };
1614
+ var KIND_NAME = { workstation: "a Cloop box with T3 Code", local: "a local machine" };
1450
1615
  async function revokeReplaced(previous, kind, revoke, say) {
1451
1616
  if (!previous?.deviceToken || isLocal(previous) === (kind === "local")) return;
1452
1617
  const was = isLocal(previous) ? "local" : "workstation";
1453
1618
  say(
1454
- `${bold("Cloop runner")} This computer was ${KIND_NAME[was]}. It becomes ${KIND_NAME[kind]}, so its old device goes.`
1619
+ `${bold("Cloop machine")} This computer was ${KIND_NAME[was]}. It becomes ${KIND_NAME[kind]}, so its old device goes.`
1455
1620
  );
1456
1621
  say(
1457
1622
  tokenGone(await revoke(previous.deviceToken)) ? " Revoked the old device on Cloop." : " Could not revoke the old device. Press Disconnect on its card on the Threads page."
@@ -1531,11 +1696,11 @@ var endDaemonStep = (environment) => ({
1531
1696
  ],
1532
1697
  mayFail: true
1533
1698
  });
1534
- function programFor(script, node, npx, version) {
1699
+ function programFor(script, node, npx, version2) {
1535
1700
  if (!/[\\/]_npx[\\/]/.test(script)) return [node, script, "box", "run"];
1536
1701
  if (!npx)
1537
1702
  return "npx is not on PATH, so the service cannot run Cloop. Install it with `npm install -g @cloop/runner` and run `cloop connect` again.";
1538
- return [npx, "-y", `@cloop/runner@${version}`, "box", "run"];
1703
+ return [npx, "-y", `@cloop/runner@${version2}`, "box", "run"];
1539
1704
  }
1540
1705
  function findNpx() {
1541
1706
  const name = process.platform === "win32" ? "npx.cmd" : "npx";
@@ -1798,7 +1963,7 @@ function workFolderLine(found, home, argv, terminal) {
1798
1963
  }
1799
1964
  async function askRepos(found, home, ask, say) {
1800
1965
  const work = workFolder(home);
1801
- say(`${bold("Cloop runner")} This folder is not a git checkout. Recent ones:`);
1966
+ say(`${bold("Cloop machine")} This folder is not a git checkout. Recent ones:`);
1802
1967
  found.forEach((r, i) => say(` ${i + 1} ${r.label} ${dim(tilde(r.path, home))}`));
1803
1968
  for (; ; ) {
1804
1969
  const answer = (await ask(
@@ -1838,7 +2003,7 @@ async function reposFor(argv) {
1838
2003
  } finally {
1839
2004
  prompt.close();
1840
2005
  }
1841
- } else out(`${bold("Cloop runner")} ${workFolderLine(found, home, argv, terminal)}`);
2006
+ } else out(`${bold("Cloop machine")} ${workFolderLine(found, home, argv, terminal)}`);
1842
2007
  if (repos.some((r) => r.path === work.path)) mkdirSync2(work.path, { recursive: true });
1843
2008
  return repos;
1844
2009
  }
@@ -1877,9 +2042,9 @@ async function t3Answers(t3Url) {
1877
2042
  }
1878
2043
  }
1879
2044
  function harnessLine(h) {
1880
- const version = h.version ? ` ${h.version}` : "";
2045
+ const version2 = h.version ? ` ${h.version}` : "";
1881
2046
  const account = h.signedIn ? h.account ?? "signed in" : "signed out";
1882
- return `${h.name}${version}, ${account}${h.experimental ? " (experimental)" : ""}`;
2047
+ return `${h.name}${version2}, ${account}${h.experimental ? " (experimental)" : ""}`;
1883
2048
  }
1884
2049
  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))) {
1885
2050
  for (const step of steps) {
@@ -1958,7 +2123,7 @@ async function installService(kind, argv, attempt, services = systemServices) {
1958
2123
  try {
1959
2124
  if (existsSync5(unit.retire.path)) {
1960
2125
  out(
1961
- ` This computer has one ${environment} runner, so connect stops and removes ${unit.retire.path}.`
2126
+ ` This computer is already a ${environment} machine, so connect stops and removes ${unit.retire.path}.`
1962
2127
  );
1963
2128
  await runSteps(unit.retire.steps, run);
1964
2129
  rmSync3(unit.retire.path, { force: true });
@@ -1973,21 +2138,21 @@ async function installService(kind, argv, attempt, services = systemServices) {
1973
2138
  attempt.step = "first_connect";
1974
2139
  if (!await services.awaitUp(since)) {
1975
2140
  out(
1976
- `${red("\u2717")} ${unit.path} started, but the runner did not reach Cloop within 15 s. Its last log lines:`
2141
+ `${red("\u2717")} ${unit.path} started, but the machine did not reach Cloop within 15 s. Its last log lines:`
1977
2142
  );
1978
2143
  try {
1979
2144
  out(services.run(unit.tail));
1980
2145
  } catch {
1981
2146
  out(` (no log yet; run ${unit.logs})`);
1982
2147
  }
1983
- throw new ConnectFailure("first_connect_timeout", "the runner did not reach Cloop", true);
2148
+ throw new ConnectFailure("first_connect_timeout", "the machine did not reach Cloop", true);
1984
2149
  }
1985
2150
  if (services.platform === "linux") {
1986
2151
  const user = userInfo().username;
1987
2152
  const linger = ensureLinger(user, services.run);
1988
2153
  if (!linger.ok) {
1989
2154
  out(
1990
- `${red("\u2717")} The runner is up, but it stops when you log out of this machine. Run this, then run cloop connect again: ${bold(linger.command)}`
2155
+ `${red("\u2717")} The machine is up, but it stops when you log out of this computer. Run this, then run cloop connect again: ${bold(linger.command)}`
1991
2156
  );
1992
2157
  throw new ConnectFailure(
1993
2158
  "service_start_failed",
@@ -1996,10 +2161,10 @@ async function installService(kind, argv, attempt, services = systemServices) {
1996
2161
  );
1997
2162
  }
1998
2163
  if (linger.changed)
1999
- out(` Linger: turned on for ${user}, so the runner keeps running after you log out.`);
2164
+ out(` Linger: turned on for ${user}, so the machine keeps running after you log out.`);
2000
2165
  }
2001
2166
  out(` Service: ${unit.path}, started and connected. Logs: ${dim(unit.logs)}`);
2002
- out(`${bold("Cloop runner")} Connected the ${environment} runner.`);
2167
+ out(`${bold("Cloop machine")} Connected the ${environment} machine.`);
2003
2168
  }
2004
2169
  async function connectT3(argv, attempt, fallback, chosen, services) {
2005
2170
  const previous = readRunnerConfig();
@@ -2016,7 +2181,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
2016
2181
  readEnvironment: async () => {
2017
2182
  const environment = await readEnvironment(t3Url);
2018
2183
  out(
2019
- `${bold("Cloop runner")} Connecting ${shortMachineName(environment.label)} (T3 ${environment.serverVersion}) to Cloop with @cloop/runner ${VERSION}.`
2184
+ `${bold("Cloop machine")} Connecting ${shortMachineName(environment.label)} (T3 ${environment.serverVersion}) to Cloop with @cloop/runner ${VERSION}.`
2020
2185
  );
2021
2186
  return environment;
2022
2187
  },
@@ -2067,7 +2232,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
2067
2232
  out
2068
2233
  );
2069
2234
  out(
2070
- `${bold("Cloop runner")} T3 ${cfg.label} paired with scope ${cfg.scope}, until ${cfg.expiresAt.slice(0, 10)}.`
2235
+ `${bold("Cloop machine")} T3 ${cfg.label} paired with scope ${cfg.scope}, until ${cfg.expiresAt.slice(0, 10)}.`
2071
2236
  );
2072
2237
  if (byLink)
2073
2238
  out(
@@ -2106,7 +2271,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
2106
2271
  version: `${harness.name} ${harness.version ?? ""}`.trim()
2107
2272
  };
2108
2273
  out(
2109
- `${bold("Cloop runner")} Connecting ${deviceName} as a Local runner with ${harnessLine(harness)}, using @cloop/runner ${VERSION}.`
2274
+ `${bold("Cloop machine")} Connecting ${deviceName} as a local machine with ${harnessLine(harness)}, using @cloop/runner ${VERSION}.`
2110
2275
  );
2111
2276
  attempt.step = "login";
2112
2277
  const deviceToken = await deviceLogin({ origin: getOrigin(), deviceName, device });
@@ -2135,7 +2300,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
2135
2300
  (h) => Boolean(h) && h !== harness
2136
2301
  );
2137
2302
  out(
2138
- `${bold("Cloop runner")} ${deviceName} is a Local runner: ${[harness, ...others].map(harnessLine).join("; ")}.`
2303
+ `${bold("Cloop machine")} ${deviceName} is a local machine: ${[harness, ...others].map(harnessLine).join("; ")}.`
2139
2304
  );
2140
2305
  out(` Folders: ${repos.map((r) => `${r.label} (${r.path})`).join(", ")}`);
2141
2306
  out(
@@ -2176,7 +2341,7 @@ async function connect(argv, attempt, deps = {}) {
2176
2341
  const forced = named ?? rememberedDriver(previous);
2177
2342
  if (forced && !named)
2178
2343
  out(
2179
- `${bold("Cloop runner")} This machine runs Cloop work in ${DRIVER_NAME[forced]}, as you chose. Change it with: cloop use <t3|claude-code|codex>`
2344
+ `${bold("Cloop machine")} This machine runs Cloop work in ${DRIVER_NAME[forced]}, as you chose. Change it with: cloop use <t3|claude-code|codex>`
2180
2345
  );
2181
2346
  const fallback = flag(argv, "--fallback-model");
2182
2347
  if (fallback !== void 0 && !MODEL_LIST.test(fallback))
@@ -2225,7 +2390,7 @@ async function connect(argv, attempt, deps = {}) {
2225
2390
  t3: () => connectT3(argv, attempt, local ? HARNESS_NAME[local] : null, forced, deps.services),
2226
2391
  local: (driver) => connectLocal(driver, current, argv, attempt, forced, deps.services),
2227
2392
  fallback: () => fallbackDriver(current, forced, workstation),
2228
- say: (line2) => out(`${bold("Cloop runner")} ${line2}`)
2393
+ say: (line2) => out(`${bold("Cloop machine")} ${line2}`)
2229
2394
  });
2230
2395
  const harnesses = [];
2231
2396
  if (current.claude) harnesses.push({ harness: "claude-code", bin: harnessBin("claude") });
@@ -2237,7 +2402,7 @@ var MCP_STEP_MS = 6 * 6e4;
2237
2402
  async function addCloopMcpLast(found, attempt, mcp, terminal) {
2238
2403
  if (!found.length) return;
2239
2404
  const server = mcpServer(runnerEnvironment());
2240
- const say = (line2) => out(`${bold("Cloop runner")} ${line2}`);
2405
+ const say = (line2) => out(`${bold("Cloop machine")} ${line2}`);
2241
2406
  const left = new Set(found.map(({ harness }) => harness));
2242
2407
  const byHand = () => [...left].flatMap((harness) => mcpByHand(harness, server)).join(", then: ");
2243
2408
  let late = false;
@@ -2252,7 +2417,7 @@ async function addCloopMcpLast(found, attempt, mcp, terminal) {
2252
2417
  `[runner:mcp] harness=${harness} registered=${result.registered} signed_in=${result.signedIn} reason=${result.reason ?? "none"}`
2253
2418
  );
2254
2419
  out(
2255
- result.registered ? `${bold("Cloop runner")} ${mcpLine(result)}` : `${red("\u2717")} ${mcpLine(result)}`
2420
+ result.registered ? `${bold("Cloop machine")} ${mcpLine(result)}` : `${red("\u2717")} ${mcpLine(result)}`
2256
2421
  );
2257
2422
  }
2258
2423
  })();
@@ -2279,7 +2444,7 @@ async function addCloopMcpLast(found, attempt, mcp, terminal) {
2279
2444
  async function prepareAgents(found, forced, workstation, deps) {
2280
2445
  if (workstation || forced === "t3") return found;
2281
2446
  let current = found;
2282
- const say = (line2) => out(`${bold("Cloop runner")} ${line2}`);
2447
+ const say = (line2) => out(`${bold("Cloop machine")} ${line2}`);
2283
2448
  const chatGptApp = forced !== "claude-code" && deps.chatGptApp();
2284
2449
  const getCodex = async (why, reason) => {
2285
2450
  say(`${why} Installing the latest Codex from ${CODEX_RELEASES}.`);
@@ -2351,17 +2516,17 @@ function signInClaude(bin) {
2351
2516
  return runShown2([bin, "auth", "login"], true).status === 0 ? probeClaude(bin) : Promise.resolve(null);
2352
2517
  }
2353
2518
  async function claudeAtFloor(found, forced, update) {
2354
- const version = found.claude?.version;
2519
+ const version2 = found.claude?.version;
2355
2520
  const codex = forced === "codex" || !forced && !found.claude?.signedIn && Boolean(found.codex?.signedIn);
2356
- if (!version || codex || !olderThan(version, CLAUDE_FLOOR)) return found;
2357
- out(`${bold("Cloop runner")} ${claudeTooOld(version)} Updating it.`);
2521
+ if (!version2 || codex || !olderThan(version2, CLAUDE_FLOOR)) return found;
2522
+ out(`${bold("Cloop machine")} ${claudeTooOld(version2)} Updating it.`);
2358
2523
  const claude = await update();
2359
2524
  if (!claude?.version || olderThan(claude.version, CLAUDE_FLOOR))
2360
2525
  throw new ConnectFailure(
2361
2526
  "harness_outdated",
2362
2527
  "Claude Code did not update. Run `claude update`, then run `cloop connect` again."
2363
2528
  );
2364
- out(`${bold("Cloop runner")} Claude Code updated to ${claude.version}.`);
2529
+ out(`${bold("Cloop machine")} Claude Code updated to ${claude.version}.`);
2365
2530
  return { ...found, claude };
2366
2531
  }
2367
2532
  var WINGET_MANAGED = /winget upgrade Anthropic\.ClaudeCode/;
@@ -2378,7 +2543,7 @@ async function updateClaude(run = runShown2, probe = probeClaude) {
2378
2543
  const update = run(["claude", "update"], false);
2379
2544
  if (WINGET_MANAGED.test(update.output)) {
2380
2545
  out(
2381
- `${bold("Cloop runner")} winget installed Claude Code, so connect updates it with winget.`
2546
+ `${bold("Cloop machine")} winget installed Claude Code, so connect updates it with winget.`
2382
2547
  );
2383
2548
  if (run(WINGET_UPDATE, true).status !== 0) return null;
2384
2549
  } else {
@@ -2409,7 +2574,7 @@ async function runConnect(argv, deps = {}) {
2409
2574
  attempt.step = "legacy_move";
2410
2575
  try {
2411
2576
  if (await moveLegacyStagingRunner(deps.services ?? systemServices))
2412
- out(`${bold("Cloop runner")} ${movedLine(environment)}`);
2577
+ out(`${bold("Cloop machine")} ${movedLine(environment)}`);
2413
2578
  } catch (err) {
2414
2579
  throw new ConnectFailure(
2415
2580
  "legacy_move_failed",
@@ -2440,7 +2605,10 @@ async function connectCommand(argv) {
2440
2605
  }
2441
2606
 
2442
2607
  export {
2443
- runBoxTool,
2608
+ runnerLog,
2609
+ buildDiag,
2610
+ classifyError,
2611
+ answerCall,
2444
2612
  SUBSCRIPTIONS,
2445
2613
  probeClaudePermissions,
2446
2614
  probeClaude,