agent-embassy 1.0.0 → 1.2.0

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 (73) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +50 -5
  3. package/README.zh-CN.md +32 -5
  4. package/SECURITY.md +26 -2
  5. package/assets/live-dashboard/app.css +14 -5
  6. package/dist/src/gateway/claude-helper-protocol.d.ts +3 -0
  7. package/dist/src/gateway/claude-helper-protocol.js +15 -1
  8. package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
  9. package/dist/src/gateway/claude-helper-supervisor.d.ts +2 -0
  10. package/dist/src/gateway/claude-helper-supervisor.js +25 -1
  11. package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
  12. package/dist/src/gateway/cli-copy.en.d.ts +1 -0
  13. package/dist/src/gateway/cli-copy.en.js +1 -0
  14. package/dist/src/gateway/cli-copy.en.js.map +1 -1
  15. package/dist/src/gateway/cli-copy.zh-CN.d.ts +1 -0
  16. package/dist/src/gateway/cli-copy.zh-CN.js +1 -0
  17. package/dist/src/gateway/cli-copy.zh-CN.js.map +1 -1
  18. package/dist/src/gateway/cli.d.ts +1 -1
  19. package/dist/src/gateway/cli.js +20 -7
  20. package/dist/src/gateway/cli.js.map +1 -1
  21. package/dist/src/gateway/codex-app-server.js +6 -2
  22. package/dist/src/gateway/codex-app-server.js.map +1 -1
  23. package/dist/src/gateway/codex-local-transport.d.ts +13 -0
  24. package/dist/src/gateway/codex-local-transport.js +21 -2
  25. package/dist/src/gateway/codex-local-transport.js.map +1 -1
  26. package/dist/src/gateway/config.js +5 -3
  27. package/dist/src/gateway/config.js.map +1 -1
  28. package/dist/src/gateway/control.d.ts +11 -1
  29. package/dist/src/gateway/control.js +48 -14
  30. package/dist/src/gateway/control.js.map +1 -1
  31. package/dist/src/gateway/dashboard-copy.d.ts +1 -1
  32. package/dist/src/gateway/dashboard-copy.en.d.ts +6 -0
  33. package/dist/src/gateway/dashboard-copy.en.js +11 -5
  34. package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
  35. package/dist/src/gateway/dashboard-copy.js +6 -0
  36. package/dist/src/gateway/dashboard-copy.js.map +1 -1
  37. package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +6 -0
  38. package/dist/src/gateway/dashboard-copy.zh-CN.js +11 -5
  39. package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
  40. package/dist/src/gateway/dashboard-model.d.ts +4 -2
  41. package/dist/src/gateway/dashboard-model.js +6 -0
  42. package/dist/src/gateway/dashboard-model.js.map +1 -1
  43. package/dist/src/gateway/dashboard.js +5 -3
  44. package/dist/src/gateway/dashboard.js.map +1 -1
  45. package/dist/src/gateway/live-dashboard-app/app.js +48 -10
  46. package/dist/src/gateway/live-dashboard-command.js +10 -0
  47. package/dist/src/gateway/live-dashboard-command.js.map +1 -1
  48. package/dist/src/gateway/live-dashboard-http.d.ts +3 -0
  49. package/dist/src/gateway/live-dashboard-http.js +13 -0
  50. package/dist/src/gateway/live-dashboard-http.js.map +1 -1
  51. package/dist/src/gateway/live-dashboard-stream.js +26 -25
  52. package/dist/src/gateway/live-dashboard-stream.js.map +1 -1
  53. package/dist/src/gateway/provenance-envelope.d.ts +16 -0
  54. package/dist/src/gateway/provenance-envelope.js +80 -0
  55. package/dist/src/gateway/provenance-envelope.js.map +1 -0
  56. package/dist/src/gateway/providers.d.ts +43 -16
  57. package/dist/src/gateway/providers.js +688 -61
  58. package/dist/src/gateway/providers.js.map +1 -1
  59. package/dist/src/gateway/server.d.ts +2 -0
  60. package/dist/src/gateway/server.js +9 -3
  61. package/dist/src/gateway/server.js.map +1 -1
  62. package/dist/src/gateway/service.d.ts +102 -10
  63. package/dist/src/gateway/service.js +1309 -54
  64. package/dist/src/gateway/service.js.map +1 -1
  65. package/dist/src/gateway/store.d.ts +39 -3
  66. package/dist/src/gateway/store.js +528 -26
  67. package/dist/src/gateway/store.js.map +1 -1
  68. package/dist/src/gateway/types.d.ts +90 -5
  69. package/dist/src/gateway/types.js +6 -0
  70. package/dist/src/gateway/types.js.map +1 -1
  71. package/docs/GATEWAY-ARCHITECTURE.md +98 -11
  72. package/package.json +3 -2
  73. package/skills/embassy-peer/SKILL.md +15 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,50 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [1.2.0] - 2026-08-10
