DSH / Atlas
2026-09-13implementedfeature

Liveshare — sharing a DSH session with a colleague

Liveshare —— 把 DSH 会话分享给同事看

A DSH session runs on your own computer. A colleague sometimes needs to watch one while you work — to follow a debugging session, or to see how a long task is going. Today there is no way to do that. Sending the session log is not the same thing: the colleague would need your plugins, configuration, and sandbox to render it, and the session only makes sense while it is running on your machine. So a share needs three

English

Problem

A DSH session runs on your own computer. A colleague sometimes needs to watch one while you work — to follow a debugging session, or to see how a long task is going. Today there is no way to do that. Sending the session log is not the same thing: the colleague would need your plugins, configuration, and sandbox to render it, and the session only makes sense while it is running on your machine.

So a share needs three things at once. A page the colleague opens in a browser that shows the session running on your machine, without connecting them to it. A limit on what that page can do, starting with "read without writing" — anything the page offers beyond what you agreed is a security hole, not a convenience. And an answer to "who shared this?", because a page that cannot say who its owner is cannot be trusted by whoever opens it.

This note covers the half that runs inside the owner's DSH — the share dialog, the owner-side service behind it, the package's browser face, and the page a reader opens — plus the protocol package both sides speak. The Liveshare server, the shared service in the middle, is its own package (@deepseek-ai/dsh-experimental-liveshare-relay) and is reviewed and deployed separately.

Decision

What a share is

An owner creates a share for one session from DSH itself. The share is published to the Liveshare server, a service both sides can reach, and DSH returns a link. Opening that link shows the session rendered by the owner's own DSH with its own plugins, so the reader never needs the owner's configuration. The reader's list contains the source Session and any children that reader created through the share. Workspace names, membership, and ordering are trimmed to those Sessions; unrelated Sessions and workspaces stay hidden.

A share created from the DSH Share dialog is an organization link share: it carries accessMode: 'open', so anyone in the organization who has the link is admitted. The deployment's LIVESHARE_ALLOWED_SUBJECTS is unioned into every share's ACL: it narrows an open share to the subjects it lists, and on a stored selected record it adds those subjects beside the record's own selection.

Specific colleagues (selected) and the older approval spelling are legacy stored records. The Host still reads them with their recorded ACL and shows their access summary, and the Liveshare server still admits their viewers by that ACL, but the shipped Share dialog offers no way to create one. liveshareShares.create keeps its accessMode and allowedSubjectIds fields for those records and for callers that invoke the Remote directly; the shipped dialog sends neither.

What a reader can do

The reader's page is the normal DSH client, not a cut-down copy. The sidebar, the session list, expanding, collapsing, and selecting are all there, because browsing is part of reading. What is missing is every action the reader is not allowed to perform: creating an unrelated session, renaming, archiving, deleting, and managing a workspace. Branching follows the share's own fork switch, prompting is available in both tiers and runs inside that tier's sandbox, and attachment upload follows the Sessions the reader can see; management permissions remain independent of the tier and the fork switch.

These actions are not hidden with CSS. One access snapshot decides what the page may do: the remote-access client follows the reader's own remoteAccess/follow, and each button and menu entry reads its endpoint's answer on the global resource, a Session, or a Workspace through useRemoteAccess, useAccess or useSessionAccess, or useWorkspaceAccess, rendering again whenever the answer changes. The owner's DSH computes the snapshot from this share's share-viewer policy, so an ability the owner withdraws closes without reloading the page — and the server refuses those actions anyway; the page only avoids offering what would be refused. The served index carries the reader's opening snapshot, so no entry appears before the page knows it is allowed, and after the snapshot stream fails every answer is refused. The owner's own page opens with the owner baseline and behaves exactly like an ordinary DSH. Per-Session refusal reasons are not part of the snapshot: the page states the page-level reason (share mode, stop, expiry, lost access) and generic read-only copy. A page that cannot read the Session at all — offline owner, stopped or expired share, lapsed sign-in — states that condition at the top and gives the reader an action, instead of leaving an empty shell or a bare code.

Two driving tiers

Every share carries a ViewerSessionMode with two values, and both drive the shared Session:

  • view — the reader drives the shared Session's loop through the normal prompt path, inside a read-only sandbox in the granted workspace, so the Session's tools never write a file. The read and search surface (read, read_image, glob, grep, present), the tools with no local file effect (todo_write, skill, web_search, web_fetch). Every declared path is checked before the tool runs, and a tool whose call cannot be checked is refused.
  • write — the reader drives the same loop in a bounded writable sandbox that also modifies files inside the granted workspace, under the Host's write ceiling.

The sandbox is installed on the Session, but it confines only the turns a share viewer starts: agent/pre-step records whether an admitted turn's entering input names a share viewer, and the guard and the replacements read that answer for each execution. A turn the owner starts keeps the Session's tools; an owner's steering input inside a viewer's turn stays confined with it. The marker lives in Host memory, is recomputed for each turn, and never enters the Session log. Stopping every share, or letting them all expire, disposes the layer and gives the Session its own tools back.

The earlier vocabulary had three tiers — view watched, fork-readonly branched, and write could write. view and fork-readonly differed only in whether the reader could branch and drive a child, which the share's own allowsFork switch already decides; a third mode duplicated that switch and let the two answers disagree, so the two driving tiers replaced it.

Forking is not a tier. The share carries its own allowsFork switch, independent of the tier: a view share may allow it and a write share may refuse it. A fork creates a child the viewer owns with its own read-only or writable ceiling and leaves the source untouched.

Attachment upload is not a tier or a switch. fileUploads/upload rides the read role, so every Session a share serves the reader accepts files; visibility alone decides it, and the owner has no separate attachment switch.

A mode this version does not recognize, and a persisted record whose mode the host cannot establish, are not driven: the share stays readable, and the page reports what it could not establish. The withdrawn fork-readonly name is not read back as view; a persisted owner record that names it is rejected when the owner state loads.

