@cloop/runner 0.2.10 → 0.3.1
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-P6LMNVYG.js → box-2SVXFDHE.js} +16 -15
- package/dist/{chunk-UL2WHOQJ.js → chunk-4H4SIIUH.js} +1 -1
- package/dist/{chunk-J6AEO3GT.js → chunk-5FZAHWPX.js} +1 -1
- package/dist/{chunk-NX2LAKNU.js → chunk-5LDFFQ4O.js} +712 -45
- package/dist/{chunk-HI3HDN35.js → chunk-6LC5XH3S.js} +3 -5
- package/dist/{chunk-C6EODIE5.js → chunk-DH6IJQG6.js} +8 -10
- package/dist/{chunk-AEWIRLRS.js → chunk-E5CKL2Q3.js} +1 -1
- package/dist/{chunk-3DIGCVL4.js → chunk-IKCGVBHA.js} +11 -0
- package/dist/{chunk-PRJBCKRP.js → chunk-N24VQSNB.js} +3 -3
- package/dist/{chunk-VNX4VJAM.js → chunk-NALGGZM6.js} +3 -3
- package/dist/{chunk-JX6VG5FE.js → chunk-NUU4GXGV.js} +1 -1
- package/dist/{chunk-AG6SI6I2.js → chunk-NYGELUTR.js} +1 -1
- package/dist/{chunk-MWWA2VH7.js → chunk-RPWSWVKD.js} +5 -2
- package/dist/{chunk-EN7WRLSI.js → chunk-TJXXWEJW.js} +192 -40
- package/dist/{connect-GURZFURZ.js → connect-NAHKIUBI.js} +9 -9
- package/dist/disconnect-KTTVOO6R.js +28 -0
- package/dist/{hook-activity-LBYV4WJW.js → hook-activity-I7TV7YG7.js} +4 -4
- package/dist/{hook-session-start-YSEV5DCB.js → hook-session-start-MFX6HR3W.js} +3 -3
- package/dist/index.js +17 -17
- package/dist/{install-HTDTCELB.js → install-EMEZBBK7.js} +1 -1
- package/dist/{login-DXPJ3ZOA.js → login-37QE2AGW.js} +4 -4
- package/dist/{mcp-server-4UMYMJ5P.js → mcp-server-FLCNIW4C.js} +6 -6
- package/dist/runner-EHVMTKAA.js +13 -0
- package/dist/{runs-HRDQ7YCY.js → runs-IDFJ3Z2K.js} +3 -4
- package/dist/{statusline-AV2F2IM4.js → statusline-HGIHZJY2.js} +3 -3
- package/dist/{takeover-PDYTQY5D.js → takeover-YUBFKEKJ.js} +7 -8
- package/dist/{use-52LTRRXJ.js → use-OLC3RTIL.js} +14 -10
- package/package.json +1 -1
- package/dist/chunk-DHUZXAK2.js +0 -640
- package/dist/disconnect-HGQW7TVG.js +0 -159
- package/dist/runner-SPOKUMLM.js +0 -13
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
localRunsFilePath,
|
|
4
|
-
readRunRecords
|
|
5
|
-
} from "./chunk-DHUZXAK2.js";
|
|
6
2
|
import {
|
|
7
3
|
STOPPED_SUMMARY,
|
|
8
4
|
isEndLogLine,
|
|
9
5
|
isLocal,
|
|
6
|
+
localRunsFilePath,
|
|
7
|
+
readRunRecords,
|
|
10
8
|
readRunnerConfig,
|
|
11
9
|
runLogDir,
|
|
12
10
|
runLogPath
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5LDFFQ4O.js";
|
|
14
12
|
import {
|
|
15
13
|
sanitizeLabel,
|
|
16
14
|
stripControl
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
findRun
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
localRunsFilePath,
|
|
7
|
-
readRunRecords,
|
|
8
|
-
takeoverSummary
|
|
9
|
-
} from "./chunk-DHUZXAK2.js";
|
|
4
|
+
} from "./chunk-6LC5XH3S.js";
|
|
10
5
|
import {
|
|
11
6
|
lockThreadsFile,
|
|
12
7
|
threadsFilePath
|
|
13
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RPWSWVKD.js";
|
|
14
9
|
import {
|
|
15
10
|
isLocal,
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
localRunsFilePath,
|
|
12
|
+
readRunRecords,
|
|
13
|
+
readRunnerConfig,
|
|
14
|
+
takeoverSummary
|
|
15
|
+
} from "./chunk-5LDFFQ4O.js";
|
|
18
16
|
import {
|
|
19
17
|
shortMachineName
|
|
20
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NUU4GXGV.js";
|
|
21
19
|
import {
|
|
22
20
|
sanitizeLabel
|
|
23
21
|
} from "./chunk-VK6GV757.js";
|
|
@@ -16,6 +16,15 @@ function applyEnvironmentFlag(argv) {
|
|
|
16
16
|
process.env.CLOOP_MESH_URL ??= process.env.CLOOP_ORIGIN;
|
|
17
17
|
return argv.filter((arg) => arg !== "--staging");
|
|
18
18
|
}
|
|
19
|
+
function pinRunnerEnvironment(runnerOrigin) {
|
|
20
|
+
if (!process.env.CLOOP_ORIGIN) originSource = runnerOrigin ? "runner" : "default";
|
|
21
|
+
process.env.CLOOP_ORIGIN ??= runnerOrigin ?? PRODUCTION_ORIGIN;
|
|
22
|
+
process.env.CLOOP_MESH_URL ??= process.env.CLOOP_ORIGIN;
|
|
23
|
+
}
|
|
24
|
+
var originSource;
|
|
25
|
+
function pinnedOriginSource() {
|
|
26
|
+
return originSource ?? "flag_or_env";
|
|
27
|
+
}
|
|
19
28
|
function configDir() {
|
|
20
29
|
return join(homedir(), CONFIG_DIR);
|
|
21
30
|
}
|
|
@@ -62,6 +71,8 @@ export {
|
|
|
62
71
|
CONFIG_DIR,
|
|
63
72
|
STAGING_ORIGIN,
|
|
64
73
|
applyEnvironmentFlag,
|
|
74
|
+
pinRunnerEnvironment,
|
|
75
|
+
pinnedOriginSource,
|
|
65
76
|
readCredentials,
|
|
66
77
|
writeCredentials,
|
|
67
78
|
getOrigin,
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ApiError,
|
|
4
4
|
api
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NYGELUTR.js";
|
|
6
6
|
import {
|
|
7
7
|
VERSION
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4H4SIIUH.js";
|
|
9
9
|
import {
|
|
10
10
|
getOrigin,
|
|
11
11
|
readCredentials,
|
|
12
12
|
writeCredentials
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IKCGVBHA.js";
|
|
14
14
|
|
|
15
15
|
// src/commands/login.ts
|
|
16
16
|
import { execFile } from "child_process";
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConnectFailure,
|
|
4
4
|
deviceLogin
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-N24VQSNB.js";
|
|
6
6
|
import {
|
|
7
7
|
ApiError,
|
|
8
8
|
ReauthError,
|
|
9
9
|
api
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NYGELUTR.js";
|
|
11
11
|
import {
|
|
12
12
|
CONFIG_DIR,
|
|
13
13
|
getOrigin,
|
|
14
14
|
readCredentials,
|
|
15
15
|
writeCredentials
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IKCGVBHA.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/runner.ts
|
|
19
19
|
import { randomBytes } from "crypto";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
RUN_TEXT_MAX
|
|
4
|
+
} from "./chunk-5LDFFQ4O.js";
|
|
2
5
|
import {
|
|
3
6
|
CONFIG_DIR
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IKCGVBHA.js";
|
|
5
8
|
|
|
6
9
|
// src/box-watch.ts
|
|
7
10
|
import { randomUUID } from "crypto";
|
|
@@ -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,15 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
readRunnerState
|
|
4
|
-
|
|
3
|
+
readRunnerState,
|
|
4
|
+
runnerStatePath,
|
|
5
|
+
threadsFilePath
|
|
6
|
+
} from "./chunk-RPWSWVKD.js";
|
|
5
7
|
import {
|
|
6
8
|
BoxToolError,
|
|
7
9
|
CLOOP_THREAD_PREFIX,
|
|
8
10
|
RUNTIME_MODES,
|
|
9
11
|
T3Driver,
|
|
12
|
+
boxPath,
|
|
10
13
|
defaultT3BinSources,
|
|
11
14
|
isLocal,
|
|
12
15
|
isYes,
|
|
16
|
+
localRunsFilePath,
|
|
13
17
|
otherThreadsChoice,
|
|
14
18
|
pickT3Bin,
|
|
15
19
|
questionLine,
|
|
@@ -18,7 +22,7 @@ import {
|
|
|
18
22
|
t3BaseDirArgs,
|
|
19
23
|
t3Candidates,
|
|
20
24
|
writeBoxConfig
|
|
21
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-5LDFFQ4O.js";
|
|
22
26
|
import {
|
|
23
27
|
CLAUDE_FLOOR,
|
|
24
28
|
claudeTooOld,
|
|
@@ -27,28 +31,57 @@ import {
|
|
|
27
31
|
import {
|
|
28
32
|
getMachine,
|
|
29
33
|
shortMachineName
|
|
30
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-NUU4GXGV.js";
|
|
31
35
|
import {
|
|
32
36
|
READ_TOOLS,
|
|
33
37
|
readOnlySettings
|
|
34
38
|
} from "./chunk-R3CLO2FB.js";
|
|
35
39
|
import {
|
|
36
40
|
connectWebhook
|
|
37
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-NALGGZM6.js";
|
|
38
42
|
import {
|
|
39
43
|
ConnectFailure,
|
|
40
44
|
connectReport,
|
|
41
45
|
deviceLogin,
|
|
42
46
|
newAttempt,
|
|
43
47
|
sendConnectReport
|
|
44
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-N24VQSNB.js";
|
|
45
49
|
import {
|
|
46
50
|
VERSION
|
|
47
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-4H4SIIUH.js";
|
|
48
52
|
import {
|
|
49
53
|
STAGING_ORIGIN,
|
|
50
|
-
getOrigin
|
|
51
|
-
|
|
54
|
+
getOrigin,
|
|
55
|
+
pinRunnerEnvironment,
|
|
56
|
+
pinnedOriginSource
|
|
57
|
+
} from "./chunk-IKCGVBHA.js";
|
|
58
|
+
|
|
59
|
+
// src/commands/disconnect.ts
|
|
60
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
61
|
+
import { existsSync as existsSync2, readFileSync, rmSync as rmSync2 } from "fs";
|
|
62
|
+
import { homedir as homedir2 } from "os";
|
|
63
|
+
|
|
64
|
+
// src/device-revoke.ts
|
|
65
|
+
function tokenGone(revoke) {
|
|
66
|
+
return revoke === "revoked" || revoke === "already_revoked" || revoke === "no_device";
|
|
67
|
+
}
|
|
68
|
+
async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
|
|
69
|
+
if (!deviceToken) return "no_device";
|
|
70
|
+
try {
|
|
71
|
+
const res = await fetchFn(`${origin}/api/agent/mesh/device-revoke`, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: { authorization: `Bearer ${deviceToken}` },
|
|
74
|
+
signal: AbortSignal.timeout(1e4)
|
|
75
|
+
});
|
|
76
|
+
const body = await res.json().catch(() => null);
|
|
77
|
+
if (res.ok && body?.outcome === "revoked") return "revoked";
|
|
78
|
+
if (res.ok && body?.outcome === "already_revoked") return "already_revoked";
|
|
79
|
+
if (res.status === 401 && body?.error === "unknown_device") return "unknown_device";
|
|
80
|
+
return "failed";
|
|
81
|
+
} catch {
|
|
82
|
+
return "failed";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
52
85
|
|
|
53
86
|
// src/commands/connect.ts
|
|
54
87
|
import { execFileSync } from "child_process";
|
|
@@ -328,28 +361,6 @@ async function runBoxTool(ctx, tool, args) {
|
|
|
328
361
|
}
|
|
329
362
|
}
|
|
330
363
|
|
|
331
|
-
// src/device-revoke.ts
|
|
332
|
-
function tokenGone(revoke) {
|
|
333
|
-
return revoke === "revoked" || revoke === "already_revoked" || revoke === "no_device";
|
|
334
|
-
}
|
|
335
|
-
async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
|
|
336
|
-
if (!deviceToken) return "no_device";
|
|
337
|
-
try {
|
|
338
|
-
const res = await fetchFn(`${origin}/api/agent/mesh/device-revoke`, {
|
|
339
|
-
method: "POST",
|
|
340
|
-
headers: { authorization: `Bearer ${deviceToken}` },
|
|
341
|
-
signal: AbortSignal.timeout(1e4)
|
|
342
|
-
});
|
|
343
|
-
const body = await res.json().catch(() => null);
|
|
344
|
-
if (res.ok && body?.outcome === "revoked") return "revoked";
|
|
345
|
-
if (res.ok && body?.outcome === "already_revoked") return "already_revoked";
|
|
346
|
-
if (res.status === 401 && body?.error === "unknown_device") return "unknown_device";
|
|
347
|
-
return "failed";
|
|
348
|
-
} catch {
|
|
349
|
-
return "failed";
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
364
|
// src/drivers/claude-code.ts
|
|
354
365
|
import { execFile } from "child_process";
|
|
355
366
|
import { basename, isAbsolute, relative, resolve } from "path";
|
|
@@ -390,9 +401,13 @@ async function probeClaudePermissions(bin = "claude") {
|
|
|
390
401
|
return claudePermissionSupport(await exec(bin, ["--help"]));
|
|
391
402
|
}
|
|
392
403
|
async function probeClaude(bin = "claude") {
|
|
393
|
-
const
|
|
404
|
+
const [versionOut, auth] = await Promise.all([
|
|
405
|
+
exec(bin, ["--version"]),
|
|
406
|
+
exec(bin, ["auth", "status", "--json"])
|
|
407
|
+
]);
|
|
408
|
+
const version = versionOut?.trim().split(/\s+/)[0];
|
|
394
409
|
if (!version) return null;
|
|
395
|
-
const { signedIn, account } = claudeAccount(
|
|
410
|
+
const { signedIn, account } = claudeAccount(auth);
|
|
396
411
|
return {
|
|
397
412
|
id: "claude-code",
|
|
398
413
|
name: "Claude Code",
|
|
@@ -644,9 +659,11 @@ function codexAccount(ok, out2) {
|
|
|
644
659
|
return { signedIn: true, account: /chatgpt/i.test(out2) ? "ChatGPT" : "API key" };
|
|
645
660
|
}
|
|
646
661
|
async function probeCodex(bin = "codex") {
|
|
647
|
-
const version = await
|
|
662
|
+
const [version, status] = await Promise.all([
|
|
663
|
+
exec2(bin, ["--version"]),
|
|
664
|
+
exec2(bin, ["login", "status"])
|
|
665
|
+
]);
|
|
648
666
|
if (!version.ok) return null;
|
|
649
|
-
const status = await exec2(bin, ["login", "status"]);
|
|
650
667
|
const { signedIn, account } = codexAccount(status.ok, status.out);
|
|
651
668
|
return {
|
|
652
669
|
id: "codex",
|
|
@@ -1136,7 +1153,7 @@ function parsePicks(answer, max) {
|
|
|
1136
1153
|
return [...new Set(picks)];
|
|
1137
1154
|
}
|
|
1138
1155
|
function rerunCommand(argv, script = process.argv[1] ?? "") {
|
|
1139
|
-
const base = script.includes("/_npx/") ? "npx -y @cloop/runner" : "cloop";
|
|
1156
|
+
const base = script.includes("/_npx/") ? "npx -y @cloop/runner@latest" : "cloop";
|
|
1140
1157
|
const staging = process.env.CLOOP_ORIGIN === STAGING_ORIGIN ? ["--staging"] : [];
|
|
1141
1158
|
return [base, "connect", ...staging, ...argv].join(" ");
|
|
1142
1159
|
}
|
|
@@ -1402,7 +1419,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
1402
1419
|
...chosen ? { chosenDriver: chosen } : {}
|
|
1403
1420
|
})
|
|
1404
1421
|
});
|
|
1405
|
-
await revokeReplaced(previous, "workstation", (t) => revokeOwnDevice(getOrigin(), t), out);
|
|
1422
|
+
await revokeReplaced(previous, "workstation", (t) => revokeOwnDevice(attempt.replacedOrigin ?? getOrigin(), t), out);
|
|
1406
1423
|
out(
|
|
1407
1424
|
`${bold("Cloop runner")} T3 ${cfg.label} paired with scope ${cfg.scope}, until ${cfg.expiresAt.slice(0, 10)}.`
|
|
1408
1425
|
);
|
|
@@ -1460,7 +1477,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
|
1460
1477
|
...chosen ? { chosenDriver: chosen } : {}
|
|
1461
1478
|
};
|
|
1462
1479
|
writeBoxConfig(cfg);
|
|
1463
|
-
await revokeReplaced(previous, "local", (t) => revokeOwnDevice(getOrigin(), t), out);
|
|
1480
|
+
await revokeReplaced(previous, "local", (t) => revokeOwnDevice(attempt.replacedOrigin ?? getOrigin(), t), out);
|
|
1464
1481
|
const others = [found.claude, found.codex].filter(
|
|
1465
1482
|
(h) => Boolean(h) && h !== harness
|
|
1466
1483
|
);
|
|
@@ -1574,7 +1591,13 @@ function terminalYesNo() {
|
|
|
1574
1591
|
};
|
|
1575
1592
|
}
|
|
1576
1593
|
async function runConnect(argv, deps = {}) {
|
|
1594
|
+
const replacedOrigin = runnerOrigin();
|
|
1595
|
+
pinRunnerEnvironment();
|
|
1596
|
+
console.error(
|
|
1597
|
+
`[runner:connect] origin=${getOrigin()} source=${pinnedOriginSource()} replaced_origin=${replacedOrigin ?? "none"}`
|
|
1598
|
+
);
|
|
1577
1599
|
const attempt = newAttempt();
|
|
1600
|
+
if (replacedOrigin) attempt.replacedOrigin = replacedOrigin;
|
|
1578
1601
|
let error = null;
|
|
1579
1602
|
try {
|
|
1580
1603
|
await connect(argv, attempt, deps);
|
|
@@ -1594,11 +1617,140 @@ async function connectCommand(argv) {
|
|
|
1594
1617
|
if (await runConnect(argv)) process.exit(1);
|
|
1595
1618
|
}
|
|
1596
1619
|
|
|
1620
|
+
// src/commands/disconnect.ts
|
|
1621
|
+
var DONE_LINE = "This computer is no longer a Cloop runner. To connect it again: npx -y @cloop/runner@latest connect";
|
|
1622
|
+
function unitOrigin(contents) {
|
|
1623
|
+
const plist = /<key>CLOOP_ORIGIN<\/key><string>([^<]+)<\/string>/.exec(contents)?.[1];
|
|
1624
|
+
if (plist) return plist.replace(/&/g, "&");
|
|
1625
|
+
const unit = /Environment="CLOOP_ORIGIN=([^"]+)"/.exec(contents)?.[1];
|
|
1626
|
+
return unit ? unit.replace(/%%/g, "%") : null;
|
|
1627
|
+
}
|
|
1628
|
+
function disconnectPlan(opts) {
|
|
1629
|
+
const exists = opts.exists ?? existsSync2;
|
|
1630
|
+
const read = opts.read ?? ((path) => readFileSync(path, "utf-8"));
|
|
1631
|
+
const services = ["local", "workstation"].map((kind) => installedService({ ...opts, kind })).filter((service) => exists(service.path));
|
|
1632
|
+
const fromUnit = services.map((service) => {
|
|
1633
|
+
try {
|
|
1634
|
+
return unitOrigin(read(service.path));
|
|
1635
|
+
} catch {
|
|
1636
|
+
return null;
|
|
1637
|
+
}
|
|
1638
|
+
}).find(Boolean);
|
|
1639
|
+
return {
|
|
1640
|
+
origin: opts.boxOrigin ?? fromUnit ?? opts.fallbackOrigin,
|
|
1641
|
+
deviceToken: opts.deviceToken,
|
|
1642
|
+
services,
|
|
1643
|
+
box: exists(opts.box) ? opts.box : null,
|
|
1644
|
+
files: opts.files.filter((file) => exists(file)),
|
|
1645
|
+
isBox: opts.platform !== "darwin" && services.some((s) => s.path.endsWith("/cloop-box.service"))
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
function revokeLine(revoke, origin, box) {
|
|
1649
|
+
const keep = box ? ` Kept ${box}, which holds the device token, so you can try again.` : "";
|
|
1650
|
+
switch (revoke) {
|
|
1651
|
+
case "revoked":
|
|
1652
|
+
return [`Revoked this computer on Cloop (${origin}).`];
|
|
1653
|
+
case "already_revoked":
|
|
1654
|
+
return [`Cloop (${origin}) had already revoked this computer.`];
|
|
1655
|
+
case "no_device":
|
|
1656
|
+
return ["No runner device on this computer to revoke."];
|
|
1657
|
+
case "unknown_device":
|
|
1658
|
+
return [
|
|
1659
|
+
`Cloop at ${origin} never issued this computer's device token, so it belongs to the other environment.${keep}`,
|
|
1660
|
+
"Run `cloop disconnect --staging` for a staging runner, or `cloop disconnect` for production."
|
|
1661
|
+
];
|
|
1662
|
+
case "failed":
|
|
1663
|
+
return [
|
|
1664
|
+
`Could not revoke this computer at ${origin}: Cloop did not answer as expected.${keep}`,
|
|
1665
|
+
"Run `cloop disconnect` again when Cloop answers, or press Disconnect on its card on the Threads page and then delete that file."
|
|
1666
|
+
];
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
async function disconnect(plan, opts) {
|
|
1670
|
+
const { say } = opts;
|
|
1671
|
+
const run = opts.run ?? ((command) => void execFileSync2(command[0], command.slice(1), {
|
|
1672
|
+
stdio: "ignore",
|
|
1673
|
+
timeout: 15e3
|
|
1674
|
+
}));
|
|
1675
|
+
if (plan.isBox && !opts.yes) {
|
|
1676
|
+
say("This computer runs cloop-box.service, a Cloop box with T3 Code. Disconnect would:");
|
|
1677
|
+
for (const s of plan.services) say(` stop and remove ${s.path}`);
|
|
1678
|
+
if (plan.deviceToken) say(` revoke its runner device on Cloop (${plan.origin})`);
|
|
1679
|
+
for (const f of [...plan.box ? [plan.box] : [], ...plan.files]) say(` delete ${f}`);
|
|
1680
|
+
say("Run `cloop disconnect --yes` to do this.");
|
|
1681
|
+
return 1;
|
|
1682
|
+
}
|
|
1683
|
+
for (const service of plan.services) {
|
|
1684
|
+
await runSteps(service.steps, run);
|
|
1685
|
+
const stillRunning = async () => {
|
|
1686
|
+
const until = Date.now() + (opts.stopWaitMs ?? 1e4);
|
|
1687
|
+
for (; ; ) {
|
|
1688
|
+
try {
|
|
1689
|
+
run(service.running);
|
|
1690
|
+
} catch {
|
|
1691
|
+
return false;
|
|
1692
|
+
}
|
|
1693
|
+
if (Date.now() >= until) return true;
|
|
1694
|
+
await new Promise((resolve3) => setTimeout(resolve3, 250));
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
if (await stillRunning()) {
|
|
1698
|
+
say(
|
|
1699
|
+
`Could not stop the service in ${service.path}. Nothing was removed. Stop it with \`${service.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run \`cloop disconnect\` again.`
|
|
1700
|
+
);
|
|
1701
|
+
return 1;
|
|
1702
|
+
}
|
|
1703
|
+
say(`Stopped the service in ${service.path}`);
|
|
1704
|
+
}
|
|
1705
|
+
const revoked = await opts.revoke(plan.origin, plan.deviceToken);
|
|
1706
|
+
const gone = tokenGone(revoked);
|
|
1707
|
+
for (const service of plan.services) {
|
|
1708
|
+
rmSync2(service.path, { force: true });
|
|
1709
|
+
say(`Removed ${service.path}`);
|
|
1710
|
+
}
|
|
1711
|
+
for (const file of [...gone && plan.box ? [plan.box] : [], ...plan.files]) {
|
|
1712
|
+
rmSync2(file, { force: true });
|
|
1713
|
+
say(`Deleted ${file}`);
|
|
1714
|
+
}
|
|
1715
|
+
for (const line2 of revokeLine(revoked, plan.origin, plan.box)) say(line2);
|
|
1716
|
+
if (!gone) return 1;
|
|
1717
|
+
say(DONE_LINE);
|
|
1718
|
+
return 0;
|
|
1719
|
+
}
|
|
1720
|
+
function runnerOrigin() {
|
|
1721
|
+
return disconnectPlan(thisComputer(readRunnerConfig(), "")).origin || void 0;
|
|
1722
|
+
}
|
|
1723
|
+
function thisComputer(cfg, fallbackOrigin) {
|
|
1724
|
+
return {
|
|
1725
|
+
platform: process.platform,
|
|
1726
|
+
home: homedir2(),
|
|
1727
|
+
uid: process.getuid?.() ?? 0,
|
|
1728
|
+
...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {},
|
|
1729
|
+
box: boxPath(),
|
|
1730
|
+
deviceToken: cfg?.deviceToken ?? null,
|
|
1731
|
+
...cfg?.origin ? { boxOrigin: cfg.origin } : {},
|
|
1732
|
+
fallbackOrigin,
|
|
1733
|
+
files: [localRunsFilePath(), runnerStatePath(), threadsFilePath()]
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
async function disconnectCommand(argv) {
|
|
1737
|
+
const plan = disconnectPlan(thisComputer(readRunnerConfig(), getOrigin()));
|
|
1738
|
+
process.exitCode = await disconnect(plan, {
|
|
1739
|
+
yes: argv.includes("--yes"),
|
|
1740
|
+
revoke: (origin, token) => revokeOwnDevice(origin, token),
|
|
1741
|
+
say: (line2) => console.log(line2)
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1597
1745
|
export {
|
|
1598
1746
|
T3Client,
|
|
1599
1747
|
runBoxTool,
|
|
1600
|
-
|
|
1601
|
-
|
|
1748
|
+
DONE_LINE,
|
|
1749
|
+
unitOrigin,
|
|
1750
|
+
disconnectPlan,
|
|
1751
|
+
disconnect,
|
|
1752
|
+
runnerOrigin,
|
|
1753
|
+
disconnectCommand,
|
|
1602
1754
|
probeClaudePermissions,
|
|
1603
1755
|
probeClaude,
|
|
1604
1756
|
DEFAULT_FALLBACK_MODEL,
|
|
@@ -39,18 +39,18 @@ import {
|
|
|
39
39
|
tilde,
|
|
40
40
|
unitEnv,
|
|
41
41
|
unitFor
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
42
|
+
} from "./chunk-TJXXWEJW.js";
|
|
43
|
+
import "./chunk-RPWSWVKD.js";
|
|
44
|
+
import "./chunk-5LDFFQ4O.js";
|
|
45
45
|
import "./chunk-UBXT5IDU.js";
|
|
46
|
-
import "./chunk-
|
|
46
|
+
import "./chunk-NUU4GXGV.js";
|
|
47
47
|
import "./chunk-VK6GV757.js";
|
|
48
48
|
import "./chunk-R3CLO2FB.js";
|
|
49
|
-
import "./chunk-
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-NALGGZM6.js";
|
|
50
|
+
import "./chunk-N24VQSNB.js";
|
|
51
|
+
import "./chunk-NYGELUTR.js";
|
|
52
|
+
import "./chunk-4H4SIIUH.js";
|
|
53
|
+
import "./chunk-IKCGVBHA.js";
|
|
54
54
|
export {
|
|
55
55
|
DEFAULT_T3_URL,
|
|
56
56
|
DRIVER_NAME,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
DONE_LINE,
|
|
4
|
+
disconnect,
|
|
5
|
+
disconnectCommand,
|
|
6
|
+
disconnectPlan,
|
|
7
|
+
runnerOrigin,
|
|
8
|
+
unitOrigin
|
|
9
|
+
} from "./chunk-TJXXWEJW.js";
|
|
10
|
+
import "./chunk-RPWSWVKD.js";
|
|
11
|
+
import "./chunk-5LDFFQ4O.js";
|
|
12
|
+
import "./chunk-UBXT5IDU.js";
|
|
13
|
+
import "./chunk-NUU4GXGV.js";
|
|
14
|
+
import "./chunk-VK6GV757.js";
|
|
15
|
+
import "./chunk-R3CLO2FB.js";
|
|
16
|
+
import "./chunk-NALGGZM6.js";
|
|
17
|
+
import "./chunk-N24VQSNB.js";
|
|
18
|
+
import "./chunk-NYGELUTR.js";
|
|
19
|
+
import "./chunk-4H4SIIUH.js";
|
|
20
|
+
import "./chunk-IKCGVBHA.js";
|
|
21
|
+
export {
|
|
22
|
+
DONE_LINE,
|
|
23
|
+
disconnect,
|
|
24
|
+
disconnectCommand,
|
|
25
|
+
disconnectPlan,
|
|
26
|
+
runnerOrigin,
|
|
27
|
+
unitOrigin
|
|
28
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
pruneSessionStates,
|
|
5
5
|
toolPhrase,
|
|
6
6
|
writeSessionState
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-E5CKL2Q3.js";
|
|
8
8
|
import {
|
|
9
9
|
HeartbeatClient,
|
|
10
10
|
detectPlatform,
|
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
getName,
|
|
13
13
|
getSurface,
|
|
14
14
|
sanitizeSessionKey
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NUU4GXGV.js";
|
|
16
16
|
import "./chunk-VK6GV757.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-NYGELUTR.js";
|
|
18
18
|
import {
|
|
19
19
|
getToken
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IKCGVBHA.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/hook-activity.ts
|
|
23
23
|
async function readStdin() {
|
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
getName,
|
|
7
7
|
getSurface,
|
|
8
8
|
newSessionKey
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NUU4GXGV.js";
|
|
10
10
|
import {
|
|
11
11
|
sanitizeLabel
|
|
12
12
|
} from "./chunk-VK6GV757.js";
|
|
13
13
|
import {
|
|
14
14
|
api
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NYGELUTR.js";
|
|
16
16
|
import {
|
|
17
17
|
getToken
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IKCGVBHA.js";
|
|
19
19
|
|
|
20
20
|
// src/digest.ts
|
|
21
21
|
var CHAR_BUDGET = 1600;
|