@commonlyai/cli 0.1.378 → 0.1.380

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.
@@ -228,6 +228,14 @@ export const createHermesAdapter = ({
228
228
  throw new Error('Commonly can\'t give Hermes extra MCP servers yet, so this environment file can\'t '
229
229
  + 'list any. Remove the mcp block to run Hermes.');
230
230
  }
231
+ // Workspace trust is claude's tier. Any other adapter that ran it would
232
+ // run bare while the unconfined-seat guard reads it as confined.
233
+ if (environment?.sandbox?.trust === 'workspace') {
234
+ throw new Error('hermes adapter: sandbox.trust=workspace is claude-only for now. '
235
+ + "Attach this agent with the claude adapter, or remove sandbox.trust 'workspace' from its environment file, "
236
+ + "along with sandbox.allow (it applies only to trust 'workspace') and any sandbox.mode other than 'none'. "
237
+ + 'Hermes has no sandbox yet, so it runs with no sandbox settings at all.');
238
+ }
231
239
  if (effectiveTrust(environment?.sandbox?.trust) === 'public') {
232
240
  throw new Error('Commonly has no sandbox for Hermes yet, so Hermes can\'t run as a public seat. '
233
241
  + 'Pick another harness for a public seat.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.378",
3
+ "version": "0.1.380",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -39,6 +39,9 @@ import { startPoller, terminalDeliveryAckError } from '../lib/poller.js';
39
39
  import { formatDigestFrame, formatUnreadMessagesFrame } from '../lib/digest-frame.js';
40
40
  import { startWebhookServer, forwardToLocalWebhook, logOnlyHandler } from '../lib/webhook-server.js';
41
41
  import { getAdapter, listAdapterNames, listPublicAdapterNames } from '../lib/adapters/index.js';
42
+ import {
43
+ harnessFindings, nodeFinding, preflightOutcome, reportListenBlocked,
44
+ } from '../lib/run-preflight.js';
42
45
  import {
43
46
  getSession,
44
47
  getSessionEntry,
@@ -99,6 +102,7 @@ import {
99
102
  import { mergeGrantBrokers, withholdGrantBroker } from '../lib/grant-broker-guard.js';
100
103
  import { withPublicSeatMcpFlag } from '../lib/public-seat-mcp-flag.js';
101
104
  import { UNCONFINED_TURN_REFUSAL, seatRunsUnconfined, unconfinedPodRefusalReason } from '../lib/unconfined-seat-guard.js';
105
+ import { sandboxOptionRefusal } from '../lib/sandbox-option-refusal.js';
102
106
  import {
103
107
  OUTSIDER_GRANT_MCP_UNCONFINED, outsiderGrantMcpRefusal, seatIsConfined, unshippedMcpEntries,
104
108
  } from '../lib/outsider-grant-mcp.js';
@@ -1369,8 +1373,9 @@ export const updateAgentConfiguration = async ({
1369
1373
  environment = { ...environmentRuntime };
1370
1374
  }
1371
1375
  {
1372
- const refusal = providerRefusal(environment,
1373
- adapterRegistry.getAdapter(String(runtime.adapter || record.adapter || '').trim().toLowerCase()));
1376
+ const configAdapter = String(runtime.adapter || record.adapter || '').trim().toLowerCase();
1377
+ const refusal = providerRefusal(environment, adapterRegistry.getAdapter(configAdapter))
1378
+ || sandboxOptionRefusal(environment, configAdapter);
1374
1379
  if (refusal) throw new Error(refusal);
1375
1380
  }
1376
1381
  if (environment) config.environment = environmentForServer(environment);
@@ -1541,7 +1546,7 @@ export const performAttach = async ({
1541
1546
  // kernel server. The daemon applies this same baseline before every spawn.
1542
1547
  environment = withDefaultMcpServer(await parseEnvironmentFile(envPath), adapterName);
1543
1548
  {
1544
- const refusal = providerRefusal(environment, adapter);
1549
+ const refusal = providerRefusal(environment, adapter) || sandboxOptionRefusal(environment, adapterName, platform);
1545
1550
  if (refusal) throw new Error(refusal);
1546
1551
  }
1547
1552
  workspace = await resolveWorkspace(environment, agentName, dirname(envPath));
@@ -2212,7 +2217,7 @@ export const performRun = ({
2212
2217
  const supervising = superviseRuns ?? superviseRunsByDefault(adapter?.name);
2213
2218
  reportRuntime = reportRuntime && WALKED_HARNESSES.includes(adapter?.name);
2214
2219
  {
2215
- const refusal = providerRefusal(environment, adapter);
2220
+ const refusal = providerRefusal(environment, adapter) || sandboxOptionRefusal(environment, adapter?.name);
2216
2221
  if (refusal) throw new Error(refusal);
2217
2222
  }
2218
2223
  const requestedTurnTimeout = Number(turnTimeoutMs ?? process.env.COMMONLY_AGENT_RUN_TIMEOUT_MS);
@@ -5891,6 +5896,23 @@ Docs:
5891
5896
  name = agentArg;
5892
5897
  }
5893
5898
  }
5899
+ // F515: Node first, before anything uses the token: on a Node without
5900
+ // fetch, the first call fails and reads as a bad token. A first run stops
5901
+ // here and says so, telling the instance when it can; a seat with a saved
5902
+ // record only warns.
5903
+ const oldNode = nodeFinding();
5904
+ const nodeOutcome = preflightOutcome(oldNode ? [oldNode] : [], { firstRun: !record });
5905
+ for (const line of nodeOutcome.lines) console.error(`${stamp()} [${name}] ${line}`);
5906
+ if (nodeOutcome.stop) {
5907
+ const envToken = (process.env.COMMONLY_AGENT_TOKEN || '').trim();
5908
+ if (envToken.startsWith('cm_agent_') && typeof fetch === 'function') {
5909
+ await reportListenBlocked(createClient({
5910
+ instance: (process.env.COMMONLY_API_URL || '').trim() || resolveInstanceUrl(undefined),
5911
+ token: envToken,
5912
+ }), nodeOutcome.report);
5913
+ }
5914
+ process.exit(1);
5915
+ }
5894
5916
  let bootstrapped = false;
5895
5917
  const saved = record;
5896
5918
  const savedRefusal = record && named ? runInstanceRefusal({ record, instanceId }) : null;
@@ -5924,11 +5946,14 @@ Docs:
5924
5946
  process.exit(1);
5925
5947
  }
5926
5948
  if (!record) {
5927
- console.error(
5928
- `No token for '${name}'. Either export COMMONLY_API_URL + COMMONLY_AGENT_TOKEN`
5929
- + ` (shown on the Connect your own agent page) and re-run, or:`
5930
- + ` ${CLI} agent attach <adapter> --pod <podId> --name ${agentArg}`,
5931
- );
5949
+ // F515: on Windows the page's lines are PowerShell's ($env:…), and in
5950
+ // Command Prompt they set nothing, so this is where that run lands.
5951
+ console.error(process.platform === 'win32'
5952
+ ? `No token for '${name}'. Run all the lines from the Connect your own agent page together, `
5953
+ + 'in PowerShell (not Command Prompt): the $env: lines set the token for this window.'
5954
+ : `No token for '${name}'. Either export COMMONLY_API_URL + COMMONLY_AGENT_TOKEN`
5955
+ + ` (shown on the Connect your own agent page) and re-run, or:`
5956
+ + ` ${CLI} agent attach <adapter> --pod <podId> --name ${agentArg}`);
5932
5957
  process.exit(1);
5933
5958
  }
5934
5959
  const instanceRefusal = named ? runInstanceRefusal({ record, instanceId }) : null;
@@ -5939,6 +5964,27 @@ Docs:
5939
5964
  bootstrapped = true;
5940
5965
  }
5941
5966
 
5967
+ // F515: the harness this record names, installed and signed in, before
5968
+ // the run starts waiting. A first run has already looked for the harness
5969
+ // (and reported a missing one); it stops on a signed-out one too, and the
5970
+ // instance hears why, so the page and the pod can say it. A seat with a
5971
+ // saved record only warns: a probe that reads it wrong must not stop it.
5972
+ const harnessProblems = await harnessFindings({
5973
+ adapterName: record.adapter,
5974
+ adapter: getAdapter(record.adapter),
5975
+ environment: record.environment,
5976
+ checkInstalled: !bootstrapped,
5977
+ });
5978
+ const harnessOutcome = preflightOutcome(harnessProblems, { firstRun: bootstrapped });
5979
+ for (const line of harnessOutcome.lines) console.error(`${stamp()} [${name}] ${line}`);
5980
+ if (harnessOutcome.stop) {
5981
+ await reportListenBlocked(
5982
+ createClient({ instance: record.instanceUrl, token: record.runtimeToken }),
5983
+ harnessOutcome.report,
5984
+ );
5985
+ process.exit(1);
5986
+ }
5987
+
5942
5988
  // On native Windows the user may choose to run without an OS
5943
5989
  // sandbox, by typing the flag or by installing the daemon with it (the
5944
5990
  // marker is read only by the seats that daemon spawns). Nothing from the
@@ -1370,7 +1370,7 @@ const createMcpConfig = async (mcpServers, ctx = {}) => {
1370
1370
  // child environment and to every detection lookup so a daemon does not report
1371
1371
  // a false "adapter unavailable" (or hit spawn ENOENT) merely because it was
1372
1372
  // started outside an interactive shell.
1373
- const withClaudePath = (input) => {
1373
+ export const withClaudePath = (input) => {
1374
1374
  const output = { ...(input || process.env) };
1375
1375
  const localBin = join(homedir(), '.local', 'bin');
1376
1376
  // Windows keys are case-insensitive, and a child given both `Path` and a
@@ -1471,6 +1471,10 @@ export default {
1471
1471
  if (isPublic && !['workspace', 'read-only', 'bwrap'].includes(sandboxMode)) {
1472
1472
  throw new Error(`public OpenCode agents require an enforced sandbox mode, got ${sandboxMode || 'unset'}`);
1473
1473
  }
1474
+ // F535: a public seat reads only its workspace (sandbox-option-refusal.js).
1475
+ if (isPublic && sandbox.filesystem?.['read-outside']?.length) {
1476
+ throw new Error('opencode adapter: public seats do not allow sandbox.filesystem.read-outside');
1477
+ }
1474
1478
 
1475
1479
  const provider = ctx.environment?.provider;
1476
1480
  // Attach and config refuse these first; a turn refuses them too, for a
@@ -332,6 +332,10 @@ export default {
332
332
  if (isPublic && !['workspace', 'read-only', 'bwrap'].includes(mode)) {
333
333
  throw new Error('public Qwen seats require an enforced sandbox');
334
334
  }
335
+ // F535: a public seat reads only its workspace (sandbox-option-refusal.js).
336
+ if (isPublic && sandbox.filesystem?.['read-outside']?.length) {
337
+ throw new Error('qwen adapter: public seats do not allow sandbox.filesystem.read-outside');
338
+ }
335
339
  const provider = ctx.environment?.provider;
336
340
  if (!provider || !ctx.environment?.model) {
337
341
  throw new Error('Qwen seats require environment.provider and environment.model');
@@ -0,0 +1,149 @@
1
+ // F515: what `agent run` checks before it starts waiting. Both newcomers in the
2
+ // week of 11-09 created an agent and never got it listening: the page waited,
3
+ // and the terminal said nothing they could act on. So the run checks the three
4
+ // things the connect command needs (Node 22+, the harness installed, the
5
+ // harness signed in), and prints one plain line for each that fails.
6
+ //
7
+ // A first run (the pasted command, no saved record) stops on a failure, and
8
+ // tells the instance why, by reason code only, so the page and the pod can say
9
+ // it. A run with a saved record only warns: that is a seat that has run here
10
+ // before, and a login probe that reads it wrong must not take it down.
11
+
12
+ import { spawn } from 'child_process';
13
+ import { readFileSync } from 'fs';
14
+
15
+ import { checkNode, FAIL } from './doctor.js';
16
+ import { loginState } from './adapter-login.js';
17
+ import { missingHarnessHint } from './missing-harness.js';
18
+ import { withClaudePath } from './adapters/claude.js';
19
+ import { resolveWindowsCommandWithReason } from './windows-command.js';
20
+
21
+ // The reason codes the instance accepts (POST /api/agents/runtime/listen-blocked).
22
+ // A code, never text: nothing from this computer but the code is sent.
23
+ export const LISTEN_BLOCKED_REASONS = ['node-too-old', 'harness-signed-out'];
24
+
25
+ // The floor the CLI declares, read as `commonly doctor` reads it.
26
+ const CLI_ENGINES_NODE = (() => {
27
+ try {
28
+ return JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).engines?.node;
29
+ } catch {
30
+ return undefined;
31
+ }
32
+ })();
33
+
34
+ const LABEL = { claude: 'Claude Code', codex: 'Codex' };
35
+ const SIGN_IN = { claude: 'claude', codex: 'codex login' };
36
+
37
+ /** The Node finding, or null when this Node meets the CLI's floor. */
38
+ export const nodeFinding = ({ nodeVersion = process.versions.node, enginesRange = CLI_ENGINES_NODE } = {}) => {
39
+ const check = checkNode({ nodeVersion, enginesRange });
40
+ if (check.status !== FAIL) return null;
41
+ const floor = /(\d+)/.exec(String(enginesRange || ''))?.[1] || '22';
42
+ return {
43
+ reason: 'node-too-old',
44
+ harness: null,
45
+ line: `This computer has Node ${nodeVersion}, and Commonly needs Node ${floor} or later. `
46
+ + `Install Node ${floor} from nodejs.org, then run this line again.`,
47
+ };
48
+ };
49
+
50
+ /**
51
+ * The exit code of a harness's login status, run as its adapter runs it: the
52
+ * same command `detect()` found (Claude Code with its own ~/.local/bin on
53
+ * PATH, where the native installer puts it), without a shell. Through a shell
54
+ * on Windows a name cmd can't find exits 1, which is the signed-out code, and
55
+ * would stop a run that is signed in. null when the command can't be resolved
56
+ * or the probe can't run or times out (no verdict).
57
+ */
58
+ export const runHarnessLoginStatus = (name, args, {
59
+ env = process.env,
60
+ platform = process.platform,
61
+ resolve = resolveWindowsCommandWithReason,
62
+ spawnFn = spawn,
63
+ timeoutMs = 10_000,
64
+ } = {}) => new Promise((done) => {
65
+ const childEnv = name === 'claude' ? withClaudePath(env) : env;
66
+ const located = resolve(name, { env: childEnv, platform });
67
+ if (!located?.command) {
68
+ done(null);
69
+ return;
70
+ }
71
+ let child;
72
+ try {
73
+ child = spawnFn(located.command, [...(located.args || []), ...args], {
74
+ stdio: 'ignore', windowsHide: true, env: childEnv, shell: false,
75
+ });
76
+ } catch {
77
+ done(null);
78
+ return;
79
+ }
80
+ const timer = setTimeout(() => { child.kill(); done(null); }, timeoutMs);
81
+ child.on('error', () => { clearTimeout(timer); done(null); });
82
+ child.on('exit', (code) => { clearTimeout(timer); done(typeof code === 'number' ? code : null); });
83
+ });
84
+
85
+ /**
86
+ * The harness findings for one adapter: not installed, or installed and not
87
+ * signed in. `checkInstalled` is false where the caller has already looked (a
88
+ * first run's bootstrap does, and reports it on its own route). A seat that
89
+ * runs on its own provider block needs no harness login, and a key in the
90
+ * environment is skipped by loginState itself.
91
+ */
92
+ export const harnessFindings = async ({
93
+ adapterName,
94
+ adapter,
95
+ environment = null,
96
+ checkInstalled = true,
97
+ env = process.env,
98
+ runStatus = (name, args) => runHarnessLoginStatus(name, args, { env }),
99
+ }) => {
100
+ if (!adapter || !adapterName) return [];
101
+ if (checkInstalled) {
102
+ let installed = false;
103
+ try { installed = Boolean(await adapter.detect()); } catch { /* not installed */ }
104
+ if (!installed) {
105
+ return [{
106
+ reason: 'harness-missing',
107
+ harness: adapterName,
108
+ line: `${LABEL[adapterName] || adapterName} isn't installed on this computer. ${missingHarnessHint(adapterName)}`,
109
+ }];
110
+ }
111
+ }
112
+ if (environment?.provider !== undefined || !LABEL[adapterName]) return [];
113
+ const signedIn = await loginState(adapterName, { runStatus, env });
114
+ if (signedIn !== false) return [];
115
+ return [{
116
+ reason: 'harness-signed-out',
117
+ harness: adapterName,
118
+ line: `${LABEL[adapterName]} is installed but not signed in on this computer. `
119
+ + `Run ${SIGN_IN[adapterName]} once to sign in, then run this line again.`,
120
+ }];
121
+ };
122
+
123
+ /**
124
+ * What the run does with its findings. A first run (the pasted command) stops,
125
+ * and the first finding is the one reported. A run from a saved record only
126
+ * warns and goes on: that seat has run here before, and a probe that misreads
127
+ * it must not take it down.
128
+ */
129
+ export const preflightOutcome = (findings, { firstRun }) => {
130
+ if (!findings.length) return { stop: false, lines: [], report: null };
131
+ if (firstRun) return { stop: true, lines: findings.map((f) => f.line), report: findings[0] };
132
+ return { stop: false, lines: findings.map((f) => `warning: ${f.line}`), report: null };
133
+ };
134
+
135
+ /**
136
+ * Tell the instance why this agent isn't listening yet. Best effort, as the
137
+ * harness-missing report: an older instance without the route, or a failed
138
+ * call, must not hide the line the person needs in the terminal (which is
139
+ * printed first). A missing harness has its own route, posted by bootstrap.
140
+ */
141
+ export const reportListenBlocked = async (client, finding) => {
142
+ if (!finding) return;
143
+ try {
144
+ if (!LISTEN_BLOCKED_REASONS.includes(finding.reason)) return;
145
+ await client?.post?.('/api/agents/runtime/listen-blocked', { reason: finding.reason, harness: finding.harness });
146
+ } catch {
147
+ // The terminal line is the answer either way.
148
+ }
149
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Refuse before open (F535): a sandbox option the seat's adapter can't
3
+ * enforce fails the seat at start, never drops silently. One check for config,
4
+ * attach and run (the daemon starts seats through run), beside providerRefusal.
5
+ *
6
+ * Each rule below is a shape that was accepted and then not enforced (the
7
+ * 11-15 audit on main 10364a0c):
8
+ * - network.allow-hosts on an open network: the schema reads it and no
9
+ * adapter does, so every host stays reachable. Beside a restricted network
10
+ * it only asks for less than it gets, and the rules below decide.
11
+ * - network.policy=restricted under macOS Seatbelt on claude, opencode or
12
+ * qwen: the profile keeps the network on for the model and MCP. Under bwrap
13
+ * claude and qwen refuse it already, and opencode restricts it.
14
+ * - sandbox.mode on a seat with no public or workspace trust: claude (any mode
15
+ * but bwrap), opencode and qwen spawn bare. codex runs every such seat in
16
+ * its one private profile (workspace writable, network on), so it keeps
17
+ * mode workspace and refuses read-only. dsh enforces its one shape.
18
+ * - network or filesystem rules on a seat with no trust: nothing reads them
19
+ * when there is no mode, and codex's private profile never does.
20
+ * An open network policy and empty lists ask for nothing, so they pass.
21
+ * The test-only `stub` adapter runs nothing and is not checked.
22
+ */
23
+ import { normalizeSandboxTrust } from './environment.js';
24
+ import { resolvePublicSandboxMode } from './sandbox/mode.js';
25
+ import { adapterConfinesItself } from './unconfined-seat-guard.js';
26
+
27
+ const SEATBELT_MODES = new Set(['workspace', 'read-only']);
28
+ const SEATBELT_NETWORK_KEPT = new Set(['claude', 'opencode', 'qwen']);
29
+ // The modes an adapter honours on a seat with no confined trust (dsh's one
30
+ // shape returns earlier, through adapterConfinesItself).
31
+ const MODES_WITHOUT_TRUST = { codex: new Set(['workspace']) };
32
+ const UNCHECKED = new Set(['stub']);
33
+
34
+ const declares = (value) => value !== undefined && value !== null && value !== ''
35
+ && !(Array.isArray(value) && value.length === 0)
36
+ && !(typeof value === 'object' && !Array.isArray(value) && Object.values(value).every((v) => !declares(v)));
37
+ // A rule asks for something unless it is an open network or an empty list.
38
+ const asksFor = (key, rules) => {
39
+ if (!rules || typeof rules !== 'object') return declares(rules);
40
+ return Object.entries(rules).some(([name, value]) => declares(value)
41
+ && !(key === 'network' && name === 'policy' && value === 'unrestricted'));
42
+ };
43
+
44
+ /** Null when every sandbox option the seat declares is enforced, otherwise why not. */
45
+ export const sandboxOptionRefusal = (environment, adapterName, platform = process.platform) => {
46
+ if (!environment?.sandbox || UNCHECKED.has(adapterName)) return null;
47
+ const sandbox = normalizeSandboxTrust(environment.sandbox);
48
+ const adapter = adapterName || 'this';
49
+ const network = sandbox.network || {};
50
+ if (declares(network['allow-hosts']) && network.policy !== 'restricted') {
51
+ return `sandbox.network.allow-hosts is not enforced by any adapter yet, so the ${adapter} seat would reach every host. `
52
+ + 'Remove it, or use sandbox.network.policy.';
53
+ }
54
+ // A public seat answers strangers, so it reads only its workspace: a path
55
+ // outside it is what an injected agent would use to reach tokens
56
+ // (F535). bwrap opencode and qwen used to bind it in.
57
+ if (sandbox.trust === 'public' && declares(sandbox.filesystem?.['read-outside'])) {
58
+ return `A public seat reads only its workspace, so sandbox.filesystem.read-outside is refused on the ${adapter} adapter. `
59
+ + 'Remove it, or copy what the agent needs into the workspace.';
60
+ }
61
+ if (adapterConfinesItself(adapterName, sandbox)) return null;
62
+ const confined = sandbox.trust === 'public' || sandbox.trust === 'workspace';
63
+ if (confined) {
64
+ const mode = resolvePublicSandboxMode(sandbox, platform);
65
+ if (network.policy === 'restricted' && SEATBELT_MODES.has(mode) && SEATBELT_NETWORK_KEPT.has(adapterName)) {
66
+ return `The ${adapter} adapter can't restrict the network under macOS Seatbelt (sandbox.mode=${mode}): `
67
+ + 'the sandbox keeps it on for the model and MCP. Remove sandbox.network.policy, or run the seat under bwrap on Linux.';
68
+ }
69
+ return null;
70
+ }
71
+ const hasMode = declares(sandbox.mode) && sandbox.mode !== 'none';
72
+ const ownModes = MODES_WITHOUT_TRUST[adapterName];
73
+ if (hasMode && !ownModes?.has(sandbox.mode)) {
74
+ return ownModes
75
+ ? `The ${adapter} adapter runs a seat with no sandbox.trust in one private profile (workspace writable, network on), `
76
+ + `so sandbox.mode=${sandbox.mode} would not apply. Add sandbox.trust=public, or remove sandbox.mode.`
77
+ : `The ${adapter} adapter applies sandbox.mode=${sandbox.mode} only with sandbox.trust=public, so this seat would run `
78
+ + 'without a sandbox. Add sandbox.trust=public, or remove sandbox.mode.';
79
+ }
80
+ const rules = ['network', 'filesystem'].filter((key) => asksFor(key, sandbox[key]));
81
+ if (rules.length) {
82
+ const they = rules.length > 1;
83
+ return hasMode
84
+ ? `sandbox.${rules.join(' and sandbox.')} ${they ? 'are' : 'is'} not applied by the ${adapter} adapter's private profile. `
85
+ + `Add sandbox.trust=public, or remove ${they ? 'them' : 'it'}.`
86
+ : `sandbox.${rules.join(' and sandbox.')} ${they ? 'are' : 'is'} enforced only inside a sandbox, and this `
87
+ + `${adapter} seat has none. Add sandbox.trust=public, or remove ${they ? 'them' : 'it'}.`;
88
+ }
89
+ return null;
90
+ };
91
+
92
+ export default sandboxOptionRefusal;
@@ -19,8 +19,9 @@
19
19
  * "Confined" is what the adapters enforce, not what the file declares: a public
20
20
  * or workspace trust, or a shape one adapter enforces with no trust (claude's
21
21
  * `bwrap` mode, dsh's `isConfinedDsh` shape). Any other `sandbox.mode` with no
22
- * trust is spawned bare (claude, codex) or refused at spawn, so it is
23
- * unconfined here, and `mode: 'none'` always is.
22
+ * trust is unconfined here: claude, opencode and qwen spawn it bare, codex
23
+ * runs its private profile (workspace writable, network on), and the rest
24
+ * refuse it. `mode: 'none'` always is.
24
25
  *
25
26
  * A legacy pod with no joinPolicy is reported 'open', and that is not only a
26
27
  * default: an agent may self-install into a pod an agent created unless it is
@@ -50,6 +51,9 @@ const ADAPTER_OWN_CONFINEMENT = {
50
51
  dsh: isConfinedDshShape,
51
52
  };
52
53
 
54
+ /** True when the adapter enforces this sandbox shape with no trust (claude bwrap, dsh's one shape). */
55
+ export const adapterConfinesItself = (adapterName, sandbox) => Boolean(ADAPTER_OWN_CONFINEMENT[adapterName]?.(sandbox));
56
+
53
57
  export const seatRunsUnconfined = ({ environment, adapterName }) => {
54
58
  if (UNCONFINED_UNCHECKED_ADAPTERS.has(adapterName)) return false;
55
59
  const sandbox = normalizeSandboxTrust(environment?.sandbox);