The sandbox is a property of the Session, but it applies per turn: the Host records, in memory, whether the admitted input of the running turn names a share viewer, and confines that turn while leaving an owner-started turn on the Session's native tools. The earlier shipped design confined every turn, including the owner's; it needed no turn read, but a share changed how the owner's own work ran. Persisting a turn's requester was rejected: a committed-message projection had to be folded, re-read for every execution, and kept in step with the share that admitted it, and it still had to fail closed on mixed or unestablished requesters. The in-memory marker keeps the guard and the replacements reading one answer per execution without adding a Session event; a restart recomputes it from the next admitted step, and a rejected or never-admitted step leaves no marker.

Default visibility

The package ships as a runtime dependency of every dsh installation, but a default installation must show it nowhere in the plugin manager: neither under Built-in plugin settings, nor under Experimental plugins, nor on the More page. A person enables it deliberately — by inserting the bundle's rows in the active profile's cordis.patch.yml, or by selecting the bundle in dsh.profile.bundles; the package README owns both routes. The package must still ship with the release and stay installable, and users who enabled it before this rule keep seeing it.

The Host's bundle enabled flag states whether the profile selected the bundle, which is not the same as whether the bundle's plugins run: inserting the bundle's rows through cordis.patch.yml starts its plugins while leaving the bundle unselected, so a visibility rule built on enabled would hide a bundle the person had just enabled and would strand the documented enable path.

The package declares the hiding intent in its own bundle manifest as dsh.bundle.listedByDefault: false; the manager keeps one generic visibility rule rather than a client-side name set. A bundle whose manifest does not declare listedByDefault: false is listed; one that declares it is listed only when the profile enables it, the installation carries it selected, or one of the rows its bundle patch declares is running (pkg.rows.some(row => row.enabled)). The filter applies before both lists are derived, so the name is absent from the main Experimental plugins group, the More page, Built-in plugin settings, and the Installed plugins group until one of those holds. The Host's listBundles contract, the profile format, and the installed package set are unchanged. BundleInfo.rows already joins each declared row with the Loader entry currently carrying it, and the client's PackageView carries whether that entry runs, so row state is the effective answer for both enable routes: removing the rows, disabling them, or deselecting the bundle stops them and the card leaves both lists again.

A default-hidden bundle is not addressable by ID while its card is hidden: openPkg resolves only the listed inventory, so pluginNavigation.openBundle('@deepseek-ai/dsh-experimental-liveshare') renders no details until the same enablement conditions list it.

How shared work stays inside its grant

The Owner, not the viewer page or the Liveshare server, authorizes each Session operation. A child receives its real scoped tool restrictions before it can accept a prompt, including after a cold resume: the host installs the limit from the base agent/created event. That listener runs after the agent entered the registry, but creation has not resolved, AgentLoop holds the agent's queued input, and a throw fails creation, so a refused limit still prevents any prompt. A missing host service or failed installation refuses the child; a configuration flag, a tool name, or a promise to install later is not enforcement.

A shared source Session can still serve its owner's own work. Every reader call is dispatched through the owner's own Connection and Gateway as that share-and-reader pair's own Peer, whose share-viewer principal (the share id and the server-asserted identity triple) is fixed by in-process owner code when the Peer is created; no wire field can change it. The Gateway decides the Peer's calls, and the Session notifications it forwards to the Peer, through remote access: this package registers the share-viewer policy, which binds a served reader to read roles on the shared Session, its own forks, and the Workspaces holding them, and to fork and write roles whose conditions apply the share mode; it binds nothing else, so every other endpoint and notification is refused, and it binds nothing once the share stops serving the reader. The owner invalidates the reader's access on every grant, revocation, mode change, and expiry, and disposes the reader's Peer when the grant ends or the share stops or expires. A reader's prompt enters the Session as a user-rpc message whose source.principal names that reader; owner messages carry no principal. While any share over that Session is active, the owner host mounts its own confined replacements for the read and search surface and the no-effect tools — plus bounded edit and write when some share may write — in the Session's own scope, and a viewer-started turn may run nothing else. An owner-started turn keeps the Session's native tools, so a share never narrows the owner's own work. The pre-step records which kind of turn is running, in memory only. Each operation re-reads the shares' current Relay grants and checks the resolved target against the granted root; the pre-step re-checks every entering message's viewer against the Relay's admission before a model step, so reader input queued before a revocation never drives the model. A reader's stop of the shared Session is dispatched through the Gateway like a prompt: the policy admits it while the share's tier is established and the Session is confined, and the owner's own Session controller stops whatever turn that Session is running, the owner's included. The general Peer, principal, and remote-access design is in Peer principals and remote access.

A confined file tool resolves every path its own arguments declare, checks that the granted root contains each result, and hands the deployment's tool that canonical path; a pathless search uses the Session's working directory, which the replacement checks like a named path. A bounded edit or write performs the same containment check and then edits or writes through the filesystem backend with the Session's current sandbox policy and the normal observation policy.

Keeping one branch across retries

One fork request binds its viewer, share, source, operation identity, and completed prefix. The Owner reserves that operation durably before creating a child, and records the child the owner's fork answer returned; a retry of a recorded operation replays that answer instead of forking again. A different prefix under the same identity is refused. The owner's SessionForkRequest mints the child id, so the Host sends no child identity: a host that dies after the child was created but before the operation was recorded cannot name that child on retry and creates a new one. Closing that window needs a Session Controller request that accepts a caller-supplied child identity. The inherited prefix stops before unrelated queued input; only immediately following request metadata is retained. Revoked children keep their logs but cannot resume with broader access, and removing a share does not expose the source Session's unrestricted tools.

Who the owner is

A share can only be created by a verified owner. The dialog shows the identity the owner's DSH read back — name, expiry, when it will renew — and uses a label derived from the identity when there is no display name. The code that creates the share refuses an unverified owner as well, so the question is not settled by whether a button was clickable.

The Host binds a short-lived transaction to the Relay address, its own instance, and the origin allowed to read the result. The owner can approve the same link in any browser: the Relay holds the code for the Host to collect, so approval needs neither an opener window nor a callback to a reachable Host address. Concurrent status reads share one in-flight collection per transaction.

The Owner redeems the code with the verifier it retained, stores the credential with owner-only permissions, and sends it only to the Liveshare server address that issued it. New registration requires that verified credential; existing-share reconnect uses the share's management token, and explicit identity claim preserves the share's ACL, mode, expiry, and token. A share's named colleagues are the owner's stored selection plus the deployment's own allowlist; nothing is derived from a display identity.

