@jbkjr/relay 0.0.0-stage → 1.2.1

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.
Files changed (296) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/Apache-2.0.txt +201 -0
  3. package/LICENSES/README.md +19 -0
  4. package/LICENSES/codex-NOTICE.txt +6 -0
  5. package/README.md +386 -2
  6. package/SECURITY.md +145 -0
  7. package/adapters/briefs/claude.md +43 -0
  8. package/adapters/briefs/codex.md +56 -0
  9. package/adapters/briefs/models.json +33 -0
  10. package/adapters/build.mjs +8 -0
  11. package/adapters/claude/.claude-plugin/marketplace.json +13 -0
  12. package/adapters/claude/relay/.claude-plugin/plugin.json +5 -0
  13. package/adapters/claude/relay/agents/codex.md +21 -0
  14. package/adapters/claude/relay/agents/operator.md +21 -0
  15. package/adapters/claude/relay/skills/ask/SKILL.md +20 -0
  16. package/adapters/claude/relay/skills/chat/SKILL.md +13 -0
  17. package/adapters/claude/relay/skills/delegate/SKILL.md +21 -0
  18. package/adapters/claude/relay/skills/discuss/SKILL.md +19 -0
  19. package/adapters/claude/relay/skills/review/SKILL.md +21 -0
  20. package/adapters/claude/relay/skills/tree/SKILL.md +10 -0
  21. package/adapters/claude/relay/skills/write-for-codex/SKILL.md +78 -0
  22. package/adapters/codex/.agents/plugins/marketplace.json +20 -0
  23. package/adapters/codex/AGENTS.snippet.md +5 -0
  24. package/adapters/codex/relay/.codex-plugin/plugin.json +6 -0
  25. package/adapters/codex/relay/skills/relay-ask/SKILL.md +20 -0
  26. package/adapters/codex/relay/skills/relay-chat/SKILL.md +13 -0
  27. package/adapters/codex/relay/skills/relay-delegate/SKILL.md +21 -0
  28. package/adapters/codex/relay/skills/relay-discuss/SKILL.md +19 -0
  29. package/adapters/codex/relay/skills/relay-review/SKILL.md +21 -0
  30. package/adapters/codex/relay/skills/relay-tree/SKILL.md +10 -0
  31. package/adapters/codex/relay/skills/relay-write-for-claude/SKILL.md +66 -0
  32. package/adapters/generate.mjs +124 -0
  33. package/bin/relay +59 -0
  34. package/codex-pin.json +12 -0
  35. package/dist/backends/acp.js +1424 -0
  36. package/dist/backends/claude.js +890 -0
  37. package/dist/backends/cli-version.js +112 -0
  38. package/dist/backends/codex-app.js +1525 -0
  39. package/dist/backends/codex-daybreak.js +75 -0
  40. package/dist/backends/codex-env.js +656 -0
  41. package/dist/backends/codex-network.js +304 -0
  42. package/dist/backends/codex-pin.js +320 -0
  43. package/dist/backends/codex-shell-policy.js +182 -0
  44. package/dist/backends/codex-stage2.js +998 -0
  45. package/dist/backends/codex-subagents.js +47 -0
  46. package/dist/backends/codex.js +637 -0
  47. package/dist/backends/copilot.js +246 -0
  48. package/dist/backends/env.js +147 -0
  49. package/dist/backends/gemini.js +607 -0
  50. package/dist/backends/grok.js +337 -0
  51. package/dist/backends/index.js +8 -0
  52. package/dist/backends/native-temp.js +187 -0
  53. package/dist/backends/never-admission.js +90 -0
  54. package/dist/backends/run.js +67 -0
  55. package/dist/backends/stream.js +230 -0
  56. package/dist/backends/tool-discovery.js +15 -0
  57. package/dist/backends/types.js +264 -0
  58. package/dist/build-info.json +5 -0
  59. package/dist/cli.js +344 -0
  60. package/dist/confine/bridge.js +113 -0
  61. package/dist/confine/broker-core.js +76 -0
  62. package/dist/confine/broker-http.js +650 -0
  63. package/dist/confine/broker-names.js +9 -0
  64. package/dist/confine/broker.js +258 -0
  65. package/dist/confine/canary.js +380 -0
  66. package/dist/confine/diagnostics.js +122 -0
  67. package/dist/confine/gemini-tools-main.js +8 -0
  68. package/dist/confine/gemini-tools.js +181 -0
  69. package/dist/confine/hardlinks.js +58 -0
  70. package/dist/confine/harness-config.js +16 -0
  71. package/dist/confine/index.js +117 -0
  72. package/dist/confine/leases.js +217 -0
  73. package/dist/confine/paths.js +6 -0
  74. package/dist/confine/peer.js +115 -0
  75. package/dist/confine/port-policy.js +8 -0
  76. package/dist/confine/ports.js +365 -0
  77. package/dist/confine/private-root.js +208 -0
  78. package/dist/confine/probe-stage2.js +501 -0
  79. package/dist/confine/probe.js +1109 -0
  80. package/dist/confine/proxy.js +783 -0
  81. package/dist/confine/sbcheck.js +208 -0
  82. package/dist/confine/seatbelt-never.js +41 -0
  83. package/dist/confine/seatbelt-stage2.js +139 -0
  84. package/dist/confine/seatbelt.js +1129 -0
  85. package/dist/confine/sockets.js +36 -0
  86. package/dist/confine/turn-probe.js +19 -0
  87. package/dist/confine/turn.js +86 -0
  88. package/dist/core/adoption.js +124 -0
  89. package/dist/core/api-keys.js +423 -0
  90. package/dist/core/approvals.js +740 -0
  91. package/dist/core/build-identity.js +248 -0
  92. package/dist/core/caller.js +749 -0
  93. package/dist/core/calls.js +102 -0
  94. package/dist/core/claude-settings.js +1045 -0
  95. package/dist/core/config.js +453 -0
  96. package/dist/core/context.js +186 -0
  97. package/dist/core/db.js +753 -0
  98. package/dist/core/dispatch.js +110 -0
  99. package/dist/core/env-broker.js +505 -0
  100. package/dist/core/env-policy.js +182 -0
  101. package/dist/core/escalation-authority.js +76 -0
  102. package/dist/core/escalation-contract.js +13 -0
  103. package/dist/core/escalation-person-path.js +131 -0
  104. package/dist/core/escalation-policy.js +79 -0
  105. package/dist/core/escalation-runtime.js +135 -0
  106. package/dist/core/escalation-state.js +42 -0
  107. package/dist/core/escalations.js +191 -0
  108. package/dist/core/events.js +235 -0
  109. package/dist/core/executables.js +147 -0
  110. package/dist/core/extensions.js +645 -0
  111. package/dist/core/families.js +204 -0
  112. package/dist/core/git.js +657 -0
  113. package/dist/core/identity.js +113 -0
  114. package/dist/core/liveness.js +68 -0
  115. package/dist/core/mediated-network-provider.js +81 -0
  116. package/dist/core/never-checkpoint.js +76 -0
  117. package/dist/core/never-coverage.js +97 -0
  118. package/dist/core/never-network.js +49 -0
  119. package/dist/core/never-policy.js +302 -0
  120. package/dist/core/never-proxy-policy.js +109 -0
  121. package/dist/core/never-schema.js +61 -0
  122. package/dist/core/never-tools.js +56 -0
  123. package/dist/core/notices.js +48 -0
  124. package/dist/core/ops.js +959 -0
  125. package/dist/core/outcome.js +224 -0
  126. package/dist/core/params.js +32 -0
  127. package/dist/core/presence.js +174 -0
  128. package/dist/core/procs.js +546 -0
  129. package/dist/core/prompts.js +363 -0
  130. package/dist/core/protected-config.js +238 -0
  131. package/dist/core/raw-network.js +192 -0
  132. package/dist/core/redact.js +152 -0
  133. package/dist/core/refusal.js +33 -0
  134. package/dist/core/relay-command.js +310 -0
  135. package/dist/core/reported.js +3 -0
  136. package/dist/core/restart-overlay.js +651 -0
  137. package/dist/core/retention.js +1135 -0
  138. package/dist/core/secrets.js +329 -0
  139. package/dist/core/session-token.js +175 -0
  140. package/dist/core/session.js +744 -0
  141. package/dist/core/shell.js +2 -0
  142. package/dist/core/shipped-pin.js +47 -0
  143. package/dist/core/shown.js +42 -0
  144. package/dist/core/slots.js +67 -0
  145. package/dist/core/stage2-executors.js +453 -0
  146. package/dist/core/stage2-switch.js +5 -0
  147. package/dist/core/steering.js +149 -0
  148. package/dist/core/storage.js +358 -0
  149. package/dist/core/toml.js +175 -0
  150. package/dist/core/views.js +324 -0
  151. package/dist/core/wait.js +114 -0
  152. package/dist/core/wake.js +207 -0
  153. package/dist/core/watch.js +247 -0
  154. package/dist/core/worktree.js +213 -0
  155. package/dist/hosts/claude-desktop.js +274 -0
  156. package/dist/hosts/claude.js +249 -0
  157. package/dist/hosts/codex.js +329 -0
  158. package/dist/hosts/desktop-shared.js +20 -0
  159. package/dist/hosts/index.js +11 -0
  160. package/dist/hosts/types.js +4 -0
  161. package/dist/install/basics.js +18 -0
  162. package/dist/install/claude-init.js +133 -0
  163. package/dist/install/common.js +655 -0
  164. package/dist/install/doctor.js +629 -0
  165. package/dist/install/qualify-codex.js +205 -0
  166. package/dist/install.js +524 -0
  167. package/dist/mcp/elicit.js +209 -0
  168. package/dist/mcp/gateway.js +218 -0
  169. package/dist/mcp/host.js +253 -0
  170. package/dist/mcp/server.js +1124 -0
  171. package/dist/mcp/stdio.js +37 -0
  172. package/dist/modes/discussion.js +393 -0
  173. package/dist/modes/review.js +722 -0
  174. package/dist/native/relay-sbcheck +0 -0
  175. package/dist/targets/briefs.js +86 -0
  176. package/dist/targets/claude.js +94 -0
  177. package/dist/targets/codex.js +66 -0
  178. package/dist/targets/copilot.js +93 -0
  179. package/dist/targets/gemini.js +119 -0
  180. package/dist/targets/grok.js +126 -0
  181. package/dist/targets/index.js +192 -0
  182. package/dist/targets/types.js +18 -0
  183. package/dist/targets/verified.js +35 -0
  184. package/dist/worker.js +113 -0
  185. package/docs/UPGRADING.md +1502 -0
  186. package/docs/pinned-codex.md +321 -0
  187. package/experiments/stage2-redteam/lib/oracles.mjs +214 -0
  188. package/experiments/stage2-redteam/lib/report.mjs +35 -0
  189. package/npm-shrinkwrap.json +1632 -0
  190. package/package.json +82 -4
  191. package/scripts/codex-qualify/codex-pin-store.mjs +353 -0
  192. package/scripts/codex-qualify/codex-qualifier-process.mjs +265 -0
  193. package/scripts/codex-qualify/codex-qualifier.example.json +5 -0
  194. package/scripts/codex-qualify/codex-qualifier.mjs +281 -0
  195. package/scripts/codex-qualify/codex-shipped-pin.mjs +158 -0
  196. package/scripts/codex-qualify/codex-stage2-pin.mjs +48 -0
  197. package/scripts/codex-qualify/codex-stage2.mjs +2381 -0
  198. package/scripts/codex-qualify/install-codex-qualifier.mjs +98 -0
  199. package/scripts/codex-qualify/main-module.mjs +14 -0
  200. package/scripts/codex-qualify/relay-codex-qualifier.plist +37 -0
  201. package/scripts/codex-qualify/scratch-env.mjs +31 -0
  202. package/scripts/codex-qualify/session.mjs +96 -0
  203. package/scripts/codex-qualify/stage2-escalation-cases.mjs +125 -0
  204. package/test/codex-permissions.test.ts +875 -0
  205. package/test/fixtures/boundary-probes.mjs +17 -0
  206. package/test/fixtures/denial-stream-host.mjs +7 -0
  207. package/test/fixtures/families.json +246 -0
  208. package/test/fixtures/install-snapshots/claude-desktop-foreign.txt +158 -0
  209. package/test/fixtures/install-snapshots/claude-desktop-fresh.txt +101 -0
  210. package/test/fixtures/install-snapshots/claude-desktop-installed.txt +161 -0
  211. package/test/fixtures/install-snapshots/claude-foreign.txt +133 -0
  212. package/test/fixtures/install-snapshots/claude-fresh.txt +77 -0
  213. package/test/fixtures/install-snapshots/claude-installed.txt +133 -0
  214. package/test/fixtures/install-snapshots/codex-foreign.txt +159 -0
  215. package/test/fixtures/install-snapshots/codex-fresh.txt +107 -0
  216. package/test/fixtures/install-snapshots/codex-installed.txt +161 -0
  217. package/test/fixtures/link-parent.mjs +6 -0
  218. package/test/fixtures/mediated-command.cjs +72 -0
  219. package/test/fixtures/native-skill-isolation.json +280 -0
  220. package/test/fixtures/pinned-codex-app-server.mjs +25 -0
  221. package/test/fixtures/qualified-ext-adapters.mjs +36 -0
  222. package/test/fixtures/refusals/README.md +52 -0
  223. package/test/fixtures/refusals/claude-source-result.json +7 -0
  224. package/test/fixtures/refusals/openai-app-capacity.json +24 -0
  225. package/test/fixtures/refusals/openai-app-cyberPolicy.json +24 -0
  226. package/test/fixtures/refusals/openai-gpt-6-astra-max.json +12 -0
  227. package/test/fixtures/refusals/openai-gpt-6.1-sol-xhigh.json +12 -0
  228. package/test/fixtures/refusals/openai-review-capacity.json +24 -0
  229. package/test/fixtures/relay-0.2.0.sql +57 -0
  230. package/test/fixtures/relay-0.9.1.gen.mjs +212 -0
  231. package/test/fixtures/relay-0.9.1.sql +340 -0
  232. package/test/fixtures/slow-boundary-probes.mjs +37 -0
  233. package/test/fixtures/stable-surfaces/config.json +1122 -0
  234. package/test/fixtures/stable-surfaces/escalation.json +128 -0
  235. package/test/fixtures/stable-surfaces/events.json +37 -0
  236. package/test/fixtures/stable-surfaces/gemini-native-resume.json +4 -0
  237. package/test/fixtures/stable-surfaces/inbox.jsonl +2 -0
  238. package/test/fixtures/stable-surfaces/notice.txt +1 -0
  239. package/test/fixtures/stable-surfaces/refusal-item.json +28 -0
  240. package/test/fixtures/stable-surfaces/refusal-review.json +23 -0
  241. package/test/fixtures/stable-surfaces/registry.json +49 -0
  242. package/test/fixtures/stable-surfaces/tools-desktop.json +575 -0
  243. package/test/fixtures/stable-surfaces/tools.json +716 -0
  244. package/test/fixtures/stable-surfaces/usage.txt +46 -0
  245. package/test/fixtures/stage2-acp-native.mjs +138 -0
  246. package/test/fixtures/stage2-app-server.mjs +23 -0
  247. package/test/fixtures/stage2-catalog.json +91 -0
  248. package/test/fixtures/stage2-hostile-web.mjs +35 -0
  249. package/test/fixtures/stage2-native-network.mjs +62 -0
  250. package/test/fixtures/stage2-worker.ts +87 -0
  251. package/test/fixtures/status-views/expected.json +7825 -0
  252. package/test/fixtures/status-views/registries.json +1 -0
  253. package/test/fixtures/steering.json +209 -0
  254. package/test/helpers.ts +740 -0
  255. package/test/host-env.ts +7 -0
  256. package/test/keychain-decoy.ts +197 -0
  257. package/test/live-scope.ts +44 -0
  258. package/test/mediated-network.test.ts +192 -0
  259. package/test/mediated-proxy.test.ts +264 -0
  260. package/test/native-temp-alias.ts +10 -0
  261. package/test/never-policy.test.ts +629 -0
  262. package/test/never-tools.test.ts +136 -0
  263. package/test/process-home.ts +18 -0
  264. package/test/proxy.test.ts +531 -0
  265. package/test/restart-overlay-live.test.ts +85 -0
  266. package/test/restart-overlay-profile.test.ts +66 -0
  267. package/test/restart-overlay.test.ts +416 -0
  268. package/test/stable-surfaces.test.ts +249 -0
  269. package/test/stage2-escalation-live.test.ts +544 -0
  270. package/test/stage2-escalation-qualification.test.ts +170 -0
  271. package/test/stage2-escalation.test.ts +747 -0
  272. package/test/stage2-executor.test.ts +849 -0
  273. package/test/stage2-grant.test.ts +603 -0
  274. package/test/stage2-native-live.test.ts +647 -0
  275. package/test/stage2-network-decisions.test.ts +70 -0
  276. package/test/stage2-probe.test.ts +845 -0
  277. package/test/stage2-standing-live.test.ts +203 -0
  278. package/test/stubs/broker-host.mjs +59 -0
  279. package/test/stubs/broker-peer.mjs +20 -0
  280. package/test/stubs/confined-harness.mjs +91 -0
  281. package/test/stubs/ext-broken-server.mjs +2 -0
  282. package/test/stubs/ext-odd-server.mjs +21 -0
  283. package/test/stubs/ext-server.mjs +31 -0
  284. package/test/stubs/fake-host-cli.mjs +218 -0
  285. package/test/stubs/procargs.mjs +30 -0
  286. package/test/stubs/stub-acp +4 -0
  287. package/test/stubs/stub-agent.mjs +322 -0
  288. package/test/stubs/stub-claude +4 -0
  289. package/test/stubs/stub-codex +4 -0
  290. package/test/stubs/targets/acp.mjs +307 -0
  291. package/test/stubs/targets/claude.mjs +149 -0
  292. package/test/stubs/targets/codex.mjs +479 -0
  293. package/test/stubs/targets/gemini.mjs +604 -0
  294. package/test/temp-root.ts +11 -0
  295. package/test/wp4-adapters.test.ts +353 -0
  296. package/test/wp4-interlock.test.ts +136 -0
