@cloop/runner 0.3.17 → 0.3.18

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 CHANGED
@@ -12,6 +12,8 @@ cloop install # register the MCP server with Claude Code / others
12
12
 
13
13
  Credentials live in `~/.cloop/credentials.json`. The API origin comes from `CLOOP_ORIGIN`, the stored value, or the staging default.
14
14
 
15
+ `npx -y @cloop/runner@latest connect` makes this machine a runner. As its last step, it adds the remote Cloop MCP server to each Claude Code and Codex on the machine, and signs it in with OAuth on a terminal. It runs the usual lines: `claude mcp add -s user --transport http cloop https://app.mycloop.com/api/mcp/mcp` and `codex mcp add cloop --url https://app.mycloop.com/api/mcp/mcp`, then `claude mcp login cloop` and `codex mcp login cloop`. Staging uses the name `cloop-staging` and `https://mcp-staging.mycloop.com/mcp`. When an entry under any name already has the URL, `connect` adds nothing. This step never makes `connect` fail. Details: `docs/runbooks/cloop-local.md`, "Connect", step 5.
16
+
15
17
  To disconnect a runner, use Disconnect in its ⋯ menu on the Threads page.
16
18
 
17
19
  ### Windows
@@ -5,8 +5,8 @@ import {
5
5
  } from "./chunk-IJH4O27H.js";
6
6
  import {
7
7
  serveTakeovers
8
- } from "./chunk-H3RGEJME.js";
9
- import "./chunk-2DSMNE24.js";
8
+ } from "./chunk-7OBTF35R.js";
9
+ import "./chunk-NNPOMXCM.js";
10
10
  import {
11
11
  DEFAULT_FALLBACK_MODEL,
12
12
  T3Client,
@@ -34,7 +34,7 @@ import {
34
34
  systemServices,
35
35
  unitFor,
36
36
  which
37
- } from "./chunk-OHVU476O.js";
37
+ } from "./chunk-HVXCQQWG.js";
38
38
  import {
39
39
  BoxWatch,
40
40
  lockThreadsFile,
@@ -42,7 +42,7 @@ import {
42
42
  runnerStatePath,
43
43
  threadsFilePath,
44
44
  writeRunnerState
45
- } from "./chunk-K4TU7DBU.js";
45
+ } from "./chunk-QINWGIXU.js";
46
46
  import {
47
47
  LocalDriver,
48
48
  T3Driver,
@@ -54,7 +54,7 @@ import {
54
54
  showsOtherThreads,
55
55
  windowsPowerShellEnv,
56
56
  writeBoxConfig
57
- } from "./chunk-LXRCJTHL.js";
57
+ } from "./chunk-R22774MI.js";
58
58
  import {
59
59
  getMachine
60
60
  } from "./chunk-NTXQLEMQ.js";
@@ -63,12 +63,12 @@ import {
63
63
  olderThan
64
64
  } from "./chunk-YEO27QQP.js";
65
65
  import "./chunk-R3CLO2FB.js";
66
- import "./chunk-P46CX6Z7.js";
67
- import "./chunk-44BZ2K5L.js";
66
+ import "./chunk-LORK2EOG.js";
67
+ import "./chunk-EIBHDWUG.js";
68
68
  import "./chunk-ES5BRAKJ.js";
69
69
  import {
70
70
  VERSION
71
- } from "./chunk-QG5HVBJY.js";
71
+ } from "./chunk-OBFJRACJ.js";
72
72
  import {
73
73
  getMeshUrl,
74
74
  getToken,
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  findRun,
4
4
  ownHarness
5
- } from "./chunk-2DSMNE24.js";
5
+ } from "./chunk-NNPOMXCM.js";
6
6
  import {
7
7
  lockThreadsFile,
8
8
  threadsFilePath
9
- } from "./chunk-K4TU7DBU.js";
9
+ } from "./chunk-QINWGIXU.js";
10
10
  import {
11
11
  localRunsFilePath,
12
12
  readRunRecords,
13
13
  runHarness,
14
14
  takeoverSummary
15
- } from "./chunk-LXRCJTHL.js";
15
+ } from "./chunk-R22774MI.js";
16
16
  import {
17
17
  shortMachineName
18
18
  } from "./chunk-NTXQLEMQ.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-ES5BRAKJ.js";
6
6
  import {
7
7
  VERSION
8
- } from "./chunk-QG5HVBJY.js";
8
+ } from "./chunk-OBFJRACJ.js";
9
9
  import {
10
10
  getOrigin,
11
11
  readCredentials,
@@ -39,6 +39,8 @@ function newAttempt(now = Date.now()) {
39
39
  workFolder: false,
40
40
  codexInstall: null,
41
41
  claudeInstall: null,
42
+ mcpRegistered: [],
43
+ mcpSignedIn: [],
42
44
  deviceToken: null
43
45
  };
44
46
  }
