@commonlyai/cli 0.1.107 → 0.1.108

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.107",
3
+ "version": "0.1.108",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -155,16 +155,19 @@ export const BOOTSTRAP_ADAPTER_DETECT_ORDER = ['claude', 'codex', 'pi'];
155
155
  export const NO_AGENT_CLI_CODE = 'no_agent_cli';
156
156
 
157
157
  /**
158
- * A saved Connect-page seat from before bootstrap applied the default sandbox:
159
- * an adapter that takes one, no workspace, and an environment with nothing
160
- * enforced. Such a record is told how to pick the default up; it is not
161
- * rewritten here (Cofounder, 2026-10-16: none were found outside our own tests).
158
+ * A saved seat with no enforced sandbox: an adapter that takes one, no
159
+ * workspace, and an environment that is absent or enforces nothing (a record
160
+ * from before bootstrap applied the default, or one attached without an
161
+ * environment file). Such a record is told how to pick the default up; it is
162
+ * not rewritten here (Cofounder, 2026-10-16: none were found outside our own
163
+ * tests).
162
164
  */
163
165
  export const savedSeatLacksDefaultSandbox = (record) => Boolean(record)
164
166
  && ADAPTERS_WITH_DEFAULT_SANDBOX.has(record.adapter)
165
167
  && !record.workspacePath
166
- && record.environment !== null && typeof record.environment === 'object'
167
- && withDefaultSandbox(record.environment) !== record.environment;
168
+ && (record.environment === null || record.environment === undefined
169
+ || (typeof record.environment === 'object' && !Array.isArray(record.environment)
170
+ && withDefaultSandbox(record.environment) !== record.environment));
168
171
 
169
172
  /** Return the adapter binding resolved for this exact installation by the server. */
170
173
  export const runtimeAdapterForInstallation = ({ installations, podId, instanceId } = {}) => {
@@ -3117,8 +3120,9 @@ Docs:
3117
3120
  console.log(`${stamp()} [${name}] bootstrapped ${tokenFile(record.agentName)} from COMMONLY_AGENT_TOKEN (adapter: ${record.adapter})`);
3118
3121
  } else if (savedSeatLacksDefaultSandbox(record)) {
3119
3122
  console.warn(
3120
- `${stamp()} [${name}] this agent's saved settings predate the default sandbox. To pick it up, reconnect: `
3121
- + `commonly agent detach ${name} --force, then run a fresh command from the Connect page.`,
3123
+ `${stamp()} [${name}] this agent's saved settings declare no sandbox, so it runs without one. `
3124
+ + `To give it the default: commonly agent detach ${name} --force, then either run a fresh command `
3125
+ + 'from the Connect page, or attach it again with an environment file that sets sandbox.trust: public.',
3122
3126
  );
3123
3127
  }
3124
3128
 
@@ -47,12 +47,18 @@ const DEFAULT_RO_BINDS = [
47
47
  '/lib64',
48
48
  ];
49
49
 
50
- export const detectBwrap = () => {
51
- if (process.platform !== 'linux') {
50
+ // `bwrap --version` only proves the binary is there. On Ubuntu 24.04 and later
51
+ // AppArmor restricts unprivileged user namespaces, so bwrap is installed and
52
+ // every sandbox it starts fails (`setting up uid map: Permission denied`,
53
+ // ubuntu run 38982219348). Starting one empty namespace is the real check.
54
+ const NAMESPACE_PROBE = ['--unshare-all', '--ro-bind', '/', '/', 'true'];
55
+
56
+ export const detectBwrap = ({ spawn = spawnSync, platform = process.platform } = {}) => {
57
+ if (platform !== 'linux') {
52
58
  return { available: false, error: MACOS_MESSAGE };
53
59
  }
54
60
  try {
55
- const res = spawnSync('bwrap', ['--version'], { encoding: 'utf8' });
61
+ const res = spawn('bwrap', ['--version'], { encoding: 'utf8' });
56
62
  if (res.error || res.status !== 0) {
57
63
  return {
58
64
  available: false,
@@ -60,6 +66,15 @@ export const detectBwrap = () => {
60
66
  + '`sudo dnf install bubblewrap` (Fedora) or `sudo pacman -S bubblewrap` (Arch).',
61
67
  };
62
68
  }
69
+ const probe = spawn('bwrap', NAMESPACE_PROBE, { encoding: 'utf8', timeout: 10_000 });
70
+ if (probe.error || probe.status !== 0) {
71
+ const reason = (probe.stderr || probe.error?.message || `exit ${probe.status}`).trim().split('\n').pop();
72
+ return {
73
+ available: false,
74
+ error: `bubblewrap is installed but cannot start a sandbox on this machine (${reason}). `
75
+ + 'On Ubuntu 24.04 and later, AppArmor restricts the unprivileged user namespaces it needs.',
76
+ };
77
+ }
63
78
  return { available: true, path: 'bwrap' };
64
79
  } catch (err) {
65
80
  return { available: false, error: `bwrap detection failed: ${err.message}` };
@@ -9,16 +9,21 @@
9
9
  * the pod saw nothing.
10
10
  *
11
11
  * Only the adapters that run inside these mechanisms are checked. Codex
12
- * confines with its own permission profiles (mode.js), and pi refuses a
13
- * declared sandbox itself (default-environment.js).
12
+ * confines with its own permission profiles (mode.js). pi is a scope boundary,
13
+ * not a gap in this check: it refuses a declared sandbox itself, so a
14
+ * Connect-page pi seat is saved without one and runs unconfined
15
+ * (default-environment.js, ADAPTERS_WITH_DEFAULT_SANDBOX); confining pi
16
+ * belongs to pi's own sandbox work.
14
17
  */
15
18
 
16
19
  import { normalizeSandboxTrust } from '../environment.js';
17
- import { resolvePublicSandboxMode } from './mode.js';
20
+ import { PUBLIC_SANDBOX_MODES, resolvePublicSandboxMode } from './mode.js';
18
21
  import { detectBwrap as defaultDetectBwrap } from './bwrap.js';
19
22
  import { detectSeatbelt as defaultDetectSeatbelt } from './seatbelt.js';
20
23
 
21
- const SEATBELT_MODES = new Set(['workspace', 'read-only']);
24
+ // The Seatbelt modes come from mode.js, as grant-broker-guard's do, so a mode
25
+ // added there is not silently missing here.
26
+ const SEATBELT_MODES = PUBLIC_SANDBOX_MODES;
22
27
 
23
28
  const ADAPTER_LABELS = { claude: 'Claude Code', opencode: 'OpenCode', qwen: 'Qwen Code' };
24
29