@linxin666/dsh-remote-bridge 0.4.9 → 0.4.10

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 (40) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +28 -4
  3. package/README.zh.md +27 -4
  4. package/lib/client.js +511 -9
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +8671 -148
  7. package/lib/types/client/UiPresentRow.d.ts +13 -0
  8. package/lib/types/client/index.d.ts +4 -0
  9. package/lib/types/client/locales.d.ts +15 -2
  10. package/lib/types/client/toolview-slot.d.ts +68 -0
  11. package/lib/types/client/ui-card.d.ts +160 -0
  12. package/lib/types/core/connection.d.ts +38 -0
  13. package/lib/types/core/devices.d.ts +4 -0
  14. package/lib/types/core/extension.d.ts +13 -0
  15. package/lib/types/core/hub.d.ts +64 -0
  16. package/lib/types/core/protocol.d.ts +71 -7
  17. package/lib/types/core/push.d.ts +10 -2
  18. package/lib/types/core/turn-end-quiet.d.ts +135 -0
  19. package/lib/types/core/ui.d.ts +238 -0
  20. package/lib/types/host/ui-tools.d.ts +80 -0
  21. package/lib/types/host/watchers.d.ts +7 -0
  22. package/lib/types/index.d.ts +29 -1
  23. package/package.json +3 -2
  24. package/src/client/UiPresentRow.tsx +149 -0
  25. package/src/client/index.ts +11 -0
  26. package/src/client/locales.ts +22 -2
  27. package/src/client/toolview-slot.ts +84 -0
  28. package/src/client/ui-card.ts +368 -0
  29. package/src/client/ui-present.module.css +87 -0
  30. package/src/core/connection.ts +169 -6
  31. package/src/core/devices.ts +116 -2
  32. package/src/core/extension.ts +20 -0
  33. package/src/core/hub.ts +156 -1
  34. package/src/core/protocol.ts +78 -6
  35. package/src/core/push.ts +34 -3
  36. package/src/core/turn-end-quiet.ts +388 -0
  37. package/src/core/ui.ts +398 -0
  38. package/src/host/ui-tools.ts +233 -0
  39. package/src/host/watchers.ts +27 -3
  40. package/src/index.ts +70 -2
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: 2e01759e6bc9e7c74f65df34725ecc8daa1b82d8
6
- README.zh.md: f79ea287b9b7087807a0285405a977bc96e2f9b3
5
+ README.md: 92c1ff1f608d119a13e42bd6a6f542497f67586a
6
+ README.zh.md: cb47d7bead17a772208c3c798b4a56d5e4b4262e
package/README.md CHANGED
@@ -24,6 +24,10 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
24
24
  - **A fork surface.** `session.fork` branches one session into a new one that inherits its context; the fork point and the new session's identity are the host's, so the request and the answer cross verbatim.
25
25
  - **A command surface.** `session.commands` lists a session's slash commands and skills in one directory and `session.command` runs one draft line, reporting whether the host resolved it; both catalogs are the host's own and nothing here is cached.
26
26
  - **A usage surface.** `usage.session` answers one session's context window — the host's own number, only when the host broadcast one — beside an estimate of what its next request is made of, and `usage.balance` answers what the account behind one provider route still holds, read from the provider's own balance endpoint at most once a minute and only when the route really points at the official origin. `usage.stats` answers the host's own token ledger — five buckets for today and for the month plus one ascending row per local day — from the `dsh-usage` plugin's own HTTP routes over this machine's loopback origin, at most one read per 30 seconds; a host that never mounted that plugin answers `no-usage-plugin` rather than zeros. A session the host broadcast no window for may also carry `modelContextWindow`, the figure its route's model catalog declares, which is never mixed with the host's own reading.
27
+ - **A page handed to the client, and the action that comes back.** `ui.present` takes one whole self-contained HTML document and
28
+ announces it as a `ui.request` event to the clients that declared `ui.v1`; the user's first action inside the page returns as that
29
+ tool call's result, so a chart, a form or a list operation is a real answer instead of a question with options. `ui.event` settles
30
+ it and `ui.list` reconciles the cards a client still holds.
27
31
  - **A subscription, not a poll.** `session.snapshot` opens the harness follow stream and keeps it, so the baseline and every later increment arrive over the same socket.
28
32
  - **Approvals reach the client, and a reconnecting phone is handed the ones still waiting.** A tool that asks for permission arrives as an `approval.request` event and is answered with `approval.resolve`; a request nobody answers is rejected, and a connection that declared `approvals.v1` receives every unsettled approval again after its handshake.
29
33
  - **Pairing.** A one-time bootstrap token plus a P-256 challenge-response mint a revocable device token; an unpaired connection reaches three methods only.
@@ -45,7 +49,7 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
45
49
 
46
50
  | method | request `p` | response `r` |
47
51
  | --- | --- | --- |
48
- | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:20, 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"], 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: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"}` |
49
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 |
50
54
  | `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
51
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 |
@@ -75,6 +79,8 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
75
79
  | `pair.begin` | `{token}` | `{nonce, expiresAt}` |
76
80
  | `pair.finish` | `{devicePubKey, signature}` | `{deviceToken, deviceId}` |
77
81
  | `approval.resolve` | `{id, decision}` | `{ok:true}` |
82
+ | `ui.event` | `{sessionId, callId, event:{type, payload?}}` | `{ok:true}`; the first one settles that tool call, a later one answers `ui-settled`, one this bridge never claimed answers `ui-unknown`, and a payload over 8 KiB answers `invalid-args` |
83
+ | `ui.list` | `{}` | `{cards:[{key, sessionId, state, payload}], complete:true}` — only the cards still held; `key` is `"<sessionId>/<callId>"` and `payload` is that card's `ui.request` payload verbatim, and the read claims nothing, moves no deadline and settles nothing |
78
84
 
79
85
  `hello` is callable without a device token and reports the connection's own `auth` state. `session.snapshot` maps the harness follow stream's opening snapshot into `turns`, reports its cursor as `lastSeq` and then keeps that stream open as this connection's subscription for the session; `session.prompt` ensures the same subscription idempotently, so a client may skip the snapshot. The prompt mode is fixed to queue, `clientTimeZone` is filled server-side with the host's IANA zone, and `requestId` is an idempotency key: the same `requestId` in the same session is sent once, and a repeat answers `{accepted:true}` without sending anything again. `session.interrupt` cancels the turn; it does not drop the subscription.
