@cloop/runner 0.3.59 → 0.3.61

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.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  serveTakeovers
4
- } from "./chunk-GRYTOE6F.js";
5
- import "./chunk-WE3NUVJI.js";
4
+ } from "./chunk-CBUSTVCH.js";
5
+ import "./chunk-OWYY764F.js";
6
6
  import {
7
7
  CAPTURE_TICK_MS,
8
8
  DEFAULT_FALLBACK_MODEL,
@@ -39,7 +39,7 @@ import {
39
39
  systemServices,
40
40
  unitFor,
41
41
  which
42
- } from "./chunk-EHXAIGHI.js";
42
+ } from "./chunk-QLZYSUGR.js";
43
43
  import {
44
44
  MeshSocket,
45
45
  WAKE_TICK_MS,
@@ -57,12 +57,13 @@ import {
57
57
  runnerStatePath,
58
58
  threadsFilePath,
59
59
  writeRunnerState
60
- } from "./chunk-7GRP7ZX4.js";
60
+ } from "./chunk-TUGKGUV3.js";
61
61
  import {
62
62
  BackgroundReading,
63
63
  BoxToolError,
64
64
  HARNESS_LIMIT,
65
65
  HARNESS_STALE_MS,
66
+ IDLE_SETTLE_MS,
66
67
  LocalDriver,
67
68
  MACHINE_RESULT_INSTRUCTION,
68
69
  RUN_TEXT_MAX,
@@ -80,6 +81,7 @@ import {
80
81
  fetchImages,
81
82
  finalWords,
82
83
  hasResultBlock,
84
+ holdsForNextTurn,
83
85
  isHosted,
84
86
  isLocal,
85
87
  isT3,
@@ -107,20 +109,20 @@ import {
107
109
  utcWindow,
108
110
  windowsPowerShellEnv,
109
111
  writeBoxConfig
110
- } from "./chunk-5MZDMAY2.js";
112
+ } from "./chunk-PMH5WSQK.js";
111
113
  import "./chunk-VK6GV757.js";
112
114
  import {
113
115
  olderThan
114
116
  } from "./chunk-365HFCQQ.js";
115
117
  import "./chunk-PKIEWBR7.js";
116
- import "./chunk-HBBEFTXE.js";
117
- import "./chunk-BIECV55V.js";
118
+ import "./chunk-IUBEQ342.js";
119
+ import "./chunk-LZ4NZTA2.js";
118
120
  import {
119
121
  getMachine
120
122
  } from "./chunk-SBYSVZ7J.js";
121
123
  import {
122
124
  VERSION
123
- } from "./chunk-CJKE7ELD.js";
125
+ } from "./chunk-PTOPXY65.js";
124
126
  import {
125
127
  getMeshUrl,
126
128
  getOrigin,
@@ -171,7 +173,8 @@ function parseRecord(raw) {
171
173
  switch (r.kind) {
172
174
  case "receipt": {
173
175
  const receipt = parseReceipt(data);
174
- return receipt ? { sequence, kind: "receipt", receipt } : { sequence, kind: "other" };
176
+ const at = num(r.timestamp_ms);
177
+ return receipt ? { sequence, kind: "receipt", receipt, ...at === null ? {} : { at } } : { sequence, kind: "other" };
175
178
  }
176
179
  case "state": {
177
180
  const state = str(data.state);
@@ -359,7 +362,7 @@ function sseRecord(block) {
359
362
 
360
363
  // src/drivers/cloudroom.ts
361
364
  import { createHash } from "crypto";
362
- import { chmodSync, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, writeFileSync } from "fs";
365
+ import { chmodSync, mkdirSync as mkdirSync2, readFileSync, renameSync as renameSync2, rmSync as rmSync2, writeFileSync } from "fs";
363
366
  import { basename, dirname, join as join2 } from "path";
364
367
 
365
368
  // src/drivers/cloudroom-repos.ts
@@ -606,7 +609,8 @@ var NEW_FOLD = {
606
609
  after: 0,
607
610
  spoken: null,
608
611
  lastProgressAt: 0,
609
- ended: false
612
+ ended: false,
613
+ rest: null
610
614
  };
611
615
  var PENDING = /* @__PURE__ */ new Set(["accepted", "delivered", "running"]);
612
616
  var DEAD = /* @__PURE__ */ new Set(["closed", "failed", "process_lost"]);
@@ -633,11 +637,11 @@ function apply(fold, r) {
633
637
  case "receipt": {
634
638
  const { command, state, error, request_id, target } = r.receipt;
635
639
  if (command === "start") fold.start = { state, error };
636
- else if (command === "prompt") {
637
- const turn = fold.turns.find((t) => t.id === request_id);
640
+ else if (command === "prompt" || command === "auto") {
641
+ let turn = fold.turns.find((t) => t.id === request_id);
638
642
  if (turn) Object.assign(turn, { state, error });
639
- else
640
- fold.turns.push({
643
+ else {
644
+ turn = {
641
645
  id: request_id,
642
646
  state,
643
647
  error,
@@ -645,7 +649,10 @@ function apply(fold, r) {
645
649
  limited: false,
646
650
  item: null,
647
651
  text: ""
648
- });
652
+ };
653
+ fold.turns.push(turn);
654
+ }
655
+ if (!PENDING.has(state) && r.at !== void 0) turn.endedAt = r.at;
649
656
  } else if (command === "cancel" && (state === "accepted" || state === "completed")) {
650
657
  const turn = fold.turns.find((t) => t.id === target);
651
658
  if (turn) turn.cancelled = true;
@@ -699,7 +706,23 @@ function failedRun(harness, state, said, limited) {
699
706
  });
700
707
  return { kind: "failed", summary, ...error };
701
708
  }
702
- function runEnd(fold, harness) {
709
+ function resultOf(turn) {
710
+ return readRunResult(resultText(turn.text.trim(), turn.block)).result;
711
+ }
712
+ function holds(turn) {
713
+ return holdsForNextTurn({
714
+ completed: turn.state === "completed",
715
+ limited: turn.limited,
716
+ result: resultOf(turn)
717
+ });
718
+ }
719
+ function restingTurn(fold) {
720
+ const turns = fold.turns.filter((t) => !t.cancelled);
721
+ if (turns.some((t) => PENDING.has(t.state))) return void 0;
722
+ const last = turns.at(-1);
723
+ return last && holds(last) ? last : void 0;
724
+ }
725
+ function runEnd(fold, harness, now, idleMs = IDLE_SETTLE_MS) {
703
726
  const turns = fold.turns.filter((t) => !t.cancelled);
704
727
  if (turns.some((t) => PENDING.has(t.state)))
705
728
  return fold.session && DEAD.has(fold.session) ? failedRun(harness, fold.session, null, false) : null;
@@ -711,9 +734,13 @@ function runEnd(fold, harness) {
711
734
  return failedRun(harness, fold.start.state, fold.start.error, false);
712
735
  return null;
713
736
  }
737
+ if (holds(last)) {
738
+ const since = fold.rest?.turn === last.id ? fold.rest.at : now;
739
+ if (now - since < idleMs) return null;
740
+ }
714
741
  if (last.state === "completed" && !last.limited) {
715
742
  const text = last.text.trim();
716
- const result = readRunResult(resultText(text, last.block)).result;
743
+ const result = resultOf(last);
717
744
  const pr = resultPrUrl(text);
718
745
  const summary = finalWords(text).slice(0, RUN_TEXT_MAX);
719
746
  return {
@@ -735,11 +762,22 @@ function foldRecords(fold, records, opts) {
735
762
  said = apply(next, r) ?? said;
736
763
  }
737
764
  if (next.ended) return { state: next, events: [] };
738
- const end = runEnd(next, opts.harness);
765
+ const resting = restingTurn(next);
766
+ const rests = resting !== void 0 && next.rest?.turn !== resting.id;
767
+ if (!resting) next.rest = null;
768
+ else if (rests) next.rest = { turn: resting.id, at: resting.endedAt ?? opts.now };
769
+ const end = runEnd(next, opts.harness, opts.now, opts.idleMs);
739
770
  if (end) {
740
771
  next.ended = true;
741
772
  return { state: next, events: [end] };
742
773
  }
774
+ if (resting && rests) {
775
+ next.spoken = resting.text;
776
+ const clock2 = { lastProgressAt: next.lastProgressAt };
777
+ const summary2 = nextProgress(clock2, resting.text, opts.now, opts.progressMs, true);
778
+ next.lastProgressAt = clock2.lastProgressAt;
779
+ return { state: next, events: summary2 ? [{ kind: "progress", summary: summary2 }] : [] };
780
+ }
743
781
  if (!said || said.cancelled || !PENDING.has(said.state) || said.text === next.spoken)
744
782
  return { state: next, events: [] };
745
783
  next.spoken = said.text;
@@ -781,6 +819,7 @@ function unpreparedEnd(harness, err) {
781
819
  );
782
820
  return { kind: "failed", summary };
783
821
  }
822
+ var REST_LEASE_MARGIN_MS = 2 * 6e4;
784
823
  var sleep = (ms) => new Promise((resolve) => {
785
824
  const timer = setTimeout(resolve, ms);
786
825
  timer.unref?.();
@@ -897,6 +936,8 @@ var CloudroomDriver = class {
897
936
  kept;
898
937
  /** Runs looking for the next model, by thread. */
899
938
  moving = /* @__PURE__ */ new Set();
939
+ /** Runs that wait after a turn without a result, by thread: ends the run on a Stop. */
940
+ resting = /* @__PURE__ */ new Map();
900
941
  /** The account's models, best first, while CATALOG_MS lasts. */
901
942
  catalog = null;
902
943
  /** The run's last move off a refused model, if it moved. */
@@ -976,6 +1017,45 @@ var CloudroomDriver = class {
976
1017
  now() {
977
1018
  return this.deps.now?.() ?? Date.now();
978
1019
  }
1020
+ get idleMs() {
1021
+ return this.deps.idleMs ?? IDLE_SETTLE_MS;
1022
+ }
1023
+ /** A hold's step, to the mesh (runner-log HoldCode), by the run's work id. */
1024
+ holdLog(code, thread, ms) {
1025
+ const work = thread.startsWith(CLOOP_SESSION_PREFIX) ? thread.slice(CLOOP_SESSION_PREFIX.length) : null;
1026
+ this.deps.holdLog?.(code, work, ms);
1027
+ }
1028
+ /** Named after the thread, not the process: a restarted daemon writes or removes the same lease. */
1029
+ leaseFile(thread) {
1030
+ if (!this.deps.awakeDir) return null;
1031
+ const name = createHash("sha256").update(thread).digest("hex").slice(0, 12);
1032
+ return join2(this.deps.awakeDir, `cloop-hold-${name}.json`);
1033
+ }
1034
+ /** On a Cloop Box, a lease (cloop-box AwakeLease) keeps the box up until a held run is due to settle. */
1035
+ lease(thread, until) {
1036
+ const file = this.leaseFile(thread);
1037
+ if (!file || !this.deps.awakeDir) return;
1038
+ try {
1039
+ mkdirSync2(this.deps.awakeDir, { recursive: true });
1040
+ writeFileSync(file, JSON.stringify({ label: "held run", until }));
1041
+ } catch (err) {
1042
+ this.log(
1043
+ `awake lease not written thread=${thread} reason=${err instanceof Error ? err.message : "error"}`
1044
+ );
1045
+ this.holdLog("hold_unleased", thread);
1046
+ }
1047
+ }
1048
+ unlease(thread) {
1049
+ const file = this.leaseFile(thread);
1050
+ if (!file) return;
1051
+ try {
1052
+ rmSync2(file, { force: true });
1053
+ } catch (err) {
1054
+ this.log(
1055
+ `awake lease not removed thread=${thread} reason=${err instanceof Error ? err.message : "error"}`
1056
+ );
1057
+ }
1058
+ }
979
1059
  log(line) {
980
1060
  this.deps.log?.(line);
981
1061
  }
@@ -1059,7 +1139,7 @@ var CloudroomDriver = class {
1059
1139
  const id = this.carrier(thread);
1060
1140
  const session = await this.session(id);
1061
1141
  const fold = await this.history(id);
1062
- const found = runEnd(fold, this.harness);
1142
+ const found = runEnd(fold, this.harness, this.now(), this.idleMs);
1063
1143
  const switched = found?.error === "interrupted" ? null : this.movedOf(thread)?.switched;
1064
1144
  const end = found && switched ? opened(found, switched) : found;
1065
1145
  const last = fold.turns.filter((t) => !t.cancelled).at(-1);
@@ -1243,7 +1323,8 @@ var CloudroomDriver = class {
1243
1323
  if (s.receipts[steer]) return { delivered: "steer" };
1244
1324
  if (s.receipts[queue]) return { delivered: "queue" };
1245
1325
  const running = busy(s);
1246
- if (!running && !a.resume) throw new BoxToolError("already_finished");
1326
+ if (!running && !a.resume && !this.resting.has(a.thread_id))
1327
+ throw new BoxToolError("already_finished");
1247
1328
  const deliver = async () => {
1248
1329
  if (a.mode === "steer" && s.steer && s.current_request) {
1249
1330
  try {
@@ -1333,7 +1414,9 @@ ${line}` : line;
1333
1414
  this.log(`interrupt thread=${id} while moving model`);
1334
1415
  return { ok: true, was_running: true };
1335
1416
  }
1336
- return this.stopRun(this.carrier(id), commandId);
1417
+ const stopped = await this.stopRun(this.carrier(id), commandId);
1418
+ if (!stopped.was_running && this.resting.get(id)?.()) return { ok: true, was_running: true };
1419
+ return stopped;
1337
1420
  }
1338
1421
  async stopRun(id, commandId) {
1339
1422
  const s = await this.session(id);
@@ -1399,6 +1482,11 @@ ${line}` : line;
1399
1482
  * while a child works or a turn waits, and looks again every
1400
1483
  * CHILDREN_WAIT_MS in case a child ends without a reply.
1401
1484
  *
1485
+ * A turn that completes without a result block holds the run open (the
1486
+ * fold's `rest`): a new turn carries it on, a Stop ends it, and a timer
1487
+ * ticks the fold when idleMs of nothing has passed, so the run settles
1488
+ * with its last words although no record came.
1489
+ *
1402
1490
  * A run the account refused its model moves to a new session (moveModel)
1403
1491
  * and the watch follows that one under the same thread, from the run's
1404
1492
  * kept facts after a restart too.
@@ -1416,9 +1504,19 @@ ${line}` : line;
1416
1504
  let stopped = false;
1417
1505
  let live = null;
1418
1506
  let waits = 0;
1507
+ let ticking = null;
1508
+ let leased = false;
1509
+ const quiet = () => {
1510
+ if (ticking) clearTimeout(ticking.timer);
1511
+ ticking = null;
1512
+ this.resting.delete(id);
1513
+ if (leased) this.unlease(id);
1514
+ leased = false;
1515
+ };
1419
1516
  const stop = () => {
1420
1517
  stopped = true;
1421
1518
  live?.abort();
1519
+ quiet();
1422
1520
  };
1423
1521
  const end = async (event) => {
1424
1522
  const refused = event.kind === "failed" && !event.error ? refusedModel(event.summary) : null;
@@ -1443,25 +1541,62 @@ ${line}` : line;
1443
1541
  const wait = ++waits;
1444
1542
  await sleep(CHILDREN_WAIT_MS);
1445
1543
  if (stopped || fold.ended || wait !== waits) return;
1446
- const again = runEnd(fold, this.harness);
1544
+ const again = runEnd(fold, this.harness, this.now(), this.idleMs);
1447
1545
  if (!again) return;
1448
1546
  fold = { ...fold, ended: true };
1449
1547
  return end(again);
1450
1548
  }
1451
1549
  if (stopped) return;
1550
+ if (event.kind === "settled" && restingTurn(fold)) this.holdLog("hold_expired", id);
1452
1551
  stop();
1453
1552
  const told = await this.tidy(session, event);
1454
1553
  const switched = told.error === "interrupted" ? null : this.movedOf(id)?.switched;
1455
1554
  onEvent(switched ? opened(told, switched) : told);
1456
1555
  };
1457
- const take = (from, records) => {
1458
- if (stopped || from !== session || !records.length) return;
1556
+ const tick = () => {
1557
+ const rest = fold.ended ? null : fold.rest;
1558
+ if (ticking && ticking.turn === rest?.turn) return;
1559
+ if (ticking && fold.turns.at(-1)?.id !== ticking.turn) {
1560
+ this.log(`new turn thread=${id}; the run goes on`);
1561
+ this.holdLog("hold_carried", id);
1562
+ }
1563
+ quiet();
1564
+ if (!rest) return;
1565
+ const due = rest.at + this.idleMs;
1566
+ const wait = Math.max(0, due - this.now());
1567
+ const timer = setTimeout(() => {
1568
+ ticking = null;
1569
+ take(session, [], Math.max(due, this.now()));
1570
+ }, wait);
1571
+ timer.unref?.();
1572
+ ticking = { turn: rest.turn, timer };
1573
+ this.lease(id, due + REST_LEASE_MARGIN_MS);
1574
+ leased = true;
1575
+ this.resting.set(id, () => {
1576
+ if (stopped || fold.ended) return false;
1577
+ fold = { ...fold, ended: true };
1578
+ quiet();
1579
+ this.log(`stopped a held run thread=${id}`);
1580
+ void end({ kind: "failed", summary: STOPPED_SUMMARY, error: "interrupted" });
1581
+ return true;
1582
+ });
1583
+ this.log(
1584
+ `turn ended without a result thread=${id} turn=${rest.turn}; settling in ${Math.round(wait / 6e4)} min unless a new turn starts`
1585
+ );
1586
+ this.holdLog("run_held", id, wait);
1587
+ if (fold.turns.find((t) => t.id === rest.turn)?.endedAt === void 0)
1588
+ this.holdLog("hold_untimed", id);
1589
+ };
1590
+ const take = (from, records, now = this.now()) => {
1591
+ if (stopped || from !== session) return;
1459
1592
  const next = foldRecords(fold, records, {
1460
1593
  harness: this.harness,
1461
- now: this.now(),
1462
- progressMs: this.deps.progressMs
1594
+ now,
1595
+ progressMs: this.deps.progressMs,
1596
+ idleMs: this.idleMs
1463
1597
  });
1464
1598
  fold = next.state;
1599
+ tick();
1465
1600
  for (const event of next.events) {
1466
1601
  if (stopped) return;
1467
1602
  if (event.kind === "settled" || event.kind === "failed") {
@@ -1675,7 +1810,11 @@ ${line}` : line;
1675
1810
  if (page.length < EVENTS_PAGE) break;
1676
1811
  after = page.at(-1)?.sequence ?? after;
1677
1812
  }
1678
- return foldRecords(NEW_FOLD, records, { harness: this.harness, now: this.now() }).state;
1813
+ return foldRecords(NEW_FOLD, records, {
1814
+ harness: this.harness,
1815
+ now: this.now(),
1816
+ idleMs: this.idleMs
1817
+ }).state;
1679
1818
  }
1680
1819
  };
1681
1820
 
@@ -2124,7 +2263,7 @@ import {
2124
2263
  readFileSync as readFileSync2,
2125
2264
  readdirSync,
2126
2265
  realpathSync,
2127
- rmSync as rmSync2,
2266
+ rmSync as rmSync3,
2128
2267
  symlinkSync
2129
2268
  } from "fs";
2130
2269
  import { homedir, tmpdir as tmpdir2 } from "os";
@@ -2225,7 +2364,7 @@ async function packSkills(home = homedir(), capBytes = SKILLS_CAP_BYTES, tarBin
2225
2364
  });
2226
2365
  });
2227
2366
  });
2228
- rmSync2(dir, { recursive: true, force: true });
2367
+ rmSync3(dir, { recursive: true, force: true });
2229
2368
  return packed;
2230
2369
  }
2231
2370
  var RESERVED_MCP = /* @__PURE__ */ new Set(["cloop", "playwright"]);
@@ -2512,7 +2651,7 @@ import {
2512
2651
  openSync,
2513
2652
  readFileSync as readFileSync3,
2514
2653
  renameSync as renameSync3,
2515
- rmSync as rmSync3,
2654
+ rmSync as rmSync4,
2516
2655
  writeFileSync as writeFileSync2
2517
2656
  } from "fs";
2518
2657
  import { homedir as homedir2 } from "os";
@@ -2793,7 +2932,7 @@ async function adopt(from, kind, { services: given, script = process.argv[1] ??
2793
2932
  if (legacy) {
2794
2933
  const added = installedService({ ...where, environment });
2795
2934
  if (!await stopService(added, run3)) throw new Error(`${added.path} did not stop`);
2796
- rmSync3(added.path, { force: true });
2935
+ rmSync4(added.path, { force: true });
2797
2936
  moveRunnerFiles(runnerDir(environment), runnerDir(was));
2798
2937
  }
2799
2938
  recordFailed(VERSION, was);
@@ -2946,8 +3085,12 @@ async function run2() {
2946
3085
  // Beside the daemon's threads: the model a Task named, a run's move off a refused one, refusals and the last list.
2947
3086
  runModels: fileRunModels(hostedRunModelsPath(hosted.harness)),
2948
3087
  log: log2,
3088
+ // A held run's lease keeps the box awake until the hold is due to settle.
3089
+ awakeDir: join6(homedir3(), ".cloop", "awake"),
2949
3090
  // Called only once calls arrive, so the socket below exists by then.
2950
- followUpLost: ({ work, n, error }) => socket.send(runnerLog("followup_lost", { work, n, tool: "thread.send", error }))
3091
+ followUpLost: ({ work, n, error }) => socket.send(runnerLog("followup_lost", { work, n, tool: "thread.send", error })),
3092
+ // Watches start after the socket too: a held run's steps, for the hold monitor.
3093
+ holdLog: (code, work, ms) => socket.send(runnerLog(code, { work, ms }))
2951
3094
  }) : local && (name === "claude-code" || name === "codex") ? await localDriver(local, name) : new T3Driver({
2952
3095
  client: () => t3.client,
2953
3096
  t3Bin: isT3(cfg) ? cfg.t3Bin : null,
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  findRun,
4
4
  ownHarness
5
- } from "./chunk-WE3NUVJI.js";
5
+ } from "./chunk-OWYY764F.js";
6
6
  import {
7
7
  lockThreadsFile,
8
8
  threadsFilePath
9
- } from "./chunk-7GRP7ZX4.js";
9
+ } from "./chunk-TUGKGUV3.js";
10
10
  import {
11
11
  localRunsFilePath,
12
12
  readRunRecords,
13
13
  runHarness,
14
14
  takeoverSummary
15
- } from "./chunk-5MZDMAY2.js";
15
+ } from "./chunk-PMH5WSQK.js";
16
16
  import {
17
17
  sanitizeLabel
18
18
  } from "./chunk-VK6GV757.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-BIECV55V.js";
5
+ } from "./chunk-LZ4NZTA2.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SBYSVZ7J.js";
7
7
  import {
8
8
  VERSION
9
- } from "./chunk-CJKE7ELD.js";
9
+ } from "./chunk-PTOPXY65.js";
10
10
  import {
11
11
  getOrigin,
12
12
  readCredentials,
@@ -9,7 +9,7 @@ import {
9
9
  runHarness,
10
10
  runLogDir,
11
11
  runLogPath
12
- } from "./chunk-5MZDMAY2.js";
12
+ } from "./chunk-PMH5WSQK.js";
13
13
  import {
14
14
  sanitizeLabel,
15
15
  stripControl
@@ -291,6 +291,10 @@ function isProgressSentence(value) {
291
291
  return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
292
292
  }
293
293
  var PROGRESS_MS = 3e4;
294
+ var IDLE_SETTLE_MS = 20 * 6e4;
295
+ function holdsForNextTurn(turn) {
296
+ return turn.completed && !turn.limited && !turn.result;
297
+ }
294
298
  var RUN_TEXT_MAX = 4e3;
295
299
  function finalWords(text3) {
296
300
  return text3.replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
@@ -1544,7 +1548,6 @@ var STATUS_TTL_MS = 3e4;
1544
1548
  var REPOS_TTL_MS = 10 * 6e4;
1545
1549
  var TERMINAL_RUN = /* @__PURE__ */ new Set(["completed", "interrupted", "failed", "cancelled", "rolled_back"]);
1546
1550
  var STOPPED_IN_T3 = "You stopped this in T3.";
1547
- var IDLE_SETTLE_MS = 20 * 6e4;
1548
1551
  var APPROVAL_WORDS = {
1549
1552
  command: "run a command",
1550
1553
  "file-read": "read a file",
@@ -1637,6 +1640,9 @@ function outcomeOf(p) {
1637
1640
  ...dropped.outputs || dropped.checks ? { dropped } : {}
1638
1641
  };
1639
1642
  }
1643
+ function holdsAfter(outcome) {
1644
+ return holdsForNextTurn({ completed: outcome.kind === "settled", result: outcome.result });
1645
+ }
1640
1646
  function permissionOf(runtimeMode) {
1641
1647
  return runtimeMode === "full-access" ? "full" : "ask";
1642
1648
  }
@@ -2355,7 +2361,7 @@ var T3Driver = class {
2355
2361
  return;
2356
2362
  }
2357
2363
  const turn = latestRun(p.runs ?? []);
2358
- if (turn && outcome.kind === "settled" && !outcome.result && !p.thread.settledAt && turn.id !== waited) {
2364
+ if (turn && holdsAfter(outcome) && !p.thread.settledAt && turn.id !== waited) {
2359
2365
  finishing = false;
2360
2366
  if (idle?.runId === turn.id) return;
2361
2367
  wake();
@@ -3666,6 +3672,8 @@ export {
3666
3672
  BoxToolError,
3667
3673
  CLOOP_THREAD_PREFIX,
3668
3674
  questionLine,
3675
+ IDLE_SETTLE_MS,
3676
+ holdsForNextTurn,
3669
3677
  RUN_TEXT_MAX,
3670
3678
  finalWords,
3671
3679
  nextProgress,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.59" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.61" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -9,7 +9,7 @@ import {
9
9
  readRunnerState,
10
10
  runnerStatePath,
11
11
  threadsFilePath
12
- } from "./chunk-7GRP7ZX4.js";
12
+ } from "./chunk-TUGKGUV3.js";
13
13
  import {
14
14
  BoxToolError,
15
15
  CLOOP_THREAD_PREFIX,
@@ -50,7 +50,7 @@ import {
50
50
  windowsExecutable,
51
51
  windowsPowerShellEnv,
52
52
  writeBoxConfig
53
- } from "./chunk-5MZDMAY2.js";
53
+ } from "./chunk-PMH5WSQK.js";
54
54
  import {
55
55
  CLAUDE_FLOOR,
56
56
  CODEX_FLOOR,
@@ -64,14 +64,14 @@ import {
64
64
  } from "./chunk-PKIEWBR7.js";
65
65
  import {
66
66
  connectWebhook
67
- } from "./chunk-HBBEFTXE.js";
67
+ } from "./chunk-IUBEQ342.js";
68
68
  import {
69
69
  ConnectFailure,
70
70
  connectReport,
71
71
  deviceLogin,
72
72
  newAttempt,
73
73
  sendConnectReport
74
- } from "./chunk-BIECV55V.js";
74
+ } from "./chunk-LZ4NZTA2.js";
75
75
  import {
76
76
  defaultDeviceName,
77
77
  getMachine,
@@ -79,7 +79,7 @@ import {
79
79
  } from "./chunk-SBYSVZ7J.js";
80
80
  import {
81
81
  VERSION
82
- } from "./chunk-CJKE7ELD.js";
82
+ } from "./chunk-PTOPXY65.js";
83
83
  import {
84
84
  STAGING_ORIGIN,
85
85
  getOrigin,
@@ -9,7 +9,7 @@ import {
9
9
  imageExt,
10
10
  mediaExt,
11
11
  runnerPath
12
- } from "./chunk-5MZDMAY2.js";
12
+ } from "./chunk-PMH5WSQK.js";
13
13
 
14
14
  // src/run-previews.ts
15
15
  import { execFile as execFile2, spawn } from "child_process";
@@ -54,17 +54,17 @@ import {
54
54
  which,
55
55
  workFolder,
56
56
  workFolderLine
57
- } from "./chunk-EHXAIGHI.js";
57
+ } from "./chunk-QLZYSUGR.js";
58
58
  import "./chunk-BI2Y5ZCL.js";
59
- import "./chunk-7GRP7ZX4.js";
60
- import "./chunk-5MZDMAY2.js";
59
+ import "./chunk-TUGKGUV3.js";
60
+ import "./chunk-PMH5WSQK.js";
61
61
  import "./chunk-VK6GV757.js";
62
62
  import "./chunk-365HFCQQ.js";
63
63
  import "./chunk-PKIEWBR7.js";
64
- import "./chunk-HBBEFTXE.js";
65
- import "./chunk-BIECV55V.js";
64
+ import "./chunk-IUBEQ342.js";
65
+ import "./chunk-LZ4NZTA2.js";
66
66
  import "./chunk-SBYSVZ7J.js";
67
- import "./chunk-CJKE7ELD.js";
67
+ import "./chunk-PTOPXY65.js";
68
68
  import "./chunk-D5UZW42X.js";
69
69
  export {
70
70
  DEFAULT_T3_URL,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-EHXAIGHI.js";
10
+ } from "./chunk-QLZYSUGR.js";
11
11
  import "./chunk-BI2Y5ZCL.js";
12
- import "./chunk-7GRP7ZX4.js";
13
- import "./chunk-5MZDMAY2.js";
12
+ import "./chunk-TUGKGUV3.js";
13
+ import "./chunk-PMH5WSQK.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-365HFCQQ.js";
16
16
  import "./chunk-PKIEWBR7.js";
17
- import "./chunk-HBBEFTXE.js";
18
- import "./chunk-BIECV55V.js";
17
+ import "./chunk-IUBEQ342.js";
18
+ import "./chunk-LZ4NZTA2.js";
19
19
  import "./chunk-SBYSVZ7J.js";
20
- import "./chunk-CJKE7ELD.js";
20
+ import "./chunk-PTOPXY65.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-EHXAIGHI.js";
5
+ } from "./chunk-QLZYSUGR.js";
6
6
  import "./chunk-BI2Y5ZCL.js";
7
- import "./chunk-7GRP7ZX4.js";
8
- import "./chunk-5MZDMAY2.js";
7
+ import "./chunk-TUGKGUV3.js";
8
+ import "./chunk-PMH5WSQK.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-365HFCQQ.js";
11
11
  import "./chunk-PKIEWBR7.js";
12
- import "./chunk-HBBEFTXE.js";
13
- import "./chunk-BIECV55V.js";
12
+ import "./chunk-IUBEQ342.js";
13
+ import "./chunk-LZ4NZTA2.js";
14
14
  import "./chunk-SBYSVZ7J.js";
15
- import "./chunk-CJKE7ELD.js";
15
+ import "./chunk-PTOPXY65.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-365HFCQQ.js";
5
5
  import {
6
6
  VERSION
7
- } from "./chunk-CJKE7ELD.js";
7
+ } from "./chunk-PTOPXY65.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -69,7 +69,7 @@ Add --staging to any command to use Cloop staging instead of production.
69
69
  A production machine and a staging machine can run side by side on one computer.
70
70
  `;
71
71
  async function pinExistingRunner() {
72
- const { pinExistingRunner: pin } = await import("./existing-runner-USM27GSJ.js");
72
+ const { pinExistingRunner: pin } = await import("./existing-runner-FNLWQGFZ.js");
73
73
  const { note } = pin();
74
74
  if (note) console.error(note);
75
75
  }
@@ -77,7 +77,7 @@ async function main() {
77
77
  switch (command) {
78
78
  case "login":
79
79
  case "auth": {
80
- const { loginCommand } = await import("./login-SUVMQUIZ.js");
80
+ const { loginCommand } = await import("./login-64IZF4QT.js");
81
81
  await loginCommand(argv);
82
82
  break;
83
83
  }
@@ -87,61 +87,61 @@ async function main() {
87
87
  break;
88
88
  }
89
89
  case "serve": {
90
- const { startMcpServer } = await import("./mcp-server-HPSCTFVB.js");
90
+ const { startMcpServer } = await import("./mcp-server-X4MIHXI4.js");
91
91
  await startMcpServer();
92
92
  break;
93
93
  }
94
94
  case "statusline": {
95
- const { statuslineCommand } = await import("./statusline-ACJ6FK6M.js");
95
+ const { statuslineCommand } = await import("./statusline-FKJDEYAA.js");
96
96
  statuslineCommand();
97
97
  break;
98
98
  }
99
99
  case "connect": {
100
- const { connectCommand } = await import("./connect-3566SIPL.js");
100
+ const { connectCommand } = await import("./connect-QWFKIR2A.js");
101
101
  await connectCommand(argv.slice(1));
102
102
  break;
103
103
  }
104
104
  case "use": {
105
- const { useCommand } = await import("./use-PMAT5XOG.js");
105
+ const { useCommand } = await import("./use-RASS2OSW.js");
106
106
  process.exitCode = await useCommand(argv.slice(1));
107
107
  break;
108
108
  }
109
109
  case "disconnect": {
110
- const { disconnectCommand } = await import("./disconnect-VTPVRXXC.js");
110
+ const { disconnectCommand } = await import("./disconnect-DYPSIUVQ.js");
111
111
  await disconnectCommand(argv.slice(1));
112
112
  break;
113
113
  }
114
114
  case "box": {
115
- const { boxCommand } = await import("./box-AJGVOLMF.js");
115
+ const { boxCommand } = await import("./box-OPKO2EY6.js");
116
116
  await boxCommand(argv.slice(1));
117
117
  break;
118
118
  }
119
119
  case "runs": {
120
120
  await pinExistingRunner();
121
- const { runsCommand } = await import("./runs-IU47AXGO.js");
121
+ const { runsCommand } = await import("./runs-62FX5IQ6.js");
122
122
  process.exitCode = runsCommand();
123
123
  break;
124
124
  }
125
125
  case "watch": {
126
126
  await pinExistingRunner();
127
- const { watchCommand } = await import("./runs-IU47AXGO.js");
127
+ const { watchCommand } = await import("./runs-62FX5IQ6.js");
128
128
  process.exitCode = await watchCommand(argv.slice(1));
129
129
  break;
130
130
  }
131
131
  case "takeover": {
132
132
  await pinExistingRunner();
133
- const { takeoverCommand } = await import("./takeover-WNMI3ITX.js");
133
+ const { takeoverCommand } = await import("./takeover-FUQV257E.js");
134
134
  process.exitCode = await takeoverCommand(argv.slice(1));
135
135
  break;
136
136
  }
137
137
  case "resume": {
138
138
  await pinExistingRunner();
139
- const { resumeCommand } = await import("./runs-IU47AXGO.js");
139
+ const { resumeCommand } = await import("./runs-62FX5IQ6.js");
140
140
  process.exitCode = await resumeCommand(argv.slice(1));
141
141
  break;
142
142
  }
143
143
  case "runner": {
144
- const { runnerCommand } = await import("./runner-F3HVBTUZ.js");
144
+ const { runnerCommand } = await import("./runner-RHKB5LKX.js");
145
145
  await runnerCommand(argv.slice(1));
146
146
  break;
147
147
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-BIECV55V.js";
6
+ } from "./chunk-LZ4NZTA2.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-CJKE7ELD.js";
8
+ import "./chunk-PTOPXY65.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  deviceLogin,
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-SBYSVZ7J.js";
32
32
  import {
33
33
  VERSION
34
- } from "./chunk-CJKE7ELD.js";
34
+ } from "./chunk-PTOPXY65.js";
35
35
  import {
36
36
  getMeshUrl,
37
37
  getToken
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  connectWebhook,
4
4
  runnerCommand
5
- } from "./chunk-HBBEFTXE.js";
6
- import "./chunk-BIECV55V.js";
5
+ } from "./chunk-IUBEQ342.js";
6
+ import "./chunk-LZ4NZTA2.js";
7
7
  import "./chunk-SBYSVZ7J.js";
8
- import "./chunk-CJKE7ELD.js";
8
+ import "./chunk-PTOPXY65.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  connectWebhook,
@@ -9,8 +9,8 @@ import {
9
9
  runsCommand,
10
10
  sessionFolder,
11
11
  watchCommand
12
- } from "./chunk-WE3NUVJI.js";
13
- import "./chunk-5MZDMAY2.js";
12
+ } from "./chunk-OWYY764F.js";
13
+ import "./chunk-PMH5WSQK.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-D5UZW42X.js";
16
16
  export {
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-CJKE7ELD.js";
10
+ } from "./chunk-PTOPXY65.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-GRYTOE6F.js";
13
- import "./chunk-WE3NUVJI.js";
14
- import "./chunk-7GRP7ZX4.js";
15
- import "./chunk-5MZDMAY2.js";
12
+ } from "./chunk-CBUSTVCH.js";
13
+ import "./chunk-OWYY764F.js";
14
+ import "./chunk-TUGKGUV3.js";
15
+ import "./chunk-PMH5WSQK.js";
16
16
  import "./chunk-VK6GV757.js";
17
17
  import "./chunk-SBYSVZ7J.js";
18
18
  import "./chunk-D5UZW42X.js";
@@ -3,20 +3,20 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-EHXAIGHI.js";
6
+ } from "./chunk-QLZYSUGR.js";
7
7
  import "./chunk-BI2Y5ZCL.js";
8
- import "./chunk-7GRP7ZX4.js";
8
+ import "./chunk-TUGKGUV3.js";
9
9
  import {
10
10
  isLocal,
11
11
  readRunnerConfig
12
- } from "./chunk-5MZDMAY2.js";
12
+ } from "./chunk-PMH5WSQK.js";
13
13
  import "./chunk-VK6GV757.js";
14
14
  import "./chunk-365HFCQQ.js";
15
15
  import "./chunk-PKIEWBR7.js";
16
- import "./chunk-HBBEFTXE.js";
17
- import "./chunk-BIECV55V.js";
16
+ import "./chunk-IUBEQ342.js";
17
+ import "./chunk-LZ4NZTA2.js";
18
18
  import "./chunk-SBYSVZ7J.js";
19
- import "./chunk-CJKE7ELD.js";
19
+ import "./chunk-PTOPXY65.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.59",
3
+ "version": "0.3.61",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Make your computer and your agents Cloop machines: device login, the machine daemon, the Cloop MCP server, and Claude Code hooks.",