@1agh/maude 2.2.1 → 2.3.2
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/apps/studio/acp/agents/auth.ts +241 -0
- package/apps/studio/acp/agents/catalog.ts +308 -0
- package/apps/studio/acp/agents/chat-key.ts +64 -0
- package/apps/studio/acp/agents/conformance.ts +1853 -0
- package/apps/studio/acp/agents/consent.ts +92 -0
- package/apps/studio/acp/agents/descriptor.ts +188 -0
- package/apps/studio/acp/agents/discover.ts +491 -0
- package/apps/studio/acp/agents/e2e-model.ts +58 -0
- package/apps/studio/acp/agents/health.ts +46 -0
- package/apps/studio/acp/agents/link-scan.ts +230 -0
- package/apps/studio/acp/agents/spawn.ts +164 -0
- package/apps/studio/acp/agents/state.ts +132 -0
- package/apps/studio/acp/ask-queue.ts +13 -4
- package/apps/studio/acp/bootstrap-brief.ts +16 -3
- package/apps/studio/acp/bridge.ts +709 -99
- package/apps/studio/acp/env.ts +43 -1
- package/apps/studio/acp/index.ts +428 -43
- package/apps/studio/acp/may-scope.ts +244 -21
- package/apps/studio/acp/policy/agent-home.ts +202 -0
- package/apps/studio/acp/policy/bridge-gate.ts +68 -0
- package/apps/studio/acp/policy/codex-home.ts +228 -0
- package/apps/studio/acp/policy/enforce.ts +620 -0
- package/apps/studio/acp/policy/gate-types.ts +41 -0
- package/apps/studio/acp/policy/launch-codex.ts +351 -0
- package/apps/studio/acp/policy/launch-copilot.ts +119 -0
- package/apps/studio/acp/policy/launch-gemini.ts +120 -0
- package/apps/studio/acp/policy/launch-opencode.ts +131 -0
- package/apps/studio/acp/policy/opencode-user-config.ts +240 -0
- package/apps/studio/acp/probe.ts +78 -14
- package/apps/studio/acp/transcript.ts +14 -0
- package/apps/studio/acp/write-scope.ts +62 -2
- package/apps/studio/annotations-layer.tsx +8 -0
- package/apps/studio/bin/_capture-init.js +5 -0
- package/apps/studio/bin/screenshot.sh +7 -1
- package/apps/studio/bridge/dgn-protocol.ts +3 -2
- package/apps/studio/canvas-shell.tsx +54 -0
- package/apps/studio/client/panels/ChatPanel.jsx +19 -4
- package/apps/studio/client/panels/PermissionPrompt.jsx +11 -6
- package/apps/studio/client/panels/SyncConsentDialog.jsx +4 -1
- package/apps/studio/client/panels/acp-runtime.js +95 -7
- package/apps/studio/client/v2/ai/Advanced.jsx +4 -3
- package/apps/studio/client/v2/ai/AgentNotice.jsx +138 -0
- package/apps/studio/client/v2/ai/AgentOffer.jsx +110 -0
- package/apps/studio/client/v2/ai/AgentPicker.jsx +121 -0
- package/apps/studio/client/v2/ai/Composer.jsx +4 -0
- package/apps/studio/client/v2/ai/ConnectSheet.jsx +13 -0
- package/apps/studio/client/v2/ai/Feed.jsx +8 -0
- package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +24 -1
- package/apps/studio/client/v2/ai/Suggest.jsx +5 -1
- package/apps/studio/client/v2/ai/advanced-model.js +17 -6
- package/apps/studio/client/v2/ai/agents-model.js +333 -0
- package/apps/studio/client/v2/ai/agents-store.js +223 -0
- package/apps/studio/client/v2/ai/ai.css +63 -0
- package/apps/studio/client/v2/ai/needs-you.js +1 -1
- package/apps/studio/client/v2/empty/empty-host.jsx +11 -2
- package/apps/studio/client/v2/empty/use-empty-canvas.js +22 -7
- package/apps/studio/client/v2/fold/fold-store.js +1 -0
- package/apps/studio/client/v2/preview/preview-chrome-host.jsx +1 -0
- package/apps/studio/client/v2/settings/agent-keys.js +88 -0
- package/apps/studio/client/v2/settings/agents-card.jsx +408 -0
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/settings/connections-section.jsx +4 -0
- package/apps/studio/client/v2/settings/settings-cards.js +2 -1
- package/apps/studio/client/v2/settings/settings-model.js +1 -0
- package/apps/studio/client/v2/settings/settings.css +7 -0
- package/apps/studio/client/v2/shell/served-routes.js +1 -0
- package/apps/studio/client/v2/undo/zoom-undo.jsx +19 -2
- package/apps/studio/cloud-build.ts +5 -0
- package/apps/studio/comments/reveal.ts +13 -0
- package/apps/studio/comments-overlay.tsx +36 -0
- package/apps/studio/dist/client.bundle.js +535 -535
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/annotation-count.ts +25 -0
- package/apps/studio/editing/empty-report.ts +8 -3
- package/apps/studio/editing/empty-reporter.tsx +10 -1
- package/apps/studio/generation/keys.ts +197 -11
- package/apps/studio/outbox/policy.ts +8 -2
- package/apps/studio/outbox/types.ts +5 -0
- package/apps/studio/routes/agents.ts +479 -0
- package/apps/studio/routes/index.ts +3 -0
- package/apps/studio/scripts/acp-conformance-local.ts +95 -0
- package/apps/studio/scripts/acp-e2e-local.ts +1026 -0
- package/apps/studio/server.ts +9 -0
- package/apps/studio/sync/index.ts +9 -1
- package/apps/studio/sync/writer-registry.ts +12 -0
- package/apps/studio/whats-new.json +19 -0
- package/apps/studio/ws.ts +3 -0
- package/cli/commands/codex.mjs +36 -2
- package/cli/lib/harness/codex-runtime.mjs +98 -11
- package/package.json +9 -8
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// F4 (B3) — Codex's launch policy: the agent-native boundary Maude writes per session.
|
|
2
|
+
// Contract: .ai/plans/notes/universal-acp-contract.md § "Launch policies" + DDR-252.
|
|
3
|
+
//
|
|
4
|
+
// codex-acp takes no CLI flags; everything rides env on the adapter:
|
|
5
|
+
// CODEX_PATH the user's own codex (realpath from discovery), never a bundled one
|
|
6
|
+
// INITIAL_AGENT_MODE workspace-write: the default `agent` mode hands escalations to Codex's own
|
|
7
|
+
// "Guardian" model reviewer and never asks the person
|
|
8
|
+
// CODEX_CONFIG a permission profile `maude` on top of `:workspace`. `:workspace` alone confines
|
|
9
|
+
// writes and network but NOT reads (codex-sandbox.txt: a credential outside the
|
|
10
|
+
// project was read). So the profile denies the user trees, re-allows each read
|
|
11
|
+
// root `read` and the scope + chat scratch `write`, and denies every credential
|
|
12
|
+
// store `none`. Seatbelt applies the most specific path, so a credential store
|
|
13
|
+
// inside a root stays denied (measured on 0.154 and 0.166, profile B).
|
|
14
|
+
// S1 (security review 2026-11-12): Codex's writes inside its workspace never
|
|
15
|
+
// reach Maude's write gate, so what the gate protects in a project is in the
|
|
16
|
+
// profile itself (`codexProtectedPaths` + `codexProtectedGlobs`), and the temp
|
|
17
|
+
// folders other chats and sessions use are denied (`systemDenies`).
|
|
18
|
+
//
|
|
19
|
+
// Network: stays off through the `:workspace` base (`networkAccess:false`), and Codex's own web
|
|
20
|
+
// search is removed with `web_search:"disabled"`. Both stay off when the person's "Search the web"
|
|
21
|
+
// switch is ON: Maude's web tools (`maude design fetch-asset` …) are separate and gated by the bridge;
|
|
22
|
+
// opening the sandbox's network or Codex's search would be a second, unaccounted egress path. The note
|
|
23
|
+
// reads "web off ↔ may.web" in one row and "web_search disabled" unconditionally in the policy; this
|
|
24
|
+
// takes the narrower reading.
|
|
25
|
+
//
|
|
26
|
+
// Pure: no file system, no process. The host (platform + home) is a parameter so tests stay exact.
|
|
27
|
+
|
|
28
|
+
import { realpathSync } from 'node:fs';
|
|
29
|
+
import { homedir, tmpdir } from 'node:os';
|
|
30
|
+
import { basename, dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
31
|
+
|
|
32
|
+
import { RUNTIME_STATE_DIRS, RUNTIME_STATE_FILES } from '../../sync/file-membership.ts';
|
|
33
|
+
import type { LaunchPolicy, PolicyCtx } from '../agents/descriptor.ts';
|
|
34
|
+
import { AGENT_RUNTIME_OUTPUTS, PROTECTED_IN_PROJECT, PROTECTED_PREFIXES } from '../write-scope.ts';
|
|
35
|
+
|
|
36
|
+
export type FsAccess = 'none' | 'read' | 'write';
|
|
37
|
+
|
|
38
|
+
export interface LaunchHost {
|
|
39
|
+
platform: NodeJS.Platform;
|
|
40
|
+
home: string;
|
|
41
|
+
/**
|
|
42
|
+
* S1 (A3) — this server's own temp folder, canonical (macOS: `/private/var/folders/<…>/T`). Every
|
|
43
|
+
* chat's scratch lives under it (`chatScratchDir`), so it is denied and the chat's own scratch is
|
|
44
|
+
* re-allowed. Omitted → only the fixed temp folders are denied.
|
|
45
|
+
*/
|
|
46
|
+
tmpdir?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function realTmpdir(): string | undefined {
|
|
50
|
+
try {
|
|
51
|
+
return realpathSync(tmpdir());
|
|
52
|
+
} catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function currentHost(): LaunchHost {
|
|
58
|
+
return { platform: process.platform, home: process.env.HOME || homedir(), tmpdir: realTmpdir() };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const DISK_ROOT = resolve(sep);
|
|
62
|
+
|
|
63
|
+
/** An absolute, normalised path (no trailing separator, no `..`); anything else throws. */
|
|
64
|
+
export function absPath(p: unknown, what: string): string {
|
|
65
|
+
if (typeof p !== 'string' || p.length === 0 || p.includes('\0') || !isAbsolute(p)) {
|
|
66
|
+
throw new Error(`launch policy: ${what} must be an absolute path, got ${JSON.stringify(p)}`);
|
|
67
|
+
}
|
|
68
|
+
return resolve(p);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A grant root: absolute, and never the disk root (a grant there would cancel every deny). */
|
|
72
|
+
export function rootPath(p: unknown, what: string): string {
|
|
73
|
+
const abs = absPath(p, what);
|
|
74
|
+
if (abs === DISK_ROOT) throw new Error(`launch policy: ${what} may not be the disk root`);
|
|
75
|
+
return abs;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const inside = (p: string, root: string) =>
|
|
79
|
+
p === root || p.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The folders that hold people's files, denied wholesale before the roots are re-allowed: the
|
|
83
|
+
* platform's user and volume trees, plus the parent of this home (any layout), or the home itself when
|
|
84
|
+
* it sits directly under the disk root (root's `/root`).
|
|
85
|
+
*/
|
|
86
|
+
export function userTrees(host: LaunchHost): string[] {
|
|
87
|
+
const out = new Set<string>();
|
|
88
|
+
if (host.platform === 'darwin') {
|
|
89
|
+
out.add('/Users');
|
|
90
|
+
out.add('/Volumes');
|
|
91
|
+
} else if (host.platform === 'linux') {
|
|
92
|
+
out.add('/home');
|
|
93
|
+
}
|
|
94
|
+
if (host.home && isAbsolute(host.home)) {
|
|
95
|
+
const home = resolve(host.home);
|
|
96
|
+
const parent = dirname(home);
|
|
97
|
+
if (home !== DISK_ROOT) out.add(parent === DISK_ROOT ? home : parent);
|
|
98
|
+
}
|
|
99
|
+
return [...out];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* S1 (attacker A3) — folders outside the user trees that `:workspace` would let Codex read: the
|
|
104
|
+
* temp folders other sessions and other chats write (`/private/tmp`: every Claude Code session's
|
|
105
|
+
* command output; this server's temp folder: every other chat's scratch) and the local databases a
|
|
106
|
+
* package manager keeps (`/opt/homebrew/var`, `/usr/local/var`). `none`; the chat's own scratch is a
|
|
107
|
+
* write root and so re-allowed (more specific). Codex itself runs outside the sandbox, and the
|
|
108
|
+
* commands it runs get the chat scratch as TMPDIR (spawn.ts), so they keep a writable temp folder
|
|
109
|
+
* (measured, S1: `scratch-write`).
|
|
110
|
+
*/
|
|
111
|
+
export function systemDenies(host: LaunchHost): string[] {
|
|
112
|
+
const out = new Set<string>();
|
|
113
|
+
if (host.platform === 'darwin') {
|
|
114
|
+
for (const p of ['/private/tmp', '/private/var/tmp', '/opt/homebrew/var', '/usr/local/var']) {
|
|
115
|
+
out.add(p);
|
|
116
|
+
}
|
|
117
|
+
} else if (host.platform === 'linux') {
|
|
118
|
+
for (const p of ['/tmp', '/var/tmp', '/usr/local/var']) out.add(p);
|
|
119
|
+
}
|
|
120
|
+
if (host.tmpdir && isAbsolute(host.tmpdir)) {
|
|
121
|
+
const t = resolve(host.tmpdir);
|
|
122
|
+
if (t !== DISK_ROOT && ![...out].some((o) => inside(t, o))) out.add(t);
|
|
123
|
+
}
|
|
124
|
+
return [...out];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* macOS spells `/var`, `/tmp` and `/etc` through symlinks into `/private`; Seatbelt matches the real
|
|
129
|
+
* path. A root given in the short spelling (`tmpdir()` → `/var/folders/…`, how `chatScratchDir`
|
|
130
|
+
* names the chat scratch) is granted in both, so a deny on the `/private` form never out-ranks it.
|
|
131
|
+
*/
|
|
132
|
+
export function spellings(p: string, host: LaunchHost): string[] {
|
|
133
|
+
if (host.platform !== 'darwin') return [p];
|
|
134
|
+
return /^\/(var|tmp|etc)(\/|$)/.test(p) ? [p, `/private${p}`] : [p];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* S1 (attacker A2) — in-project names that reach execution without a further agent action
|
|
139
|
+
* (write-scope.ts `PROTECTED_IN_PROJECT`, the bridge write gate's list). Codex's writes inside its
|
|
140
|
+
* workspace are never sent to that gate (`workspace-write` does not ask), so the profile itself
|
|
141
|
+
* denies them. The agent-config names S2 adds to `PROTECTED_IN_PROJECT` are named here as well, so
|
|
142
|
+
* the result does not depend on which change lands first.
|
|
143
|
+
*
|
|
144
|
+
* The root `.git` is NOT `none`: Codex's own `:workspace` protection keeps `.git` (and `.codex`,
|
|
145
|
+
* `.agents`) READ-ONLY at each workspace root (measured, S1, 0.154 / 0.165 / 0.166: a write to an
|
|
146
|
+
* existing `.git/config` and the creation of `.git/` both fail), and read-only is what Maude wants:
|
|
147
|
+
* `none` would stop `git status`. A NESTED `.git` (a submodule's) is `none` by glob
|
|
148
|
+
* (`codexProtectedGlobs`).
|
|
149
|
+
*/
|
|
150
|
+
export const CODEX_PROTECTED_NAMES: readonly string[] = [
|
|
151
|
+
...new Set([
|
|
152
|
+
...PROTECTED_IN_PROJECT.filter((n) => n !== '.git'),
|
|
153
|
+
'.claude',
|
|
154
|
+
'.mcp.json',
|
|
155
|
+
'.codex',
|
|
156
|
+
'.opencode',
|
|
157
|
+
'.gemini',
|
|
158
|
+
'AGENTS.md',
|
|
159
|
+
'opencode.json',
|
|
160
|
+
'opencode.jsonc',
|
|
161
|
+
]),
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
/** Protected multi-segment paths, root-level only (write-scope.ts `PROTECTED_PREFIXES`). */
|
|
165
|
+
export const CODEX_PROTECTED_PREFIXES: readonly string[] = [
|
|
166
|
+
...new Set([...PROTECTED_PREFIXES.map((p) => p.join(sep)), join('.ai', 'workflows.config.json')]),
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The absolute `none` entries for one root: each protected name and prefix right under it.
|
|
171
|
+
* Measured (S1): `none` stops a write to an existing file, a write into an existing folder and the
|
|
172
|
+
* creation of a missing one; `read` does NOT (codex-acp's `workspace-write` turn policy makes the cwd
|
|
173
|
+
* writable and out-ranks it, F6b). The cost: Codex cannot READ these either (no `package.json`, no
|
|
174
|
+
* `node_modules`, so no `npm` / `bun` scripts in the project; contract note "Security fixes S1").
|
|
175
|
+
*/
|
|
176
|
+
export function codexProtectedPaths(root: string): string[] {
|
|
177
|
+
return [...CODEX_PROTECTED_NAMES, ...CODEX_PROTECTED_PREFIXES].map((n) => join(root, n));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The same names at ANY depth, as `:workspace_roots` globs: the bridge gate matches a protected
|
|
182
|
+
* segment anywhere in a path (`sub/package.json`, `sub/.claude/…`). Both the name and its subtree:
|
|
183
|
+
* `**` + `/x` alone stops creating `x` but not a write into an existing `x/` (measured, S1). Seatbelt
|
|
184
|
+
* matches them when a file is created, not from a snapshot (measured on macOS: new nested files were
|
|
185
|
+
* refused). A nested `.git` is denied this way (at least one folder deep); the root one stays
|
|
186
|
+
* Codex's own read-only.
|
|
187
|
+
*/
|
|
188
|
+
export function codexProtectedGlobs(): Record<string, FsAccess> {
|
|
189
|
+
const out: Record<string, FsAccess> = {};
|
|
190
|
+
for (const n of CODEX_PROTECTED_NAMES) {
|
|
191
|
+
out[`**/${n}`] = 'none';
|
|
192
|
+
out[`**/${n}/**`] = 'none';
|
|
193
|
+
}
|
|
194
|
+
out['*/**/.git'] = 'none';
|
|
195
|
+
out['*/**/.git/**'] = 'none';
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* S1 (attacker A5) — each design root's root-level runtime FILES (`_server.json`, `_active.json`,
|
|
201
|
+
* `_sync.json`, … `RUNTIME_STATE_FILES`), named as exact files (Seatbelt takes a file path that does
|
|
202
|
+
* not exist yet: measured). `_active.json` steers the scope of the next `/design:edit`; `_server.json`
|
|
203
|
+
* tells the `maude design` verbs which server to talk to.
|
|
204
|
+
*/
|
|
205
|
+
export function runtimeStateFiles(
|
|
206
|
+
designRoots: readonly string[],
|
|
207
|
+
writeRoots: readonly string[]
|
|
208
|
+
): string[] {
|
|
209
|
+
const out = new Set<string>();
|
|
210
|
+
for (const d of designRoots) {
|
|
211
|
+
const root = absPath(d, 'design root');
|
|
212
|
+
if (!writeRoots.some((w) => inside(root, w))) continue;
|
|
213
|
+
for (const name of RUNTIME_STATE_FILES) out.add(join(root, `_${name}.json`));
|
|
214
|
+
}
|
|
215
|
+
return [...out];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* B3 — each design root's runtime-state folders (the DDR-115 taxonomy, `RUNTIME_STATE_DIRS`:
|
|
220
|
+
* `_canvas-state`, `_state`, `_chat`, `_comments`, `_untrusted`, `_history`, `_trash`, `_draw`,
|
|
221
|
+
* `_smoke`, …). Those the agent does not own are `none` inside the writable scope (see
|
|
222
|
+
* codexFilesystem): Codex never plants a chat transcript, a comment or a grant-adjacent state file.
|
|
223
|
+
* Only the top-level folders of each design root are named here; the root-level runtime FILES are
|
|
224
|
+
* `runtimeStateFiles` (S1, A5: the bridge's write gate never sees a Codex write inside its
|
|
225
|
+
* workspace, so the profile names them). A design root outside every write root is skipped: naming
|
|
226
|
+
* it would widen what Codex reads.
|
|
227
|
+
*/
|
|
228
|
+
export function runtimeStateDirs(
|
|
229
|
+
designRoots: readonly string[],
|
|
230
|
+
writeRoots: readonly string[]
|
|
231
|
+
): string[] {
|
|
232
|
+
const out = new Set<string>();
|
|
233
|
+
for (const d of designRoots) {
|
|
234
|
+
const root = absPath(d, 'design root');
|
|
235
|
+
if (!writeRoots.some((w) => inside(root, w))) continue;
|
|
236
|
+
for (const name of RUNTIME_STATE_DIRS) out.add(join(root, `_${name}`));
|
|
237
|
+
}
|
|
238
|
+
return [...out];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The `permissions.maude.filesystem` map (path → access), most specific path wins in Seatbelt. The
|
|
243
|
+
* `:workspace_roots` key holds the depth-independent protected-name globs (`codexProtectedGlobs`).
|
|
244
|
+
*/
|
|
245
|
+
export function codexFilesystem(
|
|
246
|
+
ctx: PolicyCtx,
|
|
247
|
+
host: LaunchHost = currentHost()
|
|
248
|
+
): Record<string, FsAccess | Record<string, FsAccess>> {
|
|
249
|
+
const creds = [
|
|
250
|
+
...ctx.credentialPaths.dirs.map((d) => absPath(d, 'credential dir')),
|
|
251
|
+
...ctx.credentialPaths.files.map((f) => absPath(f, 'credential file')),
|
|
252
|
+
];
|
|
253
|
+
const scope = rootPath(ctx.scopeRoot, 'scopeRoot');
|
|
254
|
+
const reads = ctx.readRoots.map((r) => rootPath(r, 'read root'));
|
|
255
|
+
const writes = [scope, ...ctx.writeRoots.map((r) => rootPath(r, 'write root'))];
|
|
256
|
+
// A grant inside (or on) a credential store would be MORE specific than its `none` and win: drop it.
|
|
257
|
+
const granted = (r: string) => !creds.some((c) => inside(r, c));
|
|
258
|
+
|
|
259
|
+
const fs = new Map<string, FsAccess>();
|
|
260
|
+
for (const t of userTrees(host)) fs.set(t, 'none');
|
|
261
|
+
for (const t of systemDenies(host)) fs.set(t, 'none');
|
|
262
|
+
for (const r of reads) if (granted(r)) for (const p of spellings(r, host)) fs.set(p, 'read');
|
|
263
|
+
for (const w of writes) if (granted(w)) for (const p of spellings(w, host)) fs.set(p, 'write');
|
|
264
|
+
// Runtime state the agent does not own is `none`. Measured (F6b, codex 0.154/0.165/0.166): a
|
|
265
|
+
// `read` entry inside a `write` root does NOT stop a write in Seatbelt, `none` does. The folders the
|
|
266
|
+
// agent may write for Claude too (`AGENT_RUNTIME_OUTPUTS`: _history, _draw, _smoke …) stay writable.
|
|
267
|
+
// A runtime folder that IS a write root (none today: the chat scratch lives in the temp folder) is
|
|
268
|
+
// left alone.
|
|
269
|
+
for (const r of runtimeStateDirs(ctx.designRoots, writes)) {
|
|
270
|
+
if (AGENT_RUNTIME_OUTPUTS.includes(basename(r))) continue;
|
|
271
|
+
if (granted(r) && fs.get(r) !== 'write') fs.set(r, 'none');
|
|
272
|
+
}
|
|
273
|
+
// S1 — the root-level runtime files (A5) and everything the bridge gate protects in a project
|
|
274
|
+
// (A2), under every write root and every design root inside one. A path that IS a write root keeps
|
|
275
|
+
// its `write` (none today).
|
|
276
|
+
const deny = (path: string) => {
|
|
277
|
+
for (const p of spellings(path, host)) if (fs.get(p) !== 'write') fs.set(p, 'none');
|
|
278
|
+
};
|
|
279
|
+
for (const f of runtimeStateFiles(ctx.designRoots, writes)) deny(f);
|
|
280
|
+
const designInside = ctx.designRoots
|
|
281
|
+
.map((d) => absPath(d, 'design root'))
|
|
282
|
+
.filter((d) => writes.some((w) => inside(d, w)));
|
|
283
|
+
for (const root of new Set([...writes, ...designInside])) {
|
|
284
|
+
for (const p of codexProtectedPaths(root)) deny(p);
|
|
285
|
+
}
|
|
286
|
+
for (const c of creds) fs.set(c, 'none');
|
|
287
|
+
return { ...Object.fromEntries(fs), ':workspace_roots': codexProtectedGlobs() };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* B7 (DDR-252) — the env Codex hands the commands it runs. A BYOK key rides Codex's own env
|
|
292
|
+
* (OPENAI_API_KEY, acp/agents/chat-key.ts) and must never reach a shell command the model writes.
|
|
293
|
+
* Codex's built-in excludes (`*KEY*`, `*TOKEN*`, applied unless `ignore_default_excludes`) would
|
|
294
|
+
* already drop it, but the default of that switch has moved between releases, so both are stated:
|
|
295
|
+
* the built-in filter on, plus every vendor-credential pattern named (case-insensitive globs, read by
|
|
296
|
+
* codex 0.154's ShellEnvironmentPolicyToml: inherit / ignore_default_excludes / exclude / set /
|
|
297
|
+
* include_only). Unit-tested (test/acp-chat-keys.test.ts); a live run is the conformance probe's job.
|
|
298
|
+
*/
|
|
299
|
+
export const CODEX_SHELL_ENV_POLICY = Object.freeze({
|
|
300
|
+
inherit: 'all',
|
|
301
|
+
ignore_default_excludes: false,
|
|
302
|
+
exclude: [
|
|
303
|
+
'OPENAI_*',
|
|
304
|
+
'CODEX_API_KEY',
|
|
305
|
+
'DEFAULT_AUTH_REQUEST',
|
|
306
|
+
'ANTHROPIC_*',
|
|
307
|
+
'GEMINI_*',
|
|
308
|
+
'GOOGLE_API_KEY',
|
|
309
|
+
'*_API_KEY',
|
|
310
|
+
'*KEY*',
|
|
311
|
+
'*TOKEN*',
|
|
312
|
+
'*SECRET*',
|
|
313
|
+
],
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
/** The CODEX_CONFIG object (serialised by the launch policy). */
|
|
317
|
+
export function codexConfig(ctx: PolicyCtx, host: LaunchHost = currentHost()) {
|
|
318
|
+
return {
|
|
319
|
+
web_search: 'disabled',
|
|
320
|
+
default_permissions: 'maude',
|
|
321
|
+
permissions: {
|
|
322
|
+
maude: { extends: ':workspace', filesystem: codexFilesystem(ctx, host) },
|
|
323
|
+
},
|
|
324
|
+
// B0 open question 3: these empty tables MERGE with the config.toml Codex reads (measured, F6),
|
|
325
|
+
// so they are not what keeps the person's MCP servers and hooks off: the Maude-owned CODEX_HOME is
|
|
326
|
+
// (codex-home.ts, F6b). Kept so a server the session config could add stays empty.
|
|
327
|
+
mcp_servers: {},
|
|
328
|
+
hooks: {},
|
|
329
|
+
shell_environment_policy: CODEX_SHELL_ENV_POLICY,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* `codexHome` (F6b): the Maude-owned CODEX_HOME (`ensureMaudeCodexHome`, codex-home.ts) — never the
|
|
335
|
+
* person's, whose config.toml / hooks.json would start their MCP servers and hooks outside the
|
|
336
|
+
* sandbox. Omitted only by the pure tests of the profile itself.
|
|
337
|
+
*/
|
|
338
|
+
export function codexLaunchPolicy(
|
|
339
|
+
ctx: PolicyCtx,
|
|
340
|
+
host: LaunchHost = currentHost(),
|
|
341
|
+
codexHome?: string
|
|
342
|
+
): LaunchPolicy {
|
|
343
|
+
return {
|
|
344
|
+
env: {
|
|
345
|
+
...(codexHome ? { CODEX_HOME: absPath(codexHome, 'codexHome') } : {}),
|
|
346
|
+
CODEX_PATH: absPath(ctx.agentBin, 'agentBin'),
|
|
347
|
+
INITIAL_AGENT_MODE: 'workspace-write',
|
|
348
|
+
CODEX_CONFIG: JSON.stringify(codexConfig(ctx, host)),
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// B8 — GitHub Copilot CLI's launch policy (`copilot --acp`): the agent-native boundary Maude writes
|
|
2
|
+
// per session. Contract: .ai/plans/notes/universal-acp-contract.md § "B8 — Gemini and Copilot".
|
|
3
|
+
//
|
|
4
|
+
// Copilot has no OS sandbox unless its own MXC sandbox is switched on; its permission engine is the
|
|
5
|
+
// boundary, the bridge's gate the second one (shellGate 'command-text', like opencode):
|
|
6
|
+
// • file tools are held to the working directory (+ the system temp folder, switched off with
|
|
7
|
+
// `--disallow-temp-dir`); anything else is a `session/request_permission` the gate judges;
|
|
8
|
+
// • every shell command and every write asks (no `--allow-*` flag, no allow-all), so each one
|
|
9
|
+
// reaches the gate;
|
|
10
|
+
// • `--deny-tool=url` refuses every URL a shell command or tool names, `--excluded-tools` removes
|
|
11
|
+
// the web tool, `--disable-builtin-mcps` removes GitHub's own MCP servers. Like Codex and
|
|
12
|
+
// opencode, web stays off even when the person's "Search the web" switch is on.
|
|
13
|
+
// • COPILOT_HOME is a Maude-owned folder (agent-home.ts): the person's mcp-config.json,
|
|
14
|
+
// settings.json hooks, plugins, skills, agents, trusted folders and saved URL / tool approvals
|
|
15
|
+
// never load. Maude's settings.json sets `disableAllHooks`.
|
|
16
|
+
// • the served repo's own Copilot config (repo settings / hooks / MCP / agents / skills) loads
|
|
17
|
+
// only for a trusted folder; Maude's home trusts none, and a project carrying any of it is
|
|
18
|
+
// refused anyway (fail closed).
|
|
19
|
+
//
|
|
20
|
+
// The pure builder takes the home path; `copilotLaunchPolicyFor` makes the home (impure).
|
|
21
|
+
|
|
22
|
+
import type { LaunchPolicy, PolicyCtx } from '../agents/descriptor.ts';
|
|
23
|
+
import {
|
|
24
|
+
ensureMaudeAgentHome,
|
|
25
|
+
type HostEnv,
|
|
26
|
+
refuseProjectEntries,
|
|
27
|
+
upToGitRoot,
|
|
28
|
+
} from './agent-home.ts';
|
|
29
|
+
import { absPath } from './launch-codex.ts';
|
|
30
|
+
|
|
31
|
+
export const COPILOT_HOME_NAME = 'copilot-home';
|
|
32
|
+
|
|
33
|
+
/** Tools removed from the model's list (web), whatever the person's switch says. */
|
|
34
|
+
export const COPILOT_EXCLUDED_TOOLS = ['web_fetch', 'web_search'] as const;
|
|
35
|
+
|
|
36
|
+
/** Maude's settings.json for the chat's Copilot. */
|
|
37
|
+
export const MAUDE_COPILOT_SETTINGS = {
|
|
38
|
+
disableAllHooks: true,
|
|
39
|
+
hooks: {},
|
|
40
|
+
trustedFolders: [],
|
|
41
|
+
allowedUrls: [],
|
|
42
|
+
autoUpdate: false,
|
|
43
|
+
sandbox: { enabled: false },
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
/** Copilot config the served repo can carry; any of them stops the spawn (see header). */
|
|
47
|
+
export const COPILOT_PROJECT_CONFIG = [
|
|
48
|
+
'.copilot',
|
|
49
|
+
'.github/copilot',
|
|
50
|
+
'.github/hooks',
|
|
51
|
+
'.github/mcp.json',
|
|
52
|
+
'.github/agents',
|
|
53
|
+
'.github/skills',
|
|
54
|
+
'.mcp.json',
|
|
55
|
+
] as const;
|
|
56
|
+
|
|
57
|
+
/** Config surfaces Copilot reads from its home that Maude never writes; removed at every spawn. */
|
|
58
|
+
export const COPILOT_HOME_FOREIGN = [
|
|
59
|
+
'hooks',
|
|
60
|
+
'agents',
|
|
61
|
+
'skills',
|
|
62
|
+
'plugins',
|
|
63
|
+
'installed-plugins',
|
|
64
|
+
'copilot-instructions.md',
|
|
65
|
+
'lsp-config.json',
|
|
66
|
+
] as const;
|
|
67
|
+
|
|
68
|
+
export function copilotArgs(): string[] {
|
|
69
|
+
return [
|
|
70
|
+
'--disable-builtin-mcps',
|
|
71
|
+
...COPILOT_EXCLUDED_TOOLS.map((t) => `--excluded-tools=${t}`),
|
|
72
|
+
'--deny-tool=url',
|
|
73
|
+
'--disallow-temp-dir',
|
|
74
|
+
'--no-auto-update',
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Pure: the policy for a session, given Maude's Copilot home. */
|
|
79
|
+
export function copilotLaunchPolicy(ctx: PolicyCtx, copilotHome: string): LaunchPolicy {
|
|
80
|
+
absPath(ctx.scopeRoot, 'scopeRoot');
|
|
81
|
+
for (const w of ctx.writeRoots) absPath(w, 'write root');
|
|
82
|
+
absPath(copilotHome, 'copilot home');
|
|
83
|
+
return {
|
|
84
|
+
env: { COPILOT_HOME: copilotHome, COPILOT_AUTO_UPDATE: 'false' },
|
|
85
|
+
args: copilotArgs(),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Throws when the session folder, or any folder above it up to its git root, carries Copilot config
|
|
91
|
+
* (COPILOT_PROJECT_CONFIG). Measured on 1.0.105 (contract note "B8"): a hook in the repo's hooks
|
|
92
|
+
* folder ran in an UNTRUSTED folder, and also from the git root above the session folder.
|
|
93
|
+
*/
|
|
94
|
+
export function refuseProjectCopilotConfig(projectRoot: string): void {
|
|
95
|
+
for (const dir of upToGitRoot(projectRoot)) {
|
|
96
|
+
refuseProjectEntries(dir, COPILOT_PROJECT_CONFIG, 'Copilot');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Make (or repair) Maude's Copilot home and return its path (impure). */
|
|
101
|
+
export function ensureMaudeCopilotHome(env: HostEnv = process.env): string {
|
|
102
|
+
return ensureMaudeAgentHome(
|
|
103
|
+
{
|
|
104
|
+
name: COPILOT_HOME_NAME,
|
|
105
|
+
foreign: COPILOT_HOME_FOREIGN,
|
|
106
|
+
files: {
|
|
107
|
+
'settings.json': `${JSON.stringify(MAUDE_COPILOT_SETTINGS, null, 2)}\n`,
|
|
108
|
+
'mcp-config.json': `${JSON.stringify({ mcpServers: {} })}\n`,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
env
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The enforcement's launch policy: refuse project config, make the home, build the policy. */
|
|
116
|
+
export function copilotLaunchPolicyFor(ctx: PolicyCtx): LaunchPolicy {
|
|
117
|
+
refuseProjectCopilotConfig(ctx.scopeRoot);
|
|
118
|
+
return copilotLaunchPolicy(ctx, ensureMaudeCopilotHome(ctx.hostEnv ?? process.env));
|
|
119
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// B8 — Gemini CLI's launch policy (`gemini --acp`): the agent-native boundary Maude writes per
|
|
2
|
+
// session. Contract: .ai/plans/notes/universal-acp-contract.md § "B8 — Gemini and Copilot".
|
|
3
|
+
//
|
|
4
|
+
// Gemini has no OS sandbox by default (`-s` re-runs the whole CLI under a Seatbelt profile that
|
|
5
|
+
// confines writes, not reads, and whose custom profiles come from the PROJECT's `.gemini/`: not
|
|
6
|
+
// used). Its own engine is the boundary, the bridge's gate the second one (shellGate
|
|
7
|
+
// 'command-text', like opencode):
|
|
8
|
+
// • file tools are held to the workspace (the session folder); a path outside is refused by
|
|
9
|
+
// Gemini itself;
|
|
10
|
+
// • approval mode is pinned to `default` (every shell command and write asks); `yolo` and
|
|
11
|
+
// `autoEdit` are refused by the bridge and switched off in settings (`disableYoloMode`,
|
|
12
|
+
// `disableAlwaysAllow`);
|
|
13
|
+
// • GEMINI_CLI_HOME is a Maude-owned folder (agent-home.ts): the person's `~/.gemini/settings.json`
|
|
14
|
+
// (MCP servers, hooks, allowed tools), extensions, skills, agents, policies and trusted folders
|
|
15
|
+
// never load. Maude's settings go in BOTH the user settings of that home and the SYSTEM settings
|
|
16
|
+
// file (GEMINI_CLI_SYSTEM_SETTINGS_PATH, the highest-precedence layer): MCP, extensions, skills
|
|
17
|
+
// and hooks off, the web tools excluded, folder trust on;
|
|
18
|
+
// • the served repo's own `.gemini/` (workspace settings, commands, policies, hooks, MCP servers)
|
|
19
|
+
// loads only for a TRUSTED folder, and nothing makes it trusted: folder trust is on in the
|
|
20
|
+
// system layer (a workspace file cannot switch it off), Maude's home has no trustedFolders.json
|
|
21
|
+
// (removed at every spawn), GEMINI_CLI_TRUST_WORKSPACE is scrubbed with every GEMINI_* name and
|
|
22
|
+
// `--skip-trust` is never passed. Measured on 0.66 (contract note "B8"): a project and a git-root
|
|
23
|
+
// `.gemini/` with MCP servers, hooks, `tools.allowed`, a policy allowing the shell and
|
|
24
|
+
// `folderTrust.enabled:false` changed nothing. The conformance probe plants exactly that on
|
|
25
|
+
// every run, so a version that starts trusting the folder fails the probe. Not refused: many
|
|
26
|
+
// repositories carry a `.gemini/` for Gemini Code Assist.
|
|
27
|
+
//
|
|
28
|
+
// The pure builder takes the home path; `geminiLaunchPolicyFor` makes the home (impure).
|
|
29
|
+
|
|
30
|
+
import { join } from 'node:path';
|
|
31
|
+
|
|
32
|
+
import type { LaunchPolicy, PolicyCtx } from '../agents/descriptor.ts';
|
|
33
|
+
import { ensureMaudeAgentHome, type HostEnv, homeOf } from './agent-home.ts';
|
|
34
|
+
import { absPath } from './launch-codex.ts';
|
|
35
|
+
|
|
36
|
+
export const GEMINI_HOME_NAME = 'gemini-home';
|
|
37
|
+
|
|
38
|
+
/** Web tools removed from the model's list, whatever the person's switch says. */
|
|
39
|
+
export const GEMINI_EXCLUDED_TOOLS = ['web_fetch', 'google_web_search'] as const;
|
|
40
|
+
|
|
41
|
+
/** The settings Maude writes (user settings of its home AND the system settings layer). */
|
|
42
|
+
export function geminiSettings() {
|
|
43
|
+
return {
|
|
44
|
+
general: { disableAutoUpdate: true, disableUpdateNag: true },
|
|
45
|
+
privacy: { usageStatisticsEnabled: false },
|
|
46
|
+
tools: { exclude: [...GEMINI_EXCLUDED_TOOLS], sandbox: false },
|
|
47
|
+
mcpServers: {},
|
|
48
|
+
hooks: {},
|
|
49
|
+
hooksConfig: { enabled: false },
|
|
50
|
+
security: {
|
|
51
|
+
folderTrust: { enabled: true },
|
|
52
|
+
disableYoloMode: true,
|
|
53
|
+
disableAlwaysAllow: true,
|
|
54
|
+
},
|
|
55
|
+
admin: {
|
|
56
|
+
mcp: { enabled: false },
|
|
57
|
+
extensions: { enabled: false },
|
|
58
|
+
skills: { enabled: false },
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Config surfaces Gemini reads from its home that Maude never writes; removed at every spawn. */
|
|
64
|
+
export const GEMINI_HOME_FOREIGN = [
|
|
65
|
+
'.gemini/extensions',
|
|
66
|
+
'.gemini/commands',
|
|
67
|
+
'.gemini/policies',
|
|
68
|
+
'.gemini/agents',
|
|
69
|
+
'.gemini/skills',
|
|
70
|
+
'.gemini/GEMINI.md',
|
|
71
|
+
'.gemini/trustedFolders.json',
|
|
72
|
+
'.gemini/.env',
|
|
73
|
+
'.agents',
|
|
74
|
+
'.env',
|
|
75
|
+
] as const;
|
|
76
|
+
|
|
77
|
+
/** Pure: the policy for a session, given Maude's Gemini home (GEMINI_CLI_HOME). */
|
|
78
|
+
export function geminiLaunchPolicy(ctx: PolicyCtx, geminiHome: string): LaunchPolicy {
|
|
79
|
+
absPath(ctx.scopeRoot, 'scopeRoot');
|
|
80
|
+
for (const w of ctx.writeRoots) absPath(w, 'write root');
|
|
81
|
+
absPath(geminiHome, 'gemini home');
|
|
82
|
+
return {
|
|
83
|
+
env: {
|
|
84
|
+
GEMINI_CLI_HOME: geminiHome,
|
|
85
|
+
GEMINI_CLI_SYSTEM_SETTINGS_PATH: join(geminiHome, 'system-settings.json'),
|
|
86
|
+
},
|
|
87
|
+
args: ['--approval-mode', 'default'],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The person's own `~/.gemini` (honouring their GEMINI_CLI_HOME). */
|
|
92
|
+
export function personGeminiDir(env: HostEnv = process.env): string {
|
|
93
|
+
const h = env.GEMINI_CLI_HOME;
|
|
94
|
+
return join(h?.startsWith('/') ? h : homeOf(env), '.gemini');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Make (or repair) Maude's Gemini home and return its path (impure). */
|
|
98
|
+
export function ensureMaudeGeminiHome(env: HostEnv = process.env): string {
|
|
99
|
+
const settings = `${JSON.stringify(geminiSettings(), null, 2)}\n`;
|
|
100
|
+
const person = personGeminiDir(env);
|
|
101
|
+
return ensureMaudeAgentHome(
|
|
102
|
+
{
|
|
103
|
+
name: GEMINI_HOME_NAME,
|
|
104
|
+
foreign: GEMINI_HOME_FOREIGN,
|
|
105
|
+
// Sign-in: the person's Google login is shared through links (an API key comes from the
|
|
106
|
+
// chat key store, B7). Everything else in their ~/.gemini stays out.
|
|
107
|
+
links: {
|
|
108
|
+
'.gemini/oauth_creds.json': join(person, 'oauth_creds.json'),
|
|
109
|
+
'.gemini/google_accounts.json': join(person, 'google_accounts.json'),
|
|
110
|
+
},
|
|
111
|
+
files: { '.gemini/settings.json': settings, 'system-settings.json': settings },
|
|
112
|
+
},
|
|
113
|
+
env
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The enforcement's launch policy: make the home, build the policy. */
|
|
118
|
+
export function geminiLaunchPolicyFor(ctx: PolicyCtx): LaunchPolicy {
|
|
119
|
+
return geminiLaunchPolicy(ctx, ensureMaudeGeminiHome(ctx.hostEnv ?? process.env));
|
|
120
|
+
}
|