@cloop/runner 0.3.7 → 0.3.9
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/dist/{box-IWMUX74G.js → box-V3DFX5TB.js} +77 -45
- package/dist/{chunk-VYM5NYS6.js → chunk-3SIF2NNR.js} +3 -3
- package/dist/{chunk-EQTFHMUJ.js → chunk-5SUC54R3.js} +11 -10
- package/dist/{chunk-5FZAHWPX.js → chunk-6QXNXJ7C.js} +1 -1
- package/dist/{chunk-QP6ZNGU3.js → chunk-AA2SZUIY.js} +366 -233
- package/dist/{chunk-IKCGVBHA.js → chunk-D5UZW42X.js} +1 -0
- package/dist/{chunk-NYGELUTR.js → chunk-ES5BRAKJ.js} +1 -1
- package/dist/{chunk-E5CKL2Q3.js → chunk-EVIVOEJY.js} +1 -1
- package/dist/{chunk-3IP5XIPV.js → chunk-FNJ74LO3.js} +4 -4
- package/dist/{chunk-5L76PKXT.js → chunk-GPQ2MSET.js} +1 -1
- package/dist/{chunk-NUU4GXGV.js → chunk-NTXQLEMQ.js} +1 -1
- package/dist/{chunk-3WD7S6VI.js → chunk-S3AB7HKD.js} +129 -71
- package/dist/{chunk-3TDL6X5T.js → chunk-TEEFTSXG.js} +1 -1
- package/dist/{chunk-PSUEFPEA.js → chunk-XQZO3UE6.js} +3 -3
- package/dist/{connect-QKQAJECG.js → connect-3IS2XXSU.js} +14 -10
- package/dist/disconnect-IMVUEDIP.js +30 -0
- package/dist/existing-runner-DYL2ZND4.js +20 -0
- package/dist/{hook-activity-I7TV7YG7.js → hook-activity-GAJ5NABA.js} +4 -4
- package/dist/{hook-session-start-MFX6HR3W.js → hook-session-start-DJ6W2NCO.js} +3 -3
- package/dist/index.js +32 -21
- package/dist/{install-EMEZBBK7.js → install-WXKWNTAO.js} +1 -1
- package/dist/{login-3IJKY6EZ.js → login-67UJOSXI.js} +4 -4
- package/dist/{mcp-server-H2DF37BP.js → mcp-server-BQIXVJYD.js} +12 -12
- package/dist/runner-2O56SWXN.js +13 -0
- package/dist/{runs-RZL34AFT.js → runs-CMRLRCTD.js} +3 -3
- package/dist/{statusline-I3MT77CR.js → statusline-G6SQFIVR.js} +3 -3
- package/dist/{takeover-V2IHVUAB.js → takeover-HFQOQTLP.js} +7 -7
- package/dist/{use-PB7RVN6H.js → use-XTJPDK4Y.js} +15 -16
- package/package.json +1 -1
- package/dist/disconnect-5FEZUWJP.js +0 -28
- package/dist/runner-5G4CLAXF.js +0 -13
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
serveTakeovers
|
|
4
|
-
} from "./chunk-3IP5XIPV.js";
|
|
5
|
-
import "./chunk-3TDL6X5T.js";
|
|
6
2
|
import {
|
|
7
3
|
MeshSocket,
|
|
8
4
|
defaultSocketFactory
|
|
9
5
|
} from "./chunk-ZILLDYL4.js";
|
|
6
|
+
import {
|
|
7
|
+
serveTakeovers
|
|
8
|
+
} from "./chunk-FNJ74LO3.js";
|
|
9
|
+
import "./chunk-TEEFTSXG.js";
|
|
10
10
|
import {
|
|
11
11
|
DEFAULT_FALLBACK_MODEL,
|
|
12
12
|
T3Client,
|
|
@@ -16,53 +16,61 @@ import {
|
|
|
16
16
|
connectCommand,
|
|
17
17
|
findNpx,
|
|
18
18
|
installedService,
|
|
19
|
+
legacyStagingRunner,
|
|
19
20
|
mintSession,
|
|
21
|
+
moveLegacyStagingRunner,
|
|
22
|
+
moveRunnerFiles,
|
|
23
|
+
pinExistingRunner,
|
|
20
24
|
probeClaude,
|
|
21
25
|
probeClaudePermissions,
|
|
22
26
|
probeCodex,
|
|
23
27
|
programFor,
|
|
24
28
|
runBoxTool,
|
|
25
29
|
runSteps,
|
|
30
|
+
serviceEnv,
|
|
31
|
+
stopService,
|
|
26
32
|
systemServices,
|
|
27
|
-
unitEnv,
|
|
28
33
|
unitFor,
|
|
29
34
|
which
|
|
30
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-AA2SZUIY.js";
|
|
31
36
|
import {
|
|
32
37
|
BoxWatch,
|
|
33
38
|
lockThreadsFile,
|
|
34
39
|
readRunnerState,
|
|
40
|
+
runnerStatePath,
|
|
35
41
|
threadsFilePath,
|
|
36
42
|
writeRunnerState
|
|
37
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-5SUC54R3.js";
|
|
38
44
|
import {
|
|
39
45
|
LocalDriver,
|
|
40
46
|
T3Driver,
|
|
41
47
|
isLocal,
|
|
42
48
|
readRunnerConfig,
|
|
49
|
+
runnerDir,
|
|
50
|
+
runnerEnvironment,
|
|
51
|
+
runnerPath,
|
|
43
52
|
showsOtherThreads,
|
|
44
53
|
writeBoxConfig
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
olderThan
|
|
48
|
-
} from "./chunk-UBXT5IDU.js";
|
|
54
|
+
} from "./chunk-S3AB7HKD.js";
|
|
49
55
|
import {
|
|
50
56
|
getMachine
|
|
51
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-NTXQLEMQ.js";
|
|
52
58
|
import "./chunk-VK6GV757.js";
|
|
59
|
+
import {
|
|
60
|
+
olderThan
|
|
61
|
+
} from "./chunk-UBXT5IDU.js";
|
|
53
62
|
import "./chunk-R3CLO2FB.js";
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
-
import "./chunk-
|
|
63
|
+
import "./chunk-3SIF2NNR.js";
|
|
64
|
+
import "./chunk-XQZO3UE6.js";
|
|
65
|
+
import "./chunk-ES5BRAKJ.js";
|
|
57
66
|
import {
|
|
58
67
|
VERSION
|
|
59
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-GPQ2MSET.js";
|
|
60
69
|
import {
|
|
61
|
-
CONFIG_DIR,
|
|
62
70
|
getMeshUrl,
|
|
63
71
|
getToken,
|
|
64
72
|
readCredentials
|
|
65
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-D5UZW42X.js";
|
|
66
74
|
|
|
67
75
|
// src/outside-sessions.ts
|
|
68
76
|
import { createReadStream } from "fs";
|
|
@@ -140,9 +148,17 @@ async function listOutsideSessions(root = join(homedir(), ".claude", "projects")
|
|
|
140
148
|
|
|
141
149
|
// src/update.ts
|
|
142
150
|
import { execFile, spawn } from "child_process";
|
|
143
|
-
import {
|
|
151
|
+
import {
|
|
152
|
+
closeSync,
|
|
153
|
+
mkdirSync,
|
|
154
|
+
openSync,
|
|
155
|
+
readFileSync,
|
|
156
|
+
renameSync,
|
|
157
|
+
rmSync,
|
|
158
|
+
writeFileSync
|
|
159
|
+
} from "fs";
|
|
144
160
|
import { homedir as homedir2 } from "os";
|
|
145
|
-
import { join as join2 } from "path";
|
|
161
|
+
import { dirname, join as join2 } from "path";
|
|
146
162
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@cloop/runner/latest";
|
|
147
163
|
var FIRST_CHECK_MS = 10 * 6e4;
|
|
148
164
|
var CHECK_EVERY_MS = 6 * 36e5;
|
|
@@ -178,14 +194,14 @@ async function readLatest(get = fetch) {
|
|
|
178
194
|
return null;
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
|
-
function updateDir() {
|
|
182
|
-
return process.env.CLOOP_UPDATE_DIR
|
|
197
|
+
function updateDir(env) {
|
|
198
|
+
return runnerPath(env, process.env.CLOOP_UPDATE_DIR, (dir) => dir);
|
|
183
199
|
}
|
|
184
200
|
function updateLogPath() {
|
|
185
201
|
return join2(updateDir(), "update.log");
|
|
186
202
|
}
|
|
187
|
-
function statePath() {
|
|
188
|
-
return join2(updateDir(), "update.json");
|
|
203
|
+
function statePath(env) {
|
|
204
|
+
return join2(updateDir(env), "update.json");
|
|
189
205
|
}
|
|
190
206
|
function readFailed() {
|
|
191
207
|
try {
|
|
@@ -195,13 +211,13 @@ function readFailed() {
|
|
|
195
211
|
return null;
|
|
196
212
|
}
|
|
197
213
|
}
|
|
198
|
-
function recordFailed(version) {
|
|
214
|
+
function recordFailed(version, env) {
|
|
199
215
|
try {
|
|
200
|
-
mkdirSync(updateDir(), { recursive: true, mode: 448 });
|
|
201
|
-
const temp = `${statePath()}.${process.pid}.tmp`;
|
|
216
|
+
mkdirSync(updateDir(env), { recursive: true, mode: 448 });
|
|
217
|
+
const temp = `${statePath(env)}.${process.pid}.tmp`;
|
|
202
218
|
writeFileSync(temp, `${JSON.stringify({ failed: version })}
|
|
203
219
|
`, { mode: 384 });
|
|
204
|
-
renameSync(temp, statePath());
|
|
220
|
+
renameSync(temp, statePath(env));
|
|
205
221
|
} catch (err) {
|
|
206
222
|
log(`could not record ${version} as failed: ${err.code ?? err}`);
|
|
207
223
|
}
|
|
@@ -224,6 +240,7 @@ function servicePath(kind) {
|
|
|
224
240
|
return installedService({
|
|
225
241
|
platform: process.platform,
|
|
226
242
|
kind,
|
|
243
|
+
environment: runnerEnvironment(),
|
|
227
244
|
home: homedir2(),
|
|
228
245
|
uid: process.getuid?.() ?? 0,
|
|
229
246
|
...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
|
|
@@ -323,34 +340,39 @@ function newDaemon(oldPid, read = readRunnerState) {
|
|
|
323
340
|
return state && state.pid !== oldPid ? state : null;
|
|
324
341
|
}
|
|
325
342
|
async function adopt(from, kind, { services: given, script = process.argv[1] ?? "cloop", npx = findNpx() } = {}) {
|
|
326
|
-
const
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
343
|
+
const environment = runnerEnvironment();
|
|
344
|
+
const legacy = legacyStagingRunner();
|
|
345
|
+
const was = legacy ? "production" : environment;
|
|
346
|
+
const oldPid = readRunnerState(runnerStatePath(was))?.pid;
|
|
347
|
+
const services = {
|
|
348
|
+
...given ?? systemServices,
|
|
349
|
+
awaitUp: given?.awaitUp ?? ((since2) => awaitDaemon(since2, () => newDaemon(oldPid), { timeoutMs: ADOPT_WAIT_MS }))
|
|
330
350
|
};
|
|
331
351
|
const refuse = (why2) => {
|
|
332
352
|
log(`adopt ${from} -> ${VERSION} refused: ${why2}`);
|
|
333
|
-
recordFailed(VERSION);
|
|
353
|
+
recordFailed(VERSION, was);
|
|
334
354
|
return 1;
|
|
335
355
|
};
|
|
336
356
|
const program = programFor(script, process.execPath, npx, VERSION);
|
|
337
357
|
if (typeof program === "string") return refuse(program);
|
|
338
|
-
const
|
|
358
|
+
const where = {
|
|
339
359
|
platform: services.platform,
|
|
340
360
|
kind,
|
|
341
361
|
home: homedir2(),
|
|
342
|
-
program,
|
|
343
|
-
env: unitEnv(process.env),
|
|
344
362
|
uid: process.getuid?.() ?? 0,
|
|
345
363
|
...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
|
|
346
|
-
}
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
364
|
+
};
|
|
365
|
+
const unit = unitFor({ ...where, environment, program, env: serviceEnv() });
|
|
366
|
+
const back = legacy ? unitFor({ ...where, environment: was, program, env: {} }) : unit;
|
|
367
|
+
const old = readText(back.path);
|
|
368
|
+
if (old === null) return refuse(`${back.path} is missing`);
|
|
369
|
+
if (!namesVersion(old, from)) return refuse(`${back.path} does not run ${from}`);
|
|
350
370
|
const run2 = (command) => void services.run(command);
|
|
351
371
|
const since = Date.now();
|
|
352
372
|
let why;
|
|
353
373
|
try {
|
|
374
|
+
if (legacy) await moveLegacyStagingRunner(services);
|
|
375
|
+
mkdirSync(dirname(unit.path), { recursive: true });
|
|
354
376
|
writeFileSync(unit.path, unit.contents);
|
|
355
377
|
await runSteps(unit.start, run2);
|
|
356
378
|
if (await services.awaitUp(since)) {
|
|
@@ -362,13 +384,19 @@ async function adopt(from, kind, { services: given, script = process.argv[1] ??
|
|
|
362
384
|
why = err instanceof Error ? err.message : String(err);
|
|
363
385
|
}
|
|
364
386
|
log(`adopt ${from} -> ${VERSION} failed: ${why}; putting ${from} back`);
|
|
365
|
-
recordFailed(VERSION);
|
|
366
387
|
try {
|
|
367
|
-
|
|
368
|
-
|
|
388
|
+
if (legacy) {
|
|
389
|
+
const added = installedService({ ...where, environment });
|
|
390
|
+
if (!await stopService(added, run2)) throw new Error(`${added.path} did not stop`);
|
|
391
|
+
rmSync(added.path, { force: true });
|
|
392
|
+
moveRunnerFiles(runnerDir(environment), runnerDir(was));
|
|
393
|
+
}
|
|
394
|
+
recordFailed(VERSION, was);
|
|
395
|
+
writeFileSync(back.path, old);
|
|
396
|
+
await runSteps(back.start, run2);
|
|
369
397
|
} catch (err) {
|
|
370
398
|
log(
|
|
371
|
-
`ROLLBACK FAILED: could not restart ${from} from ${
|
|
399
|
+
`ROLLBACK FAILED: could not restart ${from} from ${back.path}: ${err instanceof Error ? err.message : String(err)}. Run cloop connect on this machine.`
|
|
372
400
|
);
|
|
373
401
|
return 2;
|
|
374
402
|
}
|
|
@@ -453,7 +481,9 @@ async function run() {
|
|
|
453
481
|
let cfg = readRunnerConfig();
|
|
454
482
|
let token = cfg?.deviceToken ?? getToken();
|
|
455
483
|
if (!token || !cfg) {
|
|
456
|
-
out(
|
|
484
|
+
out(
|
|
485
|
+
`${red("\u2717")} ${legacyStagingRunner() ? "This staging runner is still in ~/.cloop from before 0.3.9. Run `cloop connect --staging` to move it to ~/.cloop/staging." : "Not connected. Run `cloop connect` first."}`
|
|
486
|
+
);
|
|
457
487
|
process.exit(1);
|
|
458
488
|
}
|
|
459
489
|
if (!cfg.deviceToken) {
|
|
@@ -644,6 +674,7 @@ async function boxCommand(argv) {
|
|
|
644
674
|
await connectCommand(["--driver", "t3", ...argv.slice(1)]);
|
|
645
675
|
break;
|
|
646
676
|
case "run":
|
|
677
|
+
pinExistingRunner();
|
|
647
678
|
await run();
|
|
648
679
|
break;
|
|
649
680
|
case "adopt": {
|
|
@@ -653,6 +684,7 @@ async function boxCommand(argv) {
|
|
|
653
684
|
console.error("Usage: cloop box adopt --from <version> --kind workstation|local");
|
|
654
685
|
process.exit(1);
|
|
655
686
|
}
|
|
687
|
+
pinExistingRunner();
|
|
656
688
|
process.exit(await adopt(from, kind));
|
|
657
689
|
break;
|
|
658
690
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ConnectFailure,
|
|
4
4
|
deviceLogin
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XQZO3UE6.js";
|
|
6
6
|
import {
|
|
7
7
|
ApiError,
|
|
8
8
|
ReauthError,
|
|
9
9
|
api
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ES5BRAKJ.js";
|
|
11
11
|
import {
|
|
12
12
|
CONFIG_DIR,
|
|
13
13
|
getOrigin,
|
|
14
14
|
readCredentials,
|
|
15
15
|
writeCredentials
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-D5UZW42X.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/runner.ts
|
|
19
19
|
import { randomBytes } from "crypto";
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
RUN_TEXT_MAX
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
CONFIG_DIR
|
|
7
|
-
} from "./chunk-IKCGVBHA.js";
|
|
3
|
+
RUN_TEXT_MAX,
|
|
4
|
+
runnerPath
|
|
5
|
+
} from "./chunk-S3AB7HKD.js";
|
|
8
6
|
|
|
9
7
|
// src/box-watch.ts
|
|
10
8
|
import { randomUUID } from "crypto";
|
|
11
9
|
import { chmodSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
12
|
-
import { homedir } from "os";
|
|
13
10
|
import { dirname, join } from "path";
|
|
14
11
|
var KEEP_MS = 7 * 24 * 36e5;
|
|
15
|
-
function threadsFilePath() {
|
|
16
|
-
return
|
|
12
|
+
function threadsFilePath(env) {
|
|
13
|
+
return runnerPath(
|
|
14
|
+
env,
|
|
15
|
+
process.env.CLOOP_BOX_THREADS_FILE,
|
|
16
|
+
(dir) => join(dir, "box-threads.json")
|
|
17
|
+
);
|
|
17
18
|
}
|
|
18
|
-
function runnerStatePath() {
|
|
19
|
-
return join(dirname(threadsFilePath()), "runner-state.json");
|
|
19
|
+
function runnerStatePath(env) {
|
|
20
|
+
return join(dirname(threadsFilePath(env)), "runner-state.json");
|
|
20
21
|
}
|
|
21
22
|
function writeRunnerState(state, path = runnerStatePath()) {
|
|
22
23
|
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|