10
+
11
+ Deliverability over everything: a message you send arrives, or tells you loudly why it could not.
12
+
13
+ ### Added
14
+
15
+ - **Broker-owned provenance envelopes and recipient replies** — every routed body now reaches Codex or Claude inside one deterministic `cross-session-message` textual frame with broker-validated sender attribution. Its first `embassy-reply-hint` carries the full conversation token, the exact recipient alias, and the stdin-based `embassy reply` command, so either participant can continue without reconstructing a token. Codex receives the full token as an outer `conversation` attribute as well; Claude retains its canonical outer shape and receives the token in the hint. Sender aliases over Claude's 64-character display bound use a deterministic hashed label while preserving the exact alias in the hint.
16
+ - **The durable queue** — message bodies persist in the broker's private mode-0600 state under bounded retention. Queued mail survives a broker restart and re-sends exactly once when its route is re-observed; in-flight-at-crash messages settle `ambiguous` — never silently lost, never double-sent. The live dashboard's delivery detail shows each retained body (bounded display), with an honest fallback for deliveries whose body was not retained. Static dashboards remain metadata-only.
17
+ - **Boot reactivation** — after a broker restart, retained Codex routes re-anchor automatically at startup through the same exactly-once `thread/loaded/list` proof, including staged handling when the App Server moved endpoint generations while the broker was down. `register-codex` becomes recovery of last resort; transient replies are never retargeted across a restart.
18
+ - **The deliverability soak** — `npm run soak` drives a seeded, randomized churn of sends through scripted dispatch faults, busy/idle flips, clock jumps, and full restarts, asserting that every accepted message settles exactly once into an explicit terminal outcome with an allowlisted reason.
19
+
20
+ ### Changed
21
+
22
+ - Message deadlines default to **4 hours** (was 5 minutes; max 24 hours) — agent turns routinely outlive minutes-scale deadlines, and expiry is now rare and explicit rather than routine. Stall notices stay early, within two minutes.
23
+ - Conversation hop budgets exist to stop runaway reply loops, not conversations: the default is **16** (was 2; max 64).
24
+ - Claude-bound dispatch failures carry their exact safe codes, and the broker redispatches bounded retries when the route is observed idle instead of settling terminal on first refusal.
25
+ - Documentation across both languages now states the durable-queue truth: bodies are stored, bounded, and shown; restarts keep queued mail.
26
+
27
+ ### Fixed
28
+
29
+ - The live dashboard's "Source restarted; view resynchronized" banner appears only on a true source-revision regression; clock-derived field churn no longer masquerades as a restart or triggers a frame broadcast every poll.
30
+
31
+ ### Security
32
+
33
+ - The envelope is a structural provenance marker, not XML, a cryptographic signature, or authentication against same-UID code. Broker-reserved opening and closing tag shapes inside the untrusted body are neutralized before delivery; framing happens exactly once at the final provider boundary, and invalid metadata or framed-size overflow fails before any write. The full conversation token remains transient and participant-scoped: reply rechecks caller, conversation membership, route, and hop policy, and the token never enters durable state, journals, logs, receipts, public snapshots, events, or dashboards.
34
+ - Body persistence keeps the same trust boundary the product always had: the OS account. Retained bodies live in the mode-0600 state directory and appear only on the loopback live dashboard; raw provider frames stay memory-only.
35
+
36
+ ## [1.1.0] - 2026-08-09
37
+
38
+ ### Added
39
+
40
+ - **Automatic Codex endpoint reactivation** — when the managed App Server moves from one endpoint generation to another, Embassy freezes the old connector, runs the existing bounded compatibility probe against the replacement, and re-anchors each retained route only after `thread/loaded/list` finds its byte-identical task exactly once. The alias, owner lease, and pair edges survive; the private bounded journal records the generation refresh without projecting the task ID or either endpoint generation.
41
+ - **Bounded stale-registration recovery** — the authenticated live dashboard can request removal of one canonical `codex-*` alias after an explicit confirmation. The broker accepts the operation only for a stale registration whose owning endpoint generation is dead, revalidates and quiesces the exact route, removes its incident pair edges, and records the successful recovery in its private bounded journal. Ready, merely offline, current-generation, and ambiguous routes fail closed.
42
+
43
+ ### Changed
44
+
45
+ - `CALLER_IDENTITY_CONFLICT` now gives a targeted bilingual recovery hint only when both Codex and Claude identities were inherited: restart the Codex App Server daemon from a normal terminal with `codex app-server daemon restart`. Wrong-principal failures keep the generic fail-closed advice.
46
+
47
+ ### Security
48
+
49
+ - Endpoint replacement never restores or replays a body, callback, receipt handle, reply capability, conversation capability, or delivery token. An incompatible replacement, a missing or duplicate exact task, or an unclean transition leaves the retained route stale and surfaces bounded compatibility evidence for diagnosis rather than retargeting it.
50
+
7
51
  ## [1.0.0] - 2026-08-09
8
52
 
9
53
  ### Added
package/README.md CHANGED
@@ -25,7 +25,14 @@ Embassy is built for one person, one macOS account, and agents you already trust
25
25
 
26
26
  ## Quickstart
27
27
 
28
- **Requirements:** macOS, Node.js 20+, Claude Code 2.1.226 (still-running 2.1.224–2.1.225 sessions remain discoverable), and Codex desktop configured to use the managed standalone App Server 0.147.0. The Claude session you select as a destination needs [`crossSessionInbound`](docs/CONFIGURATION.md) enabled — that is Claude Code's own setting, configured in Claude Code, not in Embassy.
28
+ **Requirements:** macOS, Node.js 20+, Claude Code 2.1.226 (still-running 2.1.224–2.1.225 sessions remain discoverable), and Codex desktop configured to use the managed standalone App Server 0.147.0:
29
+
30
+ ```bash
31
+ ~/.codex/packages/standalone/current/codex app-server daemon start
32
+ /usr/bin/open --env CODEX_APP_SERVER_USE_LOCAL_DAEMON=1 -a ChatGPT
33
+ ```
34
+
35
+ The first command starts the managed daemon if it is not already running (`restart` and `stop` also exist); the second launches the ChatGPT desktop app pointed at it. `CODEX_APP_SERVER_USE_LOCAL_DAEMON` is not documented by OpenAI; it is observed to work with this Desktop build and may change. Run the daemon command from a normal terminal, never from inside an agent session: Codex tasks inherit the daemon's environment, so a daemon started inside a Claude Code session leaks that session's identity into every task and registration fails closed with `CALLER_IDENTITY_CONFLICT` — fix it from a normal terminal with `codex app-server daemon restart`. The Claude session you select as a destination needs [`crossSessionInbound`](docs/CONFIGURATION.md) enabled — that is Claude Code's own setting, configured in Claude Code, not in Embassy.
29
36
 
