@cloop/runner 0.3.23 → 0.3.27
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 +2 -2
- package/dist/box-TENZ3P6J.js +2708 -0
- package/dist/{chunk-YEO27QQP.js → chunk-365HFCQQ.js} +1 -1
- package/dist/{chunk-Z7WF67JW.js → chunk-3OF5FEMG.js} +8 -3
- package/dist/{chunk-RKR55PPC.js → chunk-C6EAR65U.js} +1 -1
- package/dist/{chunk-IITOGOV7.js → chunk-CC2S6H4W.js} +206 -56
- package/dist/{chunk-OZN4V4GC.js → chunk-KDO735VV.js} +5 -5
- package/dist/{chunk-IJH4O27H.js → chunk-KYGYU5G2.js} +65 -2
- package/dist/{chunk-A5SHBJHU.js → chunk-MRP3S5DT.js} +1 -1
- package/dist/{chunk-R3CLO2FB.js → chunk-PKIEWBR7.js} +2 -0
- package/dist/{chunk-TNNAPOD5.js → chunk-PUKYUGWD.js} +121 -81
- package/dist/{chunk-BKPSZTPK.js → chunk-U57DZQSE.js} +1 -1
- package/dist/{chunk-H4WR3GSK.js → chunk-ZYU7Y2SE.js} +6 -6
- package/dist/{connect-5AYRHDDA.js → connect-YAFC76SG.js} +9 -8
- package/dist/{disconnect-UEH44J7T.js → disconnect-AJBQUDE3.js} +9 -8
- package/dist/existing-runner-FWDDD3L2.js +21 -0
- package/dist/{hook-session-start-DJ6W2NCO.js → hook-session-start-5JYNMGX4.js} +5 -1
- package/dist/index.js +24 -24
- package/dist/{login-ECXACUOZ.js → login-TALFCKAD.js} +2 -2
- package/dist/{mcp-server-FMYWDRGP.js → mcp-server-RUK3JL4O.js} +5 -5
- package/dist/{read-permissions-SPOKGVLO.js → read-permissions-EGSGI4HL.js} +1 -1
- package/dist/{runner-PV2WK3ZE.js → runner-GOT6CIJW.js} +3 -3
- package/dist/{runs-JCDJL7WU.js → runs-SUZJHP7M.js} +2 -2
- package/dist/{statusline-TBZIUD3P.js → statusline-XHSO6GCX.js} +1 -1
- package/dist/{takeover-2HUC4IOI.js → takeover-B63GSUZW.js} +4 -4
- package/dist/{use-W45QOQUI.js → use-L4CIPDJZ.js} +10 -9
- package/package.json +2 -2
- package/dist/box-EUWQ7RT5.js +0 -1121
- package/dist/existing-runner-CO7FNUAW.js +0 -20
|
@@ -18,7 +18,7 @@ function olderThan(version, floor) {
|
|
|
18
18
|
}
|
|
19
19
|
function nodeTooOld(version = process.versions.node) {
|
|
20
20
|
if (!olderThan(version, String(NODE_FLOOR))) return null;
|
|
21
|
-
return `Cloop
|
|
21
|
+
return `Cloop machine 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.`;
|
|
22
22
|
}
|
|
23
23
|
function claudeTooOld(version) {
|
|
24
24
|
return `Claude Code ${version} is older than ${CLAUDE_FLOOR}, the version Cloop runs on.`;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
RUN_TEXT_MAX,
|
|
4
|
+
boxPath,
|
|
4
5
|
runnerPath
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PUKYUGWD.js";
|
|
6
7
|
|
|
7
8
|
// src/box-watch.ts
|
|
8
9
|
import { randomUUID } from "crypto";
|
|
@@ -16,8 +17,11 @@ function threadsFilePath(env) {
|
|
|
16
17
|
(dir) => join(dir, "box-threads.json")
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
return join(dirname(
|
|
20
|
+
function hostedThreadsFilePath(harness) {
|
|
21
|
+
return join(dirname(boxPath()), `hosted-${harness}`, "box-threads.json");
|
|
22
|
+
}
|
|
23
|
+
function runnerStatePath(env, threadsFile = threadsFilePath(env)) {
|
|
24
|
+
return join(dirname(threadsFile), "runner-state.json");
|
|
21
25
|
}
|
|
22
26
|
function writeRunnerState(state, path = runnerStatePath()) {
|
|
23
27
|
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
@@ -220,6 +224,7 @@ var BoxWatch = class {
|
|
|
220
224
|
|
|
221
225
|
export {
|
|
222
226
|
threadsFilePath,
|
|
227
|
+
hostedThreadsFilePath,
|
|
223
228
|
runnerStatePath,
|
|
224
229
|
writeRunnerState,
|
|
225
230
|
readRunnerState,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
freshness
|
|
4
|
+
} from "./chunk-KYGYU5G2.js";
|
|
2
5
|
import {
|
|
3
6
|
readRunnerState,
|
|
4
7
|
runnerStatePath,
|
|
5
8
|
threadsFilePath
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3OF5FEMG.js";
|
|
7
10
|
import {
|
|
8
11
|
BoxToolError,
|
|
9
12
|
CLOOP_THREAD_PREFIX,
|
|
@@ -19,6 +22,7 @@ import {
|
|
|
19
22
|
defaultT3BinSources,
|
|
20
23
|
environmentOf,
|
|
21
24
|
exchangePairing,
|
|
25
|
+
isHosted,
|
|
22
26
|
isLocal,
|
|
23
27
|
isYes,
|
|
24
28
|
localRunsFilePath,
|
|
@@ -37,7 +41,7 @@ import {
|
|
|
37
41
|
windowsExecutable,
|
|
38
42
|
windowsPowerShellEnv,
|
|
39
43
|
writeBoxConfig
|
|
40
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-PUKYUGWD.js";
|
|
41
45
|
import {
|
|
42
46
|
getMachine,
|
|
43
47
|
shortMachineName
|
|
@@ -48,24 +52,24 @@ import {
|
|
|
48
52
|
claudeTooOld,
|
|
49
53
|
codexTooOld,
|
|
50
54
|
olderThan
|
|
51
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-365HFCQQ.js";
|
|
52
56
|
import {
|
|
53
57
|
READ_TOOLS,
|
|
54
58
|
readOnlySettings
|
|
55
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-PKIEWBR7.js";
|
|
56
60
|
import {
|
|
57
61
|
connectWebhook
|
|
58
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-KDO735VV.js";
|
|
59
63
|
import {
|
|
60
64
|
ConnectFailure,
|
|
61
65
|
connectReport,
|
|
62
66
|
deviceLogin,
|
|
63
67
|
newAttempt,
|
|
64
68
|
sendConnectReport
|
|
65
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-C6EAR65U.js";
|
|
66
70
|
import {
|
|
67
71
|
VERSION
|
|
68
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-U57DZQSE.js";
|
|
69
73
|
import {
|
|
70
74
|
STAGING_ORIGIN,
|
|
71
75
|
getOrigin,
|
|
@@ -252,14 +256,118 @@ function hasChatGptApp(home, platform = process.platform, env = process.env, fs
|
|
|
252
256
|
return false;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
// src/
|
|
259
|
+
// src/runner-log.ts
|
|
260
|
+
var RUNNER_TOOLS = [
|
|
261
|
+
"status",
|
|
262
|
+
"threads.list",
|
|
263
|
+
"thread.read",
|
|
264
|
+
"thread.launch",
|
|
265
|
+
"thread.send",
|
|
266
|
+
"thread.interrupt",
|
|
267
|
+
"setup.share",
|
|
268
|
+
"diag"
|
|
269
|
+
];
|
|
270
|
+
var RUNNER_ERRORS = [
|
|
271
|
+
"expired",
|
|
272
|
+
"bad_args",
|
|
273
|
+
"no_project",
|
|
274
|
+
"harness_unavailable",
|
|
275
|
+
"harness_signed_out",
|
|
276
|
+
"runtime_mode_unknown",
|
|
277
|
+
"already_finished",
|
|
278
|
+
"repo_busy",
|
|
279
|
+
"repo_unreachable",
|
|
280
|
+
"cannot_steer",
|
|
281
|
+
"cannot_share",
|
|
282
|
+
"t3_unauthorized",
|
|
283
|
+
"t3_unreachable",
|
|
284
|
+
"t3_error",
|
|
285
|
+
"harness_error",
|
|
286
|
+
"unknown_tool",
|
|
287
|
+
"registry_unreachable",
|
|
288
|
+
"fetch_failed",
|
|
289
|
+
"npx_missing",
|
|
290
|
+
"handover_failed"
|
|
291
|
+
];
|
|
292
|
+
var HARNESS_IDS = ["claude-code", "codex", "claudeAgent", "opencode"];
|
|
256
293
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
294
|
+
var VERSION2 = /^\d{1,4}\.\d{1,4}\.\d{1,4}$/;
|
|
295
|
+
var oneOf = (list) => (value) => list.includes(value) ? value : void 0;
|
|
296
|
+
var toolCode = oneOf(RUNNER_TOOLS);
|
|
297
|
+
var uuid = (value) => typeof value === "string" && UUID.test(value) ? value : void 0;
|
|
298
|
+
var count = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 1e12 ? value : void 0;
|
|
299
|
+
var version = (value) => typeof value === "string" && VERSION2.test(value) ? value : void 0;
|
|
300
|
+
function errorCode(value) {
|
|
301
|
+
const code = typeof value === "string" && value.startsWith("unknown_tool:") ? "unknown_tool" : value;
|
|
302
|
+
return oneOf(RUNNER_ERRORS)(code);
|
|
303
|
+
}
|
|
304
|
+
function runnerLog(code, fields = {}) {
|
|
305
|
+
const shaped = {
|
|
306
|
+
call: uuid(fields.call),
|
|
307
|
+
work: uuid(fields.work),
|
|
308
|
+
tool: toolCode(fields.tool),
|
|
309
|
+
ms: count(fields.ms),
|
|
310
|
+
error: errorCode(fields.error),
|
|
311
|
+
n: count(fields.n),
|
|
312
|
+
ver: version(fields.ver)
|
|
313
|
+
};
|
|
314
|
+
const frame = { type: "log", code };
|
|
315
|
+
for (const [key, value] of Object.entries(shaped)) {
|
|
316
|
+
if (value !== void 0) Object.assign(frame, { [key]: value });
|
|
317
|
+
}
|
|
318
|
+
return frame;
|
|
319
|
+
}
|
|
320
|
+
function callOutcome(input) {
|
|
321
|
+
return {
|
|
322
|
+
at: new Date(input.at).toISOString(),
|
|
323
|
+
tool: toolCode(input.tool) ?? "other",
|
|
324
|
+
call: uuid(input.call) ?? null,
|
|
325
|
+
work: uuid(input.work) ?? null,
|
|
326
|
+
ms: count(Math.round(input.ms)) ?? 0,
|
|
327
|
+
ok: input.ok,
|
|
328
|
+
error: input.ok ? null : errorCode(input.error) ?? "other"
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function outcomeLine(o) {
|
|
332
|
+
return `call tool=${o.tool} call=${o.call ?? "-"} work=${o.work ?? "-"} ms=${o.ms} ok=${o.ok}${o.error ? ` error=${o.error}` : ""}`;
|
|
333
|
+
}
|
|
334
|
+
var PLATFORMS = ["darwin", "linux", "win32", "freebsd", "openbsd", "aix", "sunos"];
|
|
335
|
+
var ARCHES = ["arm64", "x64", "arm", "ia32", "ppc64", "s390x"];
|
|
336
|
+
var iso = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && /^\d{4}-\d\d-\d\dT[\d:.]+Z$/.test(value) ? value : null;
|
|
337
|
+
function buildDiag(input) {
|
|
338
|
+
return {
|
|
339
|
+
version: version(input.version) ?? null,
|
|
340
|
+
platform: oneOf(PLATFORMS)(input.platform) ?? "other",
|
|
341
|
+
arch: oneOf(ARCHES)(input.arch) ?? "other",
|
|
342
|
+
uptime_ms: count(Math.round(input.uptimeMs)) ?? 0,
|
|
343
|
+
last_beat_at: iso(input.lastBeatAt),
|
|
344
|
+
last_wake: input.lastWake && iso(input.lastWake.woke_at) ? { slept_ms: count(input.lastWake.slept_ms) ?? 0, woke_at: input.lastWake.woke_at } : null,
|
|
345
|
+
harnesses: input.harnesses.map((h) => ({
|
|
346
|
+
id: oneOf(HARNESS_IDS)(h.id) ?? "other",
|
|
347
|
+
version: typeof h.version === "string" ? h.version.match(/\b\d{1,4}\.\d{1,4}\.\d{1,4}\b/)?.[0] ?? null : null,
|
|
348
|
+
ready: h.ready === true,
|
|
349
|
+
signed_in: h.signedIn === true
|
|
350
|
+
})),
|
|
351
|
+
update: {
|
|
352
|
+
checked_at: iso(input.update.checked_at),
|
|
353
|
+
latest: version(input.update.latest) ?? null,
|
|
354
|
+
error: errorCode(input.update.error) ?? null
|
|
355
|
+
},
|
|
356
|
+
unacked_results: count(input.unacked) ?? 0,
|
|
357
|
+
clock_offset_ms: typeof input.clockOffsetMs === "number" && Number.isInteger(input.clockOffsetMs) && Math.abs(input.clockOffsetMs) <= 1e12 ? input.clockOffsetMs : null,
|
|
358
|
+
// Already shaped: callOutcome is the only way to make one.
|
|
359
|
+
calls: input.calls
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// src/box-tools.ts
|
|
364
|
+
var UUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
257
365
|
function parseLaunchArgs(args) {
|
|
258
366
|
const str = (v, max) => typeof v === "string" && v.trim() && v.length <= max ? v.trim() : void 0;
|
|
259
367
|
const work_id = str(args.work_id, 36);
|
|
260
368
|
const title = str(args.title, 200);
|
|
261
369
|
const prompt = str(args.prompt, 1e5);
|
|
262
|
-
if (!work_id || !
|
|
370
|
+
if (!work_id || !UUID2.test(work_id) || !title || !prompt) throw new BoxToolError("bad_args");
|
|
263
371
|
const runtime_mode = str(args.runtime_mode, 40);
|
|
264
372
|
if (runtime_mode && !RUNTIME_MODES.has(runtime_mode)) throw new BoxToolError("bad_args");
|
|
265
373
|
return {
|
|
@@ -279,7 +387,7 @@ function parseThreadId(args) {
|
|
|
279
387
|
}
|
|
280
388
|
function parseCommandId(args) {
|
|
281
389
|
const id = args.command_id;
|
|
282
|
-
if (typeof id !== "string" || !
|
|
390
|
+
if (typeof id !== "string" || !UUID2.test(id)) throw new BoxToolError("bad_args");
|
|
283
391
|
return id;
|
|
284
392
|
}
|
|
285
393
|
function parseSendArgs(args) {
|
|
@@ -325,7 +433,14 @@ var BOX_TOOLS = {
|
|
|
325
433
|
if (parsed.resume) onResume?.(parsed.thread_id);
|
|
326
434
|
return result;
|
|
327
435
|
},
|
|
328
|
-
"thread.interrupt": ({ driver }, args) => driver.interrupt(parseThreadId(args), parseCommandId(args))
|
|
436
|
+
"thread.interrupt": ({ driver }, args) => driver.interrupt(parseThreadId(args), parseCommandId(args)),
|
|
437
|
+
// Codes, ids, versions and counts only (runner-log.ts), so ops can read it without the owner.
|
|
438
|
+
diag: async ({ diag }) => diag ? diag() : null,
|
|
439
|
+
// Packs the skills before it answers, so an empty or oversized set is refused now; the upload runs on.
|
|
440
|
+
async "setup.share"({ setup }) {
|
|
441
|
+
if (!setup) throw new BoxToolError("cannot_share");
|
|
442
|
+
return setup.start();
|
|
443
|
+
}
|
|
329
444
|
};
|
|
330
445
|
function classifyError(err, driver = "t3") {
|
|
331
446
|
if (err instanceof BoxToolError) return err.code;
|
|
@@ -351,6 +466,37 @@ async function runBoxTool(ctx, tool, args) {
|
|
|
351
466
|
};
|
|
352
467
|
}
|
|
353
468
|
}
|
|
469
|
+
async function answerCall(ctx, frame, io) {
|
|
470
|
+
const now = io.now ?? Date.now;
|
|
471
|
+
const started = now();
|
|
472
|
+
const offset = io.offset();
|
|
473
|
+
const fresh = freshness(frame.deadline, started, offset);
|
|
474
|
+
if (fresh !== "fresh") {
|
|
475
|
+
io.send(
|
|
476
|
+
runnerLog(fresh === "expired" ? "call_expired" : "call_late", {
|
|
477
|
+
call: frame.id,
|
|
478
|
+
tool: frame.tool,
|
|
479
|
+
work: frame.args.work_id,
|
|
480
|
+
ms: started + (offset ?? 0) - (frame.deadline ?? started)
|
|
481
|
+
})
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
const result = fresh === "expired" ? { ok: false, error: "expired" } : await runBoxTool(ctx, frame.tool, frame.args);
|
|
485
|
+
io.send({ type: "result", id: frame.id, ...result });
|
|
486
|
+
const outcome = callOutcome({
|
|
487
|
+
at: started,
|
|
488
|
+
tool: frame.tool,
|
|
489
|
+
call: frame.id,
|
|
490
|
+
work: frame.args.work_id,
|
|
491
|
+
ms: now() - started,
|
|
492
|
+
ok: result.ok,
|
|
493
|
+
error: result.ok ? void 0 : result.error
|
|
494
|
+
});
|
|
495
|
+
io.log(outcomeLine(outcome));
|
|
496
|
+
if (!result.ok && "detail" in result && result.detail)
|
|
497
|
+
io.log(`call_detail call=${frame.id} ${result.detail.slice(0, 300)}`);
|
|
498
|
+
return outcome;
|
|
499
|
+
}
|
|
354
500
|
|
|
355
501
|
// src/device-revoke.ts
|
|
356
502
|
function tokenGone(revoke) {
|
|
@@ -423,13 +569,13 @@ async function probeClaude(bin = "claude") {
|
|
|
423
569
|
exec(bin, ["--version"]),
|
|
424
570
|
exec(bin, ["auth", "status", "--json"])
|
|
425
571
|
]);
|
|
426
|
-
const
|
|
427
|
-
if (!
|
|
572
|
+
const version2 = versionOut?.trim().split(/\s+/)[0];
|
|
573
|
+
if (!version2) return null;
|
|
428
574
|
const { signedIn, account } = claudeAccount(auth);
|
|
429
575
|
return {
|
|
430
576
|
id: "claude-code",
|
|
431
577
|
name: "Claude Code",
|
|
432
|
-
version,
|
|
578
|
+
version: version2,
|
|
433
579
|
ready: signedIn,
|
|
434
580
|
signedIn,
|
|
435
581
|
account,
|
|
@@ -689,16 +835,16 @@ function codexAccount(ok, out2) {
|
|
|
689
835
|
return { signedIn: true, account: /chatgpt/i.test(out2) ? "ChatGPT" : "API key" };
|
|
690
836
|
}
|
|
691
837
|
async function probeCodex(bin = "codex") {
|
|
692
|
-
const [
|
|
838
|
+
const [version2, status] = await Promise.all([
|
|
693
839
|
exec2(bin, ["--version"]),
|
|
694
840
|
exec2(bin, ["login", "status"])
|
|
695
841
|
]);
|
|
696
|
-
if (!
|
|
842
|
+
if (!version2.ok) return null;
|
|
697
843
|
const { signedIn, account } = codexAccount(status.ok, status.out);
|
|
698
844
|
return {
|
|
699
845
|
id: "codex",
|
|
700
846
|
name: "Codex",
|
|
701
|
-
version:
|
|
847
|
+
version: version2.out.trim().split(/\s+/).at(-1) ?? null,
|
|
702
848
|
ready: signedIn,
|
|
703
849
|
signedIn,
|
|
704
850
|
account,
|
|
@@ -816,7 +962,7 @@ function existingRunnerEnvironment() {
|
|
|
816
962
|
const found = runnersOnThisComputer();
|
|
817
963
|
return found.length === 1 && found[0] ? found[0] : "production";
|
|
818
964
|
}
|
|
819
|
-
var BOTH_RUNNERS_LINE = "This computer
|
|
965
|
+
var BOTH_RUNNERS_LINE = "This computer is a production machine and a staging machine. This acts on the production machine. Add --staging for the staging machine.";
|
|
820
966
|
function pinExistingRunner() {
|
|
821
967
|
const named = Boolean(process.env.CLOOP_ORIGIN);
|
|
822
968
|
const environment = existingRunnerEnvironment();
|
|
@@ -829,7 +975,7 @@ function pinExistingRunner() {
|
|
|
829
975
|
|
|
830
976
|
// src/commands/disconnect.ts
|
|
831
977
|
function doneLine(env) {
|
|
832
|
-
return `This computer is no longer a ${env} Cloop
|
|
978
|
+
return `This computer is no longer a ${env} Cloop machine. To connect it again: ${["npx -y @cloop/runner@latest connect", ENVIRONMENTS[env].flag].filter(Boolean).join(" ")}`;
|
|
833
979
|
}
|
|
834
980
|
function unitOrigin(contents) {
|
|
835
981
|
const plist = /<key>CLOOP_ORIGIN<\/key><string>([^<]+)<\/string>/.exec(contents)?.[1];
|
|
@@ -882,11 +1028,11 @@ function revokeLine(revoke, origin, box) {
|
|
|
882
1028
|
case "already_revoked":
|
|
883
1029
|
return [`Cloop (${origin}) had already revoked this computer.`];
|
|
884
1030
|
case "no_device":
|
|
885
|
-
return ["No
|
|
1031
|
+
return ["No machine device on this computer to revoke."];
|
|
886
1032
|
case "unknown_device":
|
|
887
1033
|
return [
|
|
888
1034
|
`Cloop at ${origin} never issued this computer's device token, so it belongs to the other environment.${keep}`,
|
|
889
|
-
"Run `cloop disconnect --staging` for a staging
|
|
1035
|
+
"Run `cloop disconnect --staging` for a staging machine, or `cloop disconnect` for production."
|
|
890
1036
|
];
|
|
891
1037
|
case "failed":
|
|
892
1038
|
return [
|
|
@@ -907,7 +1053,7 @@ async function disconnect(plan, opts) {
|
|
|
907
1053
|
const unit = plan.services.map((s) => basename4(s.path)).find((n) => n.startsWith("cloop-box"));
|
|
908
1054
|
say(`This computer runs ${unit}, the ${env} Cloop box with T3 Code. Disconnect would:`);
|
|
909
1055
|
for (const s of plan.services) say(` stop and remove ${s.path}`);
|
|
910
|
-
if (plan.deviceToken) say(` revoke its
|
|
1056
|
+
if (plan.deviceToken) say(` revoke its machine device on Cloop (${plan.origin})`);
|
|
911
1057
|
for (const f of [...plan.box ? [plan.box] : [], ...plan.files]) say(` delete ${f}`);
|
|
912
1058
|
say(`Run \`${cloopCommand(env, "disconnect --yes")}\` to do this.`);
|
|
913
1059
|
return 1;
|
|
@@ -1010,7 +1156,7 @@ async function moveLegacyStagingRunner(services) {
|
|
|
1010
1156
|
for (const unit of units)
|
|
1011
1157
|
if (!await stopService(unit, run))
|
|
1012
1158
|
throw new Error(
|
|
1013
|
-
`Could not stop the staging
|
|
1159
|
+
`Could not stop the staging machine in ${unit.path}. Stop it with \`${unit.steps.map((s) => s.command.join(" ")).join(" && ")}\`, then run this again.`
|
|
1014
1160
|
);
|
|
1015
1161
|
for (const unit of units) rmSync2(unit.path, { force: true });
|
|
1016
1162
|
moveRunnerFiles(runnerDir("production"), runnerDir("staging"));
|
|
@@ -1018,7 +1164,7 @@ async function moveLegacyStagingRunner(services) {
|
|
|
1018
1164
|
return true;
|
|
1019
1165
|
}
|
|
1020
1166
|
function movedLine(connecting) {
|
|
1021
|
-
const line2 = "Moved the staging
|
|
1167
|
+
const line2 = "Moved the staging machine from ~/.cloop to ~/.cloop/staging, so a production machine can run beside it.";
|
|
1022
1168
|
return connecting === "staging" ? line2 : `${line2} It is stopped. Start it again with: cloop connect --staging`;
|
|
1023
1169
|
}
|
|
1024
1170
|
|
|
@@ -1387,7 +1533,7 @@ async function connectBox(steps) {
|
|
|
1387
1533
|
steps.writeBoxConfig(cfg);
|
|
1388
1534
|
return cfg;
|
|
1389
1535
|
}
|
|
1390
|
-
var NONE = "No coding agent found on this machine. Install Claude Code or
|
|
1536
|
+
var NONE = "No coding agent found on this machine. Install Claude Code or the ChatGPT desktop app, sign in, then run `cloop connect` again.";
|
|
1391
1537
|
var SIGNED_OUT = {
|
|
1392
1538
|
"claude-code": "Claude Code is installed but not signed in. Run `claude` once and sign in, then run `cloop connect` again.",
|
|
1393
1539
|
codex: "Codex is installed but not signed in. Run `codex login`, then run `cloop connect` again."
|
|
@@ -1440,12 +1586,12 @@ function boxServiceInstalled() {
|
|
|
1440
1586
|
}).path
|
|
1441
1587
|
);
|
|
1442
1588
|
}
|
|
1443
|
-
var KIND_NAME = { workstation: "a Cloop box with T3 Code", local: "a
|
|
1589
|
+
var KIND_NAME = { workstation: "a Cloop box with T3 Code", local: "a local machine" };
|
|
1444
1590
|
async function revokeReplaced(previous, kind, revoke, say) {
|
|
1445
1591
|
if (!previous?.deviceToken || isLocal(previous) === (kind === "local")) return;
|
|
1446
1592
|
const was = isLocal(previous) ? "local" : "workstation";
|
|
1447
1593
|
say(
|
|
1448
|
-
`${bold("Cloop
|
|
1594
|
+
`${bold("Cloop machine")} This computer was ${KIND_NAME[was]}. It becomes ${KIND_NAME[kind]}, so its old device goes.`
|
|
1449
1595
|
);
|
|
1450
1596
|
say(
|
|
1451
1597
|
tokenGone(await revoke(previous.deviceToken)) ? " Revoked the old device on Cloop." : " Could not revoke the old device. Press Disconnect on its card on the Threads page."
|
|
@@ -1525,11 +1671,11 @@ var endDaemonStep = (environment) => ({
|
|
|
1525
1671
|
],
|
|
1526
1672
|
mayFail: true
|
|
1527
1673
|
});
|
|
1528
|
-
function programFor(script, node, npx,
|
|
1674
|
+
function programFor(script, node, npx, version2) {
|
|
1529
1675
|
if (!/[\\/]_npx[\\/]/.test(script)) return [node, script, "box", "run"];
|
|
1530
1676
|
if (!npx)
|
|
1531
1677
|
return "npx is not on PATH, so the service cannot run Cloop. Install it with `npm install -g @cloop/runner` and run `cloop connect` again.";
|
|
1532
|
-
return [npx, "-y", `@cloop/runner@${
|
|
1678
|
+
return [npx, "-y", `@cloop/runner@${version2}`, "box", "run"];
|
|
1533
1679
|
}
|
|
1534
1680
|
function findNpx() {
|
|
1535
1681
|
const name = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
@@ -1792,7 +1938,7 @@ function workFolderLine(found, home, argv, terminal) {
|
|
|
1792
1938
|
}
|
|
1793
1939
|
async function askRepos(found, home, ask, say) {
|
|
1794
1940
|
const work = workFolder(home);
|
|
1795
|
-
say(`${bold("Cloop
|
|
1941
|
+
say(`${bold("Cloop machine")} This folder is not a git checkout. Recent ones:`);
|
|
1796
1942
|
found.forEach((r, i) => say(` ${i + 1} ${r.label} ${dim(tilde(r.path, home))}`));
|
|
1797
1943
|
for (; ; ) {
|
|
1798
1944
|
const answer = (await ask(
|
|
@@ -1832,7 +1978,7 @@ async function reposFor(argv) {
|
|
|
1832
1978
|
} finally {
|
|
1833
1979
|
prompt.close();
|
|
1834
1980
|
}
|
|
1835
|
-
} else out(`${bold("Cloop
|
|
1981
|
+
} else out(`${bold("Cloop machine")} ${workFolderLine(found, home, argv, terminal)}`);
|
|
1836
1982
|
if (repos.some((r) => r.path === work.path)) mkdirSync2(work.path, { recursive: true });
|
|
1837
1983
|
return repos;
|
|
1838
1984
|
}
|
|
@@ -1871,9 +2017,9 @@ async function t3Answers(t3Url) {
|
|
|
1871
2017
|
}
|
|
1872
2018
|
}
|
|
1873
2019
|
function harnessLine(h) {
|
|
1874
|
-
const
|
|
2020
|
+
const version2 = h.version ? ` ${h.version}` : "";
|
|
1875
2021
|
const account = h.signedIn ? h.account ?? "signed in" : "signed out";
|
|
1876
|
-
return `${h.name}${
|
|
2022
|
+
return `${h.name}${version2}, ${account}${h.experimental ? " (experimental)" : ""}`;
|
|
1877
2023
|
}
|
|
1878
2024
|
async function runSteps(steps, run = (command) => void execFileSync2(command[0], command.slice(1), { stdio: "ignore", timeout: 15e3 }), wait = (ms) => new Promise((r) => setTimeout(r, ms))) {
|
|
1879
2025
|
for (const step of steps) {
|
|
@@ -1952,7 +2098,7 @@ async function installService(kind, argv, attempt, services = systemServices) {
|
|
|
1952
2098
|
try {
|
|
1953
2099
|
if (existsSync5(unit.retire.path)) {
|
|
1954
2100
|
out(
|
|
1955
|
-
` This computer
|
|
2101
|
+
` This computer is already a ${environment} machine, so connect stops and removes ${unit.retire.path}.`
|
|
1956
2102
|
);
|
|
1957
2103
|
await runSteps(unit.retire.steps, run);
|
|
1958
2104
|
rmSync3(unit.retire.path, { force: true });
|
|
@@ -1967,21 +2113,21 @@ async function installService(kind, argv, attempt, services = systemServices) {
|
|
|
1967
2113
|
attempt.step = "first_connect";
|
|
1968
2114
|
if (!await services.awaitUp(since)) {
|
|
1969
2115
|
out(
|
|
1970
|
-
`${red("\u2717")} ${unit.path} started, but the
|
|
2116
|
+
`${red("\u2717")} ${unit.path} started, but the machine did not reach Cloop within 15 s. Its last log lines:`
|
|
1971
2117
|
);
|
|
1972
2118
|
try {
|
|
1973
2119
|
out(services.run(unit.tail));
|
|
1974
2120
|
} catch {
|
|
1975
2121
|
out(` (no log yet; run ${unit.logs})`);
|
|
1976
2122
|
}
|
|
1977
|
-
throw new ConnectFailure("first_connect_timeout", "the
|
|
2123
|
+
throw new ConnectFailure("first_connect_timeout", "the machine did not reach Cloop", true);
|
|
1978
2124
|
}
|
|
1979
2125
|
if (services.platform === "linux") {
|
|
1980
2126
|
const user = userInfo().username;
|
|
1981
2127
|
const linger = ensureLinger(user, services.run);
|
|
1982
2128
|
if (!linger.ok) {
|
|
1983
2129
|
out(
|
|
1984
|
-
`${red("\u2717")} The
|
|
2130
|
+
`${red("\u2717")} The machine is up, but it stops when you log out of this computer. Run this, then run cloop connect again: ${bold(linger.command)}`
|
|
1985
2131
|
);
|
|
1986
2132
|
throw new ConnectFailure(
|
|
1987
2133
|
"service_start_failed",
|
|
@@ -1990,10 +2136,10 @@ async function installService(kind, argv, attempt, services = systemServices) {
|
|
|
1990
2136
|
);
|
|
1991
2137
|
}
|
|
1992
2138
|
if (linger.changed)
|
|
1993
|
-
out(` Linger: turned on for ${user}, so the
|
|
2139
|
+
out(` Linger: turned on for ${user}, so the machine keeps running after you log out.`);
|
|
1994
2140
|
}
|
|
1995
2141
|
out(` Service: ${unit.path}, started and connected. Logs: ${dim(unit.logs)}`);
|
|
1996
|
-
out(`${bold("Cloop
|
|
2142
|
+
out(`${bold("Cloop machine")} Connected the ${environment} machine.`);
|
|
1997
2143
|
}
|
|
1998
2144
|
async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
1999
2145
|
const previous = readRunnerConfig();
|
|
@@ -2010,7 +2156,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
2010
2156
|
readEnvironment: async () => {
|
|
2011
2157
|
const environment = await readEnvironment(t3Url);
|
|
2012
2158
|
out(
|
|
2013
|
-
`${bold("Cloop
|
|
2159
|
+
`${bold("Cloop machine")} Connecting ${shortMachineName(environment.label)} (T3 ${environment.serverVersion}) to Cloop with @cloop/runner ${VERSION}.`
|
|
2014
2160
|
);
|
|
2015
2161
|
return environment;
|
|
2016
2162
|
},
|
|
@@ -2061,7 +2207,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
2061
2207
|
out
|
|
2062
2208
|
);
|
|
2063
2209
|
out(
|
|
2064
|
-
`${bold("Cloop
|
|
2210
|
+
`${bold("Cloop machine")} T3 ${cfg.label} paired with scope ${cfg.scope}, until ${cfg.expiresAt.slice(0, 10)}.`
|
|
2065
2211
|
);
|
|
2066
2212
|
if (byLink)
|
|
2067
2213
|
out(
|
|
@@ -2100,7 +2246,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
|
2100
2246
|
version: `${harness.name} ${harness.version ?? ""}`.trim()
|
|
2101
2247
|
};
|
|
2102
2248
|
out(
|
|
2103
|
-
`${bold("Cloop
|
|
2249
|
+
`${bold("Cloop machine")} Connecting ${deviceName} as a local machine with ${harnessLine(harness)}, using @cloop/runner ${VERSION}.`
|
|
2104
2250
|
);
|
|
2105
2251
|
attempt.step = "login";
|
|
2106
2252
|
const deviceToken = await deviceLogin({ origin: getOrigin(), deviceName, device });
|
|
@@ -2129,7 +2275,7 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
|
2129
2275
|
(h) => Boolean(h) && h !== harness
|
|
2130
2276
|
);
|
|
2131
2277
|
out(
|
|
2132
|
-
`${bold("Cloop
|
|
2278
|
+
`${bold("Cloop machine")} ${deviceName} is a local machine: ${[harness, ...others].map(harnessLine).join("; ")}.`
|
|
2133
2279
|
);
|
|
2134
2280
|
out(` Folders: ${repos.map((r) => `${r.label} (${r.path})`).join(", ")}`);
|
|
2135
2281
|
out(
|
|
@@ -2154,7 +2300,7 @@ function harnessesFound(found) {
|
|
|
2154
2300
|
}
|
|
2155
2301
|
var MODEL_LIST = /^[A-Za-z0-9][\w.:[\]-]*(,[A-Za-z0-9][\w.:[\]-]*)*$/;
|
|
2156
2302
|
function rememberedDriver(previous) {
|
|
2157
|
-
const chosen = previous
|
|
2303
|
+
const chosen = previous && !isHosted(previous) ? previous.chosenDriver : void 0;
|
|
2158
2304
|
return chosen && DRIVERS.includes(chosen) ? chosen : void 0;
|
|
2159
2305
|
}
|
|
2160
2306
|
var DRIVERS = ["t3", "claude-code", "codex"];
|
|
@@ -2170,7 +2316,7 @@ async function connect(argv, attempt, deps = {}) {
|
|
|
2170
2316
|
const forced = named ?? rememberedDriver(previous);
|
|
2171
2317
|
if (forced && !named)
|
|
2172
2318
|
out(
|
|
2173
|
-
`${bold("Cloop
|
|
2319
|
+
`${bold("Cloop machine")} This machine runs Cloop work in ${DRIVER_NAME[forced]}, as you chose. Change it with: cloop use <t3|claude-code|codex>`
|
|
2174
2320
|
);
|
|
2175
2321
|
const fallback = flag(argv, "--fallback-model");
|
|
2176
2322
|
if (fallback !== void 0 && !MODEL_LIST.test(fallback))
|
|
@@ -2219,7 +2365,7 @@ async function connect(argv, attempt, deps = {}) {
|
|
|
2219
2365
|
t3: () => connectT3(argv, attempt, local ? HARNESS_NAME[local] : null, forced, deps.services),
|
|
2220
2366
|
local: (driver) => connectLocal(driver, current, argv, attempt, forced, deps.services),
|
|
2221
2367
|
fallback: () => fallbackDriver(current, forced, workstation),
|
|
2222
|
-
say: (line2) => out(`${bold("Cloop
|
|
2368
|
+
say: (line2) => out(`${bold("Cloop machine")} ${line2}`)
|
|
2223
2369
|
});
|
|
2224
2370
|
const harnesses = [];
|
|
2225
2371
|
if (current.claude) harnesses.push({ harness: "claude-code", bin: harnessBin("claude") });
|
|
@@ -2231,7 +2377,7 @@ var MCP_STEP_MS = 6 * 6e4;
|
|
|
2231
2377
|
async function addCloopMcpLast(found, attempt, mcp, terminal) {
|
|
2232
2378
|
if (!found.length) return;
|
|
2233
2379
|
const server = mcpServer(runnerEnvironment());
|
|
2234
|
-
const say = (line2) => out(`${bold("Cloop
|
|
2380
|
+
const say = (line2) => out(`${bold("Cloop machine")} ${line2}`);
|
|
2235
2381
|
const left = new Set(found.map(({ harness }) => harness));
|
|
2236
2382
|
const byHand = () => [...left].flatMap((harness) => mcpByHand(harness, server)).join(", then: ");
|
|
2237
2383
|
let late = false;
|
|
@@ -2246,7 +2392,7 @@ async function addCloopMcpLast(found, attempt, mcp, terminal) {
|
|
|
2246
2392
|
`[runner:mcp] harness=${harness} registered=${result.registered} signed_in=${result.signedIn} reason=${result.reason ?? "none"}`
|
|
2247
2393
|
);
|
|
2248
2394
|
out(
|
|
2249
|
-
result.registered ? `${bold("Cloop
|
|
2395
|
+
result.registered ? `${bold("Cloop machine")} ${mcpLine(result)}` : `${red("\u2717")} ${mcpLine(result)}`
|
|
2250
2396
|
);
|
|
2251
2397
|
}
|
|
2252
2398
|
})();
|
|
@@ -2273,7 +2419,7 @@ async function addCloopMcpLast(found, attempt, mcp, terminal) {
|
|
|
2273
2419
|
async function prepareAgents(found, forced, workstation, deps) {
|
|
2274
2420
|
if (workstation || forced === "t3") return found;
|
|
2275
2421
|
let current = found;
|
|
2276
|
-
const say = (line2) => out(`${bold("Cloop
|
|
2422
|
+
const say = (line2) => out(`${bold("Cloop machine")} ${line2}`);
|
|
2277
2423
|
const chatGptApp = forced !== "claude-code" && deps.chatGptApp();
|
|
2278
2424
|
const getCodex = async (why, reason) => {
|
|
2279
2425
|
say(`${why} Installing the latest Codex from ${CODEX_RELEASES}.`);
|
|
@@ -2345,17 +2491,17 @@ function signInClaude(bin) {
|
|
|
2345
2491
|
return runShown2([bin, "auth", "login"], true).status === 0 ? probeClaude(bin) : Promise.resolve(null);
|
|
2346
2492
|
}
|
|
2347
2493
|
async function claudeAtFloor(found, forced, update) {
|
|
2348
|
-
const
|
|
2494
|
+
const version2 = found.claude?.version;
|
|
2349
2495
|
const codex = forced === "codex" || !forced && !found.claude?.signedIn && Boolean(found.codex?.signedIn);
|
|
2350
|
-
if (!
|
|
2351
|
-
out(`${bold("Cloop
|
|
2496
|
+
if (!version2 || codex || !olderThan(version2, CLAUDE_FLOOR)) return found;
|
|
2497
|
+
out(`${bold("Cloop machine")} ${claudeTooOld(version2)} Updating it.`);
|
|
2352
2498
|
const claude = await update();
|
|
2353
2499
|
if (!claude?.version || olderThan(claude.version, CLAUDE_FLOOR))
|
|
2354
2500
|
throw new ConnectFailure(
|
|
2355
2501
|
"harness_outdated",
|
|
2356
2502
|
"Claude Code did not update. Run `claude update`, then run `cloop connect` again."
|
|
2357
2503
|
);
|
|
2358
|
-
out(`${bold("Cloop
|
|
2504
|
+
out(`${bold("Cloop machine")} Claude Code updated to ${claude.version}.`);
|
|
2359
2505
|
return { ...found, claude };
|
|
2360
2506
|
}
|
|
2361
2507
|
var WINGET_MANAGED = /winget upgrade Anthropic\.ClaudeCode/;
|
|
@@ -2372,7 +2518,7 @@ async function updateClaude(run = runShown2, probe = probeClaude) {
|
|
|
2372
2518
|
const update = run(["claude", "update"], false);
|
|
2373
2519
|
if (WINGET_MANAGED.test(update.output)) {
|
|
2374
2520
|
out(
|
|
2375
|
-
`${bold("Cloop
|
|
2521
|
+
`${bold("Cloop machine")} winget installed Claude Code, so connect updates it with winget.`
|
|
2376
2522
|
);
|
|
2377
2523
|
if (run(WINGET_UPDATE, true).status !== 0) return null;
|
|
2378
2524
|
} else {
|
|
@@ -2403,7 +2549,7 @@ async function runConnect(argv, deps = {}) {
|
|
|
2403
2549
|
attempt.step = "legacy_move";
|
|
2404
2550
|
try {
|
|
2405
2551
|
if (await moveLegacyStagingRunner(deps.services ?? systemServices))
|
|
2406
|
-
out(`${bold("Cloop
|
|
2552
|
+
out(`${bold("Cloop machine")} ${movedLine(environment)}`);
|
|
2407
2553
|
} catch (err) {
|
|
2408
2554
|
throw new ConnectFailure(
|
|
2409
2555
|
"legacy_move_failed",
|
|
@@ -2434,7 +2580,11 @@ async function connectCommand(argv) {
|
|
|
2434
2580
|
}
|
|
2435
2581
|
|
|
2436
2582
|
export {
|
|
2437
|
-
|
|
2583
|
+
runnerLog,
|
|
2584
|
+
buildDiag,
|
|
2585
|
+
classifyError,
|
|
2586
|
+
answerCall,
|
|
2587
|
+
SUBSCRIPTIONS,
|
|
2438
2588
|
probeClaudePermissions,
|
|
2439
2589
|
probeClaude,
|
|
2440
2590
|
DEFAULT_FALLBACK_MODEL,
|