What the reader sees at the top

The served page reuses the sidebar's existing brand row instead of adding a bar on top of the app: the usual Harness mark, plus a LiveShare entry that names who shared the session and which DSH version they run, with the Liveshare server's own release labeled separately. Clicking it returns to the page listing the shares you can open.

When the connection breaks

A reader's feed can fail: a stream disappears, the Liveshare server cancels a request, a read times out. The page retries only the failures that are defined as repeatable, and stops for good on authentication, permission, and missing-share errors, showing the reason instead of reconnecting forever.

How the served page is exercised

The page a viewer opens is the owner's own Web page. The Liveshare server asks the owner for its rendered index document, places a short carrier script at its top, and passes the page's shell assets and plugin bundles through from the owner, so the page runs every owner plugin at the owner's version. The carrier only turns the page's calls and streams into reads over the Liveshare server's channel; the Liveshare plugin itself recognizes a viewer page and mounts the viewer surfaces instead of the Share action. The owner renders that index with the reader's own access snapshot in place of the owner baseline, and the page then follows the reader's remoteAccess/follow snapshot; no other read carries a reader's grants.

The viewer page is tested in-process: the test assembles the page from the carrier, the shell, and the client plugins including Liveshare's, stands in for the Liveshare server's read channel, and answers the page's reads from a scripted owner, so the assertions see the real shell, carrier, and presentation plugins.

What the package exposes

The package ships one Host program and one browser face. Its public entries are the Host export (lib/index.js), ./client (lib/client.js, a closure-factory bundle), ./viewer-declarations, the share-management Remote's ./typert and ./remote faces, ./types, the bundle patch ./cordis.patch.yml, and the locale JSON files. The manifest declares the browser face as dsh.client with platform: web and the client services it needs; that face reads __DSH_LIVESHARE_VIEWER__, mounts the viewer session plugin and its brand, model, permission, session-row, and share-path surfaces on a served viewer page, and otherwise mounts the owner's generated Remote before the Session-header Share action.

The liveshareShares Typert Remote exposes the Host's share-management operations. The Share dialog uses three same-origin HTTP routes for sign-in: /api/liveshare.ownerLoginStart, /api/liveshare.ownerLoginStatus, and /api/liveshare.ownerLoginCancel. The separate /api/liveshare.ownerCredential route imports a credential; the dialog does not use it for sign-in.

The outgoing gateway is a supervised child process whose source entry is src/owner-gateway/cli.ts and whose published entry is lib/owner-gateway/cli.js; the directory name keeps it distinct from the DSH API gateway.

Alternatives considered

  • Build a separate read-only page instead of serving the normal client. Rejected: reading needs browsing, grouping, and selecting, so a second page would have to rebuild all of it and would quietly lose the navigation the product keeps.
  • Decide each button's availability where the button is. Rejected: every entry reads one access snapshot the owner computes, so a screen added later cannot quietly reintroduce an action the reader may not perform.
  • Let the reader's page decide its own access. Rejected: only the owner and the service decide what a share grants; the page states what it was told.
  • Treat an older share with no mode as writable. Rejected: that would hand a reader access the owner never configured, so a share without a mode is read-only.
  • Put the sign-in code in the page address, or read the credential from the popup's cookies. Rejected: addresses leak through history, referrers, and logs, and a page should not hold credentials.
  • Show the service's own error text when the page cannot explain a refusal. Rejected: that text may contain a file path, a credential, or another reader's session, so the page shows the stable reason it can vouch for.
  • Put execution restrictions only in editable configuration or a sandbox mode. Rejected: a child can change configuration, and per-call execution choices can outrank a mode. The real operation needs a monotonic guard and a verified implementation.
  • Check a model-supplied path only before dispatch, or globally constrain every filesystem read. Rejected: a pre-dispatch check is separated from the tool call by other listeners, while a global read rule would also constrain unrelated Owner work. The containment check runs inside the authorized Session's own read and write.
  • Reuse the deployment's default root or copy the entire source tail into a child. Rejected: both can include files or pending input the viewer was never granted.
  • Use a deployment-wide secret or self-reported display fields as owner identity. Rejected: neither identifies the logged-in person who approved this publication.
  • Keep three tiers. Rejected: view and fork-readonly differ only in whether the reader can branch and drive a child, which is already the independent fork switch. A third mode duplicates that switch and lets the two answers disagree.
  • Keep a per-share attachment-upload switch. Rejected: an attachment is part of a prompt on a Session the reader can already see. The separate switch duplicated visibility and could only subtract from it, while the upload role already rides the read role.
  • Attribute every turn to a requester and exempt the owner's own turns. Rejected after it shipped, then narrowed: persisting a turn's requester needed a Host-only projection over message sources, a turn-boundary read per execution, and a re-check of the share that admitted each turn, and it still had to fail closed on mixed or unestablished requesters. The shipped design keeps only an in-memory marker for the running turn — agent/pre-step reads the entering principals and the guard reads that answer — so an owner-started turn keeps the Session's native tools without adding a Session event. The accepted cost is that an owner's steering input inside a viewer's turn stays confined; a viewer message that reaches a later step narrows that turn.
  • Let each tool name its own tier or sandbox. Rejected: the tier belongs to the share. A per-call choice would let one execution outrank the grant that admitted it.
  • Test the bundle's enabled flag directly. Rejected: it would keep the code smallest, but the patch route starts the bundle's plugins while leaving the bundle unselected, so the card would stay hidden exactly when its plugins started, contradicting the product rule.
  • Derive effective enablement in the Host. Rejected: listBundles could report a new or redefined effective state, but that would change a cross-package contract for one client-only presentation rule and invite every bundle consumer to reinterpret enabled, which must keep meaning "selected in the profile".
  • Ship LiveShare outside the installation's optional bundles. Rejected: that would make it visible nowhere by construction, but the package must still ship as an npm package with the release and be installable, and it would also remove the bundle from the Host's list entirely, taking the details entry with it.
  • Keep the colleague picker, or replace it with a directory-backed selector. Deferred: naming a colleague needs an identity directory the Liveshare server does not provide, so the dialog cannot offer a choice it can verify. Stored selected and approval records keep working through their ACL, and the creation entry point stays retired until a directory contract exists; liveshareShares.create keeps its fields for those records and direct Remote callers, so this defers the API rather than deleting it.

