@linxin666/dsh-remote-bridge 0.4.16 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 697ff27093520de35e6fa631fcb50581daeff7a5
6
- README.zh.md: 1c1a6d7ea5df84a6044b1a83009c8160b1bf3600
5
+ README.md: 9d734cffc206d476df5b975eebbd3077d21a039b
6
+ README.zh.md: 6b9152398c4640b44f3933d5a0ce85038cd58b8c
package/README.md CHANGED
@@ -5,7 +5,7 @@ English | [中文](README.zh.md)
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-remote-bridge?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.1-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -49,12 +49,13 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
49
49
 
50
50
  | method | request `p` | response `r` |
51
51
  | --- | --- | --- |
52
- | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:21, server:"dsh-remote-bridge", capabilities:["session.snapshot.trim.v1","session.snapshot.page.v1","questions.v1","questions.list.v1","subagent.thread.v1","jobs.v1","agents.v1","delta.v1","session.list.omit-archived.v1","session.deep-history.v1","frame.deflate.v1","session.list.compact.v1","session.snapshot.since.v1","session.fork.v1","commands.v1","workspace.v1","session.admin.v1","squads.v1","push.v1","usage.v1","usage.stats.v1","ui.v1","ui.list.v1"], resume:"snapshot", auth:"paired" or "unpaired"}` |
52
+ | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:22, server:"dsh-remote-bridge", capabilities:["session.snapshot.trim.v1","session.snapshot.page.v1","questions.v1","questions.list.v1","subagent.thread.v1","jobs.v1","agents.v1","delta.v1","session.list.omit-archived.v1","session.deep-history.v1","frame.deflate.v1","session.list.compact.v1","session.snapshot.since.v1","session.fork.v1","commands.v1","workspace.v1","session.admin.v1","squads.v1","push.v1","usage.v1","usage.stats.v1","ui.v1","ui.list.v1","session.attachment.path.v1"], resume:"snapshot", auth:"paired" or "unpaired"}` |
53
53
  | `session.list` | `{since?, cwd?, maxRows?, after?}` | `{mode, token, sessions:[{id, title, updatedAt, agentRunning, cwd?, parentSessionId?, origin?, blank, archived?}]}`, or `{mode:"reset", token:"", compact:true, sessions:[...], nextAfter?}` for a compact page |
