@cloop/runner 0.3.2 → 0.3.8
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 -0
- package/dist/{box-VE2WJH3A.js → box-HUVPOJZK.js} +315 -39
- package/dist/{chunk-6SRPPUR2.js → chunk-3IP5XIPV.js} +3 -3
- package/dist/{chunk-43GTYT5U.js → chunk-3TDL6X5T.js} +1 -1
- package/dist/{chunk-NEGKYXHS.js → chunk-3WD7S6VI.js} +235 -87
- package/dist/{chunk-UIFPQQCQ.js → chunk-4MM5O7TV.js} +1 -1
- package/dist/{chunk-CKFWWGDD.js → chunk-EQTFHMUJ.js} +1 -1
- package/dist/{chunk-23ZHP4EN.js → chunk-GUPXSBOJ.js} +221 -64
- package/dist/{chunk-LOSZGPY4.js → chunk-OODVBR3F.js} +1 -1
- package/dist/{chunk-LAQSZU6I.js → chunk-WE4KRF7A.js} +3 -1
- package/dist/{connect-YCCLIBTL.js → connect-YJA2CS6L.js} +24 -10
- package/dist/{disconnect-TVAN3LLV.js → disconnect-S4GR7LCM.js} +6 -6
- package/dist/index.js +17 -15
- package/dist/{login-OF62R2RQ.js → login-RAZOAK6J.js} +2 -2
- package/dist/{mcp-server-V2M6VOQP.js → mcp-server-673BK6ER.js} +1 -1
- package/dist/{runner-64HZZDG6.js → runner-NZRNAFEP.js} +3 -3
- package/dist/{runs-4DXIUYDF.js → runs-RZL34AFT.js} +2 -2
- package/dist/{statusline-354ALD5T.js → statusline-KIE2H6EM.js} +1 -1
- package/dist/{takeover-Y7ZKSHGQ.js → takeover-V2IHVUAB.js} +4 -4
- package/dist/{use-AECELCU6.js → use-ZP4SPNI6.js} +6 -6
- package/package.json +1 -1
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
readRunnerState,
|
|
4
4
|
runnerStatePath,
|
|
5
5
|
threadsFilePath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EQTFHMUJ.js";
|
|
7
7
|
import {
|
|
8
8
|
BoxToolError,
|
|
9
9
|
CLOOP_THREAD_PREFIX,
|
|
10
10
|
RUNTIME_MODES,
|
|
11
11
|
T3Driver,
|
|
12
12
|
boxPath,
|
|
13
|
+
commandFor,
|
|
13
14
|
defaultT3BinSources,
|
|
14
15
|
isLocal,
|
|
15
16
|
isYes,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
t3BaseDirArgs,
|
|
23
24
|
t3Candidates,
|
|
24
25
|
writeBoxConfig
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3WD7S6VI.js";
|
|
26
27
|
import {
|
|
27
28
|
CLAUDE_FLOOR,
|
|
28
29
|
claudeTooOld,
|
|
@@ -38,17 +39,17 @@ import {
|
|
|
38
39
|
} from "./chunk-R3CLO2FB.js";
|
|
39
40
|
import {
|
|
40
41
|
connectWebhook
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-OODVBR3F.js";
|
|
42
43
|
import {
|
|
43
44
|
ConnectFailure,
|
|
44
45
|
connectReport,
|
|
45
46
|
deviceLogin,
|
|
46
47
|
newAttempt,
|
|
47
48
|
sendConnectReport
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-WE4KRF7A.js";
|
|
49
50
|
import {
|
|
50
51
|
VERSION
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-4MM5O7TV.js";
|
|
52
53
|
import {
|
|
53
54
|
STAGING_ORIGIN,
|
|
54
55
|
getOrigin,
|
|
@@ -86,7 +87,14 @@ async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
|
|
|
86
87
|
// src/commands/connect.ts
|
|
87
88
|
import { execFileSync } from "child_process";
|
|
88
89
|
import { randomUUID } from "crypto";
|
|
89
|
-
import {
|
|
90
|
+
import {
|
|
91
|
+
existsSync,
|
|
92
|
+
mkdirSync,
|
|
93
|
+
readdirSync,
|
|
94
|
+
rmSync,
|
|
95
|
+
statSync,
|
|
96
|
+
writeFileSync
|
|
97
|
+
} from "fs";
|
|
90
98
|
import { homedir, userInfo } from "os";
|
|
91
99
|
import { basename as basename3, dirname, join, resolve as resolve2 } from "path";
|
|
92
100
|
import { createInterface } from "readline/promises";
|
|
@@ -371,11 +379,16 @@ var SUBSCRIPTIONS = {
|
|
|
371
379
|
enterprise: "Claude Enterprise"
|
|
372
380
|
};
|
|
373
381
|
function exec(bin, args) {
|
|
382
|
+
const command = commandFor(bin, args);
|
|
374
383
|
return new Promise(
|
|
375
384
|
(resolve3) => execFile(
|
|
376
|
-
|
|
377
|
-
args,
|
|
378
|
-
{
|
|
385
|
+
command.file,
|
|
386
|
+
command.args,
|
|
387
|
+
{
|
|
388
|
+
timeout: 1e4,
|
|
389
|
+
encoding: "utf-8",
|
|
390
|
+
...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
391
|
+
},
|
|
379
392
|
(err, out2) => resolve3(err ? null : String(out2))
|
|
380
393
|
)
|
|
381
394
|
);
|
|
@@ -644,11 +657,16 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
|
|
|
644
657
|
import { execFile as execFile2 } from "child_process";
|
|
645
658
|
import { basename as basename2 } from "path";
|
|
646
659
|
function exec2(bin, args) {
|
|
660
|
+
const command = commandFor(bin, args);
|
|
647
661
|
return new Promise(
|
|
648
662
|
(resolve3) => execFile2(
|
|
649
|
-
|
|
650
|
-
args,
|
|
651
|
-
{
|
|
663
|
+
command.file,
|
|
664
|
+
command.args,
|
|
665
|
+
{
|
|
666
|
+
timeout: 1e4,
|
|
667
|
+
encoding: "utf-8",
|
|
668
|
+
...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
|
|
669
|
+
},
|
|
652
670
|
(err, out2, errOut) => resolve3({ ok: !err, out: `${out2}${errOut}` })
|
|
653
671
|
)
|
|
654
672
|
);
|
|
@@ -727,7 +745,7 @@ function codexDialect(bin = "codex") {
|
|
|
727
745
|
keepsStdin: false,
|
|
728
746
|
args(run, resume) {
|
|
729
747
|
const model = run.model ? ["--model", run.model] : [];
|
|
730
|
-
const policy = ["--dangerously-bypass-approvals-and-sandbox"];
|
|
748
|
+
const policy = ["--dangerously-bypass-approvals-and-sandbox", "--skip-git-repo-check"];
|
|
731
749
|
return resume && run.session_id ? ["exec", ...policy, "resume", run.session_id, "--json", ...model, "-"] : ["exec", "--cd", run.repo, "--json", ...policy, ...model, "-"];
|
|
732
750
|
},
|
|
733
751
|
opening: (_run, prompt) => prompt,
|
|
@@ -777,12 +795,32 @@ function flags(argv, name) {
|
|
|
777
795
|
return argv.flatMap((a, i) => a === name && argv[i + 1] ? [argv[i + 1]] : []);
|
|
778
796
|
}
|
|
779
797
|
function which(bin) {
|
|
798
|
+
return process.platform === "win32" ? where(bin) : whichPosix(bin);
|
|
799
|
+
}
|
|
800
|
+
function whichPosix(bin) {
|
|
780
801
|
try {
|
|
781
802
|
return execFileSync("which", [bin], { encoding: "utf-8", env: CLEAN_ENV }).trim() || null;
|
|
782
803
|
} catch {
|
|
783
804
|
return null;
|
|
784
805
|
}
|
|
785
806
|
}
|
|
807
|
+
function where(bin) {
|
|
808
|
+
try {
|
|
809
|
+
const found = execFileSync("where", [bin], {
|
|
810
|
+
encoding: "utf-8",
|
|
811
|
+
// `where` matches extensions through PATHEXT, which CLEAN_ENV alone drops.
|
|
812
|
+
env: { ...CLEAN_ENV, PATHEXT: process.env.PATHEXT, SystemRoot: process.env.SystemRoot }
|
|
813
|
+
});
|
|
814
|
+
return preferExecutable(
|
|
815
|
+
found.split(/\r?\n/).map((line2) => line2.trim()).filter(Boolean)
|
|
816
|
+
);
|
|
817
|
+
} catch {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
function preferExecutable(lines) {
|
|
822
|
+
return lines.find((line2) => /\.exe$/i.test(line2)) ?? lines.find((line2) => /\.(cmd|bat)$/i.test(line2)) ?? lines[0] ?? null;
|
|
823
|
+
}
|
|
786
824
|
var T3PairError = class extends Error {
|
|
787
825
|
name = "T3PairError";
|
|
788
826
|
};
|
|
@@ -972,12 +1010,23 @@ function systemdWord(arg) {
|
|
|
972
1010
|
const escaped = arg.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/g, "%%").replace(/\$/g, "$$$$");
|
|
973
1011
|
return `"${escaped}"`;
|
|
974
1012
|
}
|
|
1013
|
+
function cmdValue(value) {
|
|
1014
|
+
return value.replace(/%/g, "%%");
|
|
1015
|
+
}
|
|
1016
|
+
function cmdWord(arg) {
|
|
1017
|
+
return `"${cmdValue(arg)}"`;
|
|
1018
|
+
}
|
|
975
1019
|
function programFor(script, node, npx, version) {
|
|
976
|
-
if (
|
|
1020
|
+
if (!/[\\/]_npx[\\/]/.test(script)) return [node, script, "box", "run"];
|
|
977
1021
|
if (!npx)
|
|
978
1022
|
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.";
|
|
979
1023
|
return [npx, "-y", `@cloop/runner@${version}`, "box", "run"];
|
|
980
1024
|
}
|
|
1025
|
+
function findNpx() {
|
|
1026
|
+
const name = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
1027
|
+
const beside = join(dirname(process.execPath), name);
|
|
1028
|
+
return existsSync(beside) ? beside : which(name);
|
|
1029
|
+
}
|
|
981
1030
|
async function awaitDaemon(since, read = readRunnerState, { timeoutMs = 15e3, pollMs = 500 } = {}) {
|
|
982
1031
|
for (let waited = 0; ; waited += pollMs) {
|
|
983
1032
|
const state = read();
|
|
@@ -991,6 +1040,7 @@ var UNIT_ENV = [
|
|
|
991
1040
|
"CLOOP_BOX_FILE",
|
|
992
1041
|
"CLOOP_BOX_THREADS_FILE",
|
|
993
1042
|
"CLOOP_LOCAL_RUNS_FILE",
|
|
1043
|
+
"CLOOP_UPDATE_DIR",
|
|
994
1044
|
"CLOOP_MESH_URL",
|
|
995
1045
|
"CLOOP_ORIGIN",
|
|
996
1046
|
"T3CODE_HOME"
|
|
@@ -1013,6 +1063,17 @@ function installedService(opts) {
|
|
|
1013
1063
|
running: ["launchctl", "print", `gui/${opts.uid}/${label}`]
|
|
1014
1064
|
};
|
|
1015
1065
|
}
|
|
1066
|
+
if (opts.platform === "win32") {
|
|
1067
|
+
const task = name === "box" ? "Cloop Box" : "Cloop Runner";
|
|
1068
|
+
return {
|
|
1069
|
+
path: join(opts.dir ?? join(opts.home, "AppData", "Local", "Cloop"), `cloop-${name}.cmd`),
|
|
1070
|
+
steps: [
|
|
1071
|
+
{ command: ["schtasks", "/end", "/tn", task], mayFail: true },
|
|
1072
|
+
{ command: ["schtasks", "/delete", "/tn", task, "/f"], mayFail: true }
|
|
1073
|
+
],
|
|
1074
|
+
running: ["schtasks", "/query", "/tn", task]
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1016
1077
|
const unit = `cloop-${name}.service`;
|
|
1017
1078
|
return {
|
|
1018
1079
|
path: join(opts.dir ?? join(opts.home, ".config", "systemd", "user"), unit),
|
|
@@ -1067,6 +1128,65 @@ function unitFor(opts) {
|
|
|
1067
1128
|
tail: ["tail", "-n", "20", log]
|
|
1068
1129
|
};
|
|
1069
1130
|
}
|
|
1131
|
+
if (opts.platform === "win32") {
|
|
1132
|
+
const task = name === "box" ? "Cloop Box" : "Cloop Runner";
|
|
1133
|
+
const dir = opts.dir ?? join(opts.home, "AppData", "Local", "Cloop");
|
|
1134
|
+
const path2 = join(dir, `cloop-${name}.cmd`);
|
|
1135
|
+
const log = join(dir, `cloop-${name}.log`);
|
|
1136
|
+
const psLog = log.replace(/'/g, "''");
|
|
1137
|
+
const contents2 = [
|
|
1138
|
+
"@echo off",
|
|
1139
|
+
...env.map(([key, value]) => `set "${key}=${cmdValue(value)}"`),
|
|
1140
|
+
":run",
|
|
1141
|
+
`call ${opts.program.map(cmdWord).join(" ")} >> ${cmdWord(log)} 2>&1`,
|
|
1142
|
+
"rem timeout needs a console, and a scheduled task has none.",
|
|
1143
|
+
"ping -n 6 127.0.0.1 >nul",
|
|
1144
|
+
"goto run",
|
|
1145
|
+
""
|
|
1146
|
+
].join("\r\n");
|
|
1147
|
+
return {
|
|
1148
|
+
path: path2,
|
|
1149
|
+
contents: contents2,
|
|
1150
|
+
start: [
|
|
1151
|
+
{ command: ["schtasks", "/end", "/tn", task], mayFail: true },
|
|
1152
|
+
{
|
|
1153
|
+
command: [
|
|
1154
|
+
"schtasks",
|
|
1155
|
+
"/create",
|
|
1156
|
+
"/tn",
|
|
1157
|
+
task,
|
|
1158
|
+
"/tr",
|
|
1159
|
+
`"${path2}"`,
|
|
1160
|
+
"/sc",
|
|
1161
|
+
"onlogon",
|
|
1162
|
+
"/rl",
|
|
1163
|
+
"limited",
|
|
1164
|
+
"/f"
|
|
1165
|
+
]
|
|
1166
|
+
},
|
|
1167
|
+
// schtasks /create gives the task a 72 h execution limit, which would stop the runner.
|
|
1168
|
+
{
|
|
1169
|
+
command: [
|
|
1170
|
+
"powershell",
|
|
1171
|
+
"-NoProfile",
|
|
1172
|
+
"-NonInteractive",
|
|
1173
|
+
"-Command",
|
|
1174
|
+
`Set-ScheduledTask -TaskName '${task}' -Settings (New-ScheduledTaskSettingsSet -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable) | Out-Null`
|
|
1175
|
+
]
|
|
1176
|
+
},
|
|
1177
|
+
{ command: ["schtasks", "/run", "/tn", task] }
|
|
1178
|
+
],
|
|
1179
|
+
retire,
|
|
1180
|
+
logs: `Get-Content -Wait '${psLog}'`,
|
|
1181
|
+
tail: [
|
|
1182
|
+
"powershell",
|
|
1183
|
+
"-NoProfile",
|
|
1184
|
+
"-NonInteractive",
|
|
1185
|
+
"-Command",
|
|
1186
|
+
`Get-Content -Tail 20 '${psLog}'`
|
|
1187
|
+
]
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1070
1190
|
const unit = `cloop-${name}.service`;
|
|
1071
1191
|
const units = opts.dir ?? join(opts.home, ".config", "systemd", "user");
|
|
1072
1192
|
const path = join(units, unit);
|
|
@@ -1103,16 +1223,24 @@ function unitFor(opts) {
|
|
|
1103
1223
|
tail: ["journalctl", "--user", "-u", unit, "-n", "20", "--no-pager"]
|
|
1104
1224
|
};
|
|
1105
1225
|
}
|
|
1106
|
-
function resolveRepos(paths, toplevel) {
|
|
1226
|
+
function resolveRepos(paths, toplevel, isFolder = folderAt) {
|
|
1107
1227
|
const repos = [];
|
|
1108
1228
|
for (const p of paths) {
|
|
1109
|
-
const
|
|
1110
|
-
if (!
|
|
1111
|
-
return `${p} is not a
|
|
1229
|
+
const full = resolve2(p);
|
|
1230
|
+
if (!isFolder(full))
|
|
1231
|
+
return `${p} is not a folder. Pass --repo <path> for each folder Cloop may work in.`;
|
|
1232
|
+
const top = toplevel(full) ?? full;
|
|
1112
1233
|
if (!repos.some((r) => r.path === top)) repos.push({ label: basename3(top), path: top });
|
|
1113
1234
|
}
|
|
1114
1235
|
return repos;
|
|
1115
1236
|
}
|
|
1237
|
+
function folderAt(path) {
|
|
1238
|
+
try {
|
|
1239
|
+
return statSync(path).isDirectory();
|
|
1240
|
+
} catch {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1116
1244
|
var CHECKOUT_ROOTS = ["projects", "code", "repos", "src", "Developer", "dev", "work"];
|
|
1117
1245
|
function lastCommitAt(path) {
|
|
1118
1246
|
try {
|
|
@@ -1157,49 +1285,62 @@ function rerunCommand(argv, script = process.argv[1] ?? "") {
|
|
|
1157
1285
|
const staging = process.env.CLOOP_ORIGIN === STAGING_ORIGIN ? ["--staging"] : [];
|
|
1158
1286
|
return [base, "connect", ...staging, ...argv].join(" ");
|
|
1159
1287
|
}
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1288
|
+
function workFolder(home) {
|
|
1289
|
+
return { label: "Cloop", path: join(home, "Cloop") };
|
|
1290
|
+
}
|
|
1291
|
+
function workFolderLine(found, home, argv, terminal) {
|
|
1292
|
+
const rerun = rerunCommand(argv.filter((a) => a !== "--ask"));
|
|
1293
|
+
const here = `Cloop works in ${tilde(workFolder(home).path, home)}.`;
|
|
1294
|
+
if (!found.length) return `${here} To let it work in a checkout, run: ${rerun} --repo <path>`;
|
|
1164
1295
|
const list = found.map((r) => `${r.label} (${tilde(r.path, home)})`).join(", ");
|
|
1165
|
-
|
|
1296
|
+
const pick = terminal ? `, or ${rerun} --ask to pick from the list` : "";
|
|
1297
|
+
return `${here} Recent checkouts: ${list}. To let it work in one, run: ${rerun} --repo ${tilde(found[0]?.path ?? "", home)}${pick}.`;
|
|
1166
1298
|
}
|
|
1167
|
-
async function askRepos(found, home,
|
|
1299
|
+
async function askRepos(found, home, ask, say) {
|
|
1300
|
+
const work = workFolder(home);
|
|
1168
1301
|
say(`${bold("Cloop runner")} This folder is not a git checkout. Recent ones:`);
|
|
1169
1302
|
found.forEach((r, i) => say(` ${i + 1} ${r.label} ${dim(tilde(r.path, home))}`));
|
|
1170
1303
|
for (; ; ) {
|
|
1171
|
-
const answer = (await ask(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
`No folder chosen. Run ${rerun} --repo <path> to name one.`
|
|
1176
|
-
);
|
|
1304
|
+
const answer = (await ask(
|
|
1305
|
+
`Which may Cloop work in? Numbers, comma-separated, or Enter for ${tilde(work.path, home)} only: `
|
|
1306
|
+
)).trim();
|
|
1307
|
+
if (!answer) return [work];
|
|
1177
1308
|
const picks = parsePicks(answer, found.length);
|
|
1178
1309
|
if (picks) return picks.map((n) => found[n - 1]);
|
|
1179
|
-
say(` Type numbers from 1 to ${found.length}, like 1,3.`);
|
|
1310
|
+
say(` Type numbers from 1 to ${found.length}, like 1,3, or press Enter.`);
|
|
1180
1311
|
}
|
|
1181
1312
|
}
|
|
1313
|
+
function asksForFolders(argv, found, terminal) {
|
|
1314
|
+
return found.length > 0 && terminal && argv.includes("--ask");
|
|
1315
|
+
}
|
|
1182
1316
|
async function reposFor(argv) {
|
|
1183
1317
|
const given = flags(argv, "--repo");
|
|
1184
1318
|
if (given.length) {
|
|
1185
|
-
const
|
|
1186
|
-
if (typeof
|
|
1187
|
-
return
|
|
1319
|
+
const repos2 = resolveRepos(given, gitTop);
|
|
1320
|
+
if (typeof repos2 === "string") throw new ConnectFailure("no_repo", repos2);
|
|
1321
|
+
return repos2;
|
|
1188
1322
|
}
|
|
1189
1323
|
const here = gitTop(process.cwd());
|
|
1190
1324
|
if (here) return [{ label: basename3(here), path: here }];
|
|
1191
1325
|
const home = homedir();
|
|
1326
|
+
const work = workFolder(home);
|
|
1192
1327
|
const found = findCheckouts(home);
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1328
|
+
let repos = [work];
|
|
1329
|
+
const terminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
1330
|
+
if (asksForFolders(argv, found, terminal)) {
|
|
1331
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
1332
|
+
const closed = () => new ConnectFailure(
|
|
1333
|
+
"no_repo",
|
|
1334
|
+
`No folder chosen. Run ${rerunCommand(argv)} --repo <path> to name one.`
|
|
1335
|
+
);
|
|
1336
|
+
try {
|
|
1337
|
+
repos = await askRepos(found, home, askOrClosed(prompt, closed), out);
|
|
1338
|
+
} finally {
|
|
1339
|
+
prompt.close();
|
|
1340
|
+
}
|
|
1341
|
+
} else out(`${bold("Cloop runner")} ${workFolderLine(found, home, argv, terminal)}`);
|
|
1342
|
+
if (repos.some((r) => r.path === work.path)) mkdirSync(work.path, { recursive: true });
|
|
1343
|
+
return repos;
|
|
1203
1344
|
}
|
|
1204
1345
|
function askOrClosed(prompt, closed) {
|
|
1205
1346
|
return (question) => new Promise((resolve3, reject) => {
|
|
@@ -1289,13 +1430,7 @@ async function installService(kind, argv, attempt, services = systemServices) {
|
|
|
1289
1430
|
return;
|
|
1290
1431
|
}
|
|
1291
1432
|
attempt.step = "service_write";
|
|
1292
|
-
const
|
|
1293
|
-
const program = programFor(
|
|
1294
|
-
process.argv[1] ?? "cloop",
|
|
1295
|
-
process.execPath,
|
|
1296
|
-
existsSync(npxBeside) ? npxBeside : which("npx"),
|
|
1297
|
-
VERSION
|
|
1298
|
-
);
|
|
1433
|
+
const program = programFor(process.argv[1] ?? "cloop", process.execPath, findNpx(), VERSION);
|
|
1299
1434
|
if (typeof program === "string") throw new ConnectFailure("npx_missing", program);
|
|
1300
1435
|
const unit = unitFor({
|
|
1301
1436
|
platform: services.platform,
|
|
@@ -1419,7 +1554,12 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
1419
1554
|
...chosen ? { chosenDriver: chosen } : {}
|
|
1420
1555
|
})
|
|
1421
1556
|
});
|
|
1422
|
-
await revokeReplaced(
|
|
1557
|
+
await revokeReplaced(
|
|
1558
|
+
previous,
|
|
1559
|
+
"workstation",
|
|
1560
|
+
(t) => revokeOwnDevice(attempt.replacedOrigin ?? getOrigin(), t),
|
|
1561
|
+
out
|
|
1562
|
+
);
|
|
1423
1563
|
out(
|
|
1424
1564
|
`${bold("Cloop runner")} T3 ${cfg.label} paired with scope ${cfg.scope}, until ${cfg.expiresAt.slice(0, 10)}.`
|
|
1425
1565
|
);
|
|
@@ -1446,6 +1586,8 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
|
|
|
1446
1586
|
async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
1447
1587
|
attempt.step = "repos";
|
|
1448
1588
|
const repos = await reposFor(argv);
|
|
1589
|
+
const work = workFolder(homedir()).path;
|
|
1590
|
+
attempt.workFolder = repos.every((r) => r.path === work);
|
|
1449
1591
|
const harness = driver === "claude-code" ? found.claude : found.codex;
|
|
1450
1592
|
const bin = which(driver === "claude-code" ? "claude" : "codex") ?? (driver === "claude-code" ? "claude" : "codex");
|
|
1451
1593
|
const previous = readRunnerConfig();
|
|
@@ -1477,14 +1619,19 @@ async function connectLocal(driver, found, argv, attempt, chosen, services) {
|
|
|
1477
1619
|
...chosen ? { chosenDriver: chosen } : {}
|
|
1478
1620
|
};
|
|
1479
1621
|
writeBoxConfig(cfg);
|
|
1480
|
-
await revokeReplaced(
|
|
1622
|
+
await revokeReplaced(
|
|
1623
|
+
previous,
|
|
1624
|
+
"local",
|
|
1625
|
+
(t) => revokeOwnDevice(attempt.replacedOrigin ?? getOrigin(), t),
|
|
1626
|
+
out
|
|
1627
|
+
);
|
|
1481
1628
|
const others = [found.claude, found.codex].filter(
|
|
1482
1629
|
(h) => Boolean(h) && h !== harness
|
|
1483
1630
|
);
|
|
1484
1631
|
out(
|
|
1485
1632
|
`${bold("Cloop runner")} ${deviceName} is a Local runner: ${[harness, ...others].map(harnessLine).join("; ")}.`
|
|
1486
1633
|
);
|
|
1487
|
-
out(`
|
|
1634
|
+
out(` Folders: ${repos.map((r) => `${r.label} (${r.path})`).join(", ")}`);
|
|
1488
1635
|
out(
|
|
1489
1636
|
` ${driver === "codex" ? "Full access: Codex always runs every Task without permission checks. --ask-everything applies to Claude Code only." : cfg.askEverything ? "Asks before actions except allowlisted reads." : "Full access: every Task runs without permission checks. Add --ask-everything to approve each step."}`
|
|
1490
1637
|
);
|
|
@@ -1532,11 +1679,12 @@ async function connect(argv, attempt, deps = {}) {
|
|
|
1532
1679
|
"--fallback-model takes model names, comma-separated, like opus or opus,sonnet."
|
|
1533
1680
|
);
|
|
1534
1681
|
const t3Url = (flag(argv, "--t3-url") ?? DEFAULT_T3_URL).replace(/\/+$/, "");
|
|
1682
|
+
const harnessBin = (name) => process.platform === "win32" ? which(name) ?? name : name;
|
|
1535
1683
|
const found = await detect(
|
|
1536
1684
|
deps.probes ?? {
|
|
1537
1685
|
t3: () => forced && forced !== "t3" ? Promise.resolve(false) : t3Answers(t3Url),
|
|
1538
|
-
claude: () => probeClaude(),
|
|
1539
|
-
codex: () => probeCodex()
|
|
1686
|
+
claude: () => probeClaude(harnessBin("claude")),
|
|
1687
|
+
codex: () => probeCodex(harnessBin("codex"))
|
|
1540
1688
|
}
|
|
1541
1689
|
);
|
|
1542
1690
|
attempt.harnesses = harnessesFound(found);
|
|
@@ -1623,7 +1771,9 @@ function unitOrigin(contents) {
|
|
|
1623
1771
|
const plist = /<key>CLOOP_ORIGIN<\/key><string>([^<]+)<\/string>/.exec(contents)?.[1];
|
|
1624
1772
|
if (plist) return plist.replace(/&/g, "&");
|
|
1625
1773
|
const unit = /Environment="CLOOP_ORIGIN=([^"]+)"/.exec(contents)?.[1];
|
|
1626
|
-
|
|
1774
|
+
if (unit) return unit.replace(/%%/g, "%");
|
|
1775
|
+
const launcher = /^set "CLOOP_ORIGIN=(.+)"\r?$/m.exec(contents)?.[1];
|
|
1776
|
+
return launcher ? launcher.replace(/%%/g, "%") : null;
|
|
1627
1777
|
}
|
|
1628
1778
|
function disconnectPlan(opts) {
|
|
1629
1779
|
const exists = opts.exists ?? existsSync2;
|
|
@@ -1745,19 +1895,21 @@ async function disconnectCommand(argv) {
|
|
|
1745
1895
|
export {
|
|
1746
1896
|
T3Client,
|
|
1747
1897
|
runBoxTool,
|
|
1748
|
-
DONE_LINE,
|
|
1749
|
-
unitOrigin,
|
|
1750
|
-
disconnectPlan,
|
|
1751
|
-
disconnect,
|
|
1752
|
-
runnerOrigin,
|
|
1753
|
-
disconnectCommand,
|
|
1754
1898
|
probeClaudePermissions,
|
|
1755
1899
|
probeClaude,
|
|
1756
1900
|
DEFAULT_FALLBACK_MODEL,
|
|
1757
1901
|
claudeDialect,
|
|
1758
1902
|
probeCodex,
|
|
1759
1903
|
codexDialect,
|
|
1904
|
+
DONE_LINE,
|
|
1905
|
+
unitOrigin,
|
|
1906
|
+
disconnectPlan,
|
|
1907
|
+
disconnect,
|
|
1908
|
+
runnerOrigin,
|
|
1909
|
+
disconnectCommand,
|
|
1760
1910
|
DEFAULT_T3_URL,
|
|
1911
|
+
which,
|
|
1912
|
+
preferExecutable,
|
|
1761
1913
|
T3PairError,
|
|
1762
1914
|
mintSession,
|
|
1763
1915
|
sessionFromLink,
|
|
@@ -1774,7 +1926,10 @@ export {
|
|
|
1774
1926
|
connectChosen,
|
|
1775
1927
|
systemdAssignment,
|
|
1776
1928
|
systemdWord,
|
|
1929
|
+
cmdValue,
|
|
1930
|
+
cmdWord,
|
|
1777
1931
|
programFor,
|
|
1932
|
+
findNpx,
|
|
1778
1933
|
awaitDaemon,
|
|
1779
1934
|
unitEnv,
|
|
1780
1935
|
installedService,
|
|
@@ -1784,8 +1939,10 @@ export {
|
|
|
1784
1939
|
tilde,
|
|
1785
1940
|
parsePicks,
|
|
1786
1941
|
rerunCommand,
|
|
1787
|
-
|
|
1942
|
+
workFolder,
|
|
1943
|
+
workFolderLine,
|
|
1788
1944
|
askRepos,
|
|
1945
|
+
asksForFolders,
|
|
1789
1946
|
askOrClosed,
|
|
1790
1947
|
runSteps,
|
|
1791
1948
|
systemServices,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-NYGELUTR.js";
|
|
6
6
|
import {
|
|
7
7
|
VERSION
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4MM5O7TV.js";
|
|
9
9
|
import {
|
|
10
10
|
getOrigin,
|
|
11
11
|
readCredentials,
|
|
@@ -36,6 +36,7 @@ function newAttempt(now = Date.now()) {
|
|
|
36
36
|
harnesses: [],
|
|
37
37
|
driver: null,
|
|
38
38
|
fellBack: false,
|
|
39
|
+
workFolder: false,
|
|
39
40
|
deviceToken: null
|
|
40
41
|
};
|
|
41
42
|
}
|
|
@@ -53,6 +54,7 @@ function connectReport(attempt, error, machine, now = Date.now()) {
|
|
|
53
54
|
harnesses: attempt.harnesses,
|
|
54
55
|
driver: attempt.driver,
|
|
55
56
|
fell_back: attempt.fellBack,
|
|
57
|
+
work_folder: attempt.workFolder,
|
|
56
58
|
step: attempt.step,
|
|
57
59
|
outcome: error ? "failed" : "ok",
|
|
58
60
|
error_code: error,
|
|
@@ -6,9 +6,12 @@ import {
|
|
|
6
6
|
askHidden,
|
|
7
7
|
askOrClosed,
|
|
8
8
|
askRepos,
|
|
9
|
+
asksForFolders,
|
|
9
10
|
awaitDaemon,
|
|
10
11
|
chooseDriver,
|
|
11
12
|
claudeAtFloor,
|
|
13
|
+
cmdValue,
|
|
14
|
+
cmdWord,
|
|
12
15
|
connectBox,
|
|
13
16
|
connectChosen,
|
|
14
17
|
connectCommand,
|
|
@@ -17,14 +20,15 @@ import {
|
|
|
17
20
|
fallbackDriver,
|
|
18
21
|
fallbackLine,
|
|
19
22
|
findCheckouts,
|
|
23
|
+
findNpx,
|
|
20
24
|
harnessesFound,
|
|
21
25
|
installedService,
|
|
22
26
|
isWorkstation,
|
|
23
27
|
mintSession,
|
|
24
|
-
notACheckoutLine,
|
|
25
28
|
pairPrompt,
|
|
26
29
|
pairT3,
|
|
27
30
|
parsePicks,
|
|
31
|
+
preferExecutable,
|
|
28
32
|
programFor,
|
|
29
33
|
rememberedDriver,
|
|
30
34
|
rerunCommand,
|
|
@@ -38,18 +42,21 @@ import {
|
|
|
38
42
|
systemdWord,
|
|
39
43
|
tilde,
|
|
40
44
|
unitEnv,
|
|
41
|
-
unitFor
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
unitFor,
|
|
46
|
+
which,
|
|
47
|
+
workFolder,
|
|
48
|
+
workFolderLine
|
|
49
|
+
} from "./chunk-GUPXSBOJ.js";
|
|
50
|
+
import "./chunk-EQTFHMUJ.js";
|
|
51
|
+
import "./chunk-3WD7S6VI.js";
|
|
45
52
|
import "./chunk-UBXT5IDU.js";
|
|
46
53
|
import "./chunk-NUU4GXGV.js";
|
|
47
54
|
import "./chunk-VK6GV757.js";
|
|
48
55
|
import "./chunk-R3CLO2FB.js";
|
|
49
|
-
import "./chunk-
|
|
50
|
-
import "./chunk-
|
|
56
|
+
import "./chunk-OODVBR3F.js";
|
|
57
|
+
import "./chunk-WE4KRF7A.js";
|
|
51
58
|
import "./chunk-NYGELUTR.js";
|
|
52
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-4MM5O7TV.js";
|
|
53
60
|
import "./chunk-IKCGVBHA.js";
|
|
54
61
|
export {
|
|
55
62
|
DEFAULT_T3_URL,
|
|
@@ -58,9 +65,12 @@ export {
|
|
|
58
65
|
askHidden,
|
|
59
66
|
askOrClosed,
|
|
60
67
|
askRepos,
|
|
68
|
+
asksForFolders,
|
|
61
69
|
awaitDaemon,
|
|
62
70
|
chooseDriver,
|
|
63
71
|
claudeAtFloor,
|
|
72
|
+
cmdValue,
|
|
73
|
+
cmdWord,
|
|
64
74
|
connectBox,
|
|
65
75
|
connectChosen,
|
|
66
76
|
connectCommand,
|
|
@@ -69,14 +79,15 @@ export {
|
|
|
69
79
|
fallbackDriver,
|
|
70
80
|
fallbackLine,
|
|
71
81
|
findCheckouts,
|
|
82
|
+
findNpx,
|
|
72
83
|
harnessesFound,
|
|
73
84
|
installedService,
|
|
74
85
|
isWorkstation,
|
|
75
86
|
mintSession,
|
|
76
|
-
notACheckoutLine,
|
|
77
87
|
pairPrompt,
|
|
78
88
|
pairT3,
|
|
79
89
|
parsePicks,
|
|
90
|
+
preferExecutable,
|
|
80
91
|
programFor,
|
|
81
92
|
rememberedDriver,
|
|
82
93
|
rerunCommand,
|
|
@@ -90,5 +101,8 @@ export {
|
|
|
90
101
|
systemdWord,
|
|
91
102
|
tilde,
|
|
92
103
|
unitEnv,
|
|
93
|
-
unitFor
|
|
104
|
+
unitFor,
|
|
105
|
+
which,
|
|
106
|
+
workFolder,
|
|
107
|
+
workFolderLine
|
|
94
108
|
};
|
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
disconnectPlan,
|
|
7
7
|
runnerOrigin,
|
|
8
8
|
unitOrigin
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-GUPXSBOJ.js";
|
|
10
|
+
import "./chunk-EQTFHMUJ.js";
|
|
11
|
+
import "./chunk-3WD7S6VI.js";
|
|
12
12
|
import "./chunk-UBXT5IDU.js";
|
|
13
13
|
import "./chunk-NUU4GXGV.js";
|
|
14
14
|
import "./chunk-VK6GV757.js";
|
|
15
15
|
import "./chunk-R3CLO2FB.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-OODVBR3F.js";
|
|
17
|
+
import "./chunk-WE4KRF7A.js";
|
|
18
18
|
import "./chunk-NYGELUTR.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-4MM5O7TV.js";
|
|
20
20
|
import "./chunk-IKCGVBHA.js";
|
|
21
21
|
export {
|
|
22
22
|
DONE_LINE,
|