* feat(liveshare): open reader capabilities the share can serve (cherry picked from commit 3c893b488900fff776a21eebee4eb2d95b878764) * feat(liveshare): let a reader run the session's slash commands (cherry picked from commit ae02bcc0f819e55ebf066de7581d4d89994930a4) * fix(liveshare): allow a reader to list the workspace file references (cherry picked from commit fffaa864b9d790a0aab30da639d5ef50ff8f303c) * fix(liveshare): bind the job endpoints to their session resource (cherry picked from commit 357d1f6efe5b161a4ce1b616e66599c4e75a6ab1) * chore: refresh the Cordis surface catalog (cherry picked from commit 88f88b225f0fcff0a5a88f09b0f555749dd62756) * test(job-controller): read the Session resources the Remote methods declare The job roster, the follow stream, and a kill each declare the request's Session as the resource they touch, and an unowned job's follow names none. Read those declarations off the mounted Controller and pin what they answer. (cherry picked from commit fa3f92427a6bd56ad2a949dc74315505cb75533b) * feat(liveshare): offer a shareable core component to viewers The terminal controller reaches the catalog from a core profile bundle, which the catalog excludes so no application plumbing is offered. Mark such a component shareable: PluginMetadata gains the mark, and the host names the packages that carry it, so a marked core component enters the catalog and every other core component stays out. The terminal namespace leaves the exclusion list for the same reason, and the marked component carries the title its dialog row shows. (cherry picked from commit b0e9e390719aab519fd82cf39c85c60e4f77b588) * fix(liveshare): classify the terminal methods as owner-selected The nine terminal methods leave owner-only for plugin-offered: the owner picks them in the share dialog, no reader role grants one, and a share that names none still refuses every terminal call. (cherry picked from commit 718c1b45a1b01320cbe9be46ece9deca37225fe2) * docs(liveshare): state that terminals open per method Terminals are no longer unconditionally owner-only: the share dialog offers the terminal controller's methods and opens none until the owner picks them. (cherry picked from commit 505c1193571b16431731f69bd5ca1b59a1059a13) * test(liveshare): cover a viewer reaching the Session's terminals The end-to-end case mounts a real terminal controller beside the share host: the catalog offers it as a shareable core component, a share that selects nothing refuses every terminal call, and a selected terminal/create through the reader's own Peer binds the shell to the Session its agentId names. (cherry picked from commit 25955a936dc5b58ebfd8e1d24f495d62d59f7b70) * fix(workspace-files): confine non-owner reads to the session workspace A non-owner Peer now reads and watches files only inside the connected Session workspace. stat, read, readBytes (including baseFile) and changes resolve the target canonically and refuse an outside one with workspace-file/outside-workspace before reporting its kind. Owner and trusted in-process callers keep the filesystem read authority. (cherry picked from commit 7ae855e12ba6c5bc99c7ae75d65d984661f3bbb5) * refactor(workspace-files): name the file access confinement Replace the contain boolean with a named FileConfinement carried by the service, and move the outside-workspace refusal into one helper shared by file reads and watches. No Remote interface or behavior changes. (cherry picked from commit 1c4dbd68220df7c559f84cf2782f9626c5b2ef4b) * refactor(workspace-files): name the path mode PathScope Replace the FileConfinement/confinement vocabulary with PathScope, and rename its module and test. The values and behavior are unchanged. # Conflicts: # packages/api/workspace-files/src/index.ts # packages/api/workspace-files/tsconfig.host.json (cherry picked from commit 5d3f7b31dc6a1dbcf44c5fdd59295402bf40cf76) * refactor(workspace-files): accept several workspace roots in the path check The confinement helper and change feed now take several resolved roots; the current scope still supplies one. WorkspaceFileScope.workspaceRoot remains the primary root, so a future multi-workspace Session can add optional roots without changing endpoint signatures, path arguments, or the client address. (cherry picked from commit 73fd59be92c421c378b7fe5606d8d7c5806b13cb) * fix(workspace-files): keep the multi-root watch check covered Pass the primary watch root separately and iterate the roots list, so the feed keeps full coverage for the multi-root preparation. Add braces to the multi-root test arrow for the lint rule. (cherry picked from commit 1286aac6a6d93e693dbb33f2feaa71e6252424e0) * test(workspace-files): assert a refusal never reports the target kind The outside-workspace failure carries only the path, so a share reader learns nothing about what it was refused. stat, read, readBytes, list, and a relative escape are each asserted not to carry a kind. (cherry picked from commit a9495de0ff63a1aac325d1cb62b8111c188ae8a5) * test(workspace-files): keep the search caps in the shared harness config Rebasing over the search endpoint left configOf() without the search limits the master harness passed inline, so every search call reached the subprocess provider with an undefined graceMs. configOf and peer() now take Caps and supply the suite defaults. (cherry picked from commit 70cecb9b352ce5c1e17482429b1539483e101d60) * docs(workspace-files): describe the read confinement against the search-era structure The master README added the search section and rewrote the file-read checks without a workspace-containment check. Those paragraphs now state which caller the check applies to, the change feed mentions the non-owner watch, and the source map lists path-scope.ts. Bilingual hashes re-recorded with verify-translation-pairing --write. (cherry picked from commit e61fdabaf2fb9b0c0bc507ef5ceea0f213f70683) * fix(liveshare): keep workspaceFiles/search in the reader session-read role The classification table is the single source for POLICY_DECIDED_ACTIONS, so the new search endpoint must also appear in the read role's actions. (cherry picked from commit 665093b07cfee87be105fdc71a7d58fe25974788) * docs(catalog): regenerate the client and config catalogs Removing the viewer share-path tab drops its client slot entry, and the workspace file import shifts the Config source line. (cherry picked from commit 7bb9295a18b011971b4338171a60d16ff82eebd1) * docs(catalog): regenerate the config catalog source line (cherry picked from commit 2d98a59afc8aa6e2a9ac268d4446bcd8cd5eeb26) * fix(liveshare): let share readers preview workspace files The served page keeps the shipped Sidebar and now reads the shared Session workspace through workspaceFiles: stat, read, readBytes, list and changes join the Session read role, while the file service confines every non-owner read to that workspace root. The viewer tab type that answered each file address with "a share hands over paths, not contents" is removed, so the shipped document preview opens the file. Refs #7901 (cherry picked from 5e0ceac3faa)(partial: liveshare files only) * fix(ui-jobs): offer the stop control only with job/kill access (cherry picked from commit 804956ece9c09b2fac6180cd78da7aa7393ae0de) * fix(ui-chat): attribute a reader's steering row while it is pending Chat declared the message-source seat on the user node registration, so an admitted steering row rendered the shared bubble without asking for it and a Host-pending steering occurrence carried no source to ask with. Move the seat to the flow: it renders user rows, admitted steering rows, and pending steering occurrences, and hands the same renderer to each. Liveshare's selector now elects a share-viewer source of either kind, so a reader's interjection states its author from the moment it is sent. (cherry picked from c802aef8392)(partial: liveshare client files only) * docs(liveshare): state when a reader's interjection shows its author A local submission echo carries no source, so the author line appears once the Host records the input in the Inbox, not when the reader sends it. (cherry picked from 42001b1294d)(partial: liveshare client files only) * docs(liveshare): describe the seat source arriving as row props (cherry picked from commit 466e25328c5c42c792bfb30bba05ff790259bf99) * fix(liveshare): refuse /permission to share readers The commands executor runs a command handler inside the owner Host with no reader-specific narrowing, so a reader line such as `/permission danger-full-access` left the shared Session unconfined with no approval. The read role's condition now parses the `commands/execute` line and refuses the owner-only command names, starting with `/permission`, with the new `command-owner-only` reason the viewer page classifies. Every other command keeps following visibility. * feat(permission-presets): add the permissionPresets/set Remote The `/permission` command switches a Session's sandbox mode and approval policy inside the owner Host's own handler, which gives a share reader that reaches `commands/execute` no endpoint decision to meet. The switch now has a Remote face: `permissionPresets/set` names the Session it writes as its `session` resource, so the Gateway decides who may call it before any preset is resolved or any knob changes. The request carries the Session id and the preset name only. An unknown preset and a Session this process does not hold live both refuse with `gateway/bad-request` before writing. The call reports the selection the Session reads back after the switch. The command reaches the same switch, keeping its ordering and its `success` and `error` text. Because a Remote parameter cannot carry an Agent, the command supplies the approval write itself so its model-visible policy notice still follows the switch. Co-Authored-By: DeepSeek Harness <[email protected]> * fix(liveshare): classify permissionPresets/set owner-only The new preset endpoint writes the source Session's sandbox mode and approval policy, so no share reader role may reach it at any tier. The viewer endpoint classification records it as owner-only, and the viewer access policy spec proves a reader is refused on the shared Session, on its own forks, and on a Session outside the share, and that no reader grant carries the action. The owner-only command whitelist stays as the second defense: the commands handler runs inside the owner Host, so a reader line must not depend on that handler continuing to route through the endpoint. Co-Authored-By: DeepSeek Harness <[email protected]> * test(liveshare): keep every permission preset endpoint owner-only The classification table's completeness gate proves a new generated endpoint has a row, but not that the row keeps a reader out. This case reads the table and fails when any `permissionPresets/*` endpoint is classified as anything other than owner-only, so an endpoint added there without its class checked turns the suite red instead of widening a reader's reach. Co-Authored-By: DeepSeek Harness <[email protected]> * docs(catalog): regenerate for the preset set Remote The new `permissionPresets/set` Remote adds its signature and its request type to the generated service and type catalogs, maps the request type to the permission presets subsystem page, and shifts the permission preset config source line. The permission presets subsystem pages describe the write path and its Remote face on both sides. Co-Authored-By: DeepSeek Harness <[email protected]> * test: construct SessionId values and keep the approval notice lock The rebased specs called SessionId as a value while importing it as a type, so every case threw ReferenceError. Construct the ids the way the packages already do, and keep the /permission case that locks the single model-visible approval notice. * test(liveshare): load the terminal controller without a built artifact The spec resolved a generated typert artifact at module load, so a clean checkout failed before any case ran. * docs(liveshare): state the reader limits the review asked about Marks the answer path's dependence on timed asks, records that @ mentions list every host session, and explains which commands stay owner-only. * feat(liveshare): let a viewer manage the goal of a visible Session The goal is Session data, not the workspace sandbox, so the same visibility rule that already covers goals/get and goals/edit applies to create, pause, resume, complete and clear. The /goal command reaches the same service, so the endpoint and the command now agree. # Conflicts: # packages/experimental/liveshare/README.i18n.yaml * fix(liveshare): keep the terminal component titles The shareable mark's localized titles were spread onto the metadata record, which put `en` and `zh` at the top level instead of in the `titles` field the catalog reads. A core bundle without display metadata therefore offered the terminal with no product name at all. * fix(workspace-files): decide the path scope before stat A non-owner read probed the path with `lstat` before it checked containment, so reading an absent path outside the workspace answered `not-found` while an existing one answered `outside-workspace`. That let a share reader probe whether any path on the owner's machine exists. Every confined read now resolves and confines its target first: `read`, `stat`, `readBytes` (including a path relative to a base file) and `list`. The final `lstat` still reports the component's own kind, and the owner keeps the filesystem's authority, including its previous answer for an absent path. * docs(liveshare): drop the queue-verb mention `session/updateQueue` is not in the viewer Session read role, and viewer queue management is not part of this change. The role's rationale now names the reach it actually carries, and the workspace file actions no longer leak whether a path outside the workspace exists. * test(liveshare): describe the terminal suite's actual coverage * chore: regenerate the catalogs the viewer capability change moves session-reference, user-questions and the permission presets all feed the Cordis, persistence and doc-graph generators, so their artifacts were stale. * fix(liveshare): keep the command refusal copy paired and cover the file paths The English notice read "/permission on", which the locale gate tokenised together while the translations kept the command alone. The workspace-file and preset paths the coverage lane flagged now have cases of their own. * test(workspace-files): accept either refusal code for a UNC base Windows resolves an unreachable UNC host through the local backend's ancestor walk, which reports an IO failure instead of the not-found POSIX reads. Both refuse the read; the code belongs to that backend, not to the path-scope decision this case covers. * refactor(liveshare): leave the command surface to its own change Running a slash command is a separate decision from what a reader may read: the executor wraps several capabilities in one opaque call, so the endpoint that admits it is not the place to decide them. This change keeps the reader capabilities and the preset endpoint, and returns the command wiring when the command surface itself is reshaped. * refactor(liveshare): leave the workspace file preview and terminal grant out Reading a Session's data and reaching into the owner's workspace or shell are different promises: the first follows visibility, the second changes what the owner's machine does. This change keeps the reader capabilities that describe Session data and returns the other two for their own discussion. * refactor(jobs): let the session resolver name the job endpoints' Session The session resource resolver already reads a top-level sessionId, so the explicit readers restated what it derives. Removing them keeps one rule for how a Session resource is named. * test(liveshare): drop the workspace preview stubs the strip left behind The viewer shell no longer opens workspace files, so the fixture route and the assertion about it no longer describe anything. * fix(jobs): bind the job endpoints to the Session they name The session resolver reads a top-level sessionId, but these methods take a request object and no lookup parameter, so the request fell through to the global resource and a reader was refused. The explicit readers state the Session the Gateway must authorise. * refactor(jobs): let the session resolver name the job endpoints' Session The session controller's resolver already reads the sessionId of the first object argument, so an explicit reader on these methods restated a rule the Gateway already applies. The tests now install the session controller and assert the resource the production composition produces. * refactor(session-controller): take the resolve input as one argument An exported function cannot destructure its parameters, because the JSDoc gate names them one by one. * docs(liveshare): describe the capabilities this change actually opens The workspace file preview, the terminal grant and the command surface moved out of this change, so the package reference and the PR description now state what remains. * docs(persistence): refresh the catalog after the preset JSDoc edit The permission-presets module doc grew a line, so the recorded source line for its persisted event moved from 60 to 61. --------- Co-authored-by: DeepSeek Harness <[email protected]>
12 KiB
Permission Presets
English | 中文
The permission-preset layer of dsh-permission-presets (ctx.permissionPresets, PermissionPresetService) bundles the two independent enforcement knobs — sandbox mode (sandbox/mode) and approval policy (approval/policy) — into named presets a client offers as one Permissions selector. The configured table owns future-session defaults, while the fixed registerAuto(admit) hook lets the Auto review integration publish its current-session-only option for one effect lifetime. The layer is optional and owns no execution policy: prompt narration and replay keep reading their knob folds, while Auto review owns the additional enforcement. The package README owns composition status and limitations; the historical sandbox switching design records the original knob rationale.
Source: packages/interaction/permission-presets/src/index.ts
The preset table
A preset maps one stable key to a sandbox/approval bundle plus optional client presentation. The default configured table ships workspace-write (workspace-write + ask) and danger-full-access (danger-full-access + never); custom and auto are reserved and cannot be configured.
/** One preset's sandbox/approval bundle and optional client presentation. */
interface PresetSpec {
/** The `sandbox/mode` value the preset writes through. */
sandbox: SandboxMode
/** The `approval/policy` value the preset writes through. */
approval: ApprovalPolicy
/** The display label a client shows for this preset; the raw table key when omitted. */
name?: string
/** One user-facing sentence on what the preset means; omitted when not configured. */
description?: string
}
/** The {@link PermissionPresetService} config: preset table and composition default. */
interface Config {
/**
* The preset table: name → knob bundle. Defaults to `workspace-write`
* (workspace-write + ask) and `danger-full-access` (danger-full-access +
* never). The names `custom` and `auto` are reserved for derived state and
* the Auto review integration respectively.
*/
presets: Record<string, PresetSpec>
/**
* Default for new sessions. When omitted, the preset matching the composed
* sandbox and approval defaults is used.
*/
defaultPreset: Volatile<string | undefined>
}
The service requires a confining ctx.shell executor and ctx.approval, and misconfiguration fails at plugin load: configured entries named custom or auto throw, and composing over a bash executor that does not confine (no sandboxMode capability fact) throws because presets bundle a sandbox mode.
Fixed current-session Auto registration
The Auto integration calls registerAuto(admit) for its effect lifetime. This service fixes the auto identity and its danger-full-access plus ask bundle, and a recorded Auto selection also matches the never policy that delegated children pin; the shipped client locale dictionaries own Auto's label and description, while configured preset presentation remains Host-owned. Callers cannot publish another preset through a generic contribution API. Auto appears after configured presets, never enters the permission.defaultPreset settings schema, and disappears when the effect is disposed. The synchronous admit callback runs before Auto selection mutates the Session and before a stored Auto Session publishes, so a missing or closing integration does not rewrite the durable identity.
Registering or removing Auto emits the payload-free permission-presets/catalog-changed notification. Process consumers subscribe before calling catalog(), then re-read the complete selectable catalog after each notification. The permissions Session projection contains only currentValue, so catalog changes append no Session event, publish no Session projection frame, and leave the Session sequence unchanged.
Current preset and the derived custom
current(session) derives the effective preset from the required permissions projection. The unit folds the session's sandbox mode, approval policy, and recorded selection; values absent within that state fall back to the executor's configured mode and the approval service config, then ask. A missing projection key fails explicitly. The service prefers a still-matching selection, including a recorded Auto selection under the never approval policy, then the first matching configured entry, and otherwise returns CUSTOM_PRESET ('custom'). custom is derived-only: clients may display it as the current value, but it is never a switch target or an event payload.
names lists configured presets in declaration order followed by Auto while its integration is live. catalog() returns those selectable entries as one process-level snapshot. optionOf(name) builds an available entry (its label falls back to the key) or the derived custom presentation, and throws for any other name. Clients join the catalog with the Session projection; custom may label the current value but never becomes a catalog entry.
/** Presentation for an available preset or the derived `custom` current value. */
interface PresetOption {
/** Stable option value: a configured preset key, live `auto`, or derived `custom`. */
value: string
/** The display label. */
name: string
/** One user-facing sentence on what the value means; omitted when not configured. */
description?: string
}
Switching and the permission/preset event
set(session, name) resolves the preset (unknown names throw), runs Auto admission when applicable, appends a log-only permission/preset event unless name is already the effective preset, then writes each knob through its own setter — setSandboxMode from dsh-sandbox-policy and setApprovalPolicy from dsh-user-approval — only when that knob's effective value changes. The selection event precedes the knob events in the same turn, and re-selecting the effective preset appends nothing.
The permissionPresets/set Remote (setPreset) is the write's Remote face: it switches one live Session through set and declares that Session as the session resource the Gateway decides, so access control runs before any preset is resolved.
permission/preset is durable, log-only user intent: it stays out of the model transcript (the knob events own the model-visible consequences through their consumers), and it exists so current() can preserve which preset the user chose when two presets share a bundle. The permissions projection folds that selection with both knob events and retains the session/end-seed boundary used to distinguish a restored empty seed from a fresh session; replay needs no catch-up state or raw-log rescan. A restored auto selection requires the live Auto registration before Agent publication. The complete event declaration is in the persistence log event catalog; the method signatures are in the generated service catalog.
Cordis API
Generated from source by scripts/gen-cordis-catalog.ts (verified fresh by pnpm run verify-cordis-catalog in doc-sync; regenerate with pnpm run gen-cordis-catalog) — the language sides differ only in locale-specific paired document paths. Signature blocks use a ts cordis-catalog fence and keep the original source JSDoc; dispatch modes are defined in the primer, and the framework-inherited ctx API lives in cordis-api/inherited.md.
ctx.permissionPresets — PermissionPresetService
Owns the deployment's configured permission presets, the fixed Auto integration hook, and their write path. Requires a confining ctx.shell executor and ctx.approval; unmatched knob values are reported as CUSTOM_PRESET, not an error.
/**
* Read the complete process-level catalog exposed to current-session UI.
* @returns every currently selectable preset in contribution order.
*/
@Remote('catalog') catalog(): PermissionCatalog
/**
* Switch one live Session to another preset, opened as a Remote call so a
* caller's Session access is decided before any preset is resolved or any
* knob is written. The call's `session` resource is the Session named by
* `request.sessionId`, per {@link PermissionPresetSetRequest}; the session
* controller's resolver names it.
*
* The switch appends `permission/preset` and the changed knob events to the
* Session log, so persisted-only Sessions are refused: they have no live log
* to append to.
* @param request - live target Session and the preset name to switch to.
* @returns the Session's current selection after the switch, read the way
* the client reads it: the recorded preset while its bundle still matches,
* otherwise the first preset whose bundle matches, otherwise `custom`.
* @throws {RemoteError} `gateway/bad-request` for an unknown preset name or a
* Session this process does not hold live; neither call writes.
*/
@Remote({ name: 'set' }) setPreset(request: PermissionPresetSetRequest): PermissionSelection
/**
* Publish the fixed current-session Auto preset for the calling
* integration's effect lifetime.
* @param admit - synchronous gate run before live Auto selection or restore.
* @returns the async effect disposer that removes Auto.
*/
registerAuto(admit: () => void): () => Promise<void>
/**
* Resolve the preset matching the effective knob values. A still-matching
* last selection wins shared-bundle ties, and a still-selected Auto also
* matches the `never` approval policy; otherwise the first configured
* match wins. Returns
* {@link CUSTOM_PRESET} when no available preset matches.
* @param session - the session whose knob state is read.
* @returns the effective preset name, or `custom` when nothing matches.
*/
current(session: Session): string
/**
* Resolve an available preset's knob bundle.
* @param name - the preset name to resolve.
* @returns the configured bundle.
* @throws when `name` is neither configured nor the currently live Auto preset.
*/
resolve(name: string): PresetSpec
/**
* Build the client option for an available preset or {@link CUSTOM_PRESET}.
* A missing label falls back to the preset key.
* @param name - a configured preset key, live `auto`, or `custom`.
* @returns the option a client renders.
* @throws when `name` is neither a configured preset, live `auto`, nor `custom`.
*/
optionOf(name: string): PresetOption
/**
* Record a changed preset, then update each changed knob through its own
* setter. Selecting the effective preset again appends nothing.
* @param session - the session the switch belongs to.
* @param name - the preset to switch to; unknown names throw.
*/
set(session: Session, name: string): void
Types: Session
Source: packages/interaction/permission-presets/src/index.ts
permission-presets/* events
permission-presets/catalog-changed — emit
The selectable process catalog changed. Payload-free by design: consumers subscribe first, then re-read the complete catalog.
/**
* The selectable process catalog changed. Payload-free by design:
* consumers subscribe first, then re-read the complete catalog.
* @mode emit
*/
'permission-presets/catalog-changed'(): void
Source: packages/interaction/permission-presets/src/types.ts