54
54
  | `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
55
55
  | `session.snapshot` | `{sessionId, sinceSeq?, maxBytes?}` | `{turns:[...], lastSeq:<uint>, hasMore?}`, plus `mode:"since", reset:false` for an increment and `mode:"full", reset:true` for a baseline that replaces the copy a client holds |
56
56
  | `session.history` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
57
57
  | `session.history.deep` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
58
+ | `session.attachment.path` | `{sessionId, path}` | `{image:{path, mediaType?, bytes?, width?, height?}, data:"<base64>"}` — the reference the session's own record stated, beside the bytes at that path. The path must be absolute and byte-identical to one the session named; `path-not-in-session`, `not-found`, `not-an-image` or `frame-too-large` answers instead |
58
59
  | `session.prompt` | `{sessionId, text, requestId}` | `{accepted:true}` |
59
60
  | `session.interrupt` | `{sessionId}` | `{ok:true}` |
60
61
  | `presets.list` | `{}` | the host's `agentPresets/list` body verbatim |
@@ -150,7 +151,7 @@ The package publishes one generic seam and puts no vocabulary of its own in it.
150
151
 
151
152
  A registered method is dispatched after both protocol gates: a name no plugin registered answers `unknown-method` before anything else runs, a client without a live device token answers `unpaired` exactly as it does for a protocol method, and a client that never declared the table's capability is told `unknown-method` — the method is absent from its protocol rather than forbidden to it. The handler receives the request payload and the calling connection's id, and answers `{ok:true, r}` or `{ok:false, code, msg}`; the bridge forwards either verbatim, because refusal codes belong to the registering plugin. A handler that throws, or answers neither shape, crosses as the bridge's own `internal`.
152
153
 
153
- `hello` answers `minor:21`, since the interactive-reply channel shipped: it adds two capability names (`ui.v1`, `ui.list.v1`), one topic (`ui.request`), two methods (`ui.event`, `ui.list`) and one model tool (`ui_present`), so a client reads two new names, a new event and two new reply bodies off the wire, and no existing frame, method or key changes shape. `minor:20` was when the usage stats channel shipped: behind `usage.stats.v1` a client may call `usage.stats` and read the host's own ledger, and `usage.session` may answer `modelContextWindow` from the route's model catalog, so it reads one new reply body and one new optional key off the wire and has to read the name before it asks — a bridge below this one answers `unknown-method` and omits the key, and no frame, topic or existing method changes shape. `minor:19` was when the usage channel shipped: behind `usage.v1` a client may call `usage.session` and `usage.balance`, so it read two new reply bodies off the wire and had to read the name before it asked — a bridge below that one answers `unknown-method` for both. `minor:18` was when one lock-screen card learned to lay out several sessions: `content-state` may now carry `rows`, at most three `{name, status, phase}` items, ordered by the bridge — the sessions waiting on the user first, in the order their questions arrived, then the sessions running now, most recently updated first — so no method, no capability name and no existing key changes shape, and the minor rises by one. A row's `name` is the host's own title with its trailing path group taken off, because the wire carries no paths. `minor:17` was when the live-activity channel shipped: the lock-screen card is driven by the registration surface `push.v1` already carries, and this bridge gained only the sending path — a `liveactivity` push of one session's own state. `minor:16` was when the notification channel shipped: behind `push.v1` a client may call `push.register` and have the device table remember an APNs token, so a phone learns a turn ended — or that a question is waiting — while its own socket is not open. `minor:15` was when the squads channel shipped: behind `squads.v1` a client may call `squads.state`, `squads.list`, `squads.runs`, `squads.runMember` and `squads.runSquad`, so it reads five new reply bodies off the wire and drives the host's squad domain instead of deriving agents from anything else. `minor:14` was when the session-admin channel shipped: behind `workspace.v1` a client may call `workspace.list` and read the host's workspaces with both registry-global session sets, and behind `session.admin.v1` it may rename, pin, unpin, archive and unarchive a session, so it reads six new reply bodies off the wire. `minor:13` was when the question list shipped: behind `questions.list.v1` a client may call `question.list` and be answered the questions this bridge is still holding — the set a phone reconciles the cards it holds against, and the only way it learns that a question ended while it was away, because the bridge withdraws every claim when the last paired device leaves. `minor:12` was when the command channel shipped: behind `commands.v1` a client may call `session.commands` and `session.command`, so it reads a new reply body off the wire. `minor:11` was when the fork channel shipped, one step above the snapshot-`since` channel that landed on the integration branch first: behind `session.fork.v1` a client may call `session.fork` and be answered the host's own fork result. `minor:10` was when the snapshot became incremental on request: behind `session.snapshot.since.v1` a `session.snapshot` that names `sinceSeq` is answered either the entries above that watermark or a full baseline carrying `mode` and `reset`, so the number rises for a reply shape a client reads off the wire. `minor:9` was when the compact roster shipped: behind `session.list.compact.v1` a listing that names `cwd`, `maxRows` or `after` is answered a shorter row that may be paged, so the number rises for a row schema a client reads off the wire. `minor:8` was when the outbound frame form became a capability: behind `frame.deflate.v1` a declaring client may be answered in binary frames carrying raw DEFLATE of the text, so the number is raised for something a client reads off the wire. `minor:7` was when the two channels met; `minor:6` was either channel on its own — the agent channel on dev and durable history paging on its branch; `minor:5` was when the roster stopped carrying archived sessions. Behind `agents.v1`, `presets.list` and `session.create` forward the host's preset roster and one creation request; behind `session.deep-history.v1`, `session.history.deep` pages a session's durable store back to its first entry; behind `session.fork.v1`, `session.fork` branches one session into a new one that inherits it. `minor:4` added byte-level increments, `minor:3` the background-job channel, `minor:2` the subagent thread, and `minor:1` was this seam. Major 1 and every frozen field, method name and topic name are unchanged by all of them. The one body that shrank for every client rather than only for those that declare a capability is the roster itself, which no longer names an archived session; every other answer a client that declares nothing receives is protocol v1's own.
154
+ `hello` answers `minor:22`, since the image-by-path channel shipped: behind `session.attachment.path.v1` — an announcement and nothing more, exactly as `session.deep-history.v1` is — a client may call `session.attachment.path` and read the bytes of one image the session's own durable transcript named, either the offload placeholder a message body carries or the image reference a durable tool result published, so it reads one new reply body off the wire and has to read the name before it asks. The method is open to every paired connection: the name is how a client learns it exists, never what lets the bridge serve it, and a client that does not declare it loses only that knowledge. No frame, no topic and no existing method changes shape. `minor:21` was when the interactive-reply channel shipped: it adds two capability names (`ui.v1`, `ui.list.v1`), one topic (`ui.request`), two methods (`ui.event`, `ui.list`) and one model tool (`ui_present`), so a client reads two new names, a new event and two new reply bodies off the wire, and no existing frame, method or key changes shape. `minor:20` was when the usage stats channel shipped: behind `usage.stats.v1` a client may call `usage.stats` and read the host's own ledger, and `usage.session` may answer `modelContextWindow` from the route's model catalog, so it reads one new reply body and one new optional key off the wire and has to read the name before it asks — a bridge below this one answers `unknown-method` and omits the key, and no frame, topic or existing method changes shape. `minor:19` was when the usage channel shipped: behind `usage.v1` a client may call `usage.session` and `usage.balance`, so it read two new reply bodies off the wire and had to read the name before it asked — a bridge below that one answers `unknown-method` for both. `minor:18` was when one lock-screen card learned to lay out several sessions: `content-state` may now carry `rows`, at most three `{name, status, phase}` items, ordered by the bridge — the sessions waiting on the user first, in the order their questions arrived, then the sessions running now, most recently updated first — so no method, no capability name and no existing key changes shape, and the minor rises by one. A row's `name` is the host's own title with its trailing path group taken off, because the wire carries no paths. `minor:17` was when the live-activity channel shipped: the lock-screen card is driven by the registration surface `push.v1` already carries, and this bridge gained only the sending path — a `liveactivity` push of one session's own state. `minor:16` was when the notification channel shipped: behind `push.v1` a client may call `push.register` and have the device table remember an APNs token, so a phone learns a turn ended — or that a question is waiting — while its own socket is not open. `minor:15` was when the squads channel shipped: behind `squads.v1` a client may call `squads.state`, `squads.list`, `squads.runs`, `squads.runMember` and `squads.runSquad`, so it reads five new reply bodies off the wire and drives the host's squad domain instead of deriving agents from anything else. `minor:14` was when the session-admin channel shipped: behind `workspace.v1` a client may call `workspace.list` and read the host's workspaces with both registry-global session sets, and behind `session.admin.v1` it may rename, pin, unpin, archive and unarchive a session, so it reads six new reply bodies off the wire. `minor:13` was when the question list shipped: behind `questions.list.v1` a client may call `question.list` and be answered the questions this bridge is still holding — the set a phone reconciles the cards it holds against, and the only way it learns that a question ended while it was away, because the bridge withdraws every claim when the last paired device leaves. `minor:12` was when the command channel shipped: behind `commands.v1` a client may call `session.commands` and `session.command`, so it reads a new reply body off the wire. `minor:11` was when the fork channel shipped, one step above the snapshot-`since` channel that landed on the integration branch first: behind `session.fork.v1` a client may call `session.fork` and be answered the host's own fork result. `minor:10` was when the snapshot became incremental on request: behind `session.snapshot.since.v1` a `session.snapshot` that names `sinceSeq` is answered either the entries above that watermark or a full baseline carrying `mode` and `reset`, so the number rises for a reply shape a client reads off the wire. `minor:9` was when the compact roster shipped: behind `session.list.compact.v1` a listing that names `cwd`, `maxRows` or `after` is answered a shorter row that may be paged, so the number rises for a row schema a client reads off the wire. `minor:8` was when the outbound frame form became a capability: behind `frame.deflate.v1` a declaring client may be answered in binary frames carrying raw DEFLATE of the text, so the number is raised for something a client reads off the wire. `minor:7` was when the two channels met; `minor:6` was either channel on its own — the agent channel on dev and durable history paging on its branch; `minor:5` was when the roster stopped carrying archived sessions. Behind `agents.v1`, `presets.list` and `session.create` forward the host's preset roster and one creation request; behind `session.deep-history.v1`, `session.history.deep` pages a session's durable store back to its first entry; behind `session.fork.v1`, `session.fork` branches one session into a new one that inherits it. `minor:4` added byte-level increments, `minor:3` the background-job channel, `minor:2` the subagent thread, and `minor:1` was this seam. Major 1 and every frozen field, method name and topic name are unchanged by all of them. The one body that shrank for every client rather than only for those that declare a capability is the roster itself, which no longer names an archived session; every other answer a client that declares nothing receives is protocol v1's own.
154
155
 
155
156
  ## Error codes
156
157
 
@@ -168,7 +169,9 @@ A registered method is dispatched after both protocol gates: a name no plugin re
168
169
  | `snapshot-too-large` | the opening snapshot cannot be shrunk to one frame: even a single turn does not fit |
169
170
  | `squads-unavailable` | this host serves no `dsh-agents` squad domain this bridge can reach: no answer on the plugin's loopback route, no readable ledger beside it, or a body this build cannot read as one domain. A squads read is never answered with an empty board, and a refusal the plugin itself raised crosses with the plugin's own code instead |
170
171
  | `squads-run-unavailable` | the definitions are readable but the two run commands cannot be served: no loopback run route could be reached, and the read-only ledger cannot launch a session. Answering a run that never started is the one thing this channel will not do |
171
- | `internal` | the bridge failed while serving the call |
172
+ | `path-not-in-session` | `session.attachment.path` named a path this session's own durable transcript never did — a path the client chose, or one whose `realpath()` resolves somewhere other than itself |
173
+ | `not-found` | the whitelist names the path, but no regular file is there any more: it was deleted, or a directory, device or fifo stands in its place |
174
+ | `not-an-image` | the file's own first bytes are none of PNG, JPEG, WebP or GIF. The extension is never consulted |
172
175
  | `frame-too-large` | the frame exceeded the 10 MiB cap and was not parsed |
173
176
  | `malformed` | the frame is not one JSON object with a recognizable shape |
174
177
  | `direction-violation` | the client sent a `res` or `ev` frame, which only the host sends |
@@ -353,6 +356,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
353
356
  - **The token comparison does not leak length.** It is a fixed-length comparison rather than an early-exit one, so a wrong token cannot be narrowed byte by byte.
354
357
  - **Approvals fail closed while a client is connected.** The bridge claims a tool's permission request only while at least one paired client is connected; with none, the request goes to the next answerer rather than stalling. A claimed request that nobody answers normalizes to `unavailable`, which the harness treats as a rejection: silence from the phone is never consent.
355
358
  - **The header is the safer carrier.** `Authorization: Bearer <deviceToken>` keeps the credential out of the URL; `?token=` exists for clients that cannot set handshake headers, and the relay, the edge and the access log all see a URL that authenticates as that device.
359
+ - **An image is served only from the session that named it.** `session.attachment.path` answers a file's bytes only when the string it was handed is, byte for byte, a path that session's OWN durable transcript named: an offload placeholder in a message body, or the image reference a durable tool result published. The whitelist is computed from that session's store and from nothing else — the same durable read `session.history.deep` performs, behind the same fence, so a delegated child whose parent this connection may not read is refused before any store call — and a client never contributes a path to it. Four decisions then stand between the whitelist and the bytes: byte equality, `realpath()` resolving the path to itself (a symlink pointing anywhere else is refused rather than followed), a regular file at that path, and one of the four image signatures in its first bytes; the extension is never consulted. Nothing outside the whitelist is read, and no directory is ever listed. A path that is not a host absolute path is not a whitelist entry at all, so `browser_screenshot`'s plugin-namespace name — which has no file behind it — can never be asked for.
356
360
  - **Relay tier routing and grant credential boundaries.** The device roster (`devices.json`) schema upgrades from 3 to 4, adding an optional `relay: {grant, receivedAt}` to each device row. That `grant` is a 30-day HS256 credential signed by the account service, handed from the phone to the host over an **authenticated, paired connection**; the host merely passes it verbatim in the claim request body. The host therefore still does not know who the account is or what tier it holds: it only knows whether it holds a lease admitted by the relay. Tier evaluation occurs in a single loopback request between the self-hosted relay and the account service; the relay writes quotas into the lease row without recording any user identifier. The `hello.relay` announcement, capability identifier `relay.tier.v1`, and the `relay.grant` frame **exist only when a second meeting point is configured**; without configuration, the handshake is byte-for-byte identical to today, and that frame answers `unknown-method`. The two configuration keys are `relaySecondaryControlUrl` and `relaySecondaryPublicSuffix`, both unconfigured by default.
357
361
 
358
362
  ## Known limitations
@@ -372,6 +376,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
372
376
  - **Roster edits apply on the next host start.** The roster is read once per process, so removing a device takes effect when `dsh web` restarts.
373
377
  - **The panel shows one code and nothing else.** It cannot list, name or revoke paired devices, and it never spends a code — pairing happens on the phone, and revocation stays a roster edit plus a host restart.
374
378
  - **The panel is only as fresh as its last read.** It reads a code when it opens and on every **New code** press; a code that expires while the panel stays open flips to the expiry state instead of silently renewing itself.
379
+ - **A whitelist is computed per session watermark, not per request.** `session.attachment.path` walks a session's whole durable store to build its whitelist, which on the longest session this host holds (5,680 entries, 6.0 MiB compressed) costs 40.8 ms to inflate and 108 ms to inflate and parse — paid once per store page, and two pages at the bridge's own window. A connection therefore remembers the last four sessions' whitelists, keyed by the `asOfSeq` they were read at and evicting the least recently used one, so a request arriving under the same watermark is answered without a walk; any committed event moves the watermark and forces a fresh one. This is not a cache of image bytes — those are read from disk on every call, exactly as `session.attachment` reads them.
375
380
  - **`scripts/client.mjs` is a check harness, not a client SDK.** It runs the fixed sequence once, keeps no state and has no reconnect logic.
376
381
  - **A card's own subframes are not blocked on the desktop.** The phone refuses a nested `<iframe>` inside a card as a cross-document jump; a sandboxed frame here has no equivalent interception point, so a page's own subframe renders while every frame keeps its opaque origin.
377
382
  - **The keyed registration reaches its slot through a local seam.** The SDK package that declares `tool.call.toolview` is not a dependency of this package, so the slot is reached through a narrowed `ctx.slots` port that mirrors the owner's stage union; taking that package as a devDependency replaces the seam with the SDK's own types.
package/README.zh.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-remote-bridge?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.1-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.2--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -48,12 +48,13 @@
48
48
 
49
49
  | 方法 | 请求 `p` | 响应 `r` |
50
50
  | --- | --- | --- |
51
- | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:21, server:"dsh-remote-bridge", capabilities:["session.snapshot.trim.v1","session.snapshot.page.v1","questions.v1","questions.list.v1","subagent.thread.v1","jobs.v1","agents.v1","delta.v1","session.list.omit-archived.v1","session.deep-history.v1","frame.deflate.v1","session.list.compact.v1","session.snapshot.since.v1","session.fork.v1","commands.v1","workspace.v1","session.admin.v1","squads.v1","push.v1","usage.v1","usage.stats.v1","ui.v1","ui.list.v1"], resume:"snapshot", auth:"paired" 或 "unpaired"}` |
51
+ | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:22, server:"dsh-remote-bridge", capabilities:["session.snapshot.trim.v1","session.snapshot.page.v1","questions.v1","questions.list.v1","subagent.thread.v1","jobs.v1","agents.v1","delta.v1","session.list.omit-archived.v1","session.deep-history.v1","frame.deflate.v1","session.list.compact.v1","session.snapshot.since.v1","session.fork.v1","commands.v1","workspace.v1","session.admin.v1","squads.v1","push.v1","usage.v1","usage.stats.v1","ui.v1","ui.list.v1","session.attachment.path.v1"], resume:"snapshot", auth:"paired" 或 "unpaired"}` |
52
52
  | `session.list` | `{since?, cwd?, maxRows?, after?}` | `{mode, token, sessions:[{id, title, updatedAt, agentRunning, cwd?, parentSessionId?, origin?, blank, archived?}]}`;紧凑页为 `{mode:"reset", token:"", compact:true, sessions:[...], nextAfter?}` |
53
53
  | `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