Verification

  • A reader's page keeps the normal navigation, and no action the reader may not perform appears on the shared session or on any branch.
  • A DSH without the Liveshare bundle, and the owner's own page, behave exactly as before.
  • A share uses one of two tiers and that tier's sandbox; unknown modes, unreadable answers, and shares without a mode stay readable but are never driven.
  • A share cannot be created without a verified owner identity.
  • A share created from the dialog carries open; a stored selected or approval record keeps its recorded ACL and access summary, and create still stores a requested selected mode with its subjects.
  • Only the bound page origin can read the transaction result. The Host exchanges a Relay-issued code against the bound Relay and Host instance using its PKCE verifier; the Share dialog reads no login cookie and receives neither code nor credential.
  • Real Controller, ToolRuntime, filesystem, and profile tests cover fork identity, cold enforcement, bounded execution, revocation, and normal cancellation. The built viewer must use its real POST carrier and Owner authorization handler; deterministic display fixtures do not replace execution or persistence tests.
  • Generated API documentation and both SDK projections remain aligned with the user-rpc source principal, which only the agent/pre-step admission check consumes.
  • ViewerSessionMode has two members, and a persisted fork-readonly record is rejected when the owner state loads.
  • A view share drives the source Session, refuses file writes and out-of-grant reads, and can fork when allowsFork is set.
  • fileUploads/upload is allowed on every Session the reader can see, for every tier and fork combination.
  • Source tool decisions read only the Session's mounted layer: the guard permits this installation's confined replacements for the read and search surface and the no-effect tools, plus bounded edit and write on a writable Session, and refuses every other name, with no turn, requester, or origin consulted.
  • Unit and real-runtime tests cover the tier policy, confined reads and writes, fork ceilings, the layer's installation and release, and the pre-step admission check over the durable message source.
  • The plugin-manager component tests hold the bundle out of both lists while its declared rows are off, list it once a declared row runs, and still open it by bundle ID while it is hidden; the recorded goldens and the refresh card count move with that rule.

Consequences

The reader's page can only be as accurate as what the service tells it. Capability answers, the owner's identity status, the session mode, the owner's DSH version, and the sign-in endpoints all come from the owner's DSH and the Liveshare server; until those are deployed together with this layer, the page stays at its most conservative setting — read-only, with a sign-in that cannot complete — rather than guessing.

The page is not a security boundary. The owner's DSH and the Liveshare server refuse a reader's writes no matter what the page does; the access snapshot exists so the page does not offer actions that would only be refused.

Existing ACLs are retained. A record without a mode is readable but not driven, and contradictory mode fields are refused. Unattributed shares are shown as unverified history.

Owner reconnect state is atomically replaced and queued within one process, but multiple processes sharing one file can still lose updates or compete for a gateway. Cross-process execution ownership is unresolved; atomic replacement alone is not a transaction or a route claim. Containment is checked by path: a local process that replaces a directory inside the grant with a symlink between the check and the open can redirect a viewer's read, or a write elsewhere within the sandbox's writable roots. Operations anchored to a directory handle would close this window and are left to a separate change. Final viewer-artifact and SDK snapshot evidence remains required before release.

A view share is not watch-only: it runs the reader's prompts and tool calls inside the read-only sandbox. A deployment that wants a passive reader has no separate mode and must rely on the reader not sending prompts rather than on a tier name. Fork reach is the only independently switchable action; attachment upload cannot be disabled separately.

The sandbox reaches the owner's own turns too. While any share over a Session is active the owner can only read inside the granted workspace, and can write only when some share allows writing; a share that is merely published — even one nobody is using — therefore changes the owner's own tool surface until it is stopped or expires. Cancellation has no attribution either: a reader's stop ends whatever turn the shared Session is running.

The default cards list, the More page, and their recorded goldens lose one card, and the manager's refresh card count drops by one. A person who only knows the plugin page cannot discover LiveShare or switch it on from that page; the package README owns the two enable routes instead. A bundle enabled through the patch route shows its card with the switch off while its rows run, because the switch reflects the profile's bundle selection and writes that selection; the documentation states the two routes and this difference. The rule covers one explicitly named bundle rather than a manifest flag, so adding another hidden-until-running bundle, or retiring this one, is a one-line set edit with a test and docs update.

Shipped creation produces organization-link shares only: the Share dialog sends neither accessMode nor allowedSubjectIds, so every new share is open, and the deployment's LIVESHARE_ALLOWED_SUBJECTS is the only subject-level narrowing a new share can carry. Stored selected and approval records keep working and keep their access summaries, and the create fields stay on the Remote for those records and direct callers while no UI exposes them.

中文

Problem

DSH 会话跑在你自己的电脑上。同事有时需要在你工作的同时看某个会话——跟着一起排查问题,或者看看一个长任务进展到哪了。现在没有这个能力。把会话日志发过去并不等价:对方要有你的插件、配置和沙箱才能渲染出来,而且会话只有在你机器上运行时才有意义。

所以一次分享要同时解决三件事:一个同事用浏览器打开就能看的页面,看到你机器上正在跑的会话,但不需要连到你的机器;一个对页面能做什么的限制,从"能读、不能写文件"开始——页面多给一个你没同意的操作就是安全漏洞,不是便利;以及一个**"这是谁分享的"的答案**,因为说不清归属的页面,打开它的人无从信任。

这条 Note 覆盖 owner 自己 DSH 里运行的那一半——分享对话框、背后的 owner 端服务、本包的浏览器端,以及读者打开的页面——以及双方共用的协议包。中间的 Liveshare 服务端是独立的包(@deepseek-ai/dsh-experimental-liveshare-relay),单独审查与部署。

Decision

一次分享是什么

owner 在 DSH 里为某一个会话创建分享。分享发布到 Liveshare 服务端(双方都能访问的服务)后,DSH 返回一个链接。打开链接看到的是 owner 自己的 DSH 用自己插件渲染出的会话,读者不需要 owner 的配置。读者列表包含源会话,以及该读者通过分享创建的子会话。工作区名称、成员和顺序裁剪为这些会话;无关会话和工作区保持不可见。

