@cloop/runner 0.3.15 → 0.3.17

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.
@@ -5,13 +5,14 @@ import {
5
5
  } from "./chunk-IJH4O27H.js";
6
6
  import {
7
7
  serveTakeovers
8
- } from "./chunk-3J5FFRLN.js";
9
- import "./chunk-NMVZPTFM.js";
8
+ } from "./chunk-H3RGEJME.js";
9
+ import "./chunk-2DSMNE24.js";
10
10
  import {
11
11
  DEFAULT_FALLBACK_MODEL,
12
12
  T3Client,
13
13
  awaitDaemon,
14
14
  claudeDialect,
15
+ cmdWord,
15
16
  codexDialect,
16
17
  connectCommand,
17
18
  findNpx,
@@ -25,6 +26,7 @@ import {
25
26
  probeClaudePermissions,
26
27
  probeCodex,
27
28
  programFor,
29
+ psQuote,
28
30
  runBoxTool,
29
31
  runSteps,
30
32
  serviceEnv,
@@ -32,7 +34,7 @@ import {
32
34
  systemServices,
33
35
  unitFor,
34
36
  which
35
- } from "./chunk-RT5UZNMQ.js";
37
+ } from "./chunk-OHVU476O.js";
36
38
  import {
37
39
  BoxWatch,
38
40
  lockThreadsFile,
@@ -40,7 +42,7 @@ import {
40
42
  runnerStatePath,
41
43
  threadsFilePath,
42
44
  writeRunnerState
43
- } from "./chunk-BGXIAFPO.js";
45
+ } from "./chunk-K4TU7DBU.js";
44
46
  import {
45
47
  LocalDriver,
46
48
  T3Driver,
@@ -50,8 +52,9 @@ import {
50
52
  runnerEnvironment,
51
53
  runnerPath,
52
54
  showsOtherThreads,
55
+ windowsPowerShellEnv,
53
56
  writeBoxConfig
54
- } from "./chunk-B2ZI2UWS.js";
57
+ } from "./chunk-LXRCJTHL.js";
55
58
  import {
56
59
  getMachine
57
60
  } from "./chunk-NTXQLEMQ.js";
@@ -60,12 +63,12 @@ import {
60
63
  olderThan
61
64
  } from "./chunk-YEO27QQP.js";
62
65
  import "./chunk-R3CLO2FB.js";
63
- import "./chunk-NYJ6XMD4.js";
64
- import "./chunk-M4Y4YZ46.js";
66
+ import "./chunk-P46CX6Z7.js";
67
+ import "./chunk-44BZ2K5L.js";
65
68
  import "./chunk-ES5BRAKJ.js";
66
69
  import {
67
70
  VERSION
68
- } from "./chunk-BLSH7SNK.js";
71
+ } from "./chunk-QG5HVBJY.js";
69
72
  import {
70
73
  getMeshUrl,
71
74
  getToken,
@@ -222,23 +225,45 @@ function recordFailed(version, env) {
222
225
  log(`could not record ${version} as failed: ${err.code ?? err}`);
223
226
  }
224
227
  }