@@ -59,6 +61,8 @@ function connectReport(attempt, error, machine, now = Date.now()) {
59
61
  work_folder: attempt.workFolder,
60
62
  codex_install: attempt.codexInstall,
61
63
  claude_install: attempt.claudeInstall,
64
+ mcp_registered: attempt.mcpRegistered,
65
+ mcp_signed_in: attempt.mcpSignedIn,
62
66
  step: attempt.step,
63
67
  outcome: error ? "failed" : "ok",
64
68
  error_code: error,
@@ -3,7 +3,7 @@ import {
3
3
  readRunnerState,
4
4
  runnerStatePath,
5
5
  threadsFilePath
6
- } from "./chunk-K4TU7DBU.js";
6
+ } from "./chunk-QINWGIXU.js";
7
7
  import {
8
8
  BoxToolError,
9
9
  CLOOP_THREAD_PREFIX,
@@ -21,6 +21,7 @@ import {
21
21
  otherThreadsChoice,
22
22
  pickT3Bin,
23
23
  questionLine,
24
+ quoteWindowsArg,
24
25
  readRunnerConfig,
25
26
  runT3,
26
27
  runnerDir,
@@ -31,7 +32,7 @@ import {
31
32
  windowsExecutable,
32
33
  windowsPowerShellEnv,
33
34
  writeBoxConfig
34
- } from "./chunk-LXRCJTHL.js";
35
+ } from "./chunk-R22774MI.js";
35
36
  import {
36
37
  getMachine,
37
38
  shortMachineName
@@ -49,17 +50,17 @@ import {
49
50
  } from "./chunk-R3CLO2FB.js";
50
51
  import {
51
52
  connectWebhook
52
- } from "./chunk-P46CX6Z7.js";
53
+ } from "./chunk-LORK2EOG.js";
53
54
  import {
54
55
  ConnectFailure,
55
56
  connectReport,
56
57
  deviceLogin,
57
58
  newAttempt,
58
59
  sendConnectReport
59
- } from "./chunk-44BZ2K5L.js";
60
+ } from "./chunk-EIBHDWUG.js";
60
61
  import {
61
62
  VERSION
62
- } from "./chunk-QG5HVBJY.js";
63
+ } from "./chunk-OBFJRACJ.js";
63
64
  import {
64
65
  STAGING_ORIGIN,
65
66
  getOrigin,
@@ -78,7 +79,7 @@ import {
78
79
  statSync,
79
80
  writeFileSync
80
81
  } from "fs";
81
- import { homedir as homedir3, userInfo } from "os";
82
+ import { homedir as homedir4, userInfo } from "os";
82
83
  import { basename as basename4, dirname, join as join3, resolve as resolve2 } from "path";
83
84
  import { createInterface } from "readline/promises";
84
85
  import { Writable } from "stream";
@@ -1126,6 +1127,219 @@ function movedLine(connecting) {
1126
1127
  return connecting === "staging" ? line2 : `${line2} It is stopped. Start it again with: cloop connect --staging`;
1127
1128
  }
1128
1129
 
1130
+ // src/mcp-registration.ts
1131
+ import { execFile as execFile3, spawn as spawn2 } from "child_process";
1132
+ import { homedir as homedir3 } from "os";
1133
+ var MCP_HARNESS_NAME = {
1134
+ "claude-code": "Claude Code",
1135
+ codex: "Codex"
1136
+ };
1137
+ var LOGIN_MS = 12e4;
1138
+ function mcpServer(env) {
1139
+ return { name: ENVIRONMENTS[env].mcpName, url: ENVIRONMENTS[env].mcpUrl };
1140
+ }
1141
+ var WORDS = {
1142
+ "claude-code": {
1143
+ bin: "claude",
1144
+ add: ({ name, url }) => ["mcp", "add", "-s", "user", "--transport", "http", name, url],
1145
+ remove: (name) => ["mcp", "remove", "-s", "user", name],
1146
+ login: (name) => ["mcp", "login", name]
1147
+ },
1148
+ codex: {
1149
+ bin: "codex",
1150
+ add: ({ name, url }) => ["mcp", "add", name, "--url", url],
1151
+ remove: (name) => ["mcp", "remove", name],
1152
+ login: (name) => ["mcp", "login", name]
1153
+ }
1154
+ };
1155
+ var OFFLINE = {
1156
+ HTTPS_PROXY: "http://127.0.0.1:9",
1157
+ HTTP_PROXY: "http://127.0.0.1:9",
1158
+ ALL_PROXY: "http://127.0.0.1:9",
1159
+ NO_PROXY: "",
1160
+ no_proxy: ""
1161
+ };
1162
+ function loginArgs(platform, env) {
1163
+ return platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY ? ["--no-browser"] : [];
1164
+ }
1165
+ function complaint(stderr, stdout, fallback) {
1166
+ const lines = `${stderr}
1167
+ ${stdout}`.split("\n").map((line2) => line2.trim()).filter((line2) => line2 && !line2.startsWith("WARNING:"));
1168
+ return lines[0] ?? fallback;
1169
+ }
1170
+ var systemMcpCli = {
1171
+ run: ([bin = "", ...args], env) => {
1172
+ const command = commandFor(bin, args);
1173
+ return new Promise(
1174
+ (resolve3, reject) => execFile3(
1175
+ command.file,
1176
+ command.args,
1177
+ {
1178
+ // A project's own MCP config under the folder connect ran in must not stand in for the user's.
1179
+ cwd: homedir3(),
1180
+ timeout: 45e3,
1181
+ encoding: "utf-8",
1182
+ env: { ...process.env, ...env },
1183
+ ...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
1184
+ },
1185
+ (err, stdout, stderr) => err ? reject(new Error(complaint(stderr, stdout, err.message))) : resolve3(stdout)
1186
+ )
1187
+ );
1188
+ },
1189
+ interactive: ([bin = "", ...args], ms) => {
1190
+ const command = commandFor(bin, args);
1191
+ return new Promise((resolve3) => {
1192
+ const ignore = () => {
1193
+ };
1194
+ process.on("SIGINT", ignore);
1195
+ const child = spawn2(command.file, command.args, {
1196
+ cwd: homedir3(),
1197
+ stdio: "inherit",
1198
+ ...command.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
1199
+ });
1200
+ const timer = setTimeout(() => {
1201
+ child.kill();
1202
+ done(false);
1203
+ }, ms);
1204
+ let settled = false;
1205
+ function done(ok) {
1206
+ if (settled) return;
1207
+ settled = true;
1208
+ clearTimeout(timer);
1209
+ process.off("SIGINT", ignore);
1210
+ resolve3(ok);
1211
+ }
1212
+ child.on("error", () => done(false));
1213
+ child.on("exit", (code) => done(code === 0));
1214
+ });
1215
+ }
1216
+ };
1217
+ function sameServer(a, b) {
1218
+ const key = (url) => {
1219
+ try {
1220
+ const { protocol, host, pathname } = new URL(url);
1221
+ return `${protocol}//${host}${pathname.replace(/\/+$/, "")}`;
1222
+ } catch {
1223
+ return null;
1224
+ }
1225
+ };
1226
+ const left = key(a);
1227
+ return left !== null && left === key(b);
1228
+ }
1229
+ function parseClaudeList(text) {
1230
+ const listed = [];
1231
+ for (const line2 of text.split("\n")) {
1232
+ const at = line2.indexOf(": ");
1233
+ if (at <= 0) continue;
1234
+ const rest = line2.slice(at + 2);
1235
+ if (!rest.includes(" - ")) continue;
1236
+ const url = /^(https?:\/\/\S+)/.exec(rest)?.[1] ?? null;
1237
+ listed.push({ name: line2.slice(0, at), url, signedIn: /\bConnected\s*$/.test(rest) });
1238
+ }
1239
+ return listed;
1240
+ }
1241
+ function parseCodexList(json) {
1242
+ const servers = JSON.parse(json);
1243
+ return servers.flatMap(
1244
+ ({ name, transport, auth_status }) => name ? [
1245
+ {
1246
+ name,
1247
+ url: transport?.type === "streamable_http" && transport.url ? transport.url : null,
1248
+ signedIn: auth_status === "o_auth" || auth_status === "bearer_token"
1249
+ }
1250
+ ] : []
1251
+ );
1252
+ }
1253
+ async function listEntries(harness, bin, cli) {
1254
+ return harness === "codex" ? parseCodexList(await cli.run([bin, "mcp", "list", "--json"])) : parseClaudeList(await cli.run([bin, "mcp", "list"]));
1255
+ }
1256
+ async function signedInNow(harness, bin, name, cli) {
1257
+ try {
1258
+ if (harness === "claude-code")
1259
+ return /^\s*Status: .*\bConnected\b/m.test(await cli.run([bin, "mcp", "get", name]));
1260
+ return (await listEntries(harness, bin, cli)).some((e) => e.name === name && e.signedIn);
1261
+ } catch {
1262
+ return false;
1263
+ }
1264
+ }
1265
+ function shellLine(words, platform) {
1266
+ return words.map(
1267
+ (word) => platform === "win32" ? quoteWindowsArg(word) : /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, "'\\''")}'`
1268
+ ).join(" ");
1269
+ }
1270
+ async function addCloopMcp(harness, bin, server, deps) {
1271
+ const platform = deps.platform ?? process.platform;
1272
+ const words = WORDS[harness];
1273
+ const login = (name) => [
1274
+ ...words.login(name),
1275
+ ...loginArgs(platform, deps.env ?? process.env)
1276
+ ];
1277
+ const shown = (args) => shellLine([words.bin, ...args], platform);
1278
+ const result = (registered, signedIn2, reason, byHand, as = server.name) => ({
1279
+ harness,
1280
+ url: server.url,
1281
+ as,
1282
+ found: as !== server.name,
1283
+ registered,
1284
+ signedIn: signedIn2,
1285
+ reason,
1286
+ byHand
1287
+ });
1288
+ const why = (err) => err instanceof Error ? err.message : String(err);
1289
+ let entries;
1290
+ try {
1291
+ entries = await listEntries(harness, bin, deps.cli);
1292
+ } catch (err) {
1293
+ return result(false, false, why(err), [shown(words.add(server)), shown(login(server.name))]);
1294
+ }
1295
+ const own = entries.find((entry) => entry.name === server.name);
1296
+ const ours = (entry) => Boolean(entry?.url && sameServer(entry.url, server.url));
1297
+ let signedIn = ours(own) && Boolean(own?.signedIn);
1298
+ if (!ours(own)) {
1299
+ const other = entries.find((entry) => entry.name !== server.name && ours(entry));
1300
+ if (other)
1301
+ return other.signedIn ? result(true, true, null, [], other.name) : result(true, false, "not signed in", [shown(login(other.name))], other.name);
1302
+ if (own) await deps.cli.run([bin, ...words.remove(server.name)]).catch(() => {
1303
+ });
1304
+ try {
1305
+ await deps.cli.run([bin, ...words.add(server)], harness === "codex" ? OFFLINE : void 0);
1306
+ } catch (err) {
1307
+ return result(false, false, why(err), [
1308
+ ...own ? [shown(words.remove(server.name))] : [],
1309
+ shown(words.add(server)),
1310
+ shown(login(server.name))
1311
+ ]);
1312
+ }
1313
+ signedIn = await signedInNow(harness, bin, server.name, deps.cli);
1314
+ }
1315
+ if (signedIn) return result(true, true, null, []);
1316
+ if (!deps.terminal) return result(true, false, "no terminal here", [shown(login(server.name))]);
1317
+ deps.say(
1318
+ `Sign in to Cloop for ${MCP_HARNESS_NAME[harness]}. Approve the sign-in in your browser within ${LOGIN_MS / 6e4} minutes.`
1319
+ );
1320
+ if (await deps.cli.interactive([bin, ...login(server.name)], LOGIN_MS) && await signedInNow(harness, bin, server.name, deps.cli))
1321
+ return result(true, true, null, []);
1322
+ return result(true, false, "the sign-in did not finish", [shown(login(server.name))]);
1323
+ }
1324
+ function mcpByHand(harness, server, platform = process.platform, env = process.env) {
1325
+ const words = WORDS[harness];
1326
+ return [words.add(server), [...words.login(server.name), ...loginArgs(platform, env)]].map(
1327
+ (args) => shellLine([words.bin, ...args], platform)
1328
+ );
1329
+ }
1330
+ function mcpLine(result) {
1331
+ const name = MCP_HARNESS_NAME[result.harness];
1332
+ const run = result.byHand.length ? ` Run: ${result.byHand.join(", then: ")}` : "";
1333
+ if (!result.registered)
1334
+ return `Could not add the Cloop MCP server to ${name} (${result.reason}).${run}`;
1335
+ if (result.found) {
1336
+ const head = `${name} already has the Cloop MCP server as ${result.as}`;
1337
+ return result.signedIn ? `${head}, signed in.` : `${head}. It is not signed in.${run}`;
1338
+ }
1339
+ if (result.signedIn) return `${name} has the Cloop MCP server at ${result.url}, signed in.`;
1340
+ return `${name} has the Cloop MCP server at ${result.url}. It is not signed in (${result.reason}).${run}`;
1341
+ }
1342
+
1129
1343
  // src/t3-pair-link.ts
