@cloop/runner 0.3.69 → 0.3.71

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.
@@ -11,7 +11,7 @@ import {
11
11
  localAgent,
12
12
  mintSession,
13
13
  quotaProbes
14
- } from "./chunk-57E5WOOP.js";
14
+ } from "./chunk-MUFILIJS.js";
15
15
  import {
16
16
  CAPTURE_TICK_MS,
17
17
  HOST_ID_MAX,
@@ -44,7 +44,7 @@ import {
44
44
  } from "./chunk-365HFCQQ.js";
45
45
  import {
46
46
  pinExistingRunner
47
- } from "./chunk-TPKYD3JF.js";
47
+ } from "./chunk-JDGGRIS3.js";
48
48
  import {
49
49
  awaitDaemon,
50
50
  cmdWord,
@@ -61,7 +61,7 @@ import {
61
61
  serviceEnv,
62
62
  systemServices,
63
63
  unitFor
64
- } from "./chunk-WCKW2Z2G.js";
64
+ } from "./chunk-PQURJJOD.js";
65
65
  import {
66
66
  BoxWatch,
67
67
  hostedThreadsFilePath,
@@ -115,15 +115,15 @@ import {
115
115
  } from "./chunk-AZQGERT7.js";
116
116
  import "./chunk-VK6GV757.js";
117
117
  import "./chunk-PKIEWBR7.js";
118
- import "./chunk-KIYCULVE.js";
119
- import "./chunk-SJAGZNFF.js";
120
- import "./chunk-ZHQSGJCE.js";
118
+ import "./chunk-KUGUMEYC.js";
119
+ import "./chunk-UX4D6FY7.js";
120
+ import "./chunk-VB4V65JR.js";
121
121
  import {
122
122
  getMachine
123
123
  } from "./chunk-SBYSVZ7J.js";
124
124
  import {
125
125
  VERSION
126
- } from "./chunk-DTUNRKBC.js";
126
+ } from "./chunk-EE7PMIGC.js";
127
127
  import {
128
128
  getMeshUrl,
129
129
  getOrigin,
@@ -420,6 +420,19 @@ async function withLock(file, fn) {
420
420
  await exited;
421
421
  }
422
422
  }
