@commonlyai/cli 0.1.375 → 0.1.377
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 +1 -1
- package/src/commands/agent.js +12 -12
- package/src/commands/daemon.js +3 -3
- package/src/lib/adapters/claude.js +9 -9
- package/src/lib/adapters/codex.js +6 -6
- package/src/lib/adapters/qwen.js +1 -1
- package/src/lib/adapters/tested-version.js +1 -1
- package/src/lib/daemon-service-windows.js +1 -1
- package/src/lib/daemon-service.js +1 -1
- package/src/lib/daemon-store.js +1 -1
- package/src/lib/daemon-supervisor.js +1 -1
- package/src/lib/default-environment.js +1 -1
- package/src/lib/doctor.js +2 -2
- package/src/lib/enforcement.js +1 -1
- package/src/lib/grant-broker-guard.js +2 -2
- package/src/lib/machine-host.js +1 -1
- package/src/lib/public-withheld-tools.js +1 -1
- package/src/lib/reply-receipt.js +2 -2
- package/src/lib/sandbox/bwrap.js +70 -5
- package/src/lib/sandbox/host-check.js +40 -9
- package/src/lib/sandbox/windows-unsandboxed.js +1 -1
- package/src/lib/seat-runtime-controls.js +1 -1
- package/src/lib/session-store.js +1 -1
- package/src/lib/update-check.js +1 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -1477,7 +1477,7 @@ export const resolveAttachSandbox = ({
|
|
|
1477
1477
|
// pure — a mode and an adapter name — so it belongs with the derivation, and
|
|
1478
1478
|
// its witnesses live beside it.
|
|
1479
1479
|
// Two different things can be missing, so the refusal names the one that is:
|
|
1480
|
-
// the
|
|
1480
|
+
// the walk read "requires public trust" on a seat whose trust WAS public.
|
|
1481
1481
|
if (mode === 'workspace' || mode === 'read-only') {
|
|
1482
1482
|
if (!confined) {
|
|
1483
1483
|
throw new Error(
|
|
@@ -1564,7 +1564,7 @@ export const performAttach = async ({
|
|
|
1564
1564
|
});
|
|
1565
1565
|
if (codexRefusal) throw new Error(codexRefusal);
|
|
1566
1566
|
}
|
|
1567
|
-
//
|
|
1567
|
+
// Native Windows has neither sandbox, so its refusal names Windows
|
|
1568
1568
|
// and the user's own opt-in, never Seatbelt or bwrap advice. Attach still
|
|
1569
1569
|
// refuses there, as before; only the words differ.
|
|
1570
1570
|
const windowsRefusal = () => new Error(adapterName === 'dsh'
|
|
@@ -1828,7 +1828,7 @@ export const runMemoryImport = async ({
|
|
|
1828
1828
|
|
|
1829
1829
|
// ── run: local-CLI wrapper loop (ADR-005) ────────────────────────────────────
|
|
1830
1830
|
|
|
1831
|
-
//
|
|
1831
|
+
// An 11-04 walk: a Qwen seat whose post tool was declined told the pod about
|
|
1832
1832
|
// checkpoints, first_contact and re-serving. The model wrote that, not the
|
|
1833
1833
|
// wrapper, so the fix is an instruction and not a filter on its text: a filter
|
|
1834
1834
|
// would also eat a pod that is discussing these words. It speaks only to a
|
|
@@ -1911,7 +1911,7 @@ const FINAL_TEXT_ANSWERS_ON_COMMENT = 'Your final text is posted as a reply to t
|
|
|
1911
1911
|
+ FAILURE_ON_COMMENT;
|
|
1912
1912
|
|
|
1913
1913
|
// Where a mention's answer goes is the kernel's line, in the item body: since
|
|
1914
|
-
//
|
|
1914
|
+
// Since 2026-11-09 a top-level @mention in a shared pod is answered in that
|
|
1915
1915
|
// message's thread, the same as a mention inside a thread. The wrapper used to
|
|
1916
1916
|
// add its own line beside a person's top-level mention saying to answer
|
|
1917
1917
|
// top-level (F212, #3499/#3511); it adds no placement line now, so the item
|
|
@@ -2064,7 +2064,7 @@ const extractPrompt = (event) => {
|
|
|
2064
2064
|
// cancel grace, and the wall-clock backstop past the adapter's own timeout.
|
|
2065
2065
|
export { supervisedRunPolicy };
|
|
2066
2066
|
|
|
2067
|
-
// Codex turns are supervised by default
|
|
2067
|
+
// Codex turns are supervised by default: a turn that stops making
|
|
2068
2068
|
// progress is named and killed instead of holding the seat. COMMONLY_SUPERVISE_RUNS=0
|
|
2069
2069
|
// opts out. Every other adapter stays off unless COMMONLY_SUPERVISE_RUNS=1.
|
|
2070
2070
|
export const superviseRunsByDefault = (adapterName, env = process.env) => {
|
|
@@ -2114,7 +2114,7 @@ export const performRun = ({
|
|
|
2114
2114
|
localKey = null,
|
|
2115
2115
|
podId = null,
|
|
2116
2116
|
environment = null,
|
|
2117
|
-
//
|
|
2117
|
+
// The user's own Windows opt-in for this run; reaches the adapter's
|
|
2118
2118
|
// spawn context only (never the environment).
|
|
2119
2119
|
hostUnconfined = false,
|
|
2120
2120
|
// F187: this Windows Codex run was opted in with every pod confirmed private.
|
|
@@ -2158,7 +2158,7 @@ export const performRun = ({
|
|
|
2158
2158
|
// The agent to @mention when the model provider refuses a request's content
|
|
2159
2159
|
// (lib/content-refusal.js). Null: the refusal notice names no one.
|
|
2160
2160
|
reportRuntime = false,
|
|
2161
|
-
//
|
|
2161
|
+
// A listener seat (no daemon) reads the model and effort its owner
|
|
2162
2162
|
// saved on the server before each turn. Off for daemon seats, whose daemon
|
|
2163
2163
|
// projects the same values into `environment`.
|
|
2164
2164
|
readSavedControls = false,
|
|
@@ -2442,7 +2442,7 @@ export const performRun = ({
|
|
|
2442
2442
|
// a conversation that read the workspace, whatever claude's resume would
|
|
2443
2443
|
// find from another folder.
|
|
2444
2444
|
let lastPlacementReason = null;
|
|
2445
|
-
//
|
|
2445
|
+
// The model and effort this turn spawns with. A listener seat reads
|
|
2446
2446
|
// its saved controls first; then an effort is dropped only when the device
|
|
2447
2447
|
// listed its levels and this one is not among them.
|
|
2448
2448
|
let savedControlsNoticeShown = false;
|
|
@@ -2477,7 +2477,7 @@ export const performRun = ({
|
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
2479
2479
|
// Dropped only when the device listed its levels and this one is not
|
|
2480
|
-
// among them; with nothing reported the harness decides
|
|
2480
|
+
// among them; with nothing reported the harness decides.
|
|
2481
2481
|
seatEnvironment = reportRuntime && desiredEnvironment
|
|
2482
2482
|
&& effortRefusedByDevice(inventory, desiredEnvironment.effort)
|
|
2483
2483
|
? { ...desiredEnvironment, effort: undefined } : desiredEnvironment;
|
|
@@ -3239,7 +3239,7 @@ export const performRun = ({
|
|
|
3239
3239
|
? { mounted: serverSkills.mounted, conflicted: serverSkills.conflicted, ...(skillReadUnavailable ? { status: 'unavailable' } : {}) }
|
|
3240
3240
|
: null;
|
|
3241
3241
|
let spawnCompleted = false;
|
|
3242
|
-
//
|
|
3242
|
+
// How long the runtime ran, for the reply receipt.
|
|
3243
3243
|
let spawnDurationMs;
|
|
3244
3244
|
let observedSpawn = false;
|
|
3245
3245
|
// What a failed spawn threw, read only for its fixed reason code (F370 #11).
|
|
@@ -3524,7 +3524,7 @@ export const performRun = ({
|
|
|
3524
3524
|
maxChunks: maxChatChunks,
|
|
3525
3525
|
uploadName: `${agentName}-reply-${event._id}.md`,
|
|
3526
3526
|
log: (line) => log(`[${event.type}] ${line}`),
|
|
3527
|
-
//
|
|
3527
|
+
// The wrapper's own account of this turn.
|
|
3528
3528
|
receipt: buildReplyReceipt({
|
|
3529
3529
|
adapterName: adapter.name,
|
|
3530
3530
|
stats: result.stats,
|
|
@@ -5919,7 +5919,7 @@ Docs:
|
|
|
5919
5919
|
bootstrapped = true;
|
|
5920
5920
|
}
|
|
5921
5921
|
|
|
5922
|
-
//
|
|
5922
|
+
// On native Windows the user may choose to run without an OS
|
|
5923
5923
|
// sandbox, by typing the flag or by installing the daemon with it (the
|
|
5924
5924
|
// marker is read only by the seats that daemon spawns). Nothing from the
|
|
5925
5925
|
// server decides this, and the environment never carries it: the seat
|
package/src/commands/daemon.js
CHANGED
|
@@ -365,7 +365,7 @@ export const resolveAdapterForRuntime = async (runtime, registry = { getAdapter
|
|
|
365
365
|
|
|
366
366
|
/**
|
|
367
367
|
* The daemon's first poll and heartbeat, with the Windows launcher watch armed
|
|
368
|
-
* BEFORE them
|
|
368
|
+
* BEFORE them. Arming first puts the EPIPE guard on stdout and stderr
|
|
369
369
|
* before any supervision log line, and a launcher that is already gone stops
|
|
370
370
|
* the daemon here instead of after a tick logged into a dead pipe. Returns
|
|
371
371
|
* false when the daemon should not go on to its timers.
|
|
@@ -604,7 +604,7 @@ Examples:
|
|
|
604
604
|
}
|
|
605
605
|
// A service without a credential just crash-loops at boot.
|
|
606
606
|
requireDaemonRecord();
|
|
607
|
-
//
|
|
607
|
+
// This command is the only writer of the opt-in, and installing
|
|
608
608
|
// without the flag is how it is turned off. Written before the task
|
|
609
609
|
// starts, so the first seats it spawns already read the answer.
|
|
610
610
|
// N3: the marker's state before this install, so a failed install can
|
|
@@ -824,7 +824,7 @@ Examples:
|
|
|
824
824
|
supervisor.stop();
|
|
825
825
|
process.exit(0);
|
|
826
826
|
};
|
|
827
|
-
//
|
|
827
|
+
// Under the Windows launcher, the launcher's exit is the stop
|
|
828
828
|
// signal. Armed before the first tick, so the EPIPE guard covers its
|
|
829
829
|
// log lines and a launcher already gone stops the daemon at once.
|
|
830
830
|
const started = await firstSupervisionPass({
|
|
@@ -182,7 +182,7 @@ const PUBLIC_DENIED_TOOLS = [
|
|
|
182
182
|
'WebFetch',
|
|
183
183
|
'Bash',
|
|
184
184
|
// Claude Code's shell tool on Windows. dontAsk and the Read(./**) allowlist
|
|
185
|
-
// already refuse it; named here so the deny list holds on its own
|
|
185
|
+
// already refuse it; named here so the deny list holds on its own.
|
|
186
186
|
'PowerShell',
|
|
187
187
|
'Write',
|
|
188
188
|
'Edit',
|
|
@@ -231,7 +231,7 @@ const withWorkspaceGit = (ctx) => {
|
|
|
231
231
|
};
|
|
232
232
|
};
|
|
233
233
|
const PUBLIC_SAFE_ENV = /^(?:PATH|LANG|LC_[A-Z_]+|TERM|USER|LOGNAME|NO_COLOR|CI|SSL_CERT_FILE|SSL_CERT_DIR)$/;
|
|
234
|
-
//
|
|
234
|
+
// What a Windows process needs to start at all, find its own login and
|
|
235
235
|
// open a socket. Windows keys are case-insensitive (Path, SystemRoot), so this
|
|
236
236
|
// one is matched without case. None of these carries a secret.
|
|
237
237
|
const PUBLIC_SAFE_ENV_WIN32 = /^(?:PATH|PATHEXT|SYSTEMROOT|SYSTEMDRIVE|WINDIR|COMSPEC|TEMP|TMP|USERPROFILE|USERNAME|USERDOMAIN|HOMEDRIVE|HOMEPATH|APPDATA|LOCALAPPDATA|PROGRAMDATA|PROGRAMFILES|PROGRAMFILES\(X86\)|COMMONPROGRAMFILES|NUMBER_OF_PROCESSORS|PROCESSOR_ARCHITECTURE|OS)$/i;
|
|
@@ -635,7 +635,7 @@ const buildClaudeEnv = (input, state, expansionEnv = {}, credentialFile = null,
|
|
|
635
635
|
|
|
636
636
|
const absoluteToolDeny = (path) => `Read(/${path}/**)`;
|
|
637
637
|
|
|
638
|
-
//
|
|
638
|
+
// Claude Code matches permission paths in POSIX form on Windows
|
|
639
639
|
// (C:\Users\ada becomes /c/Users/ada), so an absolute deny written from a
|
|
640
640
|
// Windows path would match nothing.
|
|
641
641
|
const permissionPath = (path, platform) => (platform === 'win32'
|
|
@@ -652,7 +652,7 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns, {
|
|
|
652
652
|
const home = homeOverride || homedir();
|
|
653
653
|
const deny = (sub) => absoluteToolDeny(permissionPath(join(home, sub), platform));
|
|
654
654
|
// `allow` is already narrowed to a workspace seat's grants (workspaceGrants).
|
|
655
|
-
//
|
|
655
|
+
// With no OS jail (native Windows, --unsandboxed) a shell would run
|
|
656
656
|
// with the user's whole access and could read the seat's own token from its
|
|
657
657
|
// environment, so `write` grants edits only there.
|
|
658
658
|
// With no jail the edit tools are also scoped to the working folder: a bare
|
|
@@ -1437,7 +1437,7 @@ const claudeInstallRefusal = (claudeBin) => new Error(
|
|
|
1437
1437
|
);
|
|
1438
1438
|
|
|
1439
1439
|
/**
|
|
1440
|
-
*
|
|
1440
|
+
* Native Windows has no OS jail, and the user chose to run without one
|
|
1441
1441
|
* (`--unsandboxed`). Read from the spawn context only, set by `agent run`, never
|
|
1442
1442
|
* from the environment. The seat keeps its trust, so everything the trust
|
|
1443
1443
|
* brings except the jail still applies.
|
|
@@ -1533,7 +1533,7 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
1533
1533
|
// unconfined seat with a public record, which is how a record can claim
|
|
1534
1534
|
// confinement it never applies.
|
|
1535
1535
|
if (isConfinedTrust(sandboxTrust) && !publicNativeSandbox && sandboxMode !== 'bwrap') {
|
|
1536
|
-
//
|
|
1536
|
+
// On native Windows, name Windows and the user's own opt-in, never
|
|
1537
1537
|
// macOS or bwrap advice (host-check passes an unrecognised mode through).
|
|
1538
1538
|
if ((ctx._platform || process.platform) === 'win32') {
|
|
1539
1539
|
throw new Error(
|
|
@@ -1876,7 +1876,7 @@ export default {
|
|
|
1876
1876
|
let publicLoginBaseUrl = null;
|
|
1877
1877
|
let loginTurn = null;
|
|
1878
1878
|
let publicSkillArgs = [];
|
|
1879
|
-
//
|
|
1879
|
+
// No jail to prepare for on a policy-only Windows host.
|
|
1880
1880
|
const jailed = !policyOnlyHost(ctx);
|
|
1881
1881
|
const publicNativeSandbox = jailed && publicTrust
|
|
1882
1882
|
&& PUBLIC_SANDBOX_MODES.has(resolvePublicSandboxMode(ctx.environment?.sandbox));
|
|
@@ -2009,7 +2009,7 @@ export default {
|
|
|
2009
2009
|
readyFileDir = join(publicClaudeState.statePath, 'mcp-ready');
|
|
2010
2010
|
await mkdir(readyFileDir, { recursive: true, mode: 0o700 });
|
|
2011
2011
|
} else if (ctx.environment?.sandbox?.trust === 'public') {
|
|
2012
|
-
// A policy-only host
|
|
2012
|
+
// A policy-only host prepares no state folder and runs the MCP
|
|
2013
2013
|
// children unjailed, so a folder of this turn's own serves.
|
|
2014
2014
|
ownReadyDir = await mkdtemp(join(tmpdir(), 'commonly-claude-ready-'));
|
|
2015
2015
|
await chmod(ownReadyDir, 0o700);
|
|
@@ -2086,7 +2086,7 @@ export default {
|
|
|
2086
2086
|
text: turnReply(stdout, { credentials: turnCredentials(spawnCtx), publicMcp: witnessedMcp }),
|
|
2087
2087
|
newSessionId: sessionId,
|
|
2088
2088
|
contextTokens,
|
|
2089
|
-
//
|
|
2089
|
+
// What the run said about itself, for the reply receipt.
|
|
2090
2090
|
stats: claudeRunStats(stdout),
|
|
2091
2091
|
};
|
|
2092
2092
|
} catch (err) {
|
|
@@ -567,7 +567,7 @@ const preparePrivateCodexHome = async (ctx, childEnv) => {
|
|
|
567
567
|
return { home, source, realSource, others, links };
|
|
568
568
|
};
|
|
569
569
|
|
|
570
|
-
// `login: false` is the proxy route
|
|
570
|
+
// `login: false` is the proxy route: codex authenticates with the
|
|
571
571
|
// per-turn token, so the public home gets no link to the person's Codex login,
|
|
572
572
|
// and a link an earlier turn left is removed.
|
|
573
573
|
const preparePublicCodexHome = async (ctx, childEnv, { login = true } = {}) => {
|
|
@@ -1128,7 +1128,7 @@ const privatePermissionProfileFlags = ({
|
|
|
1128
1128
|
// F188: the host's OpenAI-compatible model route, for a public seat. That seat
|
|
1129
1129
|
// runs with `--ignore-user-config`, so config.toml's `openai_base_url` never
|
|
1130
1130
|
// loads, and codex-cli 0.162.1 does not read the OPENAI_BASE_URL env either
|
|
1131
|
-
// (Growth's
|
|
1131
|
+
// (Growth's walk, 11-05): a host routed at LiteLLM or another
|
|
1132
1132
|
// OpenAI-compatible endpoint sent every turn to api.openai.com and got a 401.
|
|
1133
1133
|
// The env is the declaration, as ANTHROPIC_BASE_URL is for the claude adapter;
|
|
1134
1134
|
// buildArgs passes it on as `-c openai_base_url=...`, the top-level key the
|
|
@@ -1186,7 +1186,7 @@ export const codexAuthKind = async (operatorHome, source = {}) => {
|
|
|
1186
1186
|
return mode === 'apikey' ? 'apikey' : 'login';
|
|
1187
1187
|
};
|
|
1188
1188
|
|
|
1189
|
-
//
|
|
1189
|
+
// The F188 route leaves the key in codex's own environment. With
|
|
1190
1190
|
// CODEX_API_KEY in the seat's environment (codex's own name for an exec key),
|
|
1191
1191
|
// the key stays on the host behind the per-turn loopback proxy, as a Claude
|
|
1192
1192
|
// seat's ANTHROPIC_API_KEY does, and codex gets a provider entry naming the
|
|
@@ -1249,7 +1249,7 @@ const buildArgs = ({
|
|
|
1249
1249
|
}) => {
|
|
1250
1250
|
const publicSandbox = publicSandboxMode !== null;
|
|
1251
1251
|
// F387: a private seat keeps the flag below only in a cloud-codex pod, or
|
|
1252
|
-
// when its operator opted this run out of the OS sandbox (
|
|
1252
|
+
// when its operator opted this run out of the OS sandbox (native
|
|
1253
1253
|
// Windows only: Codex can't enforce a profile's read denies there).
|
|
1254
1254
|
const keepsOwnPolicy = trustedContainerPerimeter || operatorUnconfined;
|
|
1255
1255
|
const privateProfile = !publicSandbox && !keepsOwnPolicy;
|
|
@@ -1713,7 +1713,7 @@ export default {
|
|
|
1713
1713
|
}
|
|
1714
1714
|
}
|
|
1715
1715
|
// F387: only a cloud-codex pod sets the perimeter env
|
|
1716
|
-
// (sandbox/codex-perimeter.js), and only the operator's own
|
|
1716
|
+
// (sandbox/codex-perimeter.js), and only the operator's own opt-in
|
|
1717
1717
|
// sets hostUnconfined. Every other private seat runs under the private
|
|
1718
1718
|
// permission profile.
|
|
1719
1719
|
const trustedContainerPerimeter = codexTrustedPerimeter(ctx.env || process.env);
|
|
@@ -1900,7 +1900,7 @@ export default {
|
|
|
1900
1900
|
const contextTokens = newSessionId
|
|
1901
1901
|
? (ctx._codexContextTokens || codexContextTokens)({ codexHome: codexHomeFor(childEnv), sessionId: newSessionId })
|
|
1902
1902
|
: null;
|
|
1903
|
-
//
|
|
1903
|
+
// The reply receipt names the model and effort this spawn passed
|
|
1904
1904
|
// (`--model`, `model_reasoning_effort`); codex's own stream does not
|
|
1905
1905
|
// restate them.
|
|
1906
1906
|
const effort = ctx.environment?.effort;
|
package/src/lib/adapters/qwen.js
CHANGED
|
@@ -435,7 +435,7 @@ export default {
|
|
|
435
435
|
// honours CLI allow rules. Any seat needs its declared Commonly tools
|
|
436
436
|
// approved before non-interactive execution begins, public included:
|
|
437
437
|
// without it a public seat's commonly_post_message was declined
|
|
438
|
-
// (
|
|
438
|
+
// (11-04). Public parity with Claude's --allowedTools
|
|
439
439
|
// mcp__commonly__*; the withheld tools stay in --exclude-tools above.
|
|
440
440
|
// The broker parks every write for the owner itself (F175d).
|
|
441
441
|
...(allowedTools.length ? ['--allowed-tools', allowedTools.join(',')] : []),
|
|
@@ -8,7 +8,7 @@ import { resolveOnPath } from '../resolve-on-path.js';
|
|
|
8
8
|
// Public seats run only on a harness version smoke-tested in its sandbox, with
|
|
9
9
|
// one tolerance: a stable patch release after the newest tested one, on that
|
|
10
10
|
// same major.minor line. Harnesses ship patches every few days, and refusing
|
|
11
|
-
// them refused every new BYO user on the current npm release (
|
|
11
|
+
// them refused every new BYO user on the current npm release (11-04).
|
|
12
12
|
// A newer minor or major, an older patch, an older line, or a prerelease still
|
|
13
13
|
// refuses until it is smoke-tested and added to the adapter's list.
|
|
14
14
|
const STABLE = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The Windows form of `commonly daemon install` (ADR-026 D1).
|
|
3
3
|
*
|
|
4
4
|
* macOS has launchd and Linux has systemd; Windows has Task Scheduler. A
|
|
5
5
|
* per-user task needs no administrator, so the install stays a one-liner a
|
|
@@ -201,7 +201,7 @@ WantedBy=default.target
|
|
|
201
201
|
`;
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
//
|
|
204
|
+
// A systemd user unit is started by the user's own systemd manager, and
|
|
205
205
|
// without lingering that manager starts at the user's login, not at boot. On a
|
|
206
206
|
// headless box nobody logs in to, the daemon would then stay down after every
|
|
207
207
|
// reboot. logind records lingering as one file per user, so that file is what
|
package/src/lib/daemon-store.js
CHANGED
|
@@ -68,7 +68,7 @@ export const loadDaemonRecord = ({ platform = process.platform } = {}) => {
|
|
|
68
68
|
const path = daemonRecordPath();
|
|
69
69
|
const dir = daemonDir();
|
|
70
70
|
if (!existsSync(path)) return null;
|
|
71
|
-
//
|
|
71
|
+
// Windows has no POSIX mode bits. Node reports every file there as
|
|
72
72
|
// 0o666 (0o444 when read-only) whatever its ACL, so this check refused every
|
|
73
73
|
// registration on Windows. Access there is the ACL's job; the record sits in
|
|
74
74
|
// the user's profile, which only that user (and administrators) can read.
|
|
@@ -92,7 +92,7 @@ export const createDaemonSupervisor = ({
|
|
|
92
92
|
loadToken, // (agentName) => token record | null
|
|
93
93
|
saveToken, // (agentName, record) => void
|
|
94
94
|
runtimeInventory = async () => undefined,
|
|
95
|
-
// Machine-level facts for the check-in, read locally each beat (
|
|
95
|
+
// Machine-level facts for the check-in, read locally each beat (the
|
|
96
96
|
// Windows unsandboxed opt-in). Never derived from anything the server sent.
|
|
97
97
|
machineReport = () => ({}),
|
|
98
98
|
resolveAdapter, // async (runtime) => adapter name for THIS machine
|
|
@@ -49,7 +49,7 @@ export const ADAPTERS_WITH_DEFAULT_SANDBOX = new Set(['claude', 'codex', 'openco
|
|
|
49
49
|
// adapters/pi.js), and neither is handed the default block (see above). The
|
|
50
50
|
// attach gate (agent.js resolveAttachSandbox) reads this set, not the default
|
|
51
51
|
// one, or an explicitly configured public Goose or pi seat is refused before its
|
|
52
|
-
// adapter runs (
|
|
52
|
+
// adapter runs (11-04; F113b).
|
|
53
53
|
export const ADAPTERS_WITH_SANDBOX_ENFORCEMENT = new Set([...ADAPTERS_WITH_DEFAULT_SANDBOX, 'goose', 'pi']);
|
|
54
54
|
|
|
55
55
|
// Adapters that may receive a room grant: each confines a public seat AND keeps
|
package/src/lib/doctor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `commonly doctor` — the checks (TASK-660
|
|
2
|
+
* `commonly doctor` — the checks (TASK-660).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The plan keeps the Node daemon and hardens install by making breakage visible.
|
|
5
5
|
* Each check here answers one question a broken seat used to leave to a log
|
|
6
6
|
* autopsy, prints one line (pass, fail or skip) and, when it fails, the command
|
|
7
7
|
* that fixes it. Every outside fact (PATH, the saved login, the server, the
|
package/src/lib/enforcement.js
CHANGED
|
@@ -724,7 +724,7 @@ export const deliverChatReply = async ({
|
|
|
724
724
|
attachThreshold = 800,
|
|
725
725
|
uploadName = 'reply.md',
|
|
726
726
|
log = () => {},
|
|
727
|
-
//
|
|
727
|
+
// How this reply was made (lib/reply-receipt.js). It rides
|
|
728
728
|
// the first message that actually reaches the pod and no later one.
|
|
729
729
|
receipt = null,
|
|
730
730
|
// Keeps a reply that fits in up to maxChunks messages in that thread. The
|
|
@@ -185,7 +185,7 @@ const publicOnlyReason = (environment, rule, platform) => {
|
|
|
185
185
|
const sandbox = environment?.sandbox;
|
|
186
186
|
if (sandbox === null || typeof sandbox !== 'object' || Array.isArray(sandbox)) return PUBLIC_ONLY_REASON;
|
|
187
187
|
if (sandbox.mode === 'none' || effectiveSandboxTrust(sandbox.trust) !== 'public') return PUBLIC_ONLY_REASON;
|
|
188
|
-
//
|
|
188
|
+
// A public declaration on native Windows reads the same for every adapter.
|
|
189
189
|
if (platform === 'win32') return 'sandbox_mode_unenforceable';
|
|
190
190
|
const modes = Object.hasOwn(rule, platform) ? rule[platform] : null;
|
|
191
191
|
if (!modes) return PUBLIC_ONLY_REASON;
|
|
@@ -208,7 +208,7 @@ export const confinementReason = (environment, adapter, platform = process.platf
|
|
|
208
208
|
const declared = sandbox;
|
|
209
209
|
if (declared.mode === 'none') return 'sandbox_mode_none';
|
|
210
210
|
if (effectiveSandboxTrust(declared.trust) !== 'public') return 'sandbox_trust_not_public';
|
|
211
|
-
//
|
|
211
|
+
// Native Windows has no OS jail for any adapter. Claude there runs
|
|
212
212
|
// only by the user's --unsandboxed (policy without a jail), and a public
|
|
213
213
|
// Codex seat is refused there outright (host-check.js), so neither carries a
|
|
214
214
|
// grant.
|
package/src/lib/machine-host.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TASK-784
|
|
2
|
+
* TASK-784: what the daemon's computer runs, as the server stores it.
|
|
3
3
|
* Metadata only: Node's platform and arch names, the OS release's leading
|
|
4
4
|
* number, and this CLI's version. Nothing here may name the machine or the
|
|
5
5
|
* person (no hostname, path or user name); the server drops anything else.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// already catches up before each turn, so no seat on this list needs the tool.
|
|
7
7
|
export const PUBLIC_WITHHELD_TOOLS = Object.freeze(['commonly_attach_file', 'commonly_catch_up']);
|
|
8
8
|
|
|
9
|
-
// F118 (
|
|
9
|
+
// F118 (decided 11-04): public agents start from nothing and earn
|
|
10
10
|
// capabilities. A public seat answers strangers, so an injected message must
|
|
11
11
|
// not be able to spread the agent into other pods or rewrite its memory.
|
|
12
12
|
// Withheld on public trust only: a Claude workspace seat keeps its memory
|
package/src/lib/reply-receipt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// The receipt the wrapper posts with a reply, so a BYO reply
|
|
2
2
|
// carries "how this reply was made" the way a hosted reply has its run trace.
|
|
3
3
|
// It is the wrapper's own account and the server stores it as self-reported
|
|
4
4
|
// (backend/services/byoReceipt.ts), which also bounds and checks every field.
|
|
@@ -43,7 +43,7 @@ export const buildReplyReceipt = ({ adapterName, stats = {}, durationMs } = {})
|
|
|
43
43
|
// carries the account or project it runs in; that is not this reply's to
|
|
44
44
|
// publish, so such a model id is left out.
|
|
45
45
|
if (isName(stats?.model) && !/^arn:|(^|\/)projects\//i.test(stats.model)) receipt.model = stats.model;
|
|
46
|
-
//
|
|
46
|
+
// The effort level the adapter passed, as a bare level name.
|
|
47
47
|
if (isName(stats?.effort) && /^[a-z0-9][a-z0-9._-]{0,19}$/i.test(stats.effort)) receipt.effort = stats.effort;
|
|
48
48
|
if (isCount(stats?.turns)) receipt.turns = stats.turns;
|
|
49
49
|
if (Array.isArray(stats?.tools)) {
|
package/src/lib/sandbox/bwrap.js
CHANGED
|
@@ -36,7 +36,7 @@ const expandHome = (p) => {
|
|
|
36
36
|
// mechanisms that do exist are named instead.
|
|
37
37
|
const MACOS_MESSAGE = 'bwrap is Linux-only. On macOS a public seat runs under Seatbelt '
|
|
38
38
|
+ '(sandbox.mode workspace or read-only).';
|
|
39
|
-
//
|
|
39
|
+
// Native Windows has no sandbox for agents. WSL runs the Linux one,
|
|
40
40
|
// Claude Code included since F96, and host-check.js offers it; this message
|
|
41
41
|
// names the native path, which is the user's own opt-in
|
|
42
42
|
// (sandbox/windows-unsandboxed.js).
|
|
@@ -156,6 +156,74 @@ export const detectBwrap = ({
|
|
|
156
156
|
}
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
+
// OpenCode's private network: inside its own network namespace the loopback
|
|
160
|
+
// bridge (opencode-loopback.mjs) raises `lo` with CAP_NET_ADMIN, then drops
|
|
161
|
+
// both capabilities before the model process starts. wrapArgvWithBwrap and
|
|
162
|
+
// detectBwrapLoopback share these flags so the probe asks for what the
|
|
163
|
+
// sandbox will.
|
|
164
|
+
export const LOOPBACK_ISOLATION_FLAGS = Object.freeze([
|
|
165
|
+
'--uid', '0', '--gid', '0',
|
|
166
|
+
'--cap-add', 'CAP_NET_ADMIN', '--cap-add', 'CAP_SETPCAP',
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
// Where the bridge looks for iproute2's `ip`. The bridge keeps its own copy
|
|
170
|
+
// (only its file is bound into the sandbox); a test holds the two equal.
|
|
171
|
+
export const IP_CANDIDATES = Object.freeze(['/usr/sbin/ip', '/sbin/ip', '/usr/bin/ip', '/bin/ip']);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* F540: can this host give OpenCode's sandbox its private network? detectBwrap
|
|
175
|
+
* proves bubblewrap can start a namespace; a host can do that and still refuse
|
|
176
|
+
* the capability the loopback needs. Ubuntu 26.04 does ("RTNETLINK answers:
|
|
177
|
+
* Operation not permitted", GitHub run 43770297952), and so does Ubuntu's
|
|
178
|
+
* bwrap-userns-restrict AppArmor profile, under which what bubblewrap starts
|
|
179
|
+
* gets no capabilities. So this starts the same namespace with the same flags
|
|
180
|
+
* and raises its loopback. Call it only once detectBwrap reports available.
|
|
181
|
+
*/
|
|
182
|
+
export const detectBwrapLoopback = ({
|
|
183
|
+
spawn = spawnSync,
|
|
184
|
+
platform = process.platform,
|
|
185
|
+
exists = existsSync,
|
|
186
|
+
readRestriction = readApparmorRestriction,
|
|
187
|
+
readRelease = readUbuntuRelease,
|
|
188
|
+
} = {}) => {
|
|
189
|
+
if (platform !== 'linux') {
|
|
190
|
+
return { available: false, error: nonLinuxMessage(platform) };
|
|
191
|
+
}
|
|
192
|
+
const ip = IP_CANDIDATES.find((candidate) => exists(candidate));
|
|
193
|
+
if (!ip) {
|
|
194
|
+
return {
|
|
195
|
+
available: false,
|
|
196
|
+
missingIp: true,
|
|
197
|
+
error: 'It needs the ip command, which is not installed here. Install iproute2: '
|
|
198
|
+
+ '`sudo apt install iproute2` (Debian/Ubuntu, WSL), `sudo dnf install iproute` (Fedora) '
|
|
199
|
+
+ 'or `sudo pacman -S iproute2` (Arch).',
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const probe = spawn('bwrap', [
|
|
204
|
+
'--unshare-all', '--unshare-net', ...LOOPBACK_ISOLATION_FLAGS,
|
|
205
|
+
'--ro-bind', '/', '/', '--die-with-parent',
|
|
206
|
+
ip, 'link', 'set', 'lo', 'up',
|
|
207
|
+
], { encoding: 'utf8', timeout: 10_000 });
|
|
208
|
+
if (probe.error || probe.status !== 0) {
|
|
209
|
+
const reason = (probe.stderr || probe.error?.message || `exit ${probe.status}`).trim().split('\n').pop();
|
|
210
|
+
return {
|
|
211
|
+
available: false,
|
|
212
|
+
// As with the namespace probe: only a bwrap that ran and exited
|
|
213
|
+
// refusing says something about this host.
|
|
214
|
+
loopbackRefused: !probe.error && typeof probe.status === 'number',
|
|
215
|
+
reason,
|
|
216
|
+
apparmorRestricted: readRestriction(),
|
|
217
|
+
ubuntuRelease: readRelease(),
|
|
218
|
+
error: `bubblewrap starts a sandbox here, but not the private network OpenCode needs inside it (${reason}).`,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return { available: true };
|
|
222
|
+
} catch (err) {
|
|
223
|
+
return { available: false, error: `bwrap loopback detection failed: ${err.message}` };
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
159
227
|
/**
|
|
160
228
|
* Build the bwrap-wrapped argv. Caller spawns argv[0] with argv.slice(1).
|
|
161
229
|
*
|
|
@@ -193,10 +261,7 @@ export const wrapArgvWithBwrap = (innerArgv, env, opts = {}) => {
|
|
|
193
261
|
const flags = [
|
|
194
262
|
'--unshare-all',
|
|
195
263
|
...networkFlags,
|
|
196
|
-
...(opts.enableLoopback ? [
|
|
197
|
-
'--uid', '0', '--gid', '0',
|
|
198
|
-
'--cap-add', 'CAP_NET_ADMIN', '--cap-add', 'CAP_SETPCAP',
|
|
199
|
-
] : []),
|
|
264
|
+
...(opts.enableLoopback ? LOOPBACK_ISOLATION_FLAGS : []),
|
|
200
265
|
'--die-with-parent',
|
|
201
266
|
'--new-session',
|
|
202
267
|
'--proc', '/proc',
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
import { normalizeSandboxTrust } from '../environment.js';
|
|
21
21
|
import { PUBLIC_SANDBOX_MODES, resolvePublicSandboxMode } from './mode.js';
|
|
22
|
-
import { detectBwrap as defaultDetectBwrap } from './bwrap.js';
|
|
22
|
+
import { detectBwrap as defaultDetectBwrap, detectBwrapLoopback as defaultDetectBwrapLoopback } from './bwrap.js';
|
|
23
23
|
import { detectSeatbelt as defaultDetectSeatbelt } from './seatbelt.js';
|
|
24
24
|
import { codexTrustedPerimeter } from './codex-perimeter.js';
|
|
25
25
|
import { CLI } from '../cli-hint.js';
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// The Windows opt-in (windows-unsandboxed.js re-exports it; defined here to avoid an import cycle).
|
|
28
28
|
export const UNSANDBOXED_FLAG = '--unsandboxed';
|
|
29
29
|
|
|
30
30
|
// The Seatbelt modes come from mode.js, as grant-broker-guard's do, so a mode
|
|
@@ -122,6 +122,26 @@ export const bwrapRefusedMessage = (adapterName, { reason, apparmorRestricted, u
|
|
|
122
122
|
].join('\n');
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* F540: bubblewrap starts here, but this host won't give a public OpenCode's
|
|
127
|
+
* sandbox the private network it raises inside it. Ubuntu's bubblewrap profile
|
|
128
|
+
* is what takes that capability away, so it is never offered as the way out.
|
|
129
|
+
*/
|
|
130
|
+
export const opencodeLoopbackMessage = ({
|
|
131
|
+
loopbackRefused, missingIp, reason, apparmorRestricted, error,
|
|
132
|
+
} = {}) => [
|
|
133
|
+
'A connected OpenCode runs inside a bubblewrap sandbox with a private network of its own, '
|
|
134
|
+
+ (loopbackRefused === true
|
|
135
|
+
? `and this machine lets bubblewrap start the sandbox but not set up that network (${reason}).`
|
|
136
|
+
: `which can't be set up here. ${error || ''}`.trim()),
|
|
137
|
+
...(loopbackRefused === true && apparmorRestricted === true
|
|
138
|
+
? ['AppArmor on recent Ubuntu releases takes away the network setup that sandbox needs.']
|
|
139
|
+
: []),
|
|
140
|
+
'So this agent cannot listen for @mentions here yet. You can:',
|
|
141
|
+
...(missingIp === true ? [' - Install iproute2 as above and run the same command again.'] : []),
|
|
142
|
+
HOSTED_LINE,
|
|
143
|
+
].join('\n');
|
|
144
|
+
|
|
125
145
|
const CODEX_UNSANDBOXED_RUN_LINE = ` - In invite-only pods, run it without a sandbox: ${CLI} agent run <name> ${UNSANDBOXED_FLAG}`
|
|
126
146
|
+ ' (in the foreground; the daemon takes this only on Windows).'
|
|
127
147
|
+ ' Nothing confines it: it runs with your own access to files and commands, anyone in the pod,'
|
|
@@ -177,7 +197,7 @@ export const windowsSandboxMessage = (adapterName) => {
|
|
|
177
197
|
'so by default this agent cannot listen for @mentions from native Windows. You can:',
|
|
178
198
|
` - WSL 2 (Ubuntu): install Node and ${label} inside WSL, run \`sudo apt install bubblewrap\`,`
|
|
179
199
|
+ ' then run these same commands there.',
|
|
180
|
-
//
|
|
200
|
+
// The user's own choice, never a default (sandbox/windows-unsandboxed.js).
|
|
181
201
|
...(adapterName === 'claude'
|
|
182
202
|
? [` - Run it without an OS sandbox: add ${UNSANDBOXED_FLAG}`
|
|
183
203
|
+ ` (${CLI} agent run <name> ${UNSANDBOXED_FLAG}, or ${CLI} daemon install ${UNSANDBOXED_FLAG}).`
|
|
@@ -195,13 +215,15 @@ export const hostSandboxRefusal = ({
|
|
|
195
215
|
environment,
|
|
196
216
|
adapterName,
|
|
197
217
|
platform = process.platform,
|
|
198
|
-
//
|
|
218
|
+
// The user's own opt-in for this run (windows-unsandboxed.js
|
|
199
219
|
// hostUnconfinedForRun). Never derived from the environment.
|
|
200
220
|
hostUnconfined = false,
|
|
201
221
|
// The person asked for the opt-in, whether or not the seat qualified. Only
|
|
202
222
|
// chooses Codex's words: it never lets a seat through.
|
|
203
223
|
optedIn = false,
|
|
204
224
|
detectBwrap = defaultDetectBwrap,
|
|
225
|
+
// F540: only a public OpenCode seat needs it (adapters/opencode.js enableLoopback).
|
|
226
|
+
detectBwrapLoopback = defaultDetectBwrapLoopback,
|
|
205
227
|
detectSeatbelt = defaultDetectSeatbelt,
|
|
206
228
|
// F387: a cloud-codex pod declares itself here (codex-perimeter.js).
|
|
207
229
|
env = process.env,
|
|
@@ -224,7 +246,7 @@ export const hostSandboxRefusal = ({
|
|
|
224
246
|
// (walked on byo-linux.yml, walk=private-codex). Where bubblewrap can't
|
|
225
247
|
// start, every turn would fail at session start, so the seat is refused
|
|
226
248
|
// before its first poll, unless the person ran it unconfined by their own
|
|
227
|
-
// --unsandboxed (
|
|
249
|
+
// --unsandboxed (as on Windows: only with every pod confirmed
|
|
228
250
|
// private). Never unconfined without being asked.
|
|
229
251
|
if (platform === 'linux' && trust !== 'workspace' && !codexTrustedPerimeter(env)) {
|
|
230
252
|
if (hostUnconfined === true) return null;
|
|
@@ -254,10 +276,19 @@ export const hostSandboxRefusal = ({
|
|
|
254
276
|
}
|
|
255
277
|
if (mode === 'bwrap') {
|
|
256
278
|
const bwrap = detectBwrap();
|
|
257
|
-
if (bwrap.available)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
279
|
+
if (!bwrap.available) {
|
|
280
|
+
return bwrap.namespaceRefused === true
|
|
281
|
+
? bwrapRefusedMessage(adapterName, bwrap)
|
|
282
|
+
: `This seat runs in a bubblewrap sandbox, which is not available here. ${bwrap.error}`;
|
|
283
|
+
}
|
|
284
|
+
// A public OpenCode seat also raises a private loopback inside the sandbox.
|
|
285
|
+
// A host can start the namespace and refuse that, and every turn would then
|
|
286
|
+
// die at its first step while the pod heard nothing (F540).
|
|
287
|
+
if (adapterName === 'opencode' && sandbox.trust === 'public') {
|
|
288
|
+
const loopback = detectBwrapLoopback();
|
|
289
|
+
if (!loopback.available) return opencodeLoopbackMessage(loopback);
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
261
292
|
}
|
|
262
293
|
const seatbelt = detectSeatbelt();
|
|
263
294
|
return seatbelt.available
|
package/src/lib/session-store.js
CHANGED
|
@@ -32,7 +32,7 @@ const noticesFile = (agentName) => join(sessionsDir(), `${agentName}.notices.jso
|
|
|
32
32
|
const MAX_HANDLED_EVENTS = 500;
|
|
33
33
|
const handledEventsCache = new Map();
|
|
34
34
|
|
|
35
|
-
// Everything under ~/.commonly is private
|
|
35
|
+
// Everything under ~/.commonly is private. These files hold per-(agent,
|
|
36
36
|
// pod) session IDs and event rings; keep the dir and its files owner-only, and
|
|
37
37
|
// tighten an existing dir or file that a pre-0.1.309 CLI left group/world-
|
|
38
38
|
// readable. A mode arg applies only when the path is created, so each write
|
package/src/lib/update-check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* "Your CLI is N versions behind" — one line at `agent run` and `daemon run`
|
|
3
|
-
* start-up (TASK-660
|
|
3
|
+
* start-up (TASK-660).
|
|
4
4
|
*
|
|
5
5
|
* A seat pinned to an old CLI fails in ways that look like platform bugs, and
|
|
6
6
|
* nothing on the seat said it was old. This prints one line when the installed
|