从 DSH 分享弹窗新建的分享是组织内持链接分享:它携带 accessMode: 'open',组织内拿到链接的人都能看。部署级 LIVESHARE_ALLOWED_SUBJECTS 会并入每份分享的 ACL:对 open 分享,它把准入收窄到列出的主体;对已存储的 selected 记录,它把列出的主体加在记录自己的选择旁边。

指定同事(selected)与更早的 approval 拼写是旧版持久记录。 Host 仍按记录里的 ACL 读取它们并展示访问摘要,Liveshare 服务端仍按该 ACL 接纳它们的查看者,但随版本发布的分享弹窗不提供新建入口。liveshareShares.create 的 accessMode 与 allowedSubjectIds 字段保留给这些记录以及直接调用该 Remote 的调用方;随版本发布的弹窗两个都不发送。

读者能做什么

读者页面就是正常的 DSH 客户端,不是精简版:侧栏、会话列表、展开折叠、选择都在,因为浏览本来就是"看"的一部分。缺的只是读者无权执行的动作——创建无关会话、重命名、归档、删除、管理工作区。分支遵循分享自己的 fork 开关;发送消息在两档里都可用,并在该档的沙箱内运行;附件上传跟随读者可见的会话。管理权限与档位和 fork 开关都保持独立。

这些动作不是用 CSS 藏起来的。页面能做什么由一份访问快照决定:remote-access 客户端跟随读者自己的 remoteAccess/follow,每个按钮和菜单项经 useRemoteAccess、useAccess 或 useSessionAccess、useWorkspaceAccess 读取其端点在全局资源、某个会话或某个工作区上的答案,答案变化时重新渲染。owner 的 DSH 依据该分享的 share-viewer 策略计算快照,因此 owner 收回某项能力时,对应入口不用重新加载页面就会关闭——而且服务端本来就会拒绝这些操作,页面只是不去提供注定被拒绝的按钮。读者收到的 index 已带上读者的首份快照,因此页面在确认允许之前不会显示任何入口;快照流失败后,所有答案都为拒绝。owner 自己的页面以 owner 基线打开,行为与普通 DSH 完全一致。快照不包含逐会话的拒绝原因:页面陈述页面级原因(分享模式、停止、过期、失去访问权)和通用的只读文案。拿不到分享正文时,页面顶部直接陈述该状态,并且每一档都给出读者自己能做的动作(重试、重新登录、回到分享列表,或明确指引联系分享者),不会停在空白外壳或错误码上。

两档驱动

每个分享带一个 ViewerSessionMode,只有两个值,且两档都会驱动共享会话:

  • view —— 读者通过普通 prompt 路径驱动共享会话的 loop,在授予工作区的只读沙箱里运行,因此会话的工具绝不写文件。读取与检索面(read、read_image、glob、grep、present)、无本地文件副作用的工具(todo_write、skill、web_search、web_fetch)都限制在授权范围内:工具运行前检查其声明的每个路径,无法检查的调用一律拒绝。两档也都准入 PTC 传输工具 run_code:程序运行在所有者自己的常驻文件策略下而不是分享档位下,因此可以触碰授权范围之外的文件,而其嵌套调用仍保留同样的守卫与路径检查;分享对话框会就此向所有者提示。
  • write —— 读者在受宿主写入上限约束的可写沙箱里驱动同一个 loop,沙箱也会修改授予工作区内的文件。

沙箱安装在会话上,但只约束分享查看者发起的轮次:agent/pre-step 记录一个已准入轮次的进入输入是否带有 share-viewer principal,守卫与替代定义对该轮次的每次执行读取这一结论。所有者自己发起的轮次保留会话自己的工具;所有者在查看者轮次中追加的输入仍留在该受限轮次内。该标记只存在于 Host 内存,按轮次重算,不写入会话日志。所有分享停止或全部过期后执行层被释放,会话恢复自己的工具。

较早的词汇有三档——view 只观看、fork-readonly 分支、write 可写。view 与 fork-readonly 只差在读者能否分支并驱动子会话,而这已经由分享自己的 allowsFork 开关决定;第三档重复了该开关,还会让两处答案互相矛盾,因此由两档驱动取代。

fork 不是一档。分享自带独立的 allowsFork 开关,与档位无关:view 分享可以允许 fork,write 分享也可以拒绝。fork 创建的子会话归读者所有,带有自己的只读或可写上限,源会话保持不变。

附件上传既不是一档,也不是一个开关。fileUploads/upload 随读角色授予,因此分享向读者提供的每条会话都接受文件;只由可见性决定,所有者没有单独的附件开关。

本版本不认识的模式、以及宿主无法确定模式的持久记录,都不会被驱动:分享仍可读取,页面会说明它无法确定什么。已退场的 fork-readonly 名称不会读回为 view;持久化的 owner 记录若写有该值,owner 状态加载时会直接拒绝。

沙箱是会话的属性,但按轮次生效:Host 在内存中记录运行中轮次的已准入输入是否带有 share-viewer principal,只约束该轮次,把所有者发起的轮次留在会话原生工具上。此前上线的实现限制每个轮次(包括所有者的),虽不需要读取轮次,却让分享改变了所有者自己的工作方式。持久化轮次请求者被否决:那需要从已提交消息来源折叠的投影、每次执行读取 turn boundary、并与接纳该轮次的分享保持同步,而且在混合或无法确立请求者时仍必须默认拒绝。内存标记让守卫与替代定义对每次执行读取同一个结论,且不新增会话事件;重启后从下一个准入步骤重新计算,被拒绝或从未准入的步骤不留下标记。

默认可见性

本包作为运行时依赖随每个 dsh 安装一同交付,但默认安装必须在插件管理器里完全不显示它:内置插件配置下不显示,实验性插件下不显示,更多页也不显示。用户主动启用它——在当前 profile 的 cordis.patch.yml 中插入组合包的行,或在 dsh.profile.bundles 中选中该组合包;两条启用路径由包 README负责。该包仍必须随版本发布、保持可安装,且在此规则之前已启用的用户继续能看到它。

