@linxin666/dsh-remote-bridge 0.4.11 → 0.4.13
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 +47 -10
- package/README.zh.md +47 -10
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/index.js +18238 -416
- package/lib/types/core/connection.d.ts +9 -0
- package/lib/types/core/devices.d.ts +27 -6
- package/lib/types/core/liveactivity.d.ts +7 -0
- package/lib/types/core/model-efforts.d.ts +83 -0
- package/lib/types/core/protocol.d.ts +3 -1
- package/lib/types/core/push.d.ts +51 -2
- package/lib/types/core/turn-end-quiet.d.ts +104 -40
- package/lib/types/host/firewall.d.ts +74 -0
- package/lib/types/host/host-bind-capability.d.ts +90 -0
- package/lib/types/host/ingress-gate.d.ts +59 -0
- package/lib/types/host/ingress-sync.d.ts +429 -0
- package/lib/types/host/lan-bind-plan.d.ts +96 -0
- package/lib/types/host/lan-bind.d.ts +106 -0
- package/lib/types/host/lan-forward.d.ts +112 -0
- package/lib/types/host/lan.d.ts +61 -0
- package/lib/types/host/pair-origin.d.ts +34 -19
- package/lib/types/host/relay-bridge-connector.d.ts +215 -0
- package/lib/types/host/relay-connector.d.ts +152 -0
- package/lib/types/host/relay-control.d.ts +124 -0
- package/lib/types/host/relay-registry.d.ts +114 -0
- package/lib/types/host/relay.d.ts +170 -0
- package/lib/types/host/routes.d.ts +24 -1
- package/lib/types/host/tunnel-orphan.d.ts +145 -0
- package/lib/types/host/tunnel-plan.d.ts +41 -0
- package/lib/types/host/tunnel.d.ts +289 -0
- package/lib/types/index.d.ts +440 -11
- package/package.json +4 -2
- package/src/client/panel.module.css +16 -1
- package/src/core/connection.ts +244 -13
- package/src/core/devices.ts +31 -6
- package/src/core/hub.ts +17 -5
- package/src/core/liveactivity.ts +16 -2
- package/src/core/model-efforts.ts +223 -0
- package/src/core/protocol.ts +4 -1
- package/src/core/push.ts +70 -4
- package/src/core/turn-end-quiet.ts +281 -98
- package/src/host/firewall.ts +230 -0
- package/src/host/host-bind-capability.ts +249 -0
- package/src/host/ingress-gate.ts +203 -0
- package/src/host/ingress-sync.ts +1074 -0
- package/src/host/lan-bind-plan.ts +134 -0
- package/src/host/lan-bind.ts +250 -0
- package/src/host/lan-forward.ts +321 -0
- package/src/host/lan.ts +142 -0
- package/src/host/pair-origin.ts +44 -38
- package/src/host/relay-bridge-connector.ts +783 -0
- package/src/host/relay-connector.ts +317 -0
- package/src/host/relay-control.ts +224 -0
- package/src/host/relay-registry.ts +263 -0
- package/src/host/relay.ts +294 -0
- package/src/host/routes.ts +47 -3
- package/src/host/tunnel-orphan.ts +325 -0
- package/src/host/tunnel-plan.ts +58 -0
- package/src/host/tunnel.ts +688 -0
- package/src/index.ts +1303 -39
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: 8a98b374253296b7077aa07c3a2fb46ba63ad317
|
|
6
|
+
README.zh.md: 92d8fe0c6d65165b675eac217e8f3b6ecc537908
|
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ English | [中文](README.zh.md)
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The sole remote access path in this repository: native phone apps connecting to the host via protocol v1. This host-side adaptor publishes DeepSeek Harness (DSH) itself as protocol v1 over a single WebSocket surface at `/ios/v1` that native phone apps can drive directly without a browser. Browser-based remote control has retired, and its WAN/LAN ingress capabilities have migrated into this package.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
The adaptor consumes the harness in-process — the Typert gateway for session work and the approval waterfall for permission requests — and mints its own one-time bootstrap token on a loopback-only route, backed by an independent public relay, Cloudflare tunnels, and LAN ingress stack.
|
|
16
16
|
|
|
17
17
|
## What it does
|
|
18
18
|
|
|
@@ -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
|
|
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 a phone (protocol v1)") 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
|
|
@@ -92,7 +92,7 @@ The command channel interprets nothing either. `session.commands` reads both hos
|
|
|
92
92
|
|
|
93
93
|
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.
|
|
94
94
|
|
|
95
|
-
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-
|
|
95
|
+
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.
|
|
96
96
|
|
|
97
97
|
The usage channel reads two facts that belong to the host rather than to one device, so one instance serves every connection. `usage.session` names one session and answers `{contextWindow?, composition?}`: the window is the harness's own `RequestContext.contextWindow` from the latest `request/context` event this process saw broadcast, and the composition is this bridge's estimate of what the next request is made of, split three ways — `tools` from the raw tools schema of the latest `request/header`, `system` from the latest `system/message` text, and `messages` from the text of every `user/message`, `assistant/message` and `tool/result` seen since — each component the UTF-8 byte count divided by four and floored, always carrying `estimated: true`, because a phone must never read an estimate as the host's own accounting. A key the host never broadcast is absent rather than zero, and a session that exists while neither reading does answers `{}`: existence has three witnesses — the host's own session roster (the same `session/list` the roster method serves, so a session this bridge never observed and that is not live still counts), the live session store, and the events this process folded — and a session id none of the three names is refused `unknown-session`. The roster is read only when the other two answer nothing, and its answer is reused for five seconds so a burst of opens costs one read; a bridge that cannot read a roster at all falls back to the live store and the fold alone. The fold starts when this row mounts and never reads a session log: an event broadcast before it mounted is not a reading, so a session that ran entirely before it answers `{}` rather than a composition of zeros. `usage.balance` names one provider route and answers either `{provider, currency, total, toppedUp, granted, updatedAt}` — the numbers in yuan, taken from `balance_infos[0]` — or `{provider, unsupported, reason?}` with `no-credential`, `not-deepseek-route` or `probe-failed`. The route must be an official DeepSeek id (`deepseek` or `deepseek-official`) AND its configured `baseURL` absent or on `https://api.deepseek.com`: the balance endpoint reports one origin's account, so probing it for a reseller profile that merely reused the `deepseek` id would print the official account's money under that route's name. The credential is resolved the way the harness's own usage plugin resolves it — the pi-ai record `llm-pi-ai/<provider>`, then the profile's `apiKeyEnv`, then the DeepSeek adapter's own reference (default `DEEPSEEK_API_KEY`) — and an OAuth grant is not a credential here, because the official endpoint accepts an API key only. One reading is cached for 60 seconds per provider and credential, concurrent calls merge into one upstream request, and 401, a timeout or an unrecognized body all answer `probe-failed` instead of a previous reading presented as current. A client that never declared `usage.v1` is answered `unknown-method` for both methods, with no event folded and no upstream request made on its behalf. `usage.stats` reads the ledger another plugin keeps, so it is its own capability behind `usage.stats.v1` and its own read path: one `GET /api/dsh-usage/overview` and, only when the requested window reaches deeper than the 30 days that document already carries, one `GET /api/dsh-usage/day?date=YYYY-MM-DD` per day that ledger actually recorded. Days the ledger holds nothing for cross as real zeros — the host answers those dates as zeroed days itself — while a route that is absent (`no-usage-plugin`), unreachable, shaped differently or too slow answers `probe-failed` with a short reason and never a previous reading. One `days` window is cached for 30 seconds on this side and concurrent calls merge into it, so two phones asking at once cost the host one read. `usage.session` gained one optional key beside the window: when the host has broadcast no `request/context` window, the answer may carry `modelContextWindow`, taken from `GET {baseURL}/models` of the session's current route — the first available of `context_length`, `context_window` and `max_input_tokens` for that exact model id, cached for ten minutes per route, and sent with that route's own credential. The two numbers are never mixed: `contextWindow` is always the host's measurement, `modelContextWindow` is always the model's declaration, and the second never appears beside the first.
|
|
98
98
|
|
|
@@ -173,7 +173,7 @@ A registered method is dispatched after both protocol gates: a name no plugin re
|
|
|
173
173
|
| `malformed` | the frame is not one JSON object with a recognizable shape |
|
|
174
174
|
| `direction-violation` | the client sent a `res` or `ev` frame, which only the host sends |
|
|
175
175
|
|
|
176
|
-
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-
|
|
176
|
+
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-unavailable` 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.
|
|
177
177
|
|
|
178
178
|
## Authentication
|
|
179
179
|
|
|
@@ -181,14 +181,16 @@ The device token rides the WebSocket upgrade as `Authorization: Bearer <deviceTo
|
|
|
181
181
|
|
|
182
182
|
### Bootstrap token
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
The pairing entry is a QR code icon at the bottom of the sidebar, with the accessible label "Pair a phone (protocol v1)". Clicking it opens the pairing panel. 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).
|
|
185
|
+
|
|
186
|
+
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 link is printed to the host log, while the code itself renders in the pairing panel for scanning.
|
|
185
187
|
|
|
186
188
|
```sh
|
|
187
189
|
curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
188
190
|
# {"token":"...","expiresAt":1760000030000,"url":"ws://127.0.0.1:3080/ios/v1?token=..."}
|
|
189
191
|
```
|
|
190
192
|
|
|
191
|
-
When this machine can
|
|
193
|
+
When this machine can determine a public or LAN origin — from live relay lease/tunnel state, `DSH_REMOTE_PUBLIC_BASE_URL`, or a listening LAN forwarder — the same answer carries the address half:
|
|
192
194
|
|
|
193
195
|
```json
|
|
194
196
|
{
|
|
@@ -201,7 +203,7 @@ When this machine can name its own public origin — `DSH_REMOTE_PUBLIC_BASE_URL
|
|
|
201
203
|
}
|
|
202
204
|
```
|
|
203
205
|
|
|
204
|
-
|
|
206
|
+
The QR code encodes a `{token, url}` document where `url` takes the form `wss://<origin>/ios/v1?token=...` (derived via `pairingDialUrlOf`, converting https to wss and http to ws). Scanning with the mobile phone app acquires both the address and token at once without manual entry. With no discoverable origin those fields are absent rather than guessed, the panel falls back to a bare-token code, and the phone keeps whatever origin it already has.
|
|
205
207
|
|
|
206
208
|
### Device token
|
|
207
209
|
|
|
@@ -235,9 +237,44 @@ The relay that publishes a private instance on the public internet is a full rev
|
|
|
235
237
|
|
|
236
238
|
Two consequences follow from that hop. It sees the request URL, so a `?token=` connection hands the device token to the relay, the Cloudflare edge and the origin access log — prefer the header. And `GET /remote-bridge/pair/token` is forwarded like any other path, but its loopback gate rejects the forwarded request, so pairing can only be started from the machine itself.
|
|
237
239
|
|
|
240
|
+
## Ingress stack and security model
|
|
241
|
+
|
|
242
|
+
`@linxin666/dsh-remote-bridge` owns the complete public and local network ingress stack for remote access:
|
|
243
|
+
- **Relay identity and leases**: `relay-registry` persists the relay ID and secret under `$DSH_HOME/remote-web-ui-registry/<profile>.json`; changing relay config remounts the plugin row. When mounting with `relay=false` and an on-disk identity already exists, it unregisters the previous registration row and releases its lease once via `pair.release()` (best-effort, logging any errors; unmounting neither releases nor unregisters, preserving bookmarked origins for server-side GC; mounting with `relay=false` never mints a new identity and has zero side effects if no identity file exists).
|
|
244
|
+
- **Relay connectors**: `relay-connector` manages quick and named tunnel connectors side by side, and `relay-bridge-connector` connects to the Cloudflare Durable Object meeting point over WSS, recording connection state in `$DSH_HOME/remote-web-ui-relay-bridge.json` (state file writing is verified behaviorally, defaulting to `$DSH_HOME` when unspecified, not checked via source text assertions).
|
|
245
|
+
- **Tunnel lifecycle**: `tunnel`, `tunnel-plan`, and `tunnel-orphan` manage platform `cloudflared` child processes with exponential backoff and reap orphaned processes left behind by crashes.
|
|
246
|
+
- **Ingress sync**: `ingress-sync` converges Cloudflare named tunnel ingress rules to the local gate port when the host listens on a different port.
|
|
247
|
+
- **LAN forwarder and firewall**: `lan`, `lan-bind`, `lan-bind-plan`, `lan-forward`, `host-bind-capability`, and `firewall` manage the LAN-edge forwarder and OS firewall rules (Windows Defender and Linux firewalld/ufw/iptables) while keeping the host webserver bound strictly to loopback.
|
|
248
|
+
|
|
249
|
+
The security model enforces strict whitelisting across all external ingress paths:
|
|
250
|
+
- **Internal ingress gate (`src/host/ingress-gate.ts`)**: binds exclusively to `127.0.0.1` and forwards only WebSocket upgrades to `/ios/v1` to the host's own protocol port, rewriting the `Host` header to the loopback authority. Every other plain HTTP request and non-whitelisted upgrade is answered immediately with `404 {"error":"not-found"}` and closed without opening any upstream connection.
|
|
251
|
+
- **Tunnel target is the ingress gate, not the webServer**: cloudflared quick and named tunnels target the dynamic loopback port bound by `ingress-gate`, never the harness `webServer` port. A request routed through the tunnel cannot reach webServer routes, internal APIs, or other plugins.
|
|
252
|
+
- **Relay registration and public exposure**: the relay registration row only writes the quick tunnel URL, which points to the ingress gate, so the public internet still only sees /ios/v1. When the plan is quick and the tunnel is running, the gate URL is announced to the relay Worker (proxying `<id>.dsh-market.com` to this machine); plugin disposal clears local references without withdrawing the row. QR public address selection is decided by `livePublicOriginOf`: bridge or named leases prioritize the stable subdomain; quick leases fall back to the tunnel running URL while registration is unconfirmed; no lease uses the tunnel URL; none returns no address. Fallbacks then check `DSH_REMOTE_PUBLIC_BASE_URL`, and the LAN fallback provides an address only when the LAN forwarder is actually listening using its snapshot's bound address and port (never guessing the first IP in the address list, returning no address when stopped; the disk registry row fallback has been completely removed, eliminating the last data dependency on legacy data files).
|
|
253
|
+
- **LAN forwarder target is the ingress gate**: the LAN forwarder listens on the machine's LAN IPv4 address and re-issues traffic exclusively to the `ingress-gate` port, so local network reachability is also constrained strictly to `/ios/v1`.
|
|
254
|
+
- **Relay bridge connector whitelist**: the Durable Object multiplexer in `relay-bridge-connector.ts` applies the same whitelist. Non-`/ios/v1` HTTP streams receive `404 {"error":"not-found"}`, and non-whitelisted WebSocket upgrades return `ws-fail 404 {"error":"not-found"}`, establishing no upstream connection.
|
|
255
|
+
- **Historical spelling retention and coexistence caveat**: the registry directory `$DSH_HOME/remote-web-ui-registry/` and state file `remote-web-ui-relay-bridge.json` intentionally retain their historical names so existing profiles maintain identity continuity and previously paired devices keep their credentials across upgrades. **Known risk and coexistence caveat**: never enable relay concurrently on both this plugin and the deprecated `dsh-remote-web-ui` in the same profile — both share the same identity file per profile; mounting the bridge with `relay=false` withdraws the registration row and releases the lease for that shared identity, breaking the legacy plugin's active relay, while running both with relay enabled causes bridge connectors to compete over the same Durable Object connection (or quick tunnel registrations to overwrite each other). This cleanup behavior is intentional.
|
|
256
|
+
- **No browser pairing surface**: this package does not include browser pairing cookie gates, `/api/pair` endpoints, `/remote` proxy routes, or mobile web touch CSS adaptation layers.
|
|
257
|
+
|
|
258
|
+
## Configuration
|
|
259
|
+
|
|
260
|
+
The plugin is configured through profile YAML (`cordis.patch.yml` or profile configuration files); it provides no settings UI. Unconfigured fields fall back to their built-in defaults:
|
|
261
|
+
|
|
262
|
+
| Key | Type | Default | Description |
|
|
263
|
+
| --- | --- | --- | --- |
|
|
264
|
+
| `relay` | boolean | `true` | Whether to claim relay leases. Enabled by default; public availability works out of the box because leases are claimed even when no tunnel is running. |
|
|
265
|
+
| `autoTunnel` | boolean | `false` | Whether to start a Cloudflare quick tunnel targeting the ingress gate. |
|
|
266
|
+
| `lanBind` | boolean | `undefined` (off) | Whether to start the LAN-edge forwarder listening on the machine's local IPv4 address. |
|
|
267
|
+
| `tunnelToken` | string | `undefined` | Cloudflare named tunnel token for running named tunnels. |
|
|
268
|
+
| `publicBaseUrl` | string | `undefined` | Fixed public HTTPS base URL for named tunnels. |
|
|
269
|
+
| `ingressSync` | boolean | `false` | Whether to sync named tunnel ingress service ports with Cloudflare. |
|
|
270
|
+
| `cfApiToken` | string | `undefined` | Account-level Cloudflare API token for ingress sync. |
|
|
271
|
+
| `cfAccountId` | string | `undefined` | Cloudflare account ID for ingress sync. |
|
|
272
|
+
| `cfTunnelId` | string | `undefined` | Cloudflare named tunnel ID for ingress sync. |
|
|
273
|
+
| `profile` | string | `'desktop'` | Managed profile name (defaults to `$DSH_PROFILE` or `'desktop'`). |
|
|
274
|
+
|
|
238
275
|
## Web GUI pairing panel
|
|
239
276
|
|
|
240
|
-
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
|
|
277
|
+
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, sharing this list slot with `dsh-update`'s updater) 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.
|
|
241
278
|
|
|
242
279
|
The panel has one job — put the live one-time code in front of the operator, in one reading order:
|
|
243
280
|
|
|
@@ -250,7 +287,7 @@ The panel has one job — put the live one-time code in front of the operator, i
|
|
|
250
287
|
|
|
251
288
|
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.
|
|
252
289
|
|
|
253
|
-
The panel is display-only for the native path. It never spends the token (`pair.begin` stays the phone's call), it never touches the roster, and it adds no wire surface — the envelope, the method names, the topic names and the events are unchanged.
|
|
290
|
+
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. The package provides no browser pairing surface or cookie gate.
|
|
254
291
|
|
|
255
292
|
## Interactive cards in the transcript
|
|
256
293
|
|
package/README.zh.md
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
本仓库唯一的远程访问路径:手机 App 通过协议 v1 连上宿主。本包把 DeepSeek Harness(DSH)本体发布成协议 v1,在 `/ios/v1` 提供单个 WebSocket 面,原生手机 App 无需浏览器即可直连并驱动宿主。浏览器远程控制已退役,公网与局域网接入栈能力已迁入本包。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
本包在同一进程内消费宿主——会话工作走 Typert gateway,权限请求走审批瀑布——并在仅回环路由上自行签发一次性 bootstrap token,拥有独立的公网中继、Cloudflare 隧道与局域网接入栈。
|
|
16
16
|
|
|
17
17
|
## 功能
|
|
18
18
|
|
|
@@ -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` 浏览器半区:侧栏底部一个二维码图标(aria-label 为「配对手机(协议 v1)」),点开弹窗展示 30 秒有效的一次性配对二维码与「重新取码」动作。
|
|
34
34
|
- **中继无需改动。** 协议搭在实例本来就发布的那个 origin 上,中继这一跳照原样转发它,与其他所有请求无异。
|
|
35
35
|
|
|
36
36
|
## 传输
|
|
@@ -91,7 +91,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
91
91
|
|
|
92
92
|
会话管理通道同样什么都不解释,而它分成两个能力,是因为读与写是两份不同的提供。`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`,既不为它读一次注册表,也不为它写一次。
|
|
93
93
|
|
|
94
|
-
小队通道是唯一一条不替换任何东西的通道:它读并驱动 `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-
|
|
94
|
+
小队通道是唯一一条不替换任何东西的通道:它读并驱动 `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`。
|
|
95
95
|
|
|
96
96
|
用量通道读的是两件属于宿主、而不属于某台设备的事实,因此一个实例服务所有连接。`usage.session` 点名一条会话并回 `{contextWindow?, composition?}`:窗口是本进程看到宿主广播的最近一次 `request/context` 里的 `RequestContext.contextWindow`,组成则是本桥对「下一次请求由什么构成」的估算,分三格——`tools` 取最近一次 `request/header` 的 tools schema 原文,`system` 取最近一条 `system/message` 的文本,`messages` 取此后观察到的每一条 `user/message`、`assistant/message` 与 `tool/result` 的文本——每一格都是 UTF-8 字节数除以四再向下取整,并恒带 `estimated: true`,因为手机绝不能把估算当成宿主的读数。宿主没广播过的键是缺席而不是 0;会话存在而两项读数都取不到时回 `{}`——存在有三处证词:宿主自己的会话名册(与名册方法服务的是同一个 `session/list`,因此本桥从未观察过、当前也不 live 的会话同样算存在)、活会话存储,以及本进程折过的事件——三处都不认这条 id 时才回 `unknown-session`。名册只在另外两处都答不上时才读,且它的答案在五秒内复用,所以一次开屏连问几条只花一次读取;读不到名册的桥退回活会话存储与折叠两条证词。折叠从这一行挂载时开始,且从不读会话日志:挂载之前广播的事件不算读数,因此整段都跑在挂载之前的会话回 `{}`,而不是回一份全是 0 的组成。`usage.balance` 点名一条 provider 路由,回 `{provider, currency, total, toppedUp, granted, updatedAt}`(元口径的金额,取自 `balance_infos[0]`),或回 `{provider, unsupported, reason?}`,取值 `no-credential`、`not-deepseek-route`、`probe-failed`。这条路由必须是官方 DeepSeek 的 id(`deepseek` 或 `deepseek-official`),并且它配置的 `baseURL` 缺席或落在 `https://api.deepseek.com`:余额端点报的是某一个 origin 的账户,拿它去查一个只是复用了 `deepseek` 这个 id 的转售 profile,会把官方账户的钱印在那条路由名下。凭据按宿主自己用量插件的同一套顺序解析——先 pi-ai 记录 `llm-pi-ai/<provider>`,再 profile 的 `apiKeyEnv`,最后 DeepSeek 适配器自己的引用(默认 `DEEPSEEK_API_KEY`)——OAuth grant 在这里不算凭据,因为官方端点只认 API key。同一条读数按 provider + 凭据缓存 60 秒,并发调用合并成一次上游请求;401、超时与认不出的应答体都回 `probe-failed`,绝不把上一轮的读数当成当前值发出去。从未声明 `usage.v1` 的客户端,这两个方法都回 `unknown-method`,桥也不会替它折一条事件、更不会替它打一次上游请求。`usage.stats` 读的是另一个插件记的台账,所以它是 `usage.stats.v1` 背后独立的一个能力、也是独立的一条读路:一条 `GET /api/dsh-usage/overview`,外加——只在请求的窗口比那份文档自带的 30 天更深时——对台账确实记过的每一天各一条 `GET /api/dsh-usage/day?date=YYYY-MM-DD`。台账里没有条目的日子按真实的 0 过线(宿主自己对那些日期答的也是全 0 的一天),而路由不存在(`no-usage-plugin`)、连接不上、形状不符或太慢都回 `probe-failed` 并带一句短原因,绝不拿上一轮的读数顶上。同一个 `days` 窗口在本桥这一侧缓存 30 秒,并发调用合并进去,所以两台手机同时问只让宿主读一次。`usage.session` 在窗口旁边多了一个可选键:宿主没广播过 `request/context` 窗口时,应答可以带上 `modelContextWindow`,取自这条会话当前路由的 `GET {baseURL}/models`——按模型 id 精确匹配后依次取 `context_length`、`context_window`、`max_input_tokens` 里第一个可用值,按路由缓存十分钟,并带上这条路由自己的凭据。两个数字永不混用:`contextWindow` 恒为宿主实测,`modelContextWindow` 恒为模型声明,后者也永不与前者同时出现。
|
|
97
97
|
|
|
@@ -170,7 +170,7 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
170
170
|
| `malformed` | 该帧不是形状可辨的单个 JSON 对象 |
|
|
171
171
|
| `direction-violation` | 客户端发来了只有宿主才发的 `res` 或 `ev` 帧 |
|
|
172
172
|
|
|
173
|
-
在 DSH 内部产生的失败同样不被改名:它带着 gateway 自己的错误码穿过桥,例如 `service-unavailable`、`invocation-unavailable`、`definition-unavailable`、`arguments-invalid`。`dsh-agents` 插件抛出的拒绝也这样穿过:带它自己的稳定错误码——`team-not-found`、`member-not-found`、`preset-unknown`、`workspace-
|
|
173
|
+
在 DSH 内部产生的失败同样不被改名:它带着 gateway 自己的错误码穿过桥,例如 `service-unavailable`、`invocation-unavailable`、`definition-unavailable`、`arguments-invalid`。`dsh-agents` 插件抛出的拒绝也这样穿过:带它自己的稳定错误码——`team-not-found`、`member-not-found`、`preset-unknown`、`workspace-unavailable` 及其邻居——以及它自己那一句有界文案。只有服务激活窗口会被重试(5 次、间隔 2 秒),因为那是唯一「片刻后即成功」的失败。
|
|
174
174
|
|
|
175
175
|
## 鉴权
|
|
176
176
|
|
|
@@ -178,14 +178,16 @@ fork 的方法同样什么都不解释。`session.fork` 把 `sessionId` 与客
|
|
|
178
178
|
|
|
179
179
|
### Bootstrap token
|
|
180
180
|
|
|
181
|
-
`GET /remote-bridge/pair/token`
|
|
181
|
+
配对入口位于侧栏底部的二维码图标,按钮的 aria-label 为「配对手机(协议 v1)」。点击后打开配对面板。该面板只在本机可用:令牌路由 `GET /remote-bridge/pair/token` 受回环门控保护,来源地址与 `Host` header 必须均为本机(非本机或经隧道访问一律返回 403)。
|
|
182
|
+
|
|
183
|
+
配对码一次性有效且具备 30 秒时效(`BOOTSTRAP_TOKEN_TTL_MS = 30_000`),被首次 `pair.begin` 用掉即失效;在面板中点击「重新取码」会使上一张配对码作废并生成新码。面板中没有「停止」按钮,也没有「吊销所有已连接设备」的操作。同一条链接会打印到宿主日志,配对码本身则渲染在配对面板中供扫码。
|
|
182
184
|
|
|
183
185
|
```sh
|
|
184
186
|
curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
185
187
|
# {"token":"...","expiresAt":1760000030000,"url":"ws://127.0.0.1:3080/ios/v1?token=..."}
|
|
186
188
|
```
|
|
187
189
|
|
|
188
|
-
|
|
190
|
+
当这台机器能解析出公网或局域网地址时——无论来自实时的中继租约/隧道状态、`DSH_REMOTE_PUBLIC_BASE_URL` 还是正在监听的局域网转发器——同一个响应里会多出地址那一半:
|
|
189
191
|
|
|
190
192
|
```json
|
|
191
193
|
{
|
|
@@ -198,7 +200,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
198
200
|
}
|
|
199
201
|
```
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
二维码编码一个 `{token, url}` 文档,其中 `url` 形如 `wss://<origin>/ios/v1?token=...`(由 `pairingDialUrlOf` 将 https 转为 wss、http 转为 ws)。手机 App 扫码即同时得到地址与令牌,无需手动输入。查不到可用地址时字段缺省而非盲目猜测,面板退回裸配对码,手机保持已有地址不变。
|
|
202
204
|
|
|
203
205
|
### 设备令牌
|
|
204
206
|
|
|
@@ -232,9 +234,44 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
232
234
|
|
|
233
235
|
这一跳带来两条后果。它看得见请求 URL,所以用 `?token=` 连接等于把设备令牌交给中继、Cloudflare 边缘与 origin 访问日志——优先用 header。而 `GET /remote-bridge/pair/token` 会像其他路径一样被转发,但它的 loopback 门禁会拒掉这条转发请求,因此配对只能从本机发起。
|
|
234
236
|
|
|
237
|
+
## 接入栈与安全模型
|
|
238
|
+
|
|
239
|
+
`@linxin666/dsh-remote-bridge` 拥有完整的公网与局域网接入栈:
|
|
240
|
+
- **中继身份与租约**:`relay-registry` 在 `$DSH_HOME/remote-web-ui-registry/<profile>.json` 下持久化中继身份(id 与 secret);改 relay 配置会重挂载插件行,当以 `relay=false` 挂载且盘上存在身份时,挂载时撤销上一次留下的注册行并 `pair.release()` 释放租约各一次(失败各记一行;卸载时不释放也不撤行,保留手机收藏地址由服务端 GC 回收;`relay=false` 挂载绝不铸造新身份,盘上无身份时零副作用、不写盘)。
|
|
241
|
+
- **中继连接器**:`relay-connector` 并行维护快速隧道与命名隧道连接器;`relay-bridge-connector` 经 WSS 连接 Cloudflare Durable Object 会合点,并将连接状态记录在 `$DSH_HOME/remote-web-ui-relay-bridge.json`(状态文件写入经行为级验证,缺省落到 `$DSH_HOME`,非源码文本断言)。
|
|
242
|
+
- **隧道生命周期**:`tunnel`、`tunnel-plan` 与 `tunnel-orphan` 管理平台原生 `cloudflared` 子进程,具备指数退避重启机制并自动清理崩溃遗留的孤儿进程。
|
|
243
|
+
- **命名隧道端口同步**:`ingress-sync` 在宿主监听端口变化时,把 Cloudflare 命名隧道的 ingress 规则原子收敛到本机闸门端口。
|
|
244
|
+
- **局域网转发与防火墙**:`lan`、`lan-bind`、`lan-bind-plan`、`lan-forward`、`host-bind-capability` 与 `firewall` 管理局域网边缘转发器与操作系统防火墙规则(Windows Defender 与 Linux firewalld/ufw/iptables),宿主 webserver 本身始终严格保持回环绑定。
|
|
245
|
+
|
|
246
|
+
本包的安全模型对所有外部接入入口实施严格的白名单隔离:
|
|
247
|
+
- **入站网关(`src/host/ingress-gate.ts`)**:仅绑定 `127.0.0.1`,且仅将 `/ios/v1` 的 WebSocket 升级转发到本机协议端口,同时将 `Host` 头改写为回环权威。其余任何普通 HTTP 请求与非白名单升级一律直接返回 `404 {"error":"not-found"}` 并关闭连接,绝不建立上游连接。
|
|
248
|
+
- **隧道的目标是入站网关而非 webServer 端口**:cloudflared 快速隧道与命名隧道的目标均指向 `ingress-gate` 的动态回环端口,绝不直连 `webServer` 端口。外界经隧道传入的请求无法触达 webServer 路由、内部 API 或其他插件。
|
|
249
|
+
- **中继注册行与公网暴露面**:中继注册行只写入快速隧道的 URL,也就是入站闸门,公网因此只看得见 /ios/v1。计划为 quick 且隧道 running 时把闸门 URL 注册给中继 Worker(`<id>.dsh-market.com` 代理到本机);卸载时只清本地引用不撤行。二维码公网地址由 `livePublicOriginOf` 裁定:bridge 或 named 租约优先稳定子域名;quick 租约在注册未成功时退回隧道 running URL;无租约用隧道 URL;皆无则无地址。其后退回 `DSH_REMOTE_PUBLIC_BASE_URL`,局域网兜底仅当局域网转发器真的在监听时才按实际绑定的 address 与 port 给出(不猜地址列表首项,转发器停止即无兜底;已彻底移除磁盘 registry 行作为兜底地址,消除了对老插件数据文件的最后一处依赖)。
|
|
250
|
+
- **局域网转发器的目标同样是入站网关**:局域网转发器监听本机局域网 IPv4 地址,并将请求严格转发至 `ingress-gate` 端口,因此局域网入口的暴露面同样仅有 `/ios/v1`。
|
|
251
|
+
- **中继桥会合点白名单**:`relay-bridge-connector.ts` 对 Durable Object 汇聚的入站流执行完全相同的白名单检查,非 `/ios/v1` 的 HTTP 流直接应答 `404 {"error":"not-found"}`,非白名单 WebSocket 升级直接回复 `ws-fail 404 {"error":"not-found"}`,两条路都不建立上游连接。
|
|
252
|
+
- **身份目录沿用历史拼写与并存禁忌**:中继身份目录 `$DSH_HOME/remote-web-ui-registry/` 与状态文件 `remote-web-ui-relay-bridge.json` 有意沿用历史拼写,确保既有 profile 保持身份连续性,已配对设备升级后无需重新配对。**已知风险与并存禁忌**:同一 profile 切勿同时启用本插件与已弃用的 `dsh-remote-web-ui` 的中继——两者按 profile 共用同一份身份文件;若新桥以 `relay=false` 挂载,会撤销该身份下的注册行并释放租约,从而打断老插件正在使用的公网中继;若两侧 relay 同时开启,bridge 传输下两个连接器会拿同一凭据竞争同一个 Durable Object 连接互相顶掉,quick 传输下后注册者覆盖前者。该收尾行为是有意设计的。
|
|
253
|
+
- **本插件不含浏览器配对面**:本包不包含配对 cookie 门控、`/api/pair` 路由族、`/remote` 代理通道以及手机浏览器竖屏触控适配层。
|
|
254
|
+
|
|
255
|
+
## 配置
|
|
256
|
+
|
|
257
|
+
本插件通过 profile YAML(如 `cordis.patch.yml` 或 profile 配置)进行配置,不提供设置界面。未配置的字段回退到内置默认值:
|
|
258
|
+
|
|
259
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
260
|
+
| --- | --- | --- | --- |
|
|
261
|
+
| `relay` | boolean | `true` | 是否申领 relay 租约。默认开启;无隧道时仍 claim 租约,因此默认配置下公网即可用。 |
|
|
262
|
+
| `autoTunnel` | boolean | `false` | 是否启动指向入站网关的 Cloudflare 快速隧道。 |
|
|
263
|
+
| `lanBind` | boolean | `undefined`(关) | 是否启动监听本机局域网 IPv4 地址的局域网转发器。 |
|
|
264
|
+
| `tunnelToken` | string | `undefined` | 运行 Cloudflare 命名隧道所需的隧道令牌。 |
|
|
265
|
+
| `publicBaseUrl` | string | `undefined` | 命名隧道的固定公网 HTTPS 基地址。 |
|
|
266
|
+
| `ingressSync` | boolean | `false` | 是否自动将命名隧道 ingress 服务端口同步至 Cloudflare。 |
|
|
267
|
+
| `cfApiToken` | string | `undefined` | 用于 ingress-sync 的 Cloudflare 账户级 API 令牌。 |
|
|
268
|
+
| `cfAccountId` | string | `undefined` | 用于 ingress-sync 的 Cloudflare 账户 ID。 |
|
|
269
|
+
| `cfTunnelId` | string | `undefined` | 用于 ingress-sync 的 Cloudflare 命名隧道 ID。 |
|
|
270
|
+
| `profile` | string | `'desktop'` | 受管 profile 名称(缺省读取 `$DSH_PROFILE` 或 `'desktop'`)。 |
|
|
271
|
+
|
|
235
272
|
## Web GUI 配对面板
|
|
236
273
|
|
|
237
|
-
浏览器半区存在的理由,是让从不开终端的操作者也有一条发起配对的路径。它沿用家族在侧栏底部的惯例:触发器注册进官方 `sidebar.footer.action` 列表槽位(由 ui-sidebar
|
|
274
|
+
浏览器半区存在的理由,是让从不开终端的操作者也有一条发起配对的路径。它沿用家族在侧栏底部的惯例:触发器注册进官方 `sidebar.footer.action` 列表槽位(由 ui-sidebar 声明,与 `dsh-update` 的更新器共用该列表槽位),点开后是官方 `Modal`,这张无头卡片由本包填充。它渲染的每个控件都是库里已有的 primitive——弹窗、三个动作与它们的字形——因此遮罩、卡片、焦点圈定、Esc、焦点归还,以及每个 hover/focus/disabled 状态都是官方壳自己的行为,而不是本包的一份复制品。它由同一插件行承载:产物是 `exports["./client"]`,`dsh.client` 声明必须先就位的 client 模块。
|
|
238
275
|
|
|
239
276
|
面板只做一件事——把活着的那个一次性配对码摆到操作者面前,且只有这一个阅读顺序:
|
|
240
277
|
|
|
@@ -247,7 +284,7 @@ curl -s http://127.0.0.1:3080/remote-bridge/pair/token
|
|
|
247
284
|
|
|
248
285
|
开与关是同一段动效的两条腿:卡片保持挂载,把弹窗自己的进场淡入反向播完才卸载;reduced-motion 下这条生命周期换成一段短淡出,而不是干脆没有出场。几何在每种状态里都钉住——二维码的盒子、状态行、地址说明与复制标签都不改高度和宽度——所以倒计时、过期与复制确认都不会挪动它们旁边的元素。
|
|
249
286
|
|
|
250
|
-
面板对原生路径而言只是显示层。它从不消耗配对码(`pair.begin` 始终是手机那一侧的动作),从不碰名册,也不新增任何 wire
|
|
287
|
+
面板对原生路径而言只是显示层。它从不消耗配对码(`pair.begin` 始终是手机那一侧的动作),从不碰名册,也不新增任何 wire 面——信封、方法名、主题名与事件一律不动。本插件不提供任何浏览器配对面或 cookie 门控。
|
|
251
288
|
|
|
252
289
|
## 会话里的整页卡
|
|
253
290
|
|
package/lib/client.js
CHANGED
|
@@ -1226,7 +1226,7 @@ window.__ModuleLoader__.load({
|
|
|
1226
1226
|
const PART_PANEL = "panel";
|
|
1227
1227
|
//#endregion
|
|
1228
1228
|
//#region \0dsh-css:packages/dsh-remote-bridge/src/client/panel.module.css.mjs
|
|
1229
|
-
const css$1 = ".sd7VOG_panel,.sd7VOG_trigger,.sd7VOG_dialog{--pair-space-1:4px;--pair-space-2:8px;--pair-space-3:12px;--pair-space-4:24px;--pair-title-size:15px;--pair-title-line:24px;--pair-text-size:13px;--pair-text-line:20px;--pair-state-size:12px;--pair-state-line:18px;--pair-qr:184px;--pair-bar:4px;--pair-seat:36px;--pair-close:28px;--pair-hit:44px;--pair-width:460px;--pair-faded:.35;--pair-focus-offset:2px;--pair-status:calc(var(--pair-state-line) + var(--pair-space-1) + var(--pair-bar));--pair-address:calc(var(--pair-text-line) * 2)}.sd7VOG_trigger{width:var(--pair-seat);height:var(--pair-seat);color:var(--dsw-alias-label-secondary);cursor:pointer;transition:background-color var(--ds-transition-duration) ease, color var(--ds-transition-duration) ease;background:0 0;border:none;border-radius:50%;flex:none;order:-1;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}.sd7VOG_trigger:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-seat)) / -2);border-radius:50%;position:absolute}.sd7VOG_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.sd7VOG_trigger:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}.sd7VOG_trigger:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:var(--pair-focus-offset)}[class*=footerActions]:has([data-dsh-plugin=remote-bridge][data-wide=rail]){align-items:center;gap:var(--pair-space-1,4px);flex-direction:column}.sd7VOG_dialog.sd7VOG_dialog{width:min(var(--pair-width), 100%);max-height:100%;padding:var(--pair-space-4);overflow:auto}.sd7VOG_panel{gap:var(--pair-space-3);box-sizing:border-box;width:100%;max-width:100%;color:var(--dsw-alias-label-primary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);transition:opacity var(--ds-transition-duration) var(--ds-ease-in-out);flex-direction:column;display:flex}.sd7VOG_panel[data-closing]{opacity:0;animation:var(--pair-exit-name,none) var(--ds-transition-duration) var(--ds-ease-in-out) reverse both}@media (prefers-reduced-motion:reduce){.sd7VOG_panel[data-closing]{animation:none}}.sd7VOG_header{align-items:flex-start;gap:var(--pair-space-3);display:flex}.sd7VOG_heading{flex:1;min-width:0}.sd7VOG_title{font-size:var(--pair-title-size);font-weight:600;line-height:var(--pair-title-line);margin:0}.sd7VOG_subtitle{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_close{width:var(--pair-close);color:var(--dsw-alias-label-secondary);flex:none;padding:0;position:relative}.sd7VOG_close:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-close)) / -2);border-radius:50%;position:absolute}.sd7VOG_body{gap:var(--pair-space-2);flex-direction:column;display:flex}.sd7VOG_qrCard{align-items:center;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1);flex-direction:column;display:flex}.sd7VOG_qrSlot{width:var(--pair-qr);height:var(--pair-qr);justify-content:center;align-items:center;display:flex}.sd7VOG_qrSlot[data-expired]{opacity:var(--pair-faded)}.sd7VOG_skeleton{width:var(--pair-qr);height:var(--pair-qr);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);display:block}.sd7VOG_status{justify-content:center;align-items:center;gap:var(--pair-space-1);box-sizing:border-box;width:100%;height:var(--pair-status);flex-direction:column;display:flex}.sd7VOG_statusText{color:var(--dsw-alias-label-secondary);font-size:var(--pair-state-size);line-height:var(--pair-state-line);font-variant-numeric:tabular-nums;margin:0}.sd7VOG_bar{width:100%;height:var(--pair-bar);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-interactive-bg-hover);display:block;overflow:hidden}.sd7VOG_barFill{border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-brand-primary);height:100%;transition:width var(--ds-transition-duration) linear;display:block}.sd7VOG_address{min-height:var(--pair-address);color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);align-items:center;margin:0;display:flex}.sd7VOG_address[data-tone=warning]{color:var(--dsw-alias-state-warn-primary)}.sd7VOG_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);margin:0}.sd7VOG_notice{align-items:flex-start;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-state-error-primary);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);display:flex}.sd7VOG_noticeIcon{color:var(--dsw-alias-state-error-primary);flex:none;display:inline-flex}.sd7VOG_noticeCopy{min-width:0}.sd7VOG_noticeTitle{font-size:var(--pair-text-size);font-weight:600;line-height:var(--pair-text-line);margin:0}.sd7VOG_noticeText{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_actions{justify-content:flex-end;align-items:center;gap:var(--pair-space-2);display:flex}.sd7VOG_labels{display:grid}.sd7VOG_label{grid-area:1/1}.sd7VOG_label[data-visible=false]{visibility:hidden}.sd7VOG_announce{clip:rect(0, 0, 0, 0);clip-path:inset(0);width:0;height:0;margin:0;position:absolute;overflow:hidden}";
|
|
1229
|
+
const css$1 = ".sd7VOG_panel,.sd7VOG_trigger,.sd7VOG_dialog{--pair-space-1:4px;--pair-space-2:8px;--pair-space-3:12px;--pair-space-4:24px;--pair-title-size:15px;--pair-title-line:24px;--pair-text-size:13px;--pair-text-line:20px;--pair-state-size:12px;--pair-state-line:18px;--pair-qr:184px;--pair-bar:4px;--pair-seat:36px;--pair-close:28px;--pair-hit:44px;--pair-width:460px;--pair-faded:.35;--pair-focus-offset:2px;--pair-status:calc(var(--pair-state-line) + var(--pair-space-1) + var(--pair-bar));--pair-address:calc(var(--pair-text-line) * 2)}.sd7VOG_trigger{width:var(--pair-seat);height:var(--pair-seat);color:var(--dsw-alias-label-secondary);cursor:pointer;transition:background-color var(--ds-transition-duration) ease, color var(--ds-transition-duration) ease;background:0 0;border:none;border-radius:50%;flex:none;order:-1;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}.sd7VOG_trigger:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-seat)) / -2);border-radius:50%;position:absolute}.sd7VOG_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.sd7VOG_trigger:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}.sd7VOG_trigger:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:var(--pair-focus-offset)}.sd7VOG_trigger[data-wide=wide]{order:1;margin-inline-start:auto}[class*=footerActions]:has([data-dsh-plugin=remote-bridge][data-wide=rail]){align-items:center;gap:var(--pair-space-1,4px);flex-direction:column}.sd7VOG_dialog.sd7VOG_dialog{width:min(var(--pair-width), 100%);max-height:100%;padding:var(--pair-space-4);overflow:auto}.sd7VOG_panel{gap:var(--pair-space-3);box-sizing:border-box;width:100%;max-width:100%;color:var(--dsw-alias-label-primary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);transition:opacity var(--ds-transition-duration) var(--ds-ease-in-out);flex-direction:column;display:flex}.sd7VOG_panel[data-closing]{opacity:0;animation:var(--pair-exit-name,none) var(--ds-transition-duration) var(--ds-ease-in-out) reverse both}@media (prefers-reduced-motion:reduce){.sd7VOG_panel[data-closing]{animation:none}}.sd7VOG_header{align-items:flex-start;gap:var(--pair-space-3);display:flex}.sd7VOG_heading{flex:1;min-width:0}.sd7VOG_title{font-size:var(--pair-title-size);font-weight:600;line-height:var(--pair-title-line);margin:0}.sd7VOG_subtitle{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_close{width:var(--pair-close);color:var(--dsw-alias-label-secondary);flex:none;padding:0;position:relative}.sd7VOG_close:after{content:\"\";inset:calc((var(--pair-hit) - var(--pair-close)) / -2);border-radius:50%;position:absolute}.sd7VOG_body{gap:var(--pair-space-2);flex-direction:column;display:flex}.sd7VOG_qrCard{align-items:center;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1);flex-direction:column;display:flex}.sd7VOG_qrSlot{width:var(--pair-qr);height:var(--pair-qr);justify-content:center;align-items:center;display:flex}.sd7VOG_qrSlot[data-expired]{opacity:var(--pair-faded)}.sd7VOG_skeleton{width:var(--pair-qr);height:var(--pair-qr);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover);display:block}.sd7VOG_status{justify-content:center;align-items:center;gap:var(--pair-space-1);box-sizing:border-box;width:100%;height:var(--pair-status);flex-direction:column;display:flex}.sd7VOG_statusText{color:var(--dsw-alias-label-secondary);font-size:var(--pair-state-size);line-height:var(--pair-state-line);font-variant-numeric:tabular-nums;margin:0}.sd7VOG_bar{width:100%;height:var(--pair-bar);border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-interactive-bg-hover);display:block;overflow:hidden}.sd7VOG_barFill{border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-brand-primary);height:100%;transition:width var(--ds-transition-duration) linear;display:block}.sd7VOG_address{min-height:var(--pair-address);color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);align-items:center;margin:0;display:flex}.sd7VOG_address[data-tone=warning]{color:var(--dsw-alias-state-warn-primary)}.sd7VOG_hint{color:var(--dsw-alias-label-tertiary);font-size:var(--pair-text-size);line-height:var(--pair-text-line);margin:0}.sd7VOG_notice{align-items:flex-start;gap:var(--pair-space-2);padding:var(--pair-space-3);border:1px solid var(--dsw-alias-state-error-primary);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);display:flex}.sd7VOG_noticeIcon{color:var(--dsw-alias-state-error-primary);flex:none;display:inline-flex}.sd7VOG_noticeCopy{min-width:0}.sd7VOG_noticeTitle{font-size:var(--pair-text-size);font-weight:600;line-height:var(--pair-text-line);margin:0}.sd7VOG_noticeText{margin:var(--pair-space-1) 0 0;color:var(--dsw-alias-label-secondary);font-size:var(--pair-text-size);line-height:var(--pair-text-line)}.sd7VOG_actions{justify-content:flex-end;align-items:center;gap:var(--pair-space-2);display:flex}.sd7VOG_labels{display:grid}.sd7VOG_label{grid-area:1/1}.sd7VOG_label[data-visible=false]{visibility:hidden}.sd7VOG_announce{clip:rect(0, 0, 0, 0);clip-path:inset(0);width:0;height:0;margin:0;position:absolute;overflow:hidden}";
|
|
1230
1230
|
const tagId$1 = "@linxin666/dsh-remote-bridge/packages/dsh-remote-bridge/src/client/panel.module.css";
|
|
1231
1231
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
1232
1232
|
const tag = document.createElement("style");
|