@cloop/runner 0.2.8 → 0.2.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.
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  serveTakeovers
4
- } from "./chunk-LJTAYH6Q.js";
5
- import "./chunk-GGK4FLAH.js";
4
+ } from "./chunk-C6EODIE5.js";
5
+ import "./chunk-HI3HDN35.js";
6
6
  import {
7
7
  LocalDriver
8
- } from "./chunk-5GPCD7HI.js";
8
+ } from "./chunk-DHUZXAK2.js";
9
9
  import {
10
10
  MeshSocket,
11
11
  defaultSocketFactory
@@ -21,7 +21,7 @@ import {
21
21
  probeClaudePermissions,
22
22
  probeCodex,
23
23
  runBoxTool
24
- } from "./chunk-WKJBZKUO.js";
24
+ } from "./chunk-EN7WRLSI.js";
25
25
  import {
26
26
  BoxWatch,
27
27
  lockThreadsFile,
@@ -34,18 +34,19 @@ import {
34
34
  readRunnerConfig,
35
35
  showsOtherThreads,
36
36
  writeBoxConfig
37
- } from "./chunk-L5R7QXIB.js";
37
+ } from "./chunk-NX2LAKNU.js";
38
+ import "./chunk-UBXT5IDU.js";
38
39
  import {
39
40
  getMachine
40
41
  } from "./chunk-JX6VG5FE.js";
41
42
  import "./chunk-VK6GV757.js";
42
43
  import "./chunk-R3CLO2FB.js";
43
- import "./chunk-YVMU3GCX.js";
44
- import "./chunk-SQLFEVGP.js";
44
+ import "./chunk-VNX4VJAM.js";
45
+ import "./chunk-PRJBCKRP.js";
45
46
  import "./chunk-AG6SI6I2.js";
46
47
  import {
47
48
  VERSION
48
- } from "./chunk-JXVCUFUB.js";
49
+ } from "./chunk-UL2WHOQJ.js";
49
50
  import {
50
51
  getMeshUrl,
51
52
  getToken,
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  findRun
4
- } from "./chunk-GGK4FLAH.js";
4
+ } from "./chunk-HI3HDN35.js";
5
5
  import {
6
6
  localRunsFilePath,
7
7
  readRunRecords,
8
8
  takeoverSummary
9
- } from "./chunk-5GPCD7HI.js";
9
+ } from "./chunk-DHUZXAK2.js";
10
10
  import {
11
11
  lockThreadsFile,
12
12
  threadsFilePath
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  isLocal,
16
16
  readRunnerConfig
17
- } from "./chunk-L5R7QXIB.js";
17
+ } from "./chunk-NX2LAKNU.js";
18
18
  import {
19
19
  shortMachineName
20
20
  } from "./chunk-JX6VG5FE.js";
@@ -4,17 +4,18 @@ import {
4
4
  RESULT_INSTRUCTION,
5
5
  STOPPED_SUMMARY,
6
6
  appendRunLog,
7
+ droppedLine,
7
8
  endNote,
8
9
  isProgressSentence,
9
10
  logLineFor,
10
11
  nextProgress,
11
12
  orderThreads,
12
- parseRunResult,
13
13
  prUrlIn,
14
14
  pruneRunLogs,
15
+ readRunResult,
15
16
  resultPrUrl,
16
17
  runLogDir
17
- } from "./chunk-L5R7QXIB.js";
18
+ } from "./chunk-NX2LAKNU.js";
18
19
  import {
19
20
  CONFIG_DIR
20
21
  } from "./chunk-3DIGCVL4.js";