80
86
 
@@ -90,7 +96,7 @@ The squads channel is the one that replaces nothing: it reads and drives the age
90
96
 
91
97
  The usage channel reads two facts that belong to the host rather than to one device, so one instance serves every connection. `usage.session` names one session and answers `{contextWindow?, composition?}`: the window is the harness's own `RequestContext.contextWindow` from the latest `request/context` event this process saw broadcast, and the composition is this bridge's estimate of what the next request is made of, split three ways — `tools` from the raw tools schema of the latest `request/header`, `system` from the latest `system/message` text, and `messages` from the text of every `user/message`, `assistant/message` and `tool/result` seen since — each component the UTF-8 byte count divided by four and floored, always carrying `estimated: true`, because a phone must never read an estimate as the host's own accounting. A key the host never broadcast is absent rather than zero, and a session that exists while neither reading does answers `{}`: existence has three witnesses — the host's own session roster (the same `session/list` the roster method serves, so a session this bridge never observed and that is not live still counts), the live session store, and the events this process folded — and a session id none of the three names is refused `unknown-session`. The roster is read only when the other two answer nothing, and its answer is reused for five seconds so a burst of opens costs one read; a bridge that cannot read a roster at all falls back to the live store and the fold alone. The fold starts when this row mounts and never reads a session log: an event broadcast before it mounted is not a reading, so a session that ran entirely before it answers `{}` rather than a composition of zeros. `usage.balance` names one provider route and answers either `{provider, currency, total, toppedUp, granted, updatedAt}` — the numbers in yuan, taken from `balance_infos[0]` — or `{provider, unsupported, reason?}` with `no-credential`, `not-deepseek-route` or `probe-failed`. The route must be an official DeepSeek id (`deepseek` or `deepseek-official`) AND its configured `baseURL` absent or on `https://api.deepseek.com`: the balance endpoint reports one origin's account, so probing it for a reseller profile that merely reused the `deepseek` id would print the official account's money under that route's name. The credential is resolved the way the harness's own usage plugin resolves it — the pi-ai record `llm-pi-ai/<provider>`, then the profile's `apiKeyEnv`, then the DeepSeek adapter's own reference (default `DEEPSEEK_API_KEY`) — and an OAuth grant is not a credential here, because the official endpoint accepts an API key only. One reading is cached for 60 seconds per provider and credential, concurrent calls merge into one upstream request, and 401, a timeout or an unrecognized body all answer `probe-failed` instead of a previous reading presented as current. A client that never declared `usage.v1` is answered `unknown-method` for both methods, with no event folded and no upstream request made on its behalf. `usage.stats` reads the ledger another plugin keeps, so it is its own capability behind `usage.stats.v1` and its own read path: one `GET /api/dsh-usage/overview` and, only when the requested window reaches deeper than the 30 days that document already carries, one `GET /api/dsh-usage/day?date=YYYY-MM-DD` per day that ledger actually recorded. Days the ledger holds nothing for cross as real zeros — the host answers those dates as zeroed days itself — while a route that is absent (`no-usage-plugin`), unreachable, shaped differently or too slow answers `probe-failed` with a short reason and never a previous reading. One `days` window is cached for 30 seconds on this side and concurrent calls merge into it, so two phones asking at once cost the host one read. `usage.session` gained one optional key beside the window: when the host has broadcast no `request/context` window, the answer may carry `modelContextWindow`, taken from `GET {baseURL}/models` of the session's current route — the first available of `context_length`, `context_window` and `max_input_tokens` for that exact model id, cached for ten minutes per route, and sent with that route's own credential. The two numbers are never mixed: `contextWindow` is always the host's measurement, `modelContextWindow` is always the model's declaration, and the second never appears beside the first.
92
98
 
93
- `hello` also carries the client's capabilities, and a capability is an announcement rather than a negotiation: the handshake answers the same frame whatever `cap` holds, an unknown name is ignored, and the frame cap is one constant in both directions — the 10 MiB that bounds a received frame is the same budget that fits a snapshot and that drops an oversized outbound event. This bridge serves twenty-one capabilities and advertises them in `hello`'s `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` and `usage.stats.v1` — a capability a mounted plugin adds is not on that list, because the bridge is not its author. Nor is `approvals.v1`, which a client declares and this bridge deliberately never advertises: it gates a replay rather than the channel, so the handshake stays the same frame for every client (see the approval channel below). `questions.list.v1` is the one name here that announces a method rather than changing a channel: `question.list` answers the questions this bridge is still holding, and only an answer marked `complete` may retire a card a phone carries. The first is the trimmed baseline. A client that does not declare it — including every client written before it existed — is served exactly the baseline protocol v1 always served. A client that does declare it is sent a trimmed baseline: inside every turn, only the entries it renders (`user/message`, `assistant/message`, `tool/call`, `tool/result`, `subagent/catalog`) survive, and the harness's own bookkeeping records (`system/message`, `request/header` and the like) are dropped before the frame is measured. Nothing else about the snapshot changes: which turns are kept, their order, and each turn's `seq`, `endSeq`, `reason` and `time` are the projection's own values, a turn whose entries are all bookkeeping stays as a turn with an empty `entries` array, and `lastSeq` is still the harness cursor. The frame budget applies afterwards — entries are trimmed first, then whole oldest turns are dropped, and only then does a snapshot that still does not fit answer `snapshot-too-large`.
99
+ `hello` also carries the client's capabilities, and a capability is an announcement rather than a negotiation: the handshake answers the same frame whatever `cap` holds, an unknown name is ignored, and the frame cap is one constant in both directions — the 10 MiB that bounds a received frame is the same budget that fits a snapshot and that drops an oversized outbound event. This bridge serves twenty-three capabilities and advertises them in `hello`'s `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` and `ui.list.v1` — a capability a mounted plugin adds is not on that list, because the bridge is not its author. `ui.v1` is the one name here that a bridge can only advertise when it really serves the other half: behind it a page arrives as `ui.request` and the user's action returns with `ui.event`, and a host whose bridge predates the channel sends nothing. `ui.list.v1` is its reconciliation read, the same announcement shape as `questions.list.v1`: only an answer marked `complete` may retire a card a phone carries. Nor is `approvals.v1`, which a client declares and this bridge deliberately never advertises: it gates a replay rather than the channel, so the handshake stays the same frame for every client (see the approval channel below). `questions.list.v1` is the one name here that announces a method rather than changing a channel: `question.list` answers the questions this bridge is still holding, and only an answer marked `complete` may retire a card a phone carries. The first is the trimmed baseline. A client that does not declare it — including every client written before it existed — is served exactly the baseline protocol v1 always served. A client that does declare it is sent a trimmed baseline: inside every turn, only the entries it renders (`user/message`, `assistant/message`, `tool/call`, `tool/result`, `subagent/catalog`) survive, and the harness's own bookkeeping records (`system/message`, `request/header` and the like) are dropped before the frame is measured. Nothing else about the snapshot changes: which turns are kept, their order, and each turn's `seq`, `endSeq`, `reason` and `time` are the projection's own values, a turn whose entries are all bookkeeping stays as a turn with an empty `entries` array, and `lastSeq` is still the harness cursor. The frame budget applies afterwards — entries are trimmed first, then whole oldest turns are dropped, and only then does a snapshot that still does not fit answer `snapshot-too-large`.
94
100
 
