@cloop/runner 0.3.18 → 0.3.21

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.
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConnectFailure,
4
4
  deviceLogin
5
- } from "./chunk-EIBHDWUG.js";
5
+ } from "./chunk-TZ3I2IWD.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-R22774MI.js";
12
+ } from "./chunk-JM5NKNHE.js";
13
13
  import {
14
14
  sanitizeLabel,
15
15
  stripControl
@@ -2,17 +2,17 @@
2
2
  import {
3
3
  findRun,
4
4
  ownHarness
5
- } from "./chunk-NNPOMXCM.js";
5
+ } from "./chunk-NR3O6EC3.js";
6
6
  import {
7
7
  lockThreadsFile,
8
8
  threadsFilePath
9
- } from "./chunk-QINWGIXU.js";
9
+ } from "./chunk-S4IN6AX2.js";
10
10
  import {
11
11
  localRunsFilePath,
12
12
  readRunRecords,
13
13
  runHarness,
14
14
  takeoverSummary
15
- } from "./chunk-R22774MI.js";
15
+ } from "./chunk-JM5NKNHE.js";
16
16
  import {
17
17
  shortMachineName
18
18
  } from "./chunk-NTXQLEMQ.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  RUN_TEXT_MAX,
4
4
  runnerPath
5
- } from "./chunk-R22774MI.js";
5
+ } from "./chunk-JM5NKNHE.js";
6
6
 
7
7
  // src/box-watch.ts
8
8
  import { randomUUID } from "crypto";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-ES5BRAKJ.js";