Host 的组合包 enabled 标志表示 profile 是否选中了这个组合包,这与它的插件是否在运行并不等价:通过 cordis.patch.yml 插入组合包的行会让插件运行,而组合包本身仍未选中;因此以 enabled 为准的可见性规则会把用户刚刚启用的组合包隐藏起来,使写入文档的启用路径失效。

因此管理器维护一个 HIDDEN_UNTIL_RUNNING 组合包名集合——当前只有 @deepseek-ai/dsh-experimental-liveshare——集合中的组合包只有在它 patch 声明的行至少有一条在运行时才会被列出(pkg.rows.some(row => row.enabled))。过滤发生在两个列表派生之前,因此在满足条件前,它不会出现在主"实验性插件"组、更多页、内置插件配置和"已安装插件"组中。该集合是 PluginManagerPage.tsx 中的客户端数据;Host 的 listBundles 契约、profile 格式和已安装包集合都保持不变。BundleInfo.rows 已把每条声明的行与当前承载它的 Loader 条目关联起来,客户端的 PackageView 携带该条目是否在运行,因此行状态就是两条启用路径的有效答案:删除这些行、把它们置为 disabled,或取消选中组合包,都会让它们停止运行,卡片随之从两个列表消失。

卡片隐藏期间组合包 ID 仍可按 ID 打开:openPkg 会从未过滤的 Host 组合包列表中解析隐藏的组合包,因此 pluginNavigation.openBundle('@deepseek-ai/dsh-experimental-liveshare') 仍能渲染其详情。其它按 ID 链接组合包的界面因此继续可用,组合包页也像其它未选中组合包的页面一样列出各行及其关闭状态。

分享工作如何限制在授权范围内

Owner 而不是查看页或 Liveshare 服务端授权每次会话操作。子会话必须先安装真实作用域工具限制,才能接受消息,冷恢复后也一样:宿主机从基础 agent/created 事件安装该限制。该监听器运行时智能体已登记进注册表,但创建尚未完成,AgentLoop 会扣住其排队输入,且监听器抛错会使创建失败,因此被拒绝的限制仍能阻止任何消息。宿主机服务缺失或安装失败都会拒绝子会话;配置开关、工具名或稍后安装的承诺都不是执行限制。

共享源会话仍可服务所有者自己的工作。每次读者调用都以「该分享与该读者」专属的 Peer 经所有者自己的 Connection 与 Gateway 分派,该 Peer 的 share-viewer principal(分享 ID 与服务端断言的身份三元组)由所有者进程内代码在创建 Peer 时确定,任何线路字段都无法改变它。Gateway 经 remote access 判定该 Peer 的调用以及转发给它的会话通知:本包注册 share-viewer 策略,把受服务的读者绑定到共享会话、其自己的 fork 及包含它们的工作区上的读取角色,以及条件按分享模式判定的 fork 与写入角色;除此之外不做任何绑定,因此其它端点和通知一律被拒绝,分享不再服务该读者后也不再有任何绑定。所有者在每次授权、撤权、模式变化与过期时使读者的访问失效,并在授权结束、分享停止或过期时释放读者的 Peer。读者的提示词以 user-rpc 消息进入会话,其 source.principal 指明该读者;所有者的消息不带 principal。只要该会话还有分享活跃,所有者 Host 就在会话自身作用域内挂载读取与检索面与无副作用工具的受限替代,以及(某个分享允许写入时)有界 edit 与 write,查看者发起的轮次只能运行这些。所有者自己发起的轮次保留会话原生工具,因此分享不会收窄所有者自己的工作。pre-step 只在内存中记录当前轮次属于哪一类。每次操作都会重新读取分享当前的 Relay 授权,并按授予根目录检查解析后的目标;pre-step 在模型步骤前按 Relay 准入重新检查每条进入消息的查看者,因此撤权前排队的读者输入永远不会驱动模型。读者对共享会话的停止与提示词一样经 Gateway 分派:策略在分享档位确立且会话受沙箱限制时放行,随后由所有者自己的会话控制器停止该会话当前运行的轮次,包括所有者发起的轮次。通用的 Peer、principal 与 remote access 设计见 Peer principal 与 remote access。

受限文件工具解析其自身参数声明的每个路径,检查获授根目录包含解析结果,再把规范路径交给部署的工具;无路径的搜索使用会话工作目录,由替代定义按命名路径一样检查。受限编辑或写入执行同样的包含检查,然后按会话当前沙箱策略和正常观察策略经文件系统后端编辑或写入。

重试时保留同一个分支

一次 fork 请求绑定查看者、分享、源会话、操作身份和已完成前缀。Owner 在创建子会话前持久化预留该操作,并记录 owner 的 fork 应答返回的子会话;重试已记录的操作会重放该应答,而不是再次 fork。同一身份指定不同前缀会被拒绝。owner 的 SessionForkRequest 自己生成子会话 id,因此 host 不发送子会话身份:若 host 在子会话已创建、但操作尚未记录时退出,重试无法指名该子会话,会再创建一个。要关闭这一窗口,需要 Session Controller 的请求接受调用方提供的子会话身份。继承前缀停在无关排队输入之前;只保留紧随其后的请求元数据。被撤销的子会话保留日志,但不能以更宽权限恢复;移除分享不会暴露源会话不受限制的工具。

owner 是谁

只有已验证的 owner 才能创建分享。对话框显示 owner 的 DSH 回读到的身份——名字、有效期、何时续期——没有显示名时用身份派生出来的标签。创建分享的代码本身也会拒绝未验证的 owner,不是只看按钮能不能点。

Host 将短期事务绑定到 Relay 地址、Host 自身的实例和获准读取结果的页面来源。所有者可以在任意浏览器中打开同一个链接完成授权:Relay 保留授权码供 Host 取回,授权既不依赖打开登录页的窗口,也不要求浏览器能回调 Host 地址。同一事务的并发状态查询共用一次进行中的取码请求。

Owner 使用自己保留的校验值兑换代码,以仅所有者可读写的权限保存凭据,并只向签发它的 Liveshare 服务端地址发送。首次登记需要已验证凭据;已有分享重连使用分享管理 token,显式身份认领保留该分享的 ACL、模式、过期时间和 token。分享指定的同事是 owner 的存储选择加上部署自身的允许列表;不会从显示身份派生任何内容。