95
101
  A second capability bounds the opening screen itself: `session.snapshot.page.v1`. Without it a snapshot stays the whole opening window, byte for byte, exactly as before. With it, `session.snapshot` answers with the newest page only, measured against `maxBytes` (default 524288 = 512 KiB, and refused rather than clamped when it is not a usable budget), cut by the very same entry-level slice `session.history` uses: a turn's entries may split between this page and the next one while that turn keeps its own fields, an entry larger than the whole budget is a page of its own, and `snapshot-too-large` can no longer answer such a connection. The budget is measured on the whole encoded answer and never per turn, so what it bounds is the page rather than an entry: a page is inside `maxBytes` unless the newest entry alone is past it, and then the page is exactly as large as that entry — a 2.2 MB newest message answers a 2.2 MB page against the 512 KiB default, while a window of ordinary entries answers 513794 bytes. That is the one cost a paged snapshot can still carry. The page carries `lastSeq` and `hasMore`, and the cursor for the next, older page is the `seq` of its own oldest entry — the same value `session.history` takes as `before`, which is why no `nextBefore` field restates it. Opening a session then costs one page, and `session.history` walks the rest of the window back in the same 512 KiB pages. The capability that makes a reconnect cheap is `session.snapshot.since.v1`, and it takes two declarations to change anything: the capability in the handshake AND a `sinceSeq` in the request. A request missing either is answered byte for byte what protocol v1 answered before it existed, with no field added, so a client can adopt the name before it relies on any of it. Behind both, the client names the durable `lastSeq` of a snapshot it already holds — the harness cursor, never the connection's own event seq — and the bridge proves continuity against the current follow window: only when that window's oldest entry sits at or below `sinceSeq + 1`, or the window is empty, is the answer the increment `{turns:[...], lastSeq, mode:"since", reset:false}` carrying nothing but the entries above that watermark, each turn keeping its own `seq`, `endSeq`, `reason` and `time` exactly as the baseline presented it. An entry the client never renders still counts as an entry the window holds, so the proof is read off the untrimmed window and can only be conservative. A window that has scrolled past the watermark cannot prove the chain is unbroken, so there — and when the increment would not fit one 10 MiB frame — the answer is the baseline this connection would have received anyway, carrying `mode:"full"` and `reset:true`, the one answer that tells a client to throw its copy away. Trim, the page budget and the frame cap are untouched: the increment is cut from the same projection, and a reset reply is exactly today's reply plus those two fields.
96
102
 
@@ -131,6 +137,8 @@ An `approval.request` carries a summary taken from the harness's display reason
131
137
 
132
138
  The question channel is the one claim that outlives the socket. A question arrives as a `question.request` event under the host's own call id, or under one this bridge mints when a blocking ask carries none, and `question.answer` settles the host's ask: while that ask is still open the answer resolves the promise the bridge holds, and once the host's deadline has released the model a late answer takes the host's Remote `answer` path instead. `question.list` answers the questions the bridge is still holding, which is what a phone reconciles the cards it carries against. With no paired connection on the wire, but a device on the roster that registered for push, the bridge claims the question for that phone and the alert is its delivery: for one bridge-owned window the question exists only on the phone's side, and when the window ends it goes back to the host's own answerer chain. The window is `OFFLINE_QUESTION_CLAIM_TTL_MS`, ten minutes, overridable with `DSH_REMOTE_BRIDGE_OFFLINE_CLAIM_TTL_MS`. Inside it a phone that reconnects and declares `questions.v1` is handed the live claim and the window ends there; a phone that answers settles it, and the host's chain is then never started; and a hello from a paired connection that did not declare the channel releases the claim at once, because a claim nobody on the wire can receive is not kept. A blocking ask — no call id, no deadline — is claimed the same way, and its cost is stated rather than hidden: the agent behind it waits at most that window. Approvals keep the stricter rule above, where nothing is ever held for a phone that is not on the wire.
133
139
 
140
+ The interactive-reply channel is the one place a page travels instead of a question. `ui.present` is this bridge's own model tool: the agent writes one whole self-contained document (`<!doctype html>` first, at most 256 KiB of UTF-8) and it crosses as a `ui.request` event under the host's own `ToolCallId`, so the card hangs on the same tool-call row the transcript already draws. The call then blocks until the user's FIRST action inside the page arrives, and that action — `{type, payload?}` with `type` the page's own closed set and `payload` at most 8 KiB — is the tool call's result: one card settles one action, and a page that should keep taking them is presented again. The card is announced over as `state:"settled"` to every client that declared `ui.v1`, including the one that acted, so a second tap on the phone and a second phone both learn it is over. `ui.list` answers the cards this bridge still holds, which is what a phone reconciles against after a restart, and only a complete answer may retire one. A card never carries `expiresAt`: the tool schema declares no `timeout`, so this bridge invents no deadline, and it takes the same grace window as a question instead — a page nobody can answer any more is released to the agent as a timeout when the window the last paired device left behind runs out, and a phone that declares the channel inside that window is handed the live card and cancels the release. With no paired connection that declared `ui.v1`, `ui.present` answers `{ok:false, reason:"unavailable"}` at once instead of holding the agent. Every result of a page that did reach the wire carries the presentation payload as `meta.ui` — `{key, title?, html, height?, state}` with `key` spelled `"<sessionId>/<callId>"` — for a client that renders the card out of the transcript and holds no `ui.request` socket; the body of the result stays one human sentence.
141
+
134
142
  ## Extension seam