1130
1344
  var CODE = /^[A-Za-z0-9_-]{8,256}$/;
1131
1345
  function tokenOf(url) {
@@ -1200,7 +1414,7 @@ function boxSession(t3Url, t3Bin, env, token) {
1200
1414
  }
1201
1415
  async function mintSession(t3Url, opts = {}) {
1202
1416
  const env = await workstationEnvironment(t3Url, opts.fetchFn);
1203
- const sources = opts.sources ?? defaultT3BinSources(homedir3(), opts.stored);
1417
+ const sources = opts.sources ?? defaultT3BinSources(homedir4(), opts.stored);
1204
1418
  try {
1205
1419
  const t3Bin = opts.bin ?? pickT3Bin(t3Candidates(env.serverVersion, sources), env.serverVersion);
1206
1420
  if (!t3Bin) throw new Error("no t3 binary found; pass --t3-bin or set T3_BIN");
@@ -1322,7 +1536,7 @@ function boxServiceInstalled() {
1322
1536
  platform: process.platform,
1323
1537
  kind: "workstation",
1324
1538
  environment: runnerEnvironment(),
1325
- home: homedir3(),
1539
+ home: homedir4(),
1326
1540
  uid: process.getuid?.() ?? 0,
1327
1541
  ...process.env.CLOOP_UNIT_DIR ? { dir: process.env.CLOOP_UNIT_DIR } : {}
1328
1542
  }).path
@@ -1704,7 +1918,7 @@ async function reposFor(argv) {
1704
1918
  }
1705
1919
  const here = gitTop(process.cwd());
1706
1920
  if (here) return [{ label: basename4(here), path: here }];
1707
- const home = homedir3();
1921
+ const home = homedir4();
1708
1922
  const work = workFolder(home);
1709
1923
  const found = findCheckouts(home);
1710
1924
  let repos = [work];
@@ -1820,7 +2034,7 @@ async function installService(kind, argv, attempt, services = systemServices) {
1820
2034
  platform: services.platform,
1821
2035
  kind,
1822
2036
  environment,
1823
- home: homedir3(),
2037
+ home: homedir4(),
1824
2038
  program,
1825
2039
  env: serviceEnv(),
1826
2040
  uid: process.getuid?.() ?? 0,
@@ -1974,7 +2188,7 @@ async function connectT3(argv, attempt, fallback, chosen, services) {
1974
2188
  async function connectLocal(driver, found, argv, attempt, chosen, services) {
1975
2189
  attempt.step = "repos";
1976
2190
  const repos = await reposFor(argv);
1977
- const work = workFolder(homedir3()).path;
2191
+ const work = workFolder(homedir4()).path;
1978
2192
  attempt.workFolder = repos.every((r) => r.path === work);
1979
2193
  const harness = driver === "claude-code" ? found.claude : found.codex;
1980
2194
  const bin = which(driver === "claude-code" ? "claude" : "codex") ?? (driver === "claude-code" ? "claude" : "codex");
@@ -2068,8 +2282,8 @@ async function connect(argv, attempt, deps = {}) {
2068
2282
  );
2069
2283
  const t3Url = (flag(argv, "--t3-url") ?? DEFAULT_T3_URL).replace(/\/+$/, "");
2070
2284
  const harnessBin = (name) => process.platform === "win32" ? which(name) ?? name : name;
2071
- findLocalCodex(homedir3());
2072
- findLocalClaude(homedir3());
2285
+ findLocalCodex(homedir4());
2286
+ findLocalClaude(homedir4());
2073
2287
  const readCodex = deps.probes?.codex ?? (() => probeCodex(harnessBin("codex")));
2074
2288
  const readClaude = deps.probes?.claude ?? (() => probeClaude(harnessBin("claude")));
2075
2289
  const found = await detect(
@@ -2082,16 +2296,17 @@ async function connect(argv, attempt, deps = {}) {
2082
2296
  attempt.harnesses = harnessesFound(found);
2083
2297
  const workstation = isWorkstation(previous, boxServiceInstalled());
2084
2298
  const machine = !deps.probes;
2299
+ const terminal = deps.terminal ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
2085
2300
  const current = await prepareAgents(found, forced, workstation, {
2086
- chatGptApp: deps.chatGptApp ?? (() => machine && hasChatGptApp(homedir3())),
2087
- installCodex: deps.installCodex ?? (async () => machine && installCodex(homedir3())),
2088
- installClaude: deps.installClaude ?? (async () => machine && installClaude(homedir3())),
2301
+ chatGptApp: deps.chatGptApp ?? (() => machine && hasChatGptApp(homedir4())),
2302
+ installCodex: deps.installCodex ?? (async () => machine && installCodex(homedir4())),
2303
+ installClaude: deps.installClaude ?? (async () => machine && installClaude(homedir4())),
2089
2304
  readCodex,
2090
2305
  readClaude,
2091
2306
  updateClaude: deps.updateClaude ?? updateClaude,
2092
2307
  signInCodex: deps.signInCodex ?? (() => signInCodex(harnessBin("codex"))),
2093
2308
  signInClaude: deps.signInClaude ?? (() => signInClaude(harnessBin("claude"))),
2094
- terminal: deps.terminal ?? Boolean(process.stdin.isTTY && process.stdout.isTTY),
2309
+ terminal,
2095
2310
  installed: (agent, ok) => {
2096
2311
  attempt[agent === "codex" ? "codexInstall" : "claudeInstall"] = ok ? "ok" : "failed";
2097
2312
  }
@@ -2106,6 +2321,54 @@ async function connect(argv, attempt, deps = {}) {
2106
2321
  fallback: () => fallbackDriver(current, forced, workstation),
2107
2322
  say: (line2) => out(`${bold("Cloop runner")} ${line2}`)
2108
2323
  });
2324
+ const harnesses = [];
2325
+ if (current.claude) harnesses.push({ harness: "claude-code", bin: harnessBin("claude") });
2326
+ if (current.codex) harnesses.push({ harness: "codex", bin: harnessBin("codex") });
2327
+ const mcp = deps.mcp ?? (machine ? { cli: systemMcpCli } : null);
2328
+ if (mcp) await addCloopMcpLast(harnesses, attempt, mcp, terminal);
2329
+ }
2330
+ var MCP_STEP_MS = 6 * 6e4;
2331
+ async function addCloopMcpLast(found, attempt, mcp, terminal) {
2332
+ if (!found.length) return;
2333
+ const server = mcpServer(runnerEnvironment());
2334
+ const say = (line2) => out(`${bold("Cloop runner")} ${line2}`);
2335
+ const left = new Set(found.map(({ harness }) => harness));
2336
+ const byHand = () => [...left].flatMap((harness) => mcpByHand(harness, server)).join(", then: ");
2337
+ let late = false;
2338
+ const step = (async () => {
2339
+ for (const { harness, bin } of found) {
2340
+ const result = await addCloopMcp(harness, bin, server, { cli: mcp.cli, terminal, say });
2341
+ if (late) return;
2342
+ left.delete(harness);
2343
+ if (result.registered) attempt.mcpRegistered.push(harness);
2344
+ if (result.signedIn) attempt.mcpSignedIn.push(harness);
2345
+ console.error(
2346
+ `[runner:mcp] harness=${harness} registered=${result.registered} signed_in=${result.signedIn} reason=${result.reason ?? "none"}`
2347
+ );
2348
+ out(
2349
+ result.registered ? `${bold("Cloop runner")} ${mcpLine(result)}` : `${red("\u2717")} ${mcpLine(result)}`
2350
+ );
2351
+ }
2352
+ })();
2353
+ let timer;
2354
+ const deadline = new Promise((resolve3) => {
2355
+ timer = setTimeout(() => resolve3("late"), mcp.deadlineMs ?? MCP_STEP_MS);
2356
+ });
2357
+ try {
2358
+ if (await Promise.race([step.then(() => "done"), deadline]) === "late") {
2359
+ late = true;
2360
+ console.error("[runner:mcp] outcome=timeout");
2361
+ out(`${red("\u2717")} Adding the Cloop MCP server took too long. Run: ${byHand()}`);
2362
+ }
2363
+ } catch (err) {
2364
+ late = true;
2365
+ console.error("[runner:mcp] outcome=unexpected");
2366
+ out(
2367
+ `${red("\u2717")} Could not add the Cloop MCP server (${err instanceof Error ? err.message : String(err)}). Run: ${byHand()}`
2368
+ );
2369
+ } finally {
2370
+ clearTimeout(timer);
2371
+ }
2109
2372
  }
2110
2373
  async function prepareAgents(found, forced, workstation, deps) {
2111
2374
  if (workstation || forced === "t3") return found;
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-44BZ2K5L.js";
5
+ } from "./chunk-EIBHDWUG.js";
6
6
  import {
7
7
  ApiError,
8
8
  ReauthError,
@@ -9,7 +9,7 @@ import {
9
9
  runHarness,
10
10
  runLogDir,
11
11
  runLogPath
12
- } from "./chunk-LXRCJTHL.js";
12
+ } from "./chunk-R22774MI.js";
13
13
  import {
14
14
  sanitizeLabel,
15
15
  stripControl
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.3.17" : "0.0.0-dev";
4
+ var VERSION = true ? "0.3.18" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  RUN_TEXT_MAX,
4
4
  runnerPath
5
- } from "./chunk-LXRCJTHL.js";
5
+ } from "./chunk-R22774MI.js";
6
6
 
7
7
  // src/box-watch.ts
8
8
  import { randomUUID } from "crypto";
@@ -17,13 +17,17 @@ var ENVIRONMENTS = {
17
17
  origin: PRODUCTION_ORIGIN,
18
18
  dir: (home) => join(home, CONFIG_DIR),
19
19
  suffix: "",
20
- flag: ""
20
+ flag: "",
21
+ mcpUrl: "https://app.mycloop.com/api/mcp/mcp",
22
+ mcpName: "cloop"
21
23
  },
22
24
  staging: {
23
25
  origin: STAGING_ORIGIN,
24
26
  dir: (home) => join(home, CONFIG_DIR, "staging"),
25
27
  suffix: "staging",
26
- flag: "--staging"
28
+ flag: "--staging",
29
+ mcpUrl: "https://mcp-staging.mycloop.com/mcp",
30
+ mcpName: "cloop-staging"
27
31
  }
28
32
  };
29
33
  function environmentOf(origin) {
@@ -2244,6 +2248,7 @@ export {
2244
2248
  STOPPED_SUMMARY,
2245
2249
  isEndLogLine,
2246
2250
  commandFor,
2251
+ quoteWindowsArg,
2247
2252
  windowsExecutable,
2248
2253
  windowsPowerShellEnv,
2249
2254
  defaultT3BinSources,
@@ -52,17 +52,17 @@ import {
52
52
  which,
53
53
  workFolder,
54
54
  workFolderLine
55
- } from "./chunk-OHVU476O.js";
56
- import "./chunk-K4TU7DBU.js";
57
- import "./chunk-LXRCJTHL.js";
55
+ } from "./chunk-HVXCQQWG.js";
56
+ import "./chunk-QINWGIXU.js";
57
+ import "./chunk-R22774MI.js";
58
58
  import "./chunk-NTXQLEMQ.js";
59
59
  import "./chunk-VK6GV757.js";
60
60
  import "./chunk-YEO27QQP.js";
61
61
  import "./chunk-R3CLO2FB.js";
62
- import "./chunk-P46CX6Z7.js";
63
- import "./chunk-44BZ2K5L.js";
62
+ import "./chunk-LORK2EOG.js";
63
+ import "./chunk-EIBHDWUG.js";
64
64
  import "./chunk-ES5BRAKJ.js";
65
- import "./chunk-QG5HVBJY.js";
65
+ import "./chunk-OBFJRACJ.js";
66
66
  import "./chunk-D5UZW42X.js";
67
67
  export {
68
68
  DEFAULT_T3_URL,
@@ -7,17 +7,17 @@ import {
7
7
  runnerOrigin,
8
8
  stopService,
9
9
  unitOrigin
10
- } from "./chunk-OHVU476O.js";
11
- import "./chunk-K4TU7DBU.js";
12
- import "./chunk-LXRCJTHL.js";
10
+ } from "./chunk-HVXCQQWG.js";
11
+ import "./chunk-QINWGIXU.js";
12
+ import "./chunk-R22774MI.js";
13
13
  import "./chunk-NTXQLEMQ.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-YEO27QQP.js";
16
16
  import "./chunk-R3CLO2FB.js";
17
- import "./chunk-P46CX6Z7.js";
18
- import "./chunk-44BZ2K5L.js";
17
+ import "./chunk-LORK2EOG.js";
18
+ import "./chunk-EIBHDWUG.js";
19
19
  import "./chunk-ES5BRAKJ.js";
20
- import "./chunk-QG5HVBJY.js";
20
+ import "./chunk-OBFJRACJ.js";
21
21
  import "./chunk-D5UZW42X.js";
22
22
  export {
23
23
  disconnect,
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  existingRunnerEnvironment,
4
4
  pinExistingRunner
5
- } from "./chunk-OHVU476O.js";
6
- import "./chunk-K4TU7DBU.js";
7
- import "./chunk-LXRCJTHL.js";
5
+ } from "./chunk-HVXCQQWG.js";
6
+ import "./chunk-QINWGIXU.js";
7
+ import "./chunk-R22774MI.js";
8
8
  import "./chunk-NTXQLEMQ.js";
9
9
  import "./chunk-VK6GV757.js";
10
10
  import "./chunk-YEO27QQP.js";
11
11
  import "./chunk-R3CLO2FB.js";
12
- import "./chunk-P46CX6Z7.js";
13
- import "./chunk-44BZ2K5L.js";
12
+ import "./chunk-LORK2EOG.js";
13
+ import "./chunk-EIBHDWUG.js";
14
14
  import "./chunk-ES5BRAKJ.js";
15
- import "./chunk-QG5HVBJY.js";
15
+ import "./chunk-OBFJRACJ.js";
16
16
  import "./chunk-D5UZW42X.js";
17
17
  export {
18
18
  existingRunnerEnvironment,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-YEO27QQP.js";
5
5
  import {
6
6
  VERSION
7
- } from "./chunk-QG5HVBJY.js";
7
+ } from "./chunk-OBFJRACJ.js";
8
8
  import {
9
9
  applyEnvironmentFlag
10
10
  } from "./chunk-D5UZW42X.js";
@@ -65,7 +65,7 @@ Add --staging to any command to use Cloop staging instead of production.
65
65
  A production runner and a staging runner can run side by side on one machine.
66
66
  `;
67
67
  async function pinExistingRunner() {
68
- const { pinExistingRunner: pin } = await import("./existing-runner-WR6A3P3I.js");
68
+ const { pinExistingRunner: pin } = await import("./existing-runner-YSP7FXZR.js");
69
69
  const { note } = pin();
70
70
  if (note) console.error(note);
71
71
  }
@@ -73,7 +73,7 @@ async function main() {
73
73
  switch (command) {
74
74
  case "login":
75
75
  case "auth": {
76
- const { loginCommand } = await import("./login-OAYCNQ2O.js");
76
+ const { loginCommand } = await import("./login-V75JRH67.js");
77
77
  await loginCommand(argv);
78
78
  break;
79
79
  }
@@ -83,61 +83,61 @@ async function main() {
83
83
  break;
84
84
  }
85
85
  case "serve": {
86
- const { startMcpServer } = await import("./mcp-server-XIJGOXBH.js");
86
+ const { startMcpServer } = await import("./mcp-server-DZDP77CZ.js");
87
87
  await startMcpServer();
88
88
  break;
89
89
  }
90
90
  case "statusline": {
91
- const { statuslineCommand } = await import("./statusline-O7C5PR36.js");
91
+ const { statuslineCommand } = await import("./statusline-N2KTSLFM.js");
92
92
  statuslineCommand();
93
93
  break;
94
94
  }
95
95
  case "connect": {
96
- const { connectCommand } = await import("./connect-SO3X4ANL.js");
96
+ const { connectCommand } = await import("./connect-34PDKC55.js");
97
97
  await connectCommand(argv.slice(1));
98
98
  break;
99
99
  }
100
100
  case "use": {
101
- const { useCommand } = await import("./use-765ZZES6.js");
101
+ const { useCommand } = await import("./use-MBFWAKLJ.js");
102
102
  process.exitCode = await useCommand(argv.slice(1));
103
103
  break;
104
104
  }
105
105
  case "disconnect": {
106
- const { disconnectCommand } = await import("./disconnect-QGO6KQTH.js");
106
+ const { disconnectCommand } = await import("./disconnect-DCMZAIB6.js");
107
107
  await disconnectCommand(argv.slice(1));
108
108
  break;
109
109
  }
110
110
  case "box": {
111
- const { boxCommand } = await import("./box-MCJBDKDN.js");
111
+ const { boxCommand } = await import("./box-AF56GPSV.js");
112
112
  await boxCommand(argv.slice(1));
113
113
  break;
114
114
  }
115
115
  case "runs": {
116
116
  await pinExistingRunner();
117
- const { runsCommand } = await import("./runs-VGVVNO4S.js");
117
+ const { runsCommand } = await import("./runs-IZ3AMCHT.js");
118
118
  process.exitCode = runsCommand();
119
119
  break;
120
120
  }
121
121
  case "watch": {
122
122
  await pinExistingRunner();
123
- const { watchCommand } = await import("./runs-VGVVNO4S.js");
123
+ const { watchCommand } = await import("./runs-IZ3AMCHT.js");
124
124
  process.exitCode = await watchCommand(argv.slice(1));
125
125
  break;
126
126
  }
127
127
  case "takeover": {
128
128
  await pinExistingRunner();
129
- const { takeoverCommand } = await import("./takeover-E6FYRR4M.js");
129
+ const { takeoverCommand } = await import("./takeover-3XAMWQPK.js");
130
130
  process.exitCode = await takeoverCommand(argv.slice(1));
131
131
  break;
132
132
  }
133
133
  case "resume": {
134
134
  await pinExistingRunner();
135
- const { resumeCommand } = await import("./runs-VGVVNO4S.js");
135
+ const { resumeCommand } = await import("./runs-IZ3AMCHT.js");
136
136
  process.exitCode = await resumeCommand(argv.slice(1));
137
137
  break;
138
138
  }
139
139
  case "runner": {
140
- const { runnerCommand } = await import("./runner-GDMWLS5G.js");
140
+ const { runnerCommand } = await import("./runner-TFJMSK5R.js");
141
141
  await runnerCommand(argv.slice(1));
142
142
  break;
143
143
  }
@@ -3,9 +3,9 @@ import {
3
3
  deviceLogin,
4
4
  loginCommand,
5
5
  refusalSentence
6
- } from "./chunk-44BZ2K5L.js";
6
+ } from "./chunk-EIBHDWUG.js";
7
7
  import "./chunk-ES5BRAKJ.js";
8
- import "./chunk-QG5HVBJY.js";
8
+ import "./chunk-OBFJRACJ.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  deviceLogin,
@@ -33,7 +33,7 @@ import {
33
33
  } from "./chunk-ES5BRAKJ.js";
34
34
  import {
35
35
  VERSION
36
- } from "./chunk-QG5HVBJY.js";
36
+ } from "./chunk-OBFJRACJ.js";
37
37
  import {
38
38
  getMeshUrl,
39
39
  getToken
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  connectWebhook,
4
4
  runnerCommand
5
- } from "./chunk-P46CX6Z7.js";
6
- import "./chunk-44BZ2K5L.js";
5
+ } from "./chunk-LORK2EOG.js";
6
+ import "./chunk-EIBHDWUG.js";
7
7
  import "./chunk-ES5BRAKJ.js";
8
- import "./chunk-QG5HVBJY.js";
8
+ import "./chunk-OBFJRACJ.js";
9
9
  import "./chunk-D5UZW42X.js";
10
10
  export {
11
11
  connectWebhook,
@@ -9,8 +9,8 @@ import {
9
9
  runsCommand,
10
10
  sessionFolder,
11
11
  watchCommand
12
- } from "./chunk-2DSMNE24.js";
13
- import "./chunk-LXRCJTHL.js";
12
+ } from "./chunk-NNPOMXCM.js";
13
+ import "./chunk-R22774MI.js";
14
14
  import "./chunk-VK6GV757.js";
15
15
  import "./chunk-D5UZW42X.js";
16
16
  export {
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-VK6GV757.js";
8
8
  import {
9
9
  VERSION
10
- } from "./chunk-QG5HVBJY.js";
10
+ } from "./chunk-OBFJRACJ.js";
11
11
  import {
12
12
  getToken
13
13
  } from "./chunk-D5UZW42X.js";
@@ -9,10 +9,10 @@ import {
9
9
  takeoverDir,
10
10
  writeTakeoverReply,
11
11
  writeTakeoverRequest
12
- } from "./chunk-H3RGEJME.js";
13
- import "./chunk-2DSMNE24.js";
14
- import "./chunk-K4TU7DBU.js";
15
- import "./chunk-LXRCJTHL.js";
12
+ } from "./chunk-7OBTF35R.js";
13
+ import "./chunk-NNPOMXCM.js";
14
+ import "./chunk-QINWGIXU.js";
15
+ import "./chunk-R22774MI.js";
16
16
  import "./chunk-NTXQLEMQ.js";
17
17
  import "./chunk-VK6GV757.js";
18
18
  import "./chunk-ES5BRAKJ.js";
@@ -3,20 +3,20 @@ import {
3
3
  DRIVER_NAME,
4
4
  pinExistingRunner,
5
5
  runConnect
6
- } from "./chunk-OHVU476O.js";
7
- import "./chunk-K4TU7DBU.js";
6
+ } from "./chunk-HVXCQQWG.js";
7
+ import "./chunk-QINWGIXU.js";
8
8
  import {
9
9
  isLocal,
10
10
  readRunnerConfig
11
- } from "./chunk-LXRCJTHL.js";
11
+ } from "./chunk-R22774MI.js";
12
12
  import "./chunk-NTXQLEMQ.js";
13
13
  import "./chunk-VK6GV757.js";
14
14
  import "./chunk-YEO27QQP.js";
15
15
  import "./chunk-R3CLO2FB.js";
16
- import "./chunk-P46CX6Z7.js";
17
- import "./chunk-44BZ2K5L.js";
16
+ import "./chunk-LORK2EOG.js";
17
+ import "./chunk-EIBHDWUG.js";
18
18
  import "./chunk-ES5BRAKJ.js";
19
- import "./chunk-QG5HVBJY.js";
19
+ import "./chunk-OBFJRACJ.js";
20
20
  import "./chunk-D5UZW42X.js";
21
21
 
22
22
  // src/commands/use.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloop/runner",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Make your machine and your agents Cloop runners: device login, the runner daemon, the Cloop MCP server, and Claude Code hooks.",