@linxin666/dsh-remote-bridge 0.4.8 → 0.4.9
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 +2 -2
- package/README.md +50 -17
- package/README.zh.md +50 -17
- package/lib/client.js +274 -253
- package/lib/client.js.map +1 -1
- package/lib/index.js +6690 -2277
- package/lib/types/client/PairEntry.d.ts +2 -2
- package/lib/types/client/PairPanel.d.ts +10 -2
- package/lib/types/client/icons.d.ts +5 -13
- package/lib/types/client/locales.d.ts +10 -14
- package/lib/types/client/semantic.d.ts +9 -5
- package/lib/types/core/commands.d.ts +59 -0
- package/lib/types/core/connection.d.ts +68 -0
- package/lib/types/core/devices.d.ts +98 -2
- package/lib/types/core/hub.d.ts +65 -15
- package/lib/types/core/liveactivity.d.ts +324 -0
- package/lib/types/core/protocol.d.ts +260 -1
- package/lib/types/core/push.d.ts +178 -0
- package/lib/types/core/questions.d.ts +61 -9
- package/lib/types/core/session-meta.d.ts +55 -1
- package/lib/types/core/squads.d.ts +130 -0
- package/lib/types/core/usage-stats.d.ts +160 -0
- package/lib/types/core/usage.d.ts +294 -0
- package/lib/types/host/apns.d.ts +151 -0
- package/lib/types/host/squads-ledger.d.ts +39 -0
- package/lib/types/host/squads.d.ts +77 -0
- package/lib/types/host/usage-stats.d.ts +75 -0
- package/lib/types/host/watchers.d.ts +88 -0
- package/lib/types/index.d.ts +18 -2
- package/package.json +13 -13
- package/src/client/PairEntry.tsx +58 -31
- package/src/client/PairPanel.tsx +181 -97
- package/src/client/icons.tsx +17 -60
- package/src/client/locales.ts +15 -23
- package/src/client/panel.module.css +239 -186
- package/src/client/semantic.ts +10 -6
- package/src/core/commands.ts +95 -0
- package/src/core/connection.ts +646 -10
- package/src/core/devices.ts +221 -3
- package/src/core/hub.ts +362 -42
- package/src/core/liveactivity.ts +833 -0
- package/src/core/protocol.ts +294 -1
- package/src/core/push.ts +354 -0
- package/src/core/questions.ts +81 -10
- package/src/core/session-meta.ts +73 -1
- package/src/core/squads.ts +345 -0
- package/src/core/usage-stats.ts +424 -0
- package/src/core/usage.ts +937 -0
- package/src/core/wire.ts +8 -0
- package/src/host/apns.ts +320 -0
- package/src/host/squads-ledger.ts +105 -0
- package/src/host/squads.ts +206 -0
- package/src/host/usage-stats.ts +155 -0
- package/src/host/watchers.ts +272 -0
- package/src/index.ts +257 -8
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:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 2e01759e6bc9e7c74f65df34725ecc8daa1b82d8
|
|
6
|
+
README.zh.md: f79ea287b9b7087807a0285405a977bc96e2f9b3
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -22,10 +22,12 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
|
|
|
22
22
|
- **A session surface.** `session.list`, `session.titles`, `session.snapshot`, `session.prompt` and `session.interrupt` cover the roster with its workspace, lineage and archive metadata, a batch of session titles, a full baseline plus a live subscription, a queued prompt with an idempotency key, and turn cancellation.
|
|
23
23
|
- **An agent surface.** `presets.list` forwards the host's Agent-preset roster and `session.create` forwards one creation request, so a phone instantiates an Agent from a preset the way the desktop does; neither body is interpreted here.
|
|
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
|
+
- **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
|
+
- **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.
|
|
25
27
|
- **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.
|
|
26
28
|
- **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.
|
|
27
29
|
- **Pairing.** A one-time bootstrap token plus a P-256 challenge-response mint a revocable device token; an unpaired connection reaches three methods only.
|
|
28
|
-
- **A pairing panel.** The same plugin row declares a `dsh.client` browser half: a sidebar-foot
|
|
30
|
+
- **A pairing panel.** The same plugin row declares a `dsh.client` browser half: a sidebar-foot seat that opens the official modal holding one QR symbol, one status line, one address line and one action row, over the live one-time code.
|
|
29
31
|
- **No relay change.** The protocol rides whatever origin the instance already publishes, and the relay hop forwards it exactly as it forwards everything else.
|
|
30
32
|
|
|
31
33
|
## Transport
|
|
@@ -43,7 +45,7 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
|
|
|
43
45
|
|
|
44
46
|
| method | request `p` | response `r` |
|
|
45
47
|
| --- | --- | --- |
|
|
46
|
-
| `hello` | `{proto:1, minor:
|
|
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"}` |
|
|
47
49
|
| `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 |
|
|
48
50
|
| `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
|
|
49
51
|
| `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 |
|
|
@@ -54,6 +56,22 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
|
|
|
54
56
|
| `presets.list` | `{}` | the host's `agentPresets/list` body verbatim |
|
|
55
57
|
| `session.create` | the host's `SessionCreateRequest` | the host's `session/create` body verbatim |
|
|
56
58
|
| `session.fork` | `{sessionId, atSeq?}` | the host's `session/fork` body verbatim, its `SessionForkValue` |
|
|
59
|
+
| `session.commands` | `{sessionId}` | `{sessionId, items:[{name, description, kind, line}]}`, every command first and every skill after |
|
|
60
|
+
| `session.command` | `{sessionId, line}` | `{matched:<bool>}` — false when the host resolves the line to no command |
|
|
61
|
+
| `workspace.list` | `{}` | `{workspaces:[{id, path, title, createdAt?, updatedAt?}], archivedSessionIds:[...], pinnedSessionIds:[...]}` — the registry's own order, both sets always present |
|
|
62
|
+
| `session.rename` | `{sessionId, title}` | the host's `session/rename` body verbatim, its `SessionRenameValue` |
|
|
63
|
+
| `session.pin` | `{sessionId}` | `{ok:true}` |
|
|
64
|
+
| `session.unpin` | `{sessionId}` | `{ok:true}` |
|
|
65
|
+
| `session.archive` | `{sessionId, stopActivity?}` | `{ok:true}` |
|
|
66
|
+
| `session.unarchive` | `{sessionId}` | `{ok:true}` |
|
|
67
|
+
| `squads.state` | `{}` | `{squads:[Squad], runs:[Run], presets?:[string], host:{ownerPid?}}` |
|
|
68
|
+
| `squads.list` | `{}` | `{squads:[Squad]}` — the definitions half of one `squads.state` read |
|
|
69
|
+
| `squads.runs` | `{}` | `{runs:[Run]}` — the run half of the same read |
|
|
70
|
+
| `squads.runMember` | `{squadId, memberId, firstMessage?}` | `{run:Run}`, its `kind` `"member"` |
|
|
71
|
+
| `squads.runSquad` | `{squadId, goal?}` | `{run:Run}`, its `kind` `"squad"` |
|
|
72
|
+
| `usage.session` | `{sessionId}` | `{contextWindow?, modelContextWindow?, composition?:{system, tools, messages, estimated:true}}`; `{}` when the session exists and neither reading does, `unknown-session` when it does not exist |
|
|
73
|
+
| `usage.balance` | `{provider}` | `{provider, currency, total, toppedUp, granted, updatedAt}`, or `{provider, unsupported:"no-credential"|"not-deepseek-route"|"probe-failed", reason?}` |
|
|
74
|
+
| `usage.stats` | `{days?}` | `{updatedAt, today:Buckets, month:Buckets, days:[{day:"YYYY-MM-DD", ...Buckets}], observedSpend?:{cny, since}}` with `Buckets` the five token buckets, or `{unsupported:"no-usage-plugin"|"probe-failed", reason?}` |
|
|
57
75
|
| `pair.begin` | `{token}` | `{nonce, expiresAt}` |
|
|
58
76
|
| `pair.finish` | `{devicePubKey, signature}` | `{deviceToken, deviceId}` |
|
|
59
77
|
| `approval.resolve` | `{id, decision}` | `{ok:true}` |
|
|
@@ -64,7 +82,15 @@ The two agent methods interpret nothing. `presets.list` answers the host's `agen
|
|
|
64
82
|
|
|
65
83
|
The fork method interprets nothing either. `session.fork` sends `sessionId` and, only when the client named one, `atSeq` — the source event seq the fork includes — as that endpoint's single `request` argument, and answers the host's own `SessionForkValue`. An omitted `atSeq` stays omitted: the host reads an absent fork point as its newest finished turn, and inventing one here would move the cut silently. A cut that is not a positive integer is refused here as `invalid-args`, because no event log has such a seq; what the host refuses crosses with the host's own `code` and `msg`, and an uncoded failure as this bridge's `internal`. The method exists only for a client that declared `session.fork.v1`: without it the answer is `unknown-method` and the host is asked nothing.
|
|
66
84
|
|
|
67
|
-
`
|
|
85
|
+
The command channel interprets nothing either. `session.commands` reads both host catalogs for one session and folds them into one directory: `commands/list` is the registry's effective view for that Agent — a command registered through an Agent-scoped child shadows the global one — and `skills/list` is the catalog that session's cwd and preset select, so a phone lists what the desktop composer would offer that same session. Every command comes first and every skill after, each in the host's own order, and no list is re-sorted, de-duplicated or paged. A row is `{name, description, kind, line}`, where `kind` is `command` or `skill` and `line` is the whole draft text that invokes it, separator space included — both host surfaces resolve a bare gesture only when whitespace or the end of the text follows the name, and a skill gesture is `/(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/`. That last rule is also why a skill line is not a command line: a skill is never registered with the command registry, so running one through `session.command` answers `matched: false` and nothing runs. `session.command` sends the line to `commands/execute` exactly as the client wrote it, with an empty attachment list, and answers one decided fact: whether the host resolved the line at all. A line the host resolves runs and answers `matched: true`; a line it resolves to nothing — no leading slash, an unknown name, or a skill's gesture — answers `matched: false` and nothing runs. Nothing is cached and nothing is pushed: both methods read the host on every call, hold no event, and a client that never declared `commands.v1` is answered `unknown-method` with no registry read and no catalog read on its behalf. A host that exports neither endpoint answers this bridge's own `commands-unavailable` rather than a failure per call, while a call the host refuses, and a service that is merely still activating, cross with the failure's own code and text.
|
|
86
|
+
|
|
87
|
+
The session-admin channel interprets nothing either, and it is two capabilities because reading and writing are two different offers. `workspace.list` answers the host registry's own synchronous projection — one row per registered workspace in registry order, never sorted here, never carrying the workspace's session account — with the archive and pin sets beside it; an archived session is a session-level fact, not an archived workspace, so nothing is filtered out of that list and an archived session keeps its slot, which is where `session.unarchive` puts it back. Pinning is a registry-global set rather than an order inside a workspace: a new pin is prepended, a repeated pin neither writes nor reorders, a pin on an archived session is refused by the host, and archiving drops the pin in the same durable write — the visible order a client shows is therefore its own derivation, exactly as the desktop derives it. Five writes then map one-to-one onto the endpoints that already own their semantics: `session.rename` reaches `session/rename`, which restores a cold session before it writes and answers the title it normalized with the seq that committed it, so a client needs no resume path of its own; `session.pin`, `session.unpin`, `session.archive` and `session.unarchive` reach `workspace/pinSession`, `workspace/unpinSession`, `workspace/archiveSession` and `workspace/unarchiveSession`. No boolean is invented and nothing is branched here: `stopActivity` crosses only when the client sent a boolean, and a session that is still running without it is refused by the host as `workspace/session-active`, which is the refusal that tells a phone to offer the confirmation. This channel pushes no event, because the host announces none of these writes as a cordis event a connection could fold into a delta — a rename appends one `session/title` record and nothing else — so a client re-reads after every write: the pin set through `workspace.list`, the roster through `session.list`, and the new name into its own copy while the title cache expires. The cost is stated rather than hidden: a pin or an archive made on the desktop reaches the phone at its next refresh. A connection that never declared `workspace.v1` or `session.admin.v1` is answered `unknown-method` for the methods behind it, with no registry read and no write on its behalf.
|
|
88
|
+
|
|
89
|
+
The squads channel is the one that replaces nothing: it reads and drives the agent squads of the `dsh-agents` plugin, and it sits beside `agents.v1` rather than on top of it, so a phone written before it keeps the preset roster and session creation it was built against. Five commands stand behind `squads.v1`. `squads.state` answers `{squads, runs, presets?, host:{ownerPid?}}`; `squads.list` answers `{squads}` and `squads.runs` answers `{runs}`, the two halves of one read cut from the same answer, so a squad listing and a run history can never disagree; `squads.runMember` sends `{squadId, memberId, firstMessage?}` and `squads.runSquad` sends `{squadId, goal?}`, each answering `{run}`. A `Squad` is `{id, name, description?, workspaceId?, leadPreset?, order?, members:[Member]}` and a `Member` is `{id, name, preset?, permission?, model?, reasoningEffort?, brief?}`; a `Run` is `{id, squadId, kind:'squad'|'member', memberId?, sessionId, createdAt, status:'running'|'settled'|'failed', failure?}`, where `kind` is required on this wire and a run recorded before whole-squad runs existed — one carrying no `kind` at all — reads as the member run it is by construction. Nothing the plugin keeps for itself crosses: a definition's `createdAt`/`updatedAt`, a member's `teamId` backlink and the `goal` handed to a Lead stay on the host's side. The domain is the plugin's own, so its refusals are the plugin's own too and cross with the plugin's code and its one bounded sentence — `team-not-found`, `member-not-found`, `preset-registry-unavailable`, `preset-unknown`, `preset-unavailable`, `workspace-required`, `workspace-unavailable`, `workspace-unknown`, `model-pin-invalid`, `session-create-failed` and their neighbours — while this bridge names only the two conditions the plugin cannot: `squads-unavailable`, for a host that serves no squad domain this bridge can reach or answers a body this build cannot read, and `squads-run-unavailable`, for definitions that are readable while no run route can be reached, which is answered instead of a run that never started. A malformed row is refused rather than repaired and an empty answer is never invented, so a host without the plugin answers an error rather than an empty board. How the domain is reached is this bridge's one dependency-free rule: the plugin's own routes over this machine's loopback origin — `GET /dsh-agents/api/state`, `POST /dsh-agents/api/run`, `POST /dsh-agents/api/squad/run`, addressed at the origin `webServer` already serves and carrying that origin in the `origin` header the plugin's browser fence reads as its same-origin signal — and, when no loopback call can connect at all, the plugin's ledger at `$DSH_HOME/dsh-agents/ledger.json` read read-only under the same rules, with `host.ownerPid` then read out of the plugin's own lock beside it. An answer of any status is not a fallback: it is the plugin speaking, and only a call that never connected reaches the ledger. Nothing is called on a connection's behalf, and a client that never declared `squads.v1` is answered `unknown-method` for all five.
|
|
90
|
+
|
|
91
|
+
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
|
+
|
|
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`.
|
|
68
94
|
|
|
69
95
|
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.
|
|
70
96
|
|
|
@@ -78,7 +104,7 @@ A second capability bounds the opening screen itself: `session.snapshot.page.v1`
|
|
|
78
104
|
|
|
79
105
|
`session.history` reads a session's history backwards in pages, and it is a pure read: it never opens, drops or re-addresses a subscription, and the same cursor always answers the same page. It is served from the very opening baseline `session.snapshot` uses, so the two can never disagree about a turn or an entry — `history` only slices that projection. Pages are cut BY ENTRY, not by turn: a page carries the newest entries below the caller's cursor until the encoded page reaches `maxBytes` (default 524288 = 512 KiB), a turn's entries may therefore be split across pages while that turn keeps its own `seq`, `endSeq`, `reason` and `time`, and a single entry larger than the whole budget is a page of its own rather than a refusal. `before` is a durable watermark, not an index: the page carries the entries whose `seq` is strictly below it, so a cursor stays meaningful across connections and across a projection that changed shape under it. Omit `before` for the newest page; `hasMore` says whether anything older remains, and `nextBefore` — the cursor for the next, older page — is present exactly while `hasMore` is true. The trim capability applies here exactly as it does to a snapshot.
|
|
80
106
|
|
|
81
|
-
`session.list` carries the roster's own fields plus the metadata a phone groups and labels by: `cwd`, `parentSessionId` and `origin` are present only when the host reported them, `blank` is always present, and `archived` is present only when this process can read the host's archive set — a bridge that cannot tell omits the key instead of answering `false`. An archived session is not a row at all: the archive set is read once per listing and every id in it is skipped before its row is built, so the flag that does cross is always `false` and the rows a phone would have hidden cost it nothing. The one read that this makes shorter is the roster: nothing else about the row, the lineage it carries or the delta the connection holds changes. `title`
|
|
107
|
+
`session.list` carries the roster's own fields plus the metadata a phone groups and labels by: `cwd`, `parentSessionId` and `origin` are present only when the host reported them, `blank` is always present, and `archived` is present only when this process can read the host's archive set — a bridge that cannot tell omits the key instead of answering `false`. An archived session is not a row at all: the archive set is read once per listing and every id in it is skipped before its row is built, so the flag that does cross is always `false` and the rows a phone would have hidden cost it nothing. The one read that this makes shorter is the roster: nothing else about the row, the lineage it carries or the delta the connection holds changes. `title` is the name the row itself carries: the host's own `projections.values.title`, which it folds out of its projection cache synchronously for a cold session as well as a live one, and which falls back to whatever this connection has already resolved for that id through `session.titles`, then to `""`. Listing sessions therefore still stays one call and never puts a title read on every row, while `session.titles` remains the live session's immediate source — the one a rename refreshes first — and neither method has to be called for a phone to name a cold session. `session.titles` answers a batch of one to 100 ids out of the host's own title service — the live sessions of this process, never one follow stream per session — and every requested id becomes a key: an id this host does not hold live, or one whose title has not landed yet, answers `""`. One resolved title is served for 10 s before the service is asked again, so a rename can take that long to show. Like every other session method, both answer `unpaired` without a device token.
|
|
82
108
|
|
|
83
109
|
A compact listing is the roster's other form, and it takes both halves to appear: the `session.list.compact.v1` capability and at least one compact parameter. `cwd` is a boolean that decides whether the absolute directory crosses, `maxRows` cuts the roster into pages of that many rows, and `after` is the id of the last row the previous page carried, so a page is continued rather than re-requested. Rows are ordered most recent first with the id as the tiebreak, which is what makes `after` a cursor instead of a position; `nextAfter` is present exactly while rows remain, and a cursor naming no row of this roster answers a first page again, the way a delta token this window never issued answers a reset. `updatedAt` is present only when this connection has not already sent this client that exact value for that id, so a repeated listing carries none of them; `compact:true` says the rows are in this schema, so an absent `updatedAt` is never mistaken for a value the host never had. A listing that names no compact parameter, and every listing from a client that did not declare the capability, is answered the whole roster under the schema above, byte for byte. A compact page and a `since` token are two different answers to two different questions, and a request naming both is refused with `invalid-args`.
|
|
84
110
|
|
|
@@ -101,7 +127,9 @@ A compact listing is the roster's other form, and it takes both halves to appear
|
|
|
101
127
|
| `user-message` | `{text, messageId?, attachments?, actor?}` | a user message; `actor` says where it came from |
|
|
102
128
|
| `subagent` | `{childId, label?, mode?, callId?}` | the harness registered a delegated child; capability `subagent.thread.v1` |
|
|
103
129
|
|
|
104
|
-
An `approval.request` carries a summary taken from the harness's display reason in the client's language, falling back to English and then to the tool name, plus the tool name itself. The client answers it with `approval.resolve`, whose `decision` is either `allowed-once` or `rejected`; an unknown or expired `id` is refused, and a request nobody answers is resolved after two minutes as unavailable, which the harness reads as a rejection. Every paired connection receives the event the moment the tool asks — the first broadcast is behind no capability — and a connection that declared `approvals.v1` in `hello` is handed every still-waiting request again, so a phone that reconnected, or a session screen opened after the fact, still holds a card. Only an unsettled request is replayed: one that was answered, timed out or withdrawn is gone from the claim registry, and re-handing a request never moves its two-minute deadline. The capability gates that second delivery and nothing else, which is why it is absent from `hello`'s `capabilities` and leaves `minor` alone: the handshake answers every client the same frame. The bridge claims
|
|
130
|
+
An `approval.request` carries a summary taken from the harness's display reason in the client's language, falling back to English and then to the tool name, plus the tool name itself. The client answers it with `approval.resolve`, whose `decision` is either `allowed-once` or `rejected`; an unknown or expired `id` is refused, and a request nobody answers is resolved after two minutes as unavailable, which the harness reads as a rejection. Every paired connection receives the event the moment the tool asks — the first broadcast is behind no capability — and a connection that declared `approvals.v1` in `hello` is handed every still-waiting request again, so a phone that reconnected, or a session screen opened after the fact, still holds a card. Only an unsettled request is replayed: one that was answered, timed out or withdrawn is gone from the claim registry, and re-handing a request never moves its two-minute deadline. The capability gates that second delivery and nothing else, which is why it is absent from `hello`'s `capabilities` and leaves `minor` alone: the handshake answers every client the same frame. The bridge claims an approval request only while a paired client is connected: with none, the request is left to the next answerer instead of waiting out a phone that is not there.
|
|
131
|
+
|
|
132
|
+
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.
|
|
105
133
|
|
|
106
134
|
## Extension seam
|
|
107
135
|
|
|
@@ -114,7 +142,7 @@ The package publishes one generic seam and puts no vocabulary of its own in it.
|
|
|
114
142
|
|
|
115
143
|
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`.
|
|
116
144
|
|
|
117
|
-
`hello` answers `minor:11`
|
|
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.
|
|
118
146
|
|
|
119
147
|
## Error codes
|
|
120
148
|
|
|
@@ -130,12 +158,14 @@ A registered method is dispatched after both protocol gates: a name no plugin re
|
|
|
130
158
|
| `invalid-args` | the payload does not match the method's shape |
|
|
131
159
|
| `proto-unsupported` | the `hello` handshake named a protocol version this bridge does not speak |
|
|
132
160
|
| `snapshot-too-large` | the opening snapshot cannot be shrunk to one frame: even a single turn does not fit |
|
|
161
|
+
| `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 |
|
|
162
|
+
| `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 |
|
|
133
163
|
| `internal` | the bridge failed while serving the call |
|
|
134
164
|
| `frame-too-large` | the frame exceeded the 10 MiB cap and was not parsed |
|
|
135
165
|
| `malformed` | the frame is not one JSON object with a recognizable shape |
|
|
136
166
|
| `direction-violation` | the client sent a `res` or `ev` frame, which only the host sends |
|
|
137
167
|
|
|
138
|
-
A failure raised inside DSH is not re-labelled either: it crosses with the gateway's own code, such as `service-unavailable`, `invocation-unavailable`, `definition-unavailable` or `arguments-invalid`. Only the service-activation window is retried (five tries, two seconds apart), because that is the one failure that succeeds moments later.
|
|
168
|
+
A failure raised inside DSH is not re-labelled either: it crosses with the gateway's own code, such as `service-unavailable`, `invocation-unavailable`, `definition-unavailable` or `arguments-invalid`. A refusal the `dsh-agents` plugin raises crosses the same way: its own stable code — `team-not-found`, `member-not-found`, `preset-unknown`, `workspace-required` and their neighbours — with its own one bounded sentence. Only the service-activation window is retried (five tries, two seconds apart), because that is the one failure that succeeds moments later.
|
|
139
169
|
|
|
140
170
|
## Authentication
|
|
141
171
|
|
|
@@ -199,15 +229,18 @@ Two consequences follow from that hop. It sees the request URL, so a `?token=` c
|
|
|
199
229
|
|
|
200
230
|
## Web GUI pairing panel
|
|
201
231
|
|
|
202
|
-
The browser half exists so that an operator who never opens a terminal still has a way to start pairing. It follows the family's sidebar-foot convention: the trigger registers into the official `sidebar.footer.action` list slot (declared by ui-sidebar — the seat `dsh-remote-web-ui`'s phone trigger and `dsh-update`'s updater already share) and opens a
|
|
232
|
+
The browser half exists so that an operator who never opens a terminal still has a way to start pairing. It follows the family's sidebar-foot convention: the trigger registers into the official `sidebar.footer.action` list slot (declared by ui-sidebar — the seat `dsh-remote-web-ui`'s phone trigger and `dsh-update`'s updater already share) and opens the official `Modal`, whose headless card this package fills. Every control it renders is a library primitive — the dialog, the three actions and their glyphs — so the mask, the card, the focus trap, Escape, focus restoration and each hover/focus/disabled state are the shell's behavior rather than a copy of it. It is delivered by the same plugin row: `exports["./client"]` is the artifact and `dsh.client` declares the client modules that must be live first.
|
|
233
|
+
|
|
234
|
+
The panel has one job — put the live one-time code in front of the operator, in one reading order:
|
|
203
235
|
|
|
204
|
-
The
|
|
236
|
+
- **The QR symbol is the code.** It encodes either the bare 43-character base64url token or, when the host can name its own public origin, the `{token,url}` document one scan turns into a fully configured phone. A URL the host did not vouch for would let the phone's own parser rewrite its origin onto this machine's loopback address, which is precisely the address a phone cannot reach. The encoded string is mirrored once, as the `data-dsh-qr-value` attribute on the symbol's part, so a UI check can compare it without decoding anything; it is never rendered as text.
|
|
237
|
+
- **One status line under the symbol.** A live code counts its 30 s window down beside a progress bar; an expired code states the expiry in the same fixed box, so only the sentence changes.
|
|
238
|
+
- **One address line.** When the host located its relay origin, the line names the address the phone will dial; otherwise it says outright that no public address was found, that the phone's connection address has to be the public relay set by hand, and that `127.0.0.1:<port>` (this page) is reachable only from this machine.
|
|
239
|
+
- **One single-use note.** The code is spent the moment the phone starts pairing, and a new code voids the previous one.
|
|
240
|
+
- **One action row.** Copy puts the very string the symbol encodes on the clipboard, and **New code** mints a fresh token and voids the previous one; both are one library control at one size, so their states never diverge. Once the code expires, mint-again is the only way back to a scannable symbol: copy is disabled and the symbol is dimmed in place instead of resized or removed.
|
|
241
|
+
- **A refusal is never silent.** The read is the same loopback-only route an operator would curl: a `403` renders as "this page is not open on this machine" and offers nothing to press, a request that never arrives renders as its own unreachable state with a retry, and an unexpected answer names the status it got.
|
|
205
242
|
|
|
206
|
-
|
|
207
|
-
- **The same token is printed in plaintext** beside the symbol, so an operator can check it by eye, and a copy action puts it on the clipboard.
|
|
208
|
-
- **A 30 s countdown runs** next to a **New code** action; every press mints a fresh token and voids the previous one, and an expired code says so instead of still looking scannable.
|
|
209
|
-
- **The origin warning is stated outright.** This page is served from `127.0.0.1:<port>`, which only this machine can reach, so the phone app's connection address has to be the public relay — such as `wss://<id>.dsh-market.com`.
|
|
210
|
-
- **A refusal is never silent.** The read is the same loopback-only route an operator would curl: a `403` renders as "this page is not open on this machine", and a request that never arrives renders as its own unreachable state.
|
|
243
|
+
Opening and closing are one motion in both directions: the card stays mounted and plays the dialog's own enter fade backwards, and the reduced-motion path keeps that lifecycle as one short opacity fade rather than dropping the exit. Geometry is held across every state — the symbol's box, the status row, the address line and the copy label keep their height and width — so a countdown, an expiry and a copy confirmation never move their neighbours.
|
|
211
244
|
|
|
212
245
|
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.
|
|
213
246
|
|
|
@@ -251,7 +284,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
|
|
|
251
284
|
- **Pairing is a full-control credential.** A paired device reaches the harness in-process: sessions, prompts, approvals. Only pair devices you control, and revoke by removing the roster row and restarting the host.
|
|
252
285
|
- **In-process calls speak for the owner, only behind this bridge's own gate.** Since DSH 0.2.1 the harness gateway requires every call to name the peer it speaks for, and the bridge answers with one in-process owner peer (`{kind:'owner'}`) that it mints itself at mount and attaches to every gateway call. That claim is safe because it is exercised only after the bridge's own pairing check — an unpaired connection is refused before any gateway call exists — and no field of a protocol frame can set a principal: a client that names one in its payload is ignored. The peer takes no forwarded-event interactions, so it never receives forwarded Host events either.
|
|
253
286
|
- **The token endpoint is loopback-only, on two conditions.** The socket address must be loopback and the `Host` header must name this machine. A tunneled request is terminated by the tunnel client on this same host, so the socket address alone reads `127.0.0.1` for a request the whole internet can reach, while the relay and a plain tunnel rewrite `Host` to the public name; failing either condition is a 403. The token is memory-only, expires in 30 s, is spent by one `pair.begin`, and the same link is written to the host log — treat that log line as a live secret.
|
|
254
|
-
- **The pairing panel renders a live secret and nothing more.** It reads the same loopback-gated route over a same-origin request, so it is reachable exactly where the `curl` form is, and nowhere else. It cannot mint a device token, spend one, list the roster or revoke a device: `pair.begin` stays the phone's call, and revocation stays a roster edit plus a host restart. The QR carries the bare token, so the page's
|
|
287
|
+
- **The pairing panel renders a live secret and nothing more.** It reads the same loopback-gated route over a same-origin request, so it is reachable exactly where the `curl` form is, and nowhere else. It cannot mint a device token, spend one, list the roster or revoke a device: `pair.begin` stays the phone's call, and revocation stays a roster edit plus a host restart. The QR carries either the bare token or the host's own `{token,url}` answer, so the page's `127.0.0.1` origin is never handed to the phone.
|
|
255
288
|
- **An unpaired connection has a three-method whitelist.** `hello`, `pair.begin` and `pair.finish`; every other method answers `unpaired` before dispatch, so no session, approval or roster surface is reachable without a device token.
|
|
256
289
|
- **Device tokens are stored as hashes only.** The roster keeps the public key and its SHA-256 fingerprint, never the token, so the file is not a credential store. A lost, rotated or rejected token means pairing again — a routine flow, not an exception path (a fresh bootstrap link, or a re-scan of the desktop pairing flow), and it never requires editing the roster by hand.
|
|
257
290
|
- **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.
|
|
@@ -260,7 +293,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
|
|
|
260
293
|
|
|
261
294
|
## Known limitations
|
|
262
295
|
|
|
263
|
-
-
|
|
296
|
+
- **`session.titles` answers live sessions only.** It reads the titles of the sessions this host process holds live, so an id the host does not hold live answers `""` there; the roster's own rows carry their projected title, cold sessions included, and are named without that call.
|
|
264
297
|
- **A served title can be up to 10 s old.** One resolved title is served for 10 s before the title service is asked again, so a rename or a newly generated title can take that long to appear.
|
|
265
298
|
- **`archived` is absent when the archive set cannot be read.** The flag comes from the host's workspace registry; when that service is not mounted, every row omits the key instead of answering `false`, and nothing is dropped — a bridge that cannot tell does not answer a shorter roster.
|
|
266
299
|
- **An archived parent authorizes nothing.** A live child of an archived parent is still listed and still names that parent, but following the child answers `session-not-followable` until the parent is restored: the roster is what authorizes a session, and an archived one is no longer on it.
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
- **会话面。** `session.list`、`session.titles`、`session.snapshot`、`session.prompt`、`session.interrupt` 分别覆盖带工作区、谱系与归档元数据的名册、一批会话标题、完整基线加实时订阅、带幂等键的排队发言,以及回合取消。
|
|
23
23
|
- **agent 面。** `presets.list` 转发宿主的 Agent 预设名册,`session.create` 转发一次创建请求,手机因此能像桌面一样从预设实例化一个 Agent;这两个身体在桥里都不被解释。
|
|
24
24
|
- **fork 面。** `session.fork` 把一条会话分叉成继承它上下文的新会话;切点与新会话的身份都属于宿主,因此请求与回包逐字穿过。
|
|
25
|
+
- **指令面。** `session.commands` 把一个会话的斜杠指令与技能列成同一份目录,`session.command` 执行其中一行并回报宿主是否认出了它;两份表都属于宿主,桥里不缓存任何一条。
|
|
26
|
+
- **用量面。** `usage.session` 回一条会话的上下文窗口(宿主自己的数字,且只在宿主广播过时才有)以及它下一次请求由什么构成的估算;`usage.balance` 回某条 provider 路由背后账户还剩多少,只在路由确实指向官方 origin 时才去问供应商自己的余额端点,且每分钟最多一次。`usage.stats` 回宿主自己那份按天记的 token 台账——今天与本月各五个桶,外加按日期升序的一天一行——读的是 `dsh-usage` 插件挂在这台机器回环 origin 上的两条 HTTP 路由,30 秒最多一次;没挂那个插件的宿主回 `no-usage-plugin`,而不是一堆 0。宿主没广播过窗口的会话还可能带上 `modelContextWindow`,那是它那条路由的模型目录自己声明的数字,永不与宿主实测的那个混用。
|
|
25
27
|
- **订阅而非轮询。** `session.snapshot` 打开宿主的 follow 流并保持它,基线与其后的每一条增量都走同一条 socket。
|
|
26
28
|
- **审批直达客户端,重连的手机还能拿回仍悬着的那些。** 需要授权的工具以 `approval.request` 事件到达,客户端用 `approval.resolve` 作答;无人应答的请求按拒绝处理,而声明了 `approvals.v1` 的连接会在握手之后再次收到所有未结算的审批。
|
|
27
29
|
- **配对。** 一次性 bootstrap token 加 P-256 挑战应答产出可吊销的设备令牌;未配对连接只能触达三个方法。
|
|
28
|
-
- **一个配对面板。** 同一插件行声明 `dsh.client`
|
|
30
|
+
- **一个配对面板。** 同一插件行声明 `dsh.client` 浏览器半区:侧栏底部一个座位,点开官方弹窗,里面只有一张二维码、一条状态行、一条地址说明与一行动作,摆着当前那个一次性配对码。
|
|
29
31
|
- **中继无需改动。** 协议搭在实例本来就发布的那个 origin 上,中继这一跳照原样转发它,与其他所有请求无异。
|
|
30
32
|
|
|
31
33
|
## 传输
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
|
|
44
46
|
| 方法 | 请求 `p` | 响应 `r` |
|
|
45
47
|
| --- | --- | --- |
|
|
46
|
-
| `hello` | `{proto:1, minor:
|
|
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"}` |
|
|
47
49
|
| `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?}` |
|
|
48
50
|
| `session.titles` | `{ids:[<sessionId>, ...]}` | `{titles:{"<id>":"<title>", ...}}` |
|
|
49
51
|
| `session.snapshot` | `{sessionId, sinceSeq?, maxBytes?}` | `{turns:[...], lastSeq:<uint>, hasMore?}`;增量另加 `mode:"since", reset:false`,替换客户端副本的基线另加 `mode:"full", reset:true` |
|
|
@@ -54,6 +56,22 @@
|
|
|
54
56
|
| `presets.list` | `{}` | 宿主 `agentPresets/list` 的身体,逐字转发 |
|
|
55
57
|
| `session.create` | 宿主自己的 `SessionCreateRequest` | 宿主 `session/create` 的身体,逐字转发 |
|
|
56
58
|
| `session.fork` | `{sessionId, atSeq?}` | 宿主 `session/fork` 的身体(`SessionForkValue`),逐字转发 |
|
|
59
|
+
| `session.commands` | `{sessionId}` | `{sessionId, items:[{name, description, kind, line}]}`,先全部指令、再全部技能 |
|
|
60
|
+
| `session.command` | `{sessionId, line}` | `{matched:<bool>}`——宿主没把该行解析成指令时为 false |
|
|
61
|
+
| `workspace.list` | `{}` | `{workspaces:[{id, path, title, createdAt?, updatedAt?}], archivedSessionIds:[...], pinnedSessionIds:[...]}`——注册表自己的顺序,两个集合总是存在 |
|
|
62
|
+
| `session.rename` | `{sessionId, title}` | 宿主 `session/rename` 的身体(`SessionRenameValue`),逐字转发 |
|
|
63
|
+
| `session.pin` | `{sessionId}` | `{ok:true}` |
|
|
64
|
+
| `session.unpin` | `{sessionId}` | `{ok:true}` |
|
|
65
|
+
| `session.archive` | `{sessionId, stopActivity?}` | `{ok:true}` |
|
|
66
|
+
| `session.unarchive` | `{sessionId}` | `{ok:true}` |
|
|
67
|
+
| `squads.state` | `{}` | `{squads:[Squad], runs:[Run], presets?:[string], host:{ownerPid?}}` |
|
|
68
|
+
| `squads.list` | `{}` | `{squads:[Squad]}`——同一次 `squads.state` 读取的定义半区 |
|
|
69
|
+
| `squads.runs` | `{}` | `{runs:[Run]}`——同一次读取的运行半区 |
|
|
70
|
+
| `squads.runMember` | `{squadId, memberId, firstMessage?}` | `{run:Run}`,其 `kind` 为 `"member"` |
|
|
71
|
+
| `squads.runSquad` | `{squadId, goal?}` | `{run:Run}`,其 `kind` 为 `"squad"` |
|
|
72
|
+
| `usage.session` | `{sessionId}` | `{contextWindow?, modelContextWindow?, composition?:{system, tools, messages, estimated:true}}`;会话存在但两项读数都没有时回 `{}`,会话不存在时回 `unknown-session` |
|
|
73
|
+
| `usage.balance` | `{provider}` | `{provider, currency, total, toppedUp, granted, updatedAt}`,或 `{provider, unsupported:"no-credential"|"not-deepseek-route"|"probe-failed", reason?}` |
|
|
74
|
+
| `usage.stats` | `{days?}` | `{updatedAt, today:Buckets, month:Buckets, days:[{day:"YYYY-MM-DD", ...Buckets}], observedSpend?:{cny, since}}`,`Buckets` 是那五个 token 桶;或 `{unsupported:"no-usage-plugin"|"probe-failed", reason?}` |
|
|
57
75
|
| `pair.begin` | `{token}` | `{nonce, expiresAt}` |
|
|
58
76
|
| `pair.finish` | `{devicePubKey, signature}` | `{deviceToken, deviceId}` |
|
|
59
77
|
| `approval.resolve` | `{id, decision}` | `{ok:true}` |
|
|
@@ -64,7 +82,15 @@ agent 的两个方法什么都不解释。`presets.list` 把宿主 `agentPresets
|
|
|
64
82
|
|
|
65
83
|
fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客户端真的点名时才有的 `atSeq`(fork 包含的源事件 seq)作为该端点唯一的 `request` 参数送出,再把宿主自己的 `SessionForkValue` 原样回给客户端。省略的 `atSeq` 就保持省略:宿主把缺席的切点读成最新一个已完成轮,在这里补一个等于悄悄挪动切点。不是正整数的切点在这里以 `invalid-args` 拒绝,因为任何事件日志都没有这样的 seq;宿主拒绝的请求带着宿主自己的 `code` 与 `msg` 穿出,没有错误码的失败以本桥的 `internal` 穿出。该方法只对声明了 `session.fork.v1` 的客户端存在:没声明时回 `unknown-method`,且什么都不发。
|
|
66
84
|
|
|
67
|
-
`
|
|
85
|
+
指令通道同样什么都不解释。`session.commands` 读出宿主为同一个会话准备的两份表并折成一份目录:`commands/list` 是该 Agent 的有效视图——通过 Agent 作用域子上下文注册的指令会遮蔽全局那一条——`skills/list` 是该会话 cwd 与预设选出的技能表,因此手机列出的就是桌面输入框会为同一会话提供的东西。先全部指令、再全部技能,各自保持宿主的顺序,不重排、不去重、不分页。一行是 `{name, description, kind, line}`:`kind` 取 `command` 或 `skill`,`line` 是能唤起它的整行草稿文本,含分隔空格——两个宿主面都只在名字后面跟着空白或文本结尾时才认这个手势,而技能手势是 `/(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/`。这条规则也正是技能行不是指令行的原因:技能从不注册进指令表,因此拿它调 `session.command` 只会回 `matched: false`,什么都跑不起来。`session.command` 把该行原样交给 `commands/execute`,附件列表为空,只回答一个确定的事实:宿主到底有没有认出这一行。认出就执行并回 `matched: true`;解析不出指令——没有前导斜杠、名字不认识、或技能手势——回 `matched: false` 且什么都没跑。两个方法都不缓存、不推送:每次调用都去读宿主,不持任何事件;从未声明 `commands.v1` 的客户端回 `unknown-method`,且不会为它读一次指令表或技能表。一个两端点都不导出的宿主回本桥自己的 `commands-unavailable`,而不是每次调用都失败一次;宿主主动拒绝的一次调用、以及仅仅还在激活中的服务,则带着它们自己的 code 与 msg 穿出。
|
|
86
|
+
|
|
87
|
+
会话管理通道同样什么都不解释,而它分成两个能力,是因为读与写是两份不同的提供。`workspace.list` 回的是宿主注册表自己的同步投影——每个已注册工作区一行、按注册表自己的顺序、这里不排序、也不带工作区自己的会话账本——旁边是两个全局会话集合;归档是会话级的事实而不是"已归档的工作区",因此这张表里什么都不被过滤,已归档会话仍保留原槽位,`session.unarchive` 就把它放回那里。置顶是注册表全局集合而不是某个工作区内的排序:新的置顶前插、重复置顶既不写也不重排、对已归档会话置顶被宿主拒绝、归档在同一次持久写里丢掉置顶——因此客户端展示的可见顺序是它自己推导的,与桌面端一致。五个写方法一对一映射到本来就拥有这些语义的端点:`session.rename` 打到 `session/rename`,后者先恢复冷会话再写,并回它归一化后的标题与提交它的 seq,所以客户端不需要自己的 resume 路径;`session.pin`、`session.unpin`、`session.archive`、`session.unarchive` 分别打到 `workspace/pinSession`、`workspace/unpinSession`、`workspace/archiveSession`、`workspace/unarchiveSession`。这里不发明布尔参数、也不在桥里分支:`stopActivity` 只在客户端发来布尔值时透传,不带它而会话仍在跑时由宿主以 `workspace/session-active` 拒绝,正是这条拒绝告诉手机该弹确认。这条通道不推任何事件,因为宿主并不把这些写公告成连接能折进增量的 cordis 事件——改名只追加一条 `session/title` 记录——所以客户端每次写成功后自己重读:置顶集合读 `workspace.list`,名册读 `session.list`,新名字写进自己的副本并等标题缓存过期。代价写在这里而不是藏起来:桌面上做的置顶或归档,要等手机下一次刷新才看得见。从未声明 `workspace.v1` 或 `session.admin.v1` 的连接,其背后的方法一律回 `unknown-method`,既不为它读一次注册表,也不为它写一次。
|
|
88
|
+
|
|
89
|
+
小队通道是唯一一条不替换任何东西的通道:它读并驱动 `dsh-agents` 插件的小队域,与 `agents.v1` 并排而不是叠在它上面,因此早于它写下的手机仍然拿到当初依赖的预设名册与会话创建。`squads.v1` 背后是五条指令。`squads.state` 回 `{squads, runs, presets?, host:{ownerPid?}}`;`squads.list` 回 `{squads}`、`squads.runs` 回 `{runs}`,两者是同一次读取的两个半区、从同一份应答切出,所以小队名册与运行历史不可能互相矛盾;`squads.runMember` 发 `{squadId, memberId, firstMessage?}`、`squads.runSquad` 发 `{squadId, goal?}`,各自回 `{run}`。`Squad` 是 `{id, name, description?, workspaceId?, leadPreset?, order?, members:[Member]}`,`Member` 是 `{id, name, preset?, permission?, model?, reasoningEffort?, brief?}`;`Run` 是 `{id, squadId, kind:'squad'|'member', memberId?, sessionId, createdAt, status:'running'|'settled'|'failed', failure?}`,其中 `kind` 在这条线上必填,而整队运行出现之前记下的运行(压根不带 `kind`)按它本来就成立的成员运行读。插件留给自己的东西一样都不过线:定义的 `createdAt`/`updatedAt`、成员回指团队的 `teamId`、以及交给 Lead 的 `goal` 都留在宿主那一侧。域是插件自己的域,拒绝也是插件自己的拒绝,带着插件自己的码与那一句有界文案过线——`team-not-found`、`member-not-found`、`preset-registry-unavailable`、`preset-unknown`、`preset-unavailable`、`workspace-required`、`workspace-unavailable`、`workspace-unknown`、`model-pin-invalid`、`session-create-failed` 及其邻居——桥自己只命名插件命名不了的两种条件:`squads-unavailable`,本宿主没有它能到达的小队域,或者回的应答体本构建读不懂;`squads-run-unavailable`,定义读得到、却到达不了任何运行路由,那时回的是这条码而不是一个从未启动的运行。畸形行被拒绝而不是被修补,空应答从不被发明,所以没装插件的宿主回错误而不回空板。域怎么到达属于本桥唯一那条不引依赖的规矩:优先走插件自己在这台机器 loopback origin 上的路由——`GET /dsh-agents/api/state`、`POST /dsh-agents/api/run`、`POST /dsh-agents/api/squad/run`,地址取自 `webServer` 已经在服务的 origin,并在 `origin` 头里带上同一个 origin,正是插件浏览器围栏读作同源信号的那个头——当 loopback 调用根本连不上时,改为只读地读插件账本 `$DSH_HOME/dsh-agents/ledger.json`,按同一套规则校验,此时 `host.ownerPid` 从旁边的插件自己的锁文件读出。任何状态码的应答都不是兜底:那是插件在说话,只有根本没连上的调用才走到账本。这两个方法都不替任何连接代调,从未声明 `squads.v1` 的客户端五条一律得到 `unknown-method`。
|
|
90
|
+
|
|
91
|
+
用量通道读的是两件属于宿主、而不属于某台设备的事实,因此一个实例服务所有连接。`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
|
+
|
|
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`。
|
|
68
94
|
|
|
69
95
|
第二个能力 `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 应答就是今天的应答加上这两个字段。
|
|
70
96
|
|
|
@@ -76,7 +102,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
76
102
|
|
|
77
103
|
`session.history` 以分页方式往回读一个会话的历史,而且它是纯读:既不打开、也不丢弃或改指任何订阅,同一个游标永远给出同一页。它的数据来自 `session.snapshot` 所用的那份开帧基线,因此两者永远不会在某个回合或某条 entry 上给出不同答案——`history` 只是对这份投影做切片。分页按 **entry** 切,不按回合切:一页从调用方游标之下取最新的 entry,直到编码后的页达到 `maxBytes`(默认 524288,即 512 KiB);因此一个回合的 entry 可以跨页,而该回合仍保留自己的 `seq`、`endSeq`、`reason` 与 `time`;单条 entry 若比整页预算还大,就独占一页,而不是被拒绝。`before` 是持久水位而非下标:这一页取 `seq` 严格小于它的 entry,所以游标跨连接仍然有意义,投影在它之下改变形状也不会让分页跳号或重复。省略 `before` 即取最新一页;`hasMore` 说明下面是否还有更旧的 entry,而下一页的游标 `nextBefore` 恰好在 `hasMore` 为真时出现。裁剪能力在这里的生效方式与快照完全一致。
|
|
78
104
|
|
|
79
|
-
`session.list` 除名册自身字段外还带上手机用来分组与命名的元数据:`cwd`、`parentSessionId`、`origin` 只在宿主确实上报时才出现,`blank` 始终存在,`archived` 只在本次进程能读到宿主归档集时出现——读不到就省略该键,而不是回 `false`。已归档的会话根本不是一行:归档集每次列出只读一次,其中的 id 在构造该行之前就被跳过,因此真正穿过去的标记永远是 `false`,而手机本来要藏起来的那些行一个字节都不再花。`title`
|
|
105
|
+
`session.list` 除名册自身字段外还带上手机用来分组与命名的元数据:`cwd`、`parentSessionId`、`origin` 只在宿主确实上报时才出现,`blank` 始终存在,`archived` 只在本次进程能读到宿主归档集时出现——读不到就省略该键,而不是回 `false`。已归档的会话根本不是一行:归档集每次列出只读一次,其中的 id 在构造该行之前就被跳过,因此真正穿过去的标记永远是 `false`,而手机本来要藏起来的那些行一个字节都不再花。`title` 就是该行自己带来的名字:宿主自己的 `projections.values.title`,冷会话与活跃会话都由它同步从投影缓存里折出;取不到才退回本连接已经通过 `session.titles` 解析过的值,再取不到才是 `""`。因此列名册仍然只是一次调用,不会给每一行挂上一次标题读取;而 `session.titles` 依旧是活跃会话的即时来源——改名之后最先刷新的就是它——手机要给冷会话命名,两个方法都不必调用。`session.titles` 用宿主自己的标题服务回答一批 1 到 100 个 id——读的是本进程的活跃会话,绝不为每个会话各开一条 follow 流——且每个被请求的 id 都是键:本宿主没有活跃持有的 id、或标题尚未落地的 id,一律回 `""`。一个已解析的标题会在 10 秒内被直接复用,之后才再问服务,因此重命名最多要等这么久才可见。与其它会话方法一样,没有设备令牌时两者都回 `unpaired`。
|
|
80
106
|
|
|
81
107
|
紧凑名册是同一份名册的另一种形态,需要两半同时出现:`session.list.compact.v1` 能力,以及请求里至少一个紧凑参数。`cwd` 是布尔值,决定绝对目录是否过线;`maxRows` 把名册切成每页这么多行;`after` 是上一页最后一行的 id,因此是续页而不是重取。行按最近优先排序、id 作平手判据,这正是 `after` 成为游标而不是位置的原因;`nextAfter` 只在后面还有行时出现,而指不到任何行的游标回第一页——就像本窗口从未签发过的 delta 令牌回 reset。`updatedAt` 只在本连接尚未把该 id 的这个值发给该客户端时出现,因此重复列出时一个都不带;`compact:true` 表明这些行就在这个 schema 下,于是缺失的 `updatedAt` 永远不会被误读成宿主从来没有的值。不带任何紧凑参数的请求,以及未声明该能力的客户端发出的每一次请求,都按上面的 schema 得到整份名册,逐字节相同。紧凑页与 `since` 令牌是两个不同问题各自的答案,同时出现的请求以 `invalid-args` 拒绝。
|
|
82
108
|
|
|
@@ -99,7 +125,9 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
99
125
|
| `user-message` | `{text, messageId?, attachments?, actor?}` | 一条用户消息;`actor` 说明它从哪来 |
|
|
100
126
|
| `subagent` | `{childId, label?, mode?, callId?}` | 宿主登记了一个被委派的子会话;需能力 `subagent.thread.v1` |
|
|
101
127
|
|
|
102
|
-
`approval.request` 的摘要取自宿主按客户端语言给出的显示理由,缺失时回落英文、再回落工具名,并附带工具名本身。客户端用 `approval.resolve` 作答,`decision` 取 `allowed-once` 或 `rejected`;未知或过期的 `id` 会被拒绝,而无人应答的请求在两分钟后按 unavailable 结算,宿主视之为拒绝。工具发起请求的那一刻,每一条已配对连接都会收到该事件——首播不在任何能力名之后——而声明了 `approvals.v1` 的连接会在 `hello` 之后再次收到所有仍在等待的请求,因此重连过的手机、或事后才打开该会话的界面,手里依然有卡片。只有未结算的请求会被重放:已作答、已超时、已撤回的请求早已离开认领表,而重新递一次请求绝不会挪动它的两分钟截止时间。该能力只门控这第二次送达,因此它不出现在 `hello` 的 `capabilities` 里、也不改动 `minor
|
|
128
|
+
`approval.request` 的摘要取自宿主按客户端语言给出的显示理由,缺失时回落英文、再回落工具名,并附带工具名本身。客户端用 `approval.resolve` 作答,`decision` 取 `allowed-once` 或 `rejected`;未知或过期的 `id` 会被拒绝,而无人应答的请求在两分钟后按 unavailable 结算,宿主视之为拒绝。工具发起请求的那一刻,每一条已配对连接都会收到该事件——首播不在任何能力名之后——而声明了 `approvals.v1` 的连接会在 `hello` 之后再次收到所有仍在等待的请求,因此重连过的手机、或事后才打开该会话的界面,手里依然有卡片。只有未结算的请求会被重放:已作答、已超时、已撤回的请求早已离开认领表,而重新递一次请求绝不会挪动它的两分钟截止时间。该能力只门控这第二次送达,因此它不出现在 `hello` 的 `capabilities` 里、也不改动 `minor`:握手对每个客户端都回同一个帧。桥只在下游有已配对客户端连接时才认领审批请求:一个都没有时,请求交给下一个应答者,而不是干等一台不在场的手机。
|
|
129
|
+
|
|
130
|
+
提问通道是唯一一条能比套接字活得久的认领。提问以 `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 最多白等这一个窗口。审批沿用上面更严的那条规则:永远不为不在线上的手机持有任何东西。
|
|
103
131
|
|
|
104
132
|
## 扩展缝
|
|
105
133
|
|
|
@@ -112,7 +140,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
112
140
|
|
|
113
141
|
已注册方法的派发排在两道协议闸门之后:没有插件注册的名字最先回 `unknown-method`;没有有效设备令牌的连接回 `unpaired`,与协议方法完全一致;从未声明该表所需能力的客户端同样回 `unknown-method`——方法对它而言不存在,而不是没有权限。处理器收到请求载荷与本连接 id,回 `{ok:true, r}` 或 `{ok:false, code, msg}`;两种都原样穿过,因为错误码归注册它的插件所有。处理器抛错、或两种形状都没回时,以桥自己的 `internal` 穿过。
|
|
114
142
|
|
|
115
|
-
`hello` 现在回 `minor:11
|
|
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 自己的。
|
|
116
144
|
|
|
117
145
|
## 错误码
|
|
118
146
|
|
|
@@ -128,12 +156,14 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
128
156
|
| `invalid-args` | 载荷与方法形状不符 |
|
|
129
157
|
| `proto-unsupported` | `hello` 握手声明的协议版本本桥说不出来 |
|
|
130
158
|
| `snapshot-too-large` | 开帧快照无法压缩进单帧:连一个回合都放不下 |
|
|
159
|
+
| `squads-unavailable` | 本宿主没有本桥能到达的 `dsh-agents` 小队域:插件 loopback 路由没有应答、旁边没有可读的账本,或者应答体不是本构建读得懂的那一个域。小队读取从不以空板回答,而插件自己抛出的拒绝带着插件自己的码穿过 |
|
|
160
|
+
| `squads-run-unavailable` | 定义读得到,但两条运行指令服务不了:到达不了任何 loopback 运行路由,只读账本也启动不了会话。回一个从未启动的运行是这条通道唯一不做的事 |
|
|
131
161
|
| `internal` | 桥在服务该调用时自身失败 |
|
|
132
162
|
| `frame-too-large` | 该帧超过 10 MiB 上限,未被解析 |
|
|
133
163
|
| `malformed` | 该帧不是形状可辨的单个 JSON 对象 |
|
|
134
164
|
| `direction-violation` | 客户端发来了只有宿主才发的 `res` 或 `ev` 帧 |
|
|
135
165
|
|
|
136
|
-
在 DSH 内部产生的失败同样不被改名:它带着 gateway 自己的错误码穿过桥,例如 `service-unavailable`、`invocation-unavailable`、`definition-unavailable`、`arguments-invalid
|
|
166
|
+
在 DSH 内部产生的失败同样不被改名:它带着 gateway 自己的错误码穿过桥,例如 `service-unavailable`、`invocation-unavailable`、`definition-unavailable`、`arguments-invalid`。`dsh-agents` 插件抛出的拒绝也这样穿过:带它自己的稳定错误码——`team-not-found`、`member-not-found`、`preset-unknown`、`workspace-required` 及其邻居——以及它自己那一句有界文案。只有服务激活窗口会被重试(5 次、间隔 2 秒),因为那是唯一「片刻后即成功」的失败。
|
|
137
167
|
|
|
138
168
|
## 鉴权
|
|
139
169
|
|
|
@@ -197,15 +227,18 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
197
227
|
|
|
198
228
|
## Web GUI 配对面板
|
|
199
229
|
|
|
200
|
-
浏览器半区存在的理由,是让从不开终端的操作者也有一条发起配对的路径。它沿用家族在侧栏底部的惯例:触发器注册进官方 `sidebar.footer.action` 列表槽位(由 ui-sidebar 声明——`dsh-remote-web-ui` 的手机触发器与 `dsh-update`
|
|
230
|
+
浏览器半区存在的理由,是让从不开终端的操作者也有一条发起配对的路径。它沿用家族在侧栏底部的惯例:触发器注册进官方 `sidebar.footer.action` 列表槽位(由 ui-sidebar 声明——`dsh-remote-web-ui` 的手机触发器与 `dsh-update` 的更新器已经共用的那个座位),点开后是官方 `Modal`,这张无头卡片由本包填充。它渲染的每个控件都是库里已有的 primitive——弹窗、三个动作与它们的字形——因此遮罩、卡片、焦点圈定、Esc、焦点归还,以及每个 hover/focus/disabled 状态都是官方壳自己的行为,而不是本包的一份复制品。它由同一插件行承载:产物是 `exports["./client"]`,`dsh.client` 声明必须先就位的 client 模块。
|
|
231
|
+
|
|
232
|
+
面板只做一件事——把活着的那个一次性配对码摆到操作者面前,且只有这一个阅读顺序:
|
|
201
233
|
|
|
202
|
-
|
|
234
|
+
- **二维码本身就是那个码。** 它要么装 43 个 base64url 字符的裸 token,要么在宿主说得出自己公网地址时装 `{token,url}` 文档,扫一次就把手机配好。若放一个宿主没背书过的 URL,手机端的解析器会顺手把 origin 改写成这台机器的 loopback 地址,而那恰恰是手机够不到的地址。编码串只在二维码部件的 `data-dsh-qr-value` 属性里留一份镜像,供 UI 检查不必解码就比对;它从不以文字形式渲染。
|
|
235
|
+
- **二维码下方只有一条状态行。** 活着的码在进度条旁倒数那 30 秒;过期的码在同一个固定高度里直说过期,变的只有那句话。
|
|
236
|
+
- **一条地址说明。** 宿主定位到中继地址时,这一行就写明手机将要连到哪儿;定位不到时,它直说没找到公网地址、手机里的连接地址得手填公网中继,并点明本页所在的 `127.0.0.1:<端口>` 只有本机能连。
|
|
237
|
+
- **一条一次性说明。** 手机一开始配对,这个码就作废;重新取码同样会作废上一张。
|
|
238
|
+
- **一行动作。** 复制把二维码里那个字符串原样放进剪贴板,「重新取码」签发新 token 并作废上一张;两者都是同一个库控件、同一个尺寸,交互态不会各走一套。码一旦过期,回到可扫状态的唯一路径就是重新取码:复制被禁用,二维码原地降级变暗,而不是缩小或被移除。
|
|
239
|
+
- **失败不静默。** 取码走的就是操作者本可以用 curl 打的那条仅 loopback 路由:`403` 渲染成「这个页面不是从本机打开的」且不给出可点的动作;请求没到达则渲染成它自己的不可达状态并给出重试;宿主回了别的状态就把那个状态码说出来。
|
|
203
240
|
|
|
204
|
-
-
|
|
205
|
-
- **同一个 token 以明文印在二维码旁边**,操作者可用肉眼核对,并有复制动作把它放进剪贴板。
|
|
206
|
-
- 旁边跑 **30 秒倒计时**,配一个 **「重新取码」** 动作:每按一次都签发新 token 并作废上一张;过期的配对码会明说过期,而不是继续一副还能扫的样子。
|
|
207
|
-
- **origin 警告直说。** 本页所在的 `127.0.0.1:<端口>` 只有本机能连,所以手机 App 里的连接地址必须填公网中继,形如 `wss://<id>.dsh-market.com`。
|
|
208
|
-
- **失败不静默。** 取码走的就是操作者本可以用 curl 打的那条仅 loopback 路由:`403` 渲染成「这个页面不是从本机打开的」,请求没到达则渲染成它自己的不可达状态。
|
|
241
|
+
开与关是同一段动效的两条腿:卡片保持挂载,把弹窗自己的进场淡入反向播完才卸载;reduced-motion 下这条生命周期换成一段短淡出,而不是干脆没有出场。几何在每种状态里都钉住——二维码的盒子、状态行、地址说明与复制标签都不改高度和宽度——所以倒计时、过期与复制确认都不会挪动它们旁边的元素。
|
|
209
242
|
|
|
210
243
|
面板对原生路径而言只是显示层。它从不消耗配对码(`pair.begin` 始终是手机那一侧的动作),从不碰名册,也不新增任何 wire 面——信封、方法名、主题名与事件一律不动。`dsh-remote-web-ui` 的配对服务、名册与浏览器凭据同样不参与其中,因此两条远程面各自保留自己的访问控制。
|
|
211
244
|
|
|
@@ -249,7 +282,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
|
249
282
|
- **配对即完全控制凭据。** 已配对设备在同一进程内触达宿主:会话、发言、审批。只配对你掌控的设备,吊销方式是移除名册那一行并重启宿主。
|
|
250
283
|
- **进程内调用以 owner 身份发言,且只在桥自己的门禁之后。** 自 DSH 0.2.1 起,宿主网关要求每次调用都指明代表谁发言,桥的回答是自己在挂载时铸造的一个进程内 owner peer(`{kind:'owner'}`),挂到每一次网关调用上。这个声明之所以安全,是因为它只在桥自己的配对检查之后才会被用到——未配对连接在任何网关调用存在之前即被拒——且协议帧的任何字段都不能设定 principal:客户端在载荷里自报的身份会被忽略。该 peer 不接收转发事件交互,因此它也永远收不到宿主转发事件。
|
|
251
284
|
- **token 端点仅 loopback 可达,且看两个条件。** 来源地址必须是 loopback,且 `Host` header 必须写本机。经隧道的请求由本机的隧道客户端终结,所以对一条全互联网可达的请求,来源地址也读作 `127.0.0.1`;而中继与普通隧道都会把 `Host` 改写成公网名。任一条件不成立即 403。token 只存内存、30 秒过期、被一次 `pair.begin` 用掉即焚,同一条链接还会写进宿主日志——把那一行日志当作活着的密钥。
|
|
252
|
-
- **配对面板渲染的是一份活密钥,也仅止于此。** 它用同源请求读同一条仅 loopback 门禁的路由,所以在 `curl` 够得到的地方它才够得到,别处都不行。它不能签发设备令牌、不能消耗配对码、不能列名册、不能吊销设备:`pair.begin` 始终是手机那一侧的动作,吊销始终是改名册加重启宿主。二维码里装的是裸 token
|
|
285
|
+
- **配对面板渲染的是一份活密钥,也仅止于此。** 它用同源请求读同一条仅 loopback 门禁的路由,所以在 `curl` 够得到的地方它才够得到,别处都不行。它不能签发设备令牌、不能消耗配对码、不能列名册、不能吊销设备:`pair.begin` 始终是手机那一侧的动作,吊销始终是改名册加重启宿主。二维码里装的是裸 token 或宿主自己那份 `{token,url}` 应答,因此本页的 `127.0.0.1` origin 永远不会被交给手机。
|
|
253
286
|
- **未配对连接只有三个方法的白名单。** `hello`、`pair.begin`、`pair.finish`;其余方法在分发前即回 `unpaired`,因此没有设备令牌就够不到会话面、审批面与名册面。
|
|
254
287
|
- **设备令牌只存哈希。** 名册保留公钥及其 SHA-256 指纹,从不存令牌本身,所以该文件不是凭据库。令牌丢失、轮换或被拒的处置就是重新配对——这是常规流程而非异常路径(重新签发一条 bootstrap 链接,或在桌面配对流程里重扫),且从不需要手工改名册。
|
|
255
288
|
- **令牌比对不泄漏长度。** 用的是定长比较而非提前返回的比较,因此错误令牌无法被逐字节逼近。
|
|
@@ -258,7 +291,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
|
258
291
|
|
|
259
292
|
## 已知限制
|
|
260
293
|
|
|
261
|
-
-
|
|
294
|
+
- **`session.titles` 只回答活跃会话。** 它读的是本宿主进程活跃持有的会话的标题,本宿主没有活跃持有的 id 在那里一律回 `""`;名册自己的行带的是该行投影出的标题,冷会话同样有,不必调这个方法来命名。
|
|
262
295
|
- **已服务过的标题最多可能旧 10 秒。** 一个已解析的标题在 10 秒内被直接复用,之后才再问标题服务,因此重命名或刚生成的标题最多要等这么久才出现。
|
|
263
296
|
- **读不到归档集时没有 `archived` 键。** 该标记来自宿主的 workspace registry;该服务未挂载时,每一行都省略此键,而不是回 `false`,并且一行都不丢——读不到的桥不会给出更短的名册。
|
|
264
297
|
- **已归档的父会话不授权任何东西。** 已归档父会话的活跃子会话仍会被列出、也仍点出那个父,但在父被恢复之前跟随该子会话会回 `session-not-followable`:授权一个会话的是名册,而已归档的那个已不在名册上。
|