6
6
  import {
7
7
  VERSION
8
- } from "./chunk-OBFJRACJ.js";
8
+ } from "./chunk-3NIDXMUM.js";
9
9
  import {
10
10
  getOrigin,
11
11
  readCredentials,
@@ -38,6 +38,7 @@ function newAttempt(now = Date.now()) {
38
38
  fellBack: false,
39
39
  workFolder: false,
40
40
  codexInstall: null,
41
+ codexInstallReason: null,
41
42
  claudeInstall: null,
42
43
  mcpRegistered: [],
43
44
  mcpSignedIn: [],
@@ -60,6 +61,7 @@ function connectReport(attempt, error, machine, now = Date.now()) {
60
61
  fell_back: attempt.fellBack,
61
62
  work_folder: attempt.workFolder,
62
63
  codex_install: attempt.codexInstall,
64
+ codex_install_reason: attempt.codexInstallReason,
63
65
  claude_install: attempt.claudeInstall,
64
66
  mcp_registered: attempt.mcpRegistered,
65
67
  mcp_signed_in: attempt.mcpSignedIn,
@@ -3,18 +3,22 @@ import {
3
3
  readRunnerState,
4
4
  runnerStatePath,
5
5
  threadsFilePath
6
- } from "./chunk-QINWGIXU.js";
6
+ } from "./chunk-S4IN6AX2.js";
7
7
  import {
8
8
  BoxToolError,
9
9
  CLOOP_THREAD_PREFIX,
10
10
  ENVIRONMENTS,
11
+ MIN_PROTOCOL,
11
12
  RUNTIME_MODES,
13
+ T3Client,
12
14
  T3Driver,
15
+ T3HttpError,
13
16
  boxPath,
14
17
  cloopCommand,
15
18
  commandFor,
16
19
  defaultT3BinSources,
17
20
  environmentOf,
21
+ exchangePairing,
18
22
  isLocal,
19
23
  isYes,
20
24
  localRunsFilePath,
@@ -22,6 +26,7 @@ import {
22
26
  pickT3Bin,
23
27
  questionLine,
24
28
  quoteWindowsArg,
29
+ readEnvironment,
25
30
  readRunnerConfig,
26
31
  runT3,
27
32
  runnerDir,
@@ -32,7 +37,7 @@ import {
32
37
  windowsExecutable,
33
38
  windowsPowerShellEnv,
34
39
  writeBoxConfig
35
- } from "./chunk-R22774MI.js";
40
+ } from "./chunk-JM5NKNHE.js";
36
41
  import {
37
42
  getMachine,
38
43
  shortMachineName
@@ -50,17 +55,17 @@ import {
50
55
  } from "./chunk-R3CLO2FB.js";
51
56
  import {
52
57
  connectWebhook
53
- } from "./chunk-LORK2EOG.js";
58
+ } from "./chunk-N7PVNXYU.js";
54
59
  import {
55
60
  ConnectFailure,
56
61
  connectReport,
57
62
  deviceLogin,
58
63
  newAttempt,
59
64
  sendConnectReport
60
- } from "./chunk-EIBHDWUG.js";
65
+ } from "./chunk-TZ3I2IWD.js";
61
66
  import {
62
67
  VERSION
63
- } from "./chunk-OBFJRACJ.js";
68
+ } from "./chunk-3NIDXMUM.js";
64
69
  import {
65
70
  STAGING_ORIGIN,
66
71
  getOrigin,
@@ -80,34 +85,41 @@ import {
80
85
  writeFileSync
81
86
  } from "fs";
82
87
  import { homedir as homedir4, userInfo } from "os";
83
- import { basename as basename4, dirname, join as join3, resolve as resolve2 } from "path";
88
+ import { basename as basename5, dirname as dirname2, join as join3, resolve as resolve2 } from "path";
84
89
  import { createInterface } from "readline/promises";
85
90
  import { Writable } from "stream";
86
91
 
87
92
  // src/agent-install.ts
88
93
  import { spawn } from "child_process";
89
- import { existsSync, readdirSync } from "fs";
90
- import { delimiter, join, posix, win32 } from "path";
94
+ import { existsSync, readdirSync, realpathSync } from "fs";
95
+ import { basename, delimiter, dirname, join, posix, win32 } from "path";
91
96
  var CODEX_RELEASES = "https://github.com/openai/codex/releases/latest/download";
92
97
  var CODEX_TRIPLES = {
93
98
  "darwin-arm64": "aarch64-apple-darwin",
94
99
  "darwin-x64": "x86_64-apple-darwin",
95
100
  "linux-x64": "x86_64-unknown-linux-musl",
96
101
  "linux-arm64": "aarch64-unknown-linux-musl",
97
- "win32-x64": "x86_64-pc-windows-msvc.exe",
98
- "win32-arm64": "aarch64-pc-windows-msvc.exe"
102
+ "win32-x64": "x86_64-pc-windows-msvc",
103
+ "win32-arm64": "aarch64-pc-windows-msvc"
99
104
  };
100
105
  function codexAsset(platform, arch) {
101
106
  const triple = CODEX_TRIPLES[`${platform}-${arch}`];
102
- return triple ? `codex-${triple}` : null;
107
+ return triple ? `codex-package-${triple}` : null;
103
108
  }
104
- var codexBinDir = (home) => join(home, ".cloop", "bin");
109
+ var codexHome = (home) => join(home, ".cloop", "codex");
110
+ var codexBinDir = (home) => join(codexHome(home), "bin");
111
+ var CODE_MODE_HOST = "codex-code-mode-host";
112
+ var exe = (name, platform) => platform === "win32" ? `${name}.exe` : name;
113
+ var oneFileCodex = (home, platform) => join(home, ".cloop", "bin", exe("codex", platform));
105
114
  var psQuote = (value) => `'${value.replace(/'/g, "''")}'`;
115
+ var CODEX_SUMS = `${CODEX_RELEASES}/codex-package_SHA256SUMS`;
106
116
  function codexInstallCommand(home, platform = process.platform, arch = process.arch) {
107
117
  const asset = codexAsset(platform, arch);
108
118
  if (!asset) return null;
109
- const dir = codexBinDir(home);
110
- const url = `${CODEX_RELEASES}/${asset}.tar.gz`;
119
+ const dir = codexHome(home);
120
+ const file = `${asset}.tar.gz`;
121
+ const url = `${CODEX_RELEASES}/${file}`;
122
+ const old = oneFileCodex(home, platform);
111
123
  if (platform === "win32")
112
124
  return [
113
125
  "powershell",
@@ -118,24 +130,60 @@ function codexInstallCommand(home, platform = process.platform, arch = process.a
118
130
  [
119
131
  "$ErrorActionPreference = 'Stop'",
120
132
  `$d = ${psQuote(dir)}`,
121
- "New-Item -ItemType Directory -Force -Path $d | Out-Null",
122
- "$t = Join-Path ([IO.Path]::GetTempPath()) 'codex.tar.gz'",
133
+ "$s = $d + '.new'",
134
+ "$o = $d + '.old'",
135
+ "if (Test-Path $s) { Remove-Item -Recurse -Force $s }",
136
+ "New-Item -ItemType Directory -Force -Path $s | Out-Null",
137
+ "$t = Join-Path $s 'codex-package.tar.gz'",
123
138
  `Invoke-WebRequest -UseBasicParsing ${psQuote(url)} -OutFile $t`,
124
- "tar.exe -xzf $t -C $d",
125
- `Move-Item -Force (Join-Path $d ${psQuote(asset)}) (Join-Path $d 'codex.exe')`,
126
- "Remove-Item -Force $t"
139
+ "$h = Join-Path $s 'codex-package_SHA256SUMS'",
140
+ // GitHub serves the digest list as octet-stream, so .Content would be bytes; a file reads as lines.
141
+ `Invoke-WebRequest -UseBasicParsing ${psQuote(CODEX_SUMS)} -OutFile $h`,
142
+ `$line = Get-Content $h | Where-Object { $_.Trim().EndsWith(${psQuote(` ${file}`)}) } | Select-Object -First 1`,
143
+ `if (-not $line) { throw ${psQuote(`${file} is not in codex-package_SHA256SUMS`)} }`,
144
+ "$want = ($line.Trim() -split '\\s+')[0].ToLower()",
145
+ "$got = (Get-FileHash -Algorithm SHA256 $t).Hash.ToLower()",
146
+ `if ($got -ne $want) { throw ${psQuote(`${file} does not match its SHA-256 in codex-package_SHA256SUMS`)} }`,
147
+ "tar.exe -xzf $t -C $s",
148
+ "Remove-Item -Force $t, $h",
149
+ `foreach ($f in 'codex.exe', '${CODE_MODE_HOST}.exe') { if (-not (Test-Path (Join-Path $s (Join-Path 'bin' $f)))) { throw ($f + ' is not in the Codex package') } }`,
150
+ "if (Test-Path $o) { Remove-Item -Recurse -Force $o }",
151
+ "if (Test-Path $d) { Move-Item $d $o }",
152
+ "Move-Item $s $d",
153
+ "if (Test-Path $o) { Remove-Item -Recurse -Force $o -ErrorAction SilentlyContinue }",
154
+ `Remove-Item -Force -ErrorAction SilentlyContinue ${psQuote(old)}`
127
155
  ].join("; ")
128
156
  ];
129
157
  return [
130
158
  "sh",
131
159
  "-c",
132
- 'mkdir -p "$1" && curl -fsSL "$2" | tar -xz -C "$1" && mv -f "$1/$3" "$1/codex" && chmod 755 "$1/codex"',
160
+ POSIX_INSTALL,
133
161
  "cloop",
134
162
  dir,
135
163
  url,
136
- asset
164
+ CODEX_SUMS,
165
+ file,
166
+ platform === "darwin" ? "shasum -a 256" : "sha256sum",
167
+ CODE_MODE_HOST,
168
+ old
137
169
  ];
138
170
  }
171
+ var POSIX_INSTALL = [
172
+ 'rm -rf "$1.new" "$1.old"',
173
+ 'mkdir -p "$1.new"',
174
+ 'curl -fsSL "$2" -o "$1.new/codex-package.tar.gz"',
175
+ `want=$(curl -fsSL "$3" | awk -v f="$4" '$2 == f { print $1 }')`,
176
+ 'got=$($5 "$1.new/codex-package.tar.gz" | cut -d" " -f1)',
177
+ '{ [ -n "$want" ] && [ "$want" = "$got" ] || { echo "$4 does not match its SHA-256 in codex-package_SHA256SUMS" >&2; exit 1; }; }',
178
+ 'tar -xzf "$1.new/codex-package.tar.gz" -C "$1.new"',
179
+ 'rm -f "$1.new/codex-package.tar.gz"',
180
+ 'test -x "$1.new/bin/codex"',
181
+ 'test -x "$1.new/bin/$6"',
182
+ '{ [ ! -e "$1" ] || mv "$1" "$1.old"; }',
183
+ 'mv "$1.new" "$1"',
184
+ 'rm -rf "$1.old"',
185
+ 'rm -f "$7"'
186
+ ].join(" && ");
139
187
  async function installCodex(home, run = runShown) {
140
188
  const command = codexInstallCommand(home);
141
189
  if (!command || !await run(command)) return false;
@@ -176,6 +224,16 @@ function findIn(folder, name, env) {
176
224
  function findLocalCodex(home, env = process.env) {
177
225
  findIn(codexBinDir(home), "codex", env);
178
226
  }
227
+ function codexHostMissing(path, platform = process.platform) {
228
+ if (!path) return false;
229
+ try {
230
+ const real = realpathSync(path);
231
+ if (basename(real).toLowerCase() !== exe("codex", platform)) return false;
232
+ return !existsSync(join(dirname(real), exe(CODE_MODE_HOST, platform)));
233
+ } catch {
234
+ return false;
235
+ }
236
+ }
179
237
  function findLocalClaude(home, env = process.env) {
180
238
  findIn(join(home, ".local", "bin"), "claude", env);
181
239
  }
@@ -194,175 +252,6 @@ function hasChatGptApp(home, platform = process.platform, env = process.env, fs
194
252
  return false;
195
253
  }
196
254
 
197
- // src/t3.ts
198
- var T3_SCOPE = "orchestration:read orchestration:operate";
199
- var MIN_PROTOCOL = 2;
200
- async function readEnvironment(t3Url, fetchFn = fetch) {
201
- const res = await fetchFn(`${t3Url}/.well-known/t3/environment`);
202
- if (!res.ok) throw new Error(`T3 environment ${res.status} at ${t3Url}`);
203
- return await res.json();
204
- }
205
- async function exchangePairing(t3Url, credential, label, fetchFn = fetch) {
206
- const form = new URLSearchParams({
207
- grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
208
- subject_token: credential,
209
- subject_token_type: "urn:t3:params:oauth:token-type:environment-bootstrap",
210
- requested_token_type: "urn:ietf:params:oauth:token-type:access_token",
211
- scope: T3_SCOPE,
212
- client_label: label,
213
- client_device_type: "bot"
214
- });
215
- const res = await fetchFn(`${t3Url}/oauth/token`, { method: "POST", body: form });
216
- if (!res.ok) throw new T3HttpError("token exchange", res.status);
217
- const token = await res.json();
218
- if (!sameScopes(token.scope, T3_SCOPE))
219
- throw new Error(`T3 granted scope "${token.scope}", wanted "${T3_SCOPE}"`);
220
- return token;
221
- }
222
- function sameScopes(a, b) {
223
- const set = (s) => [...new Set(s.split(/\s+/).filter(Boolean))].sort().join(" ");
224
- return set(a) === set(b);
225
- }
226
- var T3HttpError = class extends Error {
227
- constructor(path, status) {
228
- super(`T3 ${path} ${status}`);
229
- this.status = status;
230
- this.name = "T3HttpError";
231
- }
232
- status;
233
- };
234
- var T3Client = class {
235
- constructor(t3Url, token, fetchFn = fetch) {
236
- this.t3Url = t3Url;
237
- this.token = token;
238
- this.fetchFn = fetchFn;
239
- }
240
- t3Url;
241
- token;
242
- fetchFn;
243
- async http(path, headers = {}) {
244
- const res = await this.fetchFn(`${this.t3Url}${path}`, {
245
- headers: { authorization: `Bearer ${this.token}`, ...headers }
246
- });
247
- if (!res.ok) throw new T3HttpError(path, res.status);
248
- return await res.json();
249
- }
250
- async openSocket() {
251
- const ticket = await this.fetchFn(`${this.t3Url}/api/auth/websocket-ticket`, {
252
- method: "POST",
253
- headers: { authorization: `Bearer ${this.token}` }
254
- });
255
- if (!ticket.ok) throw new T3HttpError("/api/auth/websocket-ticket", ticket.status);
256
- const { ticket: wsTicket } = await ticket.json();
257
- const { WebSocket } = await import("ws");
258
- const url = `${this.t3Url.replace(/^http/, "ws")}/ws?wsTicket=${encodeURIComponent(wsTicket)}&orchestrationProtocol=2&clientSurface=web&clientAppVersion=cloop-box`;
259
- return new WebSocket(url);
260
- }
261
- /** One request over a fresh /ws socket. The daemon makes a few calls a minute, so a socket per call is simpler than keeping one alive. */
262
- async rpc(tag, payload) {
263
- const ws = await this.openSocket();
264
- return new Promise((resolve3, reject) => {
265
- let settled = false;
266
- const finish = (fn) => {
267
- if (settled) return;
268
- settled = true;
269
- clearTimeout(timer);
270
- fn();
271
- try {
272
- ws.close();
273
- } catch {
274
- }
275
- };
276
- const timer = setTimeout(
277
- () => finish(() => reject(new Error(`T3 rpc ${tag} timed out`))),
278
- 15e3
279
- );
280
- ws.on(
281
- "error",
282
- (err) => finish(() => reject(err instanceof Error ? err : new Error(String(err))))
283
- );
284
- ws.on(
285
- "close",
286
- () => finish(() => reject(new Error(`T3 rpc ${tag}: socket closed before a reply`)))
287
- );
288
- ws.on("open", () => {
289
- ws.send(JSON.stringify({ _tag: "Request", id: 1, tag, payload, headers: [] }));
290
- });
291
- ws.on("message", (data) => {
292
- for (const msg of parseFrames(data)) {
293
- if (msg._tag !== "Exit" || String(msg.requestId) !== "1") continue;
294
- const exit = msg.exit;
295
- if (exit._tag === "Success") finish(() => resolve3(exit.value));
296
- else {
297
- finish(
298
- () => reject(
299
- new Error(`T3 rpc ${tag} failed: ${JSON.stringify(exit.cause).slice(0, 300)}`)
300
- )
301
- );
302
- }
303
- }
304
- });
305
- });
306
- }
307
- /**
308
- * A streaming request, such as `orchestration.subscribeThread`, on its own
309
- * socket. Every item is acked, as Effect RPC requires. `done` resolves with
310
- * the reason the stream ended and never rejects; `close` interrupts it.
311
- */
312
- async stream(tag, payload, onItem) {
313
- const ws = await this.openSocket();
314
- let resolveDone = () => {
315
- };
316
- const done = new Promise((r) => {
317
- resolveDone = r;
318
- });
319
- const end = (reason) => {
320
- resolveDone(reason);
321
- try {
322
- ws.close();
323
- } catch {
324
- }
325
- };
326
- ws.on("error", (err) => end(`error: ${err instanceof Error ? err.message : String(err)}`));
327
- ws.on("close", () => end("closed"));
328
- ws.on("open", () => {
329
- ws.send(JSON.stringify({ _tag: "Request", id: 1, tag, payload, headers: [] }));
330
- });
331
- ws.on("message", (data) => {
332
- for (const msg of parseFrames(data)) {
333
- if (String(msg.requestId) !== "1") continue;
334
- if (msg._tag === "Chunk") {
335
- ws.send(JSON.stringify({ _tag: "Ack", requestId: msg.requestId }));
336
- for (const value of msg.values) onItem(value);
337
- } else if (msg._tag === "Exit") {
338
- const exit = msg.exit;
339
- end(
340
- exit._tag === "Success" ? "exit" : `failed: ${JSON.stringify(exit.cause).slice(0, 300)}`
341
- );
342
- }
343
- }
344
- });
345
- return {
346
- done,
347
- close: () => {
348
- try {
349
- ws.send(JSON.stringify({ _tag: "Interrupt", requestId: "1" }));
350
- } catch {
351
- }
352
- end("closed by client");
353
- }
354
- };
355
- }
356
- };
357
- function parseFrames(data) {
358
- try {
359
- const raw = JSON.parse(String(data));
360
- return Array.isArray(raw) ? raw : [raw];
361
- } catch {
362
- return [];
363
- }
364
- }
365
-
366
255
  // src/box-tools.ts
367
256
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
368
257
  function parseLaunchArgs(args) {
@@ -487,7 +376,7 @@ async function revokeOwnDevice(origin, deviceToken, fetchFn = fetch) {
487
376
 
488
377
  // src/drivers/claude-code.ts
489
378
  import { execFile } from "child_process";
490
- import { basename, isAbsolute, relative, resolve } from "path";
379
+ import { basename as basename2, isAbsolute, relative, resolve } from "path";
491
380
  var SUBSCRIPTIONS = {
492
381
  max: "Claude Max",
493
382
  pro: "Claude Pro",
@@ -664,7 +553,7 @@ function parseClaudeLine(raw, run) {
664
553
  {
665
554
  type: "tool",
666
555
  name: block.name,
667
- ...path ? { target: basename(path) } : {},
556
+ ...path ? { target: basename2(path) } : {},
668
557
  ...summary ? { summary } : {},
669
558
  ...detail ? { detail } : {}
670
559
  }
@@ -764,14 +653,14 @@ function claudeDialect(bin = "claude", fallback = DEFAULT_FALLBACK_MODEL, askEve
764
653
  });
765
654
  },
766
655
  parse: parseClaudeLine,
767
- owns: (run, command) => command.includes(basename(bin)) && [run.work_id, run.session_id].some((id) => id !== null && command.includes(id)),
656
+ owns: (run, command) => command.includes(basename2(bin)) && [run.work_id, run.session_id].some((id) => id !== null && command.includes(id)),
768
657
  probe: () => probeClaude(bin)
769
658
  };
770
659
  }
771
660
 
772
661
  // src/drivers/codex.ts
773
662
  import { execFile as execFile2 } from "child_process";
774
- import { basename as basename2 } from "path";
663
+ import { basename as basename3 } from "path";
775
664
  function exec2(bin, args, timeout = 1e4) {
776
665
  const command = commandFor(bin, args);
777
666
  return new Promise(
@@ -857,7 +746,7 @@ function parseCodexLine(raw) {
857
746
  {
858
747
  type: "tool",
859
748
  name: "Edit",
860
- ...typeof path === "string" ? { target: basename2(path) } : {}
749
+ ...typeof path === "string" ? { target: basename3(path) } : {}
861
750
  }
862
751
  ];
863
752
  }
@@ -892,7 +781,7 @@ function codexDialect(bin = "codex") {
892
781
  models: () => codexModels(bin),
893
782
  parse: parseCodexLine,
894
783
  // A fresh run's command line names no id: Codex makes its session id after the start. So a run is also matched by its exact repository, which one open run per repository makes unique.
895
- owns: (run, command) => command.includes(basename2(bin)) && command.includes("exec") && command.includes("--json") && (run.session_id !== null && command.includes(run.session_id) || command.includes(`--cd ${run.repo} `)),
784
+ owns: (run, command) => command.includes(basename3(bin)) && command.includes("exec") && command.includes("--json") && (run.session_id !== null && command.includes(run.session_id) || command.includes(`--cd ${run.repo} `)),
896
785
  probe: () => probeCodex(bin)
897
786
  };
898
787
  }
@@ -906,7 +795,7 @@ import { join as join2 } from "path";
906
795
  import { execFileSync } from "child_process";
907
796
  import { existsSync as existsSync3, readFileSync, rmSync } from "fs";
908
797
  import { homedir } from "os";
909
- import { basename as basename3 } from "path";
798
+ import { basename as basename4 } from "path";
910
799
 
911
800
  // src/existing-runner.ts
912
801
  import { existsSync as existsSync2 } from "fs";
@@ -1009,7 +898,7 @@ async function disconnect(plan, opts) {
1009
898
  ...command[0] === "powershell" ? { env: windowsPowerShellEnv() } : {}
1010
899
  }));
1011
900
  if (plan.isBox && !opts.yes) {
1012
- const unit = plan.services.map((s) => basename3(s.path)).find((n) => n.startsWith("cloop-box"));
901
+ const unit = plan.services.map((s) => basename4(s.path)).find((n) => n.startsWith("cloop-box"));
1013
902
  say(`This computer runs ${unit}, the ${env} Cloop box with T3 Code. Disconnect would:`);
1014
903
  for (const s of plan.services) say(` stop and remove ${s.path}`);
1015
904
  if (plan.deviceToken) say(` revoke its runner device on Cloop (${plan.origin})`);
@@ -1383,7 +1272,10 @@ function which(bin) {
1383
1272
  }
1384
1273
  function whichPosix(bin) {
1385
1274
  try {
1386
- return execFileSync2("which", [bin], { encoding: "utf-8", env: CLEAN_ENV }).trim() || null;
1275
+ return execFileSync2("which", [bin], {
1276
+ encoding: "utf-8",
1277
+ env: { ...CLEAN_ENV, PATH: process.env.PATH }
1278
+ }).trim() || null;
1387
1279
  } catch {
1388
1280
  return null;
1389
1281
  }
@@ -1635,7 +1527,7 @@ function programFor(script, node, npx, version) {
1635
1527
  }
1636
1528
  function findNpx() {
1637
1529
  const name = process.platform === "win32" ? "npx.cmd" : "npx";
1638
- const beside = join3(dirname(process.execPath), name);
1530
+ const beside = join3(dirname2(process.execPath), name);
1639
1531
  return existsSync5(beside) ? beside : which(name);
1640
1532
  }
1641
1533
  async function awaitDaemon(since, read = readRunnerState, { timeoutMs = 15e3, pollMs = 500 } = {}) {
@@ -1826,7 +1718,7 @@ function resolveRepos(paths, toplevel, isFolder = folderAt) {
1826
1718
  if (!isFolder(full))
1827
1719
  return `${p} is not a folder. Pass --repo <path> for each folder Cloop may work in.`;
1828
1720
  const top = toplevel(full) ?? full;
1829
- if (!repos.some((r) => r.path === top)) repos.push({ label: basename4(top), path: top });
1721
+ if (!repos.some((r) => r.path === top)) repos.push({ label: basename5(top), path: top });
1830
1722
  }
1831
1723
  return repos;
1832
1724
  }
@@ -1917,7 +1809,7 @@ async function reposFor(argv) {
1917
1809
  return repos2;
1918
1810
  }
1919
1811
  const here = gitTop(process.cwd());
1920
- if (here) return [{ label: basename4(here), path: here }];
1812
+ if (here) return [{ label: basename5(here), path: here }];
1921
1813
  const home = homedir4();
1922
1814
  const work = workFolder(home);
1923
1815
  const found = findCheckouts(home);
@@ -2299,6 +2191,7 @@ async function connect(argv, attempt, deps = {}) {
2299
2191
  const terminal = deps.terminal ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
2300
2192
  const current = await prepareAgents(found, forced, workstation, {
2301
2193
  chatGptApp: deps.chatGptApp ?? (() => machine && hasChatGptApp(homedir4())),
2194
+ codexHostMissing: deps.codexHostMissing ?? (() => machine && codexHostMissing(which("codex"))),
2302
2195
  installCodex: deps.installCodex ?? (async () => machine && installCodex(homedir4())),
2303
2196
  installClaude: deps.installClaude ?? (async () => machine && installClaude(homedir4())),
2304
2197
  readCodex,
@@ -2307,8 +2200,9 @@ async function connect(argv, attempt, deps = {}) {
2307
2200
  signInCodex: deps.signInCodex ?? (() => signInCodex(harnessBin("codex"))),
2308
2201
  signInClaude: deps.signInClaude ?? (() => signInClaude(harnessBin("claude"))),
2309
2202
  terminal,
2310
- installed: (agent, ok) => {
2203
+ installed: (agent, ok, reason) => {
2311
2204
  attempt[agent === "codex" ? "codexInstall" : "claudeInstall"] = ok ? "ok" : "failed";
2205
+ if (agent === "codex") attempt.codexInstallReason = reason ?? null;
2312
2206
  }
2313
2207
  });
2314
2208
  attempt.harnesses = harnessesFound(current);
@@ -2375,10 +2269,10 @@ async function prepareAgents(found, forced, workstation, deps) {
2375
2269
  let current = found;
2376
2270
  const say = (line2) => out(`${bold("Cloop runner")} ${line2}`);
2377
2271
  const chatGptApp = forced !== "claude-code" && deps.chatGptApp();
2378
- const getCodex = async (why) => {
2272
+ const getCodex = async (why, reason) => {
2379
2273
  say(`${why} Installing the latest Codex from ${CODEX_RELEASES}.`);
2380
2274
  const codex = await deps.installCodex() ? await deps.readCodex() : null;
2381
- deps.installed("codex", Boolean(codex));
2275
+ deps.installed("codex", Boolean(codex), reason);
2382
2276
  if (codex) say(`Installed Codex${codex.version ? ` ${codex.version}` : ""}.`);
2383
2277
  else
2384
2278
  out(`${red("\u2717")} Codex did not install. Install it yourself: npm install -g @openai/codex`);
@@ -2386,16 +2280,28 @@ async function prepareAgents(found, forced, workstation, deps) {
2386
2280
  };
2387
2281
  const codexVersion = current.codex?.version;
2388
2282
  if (!current.codex && forced === "codex")
2389
- current = { ...current, codex: await getCodex("Codex is not installed here.") };
2283
+ current = { ...current, codex: await getCodex("Codex is not installed here.", "named") };
2390
2284
  else if (!current.codex && chatGptApp)
2391
2285
  current = {
2392
2286
  ...current,
2393
2287
  codex: await getCodex(
2394
- "The ChatGPT app is here, and Codex signs in with your ChatGPT account."
2288
+ "The ChatGPT app is here, and Codex signs in with your ChatGPT account.",
2289
+ "chatgpt_app"
2395
2290
  )
2396
2291
  };
2397
2292
  else if (current.codex && codexVersion && olderThan(codexVersion, CODEX_FLOOR))
2398
- current = { ...current, codex: await getCodex(codexTooOld(codexVersion)) ?? current.codex };
2293
+ current = {
2294
+ ...current,
2295
+ codex: await getCodex(codexTooOld(codexVersion), "floor") ?? current.codex
2296
+ };
2297
+ else if (current.codex && deps.codexHostMissing())
2298
+ current = {
2299
+ ...current,
2300
+ codex: await getCodex(
2301
+ `This Codex has no ${CODE_MODE_HOST} beside it, so none of its tools can run.`,
2302
+ "host_missing"
2303
+ ) ?? current.codex
2304
+ };
2399
2305
  if (!current.claude && (forced === "claude-code" || !current.codex && forced !== "codex")) {
2400
2306
  say(
2401
2307
  `${current.codex || forced ? "Claude Code is not installed here." : "No coding agent here."} Installing Claude Code with Anthropic's installer.`
@@ -2522,7 +2428,6 @@ async function connectCommand(argv) {
2522
2428
  }
2523
2429
 
2524
2430
  export {
2525
- T3Client,
2526
2431
  runBoxTool,
2527
2432
  probeClaudePermissions,
2528
2433
  probeClaude,
@@ -52,17 +52,17 @@ import {
52
52
  which,
53
53
  workFolder,
54
54
  workFolderLine
55
- } from "./chunk-HVXCQQWG.js";
56
- import "./chunk-QINWGIXU.js";
57
- import "./chunk-R22774MI.js";
55
+ } from "./chunk-UX7QUFSH.js";
56
+ import "./chunk-S4IN6AX2.js";
57
+ import "./chunk-JM5NKNHE.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-LORK2EOG.js";
63
- import "./chunk-EIBHDWUG.js";
62
+ import "./chunk-N7PVNXYU.js";
63
+ import "./chunk-TZ3I2IWD.js";
64
64
  import "./chunk-ES5BRAKJ.js";
65
- import "./chunk-OBFJRACJ.js";
65
+ import "./chunk-3NIDXMUM.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-HVXCQQWG.js";
11
- import "./chunk-QINWGIXU.js";
12
- import "./chunk-R22774MI.js";
10
+ } from "./chunk-UX7QUFSH.js";
11
+ import "./chunk-S4IN6AX2.js";
12
+ import "./chunk-JM5NKNHE.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-LORK2EOG.js";
18
- import "./chunk-EIBHDWUG.js";
17
+ import "./chunk-N7PVNXYU.js";
18
+ import "./chunk-TZ3I2IWD.js";
19
19
  import "./chunk-ES5BRAKJ.js";
20
- import "./chunk-OBFJRACJ.js";
20
+ import "./chunk-3NIDXMUM.js";
21
21
  import "./chunk-D5UZW42X.js";
22
22
  export {
23
23
  disconnect,