@@ -508,7 +509,9 @@ ${RESULT_INSTRUCTION}`));
508
509
  }
509
510
  if (code === 0 && live.result?.ok) {
510
511
  const text = live.result.text?.trim() || r.last_text;
511
- const result = parseRunResult(text);
512
+ const { result, dropped } = readRunResult(text);
513
+ const lost = droppedLine(dropped, r.work_id);
514
+ if (lost) this.log(lost);
512
515
  const { pr, note } = await this.outcome(r, text);
513
516
  const summary = [r.switched, note, text].filter(Boolean).join(" ").replace(/\s+/g, " ");
514
517
  await this.end(r, {
@@ -18,7 +18,12 @@ import {
18
18
  t3BaseDirArgs,
19
19
  t3Candidates,
20
20
  writeBoxConfig
21
- } from "./chunk-L5R7QXIB.js";
21
+ } from "./chunk-NX2LAKNU.js";
22
+ import {
23
+ CLAUDE_FLOOR,
24
+ claudeTooOld,
25
+ olderThan
26
+ } from "./chunk-UBXT5IDU.js";
22
27
  import {
23
28
  getMachine,
24
29
  shortMachineName
@@ -29,17 +34,17 @@ import {
29
34
  } from "./chunk-R3CLO2FB.js";
30
35
  import {
31
36
  connectWebhook
32
- } from "./chunk-YVMU3GCX.js";
37
+ } from "./chunk-VNX4VJAM.js";
33
38
  import {
34
39
  ConnectFailure,
35
40
  connectReport,
36
41
  deviceLogin,
37
42
  newAttempt,
38
43
  sendConnectReport
39
- } from "./chunk-SQLFEVGP.js";
44
+ } from "./chunk-PRJBCKRP.js";
40
45
  import {
41
46
  VERSION
42
- } from "./chunk-JXVCUFUB.js";
47
+ } from "./chunk-UL2WHOQJ.js";
43
48
  import {
44
49
  STAGING_ORIGIN,
45
50
  getOrigin
@@ -1353,7 +1358,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
1353
1358
  readEnvironment: async () => {
1354
1359
  const environment = await readEnvironment(t3Url);
1355
1360
  out(
1356
- `${bold("Cloop runner")} Connecting ${environment.label} (T3 ${environment.serverVersion}) to Cloop.`
1361
+ `${bold("Cloop runner")} Connecting ${shortMachineName(environment.label)} (T3 ${environment.serverVersion}) to Cloop with @cloop/runner ${VERSION}.`
1357
1362
  );
1358
1363
  return environment;
1359
1364
  },
@@ -1436,7 +1441,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
1436
1441
  version: `${harness.name} ${harness.version ?? ""}`.trim()
1437
1442
  };
1438
1443
  out(
1439
- `${bold("Cloop runner")} Connecting ${deviceName} as a Local runner with ${harnessLine(harness)}.`
1444
+ `${bold("Cloop runner")} Connecting ${deviceName} as a Local runner with ${harnessLine(harness)}, using @cloop/runner ${VERSION}.`
1440
1445
  );
1441
1446
  attempt.step = "login";
1442
1447
  const deviceToken = await deviceLogin({ origin: getOrigin(), deviceName, device });
@@ -1518,17 +1523,56 @@ async function connect(argv, attempt, deps = {}) {
1518
1523
  }
1519
1524
  );
1520
1525
  attempt.harnesses = harnessesFound(found);
1526
+ const current = await claudeAtFloor(found, forced, {
1527
+ update: deps.updateClaude ?? updateClaude,
1528
+ ask: deps.ask === void 0 ? terminalYesNo() : deps.ask
1529
+ });
1521
1530
  const workstation = isWorkstation(previous, boxServiceInstalled());
1522
- const choice = chooseDriver(found, forced, workstation);
1531
+ const choice = chooseDriver(current, forced, workstation);
1523
1532
  if (!choice.ok) throw new ConnectFailure(choice.code, choice.line);
1524
- const local = fallbackDriver(found, forced, workstation);
1533
+ const local = fallbackDriver(current, forced, workstation);
1525
1534
  await connectChosen(choice.driver, attempt, {
1526
1535
  t3: () => connectT3(argv, attempt, local ? HARNESS_NAME[local] : null, forced, deps.services),
1527
- local: (driver) => connectLocal(driver, found, argv, attempt, forced, deps.services),
1528
- fallback: () => fallbackDriver(found, forced, workstation),
1536
+ local: (driver) => connectLocal(driver, current, argv, attempt, forced, deps.services),
1537
+ fallback: () => fallbackDriver(current, forced, workstation),
1529
1538
  say: (line2) => out(`${bold("Cloop runner")} ${line2}`)
1530
1539
  });
1531
1540
  }
1541
+ async function claudeAtFloor(found, forced, deps) {
1542
+ const version = found.claude?.version;
1543
+ if (!version || forced === "codex" || !olderThan(version, CLAUDE_FLOOR)) return found;
1544
+ const fix = "Run `claude update`, then run `cloop connect` again.";
1545
+ const answer = deps.ask ? await deps.ask(`${claudeTooOld(version)} Update it now with \`claude update\`? (Y/n) `) : null;
1546
+ if (answer === null || answer.trim() && !isYes(answer))
1547
+ throw new ConnectFailure("harness_outdated", `${claudeTooOld(version)} ${fix}`);
1548
+ const claude = await deps.update();
1549
+ if (!claude?.version || olderThan(claude.version, CLAUDE_FLOOR))
1550
+ throw new ConnectFailure("harness_outdated", `Claude Code did not update. ${fix}`);
1551
+ out(`${bold("Cloop runner")} Claude Code updated to ${claude.version}.`);
1552
+ return { ...found, claude };
1553
+ }
1554
+ async function updateClaude() {
1555
+ try {
1556
+ execFileSync("claude", ["update"], { stdio: "inherit", timeout: 3e5 });
1557
+ } catch {
1558
+ return null;
1559
+ }
1560
+ return probeClaude();
1561
+ }
1562
+ function terminalYesNo() {
1563
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return null;
1564
+ return async (question) => {
1565
+ const prompt = createInterface({ input: process.stdin, output: process.stdout });
1566
+ try {
1567
+ return await askOrClosed(
1568
+ prompt,
1569
+ () => new ConnectFailure("harness_outdated", "No answer.")
1570
+ )(question);
1571
+ } finally {
1572
+ prompt.close();
1573
+ }
1574
+ };
1575
+ }
1532
1576
  async function runConnect(argv, deps = {}) {
1533
1577
  const attempt = newAttempt();
1534
1578
  let error = null;
@@ -1597,6 +1641,7 @@ export {
1597
1641
  detect,
1598
1642
  harnessesFound,
1599
1643
  rememberedDriver,
1644
+ claudeAtFloor,
1600
1645
  runConnect,
1601
1646
  connectCommand
1602
1647
  };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  localRunsFilePath,
4
4
  readRunRecords
5
- } from "./chunk-5GPCD7HI.js";
5
+ } from "./chunk-DHUZXAK2.js";
6
6
  import {
7
7
  STOPPED_SUMMARY,
8
8
  isEndLogLine,
@@ -10,7 +10,7 @@ import {
10
10
  readRunnerConfig,
11
11
  runLogDir,
12
12
  runLogPath
13
- } from "./chunk-L5R7QXIB.js";
13
+ } from "./chunk-NX2LAKNU.js";
14
14
  import {
15
15
  sanitizeLabel,
16
16
  stripControl
@@ -6,6 +6,171 @@ import {
6
6
  CONFIG_DIR
7
7
  } from "./chunk-3DIGCVL4.js";
8
8
 
9
+ // src/run-result.ts
10
+ var RESULT_INSTRUCTION = [
11
+ "When you finish, end your final message with a fenced block tagged cloop-result containing JSON, for example:",
12
+ "```cloop-result",
13
+ '{"summary": "One or two sentences on what you did.", "outputs": [{"kind": "pr", "title": "fix: the thing", "url": "https://github.com/org/repo/pull/1"}], "checks": [{"name": "Tests", "outcome": "passed"}]}',
14
+ "```",
15
+ "An output kind is one of: pr or link (title, url), draft (title, body, optional to), doc (title, optional url or body), file (title, path). A check outcome is passed, failed or skipped."
16
+ ].join("\n");
17
+ var text = (v, max) => typeof v === "string" && v.length <= max;
18
+ var optionalText = (v, max) => v === void 0 || text(v, max);
19
+ var https = (v) => {
20
+ try {
21
+ return typeof v === "string" && new URL(v).protocol === "https:";
22
+ } catch {
23
+ return false;
24
+ }
25
+ };
26
+ var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
27
+ function prUrlIn(text2) {
28
+ return text2?.match(PR_URL)?.at(-1) ?? null;
29
+ }
30
+ function resultPrUrl(finalMessage) {
31
+ const result = parseRunResult(finalMessage);
32
+ if (!result) return prUrlIn(finalMessage);
33
+ const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
34
+ return prs.at(-1) ?? null;
35
+ }
36
+ var SUMMARY_MAX = 500;
37
+ var DOC_BODY_MAX = 8e3;
38
+ function addressOutput(url) {
39
+ const pr = url.match(/\/pull\/(\d+)$/);
40
+ if (pr && prUrlIn(url) === url) return { kind: "pr", title: `Pull request #${pr[1]}`, url };
41
+ const { host, pathname } = new URL(url);
42
+ return { kind: "link", title: `${host}${pathname === "/" ? "" : pathname}`.slice(0, 120), url };
43
+ }
44
+ function cleanOutput(o) {
45
+ if (typeof o === "string") return https(o.trim()) ? addressOutput(o.trim()) : null;
46
+ if (!o || typeof o !== "object") return null;
47
+ const out = o;
48
+ if (!text(out.title, 120)) return null;
49
+ const title = out.title;
50
+ switch (out.kind) {
51
+ case "pr":
52
+ case "link":
53
+ return https(out.url) ? { kind: out.kind, title, url: out.url } : null;
54
+ case "draft":
55
+ return text(out.body, 4e3) && optionalText(out.to, 200) ? {
56
+ kind: "draft",
57
+ title,
58
+ body: out.body,
59
+ ...out.to !== void 0 ? { to: out.to } : {}
60
+ } : null;
61
+ case "doc": {
62
+ const body = typeof out.body === "string" && out.body.length > DOC_BODY_MAX ? `${out.body.slice(0, DOC_BODY_MAX - 1)}\u2026` : out.body;
63
+ return optionalText(body, DOC_BODY_MAX) && (out.url === void 0 || https(out.url)) ? {
64
+ kind: "doc",
65
+ title,
66
+ ...out.url !== void 0 ? { url: out.url } : {},
67
+ ...body !== void 0 ? { body } : {}
68
+ } : null;
69
+ }
70
+ case "file":
71
+ return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
72
+ default:
73
+ return null;
74
+ }
75
+ }
76
+ function cleanCheck(c) {
77
+ if (!c || typeof c !== "object") return null;
78
+ const check = c;
79
+ if (!text(check.name, 80) || !["passed", "failed", "skipped"].includes(check.outcome))
80
+ return null;
81
+ if (!optionalText(check.detail, 200)) return null;
82
+ return {
83
+ name: check.name,
84
+ outcome: check.outcome,
85
+ ...check.detail !== void 0 ? { detail: check.detail } : {}
86
+ };
87
+ }
88
+ function readRunResult(message) {
89
+ const none = { dropped: { outputs: 0, checks: 0 } };
90
+ const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
91
+ if (!block) return none;
92
+ try {
93
+ const value = JSON.parse(block);
94
+ const summary = typeof value?.summary === "string" ? value.summary.trim() : "";
95
+ if (!summary) return none;
96
+ const list = (v) => Array.isArray(v) ? v : [];
97
+ const outputs = list(value.outputs).flatMap((o) => cleanOutput(o) ?? []);
98
+ const checks = list(value.checks).flatMap((c) => cleanCheck(c) ?? []);
99
+ return {
100
+ result: {
101
+ summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
102
+ outputs: outputs.slice(0, 10),
103
+ checks: checks.slice(0, 10)
104
+ },
105
+ dropped: {
106
+ outputs: list(value.outputs).length - outputs.length,
107
+ checks: list(value.checks).length - checks.length
108
+ }
109
+ };
110
+ } catch {
111
+ return none;
112
+ }
113
+ }
114
+ function parseRunResult(message) {
115
+ return readRunResult(message).result;
116
+ }
117
+ function droppedLine(dropped, run) {
118
+ return dropped.outputs || dropped.checks ? `result_items_dropped run=${run} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
119
+ }
120
+
121
+ // src/drivers/driver.ts
122
+ var RUNTIME_MODES = /* @__PURE__ */ new Set([
123
+ "approval-required",
124
+ "auto-accept-edits",
125
+ "auto",
126
+ "full-access"
127
+ ]);
128
+ var BoxToolError = class extends Error {
129
+ constructor(code) {
130
+ super(code);
131
+ this.code = code;
132
+ this.name = "BoxToolError";
133
+ }
134
+ code;
135
+ };
136
+ var CLOOP_THREAD_PREFIX = "cloop:";
137
+ function questionLine(questions) {
138
+ return questions.map(
139
+ (x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
140
+ ).join(" ").slice(0, 500);
141
+ }
142
+ function isProgressSentence(value) {
143
+ return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
144
+ }
145
+ var PROGRESS_MS = 3e4;
146
+ function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
147
+ const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
148
+ if (!isProgressSentence(summary)) return null;
149
+ if (!force && now - clock.lastProgressAt < ms) return null;
150
+ clock.lastProgressAt = now;
151
+ return summary;
152
+ }
153
+ var YES_WORDS = /* @__PURE__ */ new Set([
154
+ "y",
155
+ "yes",
156
+ "yep",
157
+ "yeah",
158
+ "allow",
159
+ "allow it",
160
+ "ok",
161
+ "okay",
162
+ "approve",
163
+ "approved",
164
+ "go ahead",
165
+ "sure",
166
+ "do it"
167
+ ]);
168
+ function isYes(reply) {
169
+ return YES_WORDS.has(
170
+ reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
171
+ );
172
+ }
173
+
9
174
  // src/run-log.ts
10
175
  import {
11
176
  appendFileSync,
@@ -223,146 +388,6 @@ function whichAll(bin) {
223
388
 
224
389
  // src/drivers/t3.ts
225
390
  import { execFile, execFileSync as execFileSync2 } from "child_process";
226
-
227
- // src/run-result.ts
228
- var RESULT_INSTRUCTION = "When you finish, end your final message with a fenced block tagged cloop-result containing JSON: summary, outputs, checks.";
229
- var text = (v, max) => typeof v === "string" && v.length <= max;
230
- var optionalText = (v, max) => v === void 0 || text(v, max);
231
- var https = (v) => {
232
- try {
233
- return typeof v === "string" && new URL(v).protocol === "https:";
234
- } catch {
235
- return false;
236
- }
237
- };
238
- var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
239
- function prUrlIn(text2) {
240
- return text2?.match(PR_URL)?.at(-1) ?? null;
241
- }
242
- function resultPrUrl(finalMessage) {
243
- const result = parseRunResult(finalMessage);
244
- if (!result) return prUrlIn(finalMessage);
245
- const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
246
- return prs.at(-1) ?? null;
247
- }
248
- function parseRunResult(message) {
249
- const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
250
- if (!block) return void 0;
251
- try {
252
- const value = JSON.parse(block);
253
- if (!value || !text(value.summary, 500)) return void 0;
254
- const outputs = value.outputs ?? [];
255
- const checks = value.checks ?? [];
256
- if (!Array.isArray(outputs) || outputs.length > 10 || !Array.isArray(checks) || checks.length > 10)
257
- return void 0;
258
- const clean = [];
259
- for (const o of outputs) {
260
- if (!o || !text(o.title, 120)) return void 0;
261
- switch (o.kind) {
262
- case "pr":
263
- case "link":
264
- if (!https(o.url)) return void 0;
265
- clean.push({ kind: o.kind, title: o.title, url: o.url });
266
- break;
267
- case "draft":
268
- if (!text(o.body, 4e3) || !optionalText(o.to, 200)) return void 0;
269
- clean.push({
270
- kind: "draft",
271
- title: o.title,
272
- body: o.body,
273
- ...o.to !== void 0 ? { to: o.to } : {}
274
- });
275
- break;
276
- case "doc":
277
- if (!optionalText(o.body, 8e3) || o.url !== void 0 && !https(o.url))
278
- return void 0;
279
- clean.push({
280
- kind: "doc",
281
- title: o.title,
282
- ...o.url !== void 0 ? { url: o.url } : {},
283
- ...o.body !== void 0 ? { body: o.body } : {}
284
- });
285
- break;
286
- case "file":
287
- if (!text(o.path, 400)) return void 0;
288
- clean.push({ kind: "file", title: o.title, path: o.path });
289
- break;
290
- default:
291
- return void 0;
292
- }
293
- }
294
- if (checks.some(
295
- (c) => !c || !text(c.name, 80) || !["passed", "failed", "skipped"].includes(c.outcome) || !optionalText(c.detail, 200)
296
- ))
297
- return void 0;
298
- return {
299
- summary: value.summary,
300
- outputs: clean,
301
- checks: checks.map((c) => ({
302
- name: c.name,
303
- outcome: c.outcome,
304
- ...c.detail !== void 0 ? { detail: c.detail } : {}
305
- }))
306
- };
307
- } catch {
308
- return void 0;
309
- }
310
- }
311
-
312
- // src/drivers/driver.ts
313
- var RUNTIME_MODES = /* @__PURE__ */ new Set([
314
- "approval-required",
315
- "auto-accept-edits",
316
- "auto",
317
- "full-access"
318
- ]);
319
- var BoxToolError = class extends Error {
320
- constructor(code) {
321
- super(code);
322
- this.code = code;
323
- this.name = "BoxToolError";
324
- }
325
- code;
326
- };
327
- var CLOOP_THREAD_PREFIX = "cloop:";
328
- function questionLine(questions) {
329
- return questions.map(
330
- (x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
331
- ).join(" ").slice(0, 500);
332
- }
333
- function isProgressSentence(value) {
334
- return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
335
- }
336
- var PROGRESS_MS = 3e4;
337
- function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
338
- const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
339
- if (!isProgressSentence(summary)) return null;
340
- if (!force && now - clock.lastProgressAt < ms) return null;
341
- clock.lastProgressAt = now;
342
- return summary;
343
- }
344
- var YES_WORDS = /* @__PURE__ */ new Set([
345
- "y",
346
- "yes",
347
- "yep",
348
- "yeah",
349
- "allow",
350
- "allow it",
351
- "ok",
352
- "okay",
353
- "approve",
354
- "approved",
355
- "go ahead",
356
- "sure",
357
- "do it"
358
- ]);
359
- function isYes(reply) {
360
- return YES_WORDS.has(
361
- reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
362
- );
363
- }
364
-
365
- // src/drivers/t3.ts
366
391
  function isUnsettled(t) {
367
392
  return !t.settledAt && !t.archivedAt && !isChild(t);
368
393
  }
@@ -438,14 +463,15 @@ function outcomeOf(p) {
438
463
  const status = run?.status ?? "pending";
439
464
  const settled = TERMINAL_RUN.has(status) || Boolean(p.thread.settledAt);
440
465
  const text2 = (p.messages ?? []).filter((m) => m.role === "assistant" && m.text).at(-1)?.text?.trim();
441
- const result = parseRunResult(text2);
466
+ const { result, dropped } = readRunResult(text2);
442
467
  return {
443
468
  status,
444
469
  settled,
445
470
  kind: settled ? status === "completed" || !run ? "settled" : "failed" : null,
446
471
  pr_url: resultPrUrl(text2),
447
472
  last_assistant_text: text2 ? text2.slice(0, 300) : null,
448
- ...result ? { result } : {}
473
+ ...result ? { result } : {},
474
+ ...dropped.outputs || dropped.checks ? { dropped } : {}
449
475
  };
450
476
  }
451
477
  function permissionOf(runtimeMode) {
@@ -937,6 +963,8 @@ ${RESULT_INSTRUCTION}`, attachments: [] }
937
963
  ...outcome.result ? pr : {}
938
964
  });
