@commonlyai/cli 0.1.107 → 0.1.112
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
package/src/commands/agent.js
CHANGED
|
@@ -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
|
|
159
|
-
* an
|
|
160
|
-
*
|
|
161
|
-
*
|
|
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
|
|
167
|
-
|
|
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
|
|
3121
|
-
+ `commonly agent detach ${name} --force, then run a fresh command
|
|
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
|
|
|
@@ -258,6 +258,59 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns) => {
|
|
|
258
258
|
];
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
// A public seat's skills, as appended system-prompt text.
|
|
262
|
+
//
|
|
263
|
+
// `--disable-slash-commands` above is Claude's switch for ALL skills, and
|
|
264
|
+
// `--setting-sources ''` drops the project source the mounted copies live in.
|
|
265
|
+
// So the skills this adapter mounts into <cwd>/.claude/skills never load in a
|
|
266
|
+
// public seat: measured 2026-10-19 on a Bring your own page seat, which
|
|
267
|
+
// answered "I don't see a skill named commonly, or any skills list or Skill
|
|
268
|
+
// tool"; the same workspace with `--setting-sources project` found it. Every
|
|
269
|
+
// self-serve seat is public (COMMONLY_DEFAULT_SANDBOX), so every outsider's
|
|
270
|
+
// Claude ran without the house rules buildDefaultEnvironment mounts for it.
|
|
271
|
+
// Re-enabling skills would also hand a public seat the built-in ones
|
|
272
|
+
// (computer-use, the browser skills), so the flags stay and the declared text
|
|
273
|
+
// is delivered as prompt instead. Inline rather than a file: nothing new has to
|
|
274
|
+
// be admitted through Seatbelt. Linux caps one argv string at 128 KiB, so the
|
|
275
|
+
// total is capped well under it.
|
|
276
|
+
const PUBLIC_SKILL_PROMPT_MAX_BYTES = 96 * 1024;
|
|
277
|
+
const SKILL_FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/;
|
|
278
|
+
|
|
279
|
+
const publicSkillPromptArgs = async (skillSources) => {
|
|
280
|
+
const sections = [];
|
|
281
|
+
let total = 0;
|
|
282
|
+
for (const source of skillSources || []) {
|
|
283
|
+
let markdown;
|
|
284
|
+
try {
|
|
285
|
+
// eslint-disable-next-line no-await-in-loop
|
|
286
|
+
markdown = await readFile(join(source, 'SKILL.md'), 'utf8');
|
|
287
|
+
} catch {
|
|
288
|
+
// eslint-disable-next-line no-console
|
|
289
|
+
console.warn(`[claude] public seat: no SKILL.md to inline at ${source}`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const frontmatter = SKILL_FRONTMATTER_RE.exec(markdown);
|
|
293
|
+
const name = (frontmatter && /^name:\s*(.+)$/m.exec(frontmatter[1])?.[1].trim())
|
|
294
|
+
|| source.split(/[\\/]/).filter(Boolean).pop();
|
|
295
|
+
const section = `## Skill: ${name}\n\n${markdown.slice(frontmatter ? frontmatter[0].length : 0).trim()}`;
|
|
296
|
+
const bytes = Buffer.byteLength(section, 'utf8');
|
|
297
|
+
if (total + bytes > PUBLIC_SKILL_PROMPT_MAX_BYTES) {
|
|
298
|
+
// eslint-disable-next-line no-console
|
|
299
|
+
console.warn(`[claude] public seat: skill ${name} not inlined (over ${PUBLIC_SKILL_PROMPT_MAX_BYTES} bytes in total)`);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
total += bytes;
|
|
303
|
+
sections.push(section);
|
|
304
|
+
}
|
|
305
|
+
if (sections.length === 0) return [];
|
|
306
|
+
return [
|
|
307
|
+
'--append-system-prompt',
|
|
308
|
+
'These skills are part of how you work here. Skills are not loaded as files in this seat, '
|
|
309
|
+
+ 'so each one is given in full below. Follow them as you would a loaded skill.\n\n'
|
|
310
|
+
+ sections.join('\n\n'),
|
|
311
|
+
];
|
|
312
|
+
};
|
|
313
|
+
|
|
261
314
|
const runClaude = ({ cmd, args, cwd, env, timeoutMs, credentials = [], spawnImpl = childSpawn }) => new Promise((resolve, reject) => {
|
|
262
315
|
const proc = spawnImpl(cmd, args, {
|
|
263
316
|
cwd,
|
|
@@ -637,6 +690,7 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
637
690
|
innerArgv = [
|
|
638
691
|
...innerArgv,
|
|
639
692
|
...buildPublicClaudePolicyArgs(allowedPatterns),
|
|
693
|
+
...(ctx.publicSkillArgs || []),
|
|
640
694
|
];
|
|
641
695
|
const claudeBin = resolveClaudePath(claudeEnv);
|
|
642
696
|
// Only stdio servers have a `command`; an HTTP entry (the grant broker)
|
|
@@ -674,6 +728,7 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
674
728
|
innerArgv = [
|
|
675
729
|
...innerArgv,
|
|
676
730
|
...buildPublicClaudePolicyArgs(allowedPatterns),
|
|
731
|
+
...(ctx.publicSkillArgs || []),
|
|
677
732
|
];
|
|
678
733
|
} else if (allowedPatterns.length > 0) {
|
|
679
734
|
innerArgv = [...innerArgv, '--allowedTools', ...allowedPatterns];
|
|
@@ -779,8 +834,10 @@ export default {
|
|
|
779
834
|
];
|
|
780
835
|
const baseArgs = ['-p', fullPrompt, '--output-format', 'text', sessionFlag, sessionId, ...modelArgs];
|
|
781
836
|
|
|
837
|
+
let mountedSkills = [];
|
|
782
838
|
if (ctx.environment && ctx.cwd) {
|
|
783
839
|
const skills = await mountSkills(ctx.environment, ctx.cwd);
|
|
840
|
+
mountedSkills = skills.mounted;
|
|
784
841
|
if (skills.conflicted.length > 0) {
|
|
785
842
|
for (const c of skills.conflicted) {
|
|
786
843
|
// eslint-disable-next-line no-console
|
|
@@ -792,6 +849,7 @@ export default {
|
|
|
792
849
|
|
|
793
850
|
let mcpConfig = null;
|
|
794
851
|
let publicClaudeState = null;
|
|
852
|
+
let publicSkillArgs = [];
|
|
795
853
|
try {
|
|
796
854
|
// Trust is normalized at entry (legacy `internal` reads as public). The
|
|
797
855
|
// MCP policy follows trust alone, whatever confines the seat: a public
|
|
@@ -803,6 +861,7 @@ export default {
|
|
|
803
861
|
if (publicNativeSandbox) {
|
|
804
862
|
publicClaudeState = await preparePublicClaudeState(ctx);
|
|
805
863
|
}
|
|
864
|
+
if (publicTrust) publicSkillArgs = await publicSkillPromptArgs(mountedSkills);
|
|
806
865
|
if (Array.isArray(ctx.environment?.mcp) && ctx.environment.mcp.length > 0) {
|
|
807
866
|
mcpConfig = await createMcpConfig(ctx.environment.mcp, {
|
|
808
867
|
runtimeToken: ctx.runtimeToken,
|
|
@@ -827,6 +886,7 @@ export default {
|
|
|
827
886
|
mcpConfigDir: mcpConfig?.dir || null,
|
|
828
887
|
mcpReadDirectories: mcpConfig?.mcpReadDirectories || [],
|
|
829
888
|
publicClaudeState,
|
|
889
|
+
publicSkillArgs,
|
|
830
890
|
claudeEnv,
|
|
831
891
|
};
|
|
832
892
|
const { cmd, args, env } = await prepareArgv(baseArgs, spawnCtx);
|
|
@@ -867,6 +927,7 @@ export default {
|
|
|
867
927
|
mcpConfigDir: mcpConfig?.dir || null,
|
|
868
928
|
mcpReadDirectories: mcpConfig?.mcpReadDirectories || [],
|
|
869
929
|
publicClaudeState,
|
|
930
|
+
publicSkillArgs,
|
|
870
931
|
claudeEnv: buildClaudeEnv(
|
|
871
932
|
ctx.env,
|
|
872
933
|
publicClaudeState,
|
package/src/lib/sandbox/bwrap.js
CHANGED
|
@@ -47,12 +47,18 @@ const DEFAULT_RO_BINDS = [
|
|
|
47
47
|
'/lib64',
|
|
48
48
|
];
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
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 =
|
|
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)
|
|
13
|
-
* declared sandbox itself
|
|
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
|
-
|
|
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
|
|