54
54
  | `session.snapshot` | `{sessionId, sinceSeq?, maxBytes?}` | `{turns:[...], lastSeq:<uint>, hasMore?}`;增量另加 `mode:"since", reset:false`,替换客户端副本的基线另加 `mode:"full", reset:true` |
55
55
  | `session.history` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
56
56
  | `session.history.deep` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
57
+ | `session.attachment.path` | `{sessionId, path}` | `{image:{path, mediaType?, bytes?, width?, height?}, data:"<base64>"}` — the reference the session's own record stated, beside the bytes at that path. The path must be absolute and byte-identical to one the session named; `path-not-in-session`, `not-found`, `not-an-image` or `frame-too-large` answers instead |
57
58
  | `session.prompt` | `{sessionId, text, requestId}` | `{accepted:true}` |
58
59
  | `session.interrupt` | `{sessionId}` | `{ok:true}` |
59
60
  | `presets.list` | `{}` | 宿主 `agentPresets/list` 的身体,逐字转发 |
@@ -147,7 +148,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
147
148
 
148
149
  已注册方法的派发排在两道协议闸门之后:没有插件注册的名字最先回 `unknown-method`;没有有效设备令牌的连接回 `unpaired`,与协议方法完全一致;从未声明该表所需能力的客户端同样回 `unknown-method`——方法对它而言不存在,而不是没有权限。处理器收到请求载荷与本连接 id,回 `{ok:true, r}` 或 `{ok:false, code, msg}`;两种都原样穿过,因为错误码归注册它的插件所有。处理器抛错、或两种形状都没回时,以桥自己的 `internal` 穿过。
