@commonlyai/cli 0.1.245 → 0.1.247

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.245",
3
+ "version": "0.1.247",
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
 
@@ -1,5 +1,6 @@
1
1
  /** Goose 1.54.0 wrapper. Public seats expose only the Commonly MCP extension. */
2
2
  import { requireSeatModel } from './seat-model.js';
3
+ import { probeVersion } from './tested-version.js';
3
4
  import { spawn as childSpawn, spawnSync } from 'node:child_process';
4
5
  import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
5
6
  import { tmpdir } from 'node:os';
@@ -278,9 +279,12 @@ export default {
278
279
  : 'goose');
279
280
  if (isPublic && !isAbsolute(binary)) throw new Error('goose adapter: public seats require an absolute Goose executable');
280
281
  // A cold first launch can take several seconds while macOS scans the binary.
281
- const version = ctx._version || versionOf(spawnSync(binary, ['--version'], {
282
- encoding: 'utf8', timeout: 30000, env: safeEnv(sourceEnv),
283
- }).stdout);
282
+ // Async and cached per binary (tested-version.js probeVersion): a
283
+ // synchronous probe stalled every other seat's provider proxy on the
284
+ // daemon's loop for as long as this cold start took.
285
+ const version = ctx._version || await probeVersion(binary, {
286
+ env: safeEnv(sourceEnv), timeoutMs: 30000, parse: versionOf,
287
+ });
284
288
  if (!TESTED_GOOSE_VERSIONS.includes(version)) {
285
289
  if (isPublic) throw new Error(`goose adapter: public seats refuse untested version ${version || 'unknown'}`);
286
290
  // eslint-disable-next-line no-console
@@ -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
  /**
@@ -42,6 +42,7 @@
42
42
  */
43
43
 
44
44
  import { requireSeatModel } from './seat-model.js';
45
+ import { probeVersion } from './tested-version.js';
45
46
  import { spawn as childSpawn, spawnSync } from 'child_process';
46
47
  import { createHash, randomUUID } from 'crypto';
47
48
  import { accessSync, constants as fsConstants, existsSync, readFileSync, realpathSync } from 'fs';
@@ -572,9 +573,11 @@ export default {
572
573
  if (!packageRoot) {
573
574
  throw new Error(`pi adapter: no ${PI_PACKAGE} package found behind ${binary}, so the sandbox cannot admit pi's code`);
574
575
  }
575
- const version = ctx._version || versionOf(spawnSync(binary, ['--version'], {
576
- encoding: 'utf8', timeout: 30000, env: safeEnv(baseEnv),
577
- })?.stdout);
576
+ // Async and cached per binary (tested-version.js): a synchronous probe
577
+ // stalled every other seat's proxy on the daemon's loop.
578
+ const version = ctx._version || await probeVersion(binary, {
579
+ env: safeEnv(baseEnv), timeoutMs: 30000, parse: versionOf,
580
+ });
578
581
  if (!TESTED_PI_VERSIONS.includes(version)) {
579
582
  throw new Error(`pi adapter: public seats refuse untested pi version ${version || 'unknown'}; smoke-tested: ${TESTED_PI_VERSIONS.join(', ')}`);
580
583
  }
@@ -1,6 +1,7 @@
1
1
  /** Qwen Code 0.25.1 and 0.26.2 wrapper. Public turns have fresh HOME, config and keys. */
2
2
  import { requireSeatModel } from './seat-model.js';
3
- import { isPatchAfterNewestTested } from './tested-version.js';
3
+ import { isPatchAfterNewestTested, probeVersion } from './tested-version.js';
4
+ import * as childProcess from 'child_process';
4
5
  import { spawn as childSpawn, spawnSync } from 'child_process';
5
6
  import { lstatSync, realpathSync } from 'fs';
6
7
  import { chmod, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
@@ -50,10 +51,13 @@ const parseVersion = (output) => {
50
51
  return match ? match[1] : null;
51
52
  };
52
53
 
53
- const readVersion = (binary, env) => {
54
- const result = spawnSync(binary, ['--version'], { encoding: 'utf8', env, timeout: 5000 });
55
- return result.status === 0 && !result.error ? parseVersion(result.stdout) : null;
56
- };
54
+ // Async and cached per binary (tested-version.js probeVersion): a synchronous
55
+ // probe stalled every other seat's provider proxy on the daemon's loop. The
56
+ // namespace import is read at call time, so a suite that mocks child_process
57
+ // without execFile falls back to the real one.
58
+ const readVersion = (binary, env) => probeVersion(binary, {
59
+ env, timeoutMs: 5000, parse: parseVersion, execFileImpl: childProcess.execFile,
60
+ });
57
61
 
58
62
  const resolvedBinary = (env) => {
59
63
  const where = spawnSync('which', ['qwen'], { encoding: 'utf8', env });
@@ -75,7 +79,8 @@ const withProbeEnv = async (source, run) => {
75
79
  env.QWEN_CODE_SYSTEM_SETTINGS_PATH = settingsPath;
76
80
  env.QWEN_USAGE_STATISTICS_ENABLED = 'false';
77
81
  for (const name of PROXY_ENV) env[name] = '';
78
- return run(env);
82
+ // Awaited here, so the probe home outlives an async probe.
83
+ return await run(env);
79
84
  } finally {
80
85
  await rm(home, { recursive: true, force: true });
81
86
  }
@@ -254,9 +259,9 @@ export default {
254
259
  }
255
260
  const keyFile = await this.validateEnvironment(ctx.environment, ctx.cwd);
256
261
  const sourceEnv = ctx.env || process.env;
257
- const { binary, version } = await withProbeEnv(sourceEnv, (probeEnv) => {
262
+ const { binary, version } = await withProbeEnv(sourceEnv, async (probeEnv) => {
258
263
  const path = ctx._binaryPath || resolvedBinary(probeEnv);
259
- return { binary: path, version: readVersion(path, probeEnv) };
264
+ return { binary: path, version: await readVersion(path, probeEnv) };
260
265
  });
261
266
  if (!TESTED_QWEN_VERSIONS.includes(version)) {
262
267
  const versions = TESTED_QWEN_VERSIONS.join(', ');
@@ -1,3 +1,8 @@
1
+ // A namespace import, read at call time: suites that mock child_process with
2
+ // only spawn/spawnSync still load this module.
3
+ import * as childProcess from 'node:child_process';
4
+ import { realpathSync, statSync } from 'node:fs';
5
+
1
6
  // Public seats run only on a harness version smoke-tested in its sandbox, with
2
7
  // one tolerance: a stable patch release after the newest tested one, on that
3
8
  // same major.minor line. Harnesses ship patches every few days, and refusing
@@ -14,3 +19,36 @@ export const isPatchAfterNewestTested = (version, tested) => {
14
19
  && Number(installed[2]) === Number(newest[2])
15
20
  && Number(installed[3]) > Number(newest[3]);
16
21
  };
22
+
23
+ // The harness's own `--version`, asked without blocking the event loop and
24
+ // remembered per binary. A daemon runs every seat in one process, beside the
25
+ // loopback provider proxies of other seats' live turns, so a synchronous probe
26
+ // stalled all of them while a cold harness started (up to its timeout).
27
+ //
28
+ // The cache key is the binary's real path; its mtime decides freshness, so a
29
+ // harness upgraded in place is probed again. Only a parsed version is kept: a
30
+ // failed or unparseable probe is asked again next turn, never remembered.
31
+ const versionCache = new Map();
32
+
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;
38
+ try {
39
+ key = realpathSync(binary);
40
+ mtimeMs = statSync(key).mtimeMs;
41
+ } catch {
42
+ key = null;
43
+ }
44
+ const hit = key ? cache.get(key) : null;
45
+ if (hit && hit.mtimeMs === mtimeMs) return hit.version;
46
+ const stdout = await new Promise((resolve) => {
47
+ execFileImpl(binary, ['--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
48
+ resolve(error ? null : out);
49
+ });
50
+ });
51
+ const version = stdout === null ? null : parse(stdout);
52
+ if (version && key) cache.set(key, { mtimeMs, version });
53
+ return version;
54
+ };