package/README.md CHANGED
@@ -1,3 +1,387 @@
1
- # Temporary Holding Version
1
+ # relay
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Relay lets coding agents of different model families hand work to each other. From a Claude Code
4
+ session you can delegate a task to OpenAI's Codex, ask it a question, argue a design out with it, or
5
+ get its independent review of your work; from a Codex session you can do the same with Claude.
6
+ Gemini CLI can join as a target, and GitHub Copilot CLI and xAI's Grok Build as experimental ones.
7
+
8
+ Every agent relay starts is confined by default: in its vendor's own macOS sandbox, which relay
9
+ configures and checks (Claude Code, Codex), or in a sandbox relay builds for each turn (Gemini,
10
+ Copilot, Grok). A few settings you can choose take jobs outside that; [Security model](#security-model)
11
+ names them. Relay is one stdio MCP server that you register with each host you use. It runs on macOS only.
12
+
13
+ ## Why use it
14
+
15
+ - **A second opinion from another model family**, without leaving your session. `ask` puts a
16
+ question to the other agent mid-task and keeps the thread for follow-ups.
17
+ - **Cross-family review.** `review` has the other agent review your code or plan without seeing
18
+ your own review, then reconciles the two into one list. An item is settled only where both
19
+ sides' closing statements agree.
20
+ - **Delegation.** `delegate` hands a chunk of work to the other agent. A write job runs in its own
21
+ git worktree on its own branch, and you merge exactly what its result showed you. The agent you
22
+ delegate to can delegate back across in turn.
23
+ - **Discussion.** `discuss` argues a question out turn by turn, to an agreed conclusion or a stated
24
+ crux.
25
+
26
+ Relay fills the gaps *between* families. For more agents of your own family, your host's native
27
+ subagents are the better tool; relay admits a call that names your own family, and labels it.
28
+
29
+ ## What it looks like
30
+
31
+ In a Claude Code session, with relay installed, either type a slash command or ask in plain
32
+ language ("ask Codex whether…", "have Codex review this branch"):
33
+
34
+ ```
35
+ /relay:ask Is the retry loop in src/net/client.ts safe if the server returns 429 with no Retry-After?
36
+ ```
37
+
38
+ Claude calls relay's `ask` tool. Relay starts Codex, read-only, in the same repository, and returns
39
+ its answer to Claude, which can follow up in the same thread:
40
+
41
+ ```json
42
+ ask({ "message": "Is the retry loop …", "context": ["src/net/client.ts"] })
43
+ → { "reply": "…", "thread_id": "t_c0bbe50e", … }
44
+ ```
45
+
46
+ A write job returns at once and runs in the background, on its own branch:
47
+
48
+ ```
49
+ /relay:delegate write Add input validation to src/api/upload.ts and cover it with tests
50
+ ```
51
+
52
+ ```json
53
+ delegate({ "mode": "write", "task": "Add input validation to …" })
54
+ → { "job_id": "j_7cfab338", "target": "codex", "branch": "relay/j_7cfab338", "status": "queued" }
55
+ ```
56
+
57
+ When it finishes, Claude reads the job's `result` (summary, files changed, tests run, diff summary)
58
+ and, if you agree, `merge`s it. `relay tree` in a terminal shows every job, thread, discussion and
59
+ review of the run as it goes. From a Codex session the same tools reach Claude, through the skills
60
+ `$relay-ask`, `$relay-delegate`, `$relay-review` and so on.
61
+
62
+ ## Requirements
63
+
64
+ - **A Mac.** macOS only: process handling relies on `ps`, and confinement on macOS sandboxes; Linux
65
+ and Windows are not supported. Relay has recorded checks on macOS 27.0, 27.0.1, 27.2 and 27.2.1,
66
+ and `relay doctor` warns on another version. Codex through relay needs Apple silicon: its pinned
67
+ Codex is OpenAI's `darwin-arm64` build.
68
+ - **Node 24.15 or newer** (Node 24 LTS, or a later release), and **git**.
69
+ - **Claude Code and Codex CLI**, both installed and signed in with your account (relay refuses a
70
+ turn that would sign in with an API key unless you allow it; see `child_auth` in
71
+ [configuration](docs/configuration.md)). Tested minimums: Claude Code 2.1.302 and codex-cli
72
+ 0.163.0. Relay refuses an older version unless you set `allow_untested`; doctor reports the same
73
+ failure (a warning with that opt-in). Relay runs Claude under the login Claude Code has stored,
74
+ and Codex under the login in relay's own Codex home (see [Codex](#codex)). `relay doctor` prints
75
+ the method each CLI reports (`claude auth status`, `codex login status`); for Codex that can be a
76
+ ChatGPT account or a stored API key.
77
+ - Launched agents use your Claude and ChatGPT plans like any other use of those CLIs. See
78
+ [Accounts and cost](#accounts-and-cost).
79
+
80
+ ## Install
81
+
82
+ ```sh
83
+ npm install -g @jbkjr/relay
84
+ relay doctor # platform, Node, the CLIs and their logins, and what is registered
85
+ relay install claude # prints what it would do, and changes nothing
86
+ relay install claude --write # registers relay with Claude Code
87
+ relay install codex --write # registers relay with Codex, and puts the shipped Codex pin in place
88
+ ```
89
+
90
+ Then sign Codex in once for relay, which runs Codex with a Codex home of its own (see [Codex](#codex)):
91
+
92
+ ```sh
93
+ CODEX_HOME="$HOME/.local/share/relay-codex-home" ~/.local/share/relay-codex-pins/current/bin/codex login
94
+ ```
95
+
96
+ Restart your Claude Code and Codex sessions: each session starts its own relay server when it
97
+ starts.
98
+
99
+ What the installs set up:
100
+
101
+ - **Claude Code** (`relay install claude --write`): the MCP server `relay` at user scope, and relay's
102
+ plugin from a local marketplace (`relay@relay-local`). The plugin adds the slash commands
103
+ `/relay:delegate`, `/relay:ask`, `/relay:discuss`, `/relay:review`, `/relay:tree` and
104
+ `/relay:chat`; two subagents, `relay:operator` and `relay:codex`, that run one delegation or one
105
+ question in the background and report back; and `relay:write-for-codex`, a brief on writing tasks
106
+ for Codex that Claude loads itself.
107
+ - **Codex** (`relay install codex --write`): an `[mcp_servers.relay]` table in `~/.codex/config.toml`,
108
+ and relay's plugin, whose skills are `$relay-delegate`, `$relay-ask`, `$relay-discuss`,
109
+ `$relay-review`, `$relay-tree`, `$relay-chat` and `$relay-write-for-claude`. With `--write` it also
110
+ puts this release's shipped Codex pin in place.
111
+ - **Claude desktop app and Cowork** (`relay install claude-desktop --write`, with the app quit): see
112
+ [below](#claude-desktop-app-and-cowork).
113
+ - **ChatGPT desktop app**: its Codex side reads `~/.codex/config.toml`, so `relay install codex`
114
+ covers it; see [below](#chatgpt-desktop-app). Its Work mode has not been checked with relay.
115
+ - Each install also links `~/.local/bin/relay` to relay's launcher (`--no-link` skips that). The npm
116
+ install also puts a `relay` command in npm's bin directory; either runs the same relay
117
+ ([the `relay` command and your PATH](docs/install.md#the-relay-command-and-your-path)).
118
+
119
+ Every install is a dry run until you add `--write`. It stops, changing nothing, where something
120
+ named `relay` is not its own (unless you pass `--force`), copies each file before editing it, never
121
+ overwrites a backup, and records what it changed in `~/.config/relay/install.json`. Running it
122
+ twice changes nothing the second time. The details, every host and optional target (Gemini CLI,
123
+ OpenCode, Copilot CLI, Grok Build), upgrading, uninstalling and installing from a git checkout are
124
+ in [docs/install.md](docs/install.md).
125
+
126
+ ### Claude desktop app and Cowork
127
+
128
+ The desktop app reads local MCP servers from its own config file, and a running app overwrites that
129
+ file, so quit the app first:
130
+
131
+ ```sh
132
+ relay install claude-desktop --write
133
+ open -a Claude
134
+ ```
135
+
136
+ The entry is named `relay-desktop`, and the app shares it: one relay process serves all its chats,
137
+ and a second serves Cowork, the Code tab's in-app bridge, remote Cowork and widgets. So no session on
138
+ this shared entry gets an approval dialog, `confirm` or notices, and its waits end after 50 seconds,
139
+ under the app's 60-second tool timeout; the agent then calls again. Approval requests arrive with
140
+ the conversation's next relay call (`relay approvals` lists them in a terminal). Relay keeps the
141
+ conversations apart with a session token each one's model carries: a bearer key that separates
142
+ conversations using relay honestly, not one whose model has seen another's token. A session there
143
+ passes `cwd`, the project's absolute path, to start a job, discussion or review, or to merge (an
144
+ `ask` without one gets an empty directory of its own). A Code tab session also has the relay of its
145
+ own `relay install claude` registration, inside its project, with notices and `confirm` as in a
146
+ terminal. The full description, including what auto mode does with the token and how to recover
147
+ a conversation's work, is in [docs/install.md](docs/install.md#claude-desktop-app-and-cowork).
148
+
149
+ ### ChatGPT desktop app
150
+
151
+ The ChatGPT desktop app's Codex side reads its MCP servers from `~/.codex/config.toml`, the Codex
152
+ CLI's file, so `relay install codex --write` registers relay there too. Relay does not put approval
153
+ requests to you as dialogs there (only the app's idle case has been checked, not a request arriving
154
+ mid-task), so they arrive with the conversation's next relay call, and `relay approvals` lists them
155
+ in a terminal. A session that starts relay outside your project passes `cwd`, the project's absolute
156
+ path, as on the Claude desktop app.
157
+
158
+ The app's **Work mode**, its counterpart to Claude's Cowork, has not been checked with relay: not
159
+ whether it loads Codex's MCP servers, nor whether it runs one relay process for all its
160
+ conversations. Relay keeps Cowork's conversations apart with a session token each carries; it has no
161
+ such handling for Work mode, so treat relay there as unsupported for now.
162
+
163
+ ## Codex
164
+
165
+ Relay runs Codex only from a **pinned copy**: one Codex release, downloaded and verified, whose run
166
+ under relay has passed relay's qualification of its confinement. That qualification covers stage 2
167
+ too: an optional mode, off by default, in which Codex's commands run in relay's own sandbox instead
168
+ of Codex's (see [configuration](docs/configuration.md#codex-raw-network-stage-2)). Relay refuses
169
+ every Codex job until it has a pin, and it never falls back to the `codex` on your PATH, unless you
170
+ set `targets.codex.pinned: false`, which runs the Codex `targets.codex.bin` names, unqualified.
171
+
172
+ - **A release installed from npm ships a pin.** The maintainer qualified one Codex release with
173
+ exactly this relay build, and the package carries that pin (`codex-pin.json`).
174
+ `relay install codex --write` puts it in place: it downloads that Codex release from npm and
175
+ checks npm's integrity against the pin, Apple's signature, OpenAI's Team ID and the exact version.
176
+ That takes a minute or two, and Codex works right away. It never replaces a pin you qualified on
177
+ this Mac. What a shipped pin trusts is below, under [Pinned Codex](#pinned-codex-what-a-shipped-pin-trusts).
178
+ - **`relay qualify-codex` is for any other Codex version**, or to check this Mac yourself. It
179
+ qualifies npm's latest release (or `--version X.Y.Z`) here and pins it. That takes about an hour
180
+ and a half, from a terminal in your desktop login (not over SSH), with the network. A git checkout
181
+ ships no pin, so from a checkout run it once after installing. A pin you qualified here stays in
182
+ force over a shipped one; `relay qualify-codex --shipped` switches back to the release's.
183
+
184
+ Relay runs the pinned Codex with a Codex home of its own, `~/.local/share/relay-codex-home`, not
185
+ `~/.codex`, which is why it needs the one-time `codex login` above (`relay install codex --write`
186
+ makes that home, with the `config.toml` relay rewrites on every turn). `relay doctor` shows under
187
+ "codex pin" which pin is in force (shipped or local) and for which Codex, under "codex home" and
188
+ "codex login" whether that home is signed in, and under "codex launch" whether a Codex job started
189
+ in the current directory passes the check each turn makes of Codex's effective configuration
190
+ (system, managed and project layers included). Your own `~/.codex` is for your own Codex sessions:
191
+ relay's jobs read none of it ("your codex").
192
+
193
+ **Keeping up with Codex releases.** Relay keeps running the pinned release until another is pinned.
194
+ Each relay release ships a pin, so upgrading relay and running `relay install codex --write` again
195
+ moves to that release's Codex. To follow Codex releases sooner, rerun `relay qualify-codex`, or
196
+ install the optional LaunchAgent, which runs the same qualifier six times a day
197
+ ([Pinned Codex, the LaunchAgent](docs/pinned-codex.md#keeping-up-with-codex-releases-the-launchagent)).
198
+ How pins, the build identity and the qualifier work: [docs/pinned-codex.md](docs/pinned-codex.md).
199
+
200
+ ## A first run
201
+
202
+ About two minutes, once the installs above are done and the sessions restarted.
203
+
204
+ 1. `relay doctor` should report no failures. Read its warnings: each says what to do.
205
+ 2. In a git repository, start Claude Code and type:
206
+
207
+ ```
208
+ /relay:ask What does this repository do? Answer in three sentences.
209
+ ```
210
+
211
+ Depending on your permission settings, Claude Code may ask you first whether to allow relay's
212
+ tool. Codex starts read-only in the repository, and its answer comes back into your session,
213
+ with the item's `families` saying which family asked and which answered.
214
+ 3. While it runs, `relay tree` in another terminal shows the thread, its status, and what the agent
215
+ is doing.
216
+ 4. The other way round: start Codex in the same repository and type
217
+ `$relay-ask What does this repository do? Answer in three sentences.` This time Claude answers.
218
+
219
+ From there, try `/relay:review` on a file or a branch, or `/relay:delegate write …` on a small task
220
+ and look at its result before you merge it. [docs/usage.md](docs/usage.md) describes every tool.
221
+
222
+ ## Security model
223
+
224
+ Relay launches agents that run code on your Mac, so read this before giving one write access to a
225
+ repository you care about. In short:
226
+
227
+ - **Each launched agent runs in a sandbox.** Claude Code and Codex run in their own macOS sandboxes,
228
+ configured by relay and checked before each turn. Gemini, Copilot and Grok run inside relay's own
229
+ Seatbelt profile, built for each turn, and only after boundary probes have passed under exactly
230
+ that turn's sandbox. With stage 2 on, a Codex job's commands run in relay's Seatbelt instead. A
231
+ write job can write only its own worktree, directories the root session granted, and its private
232
+ temporary directory.
233
+ - **A job's commands have no network unless granted.** The root session grants it per job. A grant
234
+ sends a Claude job's connections, and a Codex job's under stage 2, through a per-turn proxy of
235
+ relay's, which refuses loopback, private, link-local and this Mac's own addresses. With stage 2
236
+ off, a Codex job uses Codex's own network proxy in strict mode (HTTP(S) to public addresses),
237
+ which relay verifies before each turn. For Gemini, Copilot and Grok, "off" still lets them reach
238
+ their own API hosts through relay's proxy, and a grant opens IPv4 to anything but this Mac's own
239
+ addresses, your LAN included. Every agent reaches its own model API either way.
240
+ - **The never floor.** Credential stores (`~/.ssh`, `~/.aws`, `~/.gnupg`, `~/.netrc`, the CLIs' login
241
+ files, the keychain files) are denied to the commands of Claude and Codex jobs, and of Gemini jobs
242
+ while stage 2 is on, whatever they are granted; relay's own config, install and key files are
243
+ protected from every agent. `relay doctor` says which applies on your Mac
244
+ ([the never floor](docs/configuration.md#the-never-floor)).
245
+ - **Logins stay with the CLIs.** Relay runs each CLI under the login that CLI keeps, and refuses a
246
+ turn that would sign in with an API key unless you allow it. The one key relay reads is the Gemini
247
+ API key you save for it, which it hands to Gemini's process alone.
248
+ - **Approvals go to the root.** A launched agent that needs something its sandbox does not allow
249
+ asks; the request goes to the root session, the one you started, and to you in an approval dialog
250
+ where the host is known to show one. What can be allowed is narrow: a Claude or Codex file change
251
+ outside its writable places, a Claude agent's web search or fetch, an explicit access added to one
252
+ Codex command inside its sandbox, and, under stage 2, a new turn with the capabilities the job
253
+ asked for. Relay declines a request to run a command outside the sandbox itself, without asking
254
+ anyone. Some requests (environment variables holding tokens, skills, local or raw network) only
255
+ you can allow.
256
+ - **Settings that leave these guarantees** are off by default and only your config file can set
257
+ them: `allow_dangerous` (a Codex write job without a sandbox while stage 2 is off; Claude write
258
+ jobs refused), `targets.codex.pinned: false` (an unqualified Codex), `child_network` (every job
259
+ gets the network), `allow_untested` and experimental targets, among others listed in
260
+ [SECURITY.md](SECURITY.md#settings-that-take-you-outside-these-guarantees).
261
+ - **The root session is trusted.** It can grant network and write access, merge, and decide
262
+ approval requests. Relay does not protect you from your own root agent, and an approval the root
263
+ agent gives is not proof that a person gave it. `relay approve` in a terminal asks for a code you
264
+ type back, which stops an accidental approval but is not a security boundary.
265
+
266
+ The full model, with a row per agent, is in [docs/security-model.md](docs/security-model.md). To
267
+ report a way around any of it, see [SECURITY.md](SECURITY.md).
268
+
269
+ ### Pinned Codex: what a shipped pin trusts
270
+
271
+ - **What a pin means.** Relay's Codex confinement depends on how one Codex release behaves under relay's checks. So relay runs Codex only from a pin: a release that passed relay's qualification of how Codex behaves under its checks, 33 items today ([Pinned Codex](docs/pinned-codex.md)). `targets.codex.pinned: false` turns this off and runs an unqualified Codex.
272
+ - **A pin you make with `relay qualify-codex`** is that qualification run on your own Mac. It ran under the relay build and evidence schema of its day. It stays in force when relay is upgraded, because it is bound to its Codex binary, not to the relay that runs it later. A pin qualified under an earlier schema keeps the requirements of that schema. Rerunning `relay qualify-codex` for the version that is already pinned changes nothing (the qualifier reports it unchanged); a new pin comes from qualifying another version.
273
+ - **A pin shipped with a release** is the maintainer's qualification, run on the maintainer's Mac, of one Codex release (its version and npm's sha512 integrity) with exactly this relay build (a hash of the installed build). Relay checks everything it can check here:
274
+ - the Codex it downloads must match that integrity, Apple's signature, OpenAI's Team ID and the version;
275
+ - the relay running it must be the build the pin names, both on disk and as the process loaded it at start, or relay refuses Codex on every turn. After an upgrade in place, restart the sessions.
276
+ - The build identity covers relay's own files (`dist/`, the qualifier and the tests it runs) and its dependency lock, `npm-shrinkwrap.json`. Relay also checks that the dependencies it loads (`@modelcontextprotocol/sdk`, `zod`, `smol-toml` and theirs) are the locked versions, and refuses Codex under a shipped pin when they are not; reinstalling relay fixes that.
277
+ - **What relay cannot check here** is that your Mac behaves as the maintainer's did. A different macOS version, other system configuration or other hardware can change how a sandbox behaves, and nothing on your Mac reruns the qualification. This is the same trust as Claude Code's verified list in [`src/targets/verified.ts`](src/targets/verified.ts): versions the maintainer checked, taken on the maintainer's word for your Mac.
278
+ - **To remove that trust**, run `relay qualify-codex` (with `--version` the shipped version to recheck exactly it). Your own pin then takes precedence over the shipped one. `relay doctor` says which pin is in force.
279
+ - **What a shipped pin holds.** The format admits only the Codex version and integrity and relay's build identity, nothing about the maintainer's machine, and relay refuses one that carries anything else.
280
+
281
+ ## Known limits
282
+
283
+ The ones most people meet first. The full list, with what each one covers, is
284
+ [docs/known-limits.md](docs/known-limits.md).
285
+
286
+ - **macOS only.** Process handling relies on `ps`, and confinement on each CLI's macOS sandbox, or on
287
+ relay's own Seatbelt sandbox for Copilot, Gemini and Grok.
288
+ - **Reads are not confined.** Outside the never floor and relay's own directories, a launched agent
289
+ can read whatever you can, and with any network access, including a target's own API host, which
290
+ stays reachable with the network off for the targets relay confines itself, what it reads can
291
+ leave your Mac.
292
+ - **What you approve acts with the access it names.** A file change you allow is made outside the
293
+ job's sandbox, and a capability you allow for a stage-2 turn is that turn's to use. No agent can
294
+ have a command approved to run outside its sandbox: relay declines those requests itself.
295
+ - **Keychain IPC is open for Claude, and for Codex turns with shell network while stage 2 is off.** The floor denies the
296
+ keychain files, so items in file-based keychains stay unreadable, but not the security daemons.
297
+ - **The network proxies judge addresses, not contents.** They cannot inspect TLS, tell apart
298
+ services behind one allowed public endpoint, or screen the network's own public address. A Codex
299
+ job given local mode reaches this Mac's loopback and your LAN; one given raw network (stage 2),
300
+ your LAN and tailnet.
301
+ - **Prompt injection.** Hosted web search and fetched pages can carry it into an agent's context.
302
+ - **Review independence is a workflow barrier, not a guarantee.** Relay withholds the other side's
303
+ review until yours is in, but either side could read unprotected copies of the other's.
304
+ - **Processes an agent detaches can outlive its turn.** Relay stops what it can trace; `merge` takes
305
+ only the commit the job's result showed.
306
+ - **Write jobs can plant configuration below the top of their worktree** (a nested `.claude/` or
307
+ `.mcp.json`, say), which your own agent then loads after you merge. Review a write job's diff
308
+ before you merge it.
309
+ - **ChatGPT's Work mode is unchecked.** Relay has been used from the ChatGPT desktop app's Codex
310
+ side, not from its Work mode; see [ChatGPT desktop app](#chatgpt-desktop-app).
311
+ - **Copilot and Grok are experimental**: off by default, not qualified with a signed-in run, and
312
+ launched only with `targets.<id>.experimental: true`. Gemini signs in with an API key, not an
313
+ account login.
314
+
315
+ ## Status
316
+
317
+ A personal tool, published as it is: built and used by one person, on their own Macs, before this
318
+ first public release.
319
+
320
+ - Recorded tested floors: Claude Code 2.1.302 and codex-cli 0.163.0 (including speed protocol checks). codex-cli 0.164.0 was also checked on 2026-10-23 (read, write, resume and Daybreak runs, at standard speed); the floor stays 0.163.0. Relay's Codex route has been checked on codex-cli <!-- verified:codexCli -->0.163.0, 0.164.0, 0.167.0, 0.167.1, 0.167.2 and 0.170.0<!-- /verified -->. macOS checks are recorded on 27.0, 27.0.1, 27.2 and 27.2.1; doctor reports these and warns on an untested version. Relay refuses to launch an agent on another platform, or with an older CLI, unless you set `allow_untested`.
321
+ - The automated tests run against stub agents and test relay's own logic; where an installed Codex is found, they also check Codex's sandbox as relay configures it, without a model. The confinement claims rest on the qualification records in [docs/qualification](docs/qualification), run on real CLIs before each release.
322
+ - Both CLIs change often, and OpenAI labels `codex app-server` experimental. An update to either can break relay.
323
+ - Read [Security model](#security-model) before giving it write access to a repository you care about.
324
+ - No support is promised. Reports are welcome as GitHub issues; see [Reporting a problem](#reporting-a-problem).
325
+ - Relay is unrelated to T3 Code's "T3 Connect" remote-access relay.
326
+
327
+ The 1.x compatibility and deprecation promises are in [stable surfaces](docs/stable-surfaces.md); upgrade steps and rollback are in [UPGRADING](docs/UPGRADING.md).
328
+
329
+ ## How it works
330
+
331
+ Relay is one stdio MCP server installed in each host. It launches Claude and Codex through their own CLIs (`claude -p`, `codex app-server`) under their stored logins, without reading their API keys or account credentials. The [per-harness security table](docs/security-model.md#per-harness-security) records each additional target's login policy; the one API key relay reads is the one you save for the Gemini target, which it hands to Gemini alone. Agents decide for themselves when to delegate, ask, or discuss. Relay enforces two hard limits, depth and concurrency; jobs and turns have no time limit unless you set one.
332
+
333
+ How it is built: [docs/architecture.md](docs/architecture.md).
334
+
335
+ ## Reference
336
+
337
+ - [docs/install.md](docs/install.md): what install does; Claude Code, Codex, the Claude desktop app, Gemini CLI, OpenCode, Copilot CLI and Grok Build; the `relay` command and PATH; how relay finds Node and the CLIs; upgrading; uninstalling; installing from a git checkout.
338
+ - [docs/usage.md](docs/usage.md): the tools; delegate, consult, discuss and review; speed; approval requests; extensions; watching and stopping runs; `relay tree`, `cancel` and `clean`.
339
+ - [docs/configuration.md](docs/configuration.md): every setting in `~/.config/relay/config.json`, the never floor, the environment launched agents get, Codex's launch checks and its raw network (stage 2).
340
+ - [docs/security-model.md](docs/security-model.md): the per-harness table, and what relay relies on, checks and does not do, including what it keeps on disk and the secrets it cuts from it.
341
+ - [docs/known-limits.md](docs/known-limits.md): every stated limit.
342
+ - [docs/pinned-codex.md](docs/pinned-codex.md): pinned Codex, the qualifier and the build identity.
343
+ - [docs/UPGRADING.md](docs/UPGRADING.md): what changed in each release, and how to upgrade and roll back.
344
+ - [GLOSSARY.md](GLOSSARY.md): relay's terms.
345
+
346
+ `relay --help` lists the commands.
347
+
348
+ ## Accounts and cost
349
+
350
+ Claude, Codex, Copilot and Grok run through their vendors' own unmodified CLIs under the login you already have, and Gemini through its own on an API key. Relay does not read, store or forward your vendor credentials (logins and API keys), with one exception: for the Gemini target, which is key-only (see the [per-harness security table](docs/security-model.md#per-harness-security)) and needs an explicit per-target opt-in (`targets.gemini.child_auth: "any"`), it reads the Gemini API key you saved in a file of your own and hands it to Gemini's process alone, never storing or logging it. Relay also reads the session's own Claude Code inbox token (`CLAUDE_CODE_MESSAGING_TOKEN`), which it uses only to post notices to that same session; it never stores it, and keeps it out of launched agents' environments. That is not a gate: on macOS a process running as you can post to a Claude Code session's inbox without the token (see "Delegate" in [docs/usage.md](docs/usage.md#delegate)), so a relay-formatted notice is a pointer to check, not proof that relay sent it. Launched agents draw on your Claude and ChatGPT plans (and, for the targets that are off by default, your GitHub Copilot or xAI plan, or your Gemini API key's billing) like any other use of those CLIs, and relay has no spending cap: what bounds a run is depth (3) and agents at once (4), and a time limit per job or turn only if you set one. Work delegated at high reasoning effort can use a lot of a plan's allowance, and so can a faster speed (see "Speed" in [docs/usage.md](docs/usage.md#speed); standard unless you ask): Claude's fast mode is billed to usage credits, and Codex's faster tiers use the allowance several times as fast.
351
+
352
+ Whether driving the CLIs from another tool fits each vendor's terms for your plan is for you to check; relay's author is not in a position to say. Anthropic's statement on how Claude Code may be used is at [code.claude.com/docs/en/legal-and-compliance](https://code.claude.com/docs/en/legal-and-compliance).
353
+
354
+ ## Development
355
+
356
+ ```sh
357
+ npm ci
358
+ npm test # builds, then runs the suite; spends nothing
359
+ ```
360
+
361
+ The tests come in three tiers:
362
+
363
+ - **`npm test`** runs relay's logic against stub agents. A few tests also run an installed Codex, without a model, to check its own sandbox as relay configures it (`codex sandbox`): the Codex at the absolute path in `RELAY_TEST_CODEX`, or else the first `codex` on PATH (Homebrew's for one of them). They skip, saying so, where there is none. Nothing in this tier signs in or spends model usage.
364
+ - **Host-only tests** are off unless their variable switches them on (`RELAY_TEST_STAGE2_LIVE=1` and the like, named at the top of each `*-live.test.ts` file). They start real sandboxes and real CLIs on your Mac, and some run a signed-in CLI and spend model usage. CI never switches them on.
365
+ - **Release checks** are run by the maintainer, on real CLIs on the maintainer's Macs: the Codex qualification behind each shipped pin ([docs/pinned-codex.md](docs/pinned-codex.md)), the host-only tests, signed-in checks of the targets, and red-team campaigns. The records in [docs/qualification](docs/qualification) say which checks ran for each version and which did not.
366
+
367
+ The stubs in `test/stubs/` stand in for `claude` and `codex`: they parse the real flag sets, record every prompt and argument they are given, and play back scripted replies, including calls back into relay for nested cases.
368
+
369
+ `smoke/call.mjs` and `smoke/root.mjs` are development tools that launch the real agents, and so spend your plans' allowance. Both need `RELAY_SMOKE_HOST` set to the family the root speaks as (`claude` or `codex`), and `RELAY_HOME` set to a scratch state directory outside temporary directories: they refuse the default `~/.local/state/relay`, whose registry a newer build would migrate. The first makes one call as a root session. The second keeps one root session alive behind a Unix socket so that follow-up calls (resume, approve, discuss) reach the same run; the socket carries that session's full authority, and the tool refuses a socket whose directory is not yours alone. `smoke/claude-network-probe.mjs` checks, without spending model usage, that a Claude Code binary keeps a network-granted job on relay's proxy (see the Claude network item in [docs/known-limits.md](docs/known-limits.md)).
370
+
371
+ Tests must never change real files on your machine (installed programs, the home folder, dotfiles, CLI logins): every test file loads `test/helpers.ts`, which gives it a scratch HOME and refuses paths under the real one, and a guard test checks that each file loads it. An installed Codex is only ever run, with scratch homes. In a worktree someone else is also working in, stage explicit paths; never `git commit -a`.
372
+
373
+ The hosts run a checkout's `dist/` directly, so a rebuild there replaces live code. If your hosts run relay from a checkout, develop in a separate git worktree and rebuild the main checkout only when nothing is running (`relay tree`).
374
+
375
+ `npm run build && node adapters/build.mjs` regenerates every host's adapter from one set of skill texts; each host's layout is in its module in `src/hosts/`. Each host also gets the prompting brief for every family it reaches: `adapters/briefs/<target>.md`, written by that family, with the model-specific notes (effort values, model advice) kept apart in `adapters/briefs/models.json`, dated and tied to the harness version they were checked with. Relay's `brief` tool returns the same text, for hosts and launched agents without the plugin. The build refuses notes checked with an older version than the one relay is tested with, so raising that version means checking them again. `relay doctor` says when an installed CLI is newer than the version the notes were checked with, and warns about it from a month after the check, when a new model or effort level is likely to have shipped. A test fails if the checked-in adapters differ from what the build generates.
376
+
377
+ ## Reporting a problem
378
+
379
+ Open an issue with what you ran, what happened, your macOS version and the output of `relay doctor`. Logs and transcripts under `~/.local/state/relay/runs/` help, but they can contain anything an agent read, including file contents and paths: relay cuts only the secrets it knows the shape of (see "What is kept" in [docs/security-model.md](docs/security-model.md)), so read them and cut what should not be public before attaching them.
380
+
381
+ A security problem (a way around confinement, the never floor, the network proxy or approvals, or a check that claims a protection that is not there) goes through GitHub's private vulnerability reporting instead of an issue: see [SECURITY.md](SECURITY.md).
382
+
383
+ Contributions are welcome: see [CONTRIBUTING.md](CONTRIBUTING.md) for how they land.
384
+
385
+ ## License
386
+
387
+ MIT; see [LICENSE](LICENSE). Third-party notices are in [LICENSES/](LICENSES/).
package/SECURITY.md ADDED
@@ -0,0 +1,145 @@
1
+ # Security policy
2
+
3
+ Relay launches coding agents (Claude Code, Codex CLI and, when you switch them on, Gemini CLI,
4
+ Copilot CLI and Grok Build) on your Mac and passes work between them. A flaw in relay can let an
5
+ agent do more than you allowed, so reports are welcome and taken seriously.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Report it privately through GitHub: open this repository's **Security** tab and choose
10
+ **Report a vulnerability** (GitHub's private vulnerability reporting). Please don't open a public
11
+ issue, discussion or pull request for a security problem.
12
+
13
+ A useful report says:
14
+
15
+ - the relay version (`relay --version`) and the commit if you built from source;
16
+ - your macOS version and the versions of the agent CLIs involved (`relay doctor` prints them);
17
+ - the relevant parts of your relay configuration, and which target, mode and grants the job had;
18
+ - the steps that reproduce it, and what an agent could do that it should not have been able to.
19
+
20
+ Relay's logs and transcripts (`~/.local/state/relay/runs/`) can contain anything an agent read,
21
+ including file contents, paths and tokens. Check and trim them before attaching them.
22
+
23
+ Relay is maintained by one person, as a personal project. Expect an acknowledgement within two
24
+ weeks and a fix on a best-effort basis; there is no bug bounty. Once a fix is released, the report
25
+ is published as a GitHub security advisory, with credit to you if you want it.
26
+
27
+ ## Supported versions
28
+
29
+ Only the latest release is supported. Security fixes ship in a new patch release on the latest
30
+ minor line (1.2.x when this was written); earlier lines are not patched. Relay runs on macOS only,
31
+ with Node 24.15 or newer, and supports the agent CLI versions recorded in
32
+ [stable surfaces](docs/stable-surfaces.md#supported-versions-and-qualification). Running relay with
33
+ `allow_untested`, or a target marked `experimental`, is outside what relay has qualified.
34
+
35
+ ## What relay's security model covers
36
+
37
+ The README's [Security model](README.md#security-model) has the summary; the full description is
38
+ [docs/security-model.md](docs/security-model.md), with a row per agent in
39
+ [Per-harness security](docs/security-model.md#per-harness-security). With relay's default
40
+ configuration, it aims to ensure the following. The settings that change it are listed in the next
41
+ section.
42
+
43
+ - **Each launched agent runs inside a sandbox.** Claude Code and Codex run in their own macOS
44
+ sandboxes, which relay configures and checks before each turn. Gemini, Copilot and Grok run in a
45
+ Seatbelt profile relay builds for each turn, and only after boundary probes have passed under
46
+ that turn's profile. With stage 2 switched on (`targets.codex.stage2`, off by default), a Codex
47
+ turn that has the network, or that can ask relay for more access, runs its commands in relay's
48
+ own Seatbelt profile instead of Codex's sandbox. A write job writes only its own worktree, the
49
+ directories the root session granted, and its own temporary directory.
50
+ - **A job's commands have no network unless it is granted.** The root session grants the network
51
+ per job (`grant.network`). What a grant opens depends on the agent:
52
+
53
+ | Agent | No grant | `network: true` |
54
+ | --- | --- | --- |
55
+ | Claude Code | No network for its commands. | Commands go through relay's proxy for the turn, which refuses loopback, private, link-local, on-link and this Mac's own addresses and screens your `never` hosts and ports. |
56
+ | Codex, stage 2 off (the default) | No network for its commands. | Codex's own network proxy in strict mode, which relay checks before each turn: HTTP(S) to public addresses only. It cannot screen `never` hosts or every kind of `never` port, so relay refuses the turn while you have an entry it cannot enforce. Where relay cannot verify the proxy, the turn gets Codex's hosted web search only. |
57
+ | Codex, stage 2 on | No network for its commands. | Relay's proxy (stage-2 mediated), which reaches public hosts only and screens your `never` rules. |
58
+ | Gemini, Copilot, Grok | Only the target's own API hosts, through relay's proxy, which screens your `never` rules (for Copilot and Grok, also what the certificate-trust daemons fetch, past the proxy). | IPv4 to anything but this Mac's own addresses: the internet and your local network (LAN). |
59
+
60
+ Two Codex grants widen this, and only you can allow either: `local_network` (stage 2 off, write
61
+ jobs) also opens this Mac's loopback and your LAN; `raw_network` (stage 2 on, write jobs) gives
62
+ raw TCP, UDP, ssh and DNS to the internet, your LAN and tailnet, and this Mac's loopback except
63
+ the ports relay denies. Without a grant, every agent can still reach its own model API, and
64
+ Claude's and Codex's web tools can follow `child_web`.
65
+ - **The never floor holds where it applies.** Paths such as `~/.ssh`, `~/.aws`, `~/.gnupg`,
66
+ `~/.netrc`, the agent CLIs' login files and the keychain files are denied to the commands of a
67
+ Claude or Codex job, and of a Gemini job while stage 2 is on. Relay's own configuration, install
68
+ and key files are protected from every agent. Where a route cannot enforce one of your `never`
69
+ entries, relay refuses the turn rather than run it without. `relay doctor` says which agents the
70
+ floor binds on your Mac.
71
+ - **Logins stay with the CLIs.** Relay runs each CLI under the login that CLI keeps and does not
72
+ read its credentials. By default it refuses a turn that would sign in with an API key
73
+ (`child_auth`). The one key relay reads is the Gemini API key you save for it, which it hands
74
+ to Gemini's process alone.
75
+ - **Approvals go to the top.** A job's request to act outside its limits goes to the root session
76
+ (to you, where the host can show an approval dialog), never to the agent that asked or the agents
77
+ in between. What can be approved is narrow: a Claude or Codex file change outside the job's
78
+ writable places, a Claude agent's web search or fetch, an explicit access a Codex command asks to
79
+ have added inside its sandbox, and, under stage 2, a new turn with the capabilities the job asked
80
+ for. Some requests only you can allow, never the root agent: a Codex job's `local_network` or
81
+ `raw_network`, skills given to a job, and environment values released to one turn. Relay itself
82
+ declines, without asking anyone, a native Codex request to run a command outside its sandbox and
83
+ every Claude request to run a command. For Gemini, Copilot and Grok an approval lets the agent go
84
+ ahead inside its sandbox and never widens it. A request to change relay's own files or another
85
+ job's worktree is refused without anyone being asked
86
+ ([Approval requests](docs/usage.md#approval-requests)).
87
+ - **Relay's own reports are honest.** A check that did not run is reported as not run, never as
88
+ passed.
89
+
90
+ A way around any of these, an agent reading or changing relay's state, credentials or another
91
+ job's files, or a doctor or qualification result that claims a protection that is not there, is
92
+ a vulnerability. Please report it.
93
+
94
+ ## Settings that take you outside these guarantees
95
+
96
+ Each of these is off by default and can be set only in relay's config file, never by a tool call.
97
+
98
+ - **`allow_dangerous`.** With stage 2 off, a Codex write job runs in Codex's full-access mode:
99
+ no sandbox, every network connection, and no never floor. With stage 2 on, relay refuses a Codex
100
+ write turn that would run that way. Claude write jobs are refused under it. It also turns off
101
+ approval requests.
102
+ - **`targets.codex.pinned: false`.** Relay runs the Codex that `targets.codex.bin` names instead
103
+ of a qualified pin. Relay still configures and checks its sandbox, but nothing has qualified how
104
+ that Codex behaves under relay's checks.
105
+ - **`child_network`.** Every job gets the network, as if granted.
106
+ - **`allow_untested`**, and **`targets.<id>.experimental`** for Copilot and Grok: versions,
107
+ platforms and targets relay has not qualified.
108
+ - **`child_mcp: "inherit"`, `child_hooks: true`, `trust_git_filters`, `child_git: "native"`,
109
+ `child_auth: "any"`, `codex_endpoint_override: "accept"`.** Each lets something relay does not
110
+ vet run or connect: your own MCP servers and hooks, a repository's git filters, a job's own git
111
+ configuration and hooks, API-key logins, or another endpoint. Relay refuses Claude jobs under the
112
+ first two. [Configuration](docs/configuration.md) describes each.
113
+
114
+ ## What it does not cover
115
+
116
+ These are stated limits, documented in [Known limits](docs/known-limits.md), not vulnerabilities.
117
+ A report that shows one is worse than described is still welcome.
118
+
119
+ - The session you start relay from (the root) is fully trusted: it can grant network and write
120
+ access, merge, and decide approval requests. Relay does not protect you from your own root agent.
121
+ - Reads are not confined: outside the never floor and relay's own directories, a launched agent can
122
+ read whatever you can, and with any network access (including a target's own API, which stays
123
+ reachable with the network off) what it reads can leave your Mac.
124
+ - What you approve runs with the access the request names. A file change you allow is made outside
125
+ the sandbox; a capability you allow for a Codex turn is that turn's to use.
126
+ - With stage 2 off (the default), the never floor does not bind Gemini, Copilot or Grok: they can
127
+ read the credential paths. Copilot and Grok are refused while stage 2 is on, because their login
128
+ routes conflict with the floor.
129
+ - Keychain IPC stays open for Claude, and for Codex turns with shell network while stage 2 is off:
130
+ the floor denies the keychain files, but not the security daemons.
131
+ - A Codex job given `local_network` reaches this Mac's loopback and your LAN; one given
132
+ `raw_network`, your LAN and tailnet. Gemini, Copilot and Grok with the network reach your LAN.
133
+ - The network proxies check addresses and hosts, not TLS contents: they cannot tell apart services
134
+ behind the same allowed public endpoint, stop an allowed server from forwarding elsewhere, or
135
+ screen your network's own public address.
136
+ - Hosted web search and fetched pages can carry prompt injection into an agent's context.
137
+ - Experimental targets (Copilot, Grok), versions run under `allow_untested`, and platforms other
138
+ than macOS.
139
+ - Flaws in the agent CLIs' own sandboxes or in the models themselves. Report those to the vendor
140
+ (Anthropic, OpenAI, Google, GitHub or xAI) through its own security channel; tell relay too if
141
+ relay should work around the flaw.
142
+
143
+ Relay's automated tests check its own logic against stub agents, plus model-free checks of an
144
+ installed Codex's sandbox where one is found. The confinement claims rest on the qualification
145
+ records in [docs/qualification](docs/qualification), run on real CLIs before each release.
@@ -0,0 +1,43 @@
1
+ Write the assignment the way you would brief a capable colleague who has not seen any of your work: what you want, why, and how you will know it is done. Claude follows instructions closely and literally, so what the text leaves out it will not infer, and what it says it will act on.
2
+
3
+ ### Structure the task
4
+
5
+ - Open with the outcome in one or two sentences, then the reason for it. Knowing what the work is for lets Claude make the judgment calls you did not anticipate.
6
+ - Then give what it needs, in this order as far as it applies: context (files, symbols, decisions already made and why), requirements and non-goals, how to verify, and what to hand back.
7
+ - Say plainly whether you want changes made or only proposed. "Can you suggest how to fix this" gets a suggestion; "fix this" gets a fix.
8
+ - Put long material (logs, a spec, a failing test's output) before the instructions that refer to it, and wrap each piece in its own tag, such as `<log>` or `<spec>`, so instructions and material cannot be confused. Plain headings are enough for the rest.
9
+ - If one example would settle a format or a behavior, include it, and make sure it matches the requirements exactly: Claude copies examples closely, including their accidents.
10
+
11
+ ### Ground the work
12
+
13
+ - The launched agent sees only your text and relay's preamble. Name the paths, the commands and the decisions; do not refer to "the bug we discussed" or "the approach above".
14
+ - Separate what you have checked from what you suspect. Ask it to confirm a diagnosis against the code before building on it, and to say so if the evidence points elsewhere.
15
+ - State constraints with their reasons ("keep the public API unchanged: two other services import it"). A reason travels to cases a bare rule does not cover.
16
+ - Mark pasted third-party text (an email, an issue, a web page) as material to evaluate, not instructions to follow.
17
+
18
+ ### Define the deliverable and the stopping point
19
+
20
+ - Name the deliverable: working changes with tests, a diagnosis, a recommendation with its tradeoffs, a list of findings. In a job, put any answer or structured output before relay's report, not in place of it.
21
+ - For implementation, say the job ends when the change works and is verified, not at a plan or a progress summary. For analysis, say where to stop so it does not drift into implementing.
22
+ - Bound the scope. Claude tends to be thorough: without a stated limit it may add tests, refactors or abstractions you did not ask for. Say what is out of scope and ask for unrelated problems to be reported, not fixed.
23
+ - Allow it to make reasonable, reversible choices and state them; reserve questions for missing facts that change the result. A launched agent has nobody to answer mid-turn, so it should finish what it can and report what it needs.
24
+
25
+ ### Specify verification
26
+
27
+ - Give the exact commands for build, tests and lint, and anything they need (environment variables, a service, a fixture).
28
+ - Say what counts as evidence for each acceptance criterion; a passing suite may not exercise the change. Ask for a regression test when one would show the fix.
29
+ - Ask it to report each check as run and passed, run and failed, or not run with the reason, and to say what it could not verify.
30
+
31
+ ### Avoid what works against Claude
32
+
33
+ - Capitals, "MUST", "CRITICAL" and repeated warnings. Current Claude models already take instructions seriously; emphasis makes them overapply a rule to cases it was never meant for. Say it once, calmly, with the reason.
34
+ - Long lists of prohibitions. Say what to do instead: "write the summary as prose paragraphs" works better than "no bullet points, no headers, no lists".
35
+ - Asking it to write out its full reasoning step by step in the reply. It reasons before answering on its own; ask for conclusions, evidence and a short rationale.
36
+ - Terse ticket shorthand with no why ("fix auth flake, see CI"). Claude does its best work when it understands the purpose and the stakes.
37
+ - Prescribing tool calls or naming tools from your own host. Describe the result; Claude Code has its own tools for reading, editing, searching and running commands.
38
+
39
+ ### Questions through `ask`
40
+
41
+ - State the question, the decision it feeds, and what evidence would settle it. Name the files to read first with `context`.
42
+ - Ask for a direct answer first, then the support for it, and for disagreement with your premise if the evidence warrants it. A thread is read-only, so ask for a recommendation or a patch in the reply, not edits.
43
+ - Follow up in the same thread, saying what changed since the last answer.