@cloop/runner 0.3.8 → 0.3.10

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 (32) hide show
  1. package/dist/{box-HUVPOJZK.js → box-4DQFGS7E.js} +78 -46
  2. package/dist/{chunk-5FZAHWPX.js → chunk-6QXNXJ7C.js} +1 -1
  3. package/dist/{chunk-IKCGVBHA.js → chunk-D5UZW42X.js} +1 -0
  4. package/dist/{chunk-NYGELUTR.js → chunk-ES5BRAKJ.js} +1 -1
  5. package/dist/{chunk-E5CKL2Q3.js → chunk-EVIVOEJY.js} +1 -1
  6. package/dist/{chunk-ZILLDYL4.js → chunk-IJH4O27H.js} +8 -1
  7. package/dist/{chunk-3WD7S6VI.js → chunk-LPEDYXWI.js} +132 -73
  8. package/dist/{chunk-4MM5O7TV.js → chunk-NNVHI2C4.js} +1 -1
  9. package/dist/{chunk-NUU4GXGV.js → chunk-NTXQLEMQ.js} +1 -1
  10. package/dist/{chunk-EQTFHMUJ.js → chunk-UAMXZ6YX.js} +11 -10
  11. package/dist/{chunk-OODVBR3F.js → chunk-UST7TWCL.js} +3 -3
  12. package/dist/{chunk-3IP5XIPV.js → chunk-VVKUUNUJ.js} +4 -4
  13. package/dist/{chunk-GUPXSBOJ.js → chunk-W2BHZLOG.js} +355 -229
  14. package/dist/{chunk-WE4KRF7A.js → chunk-X4KNL76Q.js} +3 -3
  15. package/dist/{chunk-3TDL6X5T.js → chunk-XPWFSXPS.js} +1 -1
  16. package/dist/{connect-YJA2CS6L.js → connect-TH2W7C7U.js} +12 -10
  17. package/dist/disconnect-JDBXNTQP.js +30 -0
  18. package/dist/existing-runner-Z3GFUJXD.js +20 -0
  19. package/dist/{hook-activity-I7TV7YG7.js → hook-activity-GAJ5NABA.js} +4 -4
  20. package/dist/{hook-session-start-MFX6HR3W.js → hook-session-start-DJ6W2NCO.js} +3 -3
  21. package/dist/index.js +29 -19
  22. package/dist/{install-EMEZBBK7.js → install-WXKWNTAO.js} +1 -1
  23. package/dist/{login-RAZOAK6J.js → login-6UZCLDYL.js} +4 -4
  24. package/dist/{mcp-server-673BK6ER.js → mcp-server-RWLW6SJI.js} +13 -13
  25. package/dist/runner-TPPZAOE5.js +13 -0
  26. package/dist/{runs-RZL34AFT.js → runs-5UEAFWLJ.js} +3 -3
  27. package/dist/{statusline-KIE2H6EM.js → statusline-MITA5QJF.js} +3 -3
  28. package/dist/{takeover-V2IHVUAB.js → takeover-Z365HOFM.js} +7 -7
  29. package/dist/{use-ZP4SPNI6.js → use-JKRWT2TU.js} +15 -16
  30. package/package.json +1 -1
  31. package/dist/disconnect-S4GR7LCM.js +0 -28
  32. package/dist/runner-NZRNAFEP.js +0 -13
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- serveTakeovers
4
- } from "./chunk-3IP5XIPV.js";
5
- import "./chunk-3TDL6X5T.js";
6
2
  import {
7
3
  MeshSocket,
8
4
  defaultSocketFactory
9
- } from "./chunk-ZILLDYL4.js";
5
+ } from "./chunk-IJH4O27H.js";
6
+ import {
7
+ serveTakeovers
8
+ } from "./chunk-VVKUUNUJ.js";
9
+ import "./chunk-XPWFSXPS.js";
10
10
  import {
11
11
  DEFAULT_FALLBACK_MODEL,
12
12
  T3Client,
@@ -16,53 +16,61 @@ import {
16
16
  connectCommand,
17
17
  findNpx,
18
18
  installedService,
19
+ legacyStagingRunner,
19
20
  mintSession,
21
+ moveLegacyStagingRunner,
22
+ moveRunnerFiles,
23
+ pinExistingRunner,
20
24
  probeClaude,
21
25
  probeClaudePermissions,
22
26
  probeCodex,
23
27
  programFor,
24
28
  runBoxTool,
25
29
  runSteps,
30
+ serviceEnv,
31
+ stopService,
26
32
  systemServices,
27
- unitEnv,
28
33
  unitFor,
29
34
  which
30
- } from "./chunk-GUPXSBOJ.js";
35
+ } from "./chunk-W2BHZLOG.js";
31
36
  import {
32
37
  BoxWatch,
33
38
  lockThreadsFile,
34
39
  readRunnerState,
40
+ runnerStatePath,
35
41
  threadsFilePath,
36
42
  writeRunnerState
37
- } from "./chunk-EQTFHMUJ.js";
43
+ } from "./chunk-UAMXZ6YX.js";
38
44
  import {
39
45
  LocalDriver,
40
46
  T3Driver,
41
47
  isLocal,
42
48
  readRunnerConfig,
49
+ runnerDir,
50
+ runnerEnvironment,
51
+ runnerPath,
43
52
  showsOtherThreads,
44
53
  writeBoxConfig
45
- } from "./chunk-3WD7S6VI.js";
46
- import {
47
- olderThan
48
- } from "./chunk-UBXT5IDU.js";
54
+ } from "./chunk-LPEDYXWI.js";
49
55
  import {
50
56
  getMachine
51
- } from "./chunk-NUU4GXGV.js";
57
+ } from "./chunk-NTXQLEMQ.js";
52
58
  import "./chunk-VK6GV757.js";