149
150
 
150
- `hello` 现在回 `minor:21`,起自可交互回复通道落地:它新增两个能力名(`ui.v1`、`ui.list.v1`)、一个主题(`ui.request`)、两个方法(`ui.event`、`ui.list`)与一个模型工具(`ui_present`),因此客户端从线缆上读到两个新名字、一种新事件与两种新应答体,而任何既有帧、方法与键都不改形状。`minor:20` 是用量台账通道落地时:`usage.stats.v1` 背后,客户端可以调 `usage.stats` 读宿主自己的台账,`usage.session` 也多了可选的 `modelContextWindow`(取自那条路由的模型目录),因此它从线缆上读到一个新的应答体和一个新的可选键,并且必须先读到这个名字才敢问——低于这一版的桥回 `unknown-method`、也不带那个键,而任何帧、主题与既有方法都不改形状。`minor:19` 是用量通道落地:`usage.v1` 背后,客户端可以调 `usage.session` 与 `usage.balance`,因此它从线缆上读到两个新的应答体,并且必须先读到这个名字才敢问——低于那一版的桥对两者都回 `unknown-method`。`minor:18` 是「一张实况卡排下几个会话」:`content-state` 可以带 `rows`,最多三项 `{name, status, phase}`,顺序由桥定——先提问中的会话(按提问到达顺序),再正在跑的会话(按最近更新倒序)——因此不新增方法、不新增能力名、也不改动任何既有键,`minor` 只加一。行的 `name` 是宿主自己的标题摘掉尾部路径组的结果,因为线上不许出现路径。`minor:17` 是实况卡推送落地:锁屏卡与灵动岛由 `push.v1` 既有的登记面驱动,桥侧只新增发送路径(`liveactivity` 推送、按会话投影的 `SessionActivityState`)。`minor:16` 是通知推送通道落地:`push.v1` 背后,客户端可以调 `push.register`,让设备表记住自己的 APNs 令牌,于是回合结束或出现待答提问时手机会被叫醒,而它自己的 socket 并没有开着。`minor:15` 是小队通道落地:`squads.v1` 背后,客户端可以调 `squads.state`、`squads.list`、`squads.runs`、`squads.runMember` 与 `squads.runSquad`,因此它从线上读到五种新的应答体,并驱动宿主的小队域而不是从别处推导 agent。`minor:14` 是会话管理通道落地:`workspace.v1` 背后,客户端可以调 `workspace.list` 并读到宿主的工作区与两个全局会话集合;`session.admin.v1` 背后,它可以改名、置顶、取消置顶、归档与取消归档一条会话,因此它从线上读到六种新的应答体。`minor:13` 是待答提问列表落地:`questions.list.v1` 背后,客户端可以调 `question.list`,拿回本桥此刻仍持有的提问——手机据此对账它手里的卡,也是它得知「自己离线时某个提问已经结束」的唯一途径,因为最后一个配对设备离开时,桥会撤回全部认领。`minor:12` 是指令通道落地之时:`commands.v1` 背后,客户端可以调 `session.commands` 与 `session.command`,因此它从线上读到一种新的应答体。`minor:11` 是 fork 通道落地之时(比先一步在集成分支上落地的快照增量通道高一位):`session.fork.v1` 背后,客户端可以调 `session.fork` 并拿到宿主自己的 fork 结果。`minor:10` 是快照可按请求增量之时:`session.snapshot.since.v1` 背后,带 `sinceSeq` 的 `session.snapshot` 要么只回该水位之上的 entry,要么回一份带 `mode` 与 `reset` 的完整基线,所以这一位是为客户端能从线上读到的应答形状而提的。`minor:9` 是紧凑名册之时:`session.list.compact.v1` 背后,带 `cwd`、`maxRows` 或 `after` 的列出得到更短、且可分页的行,所以这一位是为客户端能从线上读到的行 schema 而提的。`minor:8` 是下行帧的形态本身成为一种能力之时:`frame.deflate.v1` 背后,声明了的客户端可能收到承载裸 DEFLATE 的 binary 帧,所以这一位是为客户端能从线上读到的东西而提的。`minor:7` 是两条通道汇合之时;`minor:6` 是其中任一条单独在位——agent 通道在 dev 上,持久历史分页在它自己的分支上;`minor:5` 时是名册不再携带已归档会话。`agents.v1` 背后,`presets.list` 与 `session.create` 转发宿主的预设名册与一次创建请求;`session.deep-history.v1` 背后,`session.history.deep` 把会话的持久存储一直翻到最早一条 entry;`session.fork.v1` 背后,`session.fork` 把一条会话分叉成继承它的新会话。`minor:4` 加了字节级增量,`minor:3` 是后台作业通道,`minor:2` 是子代理线程,`minor:1` 是本扩展缝。它们都没有改动主版本 1、任何冻结字段、方法名或主题名。唯一对每个客户端都变短的响应体是名册本身,它不再点名已归档会话;其余答案对什么都不声明的客户端仍是协议 v1 自己的。
151
+ `hello` 现在回 `minor:22`,起自按路径取图通道落地:`session.attachment.path.v1` 只是一个公告(与 `session.deep-history.v1` 同例),名字背后客户端可以调 `session.attachment.path`,读回这次会话自己的持久记录点过的某一张图的字节——来源要么是消息体里的 offload 占位符,要么是持久工具结果发布的那个图像引用——因此它从线上读到一种新的应答体,并且必须先读到这个名字才敢问。这个方法对每一条已配对连接都开放:能力名只决定客户端知不知道它存在,不决定桥放不放行,不声明这个名字的客户端只是少了这份知情。没有任何既有帧、既有主题或既有方法改形状。`minor:21` 是当时可交互回复通道落地:它新增两个能力名(`ui.v1`、`ui.list.v1`)、一个主题(`ui.request`)、两个方法(`ui.event`、`ui.list`)与一个模型工具(`ui_present`),因此客户端从线缆上读到两个新名字、一种新事件与两种新应答体,而任何既有帧、方法与键都不改形状。`minor:20` 是用量台账通道落地时:`usage.stats.v1` 背后,客户端可以调 `usage.stats` 读宿主自己的台账,`usage.session` 也多了可选的 `modelContextWindow`(取自那条路由的模型目录),因此它从线缆上读到一个新的应答体和一个新的可选键,并且必须先读到这个名字才敢问——低于这一版的桥回 `unknown-method`、也不带那个键,而任何帧、主题与既有方法都不改形状。`minor:19` 是用量通道落地:`usage.v1` 背后,客户端可以调 `usage.session` 与 `usage.balance`,因此它从线缆上读到两个新的应答体,并且必须先读到这个名字才敢问——低于那一版的桥对两者都回 `unknown-method`。`minor:18` 是「一张实况卡排下几个会话」:`content-state` 可以带 `rows`,最多三项 `{name, status, phase}`,顺序由桥定——先提问中的会话(按提问到达顺序),再正在跑的会话(按最近更新倒序)——因此不新增方法、不新增能力名、也不改动任何既有键,`minor` 只加一。行的 `name` 是宿主自己的标题摘掉尾部路径组的结果,因为线上不许出现路径。`minor:17` 是实况卡推送落地:锁屏卡与灵动岛由 `push.v1` 既有的登记面驱动,桥侧只新增发送路径(`liveactivity` 推送、按会话投影的 `SessionActivityState`)。`minor:16` 是通知推送通道落地:`push.v1` 背后,客户端可以调 `push.register`,让设备表记住自己的 APNs 令牌,于是回合结束或出现待答提问时手机会被叫醒,而它自己的 socket 并没有开着。`minor:15` 是小队通道落地:`squads.v1` 背后,客户端可以调 `squads.state`、`squads.list`、`squads.runs`、`squads.runMember` 与 `squads.runSquad`,因此它从线上读到五种新的应答体,并驱动宿主的小队域而不是从别处推导 agent。`minor:14` 是会话管理通道落地:`workspace.v1` 背后,客户端可以调 `workspace.list` 并读到宿主的工作区与两个全局会话集合;`session.admin.v1` 背后,它可以改名、置顶、取消置顶、归档与取消归档一条会话,因此它从线上读到六种新的应答体。`minor:13` 是待答提问列表落地:`questions.list.v1` 背后,客户端可以调 `question.list`,拿回本桥此刻仍持有的提问——手机据此对账它手里的卡,也是它得知「自己离线时某个提问已经结束」的唯一途径,因为最后一个配对设备离开时,桥会撤回全部认领。`minor:12` 是指令通道落地之时:`commands.v1` 背后,客户端可以调 `session.commands` 与 `session.command`,因此它从线上读到一种新的应答体。`minor:11` 是 fork 通道落地之时(比先一步在集成分支上落地的快照增量通道高一位):`session.fork.v1` 背后,客户端可以调 `session.fork` 并拿到宿主自己的 fork 结果。`minor:10` 是快照可按请求增量之时:`session.snapshot.since.v1` 背后,带 `sinceSeq` 的 `session.snapshot` 要么只回该水位之上的 entry,要么回一份带 `mode` 与 `reset` 的完整基线,所以这一位是为客户端能从线上读到的应答形状而提的。`minor:9` 是紧凑名册之时:`session.list.compact.v1` 背后,带 `cwd`、`maxRows` 或 `after` 的列出得到更短、且可分页的行,所以这一位是为客户端能从线上读到的行 schema 而提的。`minor:8` 是下行帧的形态本身成为一种能力之时:`frame.deflate.v1` 背后,声明了的客户端可能收到承载裸 DEFLATE 的 binary 帧,所以这一位是为客户端能从线上读到的东西而提的。`minor:7` 是两条通道汇合之时;`minor:6` 是其中任一条单独在位——agent 通道在 dev 上,持久历史分页在它自己的分支上;`minor:5` 时是名册不再携带已归档会话。`agents.v1` 背后,`presets.list` 与 `session.create` 转发宿主的预设名册与一次创建请求;`session.deep-history.v1` 背后,`session.history.deep` 把会话的持久存储一直翻到最早一条 entry;`session.fork.v1` 背后,`session.fork` 把一条会话分叉成继承它的新会话。`minor:4` 加了字节级增量,`minor:3` 是后台作业通道,`minor:2` 是子代理线程,`minor:1` 是本扩展缝。它们都没有改动主版本 1、任何冻结字段、方法名或主题名。唯一对每个客户端都变短的响应体是名册本身,它不再点名已归档会话;其余答案对什么都不声明的客户端仍是协议 v1 自己的。
151
152
 