423
+ var ADD_WORKTREE = ["-c", "core.hooksPath=/dev/null", "worktree", "add", "--quiet"];
424
+ async function startClean(path) {
425
+ let sparse = 0;
426
+ if (await git(path, ["config", "--get", "core.sparseCheckout"]).catch(() => "") === "true") {
427
+ sparse = (await git(path, ["ls-files", "-t"])).split("\n").filter((line) => line.startsWith("S ")).length;
428
+ await git(path, ["sparse-checkout", "disable"]);
429
+ }
430
+ const left = await git(path, ["status", "--porcelain", "--untracked-files=all", "--ignored"]);
431
+ if (!left) return { sparse, dirty: 0 };
432
+ await git(path, ["reset", "--hard", "--quiet", "HEAD"]);
433
+ await git(path, ["clean", "-fdxq"]);
434
+ return { sparse, dirty: left.split("\n").length };
435
+ }
423
436
  var Repos = class {
424
437
  constructor(root = REPOS_ROOT) {
425
438
  this.root = root;
@@ -470,18 +483,21 @@ var Repos = class {
470
483
  * filled; a folder that is already the worktree is left as it is. The run's
471
484
  * branch is the local one when there is one, else the one it pushed, else
472
485
  * a new one from the remote's default branch. Call under the clone's lock.
486
+ * Returns what a new worktree held that its commit does not, which it
487
+ * dropped: none for a clean start or a worktree already there.
473
488
  */
474
489
  async ensureWorktree(clone, branch, path) {
475
490
  const dir = this.cloneDir(clone);
476
491
  await git(dir, ["worktree", "prune"]);
477
- if (await this.listed(dir, path)) return;
492
+ if (await this.listed(dir, path)) return { sparse: 0, dirty: 0 };
478
493
  if (await gitOk(dir, ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]))
479
- await git(dir, ["worktree", "add", "--quiet", path, branch]);
494
+ await git(dir, [...ADD_WORKTREE, path, branch]);
480
495
  else {
481
496
  const pushed = `refs/remotes/origin/${branch}`;
482
497
  const base = await gitOk(dir, ["rev-parse", "--verify", "--quiet", pushed]) ? pushed : "origin/HEAD";
483
- await git(dir, ["worktree", "add", "--quiet", "--no-track", "-b", branch, path, base]);
498
+ await git(dir, [...ADD_WORKTREE, "--no-track", "-b", branch, path, base]);
484
499
  }
500
+ return startClean(path);
485
501
  }
486
502
  /** What is in the worktree at `path`. Call under the clone's lock. */
487
503
  async facts(clone, branch, path, busy2) {
@@ -1220,11 +1236,7 @@ var CloudroomDriver = class {
1220
1236
  }
1221
1237
  }
1222
1238
  if (place.kind === "worktree")
1223
- await this.repos.ensureWorktree(
1224
- place.clone,
1225
- place.branch,
1226
- folder(existing2 ?? await this.session(thread))
1227
- );
1239
+ await this.worktree(place, thread, folder(existing2 ?? await this.session(thread)));
1228
1240
  if (this.stopped.has(thread)) throw STOPPED_IN_PREPARATION;
1229
1241
  const photoLine = (await photosOnce()).line;
1230
1242
  const held = this.foldEarly(thread);
@@ -1368,10 +1380,20 @@ var CloudroomDriver = class {
1368
1380
  const tree = worktreeOf(s.workspace);
1369
1381
  if (!tree) return deliver();
1370
1382
  return this.repos.locked(tree.clone, async () => {
1371
- await this.repos.ensureWorktree(tree.clone, tree.branch, folder(s));
1383
+ await this.worktree(tree, a.thread_id, folder(s));
1372
1384
  return deliver();
1373
1385
  });
1374
1386
  }
1387
+ /** The run's worktree, there and on its branch; a new one that was not clean is logged. Call under the clone's lock. */
1388
+ async worktree(tree, thread, path) {
1389
+ const start = await this.repos.ensureWorktree(tree.clone, tree.branch, path);
1390
+ if (!start.sparse && !start.dirty) return;
1391
+ const work = workOf(thread);
1392
+ this.log(
1393
+ `worktree dirty start work=${work} thread=${thread} sparse=${start.sparse} dirty=${start.dirty}`
1394
+ );
1395
+ if (work) this.deps.dirtyStartLog?.(work, start);
1396
+ }
1375
1397
  /**
1376
1398
  * When a run ends, its worktree goes if nothing in it would be lost, and
1377
1399
  * the report says where the work is when it stays. Under the clone's lock,
@@ -2408,7 +2430,7 @@ var T3Threads = class {
2408
2430
  }
2409
2431
  this.facts = known;
2410
2432
  const ask = threads.filter(
2411
- (t) => this.resolvedAt.get(t.id) !== harnessKey(t) && typeof t.updatedAt === "string" && now - Date.parse(t.updatedAt) <= LOOKBACK_MS
2433
+ (t) => this.resolvedAt.get(t.id) !== harnessKey(t) && typeof t.updatedAt === "string" && (now - Date.parse(t.updatedAt) <= LOOKBACK_MS || hostState(t) === "waiting")
2412
2434
  ).sort((a, b) => String(b.updatedAt).localeCompare(String(a.updatedAt))).slice(0, PROJECTIONS_PER_READ);
2413
2435
  for (const thread of ask) {
2414
2436
  const projection = await t3.rpc("orchestration.getThreadProjection", {
@@ -2888,7 +2910,12 @@ async function run2() {
2888
2910
  // Watches start after the socket too: a held run's steps, for the hold monitor.
2889
2911
  holdLog: (code, work, ms) => socket.send(runnerLog(code, { work, ms })),
2890
2912
  // A Claude Code run that carries on past the OAuth refresh lock, or fails on it after its last try.
2891
- authLockLog: (code, work, n, ms) => socket.send(runnerLog(code, { work, n, ms }))
2913
+ authLockLog: (code, work, n, ms) => socket.send(runnerLog(code, { work, n, ms })),
2914
+ // A repository run whose new worktree was not clean, by cause: `n` files a sparse checkout hid, or paths dropped.
2915
+ dirtyStartLog: (work, { sparse, dirty }) => {
2916
+ if (sparse) socket.send(runnerLog("worktree_sparse", { work, n: sparse }));
2917
+ if (dirty) socket.send(runnerLog("worktree_dirty", { work, n: dirty }));
2918
+ }
2892
2919
  }) : local && isLocalDriver(name) ? await localDriver(local, name) : new T3Driver({
2893
2920
  client: () => t3.client,
2894
2921
  t3Bin: isT3(cfg) ? cfg.t3Bin : null,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.69" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.71" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  legacyStagingRunner,
4
4
  runnerOrigin
5
- } from "./chunk-WCKW2Z2G.js";
5
+ } from "./chunk-PQURJJOD.js";
6
6
  import {
7
7
  ENVIRONMENTS,
8
8
  boxPath,
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  deviceLogin
4
- } from "./chunk-SJAGZNFF.js";
4
+ } from "./chunk-UX4D6FY7.js";
5
5
  import {
6
6
  ConnectFailure
7
- } from "./chunk-ZHQSGJCE.js";
7
+ } from "./chunk-VB4V65JR.js";
8
8
  import {
9
9
  ApiError,
10
10
  ReauthError,
@@ -49,7 +49,7 @@ import {
49
49
  serviceEnv,
50
50
  systemServices,
51
51
  unitFor
52
- } from "./chunk-WCKW2Z2G.js";
52
+ } from "./chunk-PQURJJOD.js";
53
53
  import {
54
54
  BoxToolError,
55
55
  CLOOP_THREAD_PREFIX,
@@ -85,16 +85,16 @@ import {
85
85
  } from "./chunk-PKIEWBR7.js";
86
86
  import {
87
87
  connectWebhook
88
- } from "./chunk-KIYCULVE.js";
88
+ } from "./chunk-KUGUMEYC.js";
89
89
  import {
90
90
  deviceLogin
91
- } from "./chunk-SJAGZNFF.js";
91
+ } from "./chunk-UX4D6FY7.js";
92
92
  import {
93
93
  ConnectFailure,
94
94
  connectReport,
95
95
  newAttempt,
96
96
  sendConnectReport
97
- } from "./chunk-ZHQSGJCE.js";
97
+ } from "./chunk-VB4V65JR.js";
98
98
  import {
99
99
  defaultDeviceName,
100
100
  getMachine,
@@ -102,7 +102,7 @@ import {
102
102
  } from "./chunk-SBYSVZ7J.js";
103
103
  import {
104
104
  VERSION
105
- } from "./chunk-DTUNRKBC.js";
105
+ } from "./chunk-EE7PMIGC.js";
106
106
  import {
107
107
  STAGING_ORIGIN,
108
108
  getOrigin,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-GAEZIKCK.js";
15
15
  import {
16
16
  ConnectFailure
17
- } from "./chunk-ZHQSGJCE.js";
17
+ } from "./chunk-VB4V65JR.js";
18
18
  import {
19
19
  getOrigin
20
20
  } from "./chunk-D5UZW42X.js";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConnectFailure
4
- } from "./chunk-ZHQSGJCE.js";
4
+ } from "./chunk-VB4V65JR.js";
5
5
  import {
6
6
  ApiError,
7
7
  api,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  VERSION
4
- } from "./chunk-DTUNRKBC.js";
4
+ } from "./chunk-EE7PMIGC.js";
5
5
 
6
6
  // src/connect-report.ts
7
7
  import { randomUUID } from "crypto";
@@ -37,21 +37,21 @@ import {
37
37
  updateClaude,
38
38
  workFolder,
39
39
  workFolderLine
40
- } from "./chunk-57E5WOOP.js";
40
+ } from "./chunk-MUFILIJS.js";
41
41
  import "./chunk-JJWSPBM4.js";
42
42
  import "./chunk-DN6TQALA.js";
43
43
  import "./chunk-365HFCQQ.js";
44
- import "./chunk-WCKW2Z2G.js";
44
+ import "./chunk-PQURJJOD.js";
45
45
  import "./chunk-4JTIWZHB.js";
46
46
  import "./chunk-GAEZIKCK.js";
47
47
  import "./chunk-AZQGERT7.js";
48
48
  import "./chunk-VK6GV757.js";
49
49
  import "./chunk-PKIEWBR7.js";
50
- import "./chunk-KIYCULVE.js";
51
- import "./chunk-SJAGZNFF.js";
52
- import "./chunk-ZHQSGJCE.js";
50
+ import "./chunk-KUGUMEYC.js";
51
+ import "./chunk-UX4D6FY7.js";
52
+ import "./chunk-VB4V65JR.js";
53
53
  import "./chunk-SBYSVZ7J.js";
54
- import "./chunk-DTUNRKBC.js";
54
+ import "./chunk-EE7PMIGC.js";
55
55
  import "./chunk-D5UZW42X.js";
56
56
  export {
57
57
  DEFAULT_T3_URL,
@@ -12,13 +12,13 @@ import {
12
12
  import "./chunk-DN6TQALA.js";
13
13
  import {
14
14
  pinExistingRunner
15
- } from "./chunk-TPKYD3JF.js";
15
+ } from "./chunk-JDGGRIS3.js";
16
16
  import {
17
17
  installedServices,
18
18
  legacyStagingRunner,
19
19
  servicesOrigin,
20
20
  stopService
21
- } from "./chunk-WCKW2Z2G.js";
21
+ } from "./chunk-PQURJJOD.js";
22
22
  import {
23
23
  runnerStatePath,
24
24
  threadsFilePath
@@ -32,8 +32,8 @@ import {
32
32
  windowsPowerShellEnv
33
33
  } from "./chunk-GAEZIKCK.js";
34
34
  import "./chunk-VK6GV757.js";
35
- import "./chunk-ZHQSGJCE.js";
36
- import "./chunk-DTUNRKBC.js";
35
+ import "./chunk-VB4V65JR.js";
36
+ import "./chunk-EE7PMIGC.js";
37
37
  import {
38
38
  getOrigin
39
39
  } from "./chunk-D5UZW42X.js";
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  existingRunnerEnvironment,
4
4
  pinExistingRunner
5
- } from "./chunk-TPKYD3JF.js";
6
- import "./chunk-WCKW2Z2G.js";
5
+ } from "./chunk-JDGGRIS3.js";
6
+ import "./chunk-PQURJJOD.js";
7
7
  import "./chunk-4JTIWZHB.js";
8
8
  import "./chunk-GAEZIKCK.js";
9
- import "./chunk-ZHQSGJCE.js";
10
- import "./chunk-DTUNRKBC.js";
9
+ import "./chunk-VB4V65JR.js";
10
+ import "./chunk-EE7PMIGC.js";
11
11
  import "./chunk-D5UZW42X.js";
12
12
  export {
13
13
  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-DTUNRKBC.js";
7
+ } from "./chunk-EE7PMIGC.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -72,7 +72,7 @@ Add --staging to any command to use Cloop staging instead of production.
72
72
  A production machine and a staging machine can run side by side on one computer.
73
73
  `;
74
74
  async function pinExistingRunner() {
75
- const { pinExistingRunner: pin } = await import("./existing-runner-BSSRQFFP.js");
75
+ const { pinExistingRunner: pin } = await import("./existing-runner-4QQYKV7I.js");
76
76
  const { note } = pin();
77
77
  if (note) console.error(note);
78
78
  }
@@ -80,7 +80,7 @@ async function main() {
80
80
  switch (command) {
81
81
  case "login":
82
82
  case "auth": {
83
- const { loginCommand } = await import("./login-4HWP4PF4.js");
83
+ const { loginCommand } = await import("./login-KHJQD25C.js");
84
84
  await loginCommand(argv);
85
85
  break;
86
86
  }
@@ -90,32 +90,32 @@ async function main() {
90
90
  break;
91
91
  }
92
92
  case "serve": {
93
- const { startMcpServer } = await import("./mcp-server-DTJVCFRG.js");
93
+ const { startMcpServer } = await import("./mcp-server-4D476KMH.js");
94
94
  await startMcpServer();
95
95
  break;
96
96
  }
97
97
  case "statusline": {
98
- const { statuslineCommand } = await import("./statusline-C2FH3YQ4.js");
98
+ const { statuslineCommand } = await import("./statusline-3TZ26LKY.js");
99
99
  statuslineCommand();
100
100
  break;
101
101
  }
102
102
  case "connect": {
103
- const { connectCommand } = await import("./connect-HVOAYXWM.js");
103
+ const { connectCommand } = await import("./connect-5D5CIC4V.js");
104
104
  await connectCommand(argv.slice(1));
105
105
  break;
106
106
  }
107
107
  case "use": {
108
- const { useCommand } = await import("./use-U3E55XBK.js");
108
+ const { useCommand } = await import("./use-HY5BO4BW.js");
109
109
  process.exitCode = await useCommand(argv.slice(1));
110
110
  break;
111
111
  }
112
112
  case "disconnect": {
113
- const { disconnectCommand } = await import("./disconnect-DQ6WSDR7.js");
113
+ const { disconnectCommand } = await import("./disconnect-CQXE6ZNH.js");
114
114
  await disconnectCommand(argv.slice(1));
115
115
  break;
116
116
  }
117
117
  case "box": {
118
- const { boxCommand } = await import("./box-UOJ6ET2B.js");
118
+ const { boxCommand } = await import("./box-N5NOCXH3.js");
119
119
  await boxCommand(argv.slice(1));
120
120
  break;
121
121
  }
@@ -144,7 +144,7 @@ async function main() {
144
144
  break;
145
145
  }
146
146
  case "runner": {
147
- const { runnerCommand } = await import("./runner-4XWS2RJL.js");
147
+ const { runnerCommand } = await import("./runner-6GIMXVD5.js");
148
148
  await runnerCommand(argv.slice(1));
149
149
  break;
150
150
  }
@@ -3,10 +3,10 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-SJAGZNFF.js";
7
- import "./chunk-ZHQSGJCE.js";
6
+ } from "./chunk-UX4D6FY7.js";
7
+ import "./chunk-VB4V65JR.js";
8
8
  import "./chunk-SBYSVZ7J.js";
9
- import "./chunk-DTUNRKBC.js";
9
+ import "./chunk-EE7PMIGC.js";
10
10
  import "./chunk-D5UZW42X.js";
11
11
  export {
12
12
  deviceLogin,
@@ -31,7 +31,7 @@ import {
31
31
  } from "./chunk-SBYSVZ7J.js";
32
32
  import {
33
33
  VERSION
34
- } from "./chunk-DTUNRKBC.js";
34
+ } from "./chunk-EE7PMIGC.js";
35
35
  import {
36
36
  getMeshUrl,
37
37
  getToken
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  connectWebhook,
4
4
  runnerCommand
5
- } from "./chunk-KIYCULVE.js";
6
- import "./chunk-SJAGZNFF.js";
7
- import "./chunk-ZHQSGJCE.js";
5
+ } from "./chunk-KUGUMEYC.js";
6
+ import "./chunk-UX4D6FY7.js";
7
+ import "./chunk-VB4V65JR.js";
8
8
  import "./chunk-SBYSVZ7J.js";
9
- import "./chunk-DTUNRKBC.js";
9
+ import "./chunk-EE7PMIGC.js";
10
10
  import "./chunk-D5UZW42X.js";
11
11
  export {
12
12
  connectWebhook,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-DTUNRKBC.js";
10
+ } from "./chunk-EE7PMIGC.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  AGENTS,
4
4
  runConnect
5
- } from "./chunk-57E5WOOP.js";
5
+ } from "./chunk-MUFILIJS.js";
6
6
  import "./chunk-JJWSPBM4.js";
7
7
  import "./chunk-DN6TQALA.js";
8
8
  import "./chunk-365HFCQQ.js";
9
9
  import {
10
10
  pinExistingRunner
11
- } from "./chunk-TPKYD3JF.js";
12
- import "./chunk-WCKW2Z2G.js";
11
+ } from "./chunk-JDGGRIS3.js";
12
+ import "./chunk-PQURJJOD.js";
13
13
  import "./chunk-4JTIWZHB.js";
14
14
  import {
15
15
  isLocal,
@@ -19,11 +19,11 @@ import {
19
19
  import "./chunk-AZQGERT7.js";
20
20
  import "./chunk-VK6GV757.js";
21
21
  import "./chunk-PKIEWBR7.js";
22
- import "./chunk-KIYCULVE.js";
23
- import "./chunk-SJAGZNFF.js";
24
- import "./chunk-ZHQSGJCE.js";
22
+ import "./chunk-KUGUMEYC.js";
23
+ import "./chunk-UX4D6FY7.js";
24
+ import "./chunk-VB4V65JR.js";
25
25
  import "./chunk-SBYSVZ7J.js";
26
- import "./chunk-DTUNRKBC.js";
26
+ import "./chunk-EE7PMIGC.js";
27
27
  import "./chunk-D5UZW42X.js";
28
28
 
29
29
  // src/commands/use.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloop/runner",
3
- "version": "0.3.69",
3
+ "version": "0.3.71",
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.",