59
+ import {
60
+ olderThan
61
+ } from "./chunk-UBXT5IDU.js";
53
62
  import "./chunk-R3CLO2FB.js";
54
- import "./chunk-OODVBR3F.js";
55
- import "./chunk-WE4KRF7A.js";
56
- import "./chunk-NYGELUTR.js";
63
+ import "./chunk-UST7TWCL.js";
64
+ import "./chunk-X4KNL76Q.js";
65
+ import "./chunk-ES5BRAKJ.js";
57
66
  import {
58
67
  VERSION
59
- } from "./chunk-4MM5O7TV.js";
68
+ } from "./chunk-NNVHI2C4.js";
60
69
  import {
61
- CONFIG_DIR,
62
70
  getMeshUrl,
63
71
  getToken,
64
72
  readCredentials
65
- } from "./chunk-IKCGVBHA.js";
73
+ } from "./chunk-D5UZW42X.js";
66
74
 
67
75
  // src/outside-sessions.ts
68
76
  import { createReadStream } from "fs";
@@ -140,9 +148,17 @@ async function listOutsideSessions(root = join(homedir(), ".claude", "projects")
140
148
 
141
149
  // src/update.ts
142
150
  import { execFile, spawn } from "child_process";
143
- import { closeSync, mkdirSync, openSync, readFileSync, renameSync, writeFileSync } from "fs";
151
+ import {
152
+ closeSync,
153
+ mkdirSync,
154
+ openSync,
155
+ readFileSync,
156
+ renameSync,
157
+ rmSync,
158
+ writeFileSync
159
+ } from "fs";
144
160
  import { homedir as homedir2 } from "os";
145
- import { join as join2 } from "path";
161
+ import { dirname, join as join2 } from "path";
146
162
  var REGISTRY_LATEST = "https://registry.npmjs.org/@cloop/runner/latest";
147
163
  var FIRST_CHECK_MS = 10 * 6e4;
148
164
  var CHECK_EVERY_MS = 6 * 36e5;
@@ -178,14 +194,14 @@ async function readLatest(get = fetch) {
178
194
  return null;
179
195
  }
180
196
  }