152
153
  ## 错误码
153
154
 
@@ -165,7 +166,9 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
165
166
  | `snapshot-too-large` | 开帧快照无法压缩进单帧:连一个回合都放不下 |
166
167
  | `squads-unavailable` | 本宿主没有本桥能到达的 `dsh-agents` 小队域:插件 loopback 路由没有应答、旁边没有可读的账本,或者应答体不是本构建读得懂的那一个域。小队读取从不以空板回答,而插件自己抛出的拒绝带着插件自己的码穿过 |
167
168
  | `squads-run-unavailable` | 定义读得到,但两条运行指令服务不了:到达不了任何 loopback 运行路由,只读账本也启动不了会话。回一个从未启动的运行是这条通道唯一不做的事 |
168
- | `internal` | 桥在服务该调用时自身失败 |
169
+ | `path-not-in-session` | `session.attachment.path` 点名的路径不在这次会话自己的持久 transcript 里——客户端自选的路径,或 `realpath()` 解析后不再等于它自己的那种 |
170
+ | `not-found` | 白名单里有这个路径,但那里已经没有常规文件:被删了,或被换成了目录、设备或 fifo |
171
+ | `not-an-image` | 文件自己的头几个字节不是 PNG、JPEG、WebP 或 GIF 中的任何一种;扩展名一律不作数 |
169
172
  | `frame-too-large` | 该帧超过 10 MiB 上限,未被解析 |
