@cloop/runner 0.2.9 → 0.3.0
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.
- package/README.md +4 -2
- package/dist/{box-Z4NS6J7A.js → box-7SVME4E5.js} +14 -10
- package/dist/{chunk-VBWETWB5.js → chunk-2PVKRGOX.js} +1 -1
- package/dist/{chunk-VKEX5FVO.js → chunk-34XAQRBL.js} +67 -16
- package/dist/{chunk-MWWA2VH7.js → chunk-3B5JV6ZP.js} +4 -1
- package/dist/{chunk-QAOAR5OL.js → chunk-3ITSIARB.js} +1 -1
- package/dist/{chunk-3PIT6YXL.js → chunk-7CPNLUDI.js} +4 -4
- package/dist/{chunk-VIQF3JF3.js → chunk-EN3XHHWJ.js} +174 -165
- package/dist/{chunk-V4QYTF6O.js → chunk-NK6MHHYP.js} +2 -2
- package/dist/{chunk-Q2MTOW4O.js → chunk-NOABXLW3.js} +1 -1
- package/dist/{chunk-IRRQ55FQ.js → chunk-QLCIEJ4C.js} +59 -3
- package/dist/chunk-UBXT5IDU.js +31 -0
- package/dist/{connect-CGOALTSO.js → connect-LLURHARY.js} +9 -6
- package/dist/{disconnect-H3RDATJF.js → disconnect-WAQTAXN3.js} +9 -8
- package/dist/index.js +21 -13
- package/dist/{login-IQSMR2SY.js → login-XS2IFIUX.js} +2 -2
- package/dist/{mcp-server-PRPB2JYE.js → mcp-server-R47CKE6A.js} +1 -1
- package/dist/{runner-JNMWMBIG.js → runner-R4Z62XVC.js} +3 -3
- package/dist/{runs-BMTJHKBI.js → runs-4ZJOIB5S.js} +3 -3
- package/dist/{statusline-UVEWJ4BA.js → statusline-RI62KCQX.js} +1 -1
- package/dist/{takeover-XL2P7RML.js → takeover-F5SEY7WI.js} +5 -5
- package/dist/{use-3B33RXZH.js → use-2OOFS53J.js} +7 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,8 @@ cloop install # register the MCP server with Claude Code / others
|
|
|
12
12
|
|
|
13
13
|
Credentials live in `~/.cloop/credentials.json`. The API origin comes from `CLOOP_ORIGIN`, the stored value, or the staging default.
|
|
14
14
|
|
|
15
|
+
To disconnect a runner, use Disconnect in its ⋯ menu on the Threads page.
|
|
16
|
+
|
|
15
17
|
## Commands
|
|
16
18
|
|
|
17
19
|
| Command | What it does |
|
|
@@ -49,8 +51,8 @@ user to run `cloop login`.
|
|
|
49
51
|
|
|
50
52
|
On start, `serve` opens a WebSocket to the cloop-mesh Worker's per-user Durable
|
|
51
53
|
Object at `{CLOOP_MESH_URL}/mesh/agent?session_key=…` (default
|
|
52
|
-
`https://mcp
|
|
53
|
-
`meshUrl`). The device token rides the first `Sec-WebSocket-Protocol` entry, never
|
|
54
|
+
`https://mcp.mycloop.com`; `--staging` or `CLOOP_MESH_URL` selects another
|
|
55
|
+
mesh, and the choice is stored as `meshUrl`). The device token rides the first `Sec-WebSocket-Protocol` entry, never
|
|
54
56
|
the URL (query strings leak into edge logs). While it's up, presence
|
|
55
57
|
beats ride the socket (the DO mirrors them into the heartbeat route) and the HTTP
|
|
56
58
|
`HeartbeatClient` is the fallback; it reconnects with 1s→60s backoff + jitter.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
serveTakeovers
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-7CPNLUDI.js";
|
|
5
|
+
import "./chunk-NK6MHHYP.js";
|
|
6
6
|
import {
|
|
7
7
|
LocalDriver
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QLCIEJ4C.js";
|
|
9
9
|
import {
|
|
10
10
|
MeshSocket,
|
|
11
11
|
defaultSocketFactory
|
|
@@ -21,31 +21,32 @@ import {
|
|
|
21
21
|
probeClaudePermissions,
|
|
22
22
|
probeCodex,
|
|
23
23
|
runBoxTool
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-34XAQRBL.js";
|
|
25
25
|
import {
|
|
26
26
|
BoxWatch,
|
|
27
27
|
lockThreadsFile,
|
|
28
28
|
threadsFilePath,
|
|
29
29
|
writeRunnerState
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3B5JV6ZP.js";
|
|
31
31
|
import {
|
|
32
32
|
T3Driver,
|
|
33
33
|
isLocal,
|
|
34
34
|
readRunnerConfig,
|
|
35
35
|
showsOtherThreads,
|
|
36
36
|
writeBoxConfig
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-EN3XHHWJ.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-
|
|
44
|
-
import "./chunk-
|
|
44
|
+
import "./chunk-3ITSIARB.js";
|
|
45
|
+
import "./chunk-2PVKRGOX.js";
|
|
45
46
|
import "./chunk-AG6SI6I2.js";
|
|
46
47
|
import {
|
|
47
48
|
VERSION
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-NOABXLW3.js";
|
|
49
50
|
import {
|
|
50
51
|
getMeshUrl,
|
|
51
52
|
getToken,
|
|
@@ -178,7 +179,7 @@ async function machineHarnesses(cfg) {
|
|
|
178
179
|
}
|
|
179
180
|
async function localDriver(cfg, name) {
|
|
180
181
|
const bin = cfg.driver === name ? cfg.bin : void 0;
|
|
181
|
-
|
|
182
|
+
const driver = new LocalDriver({
|
|
182
183
|
dialect: name === "claude-code" ? claudeDialect(bin, cfg.fallbackModels ?? DEFAULT_FALLBACK_MODEL, cfg.askEverything, {
|
|
183
184
|
...await probeClaudePermissions(bin)
|
|
184
185
|
}) : codexDialect(bin),
|
|
@@ -187,6 +188,8 @@ async function localDriver(cfg, name) {
|
|
|
187
188
|
harnesses: () => machineHarnesses(cfg),
|
|
188
189
|
log
|
|
189
190
|
});
|
|
191
|
+
driver.warmHarnesses();
|
|
192
|
+
return driver;
|
|
190
193
|
}
|
|
191
194
|
function recordConnected(logLine, write = writeRunnerState) {
|
|
192
195
|
try {
|
|
@@ -389,6 +392,7 @@ export {
|
|
|
389
392
|
awaitNewDeviceToken,
|
|
390
393
|
boxCommand,
|
|
391
394
|
boxPresence,
|
|
395
|
+
machineHarnesses,
|
|
392
396
|
recordConnected,
|
|
393
397
|
run,
|
|
394
398
|
t3Presence
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
readRunnerState
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3B5JV6ZP.js";
|
|
5
5
|
import {
|
|
6
6
|
BoxToolError,
|
|
7
7
|
CLOOP_THREAD_PREFIX,
|
|
@@ -18,7 +18,12 @@ import {
|
|
|
18
18
|
t3BaseDirArgs,
|
|
19
19
|
t3Candidates,
|
|
20
20
|
writeBoxConfig
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-EN3XHHWJ.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-
|
|
37
|
+
} from "./chunk-3ITSIARB.js";
|
|
33
38
|
import {
|
|
34
39
|
ConnectFailure,
|
|
35
40
|
connectReport,
|
|
36
41
|
deviceLogin,
|
|
37
42
|
newAttempt,
|
|
38
43
|
sendConnectReport
|
|
39
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-2PVKRGOX.js";
|
|
40
45
|
import {
|
|
41
46
|
VERSION
|
|
42
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-NOABXLW3.js";
|
|
43
48
|
import {
|
|
44
49
|
STAGING_ORIGIN,
|
|
45
50
|
getOrigin
|
|
@@ -385,9 +390,13 @@ async function probeClaudePermissions(bin = "claude") {
|
|
|
385
390
|
return claudePermissionSupport(await exec(bin, ["--help"]));
|
|
386
391
|
}
|
|
387
392
|
async function probeClaude(bin = "claude") {
|
|
388
|
-
const
|
|
393
|
+
const [versionOut, auth] = await Promise.all([
|
|
394
|
+
exec(bin, ["--version"]),
|
|
395
|
+
exec(bin, ["auth", "status", "--json"])
|
|
396
|
+
]);
|
|
397
|
+
const version = versionOut?.trim().split(/\s+/)[0];
|
|
389
398
|
if (!version) return null;
|
|
390
|
-
const { signedIn, account } = claudeAccount(
|
|
399
|
+
const { signedIn, account } = claudeAccount(auth);
|
|
391
400
|
return {
|
|
392
401
|
id: "claude-code",
|
|
393
402
|
name: "Claude Code",
|
|
@@ -639,9 +648,11 @@ function codexAccount(ok, out2) {
|
|
|
639
648
|
return { signedIn: true, account: /chatgpt/i.test(out2) ? "ChatGPT" : "API key" };
|
|
640
649
|
}
|
|
641
650
|
async function probeCodex(bin = "codex") {
|
|
642
|
-
const version = await
|
|
651
|
+
const [version, status] = await Promise.all([
|
|
652
|
+
exec2(bin, ["--version"]),
|
|
653
|
+
exec2(bin, ["login", "status"])
|
|
654
|
+
]);
|
|
643
655
|
if (!version.ok) return null;
|
|
644
|
-
const status = await exec2(bin, ["login", "status"]);
|
|
645
656
|
const { signedIn, account } = codexAccount(status.ok, status.out);
|
|
646
657
|
return {
|
|
647
658
|
id: "codex",
|
|
@@ -1131,7 +1142,7 @@ function parsePicks(answer, max) {
|
|
|
1131
1142
|
return [...new Set(picks)];
|
|
1132
1143
|
}
|
|
1133
1144
|
function rerunCommand(argv, script = process.argv[1] ?? "") {
|
|
1134
|
-
const base = script.includes("/_npx/") ? "npx -y @cloop/runner" : "cloop";
|
|
1145
|
+
const base = script.includes("/_npx/") ? "npx -y @cloop/runner@latest" : "cloop";
|
|
1135
1146
|
const staging = process.env.CLOOP_ORIGIN === STAGING_ORIGIN ? ["--staging"] : [];
|
|
1136
1147
|
return [base, "connect", ...staging, ...argv].join(" ");
|
|
1137
1148
|
}
|
|
@@ -1353,7 +1364,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
1353
1364
|
readEnvironment: async () => {
|
|
1354
1365
|
const environment = await readEnvironment(t3Url);
|
|
1355
1366
|
out(
|
|
1356
|
-
`${bold("Cloop runner")} Connecting ${environment.label} (T3 ${environment.serverVersion}) to Cloop.`
|
|
1367
|
+
`${bold("Cloop runner")} Connecting ${shortMachineName(environment.label)} (T3 ${environment.serverVersion}) to Cloop with @cloop/runner ${VERSION}.`
|
|
1357
1368
|
);
|
|
1358
1369
|
return environment;
|
|
1359
1370
|
},
|
|
@@ -1436,7 +1447,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
|
1436
1447
|
version: `${harness.name} ${harness.version ?? ""}`.trim()
|
|
1437
1448
|
};
|
|
1438
1449
|
out(
|
|
1439
|
-
`${bold("Cloop runner")} Connecting ${deviceName} as a Local runner with ${harnessLine(harness)}.`
|
|
1450
|
+
`${bold("Cloop runner")} Connecting ${deviceName} as a Local runner with ${harnessLine(harness)}, using @cloop/runner ${VERSION}.`
|
|
1440
1451
|
);
|
|
1441
1452
|
attempt.step = "login";
|
|
1442
1453
|
const deviceToken = await deviceLogin({ origin: getOrigin(), deviceName, device });
|
|
@@ -1518,17 +1529,56 @@ async function connect(argv, attempt, deps = {}) {
|
|
|
1518
1529
|
}
|
|
1519
1530
|
);
|
|
1520
1531
|
attempt.harnesses = harnessesFound(found);
|
|
1532
|
+
const current = await claudeAtFloor(found, forced, {
|
|
1533
|
+
update: deps.updateClaude ?? updateClaude,
|
|
1534
|
+
ask: deps.ask === void 0 ? terminalYesNo() : deps.ask
|
|
1535
|
+
});
|
|
1521
1536
|
const workstation = isWorkstation(previous, boxServiceInstalled());
|
|
1522
|
-
const choice = chooseDriver(
|
|
1537
|
+
const choice = chooseDriver(current, forced, workstation);
|
|
1523
1538
|
if (!choice.ok) throw new ConnectFailure(choice.code, choice.line);
|
|
1524
|
-
const local = fallbackDriver(
|
|
1539
|
+
const local = fallbackDriver(current, forced, workstation);
|
|
1525
1540
|
await connectChosen(choice.driver, attempt, {
|
|
1526
1541
|
t3: () => connectT3(argv, attempt, local ? HARNESS_NAME[local] : null, forced, deps.services),
|
|
1527
|
-
local: (driver) => connectLocal(driver,
|
|
1528
|
-
fallback: () => fallbackDriver(
|
|
1542
|
+
local: (driver) => connectLocal(driver, current, argv, attempt, forced, deps.services),
|
|
1543
|
+
fallback: () => fallbackDriver(current, forced, workstation),
|
|
1529
1544
|
say: (line2) => out(`${bold("Cloop runner")} ${line2}`)
|
|
1530
1545
|
});
|
|
1531
1546
|
}
|
|
1547
|
+
async function claudeAtFloor(found, forced, deps) {
|
|
1548
|
+
const version = found.claude?.version;
|
|
1549
|
+
if (!version || forced === "codex" || !olderThan(version, CLAUDE_FLOOR)) return found;
|
|
1550
|
+
const fix = "Run `claude update`, then run `cloop connect` again.";
|
|
1551
|
+
const answer = deps.ask ? await deps.ask(`${claudeTooOld(version)} Update it now with \`claude update\`? (Y/n) `) : null;
|
|
1552
|
+
if (answer === null || answer.trim() && !isYes(answer))
|
|
1553
|
+
throw new ConnectFailure("harness_outdated", `${claudeTooOld(version)} ${fix}`);
|
|
1554
|
+
const claude = await deps.update();
|
|
1555
|
+
if (!claude?.version || olderThan(claude.version, CLAUDE_FLOOR))
|
|
1556
|
+
throw new ConnectFailure("harness_outdated", `Claude Code did not update. ${fix}`);
|
|
1557
|
+
out(`${bold("Cloop runner")} Claude Code updated to ${claude.version}.`);
|
|
1558
|
+
return { ...found, claude };
|
|
1559
|
+
}
|
|
1560
|
+
async function updateClaude() {
|
|
1561
|
+
try {
|
|
1562
|
+
execFileSync("claude", ["update"], { stdio: "inherit", timeout: 3e5 });
|
|
1563
|
+
} catch {
|
|
1564
|
+
return null;
|
|
1565
|
+
}
|
|
1566
|
+
return probeClaude();
|
|
1567
|
+
}
|
|
1568
|
+
function terminalYesNo() {
|
|
1569
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) return null;
|
|
1570
|
+
return async (question) => {
|
|
1571
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
1572
|
+
try {
|
|
1573
|
+
return await askOrClosed(
|
|
1574
|
+
prompt,
|
|
1575
|
+
() => new ConnectFailure("harness_outdated", "No answer.")
|
|
1576
|
+
)(question);
|
|
1577
|
+
} finally {
|
|
1578
|
+
prompt.close();
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1532
1582
|
async function runConnect(argv, deps = {}) {
|
|
1533
1583
|
const attempt = newAttempt();
|
|
1534
1584
|
let error = null;
|
|
@@ -1597,6 +1647,7 @@ export {
|
|
|
1597
1647
|
detect,
|
|
1598
1648
|
harnessesFound,
|
|
1599
1649
|
rememberedDriver,
|
|
1650
|
+
claudeAtFloor,
|
|
1600
1651
|
runConnect,
|
|
1601
1652
|
connectCommand
|
|
1602
1653
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
RUN_TEXT_MAX
|
|
4
|
+
} from "./chunk-EN3XHHWJ.js";
|
|
2
5
|
import {
|
|
3
6
|
CONFIG_DIR
|
|
4
7
|
} from "./chunk-3DIGCVL4.js";
|
|
@@ -159,7 +162,7 @@ var BoxWatch = class {
|
|
|
159
162
|
thread_id: e.thread_id,
|
|
160
163
|
kind,
|
|
161
164
|
...event.kind === "question" ? { question_id: event.question_id } : {},
|
|
162
|
-
...summary ? { summary: summary.slice(0,
|
|
165
|
+
...summary ? { summary: summary.slice(0, RUN_TEXT_MAX) } : {},
|
|
163
166
|
..."result" in event && event.result ? { result: event.result } : {},
|
|
164
167
|
..."pr_url" in event && event.pr_url ? { pr_url: event.pr_url } : {},
|
|
165
168
|
..."error" in event && event.error ? { error: event.error } : {},
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
findRun
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NK6MHHYP.js";
|
|
5
5
|
import {
|
|
6
6
|
localRunsFilePath,
|
|
7
7
|
readRunRecords,
|
|
8
8
|
takeoverSummary
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QLCIEJ4C.js";
|
|
10
10
|
import {
|
|
11
11
|
lockThreadsFile,
|
|
12
12
|
threadsFilePath
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-3B5JV6ZP.js";
|
|
14
14
|
import {
|
|
15
15
|
isLocal,
|
|
16
16
|
readRunnerConfig
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-EN3XHHWJ.js";
|
|
18
18
|
import {
|
|
19
19
|
shortMachineName
|
|
20
20
|
} from "./chunk-JX6VG5FE.js";
|
|
@@ -6,6 +6,178 @@ 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
|
+
"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."
|
|
17
|
+
].join("\n");
|
|
18
|
+
var text = (v, max) => typeof v === "string" && v.length <= max;
|
|
19
|
+
var optionalText = (v, max) => v === void 0 || text(v, max);
|
|
20
|
+
var https = (v) => {
|
|
21
|
+
try {
|
|
22
|
+
return typeof v === "string" && new URL(v).protocol === "https:";
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
28
|
+
var prNumber = (url) => Number(url.slice(url.lastIndexOf("/") + 1));
|
|
29
|
+
function prUrlIn(text2) {
|
|
30
|
+
const urls = text2?.match(PR_URL) ?? [];
|
|
31
|
+
return urls.reduce(
|
|
32
|
+
(newest, url) => newest && prNumber(newest) >= prNumber(url) ? newest : url,
|
|
33
|
+
null
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function resultPrUrl(finalMessage) {
|
|
37
|
+
const result = parseRunResult(finalMessage);
|
|
38
|
+
if (!result) return prUrlIn(finalMessage);
|
|
39
|
+
const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
|
|
40
|
+
return prs.at(-1) ?? null;
|
|
41
|
+
}
|
|
42
|
+
var SUMMARY_MAX = 500;
|
|
43
|
+
var DOC_BODY_MAX = 8e3;
|
|
44
|
+
function addressOutput(url) {
|
|
45
|
+
const pr = url.match(/\/pull\/(\d+)$/);
|
|
46
|
+
if (pr && prUrlIn(url) === url) return { kind: "pr", title: `Pull request #${pr[1]}`, url };
|
|
47
|
+
const { host, pathname } = new URL(url);
|
|
48
|
+
return { kind: "link", title: `${host}${pathname === "/" ? "" : pathname}`.slice(0, 120), url };
|
|
49
|
+
}
|
|
50
|
+
function cleanOutput(o) {
|
|
51
|
+
if (typeof o === "string") return https(o.trim()) ? addressOutput(o.trim()) : null;
|
|
52
|
+
if (!o || typeof o !== "object") return null;
|
|
53
|
+
const out = o;
|
|
54
|
+
if (!text(out.title, 120)) return null;
|
|
55
|
+
const title = out.title;
|
|
56
|
+
switch (out.kind) {
|
|
57
|
+
case "pr":
|
|
58
|
+
case "link":
|
|
59
|
+
return https(out.url) ? { kind: out.kind, title, url: out.url } : null;
|
|
60
|
+
case "draft":
|
|
61
|
+
return text(out.body, 4e3) && optionalText(out.to, 200) ? {
|
|
62
|
+
kind: "draft",
|
|
63
|
+
title,
|
|
64
|
+
body: out.body,
|
|
65
|
+
...out.to !== void 0 ? { to: out.to } : {}
|
|
66
|
+
} : null;
|
|
67
|
+
case "doc": {
|
|
68
|
+
const body = typeof out.body === "string" && out.body.length > DOC_BODY_MAX ? `${out.body.slice(0, DOC_BODY_MAX - 1)}\u2026` : out.body;
|
|
69
|
+
return optionalText(body, DOC_BODY_MAX) && (out.url === void 0 || https(out.url)) ? {
|
|
70
|
+
kind: "doc",
|
|
71
|
+
title,
|
|
72
|
+
...out.url !== void 0 ? { url: out.url } : {},
|
|
73
|
+
...body !== void 0 ? { body } : {}
|
|
74
|
+
} : null;
|
|
75
|
+
}
|
|
76
|
+
case "file":
|
|
77
|
+
return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
|
|
78
|
+
default:
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function cleanCheck(c) {
|
|
83
|
+
if (!c || typeof c !== "object") return null;
|
|
84
|
+
const check = c;
|
|
85
|
+
if (!text(check.name, 80) || !["passed", "failed", "skipped"].includes(check.outcome))
|
|
86
|
+
return null;
|
|
87
|
+
if (!optionalText(check.detail, 200)) return null;
|
|
88
|
+
return {
|
|
89
|
+
name: check.name,
|
|
90
|
+
outcome: check.outcome,
|
|
91
|
+
...check.detail !== void 0 ? { detail: check.detail } : {}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function readRunResult(message) {
|
|
95
|
+
const none = { dropped: { outputs: 0, checks: 0 } };
|
|
96
|
+
const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
|
|
97
|
+
if (!block) return none;
|
|
98
|
+
try {
|
|
99
|
+
const value = JSON.parse(block);
|
|
100
|
+
const summary = typeof value?.summary === "string" ? value.summary.trim() : "";
|
|
101
|
+
if (!summary) return none;
|
|
102
|
+
const list = (v) => Array.isArray(v) ? v : [];
|
|
103
|
+
const outputs = list(value.outputs).flatMap((o) => cleanOutput(o) ?? []);
|
|
104
|
+
const checks = list(value.checks).flatMap((c) => cleanCheck(c) ?? []);
|
|
105
|
+
return {
|
|
106
|
+
result: {
|
|
107
|
+
summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
|
|
108
|
+
outputs: outputs.slice(0, 10),
|
|
109
|
+
checks: checks.slice(0, 10)
|
|
110
|
+
},
|
|
111
|
+
dropped: {
|
|
112
|
+
outputs: list(value.outputs).length - outputs.length,
|
|
113
|
+
checks: list(value.checks).length - checks.length
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
} catch {
|
|
117
|
+
return none;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function parseRunResult(message) {
|
|
121
|
+
return readRunResult(message).result;
|
|
122
|
+
}
|
|
123
|
+
function droppedLine(dropped, run) {
|
|
124
|
+
return dropped.outputs || dropped.checks ? `result_items_dropped run=${run} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/drivers/driver.ts
|
|
128
|
+
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
129
|
+
"approval-required",
|
|
130
|
+
"auto-accept-edits",
|
|
131
|
+
"auto",
|
|
132
|
+
"full-access"
|
|
133
|
+
]);
|
|
134
|
+
var BoxToolError = class extends Error {
|
|
135
|
+
constructor(code) {
|
|
136
|
+
super(code);
|
|
137
|
+
this.code = code;
|
|
138
|
+
this.name = "BoxToolError";
|
|
139
|
+
}
|
|
140
|
+
code;
|
|
141
|
+
};
|
|
142
|
+
var CLOOP_THREAD_PREFIX = "cloop:";
|
|
143
|
+
function questionLine(questions) {
|
|
144
|
+
return questions.map(
|
|
145
|
+
(x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
|
|
146
|
+
).join(" ").slice(0, 500);
|
|
147
|
+
}
|
|
148
|
+
function isProgressSentence(value) {
|
|
149
|
+
return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
|
|
150
|
+
}
|
|
151
|
+
var PROGRESS_MS = 3e4;
|
|
152
|
+
var RUN_TEXT_MAX = 4e3;
|
|
153
|
+
function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
|
|
154
|
+
const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, RUN_TEXT_MAX);
|
|
155
|
+
if (!isProgressSentence(summary)) return null;
|
|
156
|
+
if (!force && now - clock.lastProgressAt < ms) return null;
|
|
157
|
+
clock.lastProgressAt = now;
|
|
158
|
+
return summary;
|
|
159
|
+
}
|
|
160
|
+
var YES_WORDS = /* @__PURE__ */ new Set([
|
|
161
|
+
"y",
|
|
162
|
+
"yes",
|
|
163
|
+
"yep",
|
|
164
|
+
"yeah",
|
|
165
|
+
"allow",
|
|
166
|
+
"allow it",
|
|
167
|
+
"ok",
|
|
168
|
+
"okay",
|
|
169
|
+
"approve",
|
|
170
|
+
"approved",
|
|
171
|
+
"go ahead",
|
|
172
|
+
"sure",
|
|
173
|
+
"do it"
|
|
174
|
+
]);
|
|
175
|
+
function isYes(reply) {
|
|
176
|
+
return YES_WORDS.has(
|
|
177
|
+
reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
9
181
|
// src/run-log.ts
|
|
10
182
|
import {
|
|
11
183
|
appendFileSync,
|
|
@@ -223,170 +395,6 @@ function whichAll(bin) {
|
|
|
223
395
|
|
|
224
396
|
// src/drivers/t3.ts
|
|
225
397
|
import { execFile, execFileSync as execFileSync2 } from "child_process";
|
|
226
|
-
|
|
227
|
-
// src/run-result.ts
|
|
228
|
-
var RESULT_INSTRUCTION = [
|
|
229
|
-
"When you finish, end your final message with a fenced block tagged cloop-result containing JSON, for example:",
|
|
230
|
-
"```cloop-result",
|
|
231
|
-
'{"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"}]}',
|
|
232
|
-
"```",
|
|
233
|
-
"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."
|
|
234
|
-
].join("\n");
|
|
235
|
-
var text = (v, max) => typeof v === "string" && v.length <= max;
|
|
236
|
-
var optionalText = (v, max) => v === void 0 || text(v, max);
|
|
237
|
-
var https = (v) => {
|
|
238
|
-
try {
|
|
239
|
-
return typeof v === "string" && new URL(v).protocol === "https:";
|
|
240
|
-
} catch {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
var PR_URL = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+/g;
|
|
245
|
-
function prUrlIn(text2) {
|
|
246
|
-
return text2?.match(PR_URL)?.at(-1) ?? null;
|
|
247
|
-
}
|
|
248
|
-
function resultPrUrl(finalMessage) {
|
|
249
|
-
const result = parseRunResult(finalMessage);
|
|
250
|
-
if (!result) return prUrlIn(finalMessage);
|
|
251
|
-
const prs = result.outputs.flatMap((o) => o.kind === "pr" ? [o.url] : []);
|
|
252
|
-
return prs.at(-1) ?? null;
|
|
253
|
-
}
|
|
254
|
-
var SUMMARY_MAX = 500;
|
|
255
|
-
function addressOutput(url) {
|
|
256
|
-
const pr = url.match(/\/pull\/(\d+)$/);
|
|
257
|
-
if (pr && prUrlIn(url) === url) return { kind: "pr", title: `Pull request #${pr[1]}`, url };
|
|
258
|
-
const { host, pathname } = new URL(url);
|
|
259
|
-
return { kind: "link", title: `${host}${pathname === "/" ? "" : pathname}`.slice(0, 120), url };
|
|
260
|
-
}
|
|
261
|
-
function cleanOutput(o) {
|
|
262
|
-
if (typeof o === "string") return https(o.trim()) ? addressOutput(o.trim()) : null;
|
|
263
|
-
if (!o || typeof o !== "object") return null;
|
|
264
|
-
const out = o;
|
|
265
|
-
if (!text(out.title, 120)) return null;
|
|
266
|
-
const title = out.title;
|
|
267
|
-
switch (out.kind) {
|
|
268
|
-
case "pr":
|
|
269
|
-
case "link":
|
|
270
|
-
return https(out.url) ? { kind: out.kind, title, url: out.url } : null;
|
|
271
|
-
case "draft":
|
|
272
|
-
return text(out.body, 4e3) && optionalText(out.to, 200) ? {
|
|
273
|
-
kind: "draft",
|
|
274
|
-
title,
|
|
275
|
-
body: out.body,
|
|
276
|
-
...out.to !== void 0 ? { to: out.to } : {}
|
|
277
|
-
} : null;
|
|
278
|
-
case "doc":
|
|
279
|
-
return optionalText(out.body, 8e3) && (out.url === void 0 || https(out.url)) ? {
|
|
280
|
-
kind: "doc",
|
|
281
|
-
title,
|
|
282
|
-
...out.url !== void 0 ? { url: out.url } : {},
|
|
283
|
-
...out.body !== void 0 ? { body: out.body } : {}
|
|
284
|
-
} : null;
|
|
285
|
-
case "file":
|
|
286
|
-
return text(out.path, 400) ? { kind: "file", title, path: out.path } : null;
|
|
287
|
-
default:
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function cleanCheck(c) {
|
|
292
|
-
if (!c || typeof c !== "object") return null;
|
|
293
|
-
const check = c;
|
|
294
|
-
if (!text(check.name, 80) || !["passed", "failed", "skipped"].includes(check.outcome))
|
|
295
|
-
return null;
|
|
296
|
-
if (!optionalText(check.detail, 200)) return null;
|
|
297
|
-
return {
|
|
298
|
-
name: check.name,
|
|
299
|
-
outcome: check.outcome,
|
|
300
|
-
...check.detail !== void 0 ? { detail: check.detail } : {}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function readRunResult(message) {
|
|
304
|
-
const none = { dropped: { outputs: 0, checks: 0 } };
|
|
305
|
-
const block = [...(message ?? "").matchAll(/```cloop-result\s*\n([\s\S]*?)```/g)].at(-1)?.[1];
|
|
306
|
-
if (!block) return none;
|
|
307
|
-
try {
|
|
308
|
-
const value = JSON.parse(block);
|
|
309
|
-
const summary = typeof value?.summary === "string" ? value.summary.trim() : "";
|
|
310
|
-
if (!summary) return none;
|
|
311
|
-
const list = (v) => Array.isArray(v) ? v : [];
|
|
312
|
-
const outputs = list(value.outputs).flatMap((o) => cleanOutput(o) ?? []);
|
|
313
|
-
const checks = list(value.checks).flatMap((c) => cleanCheck(c) ?? []);
|
|
314
|
-
return {
|
|
315
|
-
result: {
|
|
316
|
-
summary: summary.length > SUMMARY_MAX ? `${summary.slice(0, SUMMARY_MAX - 1)}\u2026` : summary,
|
|
317
|
-
outputs: outputs.slice(0, 10),
|
|
318
|
-
checks: checks.slice(0, 10)
|
|
319
|
-
},
|
|
320
|
-
dropped: {
|
|
321
|
-
outputs: list(value.outputs).length - outputs.length,
|
|
322
|
-
checks: list(value.checks).length - checks.length
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
} catch {
|
|
326
|
-
return none;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function parseRunResult(message) {
|
|
330
|
-
return readRunResult(message).result;
|
|
331
|
-
}
|
|
332
|
-
function droppedLine(dropped, run) {
|
|
333
|
-
return dropped.outputs || dropped.checks ? `result_items_dropped run=${run} outputs=${dropped.outputs} checks=${dropped.checks}` : null;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// src/drivers/driver.ts
|
|
337
|
-
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
338
|
-
"approval-required",
|
|
339
|
-
"auto-accept-edits",
|
|
340
|
-
"auto",
|
|
341
|
-
"full-access"
|
|
342
|
-
]);
|
|
343
|
-
var BoxToolError = class extends Error {
|
|
344
|
-
constructor(code) {
|
|
345
|
-
super(code);
|
|
346
|
-
this.code = code;
|
|
347
|
-
this.name = "BoxToolError";
|
|
348
|
-
}
|
|
349
|
-
code;
|
|
350
|
-
};
|
|
351
|
-
var CLOOP_THREAD_PREFIX = "cloop:";
|
|
352
|
-
function questionLine(questions) {
|
|
353
|
-
return questions.map(
|
|
354
|
-
(x) => x.options?.length ? `${x.question} (${x.options.map((o) => o.label).join(", ")})` : x.question
|
|
355
|
-
).join(" ").slice(0, 500);
|
|
356
|
-
}
|
|
357
|
-
function isProgressSentence(value) {
|
|
358
|
-
return typeof value === "string" && /\S[ \t]+\S/.test(value.trim().split(/\r?\n/)[0] ?? "");
|
|
359
|
-
}
|
|
360
|
-
var PROGRESS_MS = 3e4;
|
|
361
|
-
function nextProgress(clock, text2, now, ms = PROGRESS_MS, force = false) {
|
|
362
|
-
const summary = (parseRunResult(text2)?.summary ?? text2.split("```cloop-result")[0] ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
|
|
363
|
-
if (!isProgressSentence(summary)) return null;
|
|
364
|
-
if (!force && now - clock.lastProgressAt < ms) return null;
|
|
365
|
-
clock.lastProgressAt = now;
|
|
366
|
-
return summary;
|
|
367
|
-
}
|
|
368
|
-
var YES_WORDS = /* @__PURE__ */ new Set([
|
|
369
|
-
"y",
|
|
370
|
-
"yes",
|
|
371
|
-
"yep",
|
|
372
|
-
"yeah",
|
|
373
|
-
"allow",
|
|
374
|
-
"allow it",
|
|
375
|
-
"ok",
|
|
376
|
-
"okay",
|
|
377
|
-
"approve",
|
|
378
|
-
"approved",
|
|
379
|
-
"go ahead",
|
|
380
|
-
"sure",
|
|
381
|
-
"do it"
|
|
382
|
-
]);
|
|
383
|
-
function isYes(reply) {
|
|
384
|
-
return YES_WORDS.has(
|
|
385
|
-
reply.trim().toLowerCase().replace(/[.!\s]+$/, "")
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// src/drivers/t3.ts
|
|
390
398
|
function isUnsettled(t) {
|
|
391
399
|
return !t.settledAt && !t.archivedAt && !isChild(t);
|
|
392
400
|
}
|
|
@@ -468,7 +476,7 @@ function outcomeOf(p) {
|
|
|
468
476
|
settled,
|
|
469
477
|
kind: settled ? status === "completed" || !run ? "settled" : "failed" : null,
|
|
470
478
|
pr_url: resultPrUrl(text2),
|
|
471
|
-
last_assistant_text: text2 ? text2.slice(0,
|
|
479
|
+
last_assistant_text: text2 ? text2.slice(0, RUN_TEXT_MAX) : null,
|
|
472
480
|
...result ? { result } : {},
|
|
473
481
|
...dropped.outputs || dropped.checks ? { dropped } : {}
|
|
474
482
|
};
|
|
@@ -1181,6 +1189,7 @@ export {
|
|
|
1181
1189
|
CLOOP_THREAD_PREFIX,
|
|
1182
1190
|
questionLine,
|
|
1183
1191
|
isProgressSentence,
|
|
1192
|
+
RUN_TEXT_MAX,
|
|
1184
1193
|
nextProgress,
|
|
1185
1194
|
isYes,
|
|
1186
1195
|
runLogDir,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
localRunsFilePath,
|
|
4
4
|
readRunRecords
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QLCIEJ4C.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-
|
|
13
|
+
} from "./chunk-EN3XHHWJ.js";
|
|
14
14
|
import {
|
|
15
15
|
sanitizeLabel,
|
|
16
16
|
stripControl
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BoxToolError,
|
|
4
4
|
RESULT_INSTRUCTION,
|
|
5
|
+
RUN_TEXT_MAX,
|
|
5
6
|
STOPPED_SUMMARY,
|
|
6
7
|
appendRunLog,
|
|
7
8
|
droppedLine,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
readRunResult,
|
|
16
17
|
resultPrUrl,
|
|
17
18
|
runLogDir
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EN3XHHWJ.js";
|
|
19
20
|
import {
|
|
20
21
|
CONFIG_DIR
|
|
21
22
|
} from "./chunk-3DIGCVL4.js";
|
|
@@ -26,6 +27,50 @@ import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "f
|
|
|
26
27
|
import { homedir, hostname } from "os";
|
|
27
28
|
import { basename, dirname, join } from "path";
|
|
28
29
|
import { createInterface } from "readline";
|
|
30
|
+
|
|
31
|
+
// src/drivers/harness-check.ts
|
|
32
|
+
var HARNESS_STALE_MS = 5 * 6e4;
|
|
33
|
+
var FIRST_CHECK_WAIT_MS = 3e3;
|
|
34
|
+
var HarnessCheck = class {
|
|
35
|
+
constructor(probe, opts) {
|
|
36
|
+
this.probe = probe;
|
|
37
|
+
this.opts = opts;
|
|
38
|
+
}
|
|
39
|
+
probe;
|
|
40
|
+
opts;
|
|
41
|
+
last = null;
|
|
42
|
+
running = null;
|
|
43
|
+
/** Starts a probe unless one is running. It never rejects. */
|
|
44
|
+
refresh() {
|
|
45
|
+
this.running ??= this.probe().then(
|
|
46
|
+
(harnesses) => {
|
|
47
|
+
this.last = { harnesses, at: this.opts.now() };
|
|
48
|
+
},
|
|
49
|
+
(err) => this.opts.log(`harness probe failed: ${err?.message}`)
|
|
50
|
+
).finally(() => {
|
|
51
|
+
this.running = null;
|
|
52
|
+
});
|
|
53
|
+
return this.running;
|
|
54
|
+
}
|
|
55
|
+
async read() {
|
|
56
|
+
if (!this.last) {
|
|
57
|
+
let timer;
|
|
58
|
+
await Promise.race([
|
|
59
|
+
this.refresh(),
|
|
60
|
+
new Promise((resolve) => {
|
|
61
|
+
timer = setTimeout(resolve, FIRST_CHECK_WAIT_MS);
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
} else if (this.opts.now() - this.last.at > HARNESS_STALE_MS) {
|
|
66
|
+
void this.refresh();
|
|
67
|
+
}
|
|
68
|
+
const last = this.last;
|
|
69
|
+
return last ? { harnesses: last.harnesses, checkedAt: new Date(last.at).toISOString(), probing: false } : { harnesses: [], checkedAt: null, probing: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/drivers/local.ts
|
|
29
74
|
var STOPPED = { kind: "failed", summary: STOPPED_SUMMARY };
|
|
30
75
|
function takeoverSummary(machine) {
|
|
31
76
|
return `You took this over on ${machine}.`;
|
|
@@ -115,6 +160,10 @@ var LocalDriver = class {
|
|
|
115
160
|
constructor(deps) {
|
|
116
161
|
this.deps = deps;
|
|
117
162
|
this.name = deps.dialect.name;
|
|
163
|
+
this.harnessCheck = new HarnessCheck(
|
|
164
|
+
deps.harnesses ?? (async () => [await deps.dialect.probe()].filter((h) => h !== null)),
|
|
165
|
+
{ now: () => this.now(), log: (line) => this.log(line) }
|
|
166
|
+
);
|
|
118
167
|
this.capabilities = deps.dialect.capabilities;
|
|
119
168
|
this.runs = new Map(this.load().map((r) => [r.work_id, r]));
|
|
120
169
|
this.logDir = deps.logDir ?? runLogDir(this.file);
|
|
@@ -135,6 +184,7 @@ var LocalDriver = class {
|
|
|
135
184
|
stopping = false;
|
|
136
185
|
logDir;
|
|
137
186
|
logFailed = false;
|
|
187
|
+
harnessCheck;
|
|
138
188
|
get repo() {
|
|
139
189
|
return this.deps.repo ?? gitProbe;
|
|
140
190
|
}
|
|
@@ -157,13 +207,19 @@ var LocalDriver = class {
|
|
|
157
207
|
now() {
|
|
158
208
|
return this.deps.now?.() ?? Date.now();
|
|
159
209
|
}
|
|
210
|
+
/** Probes the harnesses now, so the first status after the daemon starts answers at once. */
|
|
211
|
+
warmHarnesses() {
|
|
212
|
+
void this.harnessCheck.refresh();
|
|
213
|
+
}
|
|
160
214
|
async status() {
|
|
161
|
-
const
|
|
215
|
+
const { harnesses, checkedAt, probing } = await this.harnessCheck.read();
|
|
162
216
|
const all = [...this.runs.values()];
|
|
163
217
|
const unsettled = all.filter((r) => !r.end);
|
|
164
218
|
return {
|
|
165
219
|
box: { label: this.deps.label ?? hostname(), driver: this.name },
|
|
166
220
|
harnesses,
|
|
221
|
+
harnesses_checked_at: checkedAt,
|
|
222
|
+
...probing ? { probing: true } : {},
|
|
167
223
|
clients: null,
|
|
168
224
|
projects: this.deps.repos.map((r) => r.label),
|
|
169
225
|
threads: {
|
|
@@ -517,7 +573,7 @@ ${RESULT_INSTRUCTION}`));
|
|
|
517
573
|
await this.end(r, {
|
|
518
574
|
kind: "settled",
|
|
519
575
|
...result ? { result } : {},
|
|
520
|
-
...summary ? { summary: summary.slice(0,
|
|
576
|
+
...summary ? { summary: summary.slice(0, RUN_TEXT_MAX) } : {},
|
|
521
577
|
...pr ? { pr_url: pr } : {}
|
|
522
578
|
});
|
|
523
579
|
return;
|
|
@@ -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
|
+
};
|
|
@@ -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-
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import "./chunk-
|
|
42
|
+
} from "./chunk-34XAQRBL.js";
|
|
43
|
+
import "./chunk-3B5JV6ZP.js";
|
|
44
|
+
import "./chunk-EN3XHHWJ.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-
|
|
48
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-3ITSIARB.js";
|
|
50
|
+
import "./chunk-2PVKRGOX.js";
|
|
49
51
|
import "./chunk-AG6SI6I2.js";
|
|
50
|
-
import "./chunk-
|
|
52
|
+
import "./chunk-NOABXLW3.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,28 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
localRunsFilePath
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QLCIEJ4C.js";
|
|
5
5
|
import {
|
|
6
6
|
installedService,
|
|
7
7
|
revokeOwnDevice,
|
|
8
8
|
runSteps,
|
|
9
9
|
tokenGone
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-34XAQRBL.js";
|
|
11
11
|
import {
|
|
12
12
|
runnerStatePath,
|
|
13
13
|
threadsFilePath
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3B5JV6ZP.js";
|
|
15
15
|
import {
|
|
16
16
|
boxPath,
|
|
17
17
|
readRunnerConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EN3XHHWJ.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-
|
|
23
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-3ITSIARB.js";
|
|
24
|
+
import "./chunk-2PVKRGOX.js";
|
|
24
25
|
import "./chunk-AG6SI6I2.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-NOABXLW3.js";
|
|
26
27
|
import {
|
|
27
28
|
getOrigin
|
|
28
29
|
} from "./chunk-3DIGCVL4.js";
|
|
@@ -31,7 +32,7 @@ import {
|
|
|
31
32
|
import { execFileSync } from "child_process";
|
|
32
33
|
import { existsSync, readFileSync, rmSync } from "fs";
|
|
33
34
|
import { homedir } from "os";
|
|
34
|
-
var DONE_LINE = "This computer is no longer a Cloop runner. To connect it again: npx -y @cloop/runner connect";
|
|
35
|
+
var DONE_LINE = "This computer is no longer a Cloop runner. To connect it again: npx -y @cloop/runner@latest connect";
|
|
35
36
|
function unitOrigin(contents) {
|
|
36
37
|
const plist = /<key>CLOOP_ORIGIN<\/key><string>([^<]+)<\/string>/.exec(contents)?.[1];
|
|
37
38
|
if (plist) return plist.replace(/&/g, "&");
|
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-
|
|
7
|
+
} from "./chunk-NOABXLW3.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-
|
|
68
|
+
const { loginCommand } = await import("./login-XS2IFIUX.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-
|
|
78
|
+
const { startMcpServer } = await import("./mcp-server-R47CKE6A.js");
|
|
71
79
|
await startMcpServer();
|
|
72
80
|
break;
|
|
73
81
|
}
|
|
74
82
|
case "statusline": {
|
|
75
|
-
const { statuslineCommand } = await import("./statusline-
|
|
83
|
+
const { statuslineCommand } = await import("./statusline-RI62KCQX.js");
|
|
76
84
|
statuslineCommand();
|
|
77
85
|
break;
|
|
78
86
|
}
|
|
79
87
|
case "connect": {
|
|
80
|
-
const { connectCommand } = await import("./connect-
|
|
88
|
+
const { connectCommand } = await import("./connect-LLURHARY.js");
|
|
81
89
|
await connectCommand(argv.slice(1));
|
|
82
90
|
break;
|
|
83
91
|
}
|
|
84
92
|
case "use": {
|
|
85
|
-
const { useCommand } = await import("./use-
|
|
93
|
+
const { useCommand } = await import("./use-2OOFS53J.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-
|
|
98
|
+
const { disconnectCommand } = await import("./disconnect-WAQTAXN3.js");
|
|
91
99
|
await disconnectCommand(argv.slice(1));
|
|
92
100
|
break;
|
|
93
101
|
}
|
|
94
102
|
case "box": {
|
|
95
|
-
const { boxCommand } = await import("./box-
|
|
103
|
+
const { boxCommand } = await import("./box-7SVME4E5.js");
|
|
96
104
|
await boxCommand(argv.slice(1));
|
|
97
105
|
break;
|
|
98
106
|
}
|
|
99
107
|
case "runs": {
|
|
100
|
-
const { runsCommand } = await import("./runs-
|
|
108
|
+
const { runsCommand } = await import("./runs-4ZJOIB5S.js");
|
|
101
109
|
process.exitCode = runsCommand();
|
|
102
110
|
break;
|
|
103
111
|
}
|
|
104
112
|
case "watch": {
|
|
105
|
-
const { watchCommand } = await import("./runs-
|
|
113
|
+
const { watchCommand } = await import("./runs-4ZJOIB5S.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-
|
|
118
|
+
const { takeoverCommand } = await import("./takeover-F5SEY7WI.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-
|
|
123
|
+
const { resumeCommand } = await import("./runs-4ZJOIB5S.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-
|
|
128
|
+
const { runnerCommand } = await import("./runner-R4Z62XVC.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-
|
|
6
|
+
} from "./chunk-2PVKRGOX.js";
|
|
7
7
|
import "./chunk-AG6SI6I2.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-NOABXLW3.js";
|
|
9
9
|
import "./chunk-3DIGCVL4.js";
|
|
10
10
|
export {
|
|
11
11
|
deviceLogin,
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
connectWebhook,
|
|
4
4
|
runnerCommand
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-3ITSIARB.js";
|
|
6
|
+
import "./chunk-2PVKRGOX.js";
|
|
7
7
|
import "./chunk-AG6SI6I2.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-NOABXLW3.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-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-NK6MHHYP.js";
|
|
12
|
+
import "./chunk-QLCIEJ4C.js";
|
|
13
|
+
import "./chunk-EN3XHHWJ.js";
|
|
14
14
|
import "./chunk-VK6GV757.js";
|
|
15
15
|
import "./chunk-3DIGCVL4.js";
|
|
16
16
|
export {
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
takeoverDir,
|
|
10
10
|
writeTakeoverReply,
|
|
11
11
|
writeTakeoverRequest
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-7CPNLUDI.js";
|
|
13
|
+
import "./chunk-NK6MHHYP.js";
|
|
14
|
+
import "./chunk-QLCIEJ4C.js";
|
|
15
|
+
import "./chunk-3B5JV6ZP.js";
|
|
16
|
+
import "./chunk-EN3XHHWJ.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-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-34XAQRBL.js";
|
|
6
|
+
import "./chunk-3B5JV6ZP.js";
|
|
7
7
|
import {
|
|
8
8
|
isLocal,
|
|
9
9
|
readRunnerConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EN3XHHWJ.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-
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-3ITSIARB.js";
|
|
16
|
+
import "./chunk-2PVKRGOX.js";
|
|
16
17
|
import "./chunk-AG6SI6I2.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-NOABXLW3.js";
|
|
18
19
|
import "./chunk-3DIGCVL4.js";
|
|
19
20
|
|
|
20
21
|
// src/commands/use.ts
|
package/package.json
CHANGED