181
- function updateDir() {
182
- return process.env.CLOOP_UPDATE_DIR ?? join2(homedir2(), CONFIG_DIR);
197
+ function updateDir(env) {
198
+ return runnerPath(env, process.env.CLOOP_UPDATE_DIR, (dir) => dir);
183
199
  }
184
200
  function updateLogPath() {
185
201
  return join2(updateDir(), "update.log");
186
202
  }
187
- function statePath() {
188
- return join2(updateDir(), "update.json");
203
+ function statePath(env) {
204
+ return join2(updateDir(env), "update.json");
189
205
  }
190
206
  function readFailed() {
191
207
  try {
@@ -195,13 +211,13 @@ function readFailed() {
195
211
  return null;
196
212
  }
197
213
  }
198
- function recordFailed(version) {
214
+ function recordFailed(version, env) {
199
215
  try {
200
- mkdirSync(updateDir(), { recursive: true, mode: 448 });
201
- const temp = `${statePath()}.${process.pid}.tmp`;
216
+ mkdirSync(updateDir(env), { recursive: true, mode: 448 });
217
+ const temp = `${statePath(env)}.${process.pid}.tmp`;
202
218
  writeFileSync(temp, `${JSON.stringify({ failed: version })}
203
219
  `, { mode: 384 });
204
- renameSync(temp, statePath());
220
+ renameSync(temp, statePath(env));
205
221
  } catch (err) {
206
222
  log(`could not record ${version} as failed: ${err.code ?? err}`);
207
223
  }
@@ -224,6 +240,7 @@ function servicePath(kind) {
224
240
  return installedService({
225
241
  platform: process.platform,
226
242
  kind,
243
+ environment: runnerEnvironment(),
227
244
  home: homedir2(),
228
245
  uid: process.getuid?.() ?? 0,
229
246
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
@@ -323,34 +340,39 @@ function newDaemon(oldPid, read = readRunnerState) {
323
340
  return state && state.pid !== oldPid ? state : null;
324
341
  }
325
342
  async function adopt(from, kind, { services: given, script = process.argv[1] ?? "cloop", npx = findNpx() } = {}) {
326
- const oldPid = readRunnerState()?.pid;
327
- const services = given ?? {
328
- ...systemServices,
329
- awaitUp: (since2) => awaitDaemon(since2, () => newDaemon(oldPid), { timeoutMs: ADOPT_WAIT_MS })
343
+ const environment = runnerEnvironment();
344
+ const legacy = legacyStagingRunner();
345
+ const was = legacy ? "production" : environment;
346
+ const oldPid = readRunnerState(runnerStatePath(was))?.pid;
347
+ const services = {
348
+ ...given ?? systemServices,
349
+ awaitUp: given?.awaitUp ?? ((since2) => awaitDaemon(since2, () => newDaemon(oldPid), { timeoutMs: ADOPT_WAIT_MS }))
330
350
  };
331
351
  const refuse = (why2) => {
332
352
  log(`adopt ${from} -> ${VERSION} refused: ${why2}`);
333
- recordFailed(VERSION);
353
+ recordFailed(VERSION, was);
334
354
  return 1;
335
355
  };
336
356
  const program = programFor(script, process.execPath, npx, VERSION);
337
357
  if (typeof program === "string") return refuse(program);
338
- const unit = unitFor({
358
+ const where = {
339
359
  platform: services.platform,
340
360
  kind,
341
361
  home: homedir2(),
342
- program,
343
- env: unitEnv(process.env),
344
362
  uid: process.getuid?.() ?? 0,
345
363
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
346
- });
347
- const old = readText(unit.path);
348
- if (old === null) return refuse(`${unit.path} is missing`);
349
- if (!namesVersion(old, from)) return refuse(`${unit.path} does not run ${from}`);
364
+ };
365
+ const unit = unitFor({ ...where, environment, program, env: serviceEnv() });
366
+ const back = legacy ? unitFor({ ...where, environment: was, program, env: {} }) : unit;
367
+ const old = readText(back.path);
368
+ if (old === null) return refuse(`${back.path} is missing`);
369
+ if (!namesVersion(old, from)) return refuse(`${back.path} does not run ${from}`);
350
370
  const run2 = (command) => void services.run(command);
351
371
  const since = Date.now();
352
372
  let why;
353
373
  try {
374
+ if (legacy) await moveLegacyStagingRunner(services);
375
+ mkdirSync(dirname(unit.path), { recursive: true });
354
376
  writeFileSync(unit.path, unit.contents);
355
377
  await runSteps(unit.start, run2);
356
378
  if (await services.awaitUp(since)) {
@@ -362,13 +384,19 @@ async function adopt(from, kind, { services: given, script = process.argv[1] ??
362
384
  why = err instanceof Error ? err.message : String(err);
363
385
  }
364
386
  log(`adopt ${from} -> ${VERSION} failed: ${why}; putting ${from} back`);
365
- recordFailed(VERSION);
366
387
  try {
367
- writeFileSync(unit.path, old);
368
- await runSteps(unit.start, run2);
388
+ if (legacy) {
389
+ const added = installedService({ ...where, environment });
390
+ if (!await stopService(added, run2)) throw new Error(`${added.path} did not stop`);
391
+ rmSync(added.path, { force: true });
392
+ moveRunnerFiles(runnerDir(environment), runnerDir(was));
393
+ }
394
+ recordFailed(VERSION, was);
395
+ writeFileSync(back.path, old);
396
+ await runSteps(back.start, run2);
369
397
  } catch (err) {
370
398
  log(
371
- `ROLLBACK FAILED: could not restart ${from} from ${unit.path}: ${err instanceof Error ? err.message : String(err)}. Run cloop connect on this machine.`
399
+ `ROLLBACK FAILED: could not restart ${from} from ${back.path}: ${err instanceof Error ? err.message : String(err)}. Run cloop connect on this machine.`
372
400
  );
373
401
  return 2;
374
402
  }
@@ -453,7 +481,9 @@ async function run() {
453
481
  let cfg = readRunnerConfig();
454
482
  let token = cfg?.deviceToken ?? getToken();
455
483
  if (!token || !cfg) {
456
- out(`${red("\u2717")} Not connected. Run \`cloop connect\` first.`);
484
+ out(
485
+ `${red("\u2717")} ${legacyStagingRunner() ? "This staging runner is still in ~/.cloop from before 0.3.9. Run `cloop connect --staging` to move it to ~/.cloop/staging." : "Not connected. Run `cloop connect` first."}`
486
+ );
457
487
  process.exit(1);
458
488
  }
459
489
  if (!cfg.deviceToken) {
@@ -644,6 +674,7 @@ async function boxCommand(argv) {
644
674
  await connectCommand(["--driver", "t3", ...argv.slice(1)]);
645
675
  break;
646
676
  case "run":
677
+ pinExistingRunner();
647
678
  await run();
648
679
  break;
649
680
  case "adopt": {
@@ -653,6 +684,7 @@ async function boxCommand(argv) {
653
684
  console.error("Usage: cloop box adopt --from <version> --kind workstation|local");
654
685
  process.exit(1);
655
686
  }
687
+ pinExistingRunner();
656
688
  process.exit(await adopt(from, kind));
657
689
  break;
658
690
  }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR
4
- } from "./chunk-IKCGVBHA.js";
4
+ } from "./chunk-D5UZW42X.js";
5
5
 
6
6
  // src/inbox.ts
7
7
  import { appendFileSync, mkdirSync, readFileSync, rmSync } from "fs";
@@ -69,6 +69,7 @@ function getMeshUrl() {
69
69
 
70
70
  export {
71
71
  CONFIG_DIR,
72
+ PRODUCTION_ORIGIN,
72
73
  STAGING_ORIGIN,
73
74
  applyEnvironmentFlag,
74
75
  pinRunnerEnvironment,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getOrigin,
4
4
  getToken
5
- } from "./chunk-IKCGVBHA.js";
5
+ } from "./chunk-D5UZW42X.js";
6
6
 
7
7
  // src/api.ts
8
8
  var REAUTH_MESSAGE = "Cloop session expired or unauthenticated. Run `cloop login`.";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VK6GV757.js";
5
5
  import {
6
6
  CONFIG_DIR
7
- } from "./chunk-IKCGVBHA.js";
7
+ } from "./chunk-D5UZW42X.js";
8
8
 
9
9
  // src/session-state.ts
10
10
  import {
@@ -24,6 +24,8 @@ var MeshSocket = class {
24
24
  stopped = false;
25
25
  open = false;
26
26
  token;
27
+ /** The newest beat the caller gave, sent again each time the socket opens. */
28
+ presence = null;
27
29
  /** Connect again with a new device token, after a refusal of the old one. */
28
30
  restart(token) {
29
31
  this.token = token;
@@ -51,6 +53,7 @@ var MeshSocket = class {
51
53
  ws.on("open", () => {
52
54
  this.open = true;
53
55
  this.attempt = 0;
56
+ if (this.presence) this.send({ type: "presence", ...this.presence });
54
57
  this.opts.onOpen?.();
55
58
  });
56
59
  ws.on("message", (data) => this.handleMessage(data));
@@ -112,8 +115,12 @@ var MeshSocket = class {
112
115
  isConnected() {
113
116
  return this.open && this.ws?.readyState === WS_OPEN;
114
117
  }
115
- /** Send a presence beat over the socket. Returns false if not connected. */
118
+ /**
119
+ * Send a presence beat over the socket. Returns false if not connected;
120
+ * the socket still keeps the beat and sends it when it opens.
121
+ */
116
122
  sendPresence(body) {
123
+ this.presence = body;
117
124
  return this.send({ type: "presence", ...body });
118
125
  }
119
126
  /** Send any client frame. Returns false if not connected. */
@@ -3,8 +3,11 @@ import {
3
3
  stripControl
4
4
  } from "./chunk-VK6GV757.js";
5
5
  import {
6
- CONFIG_DIR
7
- } from "./chunk-IKCGVBHA.js";
6
+ CONFIG_DIR,
7
+ PRODUCTION_ORIGIN,
8
+ STAGING_ORIGIN,
9
+ getOrigin
10
+ } from "./chunk-D5UZW42X.js";
8
11
 
9
12
  // src/run-result.ts
10
13
  var RESULT_INSTRUCTION = [
@@ -40,7 +43,7 @@ function resultPrUrl(finalMessage) {
40
43
  const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
41
44
  return prs.at(-1) ?? null;
42
45
  }
43
- var SUMMARY_MAX = 500;
46
+ var SUMMARY_MAX = 4e3;
44
47
  var DOC_BODY_MAX = 8e3;
45
48
  function addressOutput(url) {
46
49
  const pr = url.match(/\/pull\/(\d+)$/);
@@ -108,7 +111,8 @@ function readRunResult(message) {
108
111
  result: {
109
112
  summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
110
113
  outputs: outputs.slice(0, 10),
111
- checks: checks.slice(0, 10)
114
+ checks: checks.slice(0, 10),
115
+ ...value.nothing_new === true ? { nothing_new: true } : {}
112
116
  },
113
117
  dropped: {
114
118
  outputs: list(value.outputs).length - outputs.length,
@@ -191,6 +195,55 @@ function handoverPrompt(prompt, from) {
191
195
  ${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
196
  }
193
197
 
198
+ // src/environment.ts
199
+ import { homedir } from "os";
200
+ import { join } from "path";
201
+ var ENVIRONMENTS = {
202
+ production: {
203
+ origin: PRODUCTION_ORIGIN,
204
+ dir: (home) => join(home, CONFIG_DIR),
205
+ suffix: "",
206
+ flag: ""
207
+ },
208
+ staging: {
209
+ origin: STAGING_ORIGIN,
210
+ dir: (home) => join(home, CONFIG_DIR, "staging"),
211
+ suffix: "staging",
212
+ flag: "--staging"
213
+ }
214
+ };
215
+ function environmentOf(origin) {
216
+ return origin.replace(/\/+$/, "") === ENVIRONMENTS.staging.origin ? "staging" : "production";
217
+ }
218
+ function runnerEnvironment() {
219
+ return environmentOf(getOrigin());
220
+ }
221
+ function runnerDir(env = runnerEnvironment(), home = homedir()) {
222
+ return ENVIRONMENTS[env].dir(home);
223
+ }
224
+ function runnerPath(env, override, inDir) {
225
+ const own = runnerEnvironment();
226
+ return override && (env ?? own) === own ? override : inDir(runnerDir(env ?? own));
227
+ }
228
+ function cloopCommand(env, args) {
229
+ return ["cloop", args, ENVIRONMENTS[env].flag].filter(Boolean).join(" ");
230
+ }
231
+ var KIND = {
232
+ workstation: { name: "box", task: "Cloop Box" },
233
+ local: { name: "runner", task: "Cloop Runner" }
234
+ };
235
+ function serviceIdentity(kind, env) {
236
+ const { suffix } = ENVIRONMENTS[env];
237
+ const { name, task } = KIND[kind];
238
+ const file = ["cloop", name, suffix].filter(Boolean).join("-");
239
+ return {
240
+ label: ["com.cloop", name, suffix].filter(Boolean).join("."),
241
+ unit: `${file}.service`,
242
+ task: suffix ? `${task} ${suffix[0]?.toUpperCase()}${suffix.slice(1)}` : task,
243
+ file
244
+ };
245
+ }
246
+
194
247
  // src/run-log.ts
195
248
  import {
196
249
  appendFileSync,
@@ -201,16 +254,16 @@ import {
201
254
  statSync,
202
255
  unlinkSync
203
256
  } from "fs";
204
- import { dirname, join } from "path";
257
+ import { dirname, join as join2 } from "path";
205
258
  var RUN_LOG_LINE_MAX = 500;
206
259
  var RUN_LOG_MAX_BYTES = 5 * 1024 * 1024;
207
260
  var RUN_LOG_KEEP_MS = 14 * 24 * 36e5;
208
261
  var SAFE_ID = /^[\w-]{1,100}$/;
209
262
  function runLogDir(runsFile) {
210
- return join(dirname(runsFile), "runs");
263
+ return join2(dirname(runsFile), "runs");
211
264
  }
212
265
  function runLogPath(dir, workId) {
213
- return SAFE_ID.test(workId) ? join(dir, `${workId}.log`) : null;
266
+ return SAFE_ID.test(workId) ? join2(dir, `${workId}.log`) : null;
214
267
  }
215
268
  var SECRETS = [
216
269
  [/-----BEGIN [A-Z ]*PRIVATE KEY-----.*/g, "[redacted private key]"],
@@ -280,7 +333,7 @@ function pruneRunLogs(dir, now = Date.now(), keepMs = RUN_LOG_KEEP_MS) {
280
333
  let removed = 0;
281
334
  for (const name of readdirSync(dir)) {
282
335
  if (!/\.log(\.1)?$/.test(name)) continue;
283
- const path = join(dir, name);
336
+ const path = join2(dir, name);
284
337
  try {
285
338
  if (statSync(path).mtimeMs < now - keepMs) {
286
339
  unlinkSync(path);
@@ -313,7 +366,7 @@ function stamp(now) {
313
366
  // src/t3-bin.ts
314
367
  import { execFileSync } from "child_process";
315
368
  import { existsSync, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
316
- import { join as join2 } from "path";
369
+ import { join as join3 } from "path";
317
370
  var CLEAN_ENV = () => ({
318
371
  HOME: process.env.HOME,
319
372
  USER: process.env.USER,
@@ -323,7 +376,7 @@ function defaultT3BinSources(home, stored) {
323
376
  return {
324
377
  env: process.env,
325
378
  home,
326
- appDirs: process.platform === "darwin" ? ["/Applications", join2(home, "Applications")] : [],
379
+ appDirs: process.platform === "darwin" ? ["/Applications", join3(home, "Applications")] : [],
327
380
  onPath: () => whichAll("t3"),
328
381
  ...stored ? { stored } : {}
329
382
  };
@@ -344,9 +397,9 @@ function bundleBinaries(appDir) {
344
397
  return [];
345
398
  }
346
399
  return bundles.flatMap((bundle) => {
347
- const root = join2(appDir, bundle);
400
+ const root = join3(appDir, bundle);
348
401
  try {
349
- return readdirSync2(root, { recursive: true }).filter((rel) => rel === "t3" || rel.endsWith("/t3")).map((rel) => join2(root, rel)).filter(isExecutable);
402
+ return readdirSync2(root, { recursive: true }).filter((rel) => rel === "t3" || rel.endsWith("/t3")).map((rel) => join3(root, rel)).filter(isExecutable);
350
403
  } catch {
351
404
  return [];
352
405
  }
@@ -355,8 +408,8 @@ function bundleBinaries(appDir) {
355
408
  function t3Candidates(serverVersion, sources) {
356
409
  const ordered = [
357
410
  sources.env.T3_BIN,
358
- join2(sources.home, ".t3", "runtime", "versions", serverVersion, "t3"),
359
- join2(sources.env.T3CODE_HOME || join2(sources.home, ".t3"), "bin", "t3"),
411
+ join3(sources.home, ".t3", "runtime", "versions", serverVersion, "t3"),
412
+ join3(sources.env.T3CODE_HOME || join3(sources.home, ".t3"), "bin", "t3"),
360
413
  ...sources.appDirs.flatMap(bundleBinaries),
361
414
  ...sources.onPath(),
362
415
  sources.stored
@@ -1257,54 +1310,11 @@ ${RESULT_INSTRUCTION}`
1257
1310
  }
1258
1311
  };
1259
1312
 
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
-
1303
1313
  // src/drivers/local.ts
1304
1314
  import { execFile as execFile2, execFileSync as execFileSync3, spawn } from "child_process";
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";
1315
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, writeFileSync } from "fs";
1316
+ import { hostname } from "os";
1317
+ import { basename, dirname as dirname2, join as join4 } from "path";
1308
1318
  import { createInterface } from "readline";
1309
1319
 
1310
1320
  // src/spawn-command.ts
@@ -1399,8 +1409,8 @@ function failedEnd(harness, run2) {
1399
1409
  const quoted = words.length > room ? `${words.slice(0, room - 1)}\u2026` : words;
1400
1410
  return { summary: `${lead}${quoted}"`, ...error };
1401
1411
  }
1402
- function localRunsFilePath() {
1403
- return process.env.CLOOP_LOCAL_RUNS_FILE ?? join4(homedir2(), CONFIG_DIR, "local-runs.json");
1412
+ function localRunsFilePath(env) {
1413
+ return runnerPath(env, process.env.CLOOP_LOCAL_RUNS_FILE, (dir) => join4(dir, "local-runs.json"));
1404
1414
  }
1405
1415
  function pickRepo(repos, repository) {
1406
1416
  if (!repository) {
@@ -2053,17 +2063,17 @@ ${RESULT_INSTRUCTION}`));
2053
2063
  return readRunRecords(this.file).filter((r) => !(r.end && Date.parse(r.end.at) < cutoff));
2054
2064
  }
2055
2065
  save() {
2056
- mkdirSync3(dirname3(this.file), { recursive: true, mode: 448 });
2066
+ mkdirSync2(dirname2(this.file), { recursive: true, mode: 448 });
2057
2067
  const tmp = `${this.file}.tmp`;
2058
- writeFileSync2(tmp, `${JSON.stringify([...this.runs.values()], null, 2)}
2068
+ writeFileSync(tmp, `${JSON.stringify([...this.runs.values()], null, 2)}
2059
2069
  `, { mode: 384 });
2060
- chmodSync3(tmp, 384);
2061
- renameSync3(tmp, this.file);
2070
+ chmodSync2(tmp, 384);
2071
+ renameSync2(tmp, this.file);
2062
2072
  }
2063
2073
  };
2064
2074
  function readRunRecords(file = localRunsFilePath()) {
2065
2075
  try {
2066
- const raw = JSON.parse(readFileSync2(file, "utf-8"));
2076
+ const raw = JSON.parse(readFileSync(file, "utf-8"));
2067
2077
  return Array.isArray(raw) ? raw.filter(
2068
2078
  (r) => typeof r?.work_id === "string" && typeof r?.repo === "string"
2069
2079
  ) : [];
@@ -2072,6 +2082,48 @@ function readRunRecords(file = localRunsFilePath()) {
2072
2082
  }
2073
2083
  }
2074
2084
 
2085
+ // src/runner-config.ts
2086
+ import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync as renameSync3, writeFileSync as writeFileSync2 } from "fs";
2087
+ import { dirname as dirname3, join as join5 } from "path";
2088
+ var BOX_FILE = "box.json";
2089
+ function boxPath(env = runnerEnvironment()) {
2090
+ return runnerPath(env, process.env.CLOOP_BOX_FILE, (dir) => join5(dir, BOX_FILE));
2091
+ }
2092
+ function isLocal(cfg) {
2093
+ return cfg.driver === "claude-code" || cfg.driver === "codex";
2094
+ }
2095
+ function showsOtherThreads(cfg) {
2096
+ return cfg?.hideOtherThreads !== true;
2097
+ }
2098
+ function otherThreadsChoice(argv, previous) {
2099
+ if (argv.includes("--hide-other-threads")) return true;
2100
+ if (argv.includes("--show-other-threads")) return false;
2101
+ return previous?.hideOtherThreads === true;
2102
+ }
2103
+ function readRunnerConfig(env) {
2104
+ let parsed;
2105
+ try {
2106
+ parsed = JSON.parse(readFileSync2(boxPath(env), "utf-8"));
2107
+ } catch {
2108
+ return null;
2109
+ }
2110
+ if (parsed.driver === "claude-code" || parsed.driver === "codex") {
2111
+ const ok = typeof parsed.deviceToken === "string" && typeof parsed.environmentId === "string" && typeof parsed.bin === "string" && Array.isArray(parsed.repos);
2112
+ return ok ? parsed : null;
2113
+ }
2114
+ if (typeof parsed.t3Url !== "string" || typeof parsed.token !== "string") return null;
2115
+ return parsed;
2116
+ }
2117
+ function writeBoxConfig(cfg) {
2118
+ const path = boxPath();
2119
+ mkdirSync3(dirname3(path), { recursive: true, mode: 448 });
2120
+ const temp = `${path}.${process.pid}.tmp`;
2121
+ writeFileSync2(temp, `${JSON.stringify(cfg, null, 2)}
2122
+ `, { mode: 384 });
2123
+ chmodSync3(temp, 384);
2124
+ renameSync3(temp, path);
2125
+ }
2126
+
2075
2127
  export {
2076
2128
  RUNTIME_MODES,
2077
2129
  BoxToolError,
@@ -2079,25 +2131,32 @@ export {
2079
2131
  questionLine,
2080
2132
  RUN_TEXT_MAX,
2081
2133
  isYes,
2082
- commandFor,
2134
+ ENVIRONMENTS,
2135
+ environmentOf,
2136
+ runnerEnvironment,
2137
+ runnerDir,
2138
+ runnerPath,
2139
+ cloopCommand,
2140
+ serviceIdentity,
2083
2141
  runLogDir,
2084
2142
  runLogPath,
2085
2143
  STOPPED_SUMMARY,
2086
2144
  isEndLogLine,
2145
+ commandFor,
2087
2146
  defaultT3BinSources,
2088
2147
  t3Candidates,
2089
2148
  pickT3Bin,
2090
2149
  t3BaseDirArgs,
2091
2150
  runT3,
2092
2151
  T3Driver,
2152
+ takeoverSummary,
2153
+ localRunsFilePath,
2154
+ LocalDriver,
2155
+ readRunRecords,
2093
2156
  boxPath,
2094
2157
  isLocal,
2095
2158
  showsOtherThreads,
2096
2159
  otherThreadsChoice,
2097
2160
  readRunnerConfig,
2098
- writeBoxConfig,
2099
- takeoverSummary,
2100
- localRunsFilePath,
2101
- LocalDriver,
2102
- readRunRecords
2161
+ writeBoxConfig
2103
2162
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.8" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.10" : "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
  api
4
- } from "./chunk-NYGELUTR.js";
4
+ } from "./chunk-ES5BRAKJ.js";
5
5
 
6
6
  // src/presence.ts
7
7
  import { execFileSync as execFileSync2 } from "child_process";