939
965
  } else {
966
+ const lost = outcome.dropped ? droppedLine(outcome.dropped, threadId) : null;
967
+ if (lost) this.log(lost);
940
968
  onEvent({
941
969
  kind: "settled",
942
970
  ...outcome.result ? { result: outcome.result } : {},
@@ -1147,7 +1175,8 @@ export {
1147
1175
  RESULT_INSTRUCTION,
1148
1176
  prUrlIn,
1149
1177
  resultPrUrl,
1150
- parseRunResult,
1178
+ readRunResult,
1179
+ droppedLine,
1151
1180
  RUNTIME_MODES,
1152
1181
  BoxToolError,
1153
1182
  CLOOP_THREAD_PREFIX,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-AG6SI6I2.js";
6
6
  import {
7
7
  VERSION
8
- } from "./chunk-JXVCUFUB.js";
8
+ } from "./chunk-UL2WHOQJ.js";
9
9
  import {
10
10
  getOrigin,
11
11
  readCredentials,
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/floors.ts
4
+ var NODE_FLOOR = 20;
5
+ var CLAUDE_FLOOR = "2.1.281";
6
+ function olderThan(version, floor) {
7
+ const parts = (v) => v.replace(/^v/, "").split(/[.+-]/).slice(0, 3).map(Number);
8
+ const have = parts(version);
9
+ const want = parts(floor);
10
+ if (have.some(Number.isNaN)) return false;
11
+ for (let i = 0; i < want.length; i++) {
12
+ const a = have[i] ?? 0;
13
+ const b = want[i] ?? 0;
14
+ if (a !== b) return a < b;
15
+ }
16
+ return false;
17
+ }
18
+ function nodeTooOld(version = process.versions.node) {
19
+ if (!olderThan(version, String(NODE_FLOOR))) return null;
20
+ return `Cloop runner needs Node ${NODE_FLOOR} or later. This computer has Node ${version}. Update Node (brew upgrade node, or https://nodejs.org), then run the command again.`;
21
+ }
22
+ function claudeTooOld(version) {
23
+ return `Claude Code ${version} is older than ${CLAUDE_FLOOR}, the version Cloop runs on.`;
24
+ }
25
+
26
+ export {
27
+ CLAUDE_FLOOR,
28
+ olderThan,
29
+ nodeTooOld,
30
+ claudeTooOld
31
+ };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.2.8" : "0.0.0-dev";
4
+ var VERSION = true ? "0.2.10" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-SQLFEVGP.js";
5
+ } from "./chunk-PRJBCKRP.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -8,6 +8,7 @@ import {
8
8
  askRepos,
9
9
  awaitDaemon,
10
10
  chooseDriver,
11
+ claudeAtFloor,
11
12
  connectBox,
12
13
  connectChosen,
13
14
  connectCommand,
@@ -38,16 +39,17 @@ import {
38
39
  tilde,
39
40
  unitEnv,
40
41
  unitFor
41
- } from "./chunk-WKJBZKUO.js";
42
+ } from "./chunk-EN7WRLSI.js";
42
43
  import "./chunk-MWWA2VH7.js";
43
- import "./chunk-L5R7QXIB.js";
44
+ import "./chunk-NX2LAKNU.js";
45
+ import "./chunk-UBXT5IDU.js";
44
46
  import "./chunk-JX6VG5FE.js";
45
47
  import "./chunk-VK6GV757.js";
46
48
  import "./chunk-R3CLO2FB.js";
47
- import "./chunk-YVMU3GCX.js";
48
- import "./chunk-SQLFEVGP.js";
49
+ import "./chunk-VNX4VJAM.js";
50
+ import "./chunk-PRJBCKRP.js";
49
51
  import "./chunk-AG6SI6I2.js";
50
- import "./chunk-JXVCUFUB.js";
52
+ import "./chunk-UL2WHOQJ.js";
51
53
  import "./chunk-3DIGCVL4.js";
52
54
  export {
53
55
  DEFAULT_T3_URL,
@@ -58,6 +60,7 @@ export {
58
60
  askRepos,
59
61
  awaitDaemon,
60
62
  chooseDriver,
63
+ claudeAtFloor,
61
64
  connectBox,
62
65
  connectChosen,
63
66
  connectCommand,
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  localRunsFilePath
4
- } from "./chunk-5GPCD7HI.js";
4
+ } from "./chunk-DHUZXAK2.js";
5
5
  import {
6
6
  installedService,
7
7
  revokeOwnDevice,
8
8
  runSteps,
9
9
  tokenGone
10
- } from "./chunk-WKJBZKUO.js";
10
+ } from "./chunk-EN7WRLSI.js";
11
11
  import {
12
12
  runnerStatePath,
13
13
  threadsFilePath
@@ -15,14 +15,15 @@ import {
15
15
  import {
16
16
  boxPath,
17
17
  readRunnerConfig
18
- } from "./chunk-L5R7QXIB.js";
18
+ } from "./chunk-NX2LAKNU.js";
19
+ import "./chunk-UBXT5IDU.js";
19
20
  import "./chunk-JX6VG5FE.js";
20
21
  import "./chunk-VK6GV757.js";
21
22
  import "./chunk-R3CLO2FB.js";
22
- import "./chunk-YVMU3GCX.js";
23
- import "./chunk-SQLFEVGP.js";
23
+ import "./chunk-VNX4VJAM.js";
24
+ import "./chunk-PRJBCKRP.js";
24
25
  import "./chunk-AG6SI6I2.js";
25
- import "./chunk-JXVCUFUB.js";
26
+ import "./chunk-UL2WHOQJ.js";
26
27
  import {
27
28
  getOrigin
28
29
  } from "./chunk-3DIGCVL4.js";
package/dist/index.js CHANGED
@@ -1,12 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ nodeTooOld
4
+ } from "./chunk-UBXT5IDU.js";
2
5
  import {
3
6
  VERSION
4
- } from "./chunk-JXVCUFUB.js";
7
+ } from "./chunk-UL2WHOQJ.js";
5
8
  import {
6
9
  applyEnvironmentFlag
7
10
  } from "./chunk-3DIGCVL4.js";
