Plugin sync & the plugin bridge
Sync native DSH workspaces and dsh-better-sidebar out of the box, or connect any third-party plugin cleanly via the declarative bridge protocol.
Three sync layers
When operating inside a remote session, panel requests route seamlessly back to the Host:
- DSH native plugins: workspace diffs, file trees, interactive terminals, approval prompts, and mobile shortcut chips stay in sync automatically.
- dsh-better-sidebar built-in adapter: verified support across 0.25.0–0.33.0 (matched automatically by endpoint signature; 0.33.0 requires DSH ≥0.2.2-rc.3, so hosts still on 0.2.2-rc.2 should stay on 0.32.1) for remote file browsing, Git commit graphs, uploads, and live SideChat streams; its “More” menu entry is hidden in remote sessions that are not bridged.
- Open plugin bridge protocol: any third-party plugin registers route locators through ctx.zenRemote with zero runtime impact when zen-remote is absent.
Explicit whole-machine consent
Bridge routes distinguish session-scoped reads (scope: "session") from whole-machine server routes (scope: "server"). Server-scoped routes remain disabled by default until the Host owner opts in per plugin inside settings.
How bridge routing works
The desktop client reroutes requests targeting your plugin from a remote session to the Host, which invokes your endpoint over local loopback HTTP and returns the response untouched. On machines without zen-remote or running older versions (<2.1), inject never fires and your plugin behaves identically.
Quick integration (~15 lines)
Import the types and declare your routes inside apply() using query params, path segments, JSON payloads, or WebSocket upgrade tunnels:
import type { Context } from '@deepseek-ai/cordis';
import type { BridgeDeclaration, ZenRemoteService } from 'dsh-zen-remote';
export function apply(ctx: Context) {
ctx.inject(['zenRemote'], (c) => {
const bridge: ZenRemoteService = c.zenRemote;
const declaration: BridgeDeclaration = {
plugin: '@scope/my-plugin', // must match package.json name
version: '0.2.0', // must match the running version
routes: [
{ path: '/my-plugin/session-data', scope: 'session' },
{ path: '/my-plugin/all-tasks', scope: 'server' },
],
};
const dispose = bridge.bridge(declaration);
ctx.effect(() => dispose, 'my-plugin: bridge declaration');
});
}Declaration field reference
Unknown fields error at registration. A plugin is considered “bridged” only when both ends agree on plugin name, exact version, and declaration digest (the first 16 hex characters of sha256 over the normalized declaration; route order is ignored, every field value counts).
| Field | Rules |
|---|---|
| plugin | npm-name format (@scope/name allowed), ≤214 chars |
| version | Compared verbatim, no semver parsing |
| routes[] | ≤64 routes; path starts with /, must not start with /_dsh/ or /api, unique per declaration |
| scope | 'session' (session data) or 'server' (machine-wide; owner consents per plugin, default off) |
| sessionParam | Default 'sessionId'; declare when your endpoint uses another parameter name |
| stream | Marks streaming-response routes |
| methods | Default ['GET']; may declare GET/HEAD/POST/PUT/PATCH/DELETE (since 2.2; write bodies stream through the relay) |
| maxBody | Default 1 MiB, ceiling 500 MiB |
| upgrade | WebSocket endpoint (since 2.2; forwarded verbatim as an opaque byte tunnel; GET only, never with stream) |
| locator (2.4) | Where the session id lives: {in:'query',name} / {in:'path-segment',index} / {in:'json-body',fields}, replacing sessionParam |
| prefix (2.4) | Match sub-paths; cannot be combined with upgrade |
| deny (2.4) | Data that only makes sense locally: remote hits return 503 route-denied |
| rewriteIds (2.4) | Rewrite session ids in remote responses: true (deep value scan) or {fields:[dot paths]} (wraps newly created ids); never with stream |
Four integration rules
- Browser requests on session routes must include the session parameter (default sessionId) so zen-remote can reroute them; requests without it stay local.
- Your server-side endpoint must resolve context from the session id rather than client paths — it always receives the Host’s session id.
- Pass response bodies through cleanly — avoid embedding local URLs or having the browser chase an id from one response in a follow-up request.
- Re-issue streaming requests whenever the user switches sessions; never reuse a prior stream.
Unbridged behavior
Unbridged requests fail closed with HTTP 503, header x-zen-remote: unbridged, and body {"ok":false,"error":{"code":"zr-plugin-unbridged","reason":…}} — never falling back to the local plugin so local data cannot leak into remote sessions.
Common reason codes: not-on-server, version-mismatch, declaration-mismatch, consent-off (server scope not consented), offline, server-changed (session id points to another Host), bad-query, server-too-old, method-not-bridged, route-denied, plus relay passthrough codes (not-shared, busy, plugin-unknown).
Version capability matrix & adapter precedence
Upgrades never break existing bridges: newer fields enter the digest only when explicitly specified. Built-in adapters apply only when a third-party plugin has not registered its own declaration (currently supporting dsh-better-sidebar 0.25.0–0.33.0); an explicit BridgeDeclaration always takes precedence. See Glossary for key terms.
| zen-remote version | Capabilities |
|---|---|
| 2.1 | Cooperative declarations (GET, exact path matching) |
| 2.2 | Write methods, maxBody limits, upgrade WebSocket tunnels |
| 2.4 | locator, prefix, deny, and rewriteIds fields with matching adapter prefix rules |