读者页面顶部显示什么

被服务的页面复用侧栏原有的品牌行,而不是在应用上再压一条横条:原本的 Harness 标记,加上一个 LiveShare 入口,写明是谁分享的、对方跑的是哪个 DSH 版本(Liveshare 服务端自己的 release 另行标注)。点击它回到"我能看的分享"列表页。

连接断开时

读者的数据流可能失败:流消失、Liveshare 服务端取消请求、读取超时。页面只重试定义上可重复的失败;遇到认证、权限与分享不存在的错误就直接停下并显示原因,不会无休止地重连。

服务出去的页面怎么测

读者打开的页面就是 owner 自己的 Web 页面。Liveshare 服务端向 owner 要渲染好的 index 文档,在最前面插入一段很短的 carrier 脚本,页面的 shell 资源和插件 bundle 也从 owner 透传过来,所以页面跑的是 owner 版本的全部插件。carrier 只把页面的调用和流转成 Liveshare 服务端通道上的读请求;由 Liveshare 插件自己识别 viewer 页,挂上 viewer 界面,而不是分享按钮。owner 渲染这份 index 时用读者自己的访问快照取代 owner 基线,页面随后跟随读者的 remoteAccess/follow 快照;其他读请求都不夹带读者的授权。

读者页面在进程内测试:测试用 carrier、shell 和包括 Liveshare 在内的 client 插件拼出页面,顶替 Liveshare 服务端的读通道,并用脚本化的 owner 回答页面的读请求,因此断言看到的是真实 shell、carrier 与呈现插件。

本包对外提供什么

本包交付一个 Host 程序和一个浏览器端。公开入口包括 Host 导出(lib/index.js)、./client(lib/client.js,closure-factory bundle)、./viewer-declarations、分享管理 Remote 的 ./typert 与 ./remote 两个面、./types、组合包 patch ./cordis.patch.yml,以及 locale JSON 文件。manifest 以 dsh.client 声明浏览器端,platform 为 web,并列出它需要的客户端服务;该入口读取 __DSH_LIVESHARE_VIEWER__:在被服务的查看页上挂载查看页 session 插件及其品牌、模型、权限、会话行与分享路径界面,否则先挂载 owner 生成的 Remote,再挂载 Session 头部操作。

liveshareShares Typert Remote 提供 Host 的分享管理操作。分享对话框使用三条同源 HTTP 登录路由:/api/liveshare.ownerLoginStart、/api/liveshare.ownerLoginStatus 和 /api/liveshare.ownerLoginCancel。独立的 /api/liveshare.ownerCredential 路由用于导入凭据,分享对话框登录不调用它。

出站网关是受监督的子进程,源码入口为 src/owner-gateway/cli.ts,发布入口为 lib/owner-gateway/cli.js;目录名让它与 DSH API gateway 明确区分。

Alternatives considered

  • 单独做一个只读页面,不服务正常客户端。 否决:阅读需要浏览、分组与选择,另做一个页面就得把这些全部重建,还会悄悄丢掉产品要保留的导航。
  • 每个按钮各自判断能不能点。 否决:每个入口都读取 owner 计算的同一份访问快照,后加的界面才不会悄悄重新引入读者无权执行的动作。
  • 让读者页面自己决定权限。 否决:分享授予什么,只由 owner 与服务端决定;页面只陈述被告知的结果。
  • 把没有模式字段的旧分享当作可写。 否决:那会把 owner 从未配置的权限交给读者,因此没有模式的分享一律只读。
  • 把登录 code 放进页面地址,或从弹窗的 cookie 读凭据。 否决:地址会经浏览历史、referrer 和日志泄漏,页面也不应该持有凭据。
  • 页面解释不了某个拒绝时,直接展示服务端的错误原文。 否决:那段文本可能包含文件路径、凭据或别的读者的会话,所以页面只显示它能担保的稳定原因。
  • 只在可编辑配置或沙箱模式中写执行限制。 否决:子会话能够改变配置,而逐调用执行选择可能优先于模式。真实操作必须经过单调拒绝的守卫和已验证实现。
  • 只在分派前检查模型路径,或全局限制所有文件系统读取。 否决:分派前检查与工具调用之间还隔着其他监听器,而全局读取规则还会限制无关 Owner 工作。包含检查在已授权会话自身的读写中执行。
  • 复用部署默认根目录,或把源会话整个尾部复制到子会话。 否决:两者都可能包含查看者未获授的文件或待处理输入。
  • 以部署共享密钥或自报显示字段作为所有者身份。 否决:两者都不能识别批准本次发布的已登录人员。
  • 保留三档。 否决:view 与 fork-readonly 只差在读者能否分支并驱动子会话,而这已经是独立的 fork 开关。第三档重复了该开关,还会让两处答案互相矛盾。
  • 保留分享级的附件上传开关。 否决:附件是读者已经能看到的会话上的一条 prompt 的一部分。单独的开关重复了可见性,且只能从可见性里做减法,而上传角色本来就随读角色授予。
  • 按轮次归属请求者并让所有者轮次豁免。 上线后否决,之后缩小范围:持久化轮次请求者需要仅 Host 可见的消息来源投影、每次执行读取 turn boundary、重新检查接纳该轮次的分享,而且在混合或无法确立请求者时仍必须默认拒绝。现在的实现只为运行中轮次保留内存标记——agent/pre-step 读取进入消息的 principal,守卫读取该结论——因此所有者发起的轮次保留会话原生工具,且不新增会话事件。接受的代价是:所有者在查看者轮次中追加的输入仍留在受限轮次内;查看者消息若进入后续步骤,会立即收窄该轮次。
  • 让每个工具自行声明档位或沙箱。 否决:档位属于分享。逐调用选择会让某次执行凌驾于批准它的授权之上。
  • 严格的 manifest 选中判断。 否决:直接判断 pkg.enabled 代码最少,但默认安装启用 LiveShare 的唯一文档路径是编辑 cordis.patch.yml,那不会让组合包被选中。卡片会在插件恰好开始运行时仍然隐藏,与产品规则矛盾。
  • 在 Host 派生有效启用状态。 否决:listBundles 可以以新字段或改写字段报告有效状态,但这会为一条纯客户端的展示规则改动跨包契约,并诱使每个组合包消费方重新解释 enabled——它必须继续表示"profile 已选中"。
  • 把 LiveShare 移出安装随附的可选组合包。 否决:将它从可选集合移除即可从构造上让它处处不可见,但该包仍需随版本作为 npm 包发布并可安装,而且这会把组合包从 Host 列表中完全移除,详情入口也会随之消失。
  • 保留选人器,或换成由目录支撑的选择器。 推迟:点名同事需要身份目录,而 Liveshare 服务端目前不提供;弹窗无法给出它能验证的选择。已存储的 selected 与 approval 记录仍按 ACL 工作,在有目录契约之前新建入口保持退役;liveshareShares.create 的字段保留给这些记录与直接调用方,所以这是推迟 API,而不是删除它。