135
143
 
136
144
  The package publishes one generic seam and puts no vocabulary of its own in it. Mounted plugins resolve the cordis service `remoteBridge` and add methods and events to protocol v1 without the bridge learning what they mean:
@@ -142,7 +150,7 @@ The package publishes one generic seam and puts no vocabulary of its own in it.
142
150
 
143
151
  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`.
144
152
 
145
- `hello` answers `minor:20`, since 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.
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.
146
154
 
147
155
  ## Error codes
148
156
 
@@ -219,7 +227,7 @@ The roster lives in `$DSH_HOME/remote-bridge/devices.json`, a versioned document
219
227
  }
220
228
  ```
221
229
 
222
- Nothing in that file is a usable credential in the clear: a row keeps the device's public key, its fingerprint and the SHA-256 of the token it was issued, never the token. The directory is 0700 and the file 0600; a write goes to a temporary file, is flushed and renamed into place, so a crash never leaves a half-written roster, and a file that does not parse is moved aside with a `.corrupt-<timestamp>` suffix instead of being treated as an empty roster. Protocol v1 has no revoke method, so revoking a device is removing its row (or deleting the file) and restarting the host: the roster is read once per process, and from that start on the device's connection is unpaired.
230
+ Nothing in that file is a usable credential in the clear: a row keeps the device's public key, its fingerprint and the SHA-256 of the token it was issued, never the token. The directory is 0700 and the file 0600; a write goes to a temporary file, is flushed and renamed into place, so a crash never leaves a half-written roster, and a file that does not parse is moved aside with a `.corrupt-<timestamp>` suffix instead of being treated as an empty roster. Protocol v1 has no revoke method, so revoking a device is removing its row (or deleting the file) and restarting the host: the roster is read once per process, and from that start on the device's connection is unpaired. One row is one phone and one APNs token is delivered to once: pairing again replaces the bearer token on the row the device already has — its id, its creation time and its notification registration stay — and a table that still carries several rows for one fingerprint, or one token on several rows, is compacted when it is read, so a re-pairing is a new credential rather than a new device and one event never rings the same lock screen twice.
223
231
 
224
232
  ## Relay
225
233
 
@@ -244,6 +252,20 @@ Opening and closing are one motion in both directions: the card stays mounted an
244
252
 