170
173
  | `malformed` | 该帧不是形状可辨的单个 JSON 对象 |
171
174
  | `direction-violation` | 客户端发来了只有宿主才发的 `res` 或 `ev` 帧 |
@@ -350,6 +353,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
350
353
  - **令牌比对不泄漏长度。** 用的是定长比较而非提前返回的比较,因此错误令牌无法被逐字节逼近。
351
354
  - **审批在客户端在线时 fail closed。** 只要还有一个已配对客户端在线,桥才认领工具的权限请求;一个都没有时,请求交给下一个应答者而不是卡住。已认领而无人应答的审批会被归一为 `unavailable`,宿主按拒绝处理:手机沉默永远不等于同意。
352
355
  - **header 是更安全的载体。** `Authorization: Bearer <deviceToken>` 让凭据不进入 URL;`?token=` 是给无法设置握手 header 的客户端的,此时中继、边缘与访问日志都会看到一条以该设备身份鉴权的 URL。
356
+ - **一张图只能由点过它的那条会话取。** `session.attachment.path` 只在拿到的字符串逐字节等于**这次会话自己的持久 transcript** 点过的某个路径时才回字节:来源是消息体里的 offload 占位符,或持久工具结果发布的图像引用。白名单每次请求都从该会话自己的存储现算,别的什么都不读——走的就是 `session.history.deep` 那条持久读面、同一道栅栏,所以父会话不是本连接可读的委派子会话在任何存储调用之前就被拒——而客户端一个路径都贡献不了。白名单与字节之间还立着四道判定:逐字节相等、`realpath()` 必须解析回它自己(指向别处的软链接被拒而不是被跟随)、那里必须是常规文件、头几个字节必须是四种图像签名之一;扩展名一律不看。白名单之外的文件一个都不读,也不会去列目录。不是宿主绝对路径的条目根本不进白名单,所以 `browser_screenshot` 那个磁盘上没有对应文件的插件命名空间名永远发不出去。
353
357
  - **中继档位分流与授权凭据边界。** 名册(`devices.json`)schema 3 → 4,每台设备行新增可选的 `relay: {grant, receivedAt}`。那枚 `grant` 是账号服务签发的 30 天 HS256 凭据,经**已配对的加密连接**由手机交给宿主,宿主只把它原样放进 claim 请求体。宿主因此仍然不知道账号是谁、也不知道档位:它只知道「我有没有一份被中继承认的租约」。档位判定发生在自建中继与账号服务之间的一次回环请求里,中继只把额度写进租约行,不落任何用户标识。`hello.relay`、能力名 `relay.tier.v1`、`relay.grant` 这一帧**只在配置了第二个会合点时才存在**;不配置时握手逐字节等于今天,那一帧回 `unknown-method`。两个配置项名:`relaySecondaryControlUrl` 与 `relaySecondaryPublicSuffix`,缺省都不配置。