Verification

  • 读者页面保留正常导航,且在共享会话与任何分支上都不会出现读者无权执行的动作。
  • 没有 Liveshare bundle 的 DSH 以及 owner 自己的页面,行为与以前完全一致。
  • 分享使用两档之一及该档的沙箱;未知模式、读不懂的应答、没有模式的分享仍可读取,但绝不会被驱动。
  • 没有已验证的 owner 身份,就无法创建分享。
  • 弹窗创建的分享携带 open;已存储的 selected 或 approval 记录保留记录中的 ACL 与访问摘要,create 仍会存储调用方请求的 selected 模式及其主体。
  • 只有与事务绑定的页面来源才能读取结果。Host 核对绑定的 Relay 和 Host 实例,用自己的 PKCE 校验值兑换 Relay 签发的授权码;分享对话框不读取登录 cookie,也不接收授权码或凭据。
  • 真实 Controller、ToolRuntime、文件系统和 profile 测试覆盖 fork 身份、冷恢复限制、有界执行、撤权和正常取消。已构建查看页必须使用真实 POST 载体和 Owner 授权处理器;确定性显示 fixture(测试前置数据)不替代执行或持久化测试。
  • 生成的 API 文档和两种 SDK 投影与 user-rpc 来源 principal 保持一致;该字段只由 agent/pre-step 准入校验消费。
  • ViewerSessionMode 只有两个成员;持久化的 fork-readonly 记录在 owner 状态加载时被拒绝。
  • view 分享驱动源会话,拒绝文件写入与越界读取,并在设置 allowsFork 时可以 fork。
  • 对读者可见的每条会话,无论档位与 fork 开关如何组合,fileUploads/upload 都被允许。
  • 源会话的工具决策只读取会话上挂载的执行层:守卫放行本次安装的读取与检索面与无副作用工具的受限替代,可写会话下另有有界 edit 与 write,拒绝其它所有工具名,不读取轮次、请求者或来源。
  • 单元测试与真实运行时测试覆盖档位策略、受限读写、fork 上限、执行层的安装与释放,以及基于持久消息来源的 pre-step 准入校验。
  • 插件管理器的组件测试在声明行全部关闭时把该组合包排除在两个列表之外,在声明行有一条运行后列出它,并在它隐藏时仍能按组合包 ID 打开;录制的 golden 与刷新卡片数随该规则变化。

Consequences

读者页面只能准确到服务端告诉它的程度。能力回答、owner 身份状态、会话模式、owner 的 DSH 版本、登录端点,都由 owner 的 DSH 与 Liveshare 服务端提供;在与本层一起部署之前,页面保持最保守的状态——只读,且登录无法完成——而不是去猜。

页面不是安全边界。无论页面做什么,owner 的 DSH 与 Liveshare 服务端都会拒绝读者的写入;这份访问快照的作用只是让页面不去提供注定被拒绝的按钮。

已有 ACL 保持不变。无模式记录仍可读取,但不会被驱动;互相矛盾的模式字段被拒绝。没有归属的分享显示为“未验证历史”。

Owner 重连状态以原子替换写入,并在单进程内排队,但多个进程共享一个文件仍可能丢失更新或争用网关。跨进程执行归属尚未解决;原子替换本身不是事务或路由认领。包含关系按路径检查:若本地进程在检查与打开之间把获授范围内的目录换成符号链接,可以让查看者的读取改指别处,或让写入落到沙箱可写根内的其他位置。基于目录句柄锚定的操作可以消除这一窗口,留待单独变更引入。发布前仍需完成查看页产物和 SDK 快照验证。

view 分享不是"只看":它会在只读沙箱里运行读者的 prompt 与工具调用。想要被动观看的部署没有单独模式,只能依赖读者不发送 prompt,而不能依赖档位名称。fork 是唯一可独立关闭的动作;附件上传无法单独关闭。

沙箱同样作用于所有者自己的轮次。只要某会话还有分享活跃,所有者也只能在授予工作区内读取,且只有在某个分享允许写入时才能写入;因此一条仅仅发布、并没有人在用的分享也会改变所有者自己的工具面,直到它停止或过期。取消同样没有归属:读者的一次停止会结束共享会话正在运行的任何轮次。

默认卡片列表、更多页及其录制 golden 各少一张卡片,管理器的刷新卡片数也减一。只认识插件页的人无法从该页发现 LiveShare 或直接开启它;启用路径由包 README 负责。通过 patch 路径启用的组合包,其卡片显示为关闭状态而行在运行,因为开关反映并写入 profile 的组合包选中状态;文档会说明两条路径及其差异。该规则覆盖一个显式命名的组合包而不是 manifest 标志,因此新增另一个"运行前隐藏"的组合包或退役这一个,都只是一行集合改动,并配一条测试和文档更新。

随版本发布的创建流程只产生组织链接分享:分享弹窗不发送 accessMode 与 allowedSubjectIds,因此新分享一律为 open,部署级 LIVESHARE_ALLOWED_SUBJECTS 是新分享唯一能获得的主体级收窄。已存储的 selected 与 approval 记录继续工作并保留访问摘要;liveshareShares.create 的字段仍留在 Remote 上供这些记录与直接调用方使用,而界面不暴露它们。