@commonlyai/cli 0.1.246 → 0.1.248

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.246",
3
+ "version": "0.1.248",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -37,7 +37,7 @@ import { getToken, resolveInstanceUrl } from '../lib/config.js';
37
37
  import { startPoller, terminalDeliveryAckError } from '../lib/poller.js';
38
38
  import { formatDigestFrame } from '../lib/digest-frame.js';
39
39
  import { startWebhookServer, forwardToLocalWebhook, logOnlyHandler } from '../lib/webhook-server.js';
40
- import { getAdapter, listAdapterNames } from '../lib/adapters/index.js';
40
+ import { getAdapter, listAdapterNames, listPublicAdapterNames } from '../lib/adapters/index.js';
41
41
  import {
42
42
  getSession,
43
43
  getSessionEntry,
@@ -388,7 +388,7 @@ export const bootstrapAgentRecordFromEnv = async ({
388
388
  name,
389
389
  env = process.env,
390
390
  clientFactory = createClient,
391
- adapterRegistry = { getAdapter, listAdapterNames },
391
+ adapterRegistry = { getAdapter, listAdapterNames, listPublicAdapterNames },
392
392
  adapterOverride = null,
393
393
  log = () => {},
394
394
  startDir = process.cwd(),
@@ -424,7 +424,7 @@ export const bootstrapAgentRecordFromEnv = async ({
424
424
  if (adapterOverride) {
425
425
  const adapter = adapterRegistry.getAdapter(adapterOverride);
426
426
  if (!adapter) {
427
- throw new Error(`Unknown adapter '${adapterOverride}'. Known: ${adapterRegistry.listAdapterNames().join(', ')}`);
427
+ throw new Error(`Unknown adapter '${adapterOverride}'. Known: ${(adapterRegistry.listPublicAdapterNames || adapterRegistry.listAdapterNames)().join(', ')}`);
428
428
  }
429
429
  if (!await adapter.detect()) {
430
430
  throw new Error(`Adapter '${adapterOverride}' not found on PATH.`);
@@ -977,7 +977,7 @@ export const updateAgentConfiguration = async ({
977
977
  envPath = null,
978
978
  runtimeKey = false,
979
979
  parseEnv = parseEnvironmentFile,
980
- adapterRegistry = { getAdapter, listAdapterNames },
980
+ adapterRegistry = { getAdapter, listAdapterNames, listPublicAdapterNames },
981
981
  }) => {
982
982
  if (!record?.agentName) {
983
983
  throw new Error('token record is missing agentName — re-attach the agent');
@@ -1007,7 +1007,7 @@ export const updateAgentConfiguration = async ({
1007
1007
  const selectedAdapter = adapterRegistry.getAdapter(normalizedAdapter);
1008
1008
  if (!selectedAdapter || !knownAdapters.includes(normalizedAdapter)) {
1009
1009
  throw new Error(
1010
- `Unknown adapter '${normalizedAdapter}'. Known: ${knownAdapters.join(', ')}`,
1010
+ `Unknown adapter '${normalizedAdapter}'. Known: ${(adapterRegistry.listPublicAdapterNames || adapterRegistry.listAdapterNames)().join(', ')}`,
1011
1011
  );
1012
1012
  }
1013
1013
  if (!await selectedAdapter.detect()) {
@@ -1176,7 +1176,7 @@ export const performAttach = async ({
1176
1176
  memoryFrom = null,
1177
1177
  memoryInstance = 'default',
1178
1178
  log = () => {},
1179
- adapterRegistry = { getAdapter, listAdapterNames },
1179
+ adapterRegistry = { getAdapter, listAdapterNames, listPublicAdapterNames },
1180
1180
  seatbelt: probeSeatbelt = detectSeatbelt,
1181
1181
  bwrap: probeBwrap = detectBwrap,
1182
1182
  platform = process.platform,
@@ -1184,7 +1184,7 @@ export const performAttach = async ({
1184
1184
  const adapter = adapterRegistry.getAdapter(adapterName);
1185
1185
  if (!adapter) {
1186
1186
  throw new Error(
1187
- `Unknown adapter "${adapterName}". Known: ${adapterRegistry.listAdapterNames().join(', ')}`,
1187
+ `Unknown adapter "${adapterName}". Known: ${(adapterRegistry.listPublicAdapterNames || adapterRegistry.listAdapterNames)().join(', ')}`,
1188
1188
  );
1189
1189
  }
1190
1190
 
@@ -4090,7 +4090,7 @@ Docs:
4090
4090
  // ── attach (ADR-005, ADR-008) ─────────────────────────────────────────────
4091
4091
  agent
4092
4092
  .command('attach <adapter>')
4093
- .description('Wrap a local CLI as a Commonly agent (stub|claude|codex|opencode|qwen|dsh|…)')
4093
+ .description(`Wrap a local CLI as a Commonly agent (${listPublicAdapterNames().join('|')})`)
4094
4094
  .requiredOption('--pod <podId>', 'Pod ID to install into')
4095
4095
  .requiredOption('--name <name>', 'Agent name (e.g. my-claude)')
4096
4096
  .option('--memory-from <agent>', 'Copy long-term memory from a hosted agent you own')
@@ -4276,7 +4276,7 @@ Docs:
4276
4276
  .command('run <name>')
4277
4277
  .description('Run the local-CLI wrapper loop for an attached agent')
4278
4278
  .option('--interval <ms>', 'Poll interval in ms', '5000')
4279
- .option('--adapter <name>', 'CLI to wrap on first-run bootstrap (claude|codex|pi|opencode|qwen); an existing token file bound to a different adapter stops the run')
4279
+ .option('--adapter <name>', `CLI to wrap on first-run bootstrap (${listPublicAdapterNames().join('|')}); an existing token file bound to a different adapter stops the run`)
4280
4280
  .option('--cascade-cap <n>', `Consecutive agent-triggered turns allowed per pod (env ${CASCADE_ENV_VARS.cap}, default ${CASCADE_DEFAULTS.cap})`)
4281
4281
  .option('--cascade-grace <n>', `Extra turns allowed when this seat was directly addressed; 0 disables the grace (env ${CASCADE_ENV_VARS.addressedGrace}, default ${CASCADE_DEFAULTS.addressedGrace})`)
4282
4282
  .option('--cascade-reset <ms>', `Silence window that clears the streak (env ${CASCADE_ENV_VARS.resetMs}, default ${CASCADE_DEFAULTS.resetMs})`)
@@ -4375,7 +4375,7 @@ Docs:
4375
4375
 
4376
4376
  const adapter = getAdapter(record.adapter);
4377
4377
  if (!adapter) {
4378
- console.error(`Unknown adapter '${record.adapter}' in token file. Known: ${listAdapterNames().join(', ')}`);
4378
+ console.error(`Unknown adapter '${record.adapter}' in token file. Known: ${listPublicAdapterNames().join(', ')}`);
4379
4379
  process.exit(1);
4380
4380
  }
4381
4381
 
@@ -31,6 +31,10 @@ const ADAPTERS = {
31
31
 
32
32
  export const listAdapterNames = () => Object.keys(ADAPTERS);
33
33
 
34
+ // The adapters a person can choose: every one but the internal test stub. Help
35
+ // text and "Known:" lists read this, so they never drift from the registry.
36
+ export const listPublicAdapterNames = () => listAdapterNames().filter((name) => name !== stub.name);
37
+
34
38
  export const getAdapter = (name) => ADAPTERS[name] || null;
35
39
 
36
40
  /**
@@ -43,12 +43,13 @@
43
43
 
44
44
  import { requireSeatModel } from './seat-model.js';
45
45
  import { probeVersion } from './tested-version.js';
46
+ import { resolveOnPath } from '../resolve-on-path.js';
46
47
  import { spawn as childSpawn, spawnSync } from 'child_process';
47
48
  import { createHash, randomUUID } from 'crypto';
48
- import { accessSync, constants as fsConstants, existsSync, readFileSync, realpathSync } from 'fs';
49
+ import { existsSync, readFileSync, realpathSync } from 'fs';
49
50
  import { mkdir, readdir, writeFile } from 'fs/promises';
50
51
  import { homedir } from 'os';
51
- import { delimiter, dirname, isAbsolute, join } from 'path';
52
+ import { dirname, isAbsolute, join } from 'path';
52
53
  import { fileURLToPath } from 'url';
53
54
  import {
54
55
  readUpstreamRefusal,
@@ -396,18 +397,8 @@ export const assertSandboxSupported = (environment = {}, platform = process.plat
396
397
  }
397
398
  };
398
399
 
399
- /** The first executable `name` on PATH, absolute, or null. No shell involved. */
400
- export const resolveOnPath = (name, pathValue) => {
401
- for (const dir of String(pathValue || '').split(delimiter)) {
402
- if (!dir || !isAbsolute(dir)) continue;
403
- const candidate = join(dir, name);
404
- try {
405
- accessSync(candidate, fsConstants.X_OK);
406
- return candidate;
407
- } catch { /* next */ }
408
- }
409
- return null;
410
- };
400
+ // Shared with the version probe (tested-version.js).
401
+ export { resolveOnPath };
411
402
 
412
403
  /**
413
404
  * pi's install tree: the nearest directory above the real entry file whose
@@ -2,6 +2,8 @@
2
2
  // only spawn/spawnSync still load this module.
3
3
  import * as childProcess from 'node:child_process';
4
4
  import { realpathSync, statSync } from 'node:fs';
5
+ import { basename } from 'node:path';
6
+ import { resolveOnPath } from '../resolve-on-path.js';
5
7
 
6
8
  // Public seats run only on a harness version smoke-tested in its sandbox, with
7
9
  // one tolerance: a stable patch release after the newest tested one, on that
@@ -28,27 +30,40 @@ export const isPatchAfterNewestTested = (version, tested) => {
28
30
  // The cache key is the binary's real path; its mtime decides freshness, so a
29
31
  // harness upgraded in place is probed again. Only a parsed version is kept: a
30
32
  // failed or unparseable probe is asked again next turn, never remembered.
33
+ //
34
+ // A bare name ('goose', 'qwen') is resolved through the probe env's PATH, as
35
+ // execFile would resolve it, never against the daemon's working directory: a
36
+ // cwd lookup missed the cache every turn and could key it on a same-named file
37
+ // there. What runs is that resolved real path, so the binary that answers is
38
+ // the one the key names. A name that does not resolve runs as given, uncached.
31
39
  const versionCache = new Map();
32
40
 
33
- export const probeVersion = async (binary, {
34
- env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
35
- } = {}) => {
36
- let key = null;
37
- let mtimeMs = null;
41
+ const resolveBinary = (binary, env) => {
42
+ const name = String(binary || '');
43
+ if (!name) return null;
44
+ const located = basename(name) === name ? resolveOnPath(name, env?.PATH) : name;
45
+ if (!located) return null;
38
46
  try {
39
- key = realpathSync(binary);
40
- mtimeMs = statSync(key).mtimeMs;
47
+ const key = realpathSync(located);
48
+ return { key, mtimeMs: statSync(key).mtimeMs };
41
49
  } catch {
42
- key = null;
50
+ return null;
43
51
  }
52
+ };
53
+
54
+ export const probeVersion = async (binary, {
55
+ env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
56
+ } = {}) => {
57
+ const resolved = resolveBinary(binary, env);
58
+ const key = resolved?.key || null;
44
59
  const hit = key ? cache.get(key) : null;
45
- if (hit && hit.mtimeMs === mtimeMs) return hit.version;
60
+ if (hit && hit.mtimeMs === resolved.mtimeMs) return hit.version;
46
61
  const stdout = await new Promise((resolve) => {
47
- execFileImpl(binary, ['--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
62
+ execFileImpl(key || binary, ['--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
48
63
  resolve(error ? null : out);
49
64
  });
50
65
  });
51
66
  const version = stdout === null ? null : parse(stdout);
52
- if (version && key) cache.set(key, { mtimeMs, version });
67
+ if (version && key) cache.set(key, { mtimeMs: resolved.mtimeMs, version });
53
68
  return version;
54
69
  };
@@ -0,0 +1,19 @@
1
+ import { accessSync, constants as fsConstants } from 'node:fs';
2
+ import { delimiter, isAbsolute, join } from 'node:path';
3
+
4
+ /**
5
+ * The first executable `name` on `pathValue`, absolute, or null. No shell
6
+ * involved, and only absolute PATH entries count: a relative entry would
7
+ * resolve against whatever the daemon's working directory happens to be.
8
+ */
9
+ export const resolveOnPath = (name, pathValue) => {
10
+ for (const dir of String(pathValue || '').split(delimiter)) {
11
+ if (!dir || !isAbsolute(dir)) continue;
12
+ const candidate = join(dir, name);
13
+ try {
14
+ accessSync(candidate, fsConstants.X_OK);
15
+ return candidate;
16
+ } catch { /* next */ }
17
+ }
18
+ return null;
19
+ };