@jbkjr/relay 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +201 -0
- package/LICENSES/README.md +19 -0
- package/LICENSES/codex-NOTICE.txt +6 -0
- package/README.md +393 -2
- package/SECURITY.md +145 -0
- package/adapters/briefs/claude.md +43 -0
- package/adapters/briefs/codex.md +56 -0
- package/adapters/briefs/models.json +33 -0
- package/adapters/build.mjs +8 -0
- package/adapters/claude/.claude-plugin/marketplace.json +13 -0
- package/adapters/claude/relay/.claude-plugin/plugin.json +5 -0
- package/adapters/claude/relay/agents/codex.md +21 -0
- package/adapters/claude/relay/agents/operator.md +21 -0
- package/adapters/claude/relay/skills/ask/SKILL.md +20 -0
- package/adapters/claude/relay/skills/chat/SKILL.md +13 -0
- package/adapters/claude/relay/skills/delegate/SKILL.md +21 -0
- package/adapters/claude/relay/skills/discuss/SKILL.md +19 -0
- package/adapters/claude/relay/skills/review/SKILL.md +21 -0
- package/adapters/claude/relay/skills/tree/SKILL.md +10 -0
- package/adapters/claude/relay/skills/write-for-codex/SKILL.md +78 -0
- package/adapters/codex/.agents/plugins/marketplace.json +20 -0
- package/adapters/codex/AGENTS.snippet.md +5 -0
- package/adapters/codex/relay/.codex-plugin/plugin.json +6 -0
- package/adapters/codex/relay/skills/relay-ask/SKILL.md +20 -0
- package/adapters/codex/relay/skills/relay-chat/SKILL.md +13 -0
- package/adapters/codex/relay/skills/relay-delegate/SKILL.md +21 -0
- package/adapters/codex/relay/skills/relay-discuss/SKILL.md +19 -0
- package/adapters/codex/relay/skills/relay-review/SKILL.md +21 -0
- package/adapters/codex/relay/skills/relay-tree/SKILL.md +10 -0
- package/adapters/codex/relay/skills/relay-write-for-claude/SKILL.md +66 -0
- package/adapters/generate.mjs +124 -0
- package/bin/relay +59 -0
- package/codex-pin.json +12 -0
- package/dist/backends/acp.js +1424 -0
- package/dist/backends/claude.js +890 -0
- package/dist/backends/cli-version.js +112 -0
- package/dist/backends/codex-app.js +1539 -0
- package/dist/backends/codex-daybreak.js +75 -0
- package/dist/backends/codex-env.js +656 -0
- package/dist/backends/codex-network.js +304 -0
- package/dist/backends/codex-pin.js +345 -0
- package/dist/backends/codex-shell-policy.js +182 -0
- package/dist/backends/codex-stage2.js +998 -0
- package/dist/backends/codex-subagents.js +47 -0
- package/dist/backends/codex.js +641 -0
- package/dist/backends/copilot.js +246 -0
- package/dist/backends/env.js +147 -0
- package/dist/backends/gemini.js +607 -0
- package/dist/backends/grok.js +337 -0
- package/dist/backends/index.js +8 -0
- package/dist/backends/native-temp.js +187 -0
- package/dist/backends/never-admission.js +90 -0
- package/dist/backends/run.js +67 -0
- package/dist/backends/stream.js +230 -0
- package/dist/backends/tool-discovery.js +15 -0
- package/dist/backends/types.js +264 -0
- package/dist/build-info.json +5 -0
- package/dist/cli.js +344 -0
- package/dist/confine/bridge.js +113 -0
- package/dist/confine/broker-core.js +76 -0
- package/dist/confine/broker-http.js +650 -0
- package/dist/confine/broker-names.js +9 -0
- package/dist/confine/broker.js +258 -0
- package/dist/confine/canary.js +380 -0
- package/dist/confine/diagnostics.js +122 -0
- package/dist/confine/gemini-tools-main.js +8 -0
- package/dist/confine/gemini-tools.js +181 -0
- package/dist/confine/hardlinks.js +58 -0
- package/dist/confine/harness-config.js +16 -0
- package/dist/confine/index.js +117 -0
- package/dist/confine/leases.js +217 -0
- package/dist/confine/paths.js +6 -0
- package/dist/confine/peer.js +115 -0
- package/dist/confine/port-policy.js +8 -0
- package/dist/confine/ports.js +365 -0
- package/dist/confine/private-root.js +208 -0
- package/dist/confine/probe-stage2.js +501 -0
- package/dist/confine/probe.js +1109 -0
- package/dist/confine/proxy.js +783 -0
- package/dist/confine/sbcheck.js +208 -0
- package/dist/confine/seatbelt-never.js +41 -0
- package/dist/confine/seatbelt-stage2.js +139 -0
- package/dist/confine/seatbelt.js +1129 -0
- package/dist/confine/sockets.js +36 -0
- package/dist/confine/turn-probe.js +19 -0
- package/dist/confine/turn.js +86 -0
- package/dist/core/adoption.js +124 -0
- package/dist/core/api-keys.js +423 -0
- package/dist/core/approvals.js +740 -0
- package/dist/core/build-identity.js +248 -0
- package/dist/core/caller.js +749 -0
- package/dist/core/calls.js +102 -0
- package/dist/core/claude-settings.js +1045 -0
- package/dist/core/config.js +453 -0
- package/dist/core/context.js +186 -0
- package/dist/core/db.js +753 -0
- package/dist/core/dispatch.js +110 -0
- package/dist/core/env-broker.js +505 -0
- package/dist/core/env-policy.js +182 -0
- package/dist/core/escalation-authority.js +76 -0
- package/dist/core/escalation-contract.js +13 -0
- package/dist/core/escalation-person-path.js +131 -0
- package/dist/core/escalation-policy.js +79 -0
- package/dist/core/escalation-runtime.js +135 -0
- package/dist/core/escalation-state.js +42 -0
- package/dist/core/escalations.js +191 -0
- package/dist/core/events.js +235 -0
- package/dist/core/executables.js +147 -0
- package/dist/core/extensions.js +645 -0
- package/dist/core/families.js +204 -0
- package/dist/core/git.js +657 -0
- package/dist/core/identity.js +113 -0
- package/dist/core/liveness.js +68 -0
- package/dist/core/mediated-network-provider.js +81 -0
- package/dist/core/never-checkpoint.js +76 -0
- package/dist/core/never-coverage.js +97 -0
- package/dist/core/never-network.js +49 -0
- package/dist/core/never-policy.js +302 -0
- package/dist/core/never-proxy-policy.js +109 -0
- package/dist/core/never-schema.js +61 -0
- package/dist/core/never-tools.js +56 -0
- package/dist/core/notices.js +48 -0
- package/dist/core/ops.js +959 -0
- package/dist/core/outcome.js +224 -0
- package/dist/core/params.js +32 -0
- package/dist/core/presence.js +174 -0
- package/dist/core/procs.js +546 -0
- package/dist/core/prompts.js +363 -0
- package/dist/core/protected-config.js +238 -0
- package/dist/core/raw-network.js +192 -0
- package/dist/core/redact.js +152 -0
- package/dist/core/refusal.js +33 -0
- package/dist/core/relay-command.js +310 -0
- package/dist/core/reported.js +3 -0
- package/dist/core/restart-overlay.js +651 -0
- package/dist/core/retention.js +1135 -0
- package/dist/core/secrets.js +329 -0
- package/dist/core/session-token.js +175 -0
- package/dist/core/session.js +744 -0
- package/dist/core/shell.js +2 -0
- package/dist/core/shipped-pin.js +47 -0
- package/dist/core/shown.js +42 -0
- package/dist/core/slots.js +67 -0
- package/dist/core/stage2-executors.js +453 -0
- package/dist/core/stage2-switch.js +5 -0
- package/dist/core/steering.js +149 -0
- package/dist/core/storage.js +358 -0
- package/dist/core/toml.js +175 -0
- package/dist/core/views.js +324 -0
- package/dist/core/wait.js +114 -0
- package/dist/core/wake.js +207 -0
- package/dist/core/watch.js +247 -0
- package/dist/core/worktree.js +213 -0
- package/dist/hosts/claude-desktop.js +274 -0
- package/dist/hosts/claude.js +249 -0
- package/dist/hosts/codex.js +345 -0
- package/dist/hosts/desktop-shared.js +20 -0
- package/dist/hosts/index.js +11 -0
- package/dist/hosts/types.js +4 -0
- package/dist/install/basics.js +18 -0
- package/dist/install/claude-init.js +133 -0
- package/dist/install/common.js +655 -0
- package/dist/install/doctor.js +635 -0
- package/dist/install/qualify-codex.js +205 -0
- package/dist/install.js +524 -0
- package/dist/mcp/elicit.js +209 -0
- package/dist/mcp/gateway.js +218 -0
- package/dist/mcp/host.js +253 -0
- package/dist/mcp/server.js +1124 -0
- package/dist/mcp/stdio.js +37 -0
- package/dist/modes/discussion.js +393 -0
- package/dist/modes/review.js +722 -0
- package/dist/native/relay-sbcheck +0 -0
- package/dist/targets/briefs.js +86 -0
- package/dist/targets/claude.js +94 -0
- package/dist/targets/codex.js +66 -0
- package/dist/targets/copilot.js +93 -0
- package/dist/targets/gemini.js +119 -0
- package/dist/targets/grok.js +126 -0
- package/dist/targets/index.js +192 -0
- package/dist/targets/types.js +18 -0
- package/dist/targets/verified.js +35 -0
- package/dist/worker.js +113 -0
- package/docs/UPGRADING.md +1518 -0
- package/docs/pinned-codex.md +333 -0
- package/experiments/stage2-redteam/lib/oracles.mjs +214 -0
- package/experiments/stage2-redteam/lib/report.mjs +35 -0
- package/npm-shrinkwrap.json +1632 -0
- package/package.json +82 -4
- package/scripts/codex-qualify/codex-pin-store.mjs +353 -0
- package/scripts/codex-qualify/codex-qualifier-process.mjs +265 -0
- package/scripts/codex-qualify/codex-qualifier.example.json +5 -0
- package/scripts/codex-qualify/codex-qualifier.mjs +281 -0
- package/scripts/codex-qualify/codex-shipped-pin.mjs +158 -0
- package/scripts/codex-qualify/codex-stage2-pin.mjs +48 -0
- package/scripts/codex-qualify/codex-stage2.mjs +2381 -0
- package/scripts/codex-qualify/install-codex-qualifier.mjs +98 -0
- package/scripts/codex-qualify/main-module.mjs +14 -0
- package/scripts/codex-qualify/relay-codex-qualifier.plist +37 -0
- package/scripts/codex-qualify/scratch-env.mjs +31 -0
- package/scripts/codex-qualify/session.mjs +96 -0
- package/scripts/codex-qualify/stage2-escalation-cases.mjs +125 -0
- package/test/codex-permissions.test.ts +875 -0
- package/test/fixtures/boundary-probes.mjs +17 -0
- package/test/fixtures/denial-stream-host.mjs +7 -0
- package/test/fixtures/families.json +246 -0
- package/test/fixtures/install-snapshots/claude-desktop-foreign.txt +158 -0
- package/test/fixtures/install-snapshots/claude-desktop-fresh.txt +101 -0
- package/test/fixtures/install-snapshots/claude-desktop-installed.txt +161 -0
- package/test/fixtures/install-snapshots/claude-foreign.txt +133 -0
- package/test/fixtures/install-snapshots/claude-fresh.txt +77 -0
- package/test/fixtures/install-snapshots/claude-installed.txt +133 -0
- package/test/fixtures/install-snapshots/codex-foreign.txt +159 -0
- package/test/fixtures/install-snapshots/codex-fresh.txt +107 -0
- package/test/fixtures/install-snapshots/codex-installed.txt +161 -0
- package/test/fixtures/link-parent.mjs +6 -0
- package/test/fixtures/mediated-command.cjs +72 -0
- package/test/fixtures/native-skill-isolation.json +280 -0
- package/test/fixtures/pinned-codex-app-server.mjs +25 -0
- package/test/fixtures/qualified-ext-adapters.mjs +36 -0
- package/test/fixtures/refusals/README.md +52 -0
- package/test/fixtures/refusals/claude-source-result.json +7 -0
- package/test/fixtures/refusals/openai-app-capacity.json +24 -0
- package/test/fixtures/refusals/openai-app-cyberPolicy.json +24 -0
- package/test/fixtures/refusals/openai-gpt-6-astra-max.json +12 -0
- package/test/fixtures/refusals/openai-gpt-6.1-sol-xhigh.json +12 -0
- package/test/fixtures/refusals/openai-review-capacity.json +24 -0
- package/test/fixtures/relay-0.2.0.sql +57 -0
- package/test/fixtures/relay-0.9.1.gen.mjs +212 -0
- package/test/fixtures/relay-0.9.1.sql +340 -0
- package/test/fixtures/slow-boundary-probes.mjs +37 -0
- package/test/fixtures/stable-surfaces/config.json +1122 -0
- package/test/fixtures/stable-surfaces/escalation.json +128 -0
- package/test/fixtures/stable-surfaces/events.json +37 -0
- package/test/fixtures/stable-surfaces/gemini-native-resume.json +4 -0
- package/test/fixtures/stable-surfaces/inbox.jsonl +2 -0
- package/test/fixtures/stable-surfaces/notice.txt +1 -0
- package/test/fixtures/stable-surfaces/refusal-item.json +28 -0
- package/test/fixtures/stable-surfaces/refusal-review.json +23 -0
- package/test/fixtures/stable-surfaces/registry.json +49 -0
- package/test/fixtures/stable-surfaces/tools-desktop.json +575 -0
- package/test/fixtures/stable-surfaces/tools.json +716 -0
- package/test/fixtures/stable-surfaces/usage.txt +46 -0
- package/test/fixtures/stage2-acp-native.mjs +138 -0
- package/test/fixtures/stage2-app-server.mjs +23 -0
- package/test/fixtures/stage2-catalog.json +91 -0
- package/test/fixtures/stage2-hostile-web.mjs +35 -0
- package/test/fixtures/stage2-native-network.mjs +62 -0
- package/test/fixtures/stage2-worker.ts +87 -0
- package/test/fixtures/status-views/expected.json +7825 -0
- package/test/fixtures/status-views/registries.json +1 -0
- package/test/fixtures/steering.json +209 -0
- package/test/helpers.ts +740 -0
- package/test/host-env.ts +7 -0
- package/test/keychain-decoy.ts +197 -0
- package/test/live-scope.ts +44 -0
- package/test/mediated-network.test.ts +192 -0
- package/test/mediated-proxy.test.ts +264 -0
- package/test/native-temp-alias.ts +10 -0
- package/test/never-policy.test.ts +629 -0
- package/test/never-tools.test.ts +136 -0
- package/test/process-home.ts +18 -0
- package/test/proxy.test.ts +531 -0
- package/test/restart-overlay-live.test.ts +85 -0
- package/test/restart-overlay-profile.test.ts +66 -0
- package/test/restart-overlay.test.ts +416 -0
- package/test/stable-surfaces.test.ts +249 -0
- package/test/stage2-escalation-live.test.ts +544 -0
- package/test/stage2-escalation-qualification.test.ts +170 -0
- package/test/stage2-escalation.test.ts +747 -0
- package/test/stage2-executor.test.ts +849 -0
- package/test/stage2-grant.test.ts +603 -0
- package/test/stage2-native-live.test.ts +647 -0
- package/test/stage2-network-decisions.test.ts +70 -0
- package/test/stage2-probe.test.ts +845 -0
- package/test/stage2-standing-live.test.ts +203 -0
- package/test/stubs/broker-host.mjs +59 -0
- package/test/stubs/broker-peer.mjs +20 -0
- package/test/stubs/confined-harness.mjs +91 -0
- package/test/stubs/ext-broken-server.mjs +2 -0
- package/test/stubs/ext-odd-server.mjs +21 -0
- package/test/stubs/ext-server.mjs +31 -0
- package/test/stubs/fake-host-cli.mjs +218 -0
- package/test/stubs/procargs.mjs +30 -0
- package/test/stubs/stub-acp +4 -0
- package/test/stubs/stub-agent.mjs +322 -0
- package/test/stubs/stub-claude +4 -0
- package/test/stubs/stub-codex +4 -0
- package/test/stubs/targets/acp.mjs +307 -0
- package/test/stubs/targets/claude.mjs +149 -0
- package/test/stubs/targets/codex.mjs +479 -0
- package/test/stubs/targets/gemini.mjs +604 -0
- package/test/temp-root.ts +11 -0
- package/test/wp4-adapters.test.ts +353 -0
- package/test/wp4-interlock.test.ts +136 -0
|
Binary file
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The prompting briefs: for each target, how to write it a task or question so it does its best
|
|
2
|
+
// work, written by that target's own family (adapters/briefs/<target>.md). The model notes, which
|
|
3
|
+
// go stale when a family ships a new model, are kept apart in adapters/briefs/models.json with the
|
|
4
|
+
// date and harness version they were checked with. The generated skills, the brief tool and
|
|
5
|
+
// doctor all read them from here.
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { olderVersion, targetLabel, TARGETS, TESTED, versionOf } from "./index.js";
|
|
9
|
+
/** adapters/briefs in this checkout. */
|
|
10
|
+
export const BRIEFS_DIR = path.resolve(import.meta.dirname, "..", "..", "adapters", "briefs");
|
|
11
|
+
const isStrings = (v) => Array.isArray(v) && v.length > 0 && v.every((x) => typeof x === "string" && x.trim() !== "");
|
|
12
|
+
/**
|
|
13
|
+
* The brief and model notes for each target that has them, checked. The notes must have been
|
|
14
|
+
* checked with at least the version relay's confinement was last checked with (TESTED): raising
|
|
15
|
+
* that version means checking the notes again. Anything wrong is thrown.
|
|
16
|
+
*/
|
|
17
|
+
export function loadBriefs(dir = BRIEFS_DIR) {
|
|
18
|
+
const models = JSON.parse(fs.readFileSync(path.join(dir, "models.json"), "utf8"));
|
|
19
|
+
const out = {};
|
|
20
|
+
for (const t of TARGETS) {
|
|
21
|
+
const file = path.join(dir, `${t.id}.md`);
|
|
22
|
+
if (!fs.existsSync(file) && !(t.id in models))
|
|
23
|
+
continue;
|
|
24
|
+
const brief = fs.existsSync(file) ? fs.readFileSync(file, "utf8").trim() : "";
|
|
25
|
+
if (!brief)
|
|
26
|
+
throw new Error(`no prompting brief for ${t.id}: write briefs/${t.id}.md`);
|
|
27
|
+
const m = models[t.id];
|
|
28
|
+
const where = `briefs/models.json ${t.id}`;
|
|
29
|
+
if (!m || typeof m !== "object")
|
|
30
|
+
throw new Error(`no model notes for ${t.id} in briefs/models.json`);
|
|
31
|
+
// A real calendar date: Date would turn 2026-02-30 into March 2.
|
|
32
|
+
const day = typeof m.checked === "string" && /^\d{4}-\d{2}-\d{2}$/.test(m.checked) ? new Date(`${m.checked}T00:00:00Z`) : null;
|
|
33
|
+
if (!day || Number.isNaN(day.getTime()) || day.toISOString().slice(0, 10) !== m.checked)
|
|
34
|
+
throw new Error(`${where}: checked must be a date, YYYY-MM-DD`);
|
|
35
|
+
const seen = versionOf(m.checked_with);
|
|
36
|
+
if (typeof m.checked_with !== "string" || !seen)
|
|
37
|
+
throw new Error(`${where}: checked_with must name the harness version the notes were checked with`);
|
|
38
|
+
if (olderVersion(seen, TESTED[t.id])) {
|
|
39
|
+
throw new Error(`${where}: the notes were checked with ${seen.join(".")}, older than the ${TESTED[t.id].join(".")} relay is tested with; check them again`);
|
|
40
|
+
}
|
|
41
|
+
for (const key of ["effort", "notes", "sources"])
|
|
42
|
+
if (!isStrings(m[key]))
|
|
43
|
+
throw new Error(`${where}: ${key} must be a list of strings`);
|
|
44
|
+
if (!m.sources.every((u) => u.startsWith("https://")))
|
|
45
|
+
throw new Error(`${where}: sources must be https URLs`);
|
|
46
|
+
out[t.id] = { brief, models: m };
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
/** The text of `t`'s brief as an agent reads it, in a skill or from the brief tool. */
|
|
51
|
+
export function briefText(t, { brief, models }) {
|
|
52
|
+
return `## Writing for ${targetLabel(t)}
|
|
53
|
+
|
|
54
|
+
How to write a job (\`delegate\`) or a question (\`ask\`) for a ${targetLabel(t)} launched agent, written by ${targetLabel(t)}: each family wrote the brief on prompting itself. Relay's preamble already tells the agent its mode, scope and sandbox, and for a job the report to end with; the task text supplies the rest.
|
|
55
|
+
|
|
56
|
+
${brief}
|
|
57
|
+
|
|
58
|
+
### Model notes
|
|
59
|
+
|
|
60
|
+
Checked ${models.checked} with ${models.checked_with}. These go stale when new models ship: where they disagree with the models or harness in use, trust that harness's documentation and the user's settings.
|
|
61
|
+
|
|
62
|
+
- \`effort\` values (relay passes them to the harness as given): ${models.effort.map((e) => `\`${e}\``).join(", ")}.
|
|
63
|
+
${models.notes.map((n) => `- ${n}`).join("\n")}
|
|
64
|
+
|
|
65
|
+
Sources: ${models.sources.join(", ")}`;
|
|
66
|
+
}
|
|
67
|
+
/** How long after the notes were checked a newer harness is reason to check them again. */
|
|
68
|
+
export const RECHECK_DAYS = 30;
|
|
69
|
+
/**
|
|
70
|
+
* For doctor: whether the installed harness has moved past the version `notes` were checked with,
|
|
71
|
+
* null if it has not. Patch releases ship almost daily, so a newer version alone is said, not
|
|
72
|
+
* warned about; a newer version a month or more after the check is when a new model or effort
|
|
73
|
+
* level is likely to have shipped, so that is `stale`.
|
|
74
|
+
*/
|
|
75
|
+
export function notesBehind(t, notes, installed, today = new Date()) {
|
|
76
|
+
const checked = versionOf(notes.checked_with);
|
|
77
|
+
if (!checked || !olderVersion(checked, installed))
|
|
78
|
+
return null;
|
|
79
|
+
const days = Math.floor((today.getTime() - Date.parse(`${notes.checked}T00:00:00Z`)) / 86_400_000);
|
|
80
|
+
const stale = days >= RECHECK_DAYS;
|
|
81
|
+
return {
|
|
82
|
+
stale,
|
|
83
|
+
text: `newer than the ${notes.checked_with} the model notes in relay's prompting brief for ${targetLabel(t)} were checked with (${notes.checked}, ${days} day${days === 1 ? "" : "s"} ago)` +
|
|
84
|
+
(stale ? `; models or effort levels may have changed since. The notes are only advice to the launching agent: the CLI's own model list decides, and a newer relay release brings newer notes` : ""),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { shellQuote } from "../core/shell.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// Naming evidence, not endpoint authentication. Opaque Bedrock application-profile ARNs do not
|
|
4
|
+
// expose a model and stay unknown; an ARN carrying a Claude model id can be recognised locally.
|
|
5
|
+
const model = String.raw `claude-(?:(?:opus|sonnet|haiku)-\d+(?:[.-]\d+)*|v?\d+(?:[.:-]\d+)*(?:-(?:opus|sonnet|haiku)(?:-\d{8})?)?|instant-v?\d+(?:[.:]\d+)*)(?:-latest)?(?:-v\d+(?::\d+)*(?::\d+k)?)?(?:@\d{8})?(?:\[1m\])?`;
|
|
6
|
+
// Geographic profiles are not a closed list (AWS added jp. and au., for example).
|
|
7
|
+
// https://aws.amazon.com/blogs/machine-learning/introducing-amazon-bedrock-cross-region-inference-for-claude-sonnet-4-5-and-haiku-4-5-in-japan-and-australia/
|
|
8
|
+
const bedrock = String.raw `(?:[a-z]+(?:-[a-z]+)*\.)?anthropic\.${model}`;
|
|
9
|
+
const ownModels = new RegExp(String.raw `^(?:(?:opus|sonnet|haiku|opusplan)(?:\[1m\])?|${model}|${bedrock}|arn:aws(?:-us-gov|-cn)?:bedrock:[a-z0-9-]+:(?:\d{12})?:(?:foundation-model|inference-profile|application-inference-profile)/${bedrock})$`, "i");
|
|
10
|
+
// How a Claude turn is sent to its web tools. The prompt is rendered from the run's captured
|
|
11
|
+
// config, which cannot say whether this turn's settings deny them: the run's durable never floor
|
|
12
|
+
// can gain a host after capture (core/never-checkpoint.ts), and the person's own deny rules are
|
|
13
|
+
// copied in (backends/claude.ts userDenyRules); either denies them outright, without a prompt. So
|
|
14
|
+
// the wording never promises an approval prompt, and says what to do after a policy denial.
|
|
15
|
+
const WEB_TOOLS = "WebSearch or WebFetch, which, depending on permission policy, may already be allowed, may ask for approval, or may be denied outright";
|
|
16
|
+
const AFTER_POLICY_DENIAL = "If policy denies them, do not retry them or ask again: finish what you can and report what you needed.";
|
|
17
|
+
/** Claude Code, run headless (`claude -p`). */
|
|
18
|
+
export const claude = {
|
|
19
|
+
id: "claude",
|
|
20
|
+
vendor: "anthropic",
|
|
21
|
+
ownModels,
|
|
22
|
+
enabledByDefault: true,
|
|
23
|
+
defaultBin: "claude",
|
|
24
|
+
name: "Claude",
|
|
25
|
+
product: "Claude Code",
|
|
26
|
+
reviewPrefix: "C",
|
|
27
|
+
clientNames: /claude/i,
|
|
28
|
+
tested: [2, 1, 302],
|
|
29
|
+
credentialEnv: /^(ANTHROPIC_(API_KEY|AUTH_TOKEN)|CLAUDE_CODE_(OAUTH_TOKEN|USE_.*))$/,
|
|
30
|
+
endpointEnv: /^ANTHROPIC_(\w+_)?BASE_URL$/,
|
|
31
|
+
// `--permission-prompt-tool mcp__relay__permission_prompt`: Claude sends what would prompt to relay.
|
|
32
|
+
approvals: {
|
|
33
|
+
channel: "relay-tool",
|
|
34
|
+
tool: {
|
|
35
|
+
inputSchema: { tool_name: z.string(), input: z.record(z.string(), z.unknown()), tool_use_id: z.string().optional() },
|
|
36
|
+
toAsk(call) {
|
|
37
|
+
const tool = String(call.tool_name);
|
|
38
|
+
const input = call.input;
|
|
39
|
+
return tool === "WebSearch" ? { kind: "web", summary: `web search: ${String(input.query ?? "")}` }
|
|
40
|
+
: tool === "WebFetch" ? { kind: "web", summary: `fetch ${String(input.url ?? "")}` }
|
|
41
|
+
// A command asks either to leave the sandbox (dangerouslyDisableSandbox) or, sandboxed, because
|
|
42
|
+
// nothing allowed it automatically. Allowed, it goes ahead as asked, so only the first runs unconfined.
|
|
43
|
+
: tool === "Bash" ? {
|
|
44
|
+
kind: "command", summary: String(input.command ?? ""), reason: typeof input.description === "string" ? input.description : undefined,
|
|
45
|
+
...(input.dangerouslyDisableSandbox === undefined || input.dangerouslyDisableSandbox === false ? { detail: { sandboxed: true } } : {}),
|
|
46
|
+
}
|
|
47
|
+
: typeof input.file_path === "string" ? { kind: "file", summary: `${tool} ${input.file_path}`, paths: [input.file_path] }
|
|
48
|
+
// The whole input, uncut: allowing runs the call with all of it, so all of it is what is
|
|
49
|
+
// shown (the dialog shows it through shown(); JSON keeps it on one line).
|
|
50
|
+
: { kind: "tool", summary: `${tool} ${JSON.stringify(input)}` };
|
|
51
|
+
},
|
|
52
|
+
// An allowed call goes ahead with its own input, unchanged: a sandboxed command stays sandboxed.
|
|
53
|
+
reply: (call, decision) => decision.allow ? { behavior: "allow", updatedInput: call.input } : { behavior: "deny", message: decision.message },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
resumeCommand: (sessionId) => `claude --resume ${shellQuote(sessionId)}`,
|
|
57
|
+
capabilities: { subagents: "never", confinement: "verified", readOnly: true, networkOff: true, writeRoots: true, approvals: "native", escalation: true, resume: true, login: "account-verified", extensions: true },
|
|
58
|
+
// Fast mode: the fastMode setting, which relay passes in its --settings file (Claude Code's
|
|
59
|
+
// flag settings, which also count as the opt-in a headless session needs; checked in 2.1.302).
|
|
60
|
+
// Claude Code offers it for Opus 5.5, 5 and 4.8 (code.claude.com/docs/en/fast-mode, 2026-10-16;
|
|
61
|
+
// in 2.1.302 a model whose id has opus-5 or opus-4-8 in it). The opus alias is the latest Opus.
|
|
62
|
+
// Any other alias, or "default", is for Claude to say: it reports whether the turn ran fast.
|
|
63
|
+
speeds: {
|
|
64
|
+
fast: {
|
|
65
|
+
id: "fastMode",
|
|
66
|
+
models: {
|
|
67
|
+
names: "Opus 5.5, Opus 5 and Opus 4.8",
|
|
68
|
+
has: (model) => (/opus-(?:5|4-8)(?![\d.])/i.test(model) || /^opus(?:\[1m\])?$/i.test(model) ? true
|
|
69
|
+
: /^(?:sonnet|haiku)(?:\[1m\])?$/i.test(model) || /claude-/i.test(model) ? false : null),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
qualified: true,
|
|
74
|
+
text: {
|
|
75
|
+
// Claude jobs always run under the never floor (core/never-coverage.ts): its settings switch off
|
|
76
|
+
// Claude's unsandboxed retry and relay refuses a command approval, so no command is offered a way out.
|
|
77
|
+
blockedHow: (mode) => mode === "write"
|
|
78
|
+
? "make the edit with your file tools, which ask for approval when it is outside what your sandbox allows. A command the sandbox blocks cannot be approved to run outside it: report it under Open issues"
|
|
79
|
+
: `use ${WEB_TOOLS}. ${AFTER_POLICY_DENIAL} A command the sandbox blocks cannot be approved to run outside it: report it in your final message`,
|
|
80
|
+
// So a command is never among what a Claude turn may ask for. A write turn asks for a path through
|
|
81
|
+
// its file tools (the web, where it can ask for it, is in shellNetwork). A read turn can ask only
|
|
82
|
+
// through its web tools, and not when the turn already has the network (backends/claude.ts allows
|
|
83
|
+
// them outright) or the captured never.hosts denies them (applyClaudeNeverPolicy): then it has
|
|
84
|
+
// nothing to ask for. Where neither is known, policy may still deny them, as WEB_TOOLS says.
|
|
85
|
+
blockedAsks: (mode, { network, webDenied }) => mode === "write" ? "a path outside your worktree"
|
|
86
|
+
: !network && !webDenied ? "web access" : null,
|
|
87
|
+
// Claude Code's sandbox decides network access for commands by itself under -p: its question is
|
|
88
|
+
// never sent to relay's permission tool. WebFetch and WebSearch can ask, where policy leaves them.
|
|
89
|
+
shellNetwork: (canAsk) => "Your shell commands have no network access: the sandbox refuses connections by itself, and nobody is asked, so a refusal it reports (whatever reason it gives) is not a person's decision. " +
|
|
90
|
+
(canAsk
|
|
91
|
+
? `To read the web, use ${WEB_TOOLS}. ${AFTER_POLICY_DENIAL} If a command itself needs the network, do not retry it with the sandbox disabled (that is refused); say under Open issues that you need a network grant (the root session can give one when it resumes you).`
|
|
92
|
+
: "If you need the web or the network, say under Open issues that you need a network grant (the root session can give one when it resumes you)."),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { shellQuote } from "../core/shell.js";
|
|
2
|
+
/** Codex filters MCP server environments; keep home discovery and native host identity. */
|
|
3
|
+
export const CODEX_MCP_ENV_VARS = ["CODEX_HOME", "CODEX_INTERNAL_ORIGINATOR_OVERRIDE"];
|
|
4
|
+
/**
|
|
5
|
+
* Why a Codex agent cannot be given `dir` to write, or null: a granted directory, the repository's
|
|
6
|
+
* git directories under child_git "native", or a write turn's own directory, each a workspace root
|
|
7
|
+
* of relay's profile (backends/codex.ts codexPermissions). Codex 0.164.0 writes every directory its
|
|
8
|
+
* sandbox makes writable into the Seatbelt profile its commands run in, inside a regex literal
|
|
9
|
+
* (`#"…"`, which keeps the .git, .codex and .agents at its top read-only) that a double quote in
|
|
10
|
+
* the name ends early: it escapes the quote with a backslash, which such a literal does not take
|
|
11
|
+
* (codex-rs sandboxing/src/seatbelt.rs, seatbelt_protected_metadata_name_regex). The profile then
|
|
12
|
+
* does not compile, with the rest of the name read as profile text, and no command runs. A tab, a
|
|
13
|
+
* line feed or a carriage return in the name of a root relay names in the profile (a grant, a git
|
|
14
|
+
* directory) leaves that directory unwritable, with nothing said; other control characters work,
|
|
15
|
+
* with the names at its top still read-only. As the directory a command runs in (`codex sandbox`'s
|
|
16
|
+
* working directory) those three worked too, but relay refuses them for the turn's own directory
|
|
17
|
+
* as well: an app-server turn names it as a runtime workspace root, which was not tried. Seen with
|
|
18
|
+
* codex-cli 0.164.0 (test/codex-permissions.test.ts).
|
|
19
|
+
*/
|
|
20
|
+
export function codexWriteRootProblem(dir) {
|
|
21
|
+
if (dir.includes('"'))
|
|
22
|
+
return "holds a double quote, and Codex's sandbox cannot be built with a directory so named writable: the agent could run no command at all";
|
|
23
|
+
if (/[\t\n\r]/.test(dir))
|
|
24
|
+
return "holds a tab or a line break, and Codex's sandbox can leave a directory so named unwritable, saying nothing";
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** The registration relay gives a launched Codex, including extension approval waits. */
|
|
28
|
+
export function codexToolTimeoutS(approvalTimeoutS, overlayBudgetS = 3600) {
|
|
29
|
+
const total = Math.ceil(Math.max(3600, 2 * approvalTimeoutS + 300) + overlayBudgetS + 300);
|
|
30
|
+
// Pinned Codex reads an unsigned integer; keep the registration representable and exact.
|
|
31
|
+
if (!Number.isFinite(approvalTimeoutS) || approvalTimeoutS <= 0 || !Number.isFinite(overlayBudgetS) || overlayBudgetS <= 0 || !Number.isSafeInteger(total) || total > 0xffffffff)
|
|
32
|
+
throw new Error("Codex MCP timeout cannot represent the finite approval/overlay/transition budget");
|
|
33
|
+
return total;
|
|
34
|
+
}
|
|
35
|
+
/** OpenAI's Codex CLI, run through `codex app-server` (or `codex exec`). */
|
|
36
|
+
export const codex = {
|
|
37
|
+
id: "codex",
|
|
38
|
+
vendor: "openai",
|
|
39
|
+
ownModels: /^(gpt-|o\d|codex-|chatgpt-)/i,
|
|
40
|
+
enabledByDefault: true,
|
|
41
|
+
defaultBin: "codex",
|
|
42
|
+
name: "Codex",
|
|
43
|
+
product: "codex-cli",
|
|
44
|
+
reviewPrefix: "X",
|
|
45
|
+
clientNames: /codex/i,
|
|
46
|
+
tested: [0, 163, 0],
|
|
47
|
+
// 2026-10-23: relay 1.0.0 against 0.164.0, live (read, write, resume, Daybreak) and in the source it depends on.
|
|
48
|
+
checked: [[0, 164, 0]],
|
|
49
|
+
credentialEnv: /^(OPENAI_API_KEY|CODEX_API_KEY|CODEX_ACCESS_TOKEN)$/,
|
|
50
|
+
endpointEnv: /^OPENAI_BASE_URL$/,
|
|
51
|
+
// The app server sends approval requests to relay as JSON-RPC requests (`codex exec` sends none).
|
|
52
|
+
approvals: { channel: "in-band" },
|
|
53
|
+
// Withheld (nativeResumeWithheld): relay runs Codex with its own Codex home and its pinned binary
|
|
54
|
+
// (codex-pin.ts), not ~/.codex and the codex on PATH, so this plain command finds no such thread.
|
|
55
|
+
// A command with relay's CODEX_HOME would run Codex outside relay's confinement on relay's login,
|
|
56
|
+
// and the thread is archived after each turn (relay unarchives it before its own resume); no such
|
|
57
|
+
// native resume has been checked.
|
|
58
|
+
resumeCommand: (sessionId) => `codex resume ${shellQuote(sessionId)}`,
|
|
59
|
+
nativeResumeWithheld: "Relay shows no command to open a Codex session in your own codex. Relay ran it with its own Codex home (targets.codex.home, not ~/.codex) and its pinned Codex, and archives the thread after each turn, so `codex resume` with your own Codex does not find it; opened in relay's Codex home instead, it would run outside the confinement relay gave it, on relay's login and the settings relay writes there. Continue it with relay's resume, which unarchives the thread and keeps it confined.",
|
|
60
|
+
capabilities: { subagents: "always", confinement: "verified", readOnly: true, networkOff: true, writeRoots: true, approvals: "native", escalation: true, resume: true, login: "account-verified", extensions: true },
|
|
61
|
+
// Service tiers, by their ids in the model catalog (model/list serviceTiers; Codex 0.163.0).
|
|
62
|
+
// Which the account has, for which model, is the catalog's to say: relay asks it before each turn.
|
|
63
|
+
speeds: { fast: { id: "priority" }, ultrafast: { id: "ultrafast" } },
|
|
64
|
+
qualified: true,
|
|
65
|
+
text: { blockedHow: () => "request escalated permissions for that one command" },
|
|
66
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { shellQuote } from "../core/shell.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* The models relay lets Copilot run, with each one's family: the family a call to Copilot reaches.
|
|
5
|
+
* From GitHub's documented model list for Copilot CLI 1.0.98 (docs.github.com, Copilot CLI
|
|
6
|
+
* reference, 2026-10-15), not from a signed-in `copilot` run. "auto" (Copilot picks, and may pick
|
|
7
|
+
* the caller's own family) is deliberately absent, as is any id whose family relay cannot name.
|
|
8
|
+
* Under same_family "allow", unlisted models are accepted with an unknown family label; strict
|
|
9
|
+
* admission requires a listed model with a known family. Adding one is a reviewed change.
|
|
10
|
+
*/
|
|
11
|
+
export const COPILOT_MODELS = Object.freeze({
|
|
12
|
+
"claude-sonnet-5.5": "anthropic",
|
|
13
|
+
"claude-opus-5.5": "anthropic",
|
|
14
|
+
"claude-haiku-5.5": "anthropic",
|
|
15
|
+
"claude-haiku-4.5": "anthropic",
|
|
16
|
+
"gpt-6.1-sol": "openai",
|
|
17
|
+
"gpt-6-astra": "openai",
|
|
18
|
+
"gpt-6-luna": "openai",
|
|
19
|
+
"gpt-5.4": "openai",
|
|
20
|
+
"gpt-5.4-mini": "openai",
|
|
21
|
+
"gpt-5.3-codex": "openai",
|
|
22
|
+
"gemini-3.8-flash": "google",
|
|
23
|
+
"gemini-3.7-flash": "google",
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* The hosts Copilot CLI 1.0.98 needs, signed in with an individual account: `api.github.com` for its
|
|
27
|
+
* login check and account (`/copilot_internal/user`, which names the model endpoint), and the model
|
|
28
|
+
* endpoint GitHub assigns individual accounts (Free, Pro), `api.individual.githubcopilot.com`. Found
|
|
29
|
+
* from the proxy's own decisions in signed-in runs on 2026-10-17 (relay's proxy admitting only these
|
|
30
|
+
* hosts, Copilot answered), and matching GitHub's allowlist reference
|
|
31
|
+
* (docs.github.com/en/copilot/reference/copilot-allowlist-reference). Left out, and so refused:
|
|
32
|
+
* its telemetry (`telemetry.individual.githubcopilot.com`), which it drops without complaint, and
|
|
33
|
+
* update checks (off anyway). Business and enterprise accounts are given other model endpoints
|
|
34
|
+
* (`api.business.githubcopilot.com`, `api.enterprise.githubcopilot.com`), which relay has not seen
|
|
35
|
+
* work; a turn there is refused by the proxy, and says so in its log.
|
|
36
|
+
*/
|
|
37
|
+
export const COPILOT_API_HOSTS = Object.freeze(["api.github.com", "api.individual.githubcopilot.com"]);
|
|
38
|
+
/**
|
|
39
|
+
* GitHub Copilot CLI, driven over ACP (`copilot --acp`; backends/copilot.ts). A harness, not a
|
|
40
|
+
* family: on one Copilot subscription it runs Anthropic's, OpenAI's and Google's models, so the
|
|
41
|
+
* family a call reaches is the model's, and labels use COPILOT_MODELS, with unknown for automatic or unlisted models. Relay
|
|
42
|
+
* confines it with its own sandbox (Copilot's own sandbox would nest inside, which fails).
|
|
43
|
+
* Switched off by default, and experimental (targets.copilot.experimental) until a signed-in
|
|
44
|
+
* qualification run.
|
|
45
|
+
*/
|
|
46
|
+
export const copilot = {
|
|
47
|
+
id: "copilot",
|
|
48
|
+
vendor: null,
|
|
49
|
+
autoModel: "auto",
|
|
50
|
+
models: COPILOT_MODELS,
|
|
51
|
+
enabledByDefault: false,
|
|
52
|
+
defaultBin: "copilot",
|
|
53
|
+
name: "Copilot",
|
|
54
|
+
product: "GitHub Copilot CLI",
|
|
55
|
+
reviewPrefix: "G",
|
|
56
|
+
// Never taken for a root session's host: a Copilot session's family is its model's, which relay
|
|
57
|
+
// cannot tell from the outside, so such a root names targets as an unknown caller.
|
|
58
|
+
clientNames: /(?!)/,
|
|
59
|
+
tested: [1, 0, 98],
|
|
60
|
+
// Copilot's own token. GH_TOKEN and GITHUB_TOKEN also override its stored login, and GH_HOST
|
|
61
|
+
// chooses which host's stored login it uses (a GitHub Enterprise one, say), but other tools (gh)
|
|
62
|
+
// use them too, so they are removed from Copilot's environment only (loginEnv).
|
|
63
|
+
credentialEnv: /^COPILOT_GITHUB_TOKEN$/,
|
|
64
|
+
loginEnv: /^(GH_TOKEN|GITHUB_TOKEN|GH_HOST)$/,
|
|
65
|
+
// Its profile removes every COPILOT_* and GITHUB_COPILOT_* variable from its environment and sets
|
|
66
|
+
// its own, so no variable can point it elsewhere; there is nothing left here to refuse.
|
|
67
|
+
endpointEnv: /(?!)/,
|
|
68
|
+
approvals: { channel: "in-band" },
|
|
69
|
+
capabilities: { subagents: "never",
|
|
70
|
+
confinement: "relay-enforced",
|
|
71
|
+
readOnly: true,
|
|
72
|
+
// Without a network grant it reaches only COPILOT_API_HOSTS, through relay's per-turn proxy, plus
|
|
73
|
+
// what the system's certificate-trust daemons fetch for it past the proxy (its profile takes
|
|
74
|
+
// that downgrade; backends/copilot.ts).
|
|
75
|
+
networkOff: true,
|
|
76
|
+
writeRoots: true,
|
|
77
|
+
approvals: "acp",
|
|
78
|
+
// 1.0.98 drops relay's bridge (stdio MCP) when relay hands it over ACP, so its agents cannot
|
|
79
|
+
// delegate or reach relay, and are not told they can. Relay still passes the bridge.
|
|
80
|
+
relayTools: false,
|
|
81
|
+
escalation: false,
|
|
82
|
+
resume: true,
|
|
83
|
+
login: "scrubbed",
|
|
84
|
+
},
|
|
85
|
+
apiHosts: COPILOT_API_HOSTS,
|
|
86
|
+
qualified: false,
|
|
87
|
+
// Its sessions live in the home relay prepared for the item (backends/copilot.ts), not in the
|
|
88
|
+
// user's ~/.copilot. The --resume=<id> form is from Copilot's documentation; unverified here.
|
|
89
|
+
resumeCommand: (sessionId, at) => `COPILOT_HOME='${path.join(at.harnessState, "copilot").replace(/'/g, "'\\''")}' copilot --resume=${shellQuote(sessionId)}`,
|
|
90
|
+
text: {
|
|
91
|
+
blockedHow: () => "say exactly what you were blocked from doing in your final message; relay's sandbox cannot be lifted from inside a turn",
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { shellQuote } from "../core/shell.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { VERIFIED } from "./verified.js";
|
|
4
|
+
/**
|
|
5
|
+
* The one host Gemini CLI 0.64.0 needs signed in with a Gemini API key: Google's Gemini API
|
|
6
|
+
* (`generativelanguage.googleapis.com`, the Developer API endpoint of the genai SDK it uses). From
|
|
7
|
+
* the 0.64.0 source and package (docs/research/acp-google-grok.md §1.2, docs/gemini.md), not yet
|
|
8
|
+
* from a signed-in run through relay's proxy. Left out, and so refused: its Clearcut telemetry
|
|
9
|
+
* (`play.googleapis.com`, off in relay's settings anyway), the Code Assist and OAuth hosts of the
|
|
10
|
+
* Google-login path (which relay does not use), and the npm registry (its update check runs only
|
|
11
|
+
* in its terminal interface).
|
|
12
|
+
*/
|
|
13
|
+
export const GEMINI_API_HOSTS = Object.freeze(["generativelanguage.googleapis.com"]);
|
|
14
|
+
/**
|
|
15
|
+
* Where the resume command reads the key from: the default key file (core/api-keys.ts, which this
|
|
16
|
+
* registry may not import). With a local config that moves the file, the person substitutes its path.
|
|
17
|
+
*/
|
|
18
|
+
const KEY_FILE_HINT = "~/.config/relay-keys/gemini-api-key";
|
|
19
|
+
/**
|
|
20
|
+
* Google's Gemini CLI, driven over ACP (`gemini --acp`; backends/gemini.ts). The family is Google:
|
|
21
|
+
* with every endpoint redirection refused (endpointEnv, and relay never uses its ACP `gateway`
|
|
22
|
+
* method), Gemini CLI reaches only Google's Gemini API, whose models are all Google's.
|
|
23
|
+
*
|
|
24
|
+
* It signs in with an API key only (capabilities.login "key-only"): Google refuses Gemini CLI's
|
|
25
|
+
* consumer "Login with Google" since 2026-06-18, and Workspace login needs a Code Assist licence
|
|
26
|
+
* Google no longer sells. That is the one exception to relay's rule that agents run on the
|
|
27
|
+
* person's own account login, and relay makes it only for this target and only when the person
|
|
28
|
+
* asks by name (targets.gemini.child_auth "any"; the global setting does not count). The key comes
|
|
29
|
+
* from a file of the person's own (core/api-keys.ts) and goes to Gemini's process alone, in its ACP
|
|
30
|
+
* authenticate request, never in an environment.
|
|
31
|
+
*
|
|
32
|
+
* Relay confines it with its own sandbox, in an untrusted folder (a repository's `.gemini/.env`
|
|
33
|
+
* could otherwise send the key elsewhere), where Gemini connects no MCP server, relay's bridge
|
|
34
|
+
* included. Its agents get relay's tools through Gemini's command-based tool discovery instead
|
|
35
|
+
* (tools.discoveryCommand and tools.callCommand in relay's own Gemini settings, which 0.64.0 runs in
|
|
36
|
+
* an untrusted folder too), served by the same broker as the bridge (backends/gemini.ts,
|
|
37
|
+
* confine/gemini-tools.ts). Switched off by default (targets.gemini.enabled). Qualified for 1.0 on
|
|
38
|
+
* 2026-10-22, after its agents got relay's tools through discovery, with its documented
|
|
39
|
+
* residuals accepted (docs/gemini.md §8, §9): no targets.gemini.experimental is needed, and one
|
|
40
|
+
* already set is accepted and changes nothing.
|
|
41
|
+
*/
|
|
42
|
+
export const gemini = {
|
|
43
|
+
// Gemini's automatic choice (GEMINI_MODEL_ALIAS_AUTO, 0.64.0 packages/core/src/config/models.ts),
|
|
44
|
+
// which is also what its session reports with no --model: not a pin, so a model it routes to is no
|
|
45
|
+
// switch (acp.ts). The family stays Google's either way (vendor). Its other aliases (pro, flash,
|
|
46
|
+
// flash-lite and the deprecated auto-gemini-3, auto-gemini-2.5) count as pins: the model they
|
|
47
|
+
// resolve to is noted as a switch within Google, which never stops a turn (docs/gemini.md §3.4).
|
|
48
|
+
autoModel: "auto",
|
|
49
|
+
id: "gemini",
|
|
50
|
+
vendor: "google",
|
|
51
|
+
enabledByDefault: false,
|
|
52
|
+
defaultBin: "gemini",
|
|
53
|
+
name: "Gemini",
|
|
54
|
+
product: "Gemini CLI",
|
|
55
|
+
reviewPrefix: "GE",
|
|
56
|
+
// Never taken for a root session's host: relay is not registered with Gemini CLI as a host.
|
|
57
|
+
clientNames: /(?!)/,
|
|
58
|
+
// The oldest version relay runs (the version gate refuses an older one): npm @google/gemini-cli 0.64.0
|
|
59
|
+
// (2026-10-13, commit 4a0749ac). 0.65.0 (2026-10-20) was qualified too (toolDiscovery below).
|
|
60
|
+
// Homebrew's formula is frozen at 0.46.0.
|
|
61
|
+
tested: [0, 64, 0],
|
|
62
|
+
// What would make Gemini CLI, or Google's genai SDK in any agent, sign in with something else
|
|
63
|
+
// than the key relay hands it: Google's API keys, the switches to Vertex AI or Code Assist and an
|
|
64
|
+
// access token for it, compute credentials and Gemini's own auth overrides. Removed from every
|
|
65
|
+
// launched agent; Gemini's profile removes them from its own environment too, under child_auth
|
|
66
|
+
// "any" as well, and hands it the key from the key file over ACP.
|
|
67
|
+
credentialEnv: /^(GEMINI_API_KEY|GOOGLE_API_KEY|GOOGLE_GENAI_USE_(VERTEXAI|GCA)|GOOGLE_CLOUD_ACCESS_TOKEN|GEMINI_CLI_USE_COMPUTE_ADC|GEMINI_CLI_AUTH_OVERRIDE|GEMINI_API_KEY_AUTH_MECHANISM)$/,
|
|
68
|
+
// Endpoints other than Google's Gemini API, where any model (and the key) could go: Code Assist's
|
|
69
|
+
// and Vertex's base URLs, the genai SDK's API version, the metadata server. Refused, not removed.
|
|
70
|
+
endpointEnv: /^(CODE_ASSIST_ENDPOINT|CODE_ASSIST_API_VERSION|GOOGLE_GEMINI_BASE_URL|GOOGLE_VERTEX_BASE_URL|GOOGLE_GENAI_API_VERSION|GCE_METADATA_(HOST|IP))$/,
|
|
71
|
+
approvals: { channel: "in-band" },
|
|
72
|
+
capabilities: {
|
|
73
|
+
// None: relay switches Gemini's subagents off (experimental.enableAgents false, and its policy
|
|
74
|
+
// denies invoke_agent, backends/gemini.ts). They are on by default in 0.64.0 and would run other
|
|
75
|
+
// Google models outside what its prompt response reports.
|
|
76
|
+
subagents: "never",
|
|
77
|
+
confinement: "relay-enforced",
|
|
78
|
+
readOnly: true,
|
|
79
|
+
// Without a network grant it reaches only GEMINI_API_HOSTS, through relay's per-turn proxy.
|
|
80
|
+
networkOff: true,
|
|
81
|
+
writeRoots: true,
|
|
82
|
+
approvals: "acp",
|
|
83
|
+
escalation: false,
|
|
84
|
+
// Over session/load: Gemini has no session/resume.
|
|
85
|
+
resume: true,
|
|
86
|
+
login: "key-only",
|
|
87
|
+
// In the untrusted folder relay runs it in, Gemini starts no MCP server, relay's bridge included;
|
|
88
|
+
// its agents take relay's tools through its tool discovery (toolDiscovery), on every version,
|
|
89
|
+
// with a check at each launch that discovery ran.
|
|
90
|
+
relayTools: true,
|
|
91
|
+
},
|
|
92
|
+
// Gemini registers each discovered tool as `discovered_tool_<name>` (0.64.0 DISCOVERED_TOOL_PREFIX,
|
|
93
|
+
// packages/core/src/tools/tool-names.ts:237; tool-registry.ts:518-526). Discovery and calls read in
|
|
94
|
+
// the 0.64.0 source (tool-registry.ts:76-180, :376-540): no trust check, the call command spawned
|
|
95
|
+
// without a shell, the arguments as JSON on stdin, any stderr a failure (docs/gemini.md §3.8).
|
|
96
|
+
// 0.65.0 (2026-10-20): its tool-registry.ts, tool-names.ts, mcp-client-manager.ts, trustedFolders.ts,
|
|
97
|
+
// acpSessionManager.ts, sessionCleanup.ts and policy-engine.ts are 0.64.0's unchanged, and checks
|
|
98
|
+
// 12-15 passed on the real 0.65.0 binary (docs/qualification/gemini-0.65.0.md). The versions are
|
|
99
|
+
// those verified live (VERIFIED.geminiToolDiscovery, targets/verified.ts), for doctor and a turn's
|
|
100
|
+
// note: the tools are offered on every version, and each launch checks that discovery ran
|
|
101
|
+
// (backends/gemini.ts geminiDiscoveryCheck).
|
|
102
|
+
toolDiscovery: { prefix: "discovered_tool_", versions: VERIFIED.geminiToolDiscovery },
|
|
103
|
+
apiHosts: GEMINI_API_HOSTS,
|
|
104
|
+
// Qualified with a real key on 0.64.0 and 0.65.0 (docs/qualification/gemini-0.64.0.md,
|
|
105
|
+
// gemini-0.65.0.md); checks 7 (free keys) and 11 (a real fallback) stay open, since they depend on Google.
|
|
106
|
+
qualified: true,
|
|
107
|
+
// Its sessions live in the runtime directory of the home relay prepared for the item
|
|
108
|
+
// (backends/gemini.ts: `.cache/.gemini` under GEMINI_CLI_HOME, with SANDBOX=sandbox-exec), and
|
|
109
|
+
// a session is found by the directory it was started in (views.ts puts the `cd` in front). Run
|
|
110
|
+
// untrusted there too, as relay runs it, so that the repository's .gemini/.env cannot redirect it.
|
|
111
|
+
// Withheld (nativeResumeWithheld): outside relay's sandbox this would restore chats a turn could
|
|
112
|
+
// write, using relay's settings. SANDBOX only locates the sessions; it starts no sandbox, though
|
|
113
|
+
// Gemini would tell its model it runs under Seatbelt (docs/gemini.md §3.5).
|
|
114
|
+
resumeCommand: (sessionId, at) => `GEMINI_CLI_HOME='${path.join(at.harnessState, "gemini").replace(/'/g, "'\\''")}' SANDBOX=sandbox-exec GEMINI_CLI_TRUST_WORKSPACE=false GEMINI_API_KEY="$(cat ${KEY_FILE_HINT})" gemini --resume ${shellQuote(sessionId)}`,
|
|
115
|
+
nativeResumeWithheld: "Relay shows no command to open a Gemini session in your own gemini. Its session files are in relay's Gemini home for this item, which anything in its turns could write, read jobs included, and `gemini --resume` there would replay them outside relay's sandbox: with relay's Gemini settings rather than yours and whatever instructions the job left in its chats, with only Gemini's own approval prompts in between. The SANDBOX=sandbox-exec needed to find those sessions starts no sandbox, though Gemini would tell its model it runs under Seatbelt. Continue it with relay's resume, which runs it inside relay's sandbox.",
|
|
116
|
+
text: {
|
|
117
|
+
blockedHow: () => "say exactly what you were blocked from doing in your final message; relay's sandbox cannot be lifted from inside a turn",
|
|
118
|
+
},
|
|
119
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { shellQuote } from "../core/shell.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* The models relay lets Grok Build run, all xAI's. Grok runs only xAI's models while relay owns its
|
|
5
|
+
* configuration (backends/grok.ts: its own home, no `[model.*]` or `[endpoints]` of the user's, every
|
|
6
|
+
* Grok variable relay's), but its format allows any model behind any endpoint, so the family is
|
|
7
|
+
* still judged per model, from this reviewed list. Relay runs Grok on no other (listedModelsOnly:
|
|
8
|
+
* its settings allow only these, and the ACP driver refuses a turn that names another before Grok
|
|
9
|
+
* starts), so only a turn that names none runs labelled family unknown, and under same_family
|
|
10
|
+
* "refuse" a call must name one. A listed model the session does not offer is refused before the
|
|
11
|
+
* prompt. From the 1.0.62 binary's built-in catalog (grok-4.6, its default, and grok-4.5, which
|
|
12
|
+
* `grok models` lists without a login), first, since they are the ones seen offered, and its user
|
|
13
|
+
* guide (grok-4.7), not from a signed-in `grok models`. Left out: `grok-build`, which is also the
|
|
14
|
+
* name of Grok's default agent, and whose report back as the session's model is unverified; the
|
|
15
|
+
* per-tier forms (`grok-4.7-high-fast`, `grok-4.7[fast=true]`). Adding one is a reviewed change to
|
|
16
|
+
* this list.
|
|
17
|
+
*/
|
|
18
|
+
export const GROK_MODELS = Object.freeze({
|
|
19
|
+
"grok-4.6": "xai",
|
|
20
|
+
"grok-4.5": "xai",
|
|
21
|
+
"grok-4.7": "xai",
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* The hosts Grok Build needs, signed in with an xAI account (docs.x.ai, Grok Build enterprise
|
|
25
|
+
* guide, "Network requirements", read 2026-10-17): `cli-chat-proxy.grok.com`, its inference proxy,
|
|
26
|
+
* settings and model catalog, and `auth.x.ai`, its OAuth/OIDC issuer (discovery and token refresh).
|
|
27
|
+
* Left out, and so refused: `code.grok.com` (remote session sync and sharing), `assets.grok.com`,
|
|
28
|
+
* `api.mixpanel.com` (product analytics), `x.ai` and `storage.googleapis.com` (installer and update
|
|
29
|
+
* binaries, trace uploads), `registry.npmjs.org` (its npm auto-updater), and `api.x.ai`, which only
|
|
30
|
+
* the API-key path uses. Not yet confirmed by the proxy's own decisions in a signed-in run.
|
|
31
|
+
*/
|
|
32
|
+
export const GROK_API_HOSTS = Object.freeze(["cli-chat-proxy.grok.com", "auth.x.ai"]);
|
|
33
|
+
/**
|
|
34
|
+
* Grok's login directory, where `grok login` keeps the login (`~/.grok/auth.json`) and where Grok
|
|
35
|
+
* refreshes it: it takes `auth.json.lock` (an flock, never removed), spends the single-use refresh
|
|
36
|
+
* token with xAI, writes the new login to `.{pid}.{counter}.tmp` (decimal; created new with mode
|
|
37
|
+
* 0600, synced and chmodded again), renames that onto `auth.json` and chmods the result (grok-build
|
|
38
|
+
* 2bdd1d6, fs_atomic.rs and manager/lock.rs; refresh_chain.rs never refreshes without the lock).
|
|
39
|
+
* A confined Grok turn may do exactly that there and nothing else (decision D10, 2026-10-17,
|
|
40
|
+
* "Exact-name renames"; the grant and its checks are the sandbox layer's: docs/design-token-store.md).
|
|
41
|
+
* Relay always points Grok at this login (backends/grok.ts), whatever GROK_HOME the turn is given.
|
|
42
|
+
*/
|
|
43
|
+
export const GROK_LOGIN_STORE = Object.freeze({
|
|
44
|
+
name: "Grok's login directory",
|
|
45
|
+
dir: ".grok",
|
|
46
|
+
files: Object.freeze(["auth.json"]),
|
|
47
|
+
locks: Object.freeze(["auth.json.lock"]),
|
|
48
|
+
tempName: String.raw `^\.[0-9]+\.[0-9]+\.tmp$`,
|
|
49
|
+
});
|
|
50
|
+
/** A word for a POSIX shell, single-quoted. */
|
|
51
|
+
const shq = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
52
|
+
/**
|
|
53
|
+
* xAI's Grok Build CLI (`grok`, npm @xai-official/grok), driven over ACP (`grok agent stdio`;
|
|
54
|
+
* backends/grok.ts). All its models are xAI's while relay owns its configuration, but relay judges
|
|
55
|
+
* its family per model all the same (GROK_MODELS): a call with no model is labelled family unknown,
|
|
56
|
+
* and refused under same_family "refuse"; one naming a model relay does not list is refused under
|
|
57
|
+
* either setting. Relay confines it with its own sandbox (Grok's would nest inside, and fails open).
|
|
58
|
+
* Switched off by default, and experimental (targets.grok.experimental) until a signed-in
|
|
59
|
+
* qualification run.
|
|
60
|
+
*/
|
|
61
|
+
export const grok = {
|
|
62
|
+
id: "grok",
|
|
63
|
+
vendor: null,
|
|
64
|
+
models: GROK_MODELS,
|
|
65
|
+
listedModelsOnly: true,
|
|
66
|
+
enabledByDefault: false,
|
|
67
|
+
defaultBin: "grok",
|
|
68
|
+
name: "Grok",
|
|
69
|
+
product: "Grok Build",
|
|
70
|
+
reviewPrefix: "K",
|
|
71
|
+
// Never taken for a root session's host: relay does not run as a root inside Grok.
|
|
72
|
+
clientNames: /(?!)/,
|
|
73
|
+
tested: [1, 0, 62],
|
|
74
|
+
// xAI's API keys and Grok's inline and deployment credentials, which would take the place of its
|
|
75
|
+
// stored login: 1.0.62's own lists, from the binary, and GROK_EXTRA_AUTH_KEY, from the 1.0.45
|
|
76
|
+
// source but not in that binary, kept as a precaution. GROK_AUTH_PATH, which only says where the
|
|
77
|
+
// stored login is, is relay's to set, like every other Grok variable (its profile's scrub).
|
|
78
|
+
credentialEnv: /^(XAI_API_KEY|GROK_CODE_XAI_API_KEY|GROK_AUTH|GROK_EXTRA_AUTH_KEY|GROK_DEPLOYMENT_KEY|GROK_ALPHA_TEST_KEY)$/,
|
|
79
|
+
// Its profile removes every GROK_*, XAI_* and OTEL_* variable and SENTRY_DSN from its environment
|
|
80
|
+
// and sets its own, so no variable can point it elsewhere; there is nothing left here to refuse.
|
|
81
|
+
endpointEnv: /(?!)/,
|
|
82
|
+
approvals: { channel: "in-band" },
|
|
83
|
+
capabilities: {
|
|
84
|
+
// Its subagents, which can run other models, are switched off (backends/grok.ts GROK_ENV and its config file).
|
|
85
|
+
subagents: "never",
|
|
86
|
+
confinement: "relay-enforced",
|
|
87
|
+
readOnly: true,
|
|
88
|
+
// Without a network grant it reaches only GROK_API_HOSTS, through relay's per-turn proxy, plus what
|
|
89
|
+
// the system's certificate-trust daemons fetch for it past the proxy (its profile takes that
|
|
90
|
+
// downgrade: backends/grok.ts).
|
|
91
|
+
networkOff: true,
|
|
92
|
+
writeRoots: true,
|
|
93
|
+
approvals: "acp",
|
|
94
|
+
// relayTools left at its default (true): Grok advertises only HTTP and SSE MCP servers, but its
|
|
95
|
+
// source (1.0.45, admit_client_mcp_servers) admits every server a client passes, relay's stdio
|
|
96
|
+
// bridge included. Unverified until a signed-in session; Copilot turned out to drop it.
|
|
97
|
+
escalation: false,
|
|
98
|
+
// session/resume, which Grok advertises (1.0.62), with session/load as the fallback.
|
|
99
|
+
resume: true,
|
|
100
|
+
// Its `cached_token` check, under the oidc pin relay writes, fails at once without a stored
|
|
101
|
+
// login (seen with 1.0.62), but whether the stored login is an account's (it can hold a saved
|
|
102
|
+
// API key) is not reported, so relay can only remove the alternatives.
|
|
103
|
+
login: "scrubbed",
|
|
104
|
+
},
|
|
105
|
+
apiHosts: GROK_API_HOSTS,
|
|
106
|
+
// A stated downgrade: its turns may refresh the login in ~/.grok, through its token, lock and temp names only.
|
|
107
|
+
tokenStore: GROK_LOGIN_STORE,
|
|
108
|
+
qualified: false,
|
|
109
|
+
// Its sessions live in the home relay prepared for the item (backends/grok.ts), not in the
|
|
110
|
+
// user's ~/.grok; its login is the one relay's turns use, in ~/.grok (GROK_LOGIN_STORE). The
|
|
111
|
+
// ACP session id is the one Grok keeps the session under on disk (1.0.62); `--resume <id>` is
|
|
112
|
+
// from its documentation, unverified here. Relay does not show this command (nativeResumeWithheld):
|
|
113
|
+
// it is what the qualification run checks, and what relay would show once that is settled.
|
|
114
|
+
resumeCommand: (sessionId, at) => `GROK_AUTH_PATH="$HOME/.grok/auth.json" GROK_HOME=${shq(path.join(at.harnessState, "grok"))} grok --resume ${shellQuote(sessionId)}`,
|
|
115
|
+
// The session store is writable to everything in a Grok turn, read jobs included (its bash tool,
|
|
116
|
+
// the repository's MCP servers), and `grok --resume` restores the session from it, outside relay's
|
|
117
|
+
// sandbox: its history (updates.jsonl), and in summary.json a persisted agent profile, whose
|
|
118
|
+
// agent can declare MCP servers (1.0.62's user guide, 17-sessions.md and 16-subagents.md). It
|
|
119
|
+
// would run on relay's Grok home, so with relay's settings, not the user's, and with the sandbox
|
|
120
|
+
// profile the session was started with, Grok's own sandbox off, which a resume cannot change
|
|
121
|
+
// (18-sandbox.md). What a resume then starts without asking is unverified.
|
|
122
|
+
nativeResumeWithheld: "Relay shows no command to open a Grok session in your own grok. Its session files are in relay's Grok home for this item, which anything in its turns could write, read jobs included, and `grok --resume` there would restore them outside relay's sandbox: with relay's Grok settings rather than yours, with Grok's own sandbox off for the life of the session (a resume cannot turn it on), and with whatever the job left in them, such as an agent profile that declares MCP servers. Continue it with relay's resume, which runs it inside relay's sandbox.",
|
|
123
|
+
text: {
|
|
124
|
+
blockedHow: () => "say exactly what you were blocked from doing in your final message; relay's sandbox cannot be lifted from inside a turn",
|
|
125
|
+
},
|
|
126
|
+
};
|