245
253
  The panel is display-only for the native path. It never spends the token (`pair.begin` stays the phone's call), it never touches the roster, and it adds no wire surface — the envelope, the method names, the topic names and the events are unchanged. `dsh-remote-web-ui`'s pairing service, roster and browser credential are not involved either, so the two remote surfaces keep their own access controls.
246
254
 
255
+ ## Interactive cards in the transcript
256
+
257
+ `ui.present` hands one whole self-contained page into the session, and the browser half draws it inside the official tool row: the presentation is one keyed `tool.call.toolview` registration under the wire tool name `ui.present`, so the row keeps the call identity, the timing and the dispatch tree the shell already renders, and no Chat Node renderer is shadowed. This is the desktop landing point of the interactive reply extension; a client that composes no Tool layer has no keyed cell, and the card does not appear there.
258
+
259
+ The row reads its card from two sources and keeps both:
260
+
261
+ - **While the call runs** the arguments are the only material on the wire, so the page comes out of the call's own `html` argument and the header marks the card as waiting for the operator.
262
+ - **Once the result lands** the presentation payload `meta.ui` is the card's own record — its `key`, `title`, `html`, `height` and `state` — and the header marks it settled. A result that carries no payload falls back to the argument page and still reads as settled, because the stage, not the absent field, decides that.
263
+ - **The frame is `srcdoc` under the one sandbox value the extension allows.** It is `allow-scripts` and never `allow-same-origin`, so the page has an opaque origin and cannot reach the GUI's storage, cookies or DOM; top-level navigation, popups and forms are not granted, and camera, microphone, location and clipboard reads are denied by an explicit permissions policy.
264
+ - **The desktop renders and does not answer.** An action the page posts arrives as one visible sentence telling the operator to answer on the phone; nothing is forwarded, stored or requested, so this half adds no wire surface at all.
265
+ - **Height and theme come from the outside in.** The presenter's `height` covers the first paint, an injected reporter posts the document's own content height and the measurement replaces it; the theme's semantic tokens are read off the GUI root and handed to the page, so a card follows the running light or dark scheme, and a theme that cannot be read costs the variables rather than the card.
266
+ - **A refusal is visible.** A page over 256 KiB is never handed to a frame and states that it was not rendered, and a call that carries no page keeps a neutral line instead of an empty row.
267
+
268
+
247
269
  ## Client script
248
270
 
249
271
  `scripts/client.mjs` is a dependency-free protocol v1 client — Node 22 globals only, no package dependency — used to check a live bridge and to pair a test machine that has no Secure Enclave. It runs the fixed sequence once, prints every frame with its direction and numbers the events in arrival order, so a transcript can be pasted into a report; it never calls a model itself.
@@ -309,3 +331,5 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
309
331
  - **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.
310
332
  - **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.
311
333
  - **`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.
334
+ - **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.
335
+ - **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
@@ -24,6 +24,9 @@
24
24
  - **fork 面。** `session.fork` 把一条会话分叉成继承它上下文的新会话;切点与新会话的身份都属于宿主,因此请求与回包逐字穿过。
25
25
  - **指令面。** `session.commands` 把一个会话的斜杠指令与技能列成同一份目录,`session.command` 执行其中一行并回报宿主是否认出了它;两份表都属于宿主,桥里不缓存任何一条。
26
26
  - **用量面。** `usage.session` 回一条会话的上下文窗口(宿主自己的数字,且只在宿主广播过时才有)以及它下一次请求由什么构成的估算;`usage.balance` 回某条 provider 路由背后账户还剩多少,只在路由确实指向官方 origin 时才去问供应商自己的余额端点,且每分钟最多一次。`usage.stats` 回宿主自己那份按天记的 token 台账——今天与本月各五个桶,外加按日期升序的一天一行——读的是 `dsh-usage` 插件挂在这台机器回环 origin 上的两条 HTTP 路由,30 秒最多一次;没挂那个插件的宿主回 `no-usage-plugin`,而不是一堆 0。宿主没广播过窗口的会话还可能带上 `modelContextWindow`,那是它那条路由的模型目录自己声明的数字,永不与宿主实测的那个混用。
27
+ - **把一整页交给客户端,并把动作收回来。** `ui.present` 收下一整份自包含 HTML,作为 `ui.request` 事件下发到声明了 `ui.v1` 的客户端;
28
+ 用户在页面里的第一条动作就是那次工具调用的返回值,所以图表、表单或列表操作都能成为真正的答案,而不是一道带选项的提问。
29
+ `ui.event` 结算它,`ui.list` 对账客户端此刻仍持有的卡。
27
30
  - **订阅而非轮询。** `session.snapshot` 打开宿主的 follow 流并保持它,基线与其后的每一条增量都走同一条 socket。
28
31
  - **审批直达客户端,重连的手机还能拿回仍悬着的那些。** 需要授权的工具以 `approval.request` 事件到达,客户端用 `approval.resolve` 作答;无人应答的请求按拒绝处理,而声明了 `approvals.v1` 的连接会在握手之后再次收到所有未结算的审批。
29
32
  - **配对。** 一次性 bootstrap token 加 P-256 挑战应答产出可吊销的设备令牌;未配对连接只能触达三个方法。
@@ -45,7 +48,7 @@
45
48
 
46
49
  | 方法 | 请求 `p` | 响应 `r` |
47
50
  | --- | --- | --- |
48
- | `hello` | `{proto:1, minor:17, client:"ios/0.1", cap:["session.snapshot.trim.v1","subagent.thread.v1"]}` | `{proto:1, minor:20, 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"], 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: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"}` |
49
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?}` |
50
53
  | `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
51
54
  | `session.snapshot` | `{sessionId, sinceSeq?, maxBytes?}` | `{turns:[...], lastSeq:<uint>, hasMore?}`;增量另加 `mode:"since", reset:false`,替换客户端副本的基线另加 `mode:"full", reset:true` |
@@ -75,6 +78,8 @@
75
78
  | `pair.begin` | `{token}` | `{nonce, expiresAt}` |
76
79
  | `pair.finish` | `{devicePubKey, signature}` | `{deviceToken, deviceId}` |
77
80
  | `approval.resolve` | `{id, decision}` | `{ok:true}` |
81
+ | `ui.event` | `{sessionId, callId, event:{type, payload?}}` | `{ok:true}`;第一条即结算那次工具调用,此后再来一条回 `ui-settled`,本桥从未认领过的回 `ui-unknown`,payload 超 8 KiB 回 `invalid-args` |
82
+ | `ui.list` | `{}` | `{cards:[{key, sessionId, state, payload}], complete:true}`——只有仍持有的卡;`key` 是 `"<sessionId>/<callId>"`,`payload` 是那张卡 `ui.request` 载荷的逐字副本,而这次读不认领、不改 deadline、不触发任何结算 |
78
83
 
79
84
  `hello` 无需设备令牌即可调用,并回报本连接自身的 `auth` 状态。`session.snapshot` 把宿主 follow 流的开帧快照映射成 `turns`,把它的 cursor 作为 `lastSeq` 回报,随后保持该流作为本连接对该会话的订阅;`session.prompt` 幂等地确保同一条订阅,因此客户端可以跳过 snapshot。发言模式固定为排队,`clientTimeZone` 由服务端填本机 IANA 时区,`requestId` 是幂等键:同名 `requestId` 在同一会话内只发一次,重复调用直接回 `{accepted:true}` 且不再发送。`session.interrupt` 取消回合,不拆除订阅。
80
85
 
@@ -90,7 +95,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
90
95
 
91
96
  用量通道读的是两件属于宿主、而不属于某台设备的事实,因此一个实例服务所有连接。`usage.session` 点名一条会话并回 `{contextWindow?, composition?}`:窗口是本进程看到宿主广播的最近一次 `request/context` 里的 `RequestContext.contextWindow`,组成则是本桥对「下一次请求由什么构成」的估算,分三格——`tools` 取最近一次 `request/header` 的 tools schema 原文,`system` 取最近一条 `system/message` 的文本,`messages` 取此后观察到的每一条 `user/message`、`assistant/message` 与 `tool/result` 的文本——每一格都是 UTF-8 字节数除以四再向下取整,并恒带 `estimated: true`,因为手机绝不能把估算当成宿主的读数。宿主没广播过的键是缺席而不是 0;会话存在而两项读数都取不到时回 `{}`——存在有三处证词:宿主自己的会话名册(与名册方法服务的是同一个 `session/list`,因此本桥从未观察过、当前也不 live 的会话同样算存在)、活会话存储,以及本进程折过的事件——三处都不认这条 id 时才回 `unknown-session`。名册只在另外两处都答不上时才读,且它的答案在五秒内复用,所以一次开屏连问几条只花一次读取;读不到名册的桥退回活会话存储与折叠两条证词。折叠从这一行挂载时开始,且从不读会话日志:挂载之前广播的事件不算读数,因此整段都跑在挂载之前的会话回 `{}`,而不是回一份全是 0 的组成。`usage.balance` 点名一条 provider 路由,回 `{provider, currency, total, toppedUp, granted, updatedAt}`(元口径的金额,取自 `balance_infos[0]`),或回 `{provider, unsupported, reason?}`,取值 `no-credential`、`not-deepseek-route`、`probe-failed`。这条路由必须是官方 DeepSeek 的 id(`deepseek` 或 `deepseek-official`),并且它配置的 `baseURL` 缺席或落在 `https://api.deepseek.com`:余额端点报的是某一个 origin 的账户,拿它去查一个只是复用了 `deepseek` 这个 id 的转售 profile,会把官方账户的钱印在那条路由名下。凭据按宿主自己用量插件的同一套顺序解析——先 pi-ai 记录 `llm-pi-ai/<provider>`,再 profile 的 `apiKeyEnv`,最后 DeepSeek 适配器自己的引用(默认 `DEEPSEEK_API_KEY`)——OAuth grant 在这里不算凭据,因为官方端点只认 API key。同一条读数按 provider + 凭据缓存 60 秒,并发调用合并成一次上游请求;401、超时与认不出的应答体都回 `probe-failed`,绝不把上一轮的读数当成当前值发出去。从未声明 `usage.v1` 的客户端,这两个方法都回 `unknown-method`,桥也不会替它折一条事件、更不会替它打一次上游请求。`usage.stats` 读的是另一个插件记的台账,所以它是 `usage.stats.v1` 背后独立的一个能力、也是独立的一条读路:一条 `GET /api/dsh-usage/overview`,外加——只在请求的窗口比那份文档自带的 30 天更深时——对台账确实记过的每一天各一条 `GET /api/dsh-usage/day?date=YYYY-MM-DD`。台账里没有条目的日子按真实的 0 过线(宿主自己对那些日期答的也是全 0 的一天),而路由不存在(`no-usage-plugin`)、连接不上、形状不符或太慢都回 `probe-failed` 并带一句短原因,绝不拿上一轮的读数顶上。同一个 `days` 窗口在本桥这一侧缓存 30 秒,并发调用合并进去,所以两台手机同时问只让宿主读一次。`usage.session` 在窗口旁边多了一个可选键:宿主没广播过 `request/context` 窗口时,应答可以带上 `modelContextWindow`,取自这条会话当前路由的 `GET {baseURL}/models`——按模型 id 精确匹配后依次取 `context_length`、`context_window`、`max_input_tokens` 里第一个可用值,按路由缓存十分钟,并带上这条路由自己的凭据。两个数字永不混用:`contextWindow` 恒为宿主实测,`modelContextWindow` 恒为模型声明,后者也永不与前者同时出现。
92
97
 
93
- `hello` 还携带客户端的能力声明,而能力是公告而非协商:无论 `cap` 里是什么,握手都回同一个帧,未知名字被忽略;单帧上限在两个方向上都是同一个常量——约束接收帧的 10 MiB,同时也是拟合快照、以及丢弃超限出站事件的同一份预算。本桥自己服务二十一个能力,并在 `hello` 的 `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`——插件注册的能力不在其中,因为桥不是它的作者。`approvals.v1` 也不在其中,它由客户端声明、本桥刻意从不公告:它门控的是一次重放而不是通道本身,因此握手对每个客户端都是同一个帧(见下文审批通道)。`questions.list.v1` 是这里唯一「公告一个方法而不是改变一条通道」的能力:`question.list` 回答本桥此刻仍持有的提问,而只有标了 `complete` 的应答才允许客户端退休它手里的卡。第一个就是裁剪基线。未声明它的客户端——包括该能力出现之前写下的所有客户端——拿到的基线与协议 v1 一直以来提供的逐字节一致。声明了它的客户端拿到的是裁剪过的基线:每个回合内部只保留它能渲染的 entry(`user/message`、`assistant/message`、`tool/call`、`tool/result`、`subagent/catalog`),宿主自己的记账记录(`system/message`、`request/header` 之类)在量帧大小之前就被剔除。快照的其余部分不变:保留哪些回合、它们的顺序,以及每个回合的 `seq`、`endSeq`、`reason`、`time` 都是投影自己的取值;一个回合的 entry 若全是记账记录,该回合仍保留为 `entries` 为空的回合;`lastSeq` 仍是宿主游标。帧预算在其后生效——先裁 entry,再丢最旧的整回合,仍然装不下才回 `snapshot-too-large`。
98
+ `hello` 还携带客户端的能力声明,而能力是公告而非协商:无论 `cap` 里是什么,握手都回同一个帧,未知名字被忽略;单帧上限在两个方向上都是同一个常量——约束接收帧的 10 MiB,同时也是拟合快照、以及丢弃超限出站事件的同一份预算。本桥自己服务二十三个能力,并在 `hello` 的 `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`——插件注册的能力不在其中,因为桥不是它的作者。`ui.v1` 是这里唯一一个「只有真实现了另一半的桥才敢公告」的能力:它背后整页以 `ui.request` 到达,用户的动作以 `ui.event` 回来,而早于这条通道的宿主一帧都不发。`ui.list.v1` 是它的对账读,与 `questions.list.v1` 同一种公告形状:只有标了 `complete` 的应答才允许客户端退休它手里的卡。`approvals.v1` 也不在其中,它由客户端声明、本桥刻意从不公告:它门控的是一次重放而不是通道本身,因此握手对每个客户端都是同一个帧(见下文审批通道)。`questions.list.v1` 是这里唯一「公告一个方法而不是改变一条通道」的能力:`question.list` 回答本桥此刻仍持有的提问,而只有标了 `complete` 的应答才允许客户端退休它手里的卡。第一个就是裁剪基线。未声明它的客户端——包括该能力出现之前写下的所有客户端——拿到的基线与协议 v1 一直以来提供的逐字节一致。声明了它的客户端拿到的是裁剪过的基线:每个回合内部只保留它能渲染的 entry(`user/message`、`assistant/message`、`tool/call`、`tool/result`、`subagent/catalog`),宿主自己的记账记录(`system/message`、`request/header` 之类)在量帧大小之前就被剔除。快照的其余部分不变:保留哪些回合、它们的顺序,以及每个回合的 `seq`、`endSeq`、`reason`、`time` 都是投影自己的取值;一个回合的 entry 若全是记账记录,该回合仍保留为 `entries` 为空的回合;`lastSeq` 仍是宿主游标。帧预算在其后生效——先裁 entry,再丢最旧的整回合,仍然装不下才回 `snapshot-too-large`。
94
99
 
95
100
  第二个能力 `session.snapshot.page.v1` 给首屏本身加上页预算。不声明时,一次快照仍是整个开帧窗口,逐字节与今天一致。声明之后,`session.snapshot` 只回最新一页,按 `maxBytes`(默认 524288,即 512 KiB;不是可用预算就拒绝,而不是悄悄夹取)衡量,并用 `session.history` 那同一套按 entry 的切片来切:一个回合的 entry 可以跨在这一页与下一页之间,而该回合保留自己的字段;比整页预算还大的单条 entry 独占一页;`snapshot-too-large` 再也不会回给这样的连接。预算按整个编码后的应答计量、从不按回合计量,因此它约束的是页而不是 entry:除最新那条 entry 自己就超过预算的情况之外,一页都在 `maxBytes` 之内,而那种情况下这一页就等于该 entry 的大小——一条 2.2 MB 的最新消息对着 512 KiB 的默认预算,回的是 2.2 MB 的一页,而一窗普通 entry 只回 513794 字节。这是分页快照仍可能付出的唯一代价。这一页带 `lastSeq` 与 `hasMore`,而它继续往回的游标就是它自己最旧那条 entry 的 `seq`——正是 `session.history` 的 `before` 所取的值,所以不再用 `nextBefore` 重述一遍。于是打开一个会话只需一页,`session.history` 以同样的 512 KiB 页把窗口其余部分往回走完。 让重连变便宜的能力是 `session.snapshot.since.v1`,而它要两处声明同时成立才改变任何东西:握手里的能力,以及请求里的 `sinceSeq`;缺任何一处,应答逐字节等于该能力出现之前的协议 v1,且不加任何字段,因此客户端可以先接受这个名字,再逐项依赖它。两处都成立时,客户端报出它已持有的那份快照的持久 `lastSeq`——宿主 cursor,从不是本连接自己的事件序号——桥则对着当前 follow 窗口证明连续性:只有当该窗口最旧那条 entry 的 seq 小于等于 `sinceSeq + 1`,或窗口为空时,应答才是增量 `{turns:[...], lastSeq, mode:"since", reset:false}`,只携带该水位之上被发出的 entry,且每个回合保留自己原本的 `seq`、`endSeq`、`reason` 与 `time`,与基线所呈现的形状一致。客户端从不渲染的 entry 仍是窗口持有的 entry,所以这个证明读的是未裁剪的窗口,只可能更保守。窗口若已经滚过该水位,就无法证明链条没断,此时——以及增量装不进一帧 10 MiB 时——应答是本连接本来就会收到的那份基线,另加 `mode:"full"` 与 `reset:true`,这是唯一让客户端丢弃自己副本的应答。裁剪、分页预算与单帧上限都没有动:增量切自同一份投影,而 reset 应答就是今天的应答加上这两个字段。
96
101
 
@@ -129,6 +134,8 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
129
134
 
130
135
  提问通道是唯一一条能比套接字活得久的认领。提问以 `question.request` 事件到达手机,call id 用宿主自己的;阻塞式提问没有 call id,就由本桥另铸一个。手机用 `question.answer` 结算宿主的询问:询问仍然开着时,答案直接解开本桥手里的 promise;宿主自己的截止时间已经放走模型之后,迟到的答案改走宿主的 Remote `answer`。`question.list` 回答本桥此刻仍持有的提问,手机据此与手里的卡对账。没有任何已配对连接在线、但设备名册里有登记过推送令牌时,桥替那台手机认领这道题,推送就是它的送达:在桥自有的一个窗口内,这道题只存在于手机侧,窗口结束即回到宿主自己的应答者链。这个窗口是 `OFFLINE_QUESTION_CLAIM_TTL_MS`,十分钟,可用 `DSH_REMOTE_BRIDGE_OFFLINE_CLAIM_TTL_MS` 覆盖。窗口内重连并声明 `questions.v1` 的手机直接拿到这条仍然有效的认领,窗口到此为止;手机作答即结算,宿主链于是从未启动;而已配对连接完成 `hello` 却没有声明这条通道时,认领立刻被撤回——线上没人能收的认领不留。阻塞式提问(无 call id、无 deadline)同样认领,代价写在明处:它背后的 agent 最多白等这一个窗口。审批沿用上面更严的那条规则:永远不为不在线上的手机持有任何东西。
131
136
 
137
+ 可交互回复是唯一一条「走一整页而不是走一个问题」的通道。`ui.present` 是本桥自己的模型工具:agent 写一整份自包含文档(以 `<!doctype html>` 开头,UTF-8 最多 256 KiB),它作为 `ui.request` 事件、用宿主自己的 `ToolCallId` 下发,于是这张卡正好挂在转录里那条工具调用行上。随后这次调用阻塞,直到用户在页面里的**第一条**动作为止——那个动作 `{type, payload?}`(`type` 是页面自己的闭集,`payload` 最多 8 KiB)就是这次工具调用的返回值:一张卡结算一个动作,需要继续接受动作就让 agent 再呈现一次。结算时这条卡以 `state:"settled"` 对每个声明了 `ui.v1` 的客户端再公告一次(包括刚作答的那台),所以手机上重复的第二次点击、以及第二台手机都能读到它已结束。`ui.list` 回答本桥此刻仍持有的卡,是手机重启后的对账依据,且只有 `complete` 的应答才允许退休一张卡。卡永不携带 `expiresAt`:工具 schema 不声明 `timeout`,本桥也就不发明超时;它拿的是与提问同一个宽限窗口——再没有人能作答的卡在「最后一次配对设备离开」留下的窗口到期时,以超时交还给 agent,而在这个窗口内声明了通道的手机则被重放活卡、并取消这次释放。没有任何声明了 `ui.v1` 的已配对连接时,`ui.present` 立即回 `{ok:false, reason:"unavailable"}`,不占用宿主的等待。真的到过线缆上的那次呈现,其结果在 `meta.ui` 里带着同一份展示载荷——`{key, title?, html, height?, state}`,`key` 是 `"<sessionId>/<callId>"` 拼法——供从转录渲染、手里没有 `ui.request` socket 的客户端使用;结果正文仍是一句人可读的话。
138
+
132
139
  ## 扩展缝
133
140
 
134
141
  本包只发布一道通用扩展缝,自己的词表里不放任何业务词。已挂载的插件解析 cordis 服务 `remoteBridge`,即可向协议 v1 增加方法与事件,而桥不需要知道它们是什么意思:
@@ -140,7 +147,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
140
147
 
141
148
  已注册方法的派发排在两道协议闸门之后:没有插件注册的名字最先回 `unknown-method`;没有有效设备令牌的连接回 `unpaired`,与协议方法完全一致;从未声明该表所需能力的客户端同样回 `unknown-method`——方法对它而言不存在,而不是没有权限。处理器收到请求载荷与本连接 id,回 `{ok:true, r}` 或 `{ok:false, code, msg}`;两种都原样穿过,因为错误码归注册它的插件所有。处理器抛错、或两种形状都没回时,以桥自己的 `internal` 穿过。
142
149
 
143
- `hello` 现在回 `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 自己的。
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 自己的。
144
151
 
145
152
  ## 错误码
146
153
 
@@ -217,7 +224,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
217
224
  }
218
225
  ```
219
226
 
220
- 文件里没有任何可直接使用的明文凭据:一行保留设备的公钥、指纹,以及签发给它的令牌的 SHA-256,从不保留令牌本身。目录为 0700、文件为 0600;写入先落临时文件、flush 后再原子 rename,崩溃不会留下半截名册,解析失败的文件会被改名加上 `.corrupt-<时间戳>` 后缀隔离,而不是被当作空名册。协议 v1 没有吊销方法,所以吊销一个设备就是移除它的那一行(或删掉整个文件)再重启宿主:名册每个进程只读一次,自那次启动起该设备连接即未配对。
227
+ 文件里没有任何可直接使用的明文凭据:一行保留设备的公钥、指纹,以及签发给它的令牌的 SHA-256,从不保留令牌本身。目录为 0700、文件为 0600;写入先落临时文件、flush 后再原子 rename,崩溃不会留下半截名册,解析失败的文件会被改名加上 `.corrupt-<时间戳>` 后缀隔离,而不是被当作空名册。协议 v1 没有吊销方法,所以吊销一个设备就是移除它的那一行(或删掉整个文件)再重启宿主:名册每个进程只读一次,自那次启动起该设备连接即未配对。一行就是一台手机,一枚 APNs 令牌只投一次:重配对是在该设备已有的那一行上换掉 bearer 令牌——deviceId、创建时刻与推送登记原样保留——而读取时会把同一 fingerprint 的多行、以及同一枚令牌落在多行上的情况压缩掉,所以重配对是换凭据而不是加设备,一次事件也不会把同一块锁屏响两遍。
221
228
 
222
229
  ## 中继
223
230
 
@@ -242,6 +249,20 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
242
249
 
243
250
  面板对原生路径而言只是显示层。它从不消耗配对码(`pair.begin` 始终是手机那一侧的动作),从不碰名册,也不新增任何 wire 面——信封、方法名、主题名与事件一律不动。`dsh-remote-web-ui` 的配对服务、名册与浏览器凭据同样不参与其中,因此两条远程面各自保留自己的访问控制。
244
251
 
252
+ ## 会话里的整页卡
253
+
254
+ `ui.present` 把一整页自包含文档交进会话,浏览器半区把它画在官方工具行里:这份呈现是**一次**按线路工具名 `ui.present` 的 keyed `tool.call.toolview` 注册,因此工具行原有的调用身份、耗时与 dispatch 树照旧由官方渲染,本包没有影子化任何 Chat Node 渲染器。这是可交互回复扩展的桌面落点;没有组合出 Tool 层的客户端没有这个 keyed 格,卡片在那种合成里就是不出现。
255
+
256
+ 这一行从两个来源读卡,且两个都不丢:
257
+
258
+ - **调用进行中**,线路上只有参数,页面取自这次调用自己的 `html` 参数,卡头标注等人操作。
259
+ - **结果落地后**,展示载荷 `meta.ui` 就是这张卡自己的记录——它的 `key`、`title`、`html`、`height` 与 `state`——卡头标注已结算。结果没带这个载荷时回退到参数里的页面,并且照样读作已结算:决定这一点的是阶段,不是那个缺席的字段。
260
+ - **画框是 `srcdoc` 加扩展允许的那一个 sandbox 值。** 取值只有 `allow-scripts`,永不带 `allow-same-origin`,因此页面是不透明源,够不到 GUI 的存储、cookie 与 DOM;顶层导航、弹窗与表单一律不授权,相机、麦克风、定位与剪贴板读取由显式的权限策略拒绝。
261
+ - **桌面端只渲染,不作答。** 页面发出的操作会到这里变成一句可见提示,让操作者去手机上作答;不转发、不落库、不发任何请求,所以这一半不新增任何 wire 面。
262
+ - **高度与主题都由外向内给。** 宿主建议的 `height` 只顶第一帧,注入的报告脚本把文档自身的内容高度发出来、以实测为准;主题的语义令牌从 GUI 根元素读出后交给页面,卡片因此跟随当前明暗,读不到主题时损失的是那几个变量而不是卡片。
263
+ - **拒收是可见的。** 超过 256 KiB 的页面不会交给画框,并直说它没有被渲染;一次没带页面的调用保留一行中性说明,而不是留一格空白。
264
+
265
+
245
266
  ## 客户端脚本
246
267
 
247
268
  `scripts/client.mjs` 是一个零依赖的协议 v1 客户端——只用 Node 22 的内置全局,不引任何包——用于对活着的桥接做检查,也给没有 Secure Enclave 的测试机配对。它按固定顺序跑一遍,给每帧加方向前缀、把事件按到达顺序编号,整段输出可直接粘进报告;它自身不执行任何模型调用。
@@ -307,3 +328,5 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
307
328
  - **面板只显示一个配对码,别的都不做。** 它不能列出、命名或吊销已配对设备,也从不消耗配对码——配对发生在手机上,吊销仍然是改名册加重启宿主。
308
329
  - **面板的新鲜度只到它上一次取码为止。** 它在打开时取一次码,之后每按一次「重新取码」再取一次;一直开着时过期的码会翻成过期状态,而不会自己悄悄续期。
309
330
  - **`scripts/client.mjs` 是检查用的工具,不是客户端 SDK。** 它只按固定顺序跑一遍,不保存状态,也没有重连逻辑。
331
+ - **卡片自己的子帧在桌面端没有被拦。** 手机端把卡片里的嵌套 `<iframe>` 当作跨文档跳转一律拒绝;这里沙箱化的画框没有等价的拦截点,所以页面自己的子帧仍会渲染,只是每一帧都保持不透明源。
332
+ - **keyed 注册经由一条本地缝到达槽位。** 声明 `tool.call.toolview` 的那个 SDK 包不是本包的依赖,因此槽位是经窄化后的 `ctx.slots` 端口到达的,端口里镜像了 owner 的阶段联合;把那个包收作 devDependency 后,这条缝会被 SDK 自己的类型替掉。