30
37
  > **Known limitation:** Embassy can reach Codex tasks only while Desktop uses the managed standalone App Server. In that mode, tasks currently cannot connect to Desktop's built-in in-app browser (`@Browser` loads but does not attach). Switching Desktop back to its default private App Server restores the built-in browser immediately — but makes those tasks unreachable by Embassy. No other capability regressions have been identified, though this was not an exhaustive parity test.
31
38
 
@@ -56,6 +63,8 @@ embassy register-codex --alias codex-reviewer@this-mac
56
63
 
57
64
  You should see `"accepted":true`. The `codex-` prefix is required for Claude discovery. To retire the task later, run `unregister-codex`.
58
65
 
66
+ While the same `embassy serve` broker remains running, a managed App Server restart makes Embassy probe the new endpoint and reattach this alias only when the replacement is compatible and `thread/loaded/list` finds the byte-identical task exactly once. An incompatible endpoint or a missing or duplicate exact task leaves the route stale for diagnosis; Embassy never retargets by alias and never reconstructs or replays a message body across the endpoint-generation boundary. If `embassy serve` itself restarts, the retained route starts stale with `REOBSERVATION_REQUIRED`; until boot-time reactivation is implemented, the exact Codex task must rerun `embassy register-codex --alias codex-reviewer@this-mac` without unregistering first.
67
+
59
68
  ### 3. Select a Claude destination
60
69
 
61
70
  Pick one name from `availablePeers`:
@@ -83,7 +92,9 @@ You should see a `conv_` conversation token and a `dlv_` delivery token. Because
83
92
 
84
93
  ### 5. Follow up
85
94
 
86
- Either side can continue the conversation:
95
+ Either participant can continue the conversation with `reply`. The initiating
96
+ CLI receives the full `conv_` token in its accepted result; the recipient gets
97
+ the same token and an exact reply command in the broker-owned message marker:
87
98
 
88
99
  ```bash
89
100
  embassy reply \
@@ -93,10 +104,28 @@ Please expand on the migration risk.
93
104
  MSG
94
105
  ```
95
106
 
107
+ Every routed body reaches either product inside one broker-owned
108
+ `<cross-session-message>` textual frame. It identifies the verified sender
109
+ alias and begins with an `<embassy-reply-hint>` containing the full conversation
110
+ token, the recipient's exact alias, and the corresponding `embassy reply`
111
+ command. Use only that delivered full token and alias; never guess one from a
112
+ suffix or substitute the sender's alias. The CLI still rechecks the caller,
113
+ conversation membership, current route policy, and hop limit, so the hint is
114
+ not a permission bypass.
115
+
116
+ The frame is a clear provenance marker, not a cryptographic signature or a
117
+ claim that the body is trustworthy. Embassy neutralizes nested occurrences of
118
+ its two reserved framing tags in the untrusted body before provider delivery;
119
+ arbitrary same-user code and all message text remain untrusted input.
120
+
121
+ `EMBASSY_MAX_HOPS` bounds each conversation against runaway reply loops. The initial send is hop 0 and each routed reply increments the count; the default `16` means a normal conversation never notices it. An attempt past the bound is rejected and recorded as `HOP_LIMIT_EXCEEDED`. Do not retry an exhausted conversation token; start a fresh conversation. The accepted range and other bounds are documented in [Configuration](docs/CONFIGURATION.md).
122
+
96
123
  ### See it live
97
124
 
98
125
  `embassy dashboard --live` opens a five-tab streaming view in the browser (overview, deliveries, routes, activity, diagnostics). See [Dashboard](docs/DASHBOARD.md) for details.
99
126
 
127
+ The live dashboard can also remove an orphaned Codex registration after an explicit confirmation, but only when the broker proves that the registration is stale and its owning endpoint generation is dead. A current, merely offline, or ambiguous generation is never removable through this recovery action.
128
+
100
129
  The broker also publishes mode-0600 static snapshots as `gateway-dashboard.html` and `gateway-dashboard.zh-CN.html`. Live dashboard mutations require the same-origin `X-Embassy-Request` sentinel.
101
130
 
102
131
  ## How it works
@@ -118,6 +147,12 @@ A pair is one explicit permission edge between one Claude session and one Codex
118
147
 
119
148
  Messages queue while the Codex task is busy and start an ordinary turn when it goes idle. In the Claude-to-Codex direction only, a body with an exact leading `STEER:` prefix may enter the active turn at the App Server's next tool-call boundary; if that boundary is unavailable, the message returns to the normal queue.
120
149
 
150
+ Immediately before the provider write, Embassy gives every routed body one
151
+ broker-owned cross-session marker containing the verified sender alias and a
152
+ recipient reply hint. The full conversation token travels only in the
153
+ initiator's accepted result and the recipient's transient message payload; it
154
+ never enters the dashboard, public snapshot, journal, receipt, or log.
155
+
121
156
  Every settled message produces a receipt. `delivered` means terminal provider evidence was observed — toward Codex, the App Server accepted the turn; toward Claude, the message was released into the session's native queue. Neither means the model read or acted on it. `unconfirmed` and `ambiguous` mean evidence is missing; they are terminal states and never auto-retried. See [Delivery](docs/DELIVERY.md) for the full semantics.
122
157
 
123
158
  ## The vocabulary
@@ -126,13 +161,22 @@ Four embassy terms name real features:
126
161
 
127
162
  - **Registration and pairing** are the permission model: a Codex task is explicitly registered, and each pair is one explicit Claude↔Codex edge — only paired ends exchange messages, and many edges can coexist. No edge means `SENDER_NOT_PAIRED`; nothing is ever implicit.
128
163
  - **The ledger** is the delivery record: a receipt for every settled message, and a metadata-only dashboard.
129
- - **The pouch** is transit: bounded bodies, ephemeral inside Embassy, never persisted by it.
164
+ - **The pouch** is transit and the archive: bounded bodies, retained under bounded limits, private to your OS account — sealed against other users, not against you.
130
165
  - **Consulates** are the roadmap: the same model extended to Codex tasks on remote hosts over attach-only SSH — designed, and deliberately disabled in v1.