8
11
 
9
12
  // src/index.ts
13
+ var oldNode = nodeTooOld();
14
+ if (oldNode) {
15
+ console.error(oldNode);
16
+ process.exit(1);
17
+ }
10
18
  var argv = applyEnvironmentFlag(process.argv.slice(2));
11
19
  var command = argv[0];
12
20
  var HELP = `cloop \u2014 the social layer for your agents (v${VERSION})
@@ -57,7 +65,7 @@ async function main() {
57
65
  switch (command) {
58
66
  case "login":
59
67
  case "auth": {
60
- const { loginCommand } = await import("./login-262MCIQ4.js");
68
+ const { loginCommand } = await import("./login-DXPJ3ZOA.js");
61
69
  await loginCommand(argv);
62
70
  break;
63
71
  }
@@ -67,57 +75,57 @@ async function main() {
67
75
  break;
68
76
  }
69
77
  case "serve": {
70
- const { startMcpServer } = await import("./mcp-server-R5LX4ER5.js");
78
+ const { startMcpServer } = await import("./mcp-server-4UMYMJ5P.js");
71
79
  await startMcpServer();
72
80
  break;
73
81
  }
74
82
  case "statusline": {
75
- const { statuslineCommand } = await import("./statusline-LDW7RBT6.js");
83
+ const { statuslineCommand } = await import("./statusline-AV2F2IM4.js");
76
84
  statuslineCommand();
77
85
  break;
78
86
  }
79
87
  case "connect": {
80
- const { connectCommand } = await import("./connect-RLDBBQI7.js");
88
+ const { connectCommand } = await import("./connect-GURZFURZ.js");
81
89
  await connectCommand(argv.slice(1));
82
90
  break;
83
91
  }
84
92
  case "use": {
85
- const { useCommand } = await import("./use-2W7Y42JQ.js");
93
+ const { useCommand } = await import("./use-52LTRRXJ.js");
86
94
  process.exitCode = await useCommand(argv.slice(1));
87
95
  break;
88
96
  }
89
97
  case "disconnect": {
90
- const { disconnectCommand } = await import("./disconnect-UYN2G7CO.js");
98
+ const { disconnectCommand } = await import("./disconnect-HGQW7TVG.js");
91
99
  await disconnectCommand(argv.slice(1));
92
100
  break;
93
101
  }
94
102
  case "box": {
95
- const { boxCommand } = await import("./box-TMEYQ5AN.js");
103
+ const { boxCommand } = await import("./box-P6LMNVYG.js");
96
104
  await boxCommand(argv.slice(1));
97
105
  break;
98
106
  }
99
107
  case "runs": {
100
- const { runsCommand } = await import("./runs-UV7GEDGW.js");
108
+ const { runsCommand } = await import("./runs-HRDQ7YCY.js");
101
109
  process.exitCode = runsCommand();
102
110
  break;
103
111
  }
104
112
  case "watch": {
105
- const { watchCommand } = await import("./runs-UV7GEDGW.js");
113
+ const { watchCommand } = await import("./runs-HRDQ7YCY.js");
106
114
  process.exitCode = await watchCommand(argv.slice(1));
107
115
  break;
108
116
  }
109
117
  case "takeover": {
110
- const { takeoverCommand } = await import("./takeover-KTRIOB3P.js");
118
+ const { takeoverCommand } = await import("./takeover-PDYTQY5D.js");
111
119
  process.exitCode = await takeoverCommand(argv.slice(1));
112
120
  break;
113
121
  }
114
122
  case "resume": {
115
- const { resumeCommand } = await import("./runs-UV7GEDGW.js");
123
+ const { resumeCommand } = await import("./runs-HRDQ7YCY.js");
116
124
  process.exitCode = await resumeCommand(argv.slice(1));
117
125
  break;
118
126
  }
119
127
  case "runner": {
120
- const { runnerCommand } = await import("./runner-ML437F74.js");
128
+ const { runnerCommand } = await import("./runner-SPOKUMLM.js");
121
129
  await runnerCommand(argv.slice(1));
122
130
  break;
123
131
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-SQLFEVGP.js";
6
+ } from "./chunk-PRJBCKRP.js";
7
7
  import "./chunk-AG6SI6I2.js";
8
- import "./chunk-JXVCUFUB.js";
8
+ import "./chunk-UL2WHOQJ.js";
9
9
  import "./chunk-3DIGCVL4.js";
10
10
  export {
11
11
  deviceLogin,
@@ -33,7 +33,7 @@ import {
33
33
  } from "./chunk-AG6SI6I2.js";
34
34
  import {
35
35
  VERSION
36
- } from "./chunk-JXVCUFUB.js";
36
+ } from "./chunk-UL2WHOQJ.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-YVMU3GCX.js";
6
- import "./chunk-SQLFEVGP.js";
5
+ } from "./chunk-VNX4VJAM.js";
6
+ import "./chunk-PRJBCKRP.js";
7
7
  import "./chunk-AG6SI6I2.js";
8
- import "./chunk-JXVCUFUB.js";
8
+ import "./chunk-UL2WHOQJ.js";
9
9
  import "./chunk-3DIGCVL4.js";
10
10
  export {
11
11
  connectWebhook,
@@ -8,9 +8,9 @@ import {
8
8
  runsCommand,
9
9
  sessionFolder,
10
10
  watchCommand
11
- } from "./chunk-GGK4FLAH.js";
12
- import "./chunk-5GPCD7HI.js";
13
- import "./chunk-L5R7QXIB.js";
11
+ } from "./chunk-HI3HDN35.js";
12
+ import "./chunk-DHUZXAK2.js";
13
+ import "./chunk-NX2LAKNU.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-3DIGCVL4.js";
16
16
  export {
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-JXVCUFUB.js";
10
+ } from "./chunk-UL2WHOQJ.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-3DIGCVL4.js";
@@ -9,11 +9,11 @@ import {
9
9
  takeoverDir,
10
10
  writeTakeoverReply,
11
11
  writeTakeoverRequest
12
- } from "./chunk-LJTAYH6Q.js";
13
- import "./chunk-GGK4FLAH.js";
14
- import "./chunk-5GPCD7HI.js";
12
+ } from "./chunk-C6EODIE5.js";
13
+ import "./chunk-HI3HDN35.js";
14
+ import "./chunk-DHUZXAK2.js";
15
15
  import "./chunk-MWWA2VH7.js";
16
- import "./chunk-L5R7QXIB.js";
16
+ import "./chunk-NX2LAKNU.js";
17
17
  import "./chunk-JX6VG5FE.js";
18
18
  import "./chunk-VK6GV757.js";
19
19
  import "./chunk-AG6SI6I2.js";
@@ -2,19 +2,20 @@
2
2
  import {
3
3
  DRIVER_NAME,
4
4
  runConnect
5
- } from "./chunk-WKJBZKUO.js";
5
+ } from "./chunk-EN7WRLSI.js";
6
6
  import "./chunk-MWWA2VH7.js";
7
7
  import {
8
8
  isLocal,
9
9
  readRunnerConfig
10
- } from "./chunk-L5R7QXIB.js";
10
+ } from "./chunk-NX2LAKNU.js";
11
+ import "./chunk-UBXT5IDU.js";
11
12
  import "./chunk-JX6VG5FE.js";
12
13
  import "./chunk-VK6GV757.js";
13
14
  import "./chunk-R3CLO2FB.js";
14
- import "./chunk-YVMU3GCX.js";
15
- import "./chunk-SQLFEVGP.js";
15
+ import "./chunk-VNX4VJAM.js";
16
+ import "./chunk-PRJBCKRP.js";
16
17
  import "./chunk-AG6SI6I2.js";
17
- import "./chunk-JXVCUFUB.js";
18
+ import "./chunk-UL2WHOQJ.js";
18
19
  import "./chunk-3DIGCVL4.js";
19
20
 
20
21
  // src/commands/use.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloop/runner",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
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.",