@linxin666/dsh-remote-bridge 0.4.21 → 0.4.23
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 +12 -13
- package/README.zh.md +13 -14
- package/lib/client.js +195 -39
- package/lib/client.js.map +1 -1
- package/lib/index.js +2550 -715
- package/lib/types/client/PairEntry.d.ts +1 -1
- package/lib/types/client/PairPanel.d.ts +2 -2
- package/lib/types/client/RemoteConnectionExtension.d.ts +12 -0
- package/lib/types/client/UiPresentRow.d.ts +1 -1
- package/lib/types/client/index.d.ts +2 -1
- package/lib/types/core/usage.d.ts +42 -0
- package/lib/types/host/dsh-home.d.ts +13 -3
- package/package.json +24 -23
- package/src/client/PairEntry.tsx +1 -1
- package/src/client/PairPanel.tsx +3 -3
- package/src/client/RemoteConnectionExtension.tsx +161 -0
- package/src/client/UiPresentRow.tsx +1 -1
- package/src/client/index.ts +22 -2
- package/src/client/panel.module.css +51 -0
- package/src/core/connection.ts +29 -8
- package/src/core/usage.ts +173 -7
- package/src/core/wire.ts +1 -1
- package/src/host/dsh-home.ts +35 -12
- package/src/host/routes.ts +1 -4
- package/src/host/ui-tools.ts +1 -0
- package/src/index.ts +28 -10
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: 19c2dc381cec92bb6b506c2780659611a1ba0130
|
|
6
|
+
README.zh.md: 30a74f44ccab987b1c037ec1ef421503a2d92577
|
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.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.3--alpha.4-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>
|
|
@@ -31,7 +31,7 @@ The package publishes one protocol and, beside it, one small browser surface. Wh
|
|
|
31
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.
|
|
32
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.
|
|
33
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.
|
|
34
|
-
- **A pairing panel.** The same plugin row declares a `dsh.client` browser half: a QR code icon at the bottom of the sidebar (aria-label "Pair an iPhone") that opens a modal displaying a 30 s single-use pairing QR code and a "New code" action.
|
|
34
|
+
- **A pairing panel.** The same plugin row declares a `dsh.client` browser half: a pairing card inside official Settings → Remote Connection (`settings.remoteConnection.extensions`, `id: 'remote-bridge-ios'`, `order: 20`) plus a QR code icon at the bottom of the sidebar (`sidebar.footer.action`, aria-label "Pair an iPhone") that opens a modal displaying a 30 s single-use pairing QR code and a "New code" action.
|
|
35
35
|
- **No relay change.** The protocol rides whatever origin the instance already publishes, and the relay hop forwards it exactly as it forwards everything else.
|
|
36
36
|
|
|
37
37
|
## Transport
|
|
@@ -95,9 +95,9 @@ The session-admin channel interprets nothing either, and it is two capabilities
|
|
|
95
95
|
|
|
96
96
|
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-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.
|
|
97
97
|
|
|
98
|
-
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-
|
|
98
|
+
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`, `deepseek-official`, or `deepseek-account`) 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. For `deepseek-account`, the bridge reads wallet balance directly via the host's `ctx.deepseekAccount.getBalance`; for official API routes, it prefers `ctx.deepseekAuth.authorize(...)` on DSH 0.2.3-alpha.2+ and otherwise resolves the credential 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.
|
|
99
99
|
|
|
100
|
-
`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-
|
|
100
|
+
`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-four 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`, `ui.list.v1` and `session.attachment.path.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`.
|
|
101
101
|
|
|
102
102
|
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.
|
|
103
103
|
|
|
@@ -184,7 +184,7 @@ The device token rides the WebSocket upgrade as `Authorization: Bearer <deviceTo
|
|
|
184
184
|
|
|
185
185
|
### Bootstrap token
|
|
186
186
|
|
|
187
|
-
The pairing
|
|
187
|
+
The pairing surface is reachable both from the dedicated pairing card inside official Settings → Remote Connection (`settings.remoteConnection.extensions`) and from the QR code icon at the bottom of the sidebar (accessible label "Pair an iPhone"). The panel is strictly available on localhost: its token route `GET /remote-bridge/pair/token` is guarded by a two-condition loopback gate where both the socket address and the `Host` header must name this machine (remote or tunneled requests return 403).
|
|
188
188
|
|
|
189
189
|
The pairing code is single-use and valid for 30 seconds (`BOOTSTRAP_TOKEN_TTL_MS = 30_000`), consumed immediately upon the first `pair.begin`; clicking "New code" in the panel voids the previous code and mints a fresh one. There is no "Stop" button and no action to revoke all connected devices. The machine-local link is printed to the host log as `pair a device with <ws link>`, and that line is followed only by the kind of phone-facing address: `(phone: lan)` when the host calls the origin a LAN address or the literal itself answers only inside the network this page is already on, `(phone: public)` in every other case, and no suffix when the host found no address at all. The code itself renders in the pairing panel for scanning.
|
|
190
190
|
|
|
@@ -277,9 +277,11 @@ The plugin is configured through profile YAML (`cordis.patch.yml` or profile con
|
|
|
277
277
|
| `cfTunnelId` | string | `undefined` | Cloudflare named tunnel ID for ingress sync. |
|
|
278
278
|
| `profile` | string | `'desktop'` | Managed profile name (defaults to `$DSH_PROFILE` or `'desktop'`). |
|
|
279
279
|
|
|
280
|
+
Protocol-level values in this document — the 30 s one-time bootstrap token, the loopback-only token endpoint, the 10 MiB frame cap, and the fixed `/ios/v1` path — are protocol v1 constants rather than configurable settings. Pairing and revocation live in the device roster under `$DSH_HOME/remote-bridge/devices.json`.
|
|
281
|
+
|
|
280
282
|
## Web GUI pairing panel
|
|
281
283
|
|
|
282
|
-
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 same list slot the family's other foot triggers use) 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.
|
|
284
|
+
The browser half exists so that an operator who never opens a terminal still has a way to start pairing. It registers a pairing card into the official Settings → Remote Connection extension slot (`settings.remoteConnection.extensions`, `id: 'remote-bridge-ios'`, `order: 20`) and also follows the family's sidebar-foot convention: the trigger registers into the official `sidebar.footer.action` list slot (declared by ui-sidebar, the same list slot the family's other foot triggers use) 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.
|
|
283
285
|
|
|
284
286
|
The panel has one job — put the live one-time code in front of the operator, in one reading order:
|
|
285
287
|
|
|
@@ -289,7 +291,7 @@ The panel has one job — put the live one-time code in front of the operator, i
|
|
|
289
291
|
- **One address line.** A located origin is stated as a kind rather than printed: "The QR code carries the public address: the iPhone connects to this computer as soon as it scans". The one-time code burns 30 seconds after it appears, while a durable public hostname, once rendered as text, outlives every screenshot it appears in; the symbol already carries the address the phone needs, and Copy hands over the same `{token,url}` string either way. A LAN literal is not that fact, and the line names it — "The QR code points at the LAN address {origin}: the iPhone must be on the same network" — when the host calls the origin a LAN address or when the literal itself answers only inside the network this page is already on. With no located address the line says outright "No public address found: set the connection address in the app to your public relay first, then scan. {host} (this page) is reachable only from this machine."
|
|
290
292
|
- **One single-use note.** The code is single-use: pairing spends it, and a new code voids the previous one.
|
|
291
293
|
- **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.
|
|
292
|
-
- **One beta entry.** Provides "[The iOS app is in beta. Come talk to us on Discord](https://discord.gg/
|
|
294
|
+
- **One beta entry.** Provides "[The iOS app is in beta. Come talk to us on Discord](https://discord.gg/JdKTTdpUH)", clickable across the entire line.
|
|
293
295
|
- **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.
|
|
294
296
|
|
|
295
297
|
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.
|
|
@@ -335,15 +337,11 @@ dsh plugin --profile web add @linxin666/dsh-remote-bridge@latest
|
|
|
335
337
|
```sh
|
|
336
338
|
git clone https://github.com/zhu1090093659/dsh-web.git
|
|
337
339
|
cd dsh-web
|
|
338
|
-
pnpm install && pnpm
|
|
340
|
+
pnpm run deps:install && pnpm build
|
|
339
341
|
dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
340
342
|
```
|
|
341
343
|
|
|
342
|
-
This plugin is a family member: the aggregate bundle `@linxin666/dsh-web-all` installs it as its `remote-bridge` row together with the rest of the family, so adding the bundle is enough. Installing this package on its own stays supported, and remains the route for following this plugin's own version instead of the bundle's. Both routes load the same npm package, so a profile that carries both rows at once still registers the host half exactly once — `/ios/v1` and the token route belong to whichever source mounts first, and the family's single-instance guard replays a refused mount when that owner is torn down while the host keeps running. Restart `dsh web` after installing or updating — the host half registers its routes when the plugin row mounts, so the running host is what serves them — then reload the Web GUI page, which is when the browser half's sidebar-foot trigger
|
|
343
|
-
|
|
344
|
-
## Configuration
|
|
345
|
-
|
|
346
|
-
The bridge is mounted like any other host plugin row. It carries no user-facing options in v1: the values in this document — the 30 s one-time bootstrap token, the loopback-only token endpoint, the 10 MiB frame cap, the fixed `/ios/v1` path — are protocol constants rather than settings. Pairing and revocation are not configuration either; they are per-device facts in the roster. The one environment fact the bridge depends on is `$DSH_HOME`, since the roster lives under it.
|
|
344
|
+
This plugin is a family member: the aggregate bundle `@linxin666/dsh-web-all` installs it as its `remote-bridge` row together with the rest of the family, so adding the bundle is enough. Installing this package on its own stays supported, and remains the route for following this plugin's own version instead of the bundle's. Both routes load the same npm package, so a profile that carries both rows at once still registers the host half exactly once — `/ios/v1` and the token route belong to whichever source mounts first, and the family's single-instance guard replays a refused mount when that owner is torn down while the host keeps running. Restart `dsh web` after installing or updating — the host half registers its routes when the plugin row mounts, so the running host is what serves them — then reload the Web GUI page, which is when the browser half's pairing card and sidebar-foot trigger appear.
|
|
347
345
|
|
|
348
346
|
## Security model
|
|
349
347
|
|
|
@@ -358,6 +356,7 @@ The bridge is mounted like any other host plugin row. It carries no user-facing
|
|
|
358
356
|
- **The header is the safer carrier.** `Authorization: Bearer <deviceToken>` keeps the credential out of the URL; `?token=` exists for clients that cannot set handshake headers, and the relay, the edge and the access log all see a URL that authenticates as that device.
|
|
359
357
|
- **An image is served only from the session that named it.** `session.attachment.path` answers a file's bytes only when the string it was handed is, byte for byte, a path that session's OWN durable transcript named: an offload placeholder in a message body, or the image reference a durable tool result published. The whitelist is computed from that session's store and from nothing else — the same durable read `session.history.deep` performs, behind the same fence, so a delegated child whose parent this connection may not read is refused before any store call — and a client never contributes a path to it. Four decisions then stand between the whitelist and the bytes: byte equality, `realpath()` resolving the path to itself (a symlink pointing anywhere else is refused rather than followed), a regular file at that path, and one of the four image signatures in its first bytes; the extension is never consulted. Nothing outside the whitelist is read, and no directory is ever listed. A path that is not a host absolute path is not a whitelist entry at all, so `browser_screenshot`'s plugin-namespace name — which has no file behind it — can never be asked for.
|
|
360
358
|
- **Relay tier routing and grant credential boundaries.** The device roster (`devices.json`) schema upgrades from 3 to 4, adding an optional `relay: {grant, receivedAt}` to each device row. That `grant` is a 30-day HS256 credential signed by the account service, handed from the phone to the host over an **authenticated, paired connection**; the host merely passes it verbatim in the claim request body. The host therefore still does not know who the account is or what tier it holds: it only knows whether it holds a lease admitted by the relay. Tier evaluation occurs in a single loopback request between the self-hosted relay and the account service; the relay writes quotas into the lease row without recording any user identifier. The `hello.relay` announcement, capability identifier `relay.tier.v1`, and the `relay.grant` frame **exist only when a second meeting point is configured**; without configuration, the handshake is byte-for-byte identical to today, and that frame answers `unknown-method`. The two configuration keys are `relaySecondaryControlUrl` and `relaySecondaryPublicSuffix`, both unconfigured by default.
|
|
359
|
+
- **`ui_present` execution environment boundary.** `ui_present` declares `environment: 'independent'` (DSH 0.2.3-alpha.4+): it publishes a self-contained HTML card strictly to paired remote clients over the host hub and never reads or writes any host or remote execution filesystem.
|
|
361
360
|
|
|
362
361
|
## Known limitations
|
|
363
362
|
|
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.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.3--alpha.4-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>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- **订阅而非轮询。** `session.snapshot` 打开宿主的 follow 流并保持它,基线与其后的每一条增量都走同一条 socket。
|
|
31
31
|
- **审批直达客户端,重连的手机还能拿回仍悬着的那些。** 需要授权的工具以 `approval.request` 事件到达,客户端用 `approval.resolve` 作答;无人应答的请求按拒绝处理,而声明了 `approvals.v1` 的连接会在握手之后再次收到所有未结算的审批。
|
|
32
32
|
- **配对。** 一次性 bootstrap token 加 P-256 挑战应答产出可吊销的设备令牌;未配对连接只能触达三个方法。
|
|
33
|
-
- **一个配对面板。** 同一插件行声明 `dsh.client`
|
|
33
|
+
- **一个配对面板。** 同一插件行声明 `dsh.client` 浏览器半区:在官方「设置 → 远程连接」页注册专属配对卡(`settings.remoteConnection.extensions`,`id: 'remote-bridge-ios'`,`order: 20`),并在侧栏底部提供二维码图标(`sidebar.footer.action`,aria-label 为「配对 iPhone」),点开弹窗展示 30 秒有效的一次性配对二维码与「重新取码」动作。
|
|
34
34
|
- **中继无需改动。** 协议搭在实例本来就发布的那个 origin 上,中继这一跳照原样转发它,与其他所有请求无异。
|
|
35
35
|
|
|
36
36
|
## 传输
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
| `session.snapshot` | `{sessionId, sinceSeq?, maxBytes?}` | `{turns:[...], lastSeq:<uint>, hasMore?}`;增量另加 `mode:"since", reset:false`,替换客户端副本的基线另加 `mode:"full", reset:true` |
|
|
55
55
|
| `session.history` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
|
|
56
56
|
| `session.history.deep` | `{sessionId, before?, maxBytes?}` | `{turns:[...], nextBefore?:<uint>, hasMore:<bool>}` |
|
|
57
|
-
| `session.attachment.path` | `{sessionId, path}` | `{image:{path, mediaType?, bytes?, width?, height?}, data:"<base64>"}
|
|
57
|
+
| `session.attachment.path` | `{sessionId, path}` | `{image:{path, mediaType?, bytes?, width?, height?}, data:"<base64>"}`——该会话自身持久记录点过的图像引用及该路径对应的文件字节。路径必须为绝对路径且与会话记录逐字节一致;否则返回 `path-not-in-session`、`not-found`、`not-an-image` 或 `frame-too-large` |
|
|
58
58
|
| `session.prompt` | `{sessionId, text, requestId}` | `{accepted:true}` |
|
|
59
59
|
| `session.interrupt` | `{sessionId}` | `{ok:true}` |
|
|
60
60
|
| `presets.list` | `{}` | 宿主 `agentPresets/list` 的身体,逐字转发 |
|
|
@@ -94,9 +94,9 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
94
94
|
|
|
95
95
|
小队通道是唯一一条不替换任何东西的通道:它读并驱动 `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-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`。
|
|
96
96
|
|
|
97
|
-
用量通道读的是两件属于宿主、而不属于某台设备的事实,因此一个实例服务所有连接。`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-
|
|
97
|
+
用量通道读的是两件属于宿主、而不属于某台设备的事实,因此一个实例服务所有连接。`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` 或 `deepseek-account`),并且它配置的 `baseURL` 缺席或落在 `https://api.deepseek.com`:余额端点报的是某一个 origin 的账户,拿它去查一个只是复用了 `deepseek` 这个 id 的转售 profile,会把官方账户的钱印在那条路由名下。对于 `deepseek-account`,桥直接经宿主 `ctx.deepseekAccount.getBalance` 读取钱包余额;对于官方 API 路由,在 DSH 0.2.3-alpha.2+ 上优先调用 `ctx.deepseekAuth.authorize(...)`,否则按宿主用量插件的同一套顺序解析凭据——先 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` 恒为模型声明,后者也永不与前者同时出现。
|
|
98
98
|
|
|
99
|
-
`hello` 还携带客户端的能力声明,而能力是公告而非协商:无论 `cap` 里是什么,握手都回同一个帧,未知名字被忽略;单帧上限在两个方向上都是同一个常量——约束接收帧的 10 MiB
|
|
99
|
+
`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` 与 `session.attachment.path.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`。
|
|
100
100
|
|
|
101
101
|
第二个能力 `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 应答就是今天的应答加上这两个字段。
|
|
102
102
|
|
|
@@ -181,7 +181,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
181
181
|
|
|
182
182
|
### Bootstrap token
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
配对入口同时位于官方「设置 → 远程连接」页面的专属配对卡(`settings.remoteConnection.extensions`)以及侧栏底部的二维码图标(按钮 aria-label 为「配对 iPhone」)。该面板只在本机可用:令牌路由 `GET /remote-bridge/pair/token` 受回环门控保护,来源地址与 `Host` header 必须均为本机(非本机或经隧道访问一律返回 403)。
|
|
185
185
|
|
|
186
186
|
配对码一次性有效且具备 30 秒时效(`BOOTSTRAP_TOKEN_TTL_MS = 30_000`),被首次 `pair.begin` 用掉即失效;在面板中点击「重新取码」会使上一张配对码作废并生成新码。面板中没有「停止」按钮,也没有「吊销所有已连接设备」的操作。本机链接会以 `pair a device with <ws 链接>` 打印到宿主日志,而这一行后面只跟手机侧地址的种类:宿主把这个 origin 叫作局域网地址、或者该字面量本身就只在当前网络内可达时是 `(phone: lan)`,其余情形是 `(phone: public)`,一个地址都没有时不带后缀。配对码本身则渲染在配对面板中供扫码。
|
|
187
187
|
|
|
@@ -274,9 +274,11 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
274
274
|
| `cfTunnelId` | string | `undefined` | 用于 ingress-sync 的 Cloudflare 命名隧道 ID。 |
|
|
275
275
|
| `profile` | string | `'desktop'` | 受管 profile 名称(缺省读取 `$DSH_PROFILE` 或 `'desktop'`)。 |
|
|
276
276
|
|
|
277
|
+
本文中的协议级取值——30 秒一次性 bootstrap token、仅 loopback 的 token 端点、10 MiB 单帧上限、固定的 `/ios/v1` 路径——都是协议 v1 常量而非可配置项。配对与吊销保存在 `$DSH_HOME/remote-bridge/devices.json` 设备名册中。
|
|
278
|
+
|
|
277
279
|
## Web GUI 配对面板
|
|
278
280
|
|
|
279
|
-
|
|
281
|
+
浏览器半区存在的理由,是让从不开终端的操作者也有一条发起配对的路径。它向官方「设置 → 远程连接」扩展槽位注册专属配对卡(`settings.remoteConnection.extensions`,`id: 'remote-bridge-ios'`,`order: 20`),同时沿用家族在侧栏底部的惯例:触发器注册进官方 `sidebar.footer.action` 列表槽位(由 ui-sidebar 声明,与家族其它脚部触发器共用该列表槽位),点开后是官方 `Modal`,这张无头卡片由本包填充。它渲染的每个控件都是库里已有的 primitive——弹窗、三个动作与它们的字形——因此遮罩、卡片、焦点圈定、Esc、焦点归还,以及每个 hover/focus/disabled 状态都是官方壳自己的行为,而不是本包的一份复制品。它由同一插件行承载:产物是 `exports["./client"]`,`dsh.client` 声明必须先就位的 client 模块。
|
|
280
282
|
|
|
281
283
|
面板只做一件事——把活着的那个一次性配对码摆到操作者面前,且只有这一个阅读顺序:
|
|
282
284
|
|
|
@@ -286,7 +288,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
286
288
|
- **一条地址说明。** 定位到的公网地址只交代种类,不写成文字:「二维码已包含公网地址,扫码后 iPhone 自动连上这台电脑」。一次性配对码 30 秒即焚,而持久公网主机名一旦以文字渲染,会比它出现的每张截图活得久;二维码本身已带手机需要的地址,「复制配对码」交出的仍是同一个 `{token,url}` 串。局域网字面量不属于这一类事实:当宿主把这个 origin 叫作局域网地址,或者该字面量本身就只在当前网络内可达时,这一行都点名它——「二维码指向局域网地址 {origin},iPhone 需与本机在同一网络」。定位不到地址时,它直说「没有找到公网地址:先在 App 里把连接地址填成你的公网中继,再扫码。本页的 {host} 只有本机能连。」。
|
|
287
289
|
- **一条一次性说明。** 配对码一次性有效:iPhone 一开始配对就作废,重新取码也会作废上一张。
|
|
288
290
|
- **一行动作。** 复制把二维码里那个字符串原样放进剪贴板,「重新取码」签发新 token 并作废上一张;两者都是同一个库控件、同一个尺寸,交互态不会各走一套。码一旦过期,回到可扫状态的唯一路径就是重新取码:复制被禁用,二维码原地降级变暗,而不是缩小或被移除。
|
|
289
|
-
- **一行内测入口。** 提供「[iOS App 还在内测,欢迎来 Discord 交流](https://discord.gg/
|
|
291
|
+
- **一行内测入口。** 提供「[iOS App 还在内测,欢迎来 Discord 交流](https://discord.gg/JdKTTdpUH)」,整行可点击打开。
|
|
290
292
|
- **失败不静默。** 取码走的就是操作者本可以用 curl 打的那条仅 loopback 路由:`403` 渲染成「这个页面不是从本机打开的」且不给出可点的动作;请求没到达则渲染成它自己的不可达状态并给出重试;宿主回了别的状态就把那个状态码说出来。
|
|
291
293
|
|
|
292
294
|
开与关是同一段动效的两条腿:卡片保持挂载,把弹窗自己的进场淡入反向播完才卸载;reduced-motion 下这条生命周期换成一段短淡出,而不是干脆没有出场。几何在每种状态里都钉住——二维码的盒子、状态行、地址说明与复制标签都不改高度和宽度——所以倒计时、过期与复制确认都不会挪动它们旁边的元素。
|
|
@@ -332,15 +334,11 @@ dsh plugin --profile web add @linxin666/dsh-remote-bridge@latest
|
|
|
332
334
|
```sh
|
|
333
335
|
git clone https://github.com/zhu1090093659/dsh-web.git
|
|
334
336
|
cd dsh-web
|
|
335
|
-
pnpm install && pnpm
|
|
337
|
+
pnpm run deps:install && pnpm build
|
|
336
338
|
dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
337
339
|
```
|
|
338
340
|
|
|
339
|
-
本插件是家族成员:聚合包 `@linxin666/dsh-web-all` 会把它作为 `remote-bridge` 行连同家族其余内容一起装上,因此装上聚合包就够了。单装本包仍然受支持,且仍是只跟随本插件自身版本、不跟聚合包版本的做法。两条路加载的是同一个 npm 包,所以 profile 里同时存在两行时宿主半区仍只注册一份——`/ios/v1` 与 token 路由归先挂载的那个来源,家族的单实例守卫会在该来源在宿主运行期间被拆除时重放那次被拒的挂载。安装或更新后需重启 `dsh web`——宿主半区在插件行挂载时注册路由,提供服务的就是那个运行中的宿主——随后刷新 Web GUI
|
|
340
|
-
|
|
341
|
-
## 配置
|
|
342
|
-
|
|
343
|
-
桥接像其他宿主插件行一样挂载。v1 不带任何面向用户的选项:本文中的取值——30 秒一次性 bootstrap token、仅 loopback 的 token 端点、10 MiB 单帧上限、固定的 `/ios/v1` 路径——都是协议常量而非设置项。配对与吊销也不是配置,而是名册里的逐设备事实。桥接唯一依赖的环境事实是 `$DSH_HOME`,因为名册就在它下面。
|
|
341
|
+
本插件是家族成员:聚合包 `@linxin666/dsh-web-all` 会把它作为 `remote-bridge` 行连同家族其余内容一起装上,因此装上聚合包就够了。单装本包仍然受支持,且仍是只跟随本插件自身版本、不跟聚合包版本的做法。两条路加载的是同一个 npm 包,所以 profile 里同时存在两行时宿主半区仍只注册一份——`/ios/v1` 与 token 路由归先挂载的那个来源,家族的单实例守卫会在该来源在宿主运行期间被拆除时重放那次被拒的挂载。安装或更新后需重启 `dsh web`——宿主半区在插件行挂载时注册路由,提供服务的就是那个运行中的宿主——随后刷新 Web GUI 页面,浏览器半区的配对卡与侧栏底部触发器才会出现。
|
|
344
342
|
|
|
345
343
|
## 安全模型
|
|
346
344
|
|
|
@@ -355,6 +353,7 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-remote-bridge
|
|
|
355
353
|
- **header 是更安全的载体。** `Authorization: Bearer <deviceToken>` 让凭据不进入 URL;`?token=` 是给无法设置握手 header 的客户端的,此时中继、边缘与访问日志都会看到一条以该设备身份鉴权的 URL。
|
|
356
354
|
- **一张图只能由点过它的那条会话取。** `session.attachment.path` 只在拿到的字符串逐字节等于**这次会话自己的持久 transcript** 点过的某个路径时才回字节:来源是消息体里的 offload 占位符,或持久工具结果发布的图像引用。白名单每次请求都从该会话自己的存储现算,别的什么都不读——走的就是 `session.history.deep` 那条持久读面、同一道栅栏,所以父会话不是本连接可读的委派子会话在任何存储调用之前就被拒——而客户端一个路径都贡献不了。白名单与字节之间还立着四道判定:逐字节相等、`realpath()` 必须解析回它自己(指向别处的软链接被拒而不是被跟随)、那里必须是常规文件、头几个字节必须是四种图像签名之一;扩展名一律不看。白名单之外的文件一个都不读,也不会去列目录。不是宿主绝对路径的条目根本不进白名单,所以 `browser_screenshot` 那个磁盘上没有对应文件的插件命名空间名永远发不出去。
|
|
357
355
|
- **中继档位分流与授权凭据边界。** 名册(`devices.json`)schema 3 → 4,每台设备行新增可选的 `relay: {grant, receivedAt}`。那枚 `grant` 是账号服务签发的 30 天 HS256 凭据,经**已配对的加密连接**由手机交给宿主,宿主只把它原样放进 claim 请求体。宿主因此仍然不知道账号是谁、也不知道档位:它只知道「我有没有一份被中继承认的租约」。档位判定发生在自建中继与账号服务之间的一次回环请求里,中继只把额度写进租约行,不落任何用户标识。`hello.relay`、能力名 `relay.tier.v1`、`relay.grant` 这一帧**只在配置了第二个会合点时才存在**;不配置时握手逐字节等于今天,那一帧回 `unknown-method`。两个配置项名:`relaySecondaryControlUrl` 与 `relaySecondaryPublicSuffix`,缺省都不配置。
|
|
356
|
+
- **`ui_present` 执行环境边界。** `ui_present` 声明 `environment: 'independent'`(DSH 0.2.3-alpha.4+):它仅通过宿主 hub 向已配对的远程客户端推送自包含 HTML 交互卡片,不读写任何宿主或远程执行环境文件系统。
|
|
358
357
|
|
|
359
358
|
## 已知限制
|
|
360
359
|
|