131
166
 
132
167
  ## For agents
133
168
 
134
169
  Embassy's operators are often agents themselves: `register-codex` runs inside the Codex task, and the Claude side is driven entirely through native tools. The repo ships [`skills/embassy-peer/SKILL.md`](skills/embassy-peer/SKILL.md) — point your agent at it rather than paraphrasing this README.
135
170
 
171
+ The skill ships in the npm package; install it where each agent discovers skills:
172
+
173
+ ```bash
174
+ cp -R "$(npm root -g)/agent-embassy/skills/embassy-peer" ~/.codex/skills/
175
+ cp -R "$(npm root -g)/agent-embassy/skills/embassy-peer" ~/.claude/skills/
176
+ ```
177
+
178
+ Codex tasks can then be prompted with `$embassy-peer`; Claude Code discovers it as a user skill.
179
+
136
180
  ## Commands
137
181
 
138
182
  | Command | Run by | Purpose |
@@ -148,14 +192,15 @@ Embassy's operators are often agents themselves: `register-codex` runs inside th
148
192
  | `select-claude` / `unselect-claude` | operator | One-task shorthand for `pair`/`unpair`: resolves the Codex end only when it is unambiguous (inherited or sole registered task), otherwise fails closed |
149
193
  | `send-to-claude` | registered Codex task | Send one bounded message to a paired Claude session |
150
194
  | `send-to-codex` | Claude session | Send one bounded message using the inherited native reply identity |
151
- | `reply` | either provider | Continue an active conversation by its public token |
195
+ | `reply` | conversation-token holder | Continue an active conversation with the full token returned to the initiator or delivered in the recipient's broker-owned reply hint |
152
196
 
153
197
  ## Safety in one minute
154
198
 
155
199
  - **Local sockets only.** `embassy serve` listens on private Unix-domain sockets and makes no provider API call. The opt-in `embassy dashboard --live` companion is a separate process and the only listener Embassy can create, bound to `127.0.0.1` on an ephemeral port.
156
200
  - **Same-UID containment, not authentication.** Caller identity is inherited from the local process environment. Route ownership and generation checks reduce mistakes, but are not a defense against code already running as your OS user.
157
201
  - **Native permissions stay native.** Embassy sends no Codex approval or sandbox overrides and answers no approval request. `crossSessionInbound` remains Claude's own control; Embassy cannot override it.
158
- - **Bodies never persisted.** Message bodies, prompts, replies, and raw provider frames live only in memory. Metadata-only dashboard files are mode 0600 with no JavaScript.
202
+ - **Provenance is marked, not authenticated.** Routed bodies carry one broker-owned cross-session marker with the verified sender alias; it distinguishes the transport path for the receiving model but cannot make untrusted text safe or authenticate against code already running as your OS user.
203
+ - **Bodies stored, bounded, and yours.** Message bodies persist in the broker's private mode-0600 state under bounded retention so the ledger can show you the mail itself; queued mail survives a broker restart and re-sends exactly once. Raw provider frames stay memory-only. The static dashboard files remain metadata-only; the live dashboard shows retained bodies.
159
204
 
160
205
  See [SECURITY.md](SECURITY.md) for the full boundary and vulnerability-reporting process.
161
206
 
package/README.zh-CN.md CHANGED
@@ -25,7 +25,14 @@ Embassy 专为单人、单一 macOS 账户以及你已信任以该用户身份
25
25
 
26
26
  ## 快速开始
27
27
 
28
- **前置要求:** macOS、Node.js 20+、Claude Code 2.1.226(仍在运行的 2.1.224–2.1.225 会话保持可发现),以及配置为使用托管独立 App Server 0.147.0 的 Codex 桌面应用。你选择作为目的地的 Claude 会话需要启用 [`crossSessionInbound`](docs/CONFIGURATION.zh-CN.md)——这是 Claude Code 自身的设置,在 Claude Code 中配置,而非在 Embassy 中。
28
+ **前置要求:** macOS、Node.js 20+、Claude Code 2.1.226(仍在运行的 2.1.224–2.1.225 会话保持可发现),以及配置为使用托管独立 App Server 0.147.0 的 Codex 桌面应用:
29
+
30
+ ```bash
31
+ ~/.codex/packages/standalone/current/codex app-server daemon start
32
+ /usr/bin/open --env CODEX_APP_SERVER_USE_LOCAL_DAEMON=1 -a ChatGPT
33
+ ```
34
+
35
+ 第一条命令在托管守护进程未运行时启动它(也提供 `restart` 与 `stop` 子命令);第二条以指向该守护进程的方式启动 ChatGPT 桌面应用。`CODEX_APP_SERVER_USE_LOCAL_DAEMON` 未见于 OpenAI 文档;它经验证适用于当前 Desktop 构建,未来可能变化。请在普通终端中运行守护进程命令,切勿在代理会话内运行:Codex 任务会继承守护进程的环境,因此在 Claude Code 会话内启动的守护进程会把该会话的身份泄漏到每个任务中,注册将以 `CALLER_IDENTITY_CONFLICT` 关闭失败——请在普通终端执行 `codex app-server daemon restart` 修复。你选择作为目的地的 Claude 会话需要启用 [`crossSessionInbound`](docs/CONFIGURATION.zh-CN.md)——这是 Claude Code 自身的设置,在 Claude Code 中配置,而非在 Embassy 中。
29
36
 
30
37
  > **已知限制:** 仅当 Desktop 使用托管独立 App Server 时,Embassy 才能访问 Codex 任务。在该模式下,任务目前无法连接 Desktop 内置的应用内浏览器(`@Browser` 可加载但无法附着)。将 Desktop 切换回其默认的私有 App Server 会立即恢复内置浏览器——但会使这些任务对 Embassy 不可达。目前未发现其他能力回退,但这并非穷尽的能力对比测试。