225
- function handOverCommand(platform, npx, to, kind) {
226
- const adopt2 = [
227
- npx,
228
- "-y",
229
- `@cloop/runner@${to}`,
230
- "box",
231
- "adopt",
232
- "--from",
233
- VERSION,
234
- "--kind",
235
- kind
236
- ];
228
+ function handOverCommand(platform, npx, to, kind, script = adoptScriptPath()) {
229
+ if (platform === "win32")
230
+ return [
231
+ "powershell",
232
+ "-NoProfile",
233
+ "-NonInteractive",
234
+ "-Command",
235
+ [
236
+ "$ErrorActionPreference = 'Stop'",
237
+ `Start-Process -WindowStyle Hidden -FilePath (Join-Path $env:WINDIR 'System32\\conhost.exe') -ArgumentList ('--headless ' + (Join-Path $env:WINDIR 'System32\\cmd.exe') + ' /d /c ' + [char]34 + ${psQuote(script)} + [char]34)`
238
+ ].join("; ")
239
+ ];
240
+ const adopt2 = adoptWords(npx, to, kind);
237
241
  return platform === "linux" ? ["systemd-run", "--user", "--scope", "--quiet", "--collect", "--", ...adopt2] : adopt2;
238
242
  }
239
- function servicePath(kind) {
243
+ var adoptWords = (npx, to, kind) => [
244
+ npx,
245
+ "-y",
246
+ `@cloop/runner@${to}`,
247
+ "box",
248
+ "adopt",
249
+ "--from",
250
+ VERSION,
251
+ "--kind",
252
+ kind
253
+ ];
254
+ function adoptScriptPath() {
255
+ return join2(updateDir(), "adopt.cmd");
256
+ }
257
+ function adoptScript(npx, to, kind, log3) {
258
+ return [
259
+ "@echo off",
260
+ `call ${adoptWords(npx, to, kind).map(cmdWord).join(" ")} >> ${cmdWord(log3)} 2>&1`,
261
+ ""
262
+ ].join("\r\n");
263
+ }
264
+ function servicePath(kind, platform) {
240
265
  return installedService({
241
- platform: process.platform,
266
+ platform,
242
267
  kind,
243
268
  environment: runnerEnvironment(),
244
269
  home: homedir2(),
@@ -266,11 +291,11 @@ function fetchVersion(npx, version) {
266
291
  );
267
292
  });
268
293
  }
269
- function selfUpdate(kind) {
294
+ function selfUpdate(kind, platform = process.platform) {
270
295
  let latest = null;
271
296
  let handing = false;
272
297
  let lastWhy = null;
273
- const canDetach = process.platform === "darwin" || process.platform === "linux" && which("systemd-run") !== null;
298
+ const canDetach = platform === "darwin" || platform === "win32" || platform === "linux" && which("systemd-run") !== null;
274
299
  const check = async () => {
275
300
  const read = await readLatest();
276
301
  if (!read || read === latest || !olderThan(VERSION, read) || read === readFailed()) return;
@@ -288,10 +313,12 @@ function selfUpdate(kind) {
288
313
  recordFailed(to);
289
314
  return;
290
315
  }
291
- const [command, ...args] = handOverCommand(process.platform, npx, to, kind);
316
+ const [command, ...args] = handOverCommand(platform, npx, to, kind);
292
317
  let fd;
293
318
  try {
294
319
  mkdirSync(updateDir(), { recursive: true, mode: 448 });
320
+ if (platform === "win32")
321
+ writeFileSync(adoptScriptPath(), adoptScript(npx, to, kind, updateLogPath()));
295
322
  fd = openSync(updateLogPath(), "a");
296
323
  } catch (err) {
297
324
  log(`could not open ${updateLogPath()}: ${err.code ?? err}`);
@@ -299,7 +326,11 @@ function selfUpdate(kind) {
299
326
  }
300
327
  handing = true;
301
328
  log(`handing over ${VERSION} -> ${to}; its log is ${updateLogPath()}`);
302
- const child = spawn(command, args, { detached: true, stdio: ["ignore", fd, fd] });
329
+ const child = spawn(
330
+ command,
331
+ args,
332
+ platform === "win32" ? { stdio: "ignore", windowsHide: true, env: windowsPowerShellEnv() } : { detached: true, stdio: ["ignore", fd, fd] }
333
+ );
303
334
  closeSync(fd);
304
335
  child.unref();
305
336
  const failed = (why) => {
@@ -309,8 +340,7 @@ function selfUpdate(kind) {
309
340
  };
310
341
  child.on("error", (err) => failed(err.message));
311
342
  child.on("exit", (code, signal) => {
312
- if (code === 0) handing = false;
313
- else failed(signal ? `signal ${signal}` : `exit ${code}`);
343
+ if (code !== 0) failed(signal ? `signal ${signal}` : `exit ${code}`);
314
344
  });
315
345
  };
316
346
  return {
@@ -319,7 +349,7 @@ function selfUpdate(kind) {
319
349
  const decision = updateDecision({
320
350
  current: VERSION,
321
351
  latest,
322
- unitText: readText(servicePath(kind)),
352
+ unitText: readText(servicePath(kind, platform)),
323
353
  running,
324
354
  inFlight,
325
355
  failed: readFailed(),
@@ -456,12 +486,15 @@ async function machineHarnesses(cfg) {
456
486
  }
457
487
  async function localDriver(cfg, name) {
458
488
  const bin = cfg.driver === name ? cfg.bin : void 0;
489
+ const claude = async (at) => claudeDialect(
490
+ at,
491
+ cfg.fallbackModels ?? DEFAULT_FALLBACK_MODEL,
492
+ cfg.askEverything,
493
+ await probeClaudePermissions(at)
494
+ );
459
495
  const driver = new LocalDriver({
460
- dialect: name === "claude-code" ? claudeDialect(bin, cfg.fallbackModels ?? DEFAULT_FALLBACK_MODEL, cfg.askEverything, {
461
- ...await probeClaudePermissions(bin)
462
- }) : codexDialect(bin),
463
- // Codex on the same machine takes Claude Code's runs while its account is at its usage limit.
464
- ...name === "claude-code" ? { fallbackHarness: codexDialect() } : {},
496
+ dialect: name === "claude-code" ? await claude(bin) : codexDialect(bin),
497
+ fallbackHarness: name === "claude-code" ? codexDialect() : await claude(),
465
498
  repos: cfg.repos,
466
499
  label: cfg.label,
467
500
  harnesses: () => machineHarnesses(cfg),
@@ -700,6 +733,7 @@ export {
700
733
  awaitNewDeviceToken,
701
734
  boxCommand,
702
735
  boxPresence,
736
+ localDriver,
703
737
  machineHarnesses,
704
738
  recordConnected,
705
739
  run,
@@ -6,9 +6,10 @@ import {
6
6
  localRunsFilePath,
7
7
  readRunRecords,
8
8
  readRunnerConfig,
9
+ runHarness,
9
10
  runLogDir,
10
11
  runLogPath
11
- } from "./chunk-B2ZI2UWS.js";
12
+ } from "./chunk-LXRCJTHL.js";
12
13
  import {
13
14
  sanitizeLabel,
14
15
  stripControl
@@ -214,6 +215,11 @@ async function sessionFolder(id, root = join(homedir(), ".claude", "projects"))
214
215
  }
215
216
  return null;
216
217
  }
218
+ function ownHarness(deps) {
219
+ if (deps.harness) return { driver: deps.harness, ...deps.bin ? { bin: deps.bin } : {} };
220
+ const cfg = readRunnerConfig();
221
+ return cfg && isLocal(cfg) ? cfg : null;
222
+ }
217
223
  async function resumeCommand(args, deps = {}) {
218
224
  const { file, out, err } = resolved(deps);
219
225
  const id = args[0];
@@ -221,10 +227,7 @@ async function resumeCommand(args, deps = {}) {
221
227
  err("Usage: cloop resume <id>. List the runs with: cloop runs");
222
228
  return 1;
223
229
  }
224
- const cfg = deps.harness ? null : readRunnerConfig();
225
- const local = cfg && isLocal(cfg) ? cfg : null;
226
- const harness = deps.harness ?? local?.driver ?? "claude-code";
227
- const bin = deps.bin ?? local?.bin ?? (harness === "codex" ? "codex" : "claude");
230
+ const own = ownHarness(deps);
228
231
  const spawn = deps.spawn ?? ((b, a, cwd) => spawnSync(b, a, { cwd, stdio: "inherit" }).status ?? 1);
229
232
  const records = readRunRecords(file);
230
233
  const found = findRun(records, id);
@@ -240,6 +243,7 @@ async function resumeCommand(args, deps = {}) {
240
243
  err(`The repository ${r.repo} is not on this machine any more.`);
241
244
  return 1;
242
245
  }
246
+ const { harness, bin } = runHarness(r, own);
243
247
  const session = r.session_id ?? (harness === "claude-code" ? r.work_id : null);
244
248
  if (!session) {
245
249
  err("This run has no session to resume.");
@@ -251,7 +255,7 @@ async function resumeCommand(args, deps = {}) {
251
255
  const folder = await sessionFolder(id, deps.claudeProjects);
252
256
  if (folder && existsSync(folder)) {
253
257
  out(`Opening the session in ${folder}`);
254
- return spawn(harness === "claude-code" ? bin : "claude", ["--resume", id], folder);
258
+ return spawn(runHarness({ harness: "claude-code" }, own).bin, ["--resume", id], folder);
255
259
  }
256
260
  err(found.error);
257
261
  return 1;
@@ -265,5 +269,6 @@ export {
265
269
  runsCommand,
266
270
  watchCommand,
267
271
  sessionFolder,
272
+ ownHarness,
268
273
  resumeCommand
269
274
  };
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-ES5BRAKJ.js";
6
6
  import {
7
7
  VERSION
8
- } from "./chunk-BLSH7SNK.js";
8
+ } from "./chunk-QG5HVBJY.js";
9
9
  import {
10
10
  getOrigin,
11
11
  readCredentials,
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- findRun
4
- } from "./chunk-NMVZPTFM.js";
3
+ findRun,
4
+ ownHarness
5
+ } from "./chunk-2DSMNE24.js";
5
6
  import {
6
7
  lockThreadsFile,
7
8
  threadsFilePath
8
- } from "./chunk-BGXIAFPO.js";
9
+ } from "./chunk-K4TU7DBU.js";
9
10
  import {
10
- isLocal,
11
11
  localRunsFilePath,
12
12
  readRunRecords,
13
- readRunnerConfig,
13
+ runHarness,
14
14
  takeoverSummary
15
- } from "./chunk-B2ZI2UWS.js";
15
+ } from "./chunk-LXRCJTHL.js";
16
16
  import {
17
17
  shortMachineName
18
18
  } from "./chunk-NTXQLEMQ.js";
@@ -168,10 +168,7 @@ async function takeoverCommand(args, deps = {}) {
168
168
  err(`This run has ended. Open it with: cloop resume ${short}`);
169
169
  return 1;
170
170
  }
171
- const cfg = deps.harness ? null : readRunnerConfig();
172
- const local = cfg && isLocal(cfg) ? cfg : null;
173
- const harness = deps.harness ?? local?.driver ?? "claude-code";
174
- const bin = deps.bin ?? local?.bin ?? (harness === "codex" ? "codex" : "claude");
171
+ const { harness, bin } = runHarness(run, ownHarness(deps));
175
172
  const session = run.session_id ?? (harness === "claude-code" ? run.work_id : null);
176
173
  if (!session) {
177
174
  err("This run has no session yet. Try again in a few seconds.");
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  RUN_TEXT_MAX,
4
4
  runnerPath
5
- } from "./chunk-B2ZI2UWS.js";
5
+ } from "./chunk-LXRCJTHL.js";
6
6
 
7
7
  // src/box-watch.ts
8
8
  import { randomUUID } from "crypto";
@@ -340,7 +340,8 @@ var RESULT_INSTRUCTION = [
340
340
  "```",
341
341
  "An output kind is one of: pr or link (title, url), draft (title, body, optional to, optional url), doc (title, optional url or body), file (title, path). A check outcome is passed, failed or skipped.",
342
342
  "A draft's body is the message itself, as the recipient will read it; if you saved it somewhere (a Gmail draft), put that link in url, never in body. A doc's body is the whole page in GitHub Markdown: headings, lists, bold and tables all show; a table suits one row per item. Give every product, page or source you mention as a full https link.",
343
- "List as outputs only what this run made. A PR or page you only read, checked or cited goes in the summary, never in outputs."
343
+ "List as outputs only what this run made. A PR or page you only read, checked or cited goes in the summary, never in outputs.",
344
+ "When the ask is to find, compare, summarise or research something, put the whole answer in a doc output with a body, so the owner has one page to read; the summary stays one or two sentences."
344
345
  ].join("\n");
345
346
  var text = (v, max) => typeof v === "string" && v.length <= max;
346
347
  var optionalText = (v, max) => v === void 0 || text(v, max);
@@ -1430,7 +1431,19 @@ var COMMANDS_KEPT = 50;
1430
1431
  var SUMMARY_MAX2 = 200;
1431
1432
  var HARNESS_NAMES = { "claude-code": "Claude Code", codex: "Codex" };
1432
1433
  var harnessName = (name) => HARNESS_NAMES[name] ?? name;
1433
- var movedLine = (from, to) => `${harnessName(from)} was at its usage limit, so ${harnessName(to)} did this run.`;
1434
+ function runHarness(run2, own) {
1435
+ const driver = own?.driver === "codex" ? "codex" : "claude-code";
1436
+ const harness = run2.harness ?? driver;
1437
+ const bin = harness === driver && own?.bin ? own.bin : harness === "codex" ? "codex" : "claude";
1438
+ return { harness, bin };
1439
+ }
1440
+ var MOVE_STATE = {
1441
+ limit: "at its usage limit",
1442
+ signed_out: "signed out here",
1443
+ missing: "not installed here"
1444
+ };
1445
+ var movedLine = (move, from, to) => `${harnessName(from)} ${move.at === "run" ? "was" : "is"} ${MOVE_STATE[move.reason]}, so ${harnessName(to)} did this run.`;
1446
+ var movingLine = (move, from, to) => `${harnessName(from)} is ${MOVE_STATE[move.reason]}, so I moved this to ${harnessName(to)}`;
1434
1447
  function failedEnd(harness, run2) {
1435
1448
  const said = run2.result?.text?.trim() || run2.lastText;
1436
1449
  const limited = HARNESS_LIMIT.test(run2.result?.text ?? "");
@@ -1442,7 +1455,7 @@ function failedEnd(harness, run2) {
1442
1455
  summary: `${opening}${run2.result ? "The run ended with an error." : `The run exited with ${run2.exit}.`}`,
1443
1456
  ...error
1444
1457
  };
1445
- const lead = `${opening}${HARNESS_NAMES[harness] ?? harness} said: "`;
1458
+ const lead = `${opening}${harnessName(harness)} said: "`;
1446
1459
  const room = SUMMARY_MAX2 - lead.length - 1;
1447
1460
  const quoted = words.length > room ? `${words.slice(0, room - 1)}\u2026` : words;
1448
1461
  return { summary: `${lead}${quoted}"`, ...error };
@@ -1643,11 +1656,7 @@ var LocalDriver = class {
1643
1656
  throw new BoxToolError("harness_unavailable");
1644
1657
  const repo = pickRepo(this.deps.repos, a.repository);
1645
1658
  this.refuseBusy(repo.path);
1646
- const moved = a.harness ? null : await this.heldOver(a);
1647
- const dialect = moved ?? own;
1648
- const harness = await dialect.probe();
1649
- if (!harness) throw new BoxToolError("harness_unavailable");
1650
- if (!harness.signedIn) throw new BoxToolError("harness_signed_out");
1659
+ const { dialect, moved } = await this.route(a);
1651
1660
  const head = await this.repo.head(repo.path);
1652
1661
  const concurrent = this.runs.get(a.work_id);
1653
1662
  if (concurrent)
@@ -1667,15 +1676,14 @@ var LocalDriver = class {
1667
1676
  ...a.model && !moved ? { model: a.model } : {},
1668
1677
  ...a.runtime_mode ? { runtime_mode: a.runtime_mode } : {},
1669
1678
  ...a.harness ? { harness_named: true } : {},
1670
- ...moved ? {
1671
- harness: moved.name,
1672
- switched: `${HARNESS_NAMES[own.name]} is at its usage limit, so ${HARNESS_NAMES[moved.name]} did this run.`
1673
- } : {},
1679
+ ...moved ? { harness: dialect.name, moved, switched: movedLine(moved, own.name, dialect.name) } : {},
1674
1680
  pid: null,
1675
1681
  started_at: new Date(this.now()).toISOString(),
1676
1682
  head_at_launch: head
1677
1683
  };
1678
1684
  this.runs.set(a.work_id, record);
1685
+ if (moved)
1686
+ this.log(`fallback work=${a.work_id} harness=${dialect.name} reason=${moved.reason}`);
1679
1687
  this.spawnRun(record, a.prompt, false);
1680
1688
  return {
1681
1689
  thread_id: a.work_id,
@@ -1817,17 +1825,34 @@ ${a.text}` : a.text;
1817
1825
  return fallback && r.harness === fallback.name ? fallback : this.deps.dialect;
1818
1826
  }
1819
1827
  /**
1820
- * The fallback harness, while the runner's own one is at an account-wide
1821
- * limit and the fallback is signed in. Codex asks nothing, so it takes only
1822
- * runs that would have had full access anyway.
1828
+ * The fallback harness, when it may carry this run. A move never gives a
1829
+ * run more access than its own harness would: a run that asks the owner
1830
+ * does not go to a harness that asks nothing.
1823
1831
  */
1824
- async heldOver(a) {
1825
- const fallback = this.deps.fallbackHarness;
1826
- if (!fallback || this.now() >= this.limitedUntil) return null;
1832
+ carrier(run2, own) {
1833
+ const to = this.deps.fallbackHarness;
1834
+ return to && (to.permission?.(run2) !== "full" || own === "full") ? to : null;
1835
+ }
1836
+ /**
1837
+ * A Task that names its harness stays on it. Otherwise a run starts on the
1838
+ * fallback while the runner's own harness is held at its limit, or when the
1839
+ * own harness is signed out or not installed and the fallback is signed in.
1840
+ */
1841
+ async route(a) {
1842
+ const own = this.deps.dialect;
1827
1843
  const mode = a.runtime_mode ? { runtime_mode: a.runtime_mode } : {};
1828
- if (this.deps.dialect.permission?.(mode) !== "full") return null;
1829
- const probe = await fallback.probe().catch(() => null);
1830
- return probe?.signedIn ? fallback : null;
1844
+ const to = a.harness ? null : this.carrier(mode, own.permission?.(mode));
1845
+ const ready = async () => Boolean(to && (await to.probe().catch(() => null))?.signedIn);
1846
+ if (to && this.now() < this.limitedUntil && await ready())
1847
+ return { dialect: to, moved: { reason: "limit", at: "launch" } };
1848
+ const harness = await own.probe();
1849
+ if (harness?.signedIn) return { dialect: own };
1850
+ if (to && await ready())
1851
+ return {
1852
+ dialect: to,
1853
+ moved: { reason: harness ? "signed_out" : "missing", at: "launch" }
1854
+ };
1855
+ throw new BoxToolError(harness ? "harness_signed_out" : "harness_unavailable");
1831
1856
  }
1832
1857
  /** One checkout, one run: two harnesses editing the same files at once would undo each other. */
1833
1858
  refuseBusy(repo) {
@@ -2037,7 +2062,7 @@ ${RESULT_INSTRUCTION}`));
2037
2062
  if (!next)
2038
2063
  this.log(`model work=${r.work_id} refused=${refused} next=none catalog=${listed.length}`);
2039
2064
  if (!next || this.stopping || r.end) return false;
2040
- const moved = r.harness ? movedLine(this.deps.dialect.name, r.harness) : null;
2065
+ const moved = r.harness && r.moved ? movedLine(r.moved, this.deps.dialect.name, r.harness) : null;
2041
2066
  r.refused = tried;
2042
2067
  r.model = next;
2043
2068
  r.session_id = null;
@@ -2049,7 +2074,7 @@ ${RESULT_INSTRUCTION}`));
2049
2074
  this.log(`model work=${r.work_id} refused=${refused} next=${next}`);
2050
2075
  this.spawnRun(
2051
2076
  r,
2052
- r.harness ? handoverPrompt(r.prompt, harnessName(this.deps.dialect.name)) : r.prompt,
2077
+ r.moved?.at === "run" ? handoverPrompt(r.prompt, harnessName(this.deps.dialect.name)) : r.prompt,
2053
2078
  false
2054
2079
  );
2055
2080
  return true;
@@ -2060,14 +2085,13 @@ ${RESULT_INSTRUCTION}`));
2060
2085
  * The session does not: the prompt goes again, with a note to read the
2061
2086
  * checkout first. A limit that names no model holds the account, so new
2062
2087
  * runs start on the fallback for LIMIT_HOLD_MS. It does not move a run
2063
- * whose Task named its harness, nor one without full access, because
2064
- * Codex asks nothing.
2088
+ * whose Task named its harness, nor one the fallback may not carry.
2065
2089
  */
2066
2090
  async moveHarness(r, said) {
2067
2091
  const to = this.deps.fallbackHarness;
2068
2092
  if (!to || r.harness) return false;
2069
2093
  if (!limitedModel(said)) this.limitedUntil = this.now() + LIMIT_HOLD_MS;
2070
- if (r.harness_named || r.used_permission !== "full" || !r.prompt) return false;
2094
+ if (r.harness_named || !this.carrier(r, r.used_permission) || !r.prompt) return false;
2071
2095
  this.recovering.add(r.work_id);
2072
2096
  try {
2073
2097
  const probe = await to.probe().catch(() => null);
@@ -2075,19 +2099,17 @@ ${RESULT_INSTRUCTION}`));
2075
2099
  } finally {
2076
2100
  this.recovering.delete(r.work_id);
2077
2101
  }
2078
- const from = harnessName(this.deps.dialect.name);
2079
- const name = harnessName(to.name);
2102
+ const from = this.deps.dialect.name;
2103
+ const move = { reason: "limit", at: "run" };
2080
2104
  r.harness = to.name;
2105
+ r.moved = move;
2081
2106
  r.session_id = null;
2082
2107
  r.model = void 0;
2083
- r.switched = movedLine(this.deps.dialect.name, to.name);
2108
+ r.switched = movedLine(move, from, to.name);
2084
2109
  this.save();
2085
- this.log(`fallback work=${r.work_id} harness=${to.name}`);
2086
- this.emit(r.work_id, {
2087
- kind: "progress",
2088
- summary: `${from} is at its usage limit, so I moved this to ${name}`
2089
- });
2090
- this.spawnRun(r, handoverPrompt(r.prompt, from), false);
2110
+ this.log(`fallback work=${r.work_id} harness=${to.name} reason=limit`);
2111
+ this.emit(r.work_id, { kind: "progress", summary: movingLine(move, from, to.name) });
2112
+ this.spawnRun(r, handoverPrompt(r.prompt, harnessName(from)), false);
2091
2113
  return true;
2092
2114
  }
2093
2115
  /**
@@ -2231,6 +2253,7 @@ export {
2231
2253
  runT3,
2232
2254
  T3Driver,
2233
2255
  takeoverSummary,
2256
+ runHarness,
2234
2257
  localRunsFilePath,
2235
2258
  LocalDriver,
2236
2259
  readRunRecords,
@@ -3,7 +3,7 @@ import {
3
3
  readRunnerState,
4
4
  runnerStatePath,
5
5
  threadsFilePath
6
- } from "./chunk-BGXIAFPO.js";
6
+ } from "./chunk-K4TU7DBU.js";
7
7
  import {
8
8
  BoxToolError,
9
9
  CLOOP_THREAD_PREFIX,
@@ -31,7 +31,7 @@ import {
31
31
  windowsExecutable,
32
32
  windowsPowerShellEnv,
33
33
  writeBoxConfig
34
- } from "./chunk-B2ZI2UWS.js";
34
+ } from "./chunk-LXRCJTHL.js";
35
35
  import {
36
36
  getMachine,
37
37
  shortMachineName
@@ -49,17 +49,17 @@ import {
49
49
  } from "./chunk-R3CLO2FB.js";
50
50
  import {
51
51
  connectWebhook
52
- } from "./chunk-NYJ6XMD4.js";
52
+ } from "./chunk-P46CX6Z7.js";
53
53
  import {
54
54
  ConnectFailure,
55
55
  connectReport,
56
56
  deviceLogin,
57
57
  newAttempt,
58
58
  sendConnectReport
59
- } from "./chunk-M4Y4YZ46.js";
59
+ } from "./chunk-44BZ2K5L.js";
60
60
  import {
61
61
  VERSION
62
- } from "./chunk-BLSH7SNK.js";
62
+ } from "./chunk-QG5HVBJY.js";
63
63
  import {
64
64
  STAGING_ORIGIN,
65
65
  getOrigin,
@@ -2287,6 +2287,7 @@ export {
2287
2287
  systemdWord,
2288
2288
  cmdValue,
2289
2289
  cmdWord,
2290
+ psQuote2 as psQuote,
2290
2291
  registerTaskScript,
2291
2292
  endDaemonScript,
2292
2293
  programFor,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-M4Y4YZ46.js";
5
+ } from "./chunk-44BZ2K5L.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.15" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.17" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -32,6 +32,7 @@ import {
32
32
  parsePicks,
33
33
  prepareAgents,
34
34
  programFor,
35
+ psQuote,
35
36
  registerTaskScript,
36
37
  rememberedDriver,
37
38
  rerunCommand,
@@ -51,17 +52,17 @@ import {
51
52
  which,
52
53
  workFolder,
53
54
  workFolderLine
54
- } from "./chunk-RT5UZNMQ.js";
55
- import "./chunk-BGXIAFPO.js";
56
- import "./chunk-B2ZI2UWS.js";
55
+ } from "./chunk-OHVU476O.js";
56
+ import "./chunk-K4TU7DBU.js";
57
+ import "./chunk-LXRCJTHL.js";
57
58
  import "./chunk-NTXQLEMQ.js";
58
59
  import "./chunk-VK6GV757.js";
59
60
  import "./chunk-YEO27QQP.js";
60
61
  import "./chunk-R3CLO2FB.js";
61
- import "./chunk-NYJ6XMD4.js";
62
- import "./chunk-M4Y4YZ46.js";
62
+ import "./chunk-P46CX6Z7.js";
63
+ import "./chunk-44BZ2K5L.js";
63
64
  import "./chunk-ES5BRAKJ.js";
64
- import "./chunk-BLSH7SNK.js";
65
+ import "./chunk-QG5HVBJY.js";
65
66
  import "./chunk-D5UZW42X.js";
66
67
  export {
67
68
  DEFAULT_T3_URL,
@@ -96,6 +97,7 @@ export {
96
97
  parsePicks,
97
98
  prepareAgents,
98
99
  programFor,
100
+ psQuote,
99
101
  registerTaskScript,
100
102
  rememberedDriver,
101
103
  rerunCommand,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-RT5UZNMQ.js";
11
- import "./chunk-BGXIAFPO.js";
12
- import "./chunk-B2ZI2UWS.js";
10
+ } from "./chunk-OHVU476O.js";
11
+ import "./chunk-K4TU7DBU.js";
12
+ import "./chunk-LXRCJTHL.js";
13
13
  import "./chunk-NTXQLEMQ.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-YEO27QQP.js";
16
16
  import "./chunk-R3CLO2FB.js";
17
- import "./chunk-NYJ6XMD4.js";
18
- import "./chunk-M4Y4YZ46.js";
17
+ import "./chunk-P46CX6Z7.js";
18
+ import "./chunk-44BZ2K5L.js";
19
19
  import "./chunk-ES5BRAKJ.js";
20
- import "./chunk-BLSH7SNK.js";
20
+ import "./chunk-QG5HVBJY.js";
21
21
  import "./chunk-D5UZW42X.js";
22
22
  export {
23
23
  disconnect,
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  existingRunnerEnvironment,
4
4
  pinExistingRunner
5
- } from "./chunk-RT5UZNMQ.js";
6
- import "./chunk-BGXIAFPO.js";
7
- import "./chunk-B2ZI2UWS.js";
5
+ } from "./chunk-OHVU476O.js";
6
+ import "./chunk-K4TU7DBU.js";
7
+ import "./chunk-LXRCJTHL.js";
8
8
  import "./chunk-NTXQLEMQ.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-YEO27QQP.js";
11
11
  import "./chunk-R3CLO2FB.js";
12
- import "./chunk-NYJ6XMD4.js";
13
- import "./chunk-M4Y4YZ46.js";
12
+ import "./chunk-P46CX6Z7.js";
13
+ import "./chunk-44BZ2K5L.js";
14
14
  import "./chunk-ES5BRAKJ.js";
15
- import "./chunk-BLSH7SNK.js";
15
+ import "./chunk-QG5HVBJY.js";
16
16
  import "./chunk-D5UZW42X.js";
17
17
  export {
18
18
  existingRunnerEnvironment,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-YEO27QQP.js";
5
5
  import {
6
6
  VERSION
7
- } from "./chunk-BLSH7SNK.js";
7
+ } from "./chunk-QG5HVBJY.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -65,7 +65,7 @@ Add --staging to any command to use Cloop staging instead of production.
65
65
  A production runner and a staging runner can run side by side on one machine.
66
66
  `;
67
67
  async function pinExistingRunner() {
68
- const { pinExistingRunner: pin } = await import("./existing-runner-RIW2IIHJ.js");
68
+ const { pinExistingRunner: pin } = await import("./existing-runner-WR6A3P3I.js");
69
69
  const { note } = pin();
70
70
  if (note) console.error(note);
71
71
  }
@@ -73,7 +73,7 @@ async function main() {
73
73
  switch (command) {
74
74
  case "login":
75
75
  case "auth": {
76
- const { loginCommand } = await import("./login-3BUGMP4K.js");
76
+ const { loginCommand } = await import("./login-OAYCNQ2O.js");
77
77
  await loginCommand(argv);
78
78
  break;
79
79
  }
@@ -83,61 +83,61 @@ async function main() {
83
83
  break;
84
84
  }
85
85
  case "serve": {
86
- const { startMcpServer } = await import("./mcp-server-6RK4RQVI.js");
86
+ const { startMcpServer } = await import("./mcp-server-XIJGOXBH.js");
87
87
  await startMcpServer();
88
88
  break;
89
89
  }
90
90
  case "statusline": {
91
- const { statuslineCommand } = await import("./statusline-R4YJZFUC.js");
91
+ const { statuslineCommand } = await import("./statusline-O7C5PR36.js");
92
92
  statuslineCommand();
93
93
  break;
94
94
  }
95
95
  case "connect": {
96
- const { connectCommand } = await import("./connect-7GU3JGWQ.js");
96
+ const { connectCommand } = await import("./connect-SO3X4ANL.js");
97
97
  await connectCommand(argv.slice(1));
98
98
  break;
99
99
  }
100
100
  case "use": {
101
- const { useCommand } = await import("./use-TIHWB3AS.js");
101
+ const { useCommand } = await import("./use-765ZZES6.js");
102
102
  process.exitCode = await useCommand(argv.slice(1));
103
103
  break;
104
104
  }
105
105
  case "disconnect": {
106
- const { disconnectCommand } = await import("./disconnect-UC2D3CHK.js");
106
+ const { disconnectCommand } = await import("./disconnect-QGO6KQTH.js");
107
107
  await disconnectCommand(argv.slice(1));
108
108
  break;
109
109
  }
110
110
  case "box": {
111
- const { boxCommand } = await import("./box-XFXJEHHZ.js");
111
+ const { boxCommand } = await import("./box-MCJBDKDN.js");
112
112
  await boxCommand(argv.slice(1));
113
113
  break;
114
114
  }
115
115
  case "runs": {
116
116
  await pinExistingRunner();
117
- const { runsCommand } = await import("./runs-4BKFXNM5.js");
117
+ const { runsCommand } = await import("./runs-VGVVNO4S.js");
118
118
  process.exitCode = runsCommand();
119
119
  break;
120
120
  }
121
121
  case "watch": {
122
122
  await pinExistingRunner();
123
- const { watchCommand } = await import("./runs-4BKFXNM5.js");
123
+ const { watchCommand } = await import("./runs-VGVVNO4S.js");
124
124
  process.exitCode = await watchCommand(argv.slice(1));
125
125
  break;
126
126
  }
127
127
  case "takeover": {
128
128
  await pinExistingRunner();
129
- const { takeoverCommand } = await import("./takeover-FCKTVLQY.js");
129
+ const { takeoverCommand } = await import("./takeover-E6FYRR4M.js");
130
130
  process.exitCode = await takeoverCommand(argv.slice(1));
131
131
  break;
132
132
  }
133
133
  case "resume": {
134
134
  await pinExistingRunner();
135
- const { resumeCommand } = await import("./runs-4BKFXNM5.js");
135
+ const { resumeCommand } = await import("./runs-VGVVNO4S.js");
136
136
  process.exitCode = await resumeCommand(argv.slice(1));
137
137
  break;
138
138
  }
139
139
  case "runner": {
140
- const { runnerCommand } = await import("./runner-ICPDXYOC.js");
140
+ const { runnerCommand } = await import("./runner-GDMWLS5G.js");
141
141
  await runnerCommand(argv.slice(1));
142
142
  break;
143
143
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-M4Y4YZ46.js";
6
+ } from "./chunk-44BZ2K5L.js";
7
7
  import "./chunk-ES5BRAKJ.js";
8
- import "./chunk-BLSH7SNK.js";
8
+ import "./chunk-QG5HVBJY.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  deviceLogin,
@@ -33,7 +33,7 @@ import {
33
33
  } from "./chunk-ES5BRAKJ.js";
34
34
  import {
35
35
  VERSION
36
- } from "./chunk-BLSH7SNK.js";
36
+ } from "./chunk-QG5HVBJY.js";
37
37
  import {
38
38
  getMeshUrl,
39
39
  getToken
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  connectWebhook,
4
4
  runnerCommand
5
- } from "./chunk-NYJ6XMD4.js";
6
- import "./chunk-M4Y4YZ46.js";
5
+ } from "./chunk-P46CX6Z7.js";
6
+ import "./chunk-44BZ2K5L.js";
7
7
  import "./chunk-ES5BRAKJ.js";
8
- import "./chunk-BLSH7SNK.js";
8
+ import "./chunk-QG5HVBJY.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  connectWebhook,
@@ -2,19 +2,21 @@
2
2
  import {
3
3
  findRun,
4
4
  lastLines,
5
+ ownHarness,
5
6
  recentRuns,
6
7
  resumeCommand,
7
8
  runState,
8
9
  runsCommand,
9
10
  sessionFolder,
10
11
  watchCommand
11
- } from "./chunk-NMVZPTFM.js";
12
- import "./chunk-B2ZI2UWS.js";
12
+ } from "./chunk-2DSMNE24.js";
13
+ import "./chunk-LXRCJTHL.js";
13
14
  import "./chunk-VK6GV757.js";
14
15
  import "./chunk-D5UZW42X.js";
15
16
  export {
16
17
  findRun,
17
18
  lastLines,
19
+ ownHarness,
18
20
  recentRuns,
19
21
  resumeCommand,
20
22
  runState,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-BLSH7SNK.js";
10
+ } from "./chunk-QG5HVBJY.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -9,10 +9,10 @@ import {
9
9
  takeoverDir,
10
10
  writeTakeoverReply,
11
11
  writeTakeoverRequest
12
- } from "./chunk-3J5FFRLN.js";
13
- import "./chunk-NMVZPTFM.js";
14
- import "./chunk-BGXIAFPO.js";
15
- import "./chunk-B2ZI2UWS.js";
12
+ } from "./chunk-H3RGEJME.js";
13
+ import "./chunk-2DSMNE24.js";
14
+ import "./chunk-K4TU7DBU.js";
15
+ import "./chunk-LXRCJTHL.js";
16
16
  import "./chunk-NTXQLEMQ.js";
17
17
  import "./chunk-VK6GV757.js";
18
18
  import "./chunk-ES5BRAKJ.js";
@@ -3,20 +3,20 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-RT5UZNMQ.js";
7
- import "./chunk-BGXIAFPO.js";
6
+ } from "./chunk-OHVU476O.js";
7
+ import "./chunk-K4TU7DBU.js";
8
8
  import {
9
9
  isLocal,
10
10
  readRunnerConfig
11
- } from "./chunk-B2ZI2UWS.js";
11
+ } from "./chunk-LXRCJTHL.js";
12
12
  import "./chunk-NTXQLEMQ.js";
13
13
  import "./chunk-VK6GV757.js";
14
14
  import "./chunk-YEO27QQP.js";
15
15
  import "./chunk-R3CLO2FB.js";
16
- import "./chunk-NYJ6XMD4.js";
17
- import "./chunk-M4Y4YZ46.js";
16
+ import "./chunk-P46CX6Z7.js";
17
+ import "./chunk-44BZ2K5L.js";
18
18
  import "./chunk-ES5BRAKJ.js";
19
- import "./chunk-BLSH7SNK.js";
19
+ import "./chunk-QG5HVBJY.js";
20
20
  import "./chunk-D5UZW42X.js";
21
21
 
22
22
  // src/commands/use.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloop/runner",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Make your machine and your agents Cloop runners: device login, the runner daemon, the Cloop MCP server, and Claude Code hooks.",