@commonlyai/cli 0.1.342 → 0.1.344

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.342",
3
+ "version": "0.1.344",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -154,6 +154,7 @@ import {
154
154
  isClaudeSignedOut,
155
155
  spawnFailureReason,
156
156
  } from '../lib/turn-failure-notice.js';
157
+ import { missingHarnessHint, reportMissingHarness } from '../lib/missing-harness.js';
157
158
  import {
158
159
  ADDRESSED_EVENT_TYPES,
159
160
  isPersonMention,
@@ -557,9 +558,10 @@ export const bootstrapAgentRecordFromEnv = async ({
557
558
  const instanceUrl = (env.COMMONLY_API_URL || '').trim() || resolveInstanceUrl(undefined);
558
559
 
559
560
  let identity;
561
+ let client;
560
562
  try {
561
- identity = await clientFactory({ instance: instanceUrl, token: runtimeToken })
562
- .get('/api/agents/runtime/installations');
563
+ client = clientFactory({ instance: instanceUrl, token: runtimeToken });
564
+ identity = await client.get('/api/agents/runtime/installations');
563
565
  } catch (err) {
564
566
  throw new Error(
565
567
  `Could not resolve the agent behind COMMONLY_AGENT_TOKEN against ${instanceUrl}: ${err.message}. `
@@ -580,7 +582,10 @@ export const bootstrapAgentRecordFromEnv = async ({
580
582
  throw new Error(`Unknown adapter '${adapterOverride}'. Known: ${(adapterRegistry.listPublicAdapterNames || adapterRegistry.listAdapterNames)().join(', ')}`);
581
583
  }
582
584
  if (!await adapter.detect()) {
583
- throw new Error(`Adapter '${adapterOverride}' not found on PATH.`);
585
+ // F457: this run exits before it checks in, so the page would wait for
586
+ // it forever. Say what was missing there, and how to get it here.
587
+ await reportMissingHarness(client, adapterOverride);
588
+ throw new Error(`Adapter '${adapterOverride}' not found on PATH. ${missingHarnessHint(adapterOverride)}`);
584
589
  }
585
590
  } else {
586
591
  const missing = [];
@@ -591,6 +596,7 @@ export const bootstrapAgentRecordFromEnv = async ({
591
596
  missing.push(candidate);
592
597
  }
593
598
  if (!adapterName) {
599
+ await reportMissingHarness(client, null);
594
600
  const err = new Error(
595
601
  `No supported agent CLI found on PATH (looked for: ${BOOTSTRAP_ADAPTER_DETECT_ORDER.join(', ')}). `
596
602
  + 'Install one, or pass --adapter <name>.',
@@ -24,7 +24,9 @@ import { requireSeatModel, seatModelRequired } from './seat-model.js';
24
24
  import { isPatchAfterNewestTested } from './tested-version.js';
25
25
  import { spawn as childSpawn, spawnSync } from 'child_process';
26
26
  import { createHash, randomUUID } from 'crypto';
27
- import { existsSync, readdirSync, realpathSync, rmSync } from 'fs';
27
+ import {
28
+ existsSync, lstatSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync,
29
+ } from 'fs';
28
30
  import {
29
31
  chmod,
30
32
  lstat,
@@ -39,7 +41,7 @@ import {
39
41
  import { homedir, tmpdir } from 'os';
40
42
  import { fileURLToPath } from 'url';
41
43
  import {
42
- dirname, isAbsolute, join, relative, resolve as pathResolve,
44
+ basename, dirname, isAbsolute, join, relative, resolve as pathResolve,
43
45
  } from 'path';
44
46
  import { writeCredentialFile } from '../credential-file.js';
45
47
  import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
@@ -193,17 +195,138 @@ const gitReportedWorktree = (holder, env) => {
193
195
  };
194
196
 
195
197
  // Bounds for the pre-spawn symlink walk. Reaching either one leaves the
196
- // workspace unproven, and a seat carrying the grant broker then refuses
198
+ // workspace unproven, and a public seat then refuses
197
199
  // (`assertSpawnRootOutsideWorkspace`), so the depth sits well above real source
198
200
  // trees: it guards against a pathological tree, not an ordinary one.
199
201
  const SYMLINK_WALK_BOUNDS = Object.freeze({ maxDepth: 32, maxEntries: 20000 });
200
- // CodeRabbit round 4 (#3487): a grant-bearing spawn also walks every
201
- // node_modules tree, links only, under its own bound. Measured 2026-11-05 on
202
+ // CodeRabbit round 4 (#3487): the walk also covers every dependency tree,
203
+ // links only, under its own bound (every public spawn since F185). Measured 2026-11-05 on
202
204
  // this repo's backend/node_modules: 44,664 entries, 63 symlinks (none leaving
203
205
  // the workspace), 0.5-1.4 s on a host at load average ~90.
204
206
  const DEPENDENCY_WALK_BOUNDS = Object.freeze({ maxDepth: 64, maxEntries: 200000 });
205
207
  const SYMLINK_WALK_SKIP = new Set(['.git']);
206
- const DEPENDENCY_DIR = 'node_modules';
208
+ // Package-manager trees: their contents are walked links-only under the
209
+ // dependency budget, never as source. A Python environment is one too, by
210
+ // name or by its marker (`pyvenv.cfg`, conda's `conda-meta`), whatever its
211
+ // folder is called: its files would exhaust the source budget (F185).
212
+ const DEPENDENCY_DIRS = new Set(['node_modules', '.venv']);
213
+ const isPythonEnvironment = (entries) => entries.some((entry) => (
214
+ (entry.name === 'pyvenv.cfg' && entry.isFile()) || (entry.name === 'conda-meta' && entry.isDirectory())
215
+ ));
216
+ // Pseudo-file systems: a path in them names something per process (an open
217
+ // descriptor, a device), so where it leads in OpenCode is not where it leads
218
+ // here. No link may go there.
219
+ const SPECIAL_ROOTS = ['/proc', '/dev'];
220
+ const underSpecial = (path) => SPECIAL_ROOTS.some((root) => isWithin(root, path));
221
+ const MAX_LINK_HOPS = 40;
222
+
223
+ const isRegularFile = (path) => {
224
+ try { return statSync(path).isFile(); } catch { return false; }
225
+ };
226
+
227
+ /**
228
+ * F185. Matches a resolved path against the folders holding this spawn's
229
+ * secrets: it lies inside one, or holds one. The same three tests as the
230
+ * provider key file check (keyFileReadableRoot, F453): the paths as written,
231
+ * real-pathed, and by file identity, so another spelling of the same place
232
+ * (case, a firmlink) is the same place. Each path's identity is looked up once
233
+ * per walk; a dependency tree shares most of its ancestors.
234
+ */
235
+ const secretMatcher = (secretRoots) => {
236
+ const ids = new Map();
237
+ const idOf = (path) => {
238
+ if (!ids.has(path)) {
239
+ let id = null;
240
+ try {
241
+ const details = statSync(path, { bigint: true });
242
+ id = `${details.dev}:${details.ino}`;
243
+ } catch { /* absent: no identity */ }
244
+ ids.set(path, id);
245
+ }
246
+ return ids.get(path);
247
+ };
248
+ const chainIds = (path) => {
249
+ const out = new Set();
250
+ for (let current = path; ; current = dirname(current)) {
251
+ const id = idOf(current);
252
+ if (id) out.add(id);
253
+ if (dirname(current) === current) break;
254
+ }
255
+ return out;
256
+ };
257
+ const secrets = secretRoots.map((root) => ({
258
+ root,
259
+ spellings: [...new Set([pathResolve(root), realOrSelf(root)])],
260
+ id: idOf(root),
261
+ ancestorIds: chainIds(root),
262
+ }));
263
+ return (resolved) => {
264
+ const ancestors = chainIds(resolved);
265
+ const own = idOf(resolved);
266
+ const found = secrets.find((secret) => (
267
+ secret.spellings.some((spelling) => isWithin(spelling, resolved) || isWithin(resolved, spelling))
268
+ || (secret.id && ancestors.has(secret.id))
269
+ || (own && secret.ancestorIds.has(own))
270
+ ));
271
+ return found ? found.root : null;
272
+ };
273
+ };
274
+
275
+ /**
276
+ * Where a link lands, resolved one component at a time the way the kernel
277
+ * does it, so every step is seen: `special` is set when any step (a hop's
278
+ * target, or a folder passed through) is under /proc or /dev. There a path
279
+ * names something per process (an open descriptor, a process's root), so
280
+ * where it leads for OpenCode is not where it leads for this check, whether or
281
+ * not it resolves here. `..` applies to the real path reached so far, never
282
+ * to the text.
283
+ *
284
+ * `{ resolved, exists: true }` when every component exists (`resolved` is the
285
+ * canonical spelling). When one is missing, `{ resolved, exists: false }`
286
+ * gives where it would land: the real prefix with the rest appended. A missing
287
+ * target is not proof of no route: the seat's data home gets files during the
288
+ * turn. Throws ELOOP past MAX_LINK_HOPS, and any lstat or readlink error other
289
+ * than a missing component.
290
+ */
291
+ const linkLanding = (path) => {
292
+ let special = false;
293
+ let hops = 0;
294
+ // The walk only reaches real directories, so the link's own folder is real.
295
+ let done = realOrSelf(dirname(pathResolve(path)));
296
+ special = special || underSpecial(done);
297
+ const pending = [basename(path)];
298
+ while (pending.length) {
299
+ const part = pending.shift();
300
+ if (part === '' || part === '.') continue;
301
+ if (part === '..') {
302
+ done = dirname(done);
303
+ continue;
304
+ }
305
+ const next = join(done, part);
306
+ special = special || underSpecial(next);
307
+ let details;
308
+ try {
309
+ details = lstatSync(next);
310
+ } catch (err) {
311
+ if (err?.code !== 'ENOENT' && err?.code !== 'ENOTDIR') throw err;
312
+ const rest = pending.filter((piece) => piece && piece !== '.');
313
+ const resolved = pathResolve(next, ...(rest.length ? [rest.join('/')] : []));
314
+ return { resolved, exists: false, special: special || underSpecial(resolved) };
315
+ }
316
+ if (details.isSymbolicLink()) {
317
+ hops += 1;
318
+ if (hops > MAX_LINK_HOPS) throw Object.assign(new Error(`too many symlink hops resolving ${path}`), { code: 'ELOOP' });
319
+ const text = readlinkSync(next);
320
+ if (isAbsolute(text)) done = '/';
321
+ special = special || underSpecial(pathResolve(done, text));
322
+ pending.unshift(...text.split('/'));
323
+ continue;
324
+ }
325
+ done = next;
326
+ }
327
+ // Case and firmlinks: the canonical spelling, for the boundary comparison.
328
+ return { resolved: realOrSelf(done), exists: true, special: special || underSpecial(done) };
329
+ };
207
330
 
208
331
  /**
209
332
  * Scan `workspace` for a symlink OpenCode's tools could follow to the per-spawn
@@ -213,10 +336,12 @@ const DEPENDENCY_DIR = 'node_modules';
213
336
  * `path: <workspace link to the temp root>` searches the credential's contents
214
337
  * with nothing asked. This walk is what stops that, not a permission pattern.
215
338
  *
216
- * Returns `{ link, reason }` for the first offending link, `{ incomplete }` when
217
- * a bound stopped the walk before it saw the whole tree, or null.
218
- * - `reaches_spawn_root`: the link's target holds or lies inside `spawnRoot`.
219
- * A dangling link (an old spawn root, since removed) can't, and is skipped.
339
+ * Returns `{ link, reason, secret? }` for the first offending link, `{ incomplete }`
340
+ * when a bound stopped the walk before it saw the whole tree, or null.
341
+ * - `reaches_spawn_root`: the link's landing holds or lies inside `spawnRoot`
342
+ * or one of `secretRoots` (named in `secret`). A dangling link is judged by
343
+ * where it would land (`linkLanding`).
344
+ * - `special_filesystem`: the link leads, at any hop, under /proc or /dev.
220
345
  * - `outside_workspace`: a link AT a node_modules top level (or under an
221
346
  * @scope there) leading out of `boundary`. node_modules is not walked into,
222
347
  * since a typical one exhausts the entry bound on every spawn; its packages'
@@ -224,8 +349,8 @@ const DEPENDENCY_DIR = 'node_modules';
224
349
  * link out (`npm link`, a `file:` dependency) reaches a tree this walk never
225
350
  * read.
226
351
  *
227
- * `deepDependencies` (a spawn that hands its credential to a remote server):
228
- * every workspace link is held to `boundary` as well, and every node_modules tree, nested ones and @scopes included, is walked too,
352
+ * `deepDependencies` (every public spawn since F185; the default stays off for
353
+ * direct callers): every workspace link is held to `boundary` as well, and every node_modules tree, nested ones and @scopes included, is walked too,
229
354
  * links only, under `dependencyBounds`, its own budget. A link anywhere in it
230
355
  * that reaches the spawn root, or that leaves `boundary`, is refused, since a
231
356
  * package tarball or postinstall script can plant `dist/x -> /tmp`, or a chain
@@ -238,16 +363,19 @@ const DEPENDENCY_DIR = 'node_modules';
238
363
  * OS) or a link realpath cannot resolve for a reason other than a missing
239
364
  * target (`incomplete: 'unresolvable'`, a loop say), each with `problem:
240
365
  * { path, code }`. `root` is where the walk starts: the git worktree root for a
241
- * grant seat, since OpenCode's tools reach the whole worktree.
366
+ * public seat, since OpenCode's tools reach the whole worktree. A link to a
367
+ * regular file outside `boundary` and every secret folder passes: a file holds
368
+ * no further link.
242
369
  */
243
370
  const scanWorkspaceLinks = (workspace, spawnRoot, {
244
371
  boundary = workspace,
245
372
  root = workspace,
373
+ secretRoots = [],
246
374
  bounds = SYMLINK_WALK_BOUNDS,
247
375
  deepDependencies = false,
248
376
  dependencyBounds = DEPENDENCY_WALK_BOUNDS,
249
377
  } = {}) => {
250
- const target = realOrSelf(spawnRoot);
378
+ const matchSecret = secretMatcher([...new Set([spawnRoot, ...secretRoots].filter(Boolean))]);
251
379
  const inside = realOrSelf(boundary);
252
380
  let budget = bounds.maxEntries;
253
381
  let dependencyBudget = dependencyBounds.maxEntries;
@@ -261,15 +389,23 @@ const scanWorkspaceLinks = (workspace, spawnRoot, {
261
389
  problem = problem || { path, code: err?.code || String(err) };
262
390
  };
263
391
  const linkFinding = (path, { dependencyTop }) => {
264
- let resolved;
392
+ let landing;
265
393
  try {
266
- resolved = canonicalPath(path);
394
+ landing = linkLanding(path);
267
395
  } catch (err) {
268
396
  unproven('unresolvable', path, err);
269
397
  return null;
270
398
  }
271
- if (isWithin(resolved, target) || isWithin(target, resolved)) return { link: path, reason: 'reaches_spawn_root' };
272
- if (dependencyTop && !isWithin(inside, resolved)) return { link: path, reason: 'outside_workspace' };
399
+ const { resolved, exists, special } = landing;
400
+ if (special) return { link: path, reason: 'special_filesystem' };
401
+ const secret = matchSecret(resolved);
402
+ if (secret) return { link: path, reason: 'reaches_spawn_root', secret };
403
+ if (!exists) return null;
404
+ // A regular file outside every secret folder holds no further link, so a
405
+ // link to one leads nowhere else (a virtualenv's bin/python -> /usr/bin).
406
+ if (dependencyTop && !isWithin(inside, resolved) && !isRegularFile(resolved)) {
407
+ return { link: path, reason: 'outside_workspace' };
408
+ }
273
409
  return null;
274
410
  };
275
411
  const readEntries = (dir) => {
@@ -341,6 +477,8 @@ const scanWorkspaceLinks = (workspace, spawnRoot, {
341
477
  }
342
478
  const entries = readEntries(dir);
343
479
  if (incomplete) return null;
480
+ // A Python environment under any name: links only, on the dependency budget.
481
+ if (deepDependencies && isPythonEnvironment(entries)) return scanDependencyTree(dir);
344
482
  for (const entry of entries) {
345
483
  budget -= 1;
346
484
  if (budget < 0) {
@@ -349,17 +487,17 @@ const scanWorkspaceLinks = (workspace, spawnRoot, {
349
487
  }
350
488
  const path = join(dir, entry.name);
351
489
  if (entry.isSymbolicLink()) {
352
- // A grant seat holds every workspace link to the boundary: a chain
353
- // through a tree outside it (src/vendor -> /outside, a node_modules
354
- // that is itself a link) is resolved by the OS, unread by this walk.
490
+ // Every workspace link is held to the boundary: a chain through a tree
491
+ // outside it (src/vendor -> /outside, a node_modules that is itself a
492
+ // link) is resolved by the OS, unread by this walk.
355
493
  const hit = linkFinding(path, { dependencyTop: deepDependencies });
356
494
  if (hit || incomplete) return hit;
357
- } else if (entry.isDirectory() && entry.name === DEPENDENCY_DIR) {
495
+ } else if (entry.isDirectory() && DEPENDENCY_DIRS.has(entry.name)) {
358
496
  const hit = scanDependencyTop(path) || (!incomplete && deepDependencies ? scanDependencyTree(path) : null);
359
497
  if (hit || incomplete) return hit;
360
498
  } else if (deepDependencies && entry.isDirectory() && SYMLINK_WALK_SKIP.has(entry.name)) {
361
- // `.git` on a grant seat: links only, under the dependency budget
362
- // (8,243 entries in this repo's own checkout, no links).
499
+ // `.git`: links only, under the dependency budget (8,243 entries in
500
+ // this repo's own checkout, no links).
363
501
  const hit = scanDependencyTree(path);
364
502
  if (hit || incomplete) return hit;
365
503
  } else if (entry.isDirectory() && !SYMLINK_WALK_SKIP.has(entry.name)) {
@@ -377,13 +515,15 @@ const scanWorkspaceLinks = (workspace, spawnRoot, {
377
515
 
378
516
  /**
379
517
  * Refuse a public seat whose workspace lets OpenCode's tools reach the
380
- * per-spawn credential directory. `carriesGrant` says whether this spawn hands
381
- * its credential file to a remote MCP server (buildMcpConfig's report, the
382
- * grant broker among them): a walk stopped by its bound refuses only then,
383
- * since a huge monorepo should not be refused when there is no grant to protect.
518
+ * per-spawn credential directory, or another folder holding this spawn's
519
+ * secrets (`secretRoots`, the seat's data home). Every public spawn holds a
520
+ * live Commonly token and a provider-proxy token there, so every one gets the
521
+ * same walk (F185): from the worktree root, node_modules, .venv and .git
522
+ * links-only, every link held to the worktree, and a walk its bound stopped
523
+ * refuses.
384
524
  */
385
525
  const assertSpawnRootOutsideWorkspace = (workspace, spawnRoot, {
386
- carriesGrant = false,
526
+ secretRoots = [],
387
527
  bounds = SYMLINK_WALK_BOUNDS,
388
528
  dependencyBounds = DEPENDENCY_WALK_BOUNDS,
389
529
  gitEnv = null,
@@ -441,14 +581,14 @@ const assertSpawnRootOutsideWorkspace = (workspace, spawnRoot, {
441
581
  // OpenCode counts the whole git worktree as inside the project, so a
442
582
  // node_modules link into it is not a link out.
443
583
  const boundary = toplevels[0]?.[0] || gitToplevel(pathResolve(workspace)) || workspace;
444
- // A grant seat walks the whole worktree OpenCode's tools can reach, sibling
445
- // packages and .git included (Opus review, #3487); a seat without one, its
446
- // workspace.
584
+ // The whole worktree OpenCode's tools can reach, sibling packages and .git
585
+ // included (Opus review, #3487; every public spawn since F185).
447
586
  const finding = scanWorkspaceLinks(workspace, spawnRoot, {
448
587
  boundary,
449
- root: carriesGrant ? realOrSelf(boundary) : workspace,
588
+ root: realOrSelf(boundary),
589
+ secretRoots,
450
590
  bounds,
451
- deepDependencies: carriesGrant,
591
+ deepDependencies: true,
452
592
  dependencyBounds,
453
593
  });
454
594
  if (finding?.incomplete === 'unreadable' || finding?.incomplete === 'unresolvable') {
@@ -456,14 +596,22 @@ const assertSpawnRootOutsideWorkspace = (workspace, spawnRoot, {
456
596
  throw new Error(
457
597
  `public OpenCode agents could not ${finding.incomplete === 'unreadable' ? 'list the directory' : 'resolve the symlink'} `
458
598
  + `${path} (${code}) while checking the workspace (${workspace}) for symlinks to the per-spawn credential directory; `
459
- + 'what the walk cannot see is not proven clean, and this seat carries a connector grant; fix its permissions, '
460
- + 'remove it, or drop the grant broker from this seat',
599
+ + 'what the walk cannot see is not proven clean; fix its permissions, or remove it',
461
600
  );
462
601
  }
463
602
  if (finding?.reason === 'reaches_spawn_root') {
603
+ const folder = !finding.secret || finding.secret === spawnRoot
604
+ ? `the per-spawn credential directory (${spawnRoot})`
605
+ : `the seat's data folder (${finding.secret})`;
606
+ throw new Error(
607
+ `public OpenCode agents refuse a workspace (${workspace}) holding a symlink (${finding.link}) that reaches `
608
+ + `${folder}: OpenCode's tools could read this spawn's credentials through it; remove the link`,
609
+ );
610
+ }
611
+ if (finding?.reason === 'special_filesystem') {
464
612
  throw new Error(
465
- `public OpenCode agents refuse a workspace (${workspace}) holding a symlink (${finding.link}) that reaches the per-spawn `
466
- + `credential directory (${spawnRoot}): OpenCode's tools could read the credential through it; remove the link`,
613
+ `public OpenCode agents refuse a workspace (${workspace}) holding a symlink (${finding.link}) that leads into `
614
+ + '/proc or /dev, where a path names something per process and the check cannot follow it; remove the link',
467
615
  );
468
616
  }
469
617
  if (finding?.reason === 'outside_workspace') {
@@ -478,15 +626,15 @@ const assertSpawnRootOutsideWorkspace = (workspace, spawnRoot, {
478
626
  `public OpenCode agents could not finish checking the workspace's node_modules and .git trees (${workspace}) for symlinks `
479
627
  + `to the per-spawn credential directory: the link walk stopped at its ${finding.incomplete === 'dependency_depth'
480
628
  ? `depth bound (${dependencyBounds.maxDepth} levels)` : `entry bound (${dependencyBounds.maxEntries} entries)`}, `
481
- + 'and this seat carries a connector grant; prune the dependency tree, or drop the grant broker from this seat',
629
+ + 'prune the dependency tree, or choose a smaller workspace',
482
630
  );
483
631
  }
484
- if (finding?.incomplete && carriesGrant) {
632
+ if (finding?.incomplete) {
485
633
  throw new Error(
486
634
  `public OpenCode agents could not finish checking the workspace (${workspace}) for symlinks to the per-spawn `
487
635
  + `credential directory: the walk stopped at its ${finding.incomplete === 'depth'
488
- ? `depth bound (${bounds.maxDepth} levels)` : `entry bound (${bounds.maxEntries} entries)`}, and this seat `
489
- + 'carries a connector grant; choose a smaller workspace, or drop the grant broker from this seat',
636
+ ? `depth bound (${bounds.maxDepth} levels)` : `entry bound (${bounds.maxEntries} entries)`}; `
637
+ + 'choose a smaller workspace',
490
638
  );
491
639
  }
492
640
  };
@@ -1361,7 +1509,7 @@ export default {
1361
1509
  // After the child env exists: the git check runs under the very env
1362
1510
  // OpenCode gets (its HOME, its XDG config, no GIT_* from the launcher).
1363
1511
  assertSpawnRootOutsideWorkspace(ctx.cwd || process.cwd(), tempDir, {
1364
- carriesGrant,
1512
+ secretRoots: [openCodeHome.root],
1365
1513
  bounds: ctx._symlinkWalkBounds || SYMLINK_WALK_BOUNDS,
1366
1514
  dependencyBounds: ctx._dependencyWalkBounds || DEPENDENCY_WALK_BOUNDS,
1367
1515
  gitEnv: childEnv,
@@ -1503,5 +1651,6 @@ export {
1503
1651
  qualifiedProviderModel,
1504
1652
  resolveProviderKeyFile,
1505
1653
  scanWorkspaceLinks,
1654
+ assertSpawnRootOutsideWorkspace,
1506
1655
  startProviderProxy,
1507
1656
  };
@@ -0,0 +1,31 @@
1
+ // F457: what a quick-try run says when the harness it needs isn't on PATH, and
2
+ // the report it leaves first. The run exits before it ever checks in, so
3
+ // without the report the connect page waits for it forever.
4
+
5
+ import { NPM } from './cli-hint.js';
6
+
7
+ // Only harnesses whose install command we have run ourselves get one here.
8
+ const INSTALL = {
9
+ claude: { label: 'Claude Code', command: `${NPM} i -g @anthropic-ai/claude-code`, signIn: 'claude' },
10
+ codex: { label: 'Codex', command: `${NPM} i -g @openai/codex`, signIn: 'codex' },
11
+ };
12
+
13
+ /** One sentence on how to get the named harness, ending with "run this line again". */
14
+ export const missingHarnessHint = (name) => {
15
+ const known = INSTALL[name];
16
+ if (!known) return `Install ${name}, then run this line again.`;
17
+ return `Install ${known.label} (${known.command}), sign in once by running ${known.signIn}, then run this line again.`;
18
+ };
19
+
20
+ /**
21
+ * Tell the instance what this run looked for (a harness id, or null for none
22
+ * of the ones it probes). Best effort: an older instance without the route, or
23
+ * a failed call, must not hide the message the person needs in the terminal.
24
+ */
25
+ export const reportMissingHarness = async (client, harness) => {
26
+ try {
27
+ await client?.post?.('/api/agents/runtime/harness-missing', { harness });
28
+ } catch {
29
+ // The terminal message below is the answer either way.
30
+ }
31
+ };