31
38
 
@@ -56,6 +63,8 @@ embassy register-codex --alias codex-reviewer@this-mac
56
63
 
57
64
  你应看到 `"accepted":true`。`codex-` 前缀是 Claude 发现所必需的。之后若要注销该任务,运行 `unregister-codex`。
58
65
 
66
+ 仅在同一个 `embassy serve` 代理持续运行期间,托管 App Server 重启后 Embassy 才会自动探测新端点;只有替代端点兼容,且 `thread/loaded/list` 恰好一次找到字节级一致的原任务时,才会重新附着这个别名。端点不兼容,或精确任务缺失、重复,都会使路由保持陈旧以供诊断;Embassy 绝不会按别名改投其他任务,也不会跨端点代际边界重建或重放消息正文。如果 `embassy serve` 本身重启,保留的路由会以 `REOBSERVATION_REQUIRED` 陈旧状态启动;在启动时自动重新激活功能实现之前,必须由同一个 Codex 任务使用同一别名再次运行 `embassy register-codex --alias codex-reviewer@this-mac`,且不要先注销。
67
+
59
68
  ### 3. 选择 Claude 目的地
60
69
 
61
70
  从 `availablePeers` 中选择一个名称:
@@ -83,7 +92,7 @@ MSG
83
92
 
84
93
  ### 5. 后续跟进
85
94
 
86
- 任一方都可以继续对话:
95
+ 任何持有完整 `conv_` 令牌的对话参与方都可以用 `reply` 继续仍然有效的对话。初始发送方从 Embassy 命令结果中获得令牌;接收方则从入站消息的来源封装中获得同一个完整令牌和回复提示:
87
96
 
88
97
  ```bash
89
98
  embassy reply \
@@ -93,10 +102,16 @@ Please expand on the migration risk.
93
102
  MSG
94
103
  ```
95
104
 
105
+ Embassy 会在实际写入提供方之前,为双向路由消息添加一个由代理控制的 `<cross-session-message>` 来源封装。封装标出已经验证的发送方别名,其首个 `<embassy-reply-hint>` 元素包含完整对话令牌、接收方自己的精确别名和可直接使用的 `embassy reply` 命令。朝向 Codex 时,外层标记本身还带有 `conversation="conv_..."`;朝向 Claude 时,为符合 Claude Code 的规范解析格式,完整令牌和回复提示位于封装正文中,而不作为外层属性。请使用收到的完整令牌,切勿猜测或重构它。令牌本身不授予路由权限:每次回复仍会重新检查调用方身份、对话参与关系、实时路由和跳数上限。
106
+
107
+ `EMBASSY_MAX_HOPS` 限制每个对话的跳数,用于阻止失控的回复循环。初始发送为第 0 跳,此后每次路由回复都会递增;默认值 `16` 意味着正常对话不会触及它。超过上限的尝试会被拒绝,并记录为 `HOP_LIMIT_EXCEEDED`。不要重试已耗尽的对话令牌;请开始新对话。可接受范围及其他边界详见[配置](docs/CONFIGURATION.zh-CN.md)。
108
+
96
109
  ### 实时查看
97
110
 
98
111
  `embassy dashboard --live` 在浏览器中打开一个五选项卡流式视图(总览、投递、路由、活动、诊断)。详见[仪表盘](docs/DASHBOARD.zh-CN.md)。
99
112
 
113
+ 实时仪表盘也可以在明确确认后移除孤立的 Codex 注册,但仅限代理已经证明该注册陈旧且其所属端点代际已失效的情况。当前、仅离线或代际状态不明确的注册绝不能通过此恢复操作移除。
114
+
100
115
  代理还会以 mode 0600 发布静态快照 `gateway-dashboard.html` 与 `gateway-dashboard.zh-CN.html`。实时仪表盘的变更操作必须携带同源 `X-Embassy-Request` 哨兵头。
101
116
 
102
117
  ## 工作原理
@@ -118,6 +133,8 @@ Embassy 将每个已注册的 Codex 任务以各自的 `codex-*` 对等方身份
118
133
 
119
134
  消息在 Codex 任务忙碌时排队,并在任务空闲后启动普通轮次。仅在 Claude→Codex 方向,正文以精确 `STEER:` 开头的消息可以在 App Server 的下一个工具调用边界进入当前轮次;若该边界不可用,消息会回到普通队列。
120
135
 
136
+ 每条被路由的消息在接收方看到时都位于 Embassy 生成的跨会话来源封装中,其中包含已验证的发送方别名、完整 `conv_` 令牌和面向该接收方的回复提示。来源封装是模型可见的结构性提示,并非密码学身份认证;消息正文始终应被视为不可信输入。
137
+
121
138
  每条已结算的消息都会产生回执。`delivered` 表示观测到了终端提供方证据——朝向 Codex,意味着 App Server 接受了该轮次;朝向 Claude,意味着消息已释放到会话的原生队列。两者都不意味着模型已读取或执行。`unconfirmed` 和 `ambiguous` 表示证据缺失;它们是终态,从不自动重试。完整语义详见[投递](docs/DELIVERY.zh-CN.md)。
122
139
 
123
140
  ## 核心术语
@@ -126,13 +143,22 @@ Embassy 将每个已注册的 Codex 任务以各自的 `codex-*` 对等方身份
126
143
 
127
144
  - **注册与配对**构成权限模型:Codex 任务通过显式注册发布,每个配对是一条显式的 Claude↔Codex 边——只有配对的两端可以交换消息,且多条边可以并存。没有边意味着 `SENDER_NOT_PAIRED`;一切都是显式的。
128
145
  - **账簿**是投递记录:每条已结算消息的回执,以及一个仅包含元数据的仪表盘。