354
358
 
355
359
  ## 已知限制
@@ -369,6 +373,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
369
373
  - **名册改动在下一次宿主启动时生效。** 名册每个进程只读一次,因此移除设备要等 `dsh web` 重启才起作用。
370
374
  - **面板只显示一个配对码,别的都不做。** 它不能列出、命名或吊销已配对设备,也从不消耗配对码——配对发生在手机上,吊销仍然是改名册加重启宿主。
371
375
  - **面板的新鲜度只到它上一次取码为止。** 它在打开时取一次码,之后每按一次「重新取码」再取一次;一直开着时过期的码会翻成过期状态,而不会自己悄悄续期。
376
+ - **白名单按会话水位算,不按请求算。** `session.attachment.path` 要读完一条会话的整份持久存储才能算出白名单,在宿主当前最长的那条会话上(5680 条 entry、压缩后 6.0 MiB)解压要 40.8 ms、解压加解析要 108 ms,而这条路按桥自己的窗口一次要翻两页,每页都付一次。因此每条连接只记住最近四个会话的白名单,键是读它时的那个 `asOfSeq`,最久没用的先逐出:同一水位下的第二次请求不再翻页,而任何一条事件落盘都会推高水位、逼出一次重算。这不是图像字节的缓存——字节每次调用都从磁盘直取,与 `session.attachment` 完全一致。
372
377
  - **`scripts/client.mjs` 是检查用的工具,不是客户端 SDK。** 它只按固定顺序跑一遍,不保存状态,也没有重连逻辑。
373
378
  - **卡片自己的子帧在桌面端没有被拦。** 手机端把卡片里的嵌套 `<iframe>` 当作跨文档跳转一律拒绝;这里沙箱化的画框没有等价的拦截点,所以页面自己的子帧仍会渲染,只是每一帧都保持不透明源。
374
379
  - **keyed 注册经由一条本地缝到达槽位。** 声明 `tool.call.toolview` 的那个 SDK 包不是本包的依赖,因此槽位是经窄化后的 `ctx.slots` 端口到达的,端口里镜像了 owner 的阶段联合;把那个包收作 devDependency 后,这条缝会被 SDK 自己的类型替掉。