129
- - **信袋**是传输通道:有界的消息体,在 Embassy 内部是临时的,从不被持久化。
146
+ - **信袋**既是传输通道也是档案:有界的消息体,按有界策略保留,只属于你的操作系统账户 对其他用户封缄,对你敞开。
130
147
  - **领事馆**是路线图:将同一模型通过仅限 attach 的 SSH 扩展到远程主机上的 Codex 任务——已完成设计,但在 v1 中有意禁用。
131
148
 
132
149
  ## 面向代理
133
150
 
134
151
  Embassy 的操作者本身往往就是代理:`register-codex` 在 Codex 任务内部运行,而 Claude 端完全通过原生工具驱动。仓库附带 [`skills/embassy-peer/SKILL.md`](skills/embassy-peer/SKILL.md)——请将你的代理指向该技能,而非向它复述本 README。
135
152
 
153
+ 该技能随 npm 包一同发布;将它安装到各代理发现技能的目录:
154
+
155
+ ```bash
156
+ cp -R "$(npm root -g)/agent-embassy/skills/embassy-peer" ~/.codex/skills/
157
+ cp -R "$(npm root -g)/agent-embassy/skills/embassy-peer" ~/.claude/skills/
158
+ ```
159
+
160
+ 之后即可在 Codex 任务中通过 `$embassy-peer` 调用;Claude Code 会将其作为用户技能自动发现。
161
+
136
162
  ## 命令一览
137
163
 
138
164
  | 命令 | 执行者 | 用途 |
@@ -148,14 +174,15 @@ Embassy 的操作者本身往往就是代理:`register-codex` 在 Codex 任务
148
174
  | `select-claude` / `unselect-claude` | 操作员 | `pair`/`unpair` 的单任务简写:仅在 Codex 端无歧义(继承标识或唯一已注册任务)时解析,否则以关闭状态失败 |
149
175
  | `send-to-claude` | 已注册的 Codex 任务 | 向已配对的 Claude 会话发送一条有界消息 |
150
176
  | `send-to-codex` | Claude 会话 | 使用继承的原生回复标识发送一条有界消息 |
151
- | `reply` | 任一提供方 | 通过公开令牌继续一个活跃对话 |
177
+ | `reply` | 对话令牌持有方 | 使用初始发送时返回或随入站来源提示收到的完整令牌继续一个活跃对话;路由和跳数限制会重新检查 |
152
178
 
153
179
  ## 一分钟了解安全性
154
180
 
155
181
  - **仅限本地套接字。** `embassy serve` 仅监听私有 Unix 域套接字,不发起任何提供商 API 调用。可选启用的 `embassy dashboard --live` 组件是一个独立进程,也是 Embassy 能创建的唯一监听器,绑定到 `127.0.0.1` 上的临时端口。
156
182
  - **同 UID 隔离,而非身份认证。** 调用者身份继承自本地进程环境。路由所有权和生成号检查能减少误操作,但不是对已以你的 OS 用户身份运行的代码的防御。
183
+ - **来源标记是提示,不是签名。** Embassy 在提供方写入边界生成跨会话来源封装,让接收模型能够区分代理路由消息及其已验证发送方别名;这不是密码学证明,也不会把不可信正文变成可信指令。
157
184
  - **原生权限保持原生。** Embassy 不发送任何 Codex 审批或沙盒覆盖,也不应答任何审批请求。`crossSessionInbound` 仍是 Claude 自身的控制机制;Embassy 无法覆盖它。
158
- - **消息体从不持久化。** 消息体、提示词、回复和原始提供方帧仅存在于内存中。仅含元数据的仪表盘文件为 mode 0600,不含 JavaScript。
185
+ - **消息体有界保存,属于你。** 消息体以有界保留策略持久化在 broker 的私有 mode-0600 状态中,让台账能够展示邮件本身;排队中的邮件在 broker 重启后幸存并恰好重发一次。原始提供方帧仍仅存于内存。静态仪表盘文件保持仅元数据;实时仪表盘展示保留的正文。
159
186
 
160
187
  完整的安全边界和漏洞报告流程请参见 [SECURITY.md](SECURITY.md)。
161
188
 
package/SECURITY.md CHANGED
@@ -40,6 +40,11 @@ against other processes running as the same OS user.
40
40
  reply capability, not a credential.
41
41
  - Aliases are labels. They do not grant authority and are re-resolved against
42
42
  the exact private route binding before delivery.
43
+ - Immediately before provider delivery, Embassy places the body inside one
44
+ broker-owned `cross-session-message` textual frame. Its sender attribution
45
+ and first-child reply hint come from validated broker metadata, not from the
46
+ message body. This is a provenance boundary for the receiving model, not a
47
+ cryptographic signature or authentication against same-UID code.
43
48
  - Any process already running as the same OS user may be able to present local
44
49
  environment or socket capabilities. Embassy is not a sandbox for untrusted
45
50
  same-user code.
@@ -67,10 +72,15 @@ against other processes running as the same OS user.
67
72
  path; with an approval-requiring policy, the turn may wait for the user.
68
73
  - Claude's native `crossSessionInbound` setting controls messages entering a
69
74
  Claude session. Embassy cannot override an accept, hold, or refuse decision.
75
+ - A CLI initiator receives the full conversation token in the accepted control
76
+ result, and every routed recipient receives it in the broker-owned first
77
+ `embassy-reply-hint`. The token is a transient participant-scoped locator,
78
+ not sufficient authority: `reply` rechecks inherited caller identity,
79
+ conversation membership, current routing policy, and hop count.
70
80
 
71
81
  Every routed message is untrusted input capable of steering the receiving
72
- agent. Registration and selection control reachability; they do not make the
73
- message content trustworthy.
82
+ agent. Registration and routing control reachability; the provenance marker
83
+ does not make the message content or asserted intent trustworthy.
74
84
 
75
85
  The literal leading `STEER:` prefix is a protocol instruction, not proof of a
76
86
  trusted author or safe intent. Any exact same-UID Claude sender already allowed
@@ -114,6 +124,11 @@ broker.
114
124
  - Queues, frames, bodies, callbacks, deadlines, hop counts, deduplication,
115
125
  rate limits, and transient conversations are bounded. Ambiguous writes are
116
126
  never retried automatically.
127
+ - Raw-body classification and accounting happen before framing. In the
128
+ untrusted body only, Embassy case-insensitively neutralizes boundary-shaped
129
+ opening or closing copies of `cross-session-message` and
130
+ `embassy-reply-hint` before composing the real outer frame. Framing or size
131
+ failure occurs before provider write and is never an ambiguous write.
117
132
  - The only network listener Embassy can create belongs to the opt-in
118
133
  `embassy dashboard --live` companion, described under "Live companion
119
134
  boundary". Everything enumerated above concerns `embassy serve`.
@@ -161,6 +176,15 @@ Message bodies, prompts, replies, raw provider frames, tool data, stderr,
161
176
  callback addresses, and socket paths remain memory-only. They are discarded on
162
177
  restart and never replayed.
163
178
 
179
+ The full `conv_` token exposed to a CLI initiator or routed recipient travels
180
+ only inside the accepted CLI result or transient provider payload. It is never
181
+ persisted, journaled, logged, placed in a receipt, projected through public
182
+ events or snapshots, or rendered on either dashboard; public metadata may
183
+ retain only an existing non-reconstructable suffix. Broker-owned marker fields
184
+ introduce no socket paths, Codex thread IDs, Claude session UUIDs, endpoint
185
+ generations, or private route handles. The untrusted body remains opaque text
186
+ and may itself contain sender-provided strings.
187
+
164
188
  The closed private binding store may retain the exact Codex thread ID and Claude
165
189
  session UUID required for ownership and endpoint re-observation. Native IDs are
166
190
  forbidden from public snapshots, normalized events, the dashboard, aliases,
@@ -766,7 +766,6 @@ button:not(:disabled):hover { opacity: .92; }
766
766
  align-items: baseline;
767
767
  flex-wrap: wrap;
768
768
  border: 1px solid var(--hairline);
769
- border-left-width: 3px;
770
769
  border-radius: var(--radius-sm);
771
770
  padding: 12px 16px;
772
771
  font-size: 13px;
@@ -775,17 +774,14 @@ button:not(:disabled):hover { opacity: .92; }
775
774
  }
776
775
  .notice[data-tone="info"] {
777
776
  border-color: var(--border-light);
778
- border-left-color: var(--action-blue);
779
777
  background: var(--pale-blue);
780
778
  }
781
779
  .notice[data-tone="warning"] {
782
780
  border-color: var(--coral-soft);
783
- border-left-color: var(--coral);
784
781
  background: var(--coral-wash-soft);
785
782
  }
786
783
  .notice[data-tone="error"] {
787
784
  border-color: var(--coral-soft);
788
- border-left-color: var(--error);
789
785
  background: var(--error-tint);
790
786
  }
791
787
  .notice__label {
@@ -1167,7 +1163,7 @@ button:not(:disabled):hover { opacity: .92; }
1167
1163
  border: 1px solid var(--hairline);
1168
1164
  background: var(--surface-card);
1169
1165
  }
1170
- .watch-card[data-phase="episode"] { border-left: 3px solid var(--coral); }
1166
+ .watch-card[data-phase="episode"] { border-color: var(--coral-soft); background: var(--coral-wash-soft); }
1171
1167
  .watch-card__head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
1172
1168
  .watch-card > strong { display: block; margin-top: 10px; overflow-wrap: anywhere; }
1173
1169
  .watch-card__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 0; }
@@ -1236,6 +1232,19 @@ button:not(:disabled):hover { opacity: .92; }
1236
1232
  }
1237
1233
  .detail-pane__head { display: grid; gap: 6px; }
1238
1234
  .detail-pane__sub { font-size: 13px; color: var(--muted); }
1235
+ .detail-pane__message-body {
1236
+ margin: 6px 0 0;
1237
+ padding: 10px 12px;
1238
+ max-height: 240px;
1239
+ overflow: auto;
1240
+ font-family: var(--mono);
1241
+ font-size: 12.5px;
1242
+ line-height: 1.55;
1243
+ white-space: pre-wrap;
1244
+ overflow-wrap: anywhere;
1245
+ border: 1px solid var(--hairline);
1246
+ background: var(--surface-warm);
1247
+ }
1239
1248
  .detail-pane__empty {
1240
1249
  font-size: 14px;
1241
1250
  color: var(--muted);
@@ -38,6 +38,9 @@ export type ClaudeNativeHelperCommand = Readonly<{
38
38
  binding: PrivateRouteBinding;
39
39
  authorization: "selected_route" | "native_reply";
40
40
  messageId: string;
41
+ sourceAlias: string;
42
+ targetAlias: string;
43
+ conversationId: string;
41
44
  text: string;
42
45
  expectsReply: boolean;
43
46
  deadlineAt: string;
@@ -1,11 +1,15 @@
1
1
  export const CLAUDE_NATIVE_HELPER_PROTOCOL_VERSION = 1;
2
- export const CLAUDE_NATIVE_HELPER_MAX_IPC_BYTES = 32 * 1024;
2
+ // A valid raw 16 KiB dispatch can expand to nearly 96 KiB when JSON escapes
3
+ // control characters. Keep the private IPC frame bounded while carrying that
4
+ // exact reviewed raw-body maximum without changing the provider wire limit.
5
+ export const CLAUDE_NATIVE_HELPER_MAX_IPC_BYTES = 128 * 1024;
3
6
  export const CLAUDE_NATIVE_HELPER_MAX_REQUESTS = 64;
4
7
  const SAFE_CODE = /^[A-Z][A-Z0-9_]{0,95}$/;
5
8
  const REQUEST_ID = /^[A-Za-z0-9_-]{16,64}$/;
6
9
  const GENERATION = /^[A-Za-z0-9_-]{1,32}$/;
7
10
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
8
11
  const ALIAS = /^[a-z][a-z0-9_-]{0,31}@[a-z0-9](?:[a-z0-9.-]{0,61}[a-z0-9])?$/;
12
+ const CONVERSATION_ID = /^conv_[A-Za-z0-9_-]{16,64}$/;
9
13
  const ROUTE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/;
10
14
  function record(value) {
11
15
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -100,6 +104,9 @@ function command(value) {
100
104
  "binding",
101
105
  "authorization",
102
106
  "messageId",
107
+ "sourceAlias",
108
+ "targetAlias",
109
+ "conversationId",
103
110
  "text",
104
111
  "expectsReply",
105
112
  "deadlineAt",
@@ -108,6 +115,13 @@ function command(value) {
108
115
  (value.authorization === "selected_route" ||
109
116
  value.authorization === "native_reply") &&
110
117
  boundedString(value.messageId, 256) &&
118
+ typeof value.sourceAlias === "string" &&
119
+ ALIAS.test(value.sourceAlias) &&
120
+ value.sourceAlias.startsWith("codex-") &&
121
+ typeof value.targetAlias === "string" &&
122
+ ALIAS.test(value.targetAlias) &&
123
+ typeof value.conversationId === "string" &&
124
+ CONVERSATION_ID.test(value.conversationId) &&
111
125
  typeof value.text === "string" &&
112
126
  Buffer.byteLength(value.text, "utf8") <= 16 * 1024 &&
113
127
  typeof value.expectsReply === "boolean" &&
@@ -1 +1 @@
1
- {"version":3,"file":"claude-helper-protocol.js","sourceRoot":"","sources":["../../../src/gateway/claude-helper-protocol.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAU,CAAC;AAChE,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5D,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AA4LpD,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAC3C,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAC3C,MAAM,IAAI,GAAG,4EAA4E,CAAC;AAC1F,MAAM,KAAK,GAAG,+DAA+D,CAAC;AAC9E,MAAM,KAAK,GAAG,qCAAqC,CAAC;AAEpD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,KAAK,CACZ,KAA8B,EAC9B,QAA2B,EAC3B,WAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;IACpD,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CA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S,KAAK,SAAS,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAc;IAC5D,IACE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAChD,kCAAkC,EAClC,CAAC;QACD,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
@@ -28,6 +28,8 @@ export declare class ClaudeNativeHelperSupervisor {
28
28
  unadvertise(alias: string): Promise<void>;
29
29
  dispatch(input: Readonly<{
30
30
  sourceAlias: string;
31
+ targetAlias: string;
32
+ conversationId: string;
31
33
  selectedAlias?: string;
32
34
  stateRoot?: string;
33
35
  binding: PrivateRouteBinding;
@@ -11,6 +11,9 @@ const TERMINAL_DELIVERY_STATES = new Set([
11
11
  "failed",
12
12
  "cancelled",
13
13
  ]);
14
+ const PUBLIC_ALIAS = /^[a-z][a-z0-9_-]{0,31}@[a-z0-9](?:[a-z0-9.-]{0,61}[a-z0-9])?$/;
15
+ const CONVERSATION_ID = /^conv_[A-Za-z0-9_-]{16,64}$/;
16
+ const MAX_RAW_BODY_BYTES = 16 * 1024;
14
17
  function fault(code, recoverable = false) {
15
18
  return new BridgeError(code, "The supervised native Claude advertisement could not complete its bounded operation.", recoverable);
16
19
  }
@@ -138,12 +141,30 @@ export class ClaudeNativeHelperSupervisor {
138
141
  throw failure;
139
142
  }
140
143
  async dispatch(input) {
144
+ if (typeof input.sourceAlias !== "string" ||
145
+ !PUBLIC_ALIAS.test(input.sourceAlias) ||
146
+ !input.sourceAlias.startsWith("codex-") ||
147
+ typeof input.targetAlias !== "string" ||
148
+ !PUBLIC_ALIAS.test(input.targetAlias) ||
149
+ typeof input.conversationId !== "string" ||
150
+ !CONVERSATION_ID.test(input.conversationId) ||
151
+ typeof input.text !== "string") {
152
+ return { state: "failed", safeErrorCode: "PROVENANCE_ENVELOPE_INVALID" };
153
+ }
154
+ if (Buffer.byteLength(input.text, "utf8") > MAX_RAW_BODY_BYTES) {
155
+ return {
156
+ state: "failed",
157
+ safeErrorCode: "PROVENANCE_ENVELOPE_TOO_LARGE",
158
+ };
159
+ }
141
160
  const helper = this.#helpersByAlias.get(input.sourceAlias);
142
161
  if (helper === undefined || helper.closing) {
143
162
  return { state: "failed", safeErrorCode: "CLAUDE_NATIVE_HELPER_UNAVAILABLE" };
144
163
  }
145
164
  if (input.authorization === "selected_route") {
146
- if (input.selectedAlias === undefined || input.stateRoot === undefined) {
165
+ if (input.selectedAlias === undefined ||
166
+ input.selectedAlias !== input.targetAlias ||
167
+ input.stateRoot === undefined) {
147
168
  return { state: "failed", safeErrorCode: "CLAUDE_ROUTE_UNAVAILABLE" };
148
169
  }
149
170
  const authority = `${input.selectedAlias}\0${input.stateRoot}`;
@@ -167,6 +188,9 @@ export class ClaudeNativeHelperSupervisor {
167
188
  binding: input.binding,
168
189
  authorization: input.authorization,
169
190
  messageId: input.messageId,
191
+ sourceAlias: helper.activeAlias,
192
+ targetAlias: input.targetAlias,
193
+ conversationId: input.conversationId,
170
194
  text: input.text,
171
195
  expectsReply: input.expectsReply,
172
196
  deadlineAt: input.deadlineAt,