diff --git a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml index 353888c72f..772a8c6bcd 100644 --- a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml +++ b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.i18n.yaml @@ -9,11 +9,11 @@ en: 6938aa715106bb99 zh: ea1497b337712f33 /agent-note-session-workspace-root/decision: - en: 4b03efa72080dcc3 - zh: 586af24eb496f56a + en: 0b07db6326c2ecd6 + zh: 19ba9a1adf93af1f /agent-note-session-workspace-root/alternatives-considered: en: 8a4859a6f96ef49e zh: fa7088d29ebe3dd6 /agent-note-session-workspace-root/consequences: - en: 7a454ffbb3100fae - zh: 1961e70b182fe8c8 + en: a6bf8aa40464f524 + zh: 61997dc31615bdbb diff --git a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.md b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.md index 237e3553fa..a37849a230 100644 --- a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.md +++ b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.md @@ -18,7 +18,7 @@ Worktree creation enters the checkout through `set`. The model has one tool for Every consumer reads that directory. The model's file, search, and process tools resolve relative paths from it, and everything the user sees or that describes the project is bounded by it: the sandbox `workspace-write` boundary, the workspace file service and desktop file drag, the change recorder, the Files tree, deliverables, open-in-app actions and Session rows, new sidebar terminals, `@` file candidates, the skill catalog, project-instruction discovery, and the LSP workspace. -The sandbox policy derives the common directory of a linked checkout from the root's `.git` pointer through the execution-world filesystem and adds it to the resolved extra writable roots, accepting only the layout Git writes: `/worktrees/` with a `commondir` naming `` and a `gitdir` naming the checkout's `.git`, since the checkout's own pointer is writable under `workspace-write`. A root's result is kept once read and refreshed when a Host operation moves a Session's workspace to that root or a derived directory disappears; tool executions wait for the derivation, Session creation and directory changes start it early, and the derived directories stay out of the model-visible policy text. On Windows the derived directories follow the [file-tool grant decision](2026-10-29-windows-file-tool-directory-grants.md): `write` and `edit` honor them, and process confinement keeps its workspace and private-temp grants. After a move into a worktree the original project is writable only through the Git administration directories, not as a whole. Host maintenance of a checkout the Session does not work in keeps the original boundary: removing a worktree on archive, restoring a removed one, and reading its branch in the source repository run under a policy the worktree service and the forge panel build themselves: the Session's mode and grants with the recorded source checkout as the root, plus that checkout's Git administration directories from `prepare({ directory })`. The sandbox policy resolves policies only for Sessions; the Session's own root may be the removed directory, and a process sandbox cannot bind a missing or vanishing root. +The sandbox policy reads no Git layout: it bounds a Session by its directory and adds only the directories the deployment configured or a Host plugin registered for that Session through `registerWritableRoot`. A repository's Git directory lies outside a linked worktree, so after a move into a worktree a Git command that writes it, such as `git commit`, is denied under `workspace-write` until a grant covers that directory; the original project is not writable either. Granting the Git directory of the checkout a Session works in belongs to a separate plugin that reads the Git layout and registers the directory, which this decision defers. Host maintenance of a checkout the Session does not work in keeps the original boundary: removing a worktree on archive, restoring a removed one, and reading its branch in the source repository run under a policy the worktree service and the forge panel build themselves, the Session's mode and grants with the recorded source checkout as the root. The Session's own root may be the removed directory, and a process sandbox cannot bind a missing or vanishing root. ## Alternatives considered @@ -46,4 +46,4 @@ The sandbox policy derives the common directory of a linked checkout from the ro ## Consequences -Consumers read one directory through `get`. A stored Session resumes in its original project whatever directory its `working-directory/change` events recorded, and follows Host moves from there. One that worked in a worktree returns to it through `enter_worktree`; until then its relative paths resolve in the original project. The model enters a checkout only through `enter_worktree`: a new one, or a registered one in the pool. A checkout elsewhere needs a Host operation. The ACP, SDK, and Web producers record the original project by its canonical spelling, so a Host move back to it records no change. A Session opened inside a linked worktree can run `git commit` under `workspace-write`, and the shared `.git`, including its hooks and configuration, is writable from that Session as it already is from a Session in the main checkout. An SDK `setWorkingDirectory` call and a child started in a Host-chosen directory move the `workspace-write` boundary with the directory. The worktree snapshot fixture covers entering, leaving, and losing a worktree. +Consumers read one directory through `get`. A stored Session resumes in its original project whatever directory its `working-directory/change` events recorded, and follows Host moves from there. One that worked in a worktree returns to it through `enter_worktree`; until then its relative paths resolve in the original project. The model enters a checkout only through `enter_worktree`: a new one, or a registered one in the pool. A checkout elsewhere needs a Host operation. The ACP, SDK, and Web producers record the original project by its canonical spelling, so a Host move back to it records no change. A Session that works in a linked worktree, whether it entered one or was opened in one, cannot run `git commit` under `workspace-write` without a grant for the repository's Git directory; on the previous boundary a Session that entered a worktree inside its project could. An SDK `setWorkingDirectory` call and a child started in a Host-chosen directory move the `workspace-write` boundary with the directory. The worktree snapshot fixture covers entering, leaving, and losing a worktree. diff --git a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.zh.md b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.zh.md index 89dd36b95d..c35b5a9f83 100644 --- a/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.zh.md +++ b/.agents/notes/implemented/architecture/2026-11-03-session-workspace-root.zh.md @@ -18,7 +18,7 @@ Status: implemented 每个消费方都读取这个目录。模型的文件、搜索与进程工具从它解析相对路径,用户看到的、以及描述项目的一切都以它为界:沙箱 `workspace-write` 边界、工作区文件服务与桌面文件拖拽、变更记录器、文件树、交付物、在应用中打开操作与 Session 行、新开的侧栏终端、`@` 文件候选、技能目录、项目指令发现和 LSP 工作区。 -沙箱策略通过执行环境的文件系统,从根的 `.git` 指针推导出链接检出目录的公共目录并加入解析出的额外可写根,只接受 Git 写出的布局:`/worktrees/`,其 `commondir` 指向 ``、`gitdir` 指回检出目录的 `.git`,因为检出目录自己的指针在 `workspace-write` 下可写。根的结果读取后即保留,在 Host 操作把某个 Session 的工作区移到该根、或已推导目录消失时刷新;工具执行等待该推导完成,会话创建与目录变更提前启动它,推导出的目录不进入模型可见的策略文本。在 Windows 上,推导出的目录遵循[文件工具授权决策](2026-10-29-windows-file-tool-directory-grants.zh.md):`write` 与 `edit` 执行它们,进程限制保留工作区与私有临时目录授权。移入工作树之后,原始项目只能通过 Git 管理目录写入,不再整体可写。Host 对 Session 并不在其中工作的检出目录做维护时保留原来的边界:归档时移除 worktree、恢复被删除的 worktree、在源仓库中读取其分支,都在 worktree 服务与 forge 面板自己构造的策略下运行:沿用 Session 的模式与授权,以记录中的源检出目录为根,并加上 `prepare({ directory })` 给出的该检出目录的 Git 管理目录。沙箱策略只为 Session 解析策略;Session 自身的根可能正是被删除的目录,而进程沙箱无法绑定缺失或正在消失的根。 +沙箱策略不读取任何 Git 布局:它以 Session 的目录为界,只加入部署配置的目录,以及 Host 插件通过 `registerWritableRoot` 为该 Session 注册的目录。仓库的 Git 目录位于链接工作树之外,因此移入工作树之后,写入它的 Git 命令(例如 `git commit`)在 `workspace-write` 下会被拒绝,直到有授权覆盖该目录;原始项目也不再可写。为 Session 所在检出目录授权其 Git 目录,属于一个读取 Git 布局并注册该目录的独立插件,本决策将其延后。Host 对 Session 并不在其中工作的检出目录做维护时保留原来的边界:归档时移除 worktree、恢复被删除的 worktree、在源仓库中读取其分支,都在 worktree 服务与 forge 面板自己构造的策略下运行,即沿用 Session 的模式与授权、以记录中的源检出目录为根。Session 自身的根可能正是被删除的目录,而进程沙箱无法绑定缺失或正在消失的根。 ## Alternatives considered @@ -46,4 +46,4 @@ Status: implemented ## Consequences -消费方通过 `get` 读取一个目录。无论 `working-directory/change` 事件记录了什么目录,已存储的 Session 都在原始项目中恢复,并从那里跟随 Host 移动。曾在工作树中工作的 Session 通过 `enter_worktree` 回到工作树;在此之前,它的相对路径在原始项目中解析。模型只能通过 `enter_worktree` 进入检出:新建的检出,或池中已登记的检出。其他位置的检出需要 Host 操作。ACP、SDK 与 Web 的生产方以规范拼写记录原始项目,因此 Host 移回原始项目时不记录变更。在链接工作树内打开的 Session 可以在 `workspace-write` 下运行 `git commit`,共享的 `.git`(包括其钩子与配置)对该 Session 可写,正如它对主检出目录中的 Session 一样。SDK 的 `setWorkingDirectory` 调用以及在 Host 选定目录启动的子代理,会让 `workspace-write` 边界随目录一起移动。工作树快照夹具覆盖进入、离开和失去工作树。 +消费方通过 `get` 读取一个目录。无论 `working-directory/change` 事件记录了什么目录,已存储的 Session 都在原始项目中恢复,并从那里跟随 Host 移动。曾在工作树中工作的 Session 通过 `enter_worktree` 回到工作树;在此之前,它的相对路径在原始项目中解析。模型只能通过 `enter_worktree` 进入检出:新建的检出,或池中已登记的检出。其他位置的检出需要 Host 操作。ACP、SDK 与 Web 的生产方以规范拼写记录原始项目,因此 Host 移回原始项目时不记录变更。在链接工作树中工作的 Session,无论是进入的还是直接在其中打开的,在没有仓库 Git 目录授权时都不能在 `workspace-write` 下运行 `git commit`;在此前的边界下,进入项目内工作树的 Session 可以。SDK 的 `setWorkingDirectory` 调用以及在 Host 选定目录启动的子代理,会让 `workspace-write` 边界随目录一起移动。工作树快照夹具覆盖进入、离开和失去工作树。 diff --git a/docs/config-catalog.md b/docs/config-catalog.md index bb44ce112d..7108ab966f 100644 --- a/docs/config-catalog.md +++ b/docs/config-catalog.md @@ -3118,7 +3118,7 @@ export interface Config { - `inject`: `sessionProjections` - `refs`: [`SandboxMode`](subsystems/sandbox.md) -- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:112`](../packages/sandbox/sandbox-policy/src/index.ts) +- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:96`](../packages/sandbox/sandbox-policy/src/index.ts) ```ts config-catalog /** @@ -3139,11 +3139,10 @@ export interface Config { workspaceRoot?: string /** * Extra physical absolute directories that `workspace-write` may also write under - * (default: none). The supervisor names them explicitly; the Git - * administration directories of a linked checkout are derived separately - * and need no entry here. Entries are execution-world paths: this service - * validates absoluteness and detaches the list, while the enforcing host - * rejects missing, non-directory, or symlinked paths. They grant nothing under + * (default: none). The supervisor names them explicitly; there is no + * automatic repository or gitfile discovery. Entries are execution-world + * paths: this service validates absoluteness and detaches the list, while + * the enforcing host rejects missing, non-directory, or symlinked paths. They grant nothing under * `read-only`. Windows process confinement ignores them; harness file tools honor them. */ additionalWritableRoots?: string[] diff --git a/docs/config-catalog.zh.md b/docs/config-catalog.zh.md index 22910f3b8c..93b3a20729 100644 --- a/docs/config-catalog.zh.md +++ b/docs/config-catalog.zh.md @@ -3120,7 +3120,7 @@ export interface Config { - `inject`: `sessionProjections` - `refs`: [`SandboxMode`](subsystems/sandbox.zh.md) -- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:112`](../packages/sandbox/sandbox-policy/src/index.ts) +- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:96`](../packages/sandbox/sandbox-policy/src/index.ts) ```ts config-catalog /** @@ -3141,11 +3141,10 @@ export interface Config { workspaceRoot?: string /** * Extra physical absolute directories that `workspace-write` may also write under - * (default: none). The supervisor names them explicitly; the Git - * administration directories of a linked checkout are derived separately - * and need no entry here. Entries are execution-world paths: this service - * validates absoluteness and detaches the list, while the enforcing host - * rejects missing, non-directory, or symlinked paths. They grant nothing under + * (default: none). The supervisor names them explicitly; there is no + * automatic repository or gitfile discovery. Entries are execution-world + * paths: this service validates absoluteness and detaches the list, while + * the enforcing host rejects missing, non-directory, or symlinked paths. They grant nothing under * `read-only`. Windows process confinement ignores them; harness file tools honor them. */ additionalWritableRoots?: string[] diff --git a/docs/event-producer-consumer.md b/docs/event-producer-consumer.md index b1bc988f44..e27ec8d941 100644 --- a/docs/event-producer-consumer.md +++ b/docs/event-producer-consumer.md @@ -72,9 +72,9 @@ Application listeners are outside this package matrix. Desktop Host subscribes t | `schedule/changed` | `emit` | [`packages/schedule/schedule/src/types.ts:634`](../packages/schedule/schedule/src/types.ts) | [`schedule`](../packages/schedule/schedule) (`emit`) | `remotes` | | `schedule/resolve-agent` | `waterfall` | [`packages/schedule/schedule/src/index.ts:72`](../packages/schedule/schedule/src/index.ts) | [`schedule`](../packages/schedule/schedule) (`waterfall`) | `server` | | `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - | -| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`sandbox-policy`](../packages/sandbox/sandbox-policy), `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) | +| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) | | `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) | -| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`sandbox-policy`](../packages/sandbox/sandbox-policy), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) | +| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) | | `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) | | `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` | | `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - | @@ -88,7 +88,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t | `tools/change` | `emit` | [`packages/core/tools/src/events.ts:56`](../packages/core/tools/src/events.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`), [`tools`](../packages/core/tools) (`emit`) | `browser-use-runtime`, [`timeline`](../packages/experimental/timeline) | | `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`cua-macos`](../packages/experimental/cua-macos), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` | | `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) | -| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) | +| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) | | `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) | | `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`tool-office`](../packages/document/tool-office), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` | | `user-questions/request` | `waterfall` | [`packages/interaction/user-questions/src/types.ts:174`](../packages/interaction/user-questions/src/types.ts) | [`user-questions`](../packages/interaction/user-questions) (`waterfall`) | [`cua-mcp`](../packages/experimental/cua-mcp), `remotes`, `server` | diff --git a/docs/event-producer-consumer.zh.md b/docs/event-producer-consumer.zh.md index a2e3d2ac71..d5cea439a5 100644 --- a/docs/event-producer-consumer.zh.md +++ b/docs/event-producer-consumer.zh.md @@ -74,9 +74,9 @@ | `schedule/changed` | `emit` | [`packages/schedule/schedule/src/types.ts:634`](../packages/schedule/schedule/src/types.ts) | [`schedule`](../packages/schedule/schedule) (`emit`) | `remotes` | | `schedule/resolve-agent` | `waterfall` | [`packages/schedule/schedule/src/index.ts:72`](../packages/schedule/schedule/src/index.ts) | [`schedule`](../packages/schedule/schedule) (`waterfall`) | `server` | | `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - | -| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`sandbox-policy`](../packages/sandbox/sandbox-policy), `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) | +| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) | | `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) | -| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`sandbox-policy`](../packages/sandbox/sandbox-policy), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) | +| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) | | `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) | | `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` | | `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - | @@ -90,7 +90,7 @@ | `tools/change` | `emit` | [`packages/core/tools/src/events.ts:56`](../packages/core/tools/src/events.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`), [`tools`](../packages/core/tools) (`emit`) | `browser-use-runtime`, [`timeline`](../packages/experimental/timeline) | | `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`cua-macos`](../packages/experimental/cua-macos), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` | | `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) | -| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) | +| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) | | `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) | | `tools/result` | `emit` | [`packages/core/tools/src/events.ts:49`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`events.dispatch`) | [`action-cards`](../packages/experimental/action-cards), [`agent-instructions`](../packages/context/agent-instructions), `claude-code-mods`, `forge-session`, `liveshare`, [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`tool-office`](../packages/document/tool-office), [`tool-present`](../packages/deliverables/tool-present), `ui-trajectory` | | `user-questions/request` | `waterfall` | [`packages/interaction/user-questions/src/types.ts:174`](../packages/interaction/user-questions/src/types.ts) | [`user-questions`](../packages/interaction/user-questions) (`waterfall`) | [`cua-mcp`](../packages/experimental/cua-mcp), `remotes`, `server` | diff --git a/docs/module-graph.md b/docs/module-graph.md index 450e87e09f..4a7cd564af 100644 --- a/docs/module-graph.md +++ b/docs/module-graph.md @@ -755,6 +755,11 @@ flowchart TD pkg_jobs --> pkg_error pkg_jobs --> pkg_session pkg_jobs --> pkg_workspace + pkg_sandbox_policy --> pkg_agent + pkg_sandbox_policy --> pkg_sandbox + pkg_sandbox_policy --> pkg_session + pkg_sandbox_policy --> pkg_session_projection + pkg_sandbox_policy --> pkg_system_prompt pkg_session_telemetry --> pkg_agent pkg_session_telemetry --> pkg_session pkg_session_title --> pkg_agent @@ -786,6 +791,10 @@ flowchart TD pkg_command_goal --> pkg_commands pkg_command_goal --> pkg_goal pkg_command_goal --> pkg_llm + pkg_fs_sandbox --> pkg_fs + pkg_fs_sandbox --> pkg_fs_local + pkg_fs_sandbox --> pkg_sandbox + pkg_fs_sandbox --> pkg_sandbox_policy pkg_compaction --> pkg_commands pkg_compaction --> pkg_llm pkg_compaction --> pkg_session @@ -793,14 +802,45 @@ flowchart TD pkg_command_feedback --> pkg_commands pkg_command_feedback --> pkg_session pkg_command_feedback --> pkg_typert_protocol + pkg_permission_presets --> pkg_agent + pkg_permission_presets --> pkg_commands + pkg_permission_presets --> pkg_sandbox + pkg_permission_presets --> pkg_sandbox_policy + pkg_permission_presets --> pkg_session + pkg_permission_presets --> pkg_session_projection + pkg_permission_presets --> pkg_shell + pkg_permission_presets --> pkg_typert_protocol + pkg_permission_presets --> pkg_user_approval pkg_jobs_local --> pkg_agent pkg_jobs_local --> pkg_jobs pkg_jobs_local --> pkg_scope pkg_jobs_local --> pkg_timeout + pkg_ptc_runtime_node --> pkg_fs + pkg_ptc_runtime_node --> pkg_ptc_runtime + pkg_ptc_runtime_node --> pkg_sandbox + pkg_ptc_runtime_node --> pkg_sandbox_policy + pkg_ptc_runtime_node --> pkg_session + pkg_ptc_runtime_node --> pkg_subprocess + pkg_ptc_runtime_node --> pkg_timeout pkg_session_title_llm --> pkg_llm pkg_session_title_llm --> pkg_session pkg_session_title_llm --> pkg_session_title pkg_session_title_llm --> pkg_timeout + pkg_bash_sandbox --> pkg_bash_local + pkg_bash_sandbox --> pkg_sandbox + pkg_bash_sandbox --> pkg_sandbox_policy + pkg_bash_sandbox --> pkg_shell + pkg_pwsh_sandbox --> pkg_pwsh_local + pkg_pwsh_sandbox --> pkg_sandbox + pkg_pwsh_sandbox --> pkg_sandbox_policy + pkg_pwsh_sandbox --> pkg_shell + pkg_terminal_bash --> pkg_agent + pkg_terminal_bash --> pkg_sandbox + pkg_terminal_bash --> pkg_sandbox_policy + pkg_terminal_bash --> pkg_session + pkg_terminal_bash --> pkg_subprocess + pkg_terminal_bash --> pkg_terminal + pkg_terminal_bash --> pkg_working_directory pkg_agent_loop --> pkg_agent pkg_agent_loop --> pkg_llm pkg_agent_loop --> pkg_scope @@ -811,12 +851,33 @@ flowchart TD pkg_agent_loop --> pkg_tools pkg_agent_tool_presentation --> pkg_tools pkg_tool_executor_native --> pkg_tools + pkg_tool_executor_ptc --> pkg_agent + pkg_tool_executor_ptc --> pkg_llm + pkg_tool_executor_ptc --> pkg_ptc_runtime + pkg_tool_executor_ptc --> pkg_sandbox + pkg_tool_executor_ptc --> pkg_sandbox_policy + pkg_tool_executor_ptc --> pkg_scope + pkg_tool_executor_ptc --> pkg_session + pkg_tool_executor_ptc --> pkg_tools + pkg_tool_executor_ptc --> pkg_user_approval + pkg_tool_executor_ptc --> pkg_working_directory pkg_tool_goal --> pkg_agent pkg_tool_goal --> pkg_goal pkg_tool_goal --> pkg_llm pkg_tool_goal --> pkg_session pkg_tool_goal --> pkg_system_prompt pkg_tool_goal --> pkg_tools + pkg_tool_fs --> pkg_attachment + pkg_tool_fs --> pkg_error + pkg_tool_fs --> pkg_fs + pkg_tool_fs --> pkg_llm + pkg_tool_fs --> pkg_sandbox + pkg_tool_fs --> pkg_sandbox_policy + pkg_tool_fs --> pkg_session + pkg_tool_fs --> pkg_system_prompt + pkg_tool_fs --> pkg_tools + pkg_tool_fs --> pkg_user_approval + pkg_tool_fs --> pkg_working_directory pkg_tool_fs_search --> pkg_llm pkg_tool_fs_search --> pkg_output_retention pkg_tool_fs_search --> pkg_session @@ -826,6 +887,11 @@ flowchart TD pkg_tool_fs_search --> pkg_timeout pkg_tool_fs_search --> pkg_tools pkg_tool_fs_search --> pkg_working_directory + pkg_tool_str_replace_editor --> pkg_fs + pkg_tool_str_replace_editor --> pkg_output_retention + pkg_tool_str_replace_editor --> pkg_sandbox + pkg_tool_str_replace_editor --> pkg_sandbox_policy + pkg_tool_str_replace_editor --> pkg_tools pkg_tool_skill --> pkg_agent pkg_tool_skill --> pkg_llm pkg_tool_skill --> pkg_skill @@ -993,13 +1059,6 @@ flowchart TD pkg_agent_preset_registry --> pkg_system_prompt pkg_agent_preset_registry --> pkg_tools pkg_agent_preset_registry --> pkg_typert_protocol - pkg_sandbox_policy --> pkg_agent - pkg_sandbox_policy --> pkg_fs - pkg_sandbox_policy --> pkg_sandbox - pkg_sandbox_policy --> pkg_session - pkg_sandbox_policy --> pkg_session_projection - pkg_sandbox_policy --> pkg_system_prompt - pkg_sandbox_policy --> pkg_tools pkg_session_checkpoint_policy --> pkg_agent pkg_session_checkpoint_policy --> pkg_llm pkg_session_checkpoint_policy --> pkg_session @@ -1026,6 +1085,17 @@ flowchart TD pkg_tool_pwsh_persistent --> pkg_timeout pkg_tool_pwsh_persistent --> pkg_tools pkg_tool_pwsh_persistent --> pkg_working_directory + pkg_ssh --> pkg_brand + pkg_ssh --> pkg_fs + pkg_ssh --> pkg_fs_local + pkg_ssh --> pkg_fs_sandbox + pkg_ssh --> pkg_sandbox + pkg_ssh --> pkg_sandbox_local + pkg_ssh --> pkg_sandbox_policy + pkg_ssh --> pkg_session_projection + pkg_ssh --> pkg_subprocess + pkg_ssh --> pkg_subprocess_local + pkg_ssh --> pkg_util_values pkg_llm_replay --> pkg_compaction pkg_llm_replay --> pkg_deepseek_llm_api_extensions pkg_llm_replay --> pkg_llm @@ -1049,36 +1119,6 @@ flowchart TD pkg_token_meter --> pkg_llm_retry pkg_token_meter --> pkg_session pkg_token_meter --> pkg_session_projection - pkg_tool_executor_ptc --> pkg_agent - pkg_tool_executor_ptc --> pkg_llm - pkg_tool_executor_ptc --> pkg_ptc_runtime - pkg_tool_executor_ptc --> pkg_sandbox - pkg_tool_executor_ptc --> pkg_sandbox_policy - pkg_tool_executor_ptc --> pkg_scope - pkg_tool_executor_ptc --> pkg_session - pkg_tool_executor_ptc --> pkg_tools - pkg_tool_executor_ptc --> pkg_user_approval - pkg_tool_executor_ptc --> pkg_working_directory - pkg_fs_sandbox --> pkg_fs - pkg_fs_sandbox --> pkg_fs_local - pkg_fs_sandbox --> pkg_sandbox - pkg_fs_sandbox --> pkg_sandbox_policy - pkg_tool_fs --> pkg_attachment - pkg_tool_fs --> pkg_error - pkg_tool_fs --> pkg_fs - pkg_tool_fs --> pkg_llm - pkg_tool_fs --> pkg_sandbox - pkg_tool_fs --> pkg_sandbox_policy - pkg_tool_fs --> pkg_session - pkg_tool_fs --> pkg_system_prompt - pkg_tool_fs --> pkg_tools - pkg_tool_fs --> pkg_user_approval - pkg_tool_fs --> pkg_working_directory - pkg_tool_str_replace_editor --> pkg_fs - pkg_tool_str_replace_editor --> pkg_output_retention - pkg_tool_str_replace_editor --> pkg_sandbox - pkg_tool_str_replace_editor --> pkg_sandbox_policy - pkg_tool_str_replace_editor --> pkg_tools pkg_session_query --> pkg_llm pkg_session_query --> pkg_session pkg_session_query --> pkg_session_persistence @@ -1093,9 +1133,23 @@ flowchart TD pkg_api_settings_controller --> pkg_settings pkg_api_settings_controller --> pkg_typert_protocol pkg_web_app --> pkg_shell_env + pkg_cua --> pkg_attachment + pkg_cua --> pkg_error + pkg_cua --> pkg_ptc_runtime_node + pkg_cua --> pkg_scope + pkg_cua --> pkg_tool_executor_ptc + pkg_cua --> pkg_tools + pkg_cua --> pkg_user_questions pkg_deepseek_chat_import --> pkg_session pkg_deepseek_chat_import --> pkg_session_title pkg_deepseek_chat_import --> pkg_tool_web + pkg_experimental_auto_review --> pkg_agent + pkg_experimental_auto_review --> pkg_agent_instructions + pkg_experimental_auto_review --> pkg_llm + pkg_experimental_auto_review --> pkg_permission_presets + pkg_experimental_auto_review --> pkg_session + pkg_experimental_auto_review --> pkg_tools + pkg_experimental_auto_review --> pkg_working_directory pkg_experimental_forge_session --> pkg_experimental_forge pkg_experimental_forge_session --> pkg_llm pkg_experimental_forge_session --> pkg_sandbox_policy @@ -1104,6 +1158,14 @@ flowchart TD pkg_experimental_forge_session --> pkg_shell pkg_experimental_forge_session --> pkg_shell_env pkg_experimental_forge_session --> pkg_tools + pkg_webhook --> pkg_agent + pkg_webhook --> pkg_agent_default_model + pkg_webhook --> pkg_agent_preset_registry + pkg_webhook --> pkg_llm + pkg_webhook --> pkg_permission_presets + pkg_webhook --> pkg_session + pkg_webhook --> pkg_session_title + pkg_webhook --> pkg_workspace pkg_tool_cordis --> pkg_agent pkg_tool_cordis --> pkg_app_boot pkg_tool_cordis --> pkg_cordis_host_runner @@ -1111,15 +1173,6 @@ flowchart TD pkg_host_plugin_inventory --> pkg_agent_preset_registry pkg_host_plugin_inventory --> pkg_brand pkg_host_plugin_inventory --> pkg_typert_protocol - pkg_permission_presets --> pkg_agent - pkg_permission_presets --> pkg_commands - pkg_permission_presets --> pkg_sandbox - pkg_permission_presets --> pkg_sandbox_policy - pkg_permission_presets --> pkg_session - pkg_permission_presets --> pkg_session_projection - pkg_permission_presets --> pkg_shell - pkg_permission_presets --> pkg_typert_protocol - pkg_permission_presets --> pkg_user_approval pkg_mcp_client --> pkg_attachment pkg_mcp_client --> pkg_credentials pkg_mcp_client --> pkg_error @@ -1131,13 +1184,6 @@ flowchart TD pkg_mcp_client --> pkg_timeout pkg_mcp_client --> pkg_tools pkg_agent_preset --> pkg_agent_preset_registry - pkg_ptc_runtime_node --> pkg_fs - pkg_ptc_runtime_node --> pkg_ptc_runtime - pkg_ptc_runtime_node --> pkg_sandbox - pkg_ptc_runtime_node --> pkg_sandbox_policy - pkg_ptc_runtime_node --> pkg_session - pkg_ptc_runtime_node --> pkg_subprocess - pkg_ptc_runtime_node --> pkg_timeout pkg_session_telemetry_otel --> pkg_anonymous_user_id pkg_session_telemetry_otel --> pkg_command_feedback pkg_session_telemetry_otel --> pkg_llm @@ -1145,14 +1191,6 @@ flowchart TD pkg_session_telemetry_otel --> pkg_otel pkg_session_telemetry_otel --> pkg_session pkg_session_telemetry_otel --> pkg_session_telemetry - pkg_bash_sandbox --> pkg_bash_local - pkg_bash_sandbox --> pkg_sandbox - pkg_bash_sandbox --> pkg_sandbox_policy - pkg_bash_sandbox --> pkg_shell - pkg_pwsh_sandbox --> pkg_pwsh_local - pkg_pwsh_sandbox --> pkg_sandbox - pkg_pwsh_sandbox --> pkg_sandbox_policy - pkg_pwsh_sandbox --> pkg_shell pkg_tool_bash --> pkg_agent pkg_tool_bash --> pkg_jobs pkg_tool_bash --> pkg_llm @@ -1177,13 +1215,15 @@ flowchart TD pkg_tool_pwsh --> pkg_tools pkg_tool_pwsh --> pkg_user_approval pkg_tool_pwsh --> pkg_working_directory - pkg_terminal_bash --> pkg_agent - pkg_terminal_bash --> pkg_sandbox - pkg_terminal_bash --> pkg_sandbox_policy - pkg_terminal_bash --> pkg_session - pkg_terminal_bash --> pkg_subprocess - pkg_terminal_bash --> pkg_terminal - pkg_terminal_bash --> pkg_working_directory + pkg_fs_ssh --> pkg_fs + pkg_fs_ssh --> pkg_sandbox + pkg_fs_ssh --> pkg_sandbox_policy + pkg_fs_ssh --> pkg_ssh + pkg_sandbox_ssh --> pkg_sandbox + pkg_sandbox_ssh --> pkg_ssh + pkg_subprocess_ssh --> pkg_ssh + pkg_subprocess_ssh --> pkg_subprocess + pkg_subprocess_ssh --> pkg_subprocess_local pkg_agent_loop_testkit --> pkg_agent pkg_agent_loop_testkit --> pkg_agent_loop pkg_agent_loop_testkit --> pkg_fs_local @@ -1251,20 +1291,6 @@ flowchart TD pkg_compaction_tool_result_pruner --> pkg_llm pkg_compaction_tool_result_pruner --> pkg_session pkg_compaction_tool_result_pruner --> pkg_token_meter - pkg_cua --> pkg_attachment - pkg_cua --> pkg_error - pkg_cua --> pkg_ptc_runtime_node - pkg_cua --> pkg_scope - pkg_cua --> pkg_tool_executor_ptc - pkg_cua --> pkg_tools - pkg_cua --> pkg_user_questions - pkg_experimental_auto_review --> pkg_agent - pkg_experimental_auto_review --> pkg_agent_instructions - pkg_experimental_auto_review --> pkg_llm - pkg_experimental_auto_review --> pkg_permission_presets - pkg_experimental_auto_review --> pkg_session - pkg_experimental_auto_review --> pkg_tools - pkg_experimental_auto_review --> pkg_working_directory pkg_experimental_browser_use_runtime --> pkg_agent pkg_experimental_browser_use_runtime --> pkg_browser_use pkg_experimental_browser_use_runtime --> pkg_error @@ -1313,29 +1339,14 @@ flowchart TD pkg_tool_session_query --> pkg_system_prompt pkg_tool_session_query --> pkg_timeout pkg_tool_session_query --> pkg_tools - pkg_webhook --> pkg_agent - pkg_webhook --> pkg_agent_default_model - pkg_webhook --> pkg_agent_preset_registry - pkg_webhook --> pkg_llm - pkg_webhook --> pkg_permission_presets - pkg_webhook --> pkg_session - pkg_webhook --> pkg_session_title - pkg_webhook --> pkg_workspace + pkg_webhook_github --> pkg_credentials + pkg_webhook_github --> pkg_host_webserver + pkg_webhook_github --> pkg_session + pkg_webhook_github --> pkg_webhook pkg_mcp_manager --> pkg_mcp_client pkg_mcp_manager --> pkg_tools pkg_mcp_manager --> pkg_typert_protocol pkg_mcp_manager --> pkg_util_values - pkg_ssh --> pkg_brand - pkg_ssh --> pkg_fs - pkg_ssh --> pkg_fs_local - pkg_ssh --> pkg_fs_sandbox - pkg_ssh --> pkg_sandbox - pkg_ssh --> pkg_sandbox_local - pkg_ssh --> pkg_sandbox_policy - pkg_ssh --> pkg_session_projection - pkg_ssh --> pkg_subprocess - pkg_ssh --> pkg_subprocess_local - pkg_ssh --> pkg_util_values pkg_goal_round_driver --> pkg_agent pkg_goal_round_driver --> pkg_goal pkg_goal_round_driver --> pkg_llm @@ -1474,24 +1485,11 @@ flowchart TD pkg_tool_ralph --> pkg_system_prompt pkg_tool_ralph --> pkg_tools pkg_tool_ralph --> pkg_workflow - pkg_webhook_github --> pkg_credentials - pkg_webhook_github --> pkg_host_webserver - pkg_webhook_github --> pkg_session - pkg_webhook_github --> pkg_webhook pkg_sdk_protocol --> pkg_commands pkg_sdk_protocol --> pkg_llm pkg_sdk_protocol --> pkg_session pkg_sdk_protocol --> pkg_subagent pkg_sdk_protocol --> pkg_user_questions - pkg_fs_ssh --> pkg_fs - pkg_fs_ssh --> pkg_sandbox - pkg_fs_ssh --> pkg_sandbox_policy - pkg_fs_ssh --> pkg_ssh - pkg_sandbox_ssh --> pkg_sandbox - pkg_sandbox_ssh --> pkg_ssh - pkg_subprocess_ssh --> pkg_ssh - pkg_subprocess_ssh --> pkg_subprocess - pkg_subprocess_ssh --> pkg_subprocess_local pkg_agent_team --> pkg_agent pkg_agent_team --> pkg_llm pkg_agent_team --> pkg_session @@ -1836,6 +1834,7 @@ flowchart TD | [`user-approval`](../packages/interaction/user-approval) | `interaction` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | | [`user-questions`](../packages/interaction/user-questions) | `interaction` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`typert-protocol`](../packages/typert/protocol) | | [`jobs`](../packages/jobs/jobs) | `jobs` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`session`](../packages/core/session), [`workspace`](../packages/workspace/workspace) | +| [`sandbox-policy`](../packages/sandbox/sandbox-policy) | `sandbox` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | | [`session-telemetry`](../packages/session/session-telemetry) | `session` | [`agent`](../packages/core/agent), [`session`](../packages/core/session) | | [`session-title`](../packages/session/session-title) | `session` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection) | | [`working-directory`](../packages/session/working-directory) | `session` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | @@ -1844,15 +1843,24 @@ flowchart TD | [`workflow`](../packages/workflow/workflow) | `workflow` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`tools`](../packages/core/tools) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`user-approval`](../packages/interaction/user-approval) | | [`command-goal`](../packages/goal/command-goal) | `goal` | [`commands`](../packages/interaction/commands), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm) | +| [`fs-sandbox`](../packages/fs/fs-sandbox) | `fs` | [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy) | | [`compaction`](../packages/compaction/compaction) | `compaction` | [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`command-feedback`](../packages/feedback/command-feedback) | `feedback` | [`anonymous-user-id`](../packages/identity/anonymous-user-id), [`commands`](../packages/interaction/commands), [`session`](../packages/core/session), [`typert-protocol`](../packages/typert/protocol) | +| [`permission-presets`](../packages/interaction/permission-presets) | `interaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`jobs-local`](../packages/jobs/jobs-local) | `jobs` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`scope`](../packages/core/scope), [`timeout`](../packages/util/timeout) | +| [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node) | `ptc-runtime` | [`fs`](../packages/fs/fs), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`session-title-llm`](../packages/session/session-title-llm) | `session` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`timeout`](../packages/util/timeout) | +| [`bash-sandbox`](../packages/shell/bash-sandbox) | `shell` | [`bash-local`](../packages/shell/bash-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | +| [`pwsh-sandbox`](../packages/shell/pwsh-sandbox) | `shell` | [`pwsh-local`](../packages/shell/pwsh-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | +| [`terminal-bash`](../packages/terminal/terminal-bash) | `terminal` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`terminal`](../packages/terminal/terminal), [`working-directory`](../packages/session/working-directory) | | [`agent-loop`](../packages/core/agent-loop) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`agent-tool-presentation`](../packages/core/agent-tool-presentation) | `core` | [`tools`](../packages/core/tools) | | [`tool-executor-native`](../packages/core/tool-executor-native) | `core` | [`tools`](../packages/core/tools) | +| [`tool-executor-ptc`](../packages/core/tool-executor-ptc) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-goal`](../packages/goal/tool-goal) | `goal` | [`agent`](../packages/core/agent), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | +| [`tool-fs`](../packages/fs/tool-fs) | `fs` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-fs-search`](../packages/fs/tool-fs-search) | `fs` | [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`spill`](../packages/spill/spill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | +| [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) | `fs` | [`fs`](../packages/fs/fs), [`output-retention`](../packages/util/output-retention), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tools`](../packages/core/tools) | | [`tool-skill`](../packages/skill/tool-skill) | `skill` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`skill`](../packages/skill/skill), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-workspace-dependencies`](../packages/skill/tool-workspace-dependencies) | `skill` | [`error`](../packages/util/error), [`tools`](../packages/core/tools) | | [`tool-web`](../packages/web/tool-web) | `web` | [`llm`](../packages/llm/llm), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`web`](../packages/web/web) | @@ -1887,38 +1895,35 @@ flowchart TD | [`tool-lsp`](../packages/lsp/tool-lsp) | `lsp` | [`llm`](../packages/llm/llm), [`lsp`](../packages/lsp/lsp), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`mcp-resources`](../packages/mcp/mcp-resources) | `mcp` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`agent-preset-registry`](../packages/preset/agent-preset-registry) | `preset` | [`agent`](../packages/core/agent), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`settings`](../packages/settings/settings), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol) | -| [`sandbox-policy`](../packages/sandbox/sandbox-policy) | `sandbox` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy) | `session` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`tools`](../packages/core/tools) | | [`session-title-first-prompt-llm`](../packages/session/session-title-first-prompt-llm) | `session` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`session-title-llm`](../packages/session/session-title-llm) | | [`shell-env`](../packages/shell/shell-env) | `shell` | [`app-boot`](../packages/boot/app-boot), [`error`](../packages/util/error), [`home-paths`](../packages/util/home-paths), [`shell`](../packages/shell/shell), [`tools`](../packages/core/tools) | | [`tool-bash-persistent`](../packages/shell/tool-bash-persistent) | `shell` | [`agent`](../packages/core/agent), [`output-retention`](../packages/util/output-retention), [`terminal`](../packages/terminal/terminal), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-pwsh-persistent`](../packages/shell/tool-pwsh-persistent) | `shell` | [`agent`](../packages/core/agent), [`output-retention`](../packages/util/output-retention), [`terminal`](../packages/terminal/terminal), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | +| [`ssh`](../packages/ssh/ssh) | `ssh` | [`brand`](../packages/util/brand), [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`fs-sandbox`](../packages/fs/fs-sandbox), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-local`](../packages/sandbox/sandbox-local), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session-projection`](../packages/session/session-projection), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local), [`util-values`](../packages/util/values) | | [`llm-replay`](../packages/test-support/llm-replay) | `test-support` | [`compaction`](../packages/compaction/compaction), [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`tool-testkit`](../packages/test-support/tool-testkit) | `test-support` | [`llm`](../packages/llm/llm), [`tools`](../packages/core/tools) | | [`tool-workflow`](../packages/workflow/tool-workflow) | `workflow` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow) | | [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | `llm` | [`agent`](../packages/core/agent), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions), [`session`](../packages/core/session) | | [`token-meter`](../packages/llm/token-meter) | `llm` | [`compaction`](../packages/compaction/compaction), [`compaction-image-offload`](../packages/compaction/compaction-image-offload), [`llm`](../packages/llm/llm), [`llm-retry`](../packages/llm/llm-retry), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection) | -| [`tool-executor-ptc`](../packages/core/tool-executor-ptc) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`fs-sandbox`](../packages/fs/fs-sandbox) | `fs` | [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy) | -| [`tool-fs`](../packages/fs/tool-fs) | `fs` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) | `fs` | [`fs`](../packages/fs/fs), [`output-retention`](../packages/util/output-retention), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tools`](../packages/core/tools) | | [`session-query`](../packages/session-query/session-query) | `session-query` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-title`](../packages/session/session-title), [`tool-todo`](../packages/todo/tool-todo) | | [`api-settings-controller`](../packages/api/settings-controller) | `api` | [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`credentials`](../packages/credentials/credentials), [`native-command`](../packages/util/native-command), [`session`](../packages/core/session), [`settings`](../packages/settings/settings), [`typert-protocol`](../packages/typert/protocol) | | [`web-app`](../packages/bundle/web-app) | `bundle` | [`shell-env`](../packages/shell/shell-env) | +| [`cua`](../packages/experimental/cua) | `experimental` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`scope`](../packages/core/scope), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) | | [`deepseek-chat-import`](../packages/experimental/deepseek-chat-import) | `experimental` | [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`tool-web`](../packages/web/tool-web) | +| [`experimental-auto-review`](../packages/experimental/auto-review) | `experimental` | [`agent`](../packages/core/agent), [`agent-instructions`](../packages/context/agent-instructions), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-forge-session`](../packages/experimental/forge-session) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`llm`](../packages/llm/llm), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`tools`](../packages/core/tools) | +| [`webhook`](../packages/experimental/webhook) | `experimental` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`workspace`](../packages/workspace/workspace) | | [`tool-cordis`](../packages/extensions/tool-cordis) | `extensions` | [`agent`](../packages/core/agent), [`app-boot`](../packages/boot/app-boot), [`cordis-host-runner`](../packages/extensions/cordis-host-runner), [`tools`](../packages/core/tools) | | [`host-plugin-inventory`](../packages/host/plugin-inventory) | `host` | [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`brand`](../packages/util/brand), [`typert-protocol`](../packages/typert/protocol) | -| [`permission-presets`](../packages/interaction/permission-presets) | `interaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`mcp-client`](../packages/mcp/mcp-client) | `mcp` | [`attachment`](../packages/attachment/attachment), [`credentials`](../packages/credentials/credentials), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`mcp-resources`](../packages/mcp/mcp-resources), [`scope`](../packages/core/scope), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools) | | [`agent-preset`](../packages/preset/agent-preset) | `preset` | [`agent-preset-registry`](../packages/preset/agent-preset-registry) | -| [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node) | `ptc-runtime` | [`fs`](../packages/fs/fs), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`session-telemetry-otel`](../packages/session/session-telemetry-otel) | `session` | [`anonymous-user-id`](../packages/identity/anonymous-user-id), [`command-feedback`](../packages/feedback/command-feedback), [`llm`](../packages/llm/llm), [`message-feedback`](../packages/feedback/message-feedback), [`otel`](../packages/telemetry/otel), [`session`](../packages/core/session), [`session-telemetry`](../packages/session/session-telemetry) | -| [`bash-sandbox`](../packages/shell/bash-sandbox) | `shell` | [`bash-local`](../packages/shell/bash-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | -| [`pwsh-sandbox`](../packages/shell/pwsh-sandbox) | `shell` | [`pwsh-local`](../packages/shell/pwsh-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | | [`tool-bash`](../packages/shell/tool-bash) | `shell` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-pwsh`](../packages/shell/tool-pwsh) | `shell` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`terminal-bash`](../packages/terminal/terminal-bash) | `terminal` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`terminal`](../packages/terminal/terminal), [`working-directory`](../packages/session/working-directory) | +| [`fs-ssh`](../packages/ssh/fs-ssh) | `ssh` | [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`ssh`](../packages/ssh/ssh) | +| [`sandbox-ssh`](../packages/ssh/sandbox-ssh) | `ssh` | [`sandbox`](../packages/sandbox/sandbox), [`ssh`](../packages/ssh/ssh) | +| [`subprocess-ssh`](../packages/ssh/subprocess-ssh) | `ssh` | [`ssh`](../packages/ssh/ssh), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local) | | [`agent-loop-testkit`](../packages/test-support/agent-loop-testkit) | `test-support` | [`agent`](../packages/core/agent), [`agent-loop`](../packages/core/agent-loop), [`fs-local`](../packages/fs/fs-local), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`subagent`](../packages/subagent/subagent) | `subagent` | [`agent`](../packages/core/agent), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`attachment`](../packages/attachment/attachment), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`session-query`](../packages/session-query/session-query), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval), [`util-time`](../packages/util/time), [`working-directory`](../packages/session/working-directory), [`workspace`](../packages/workspace/workspace) | | [`spill-policy`](../packages/spill/spill-policy) | `spill` | [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`spill`](../packages/spill/spill), [`token-meter`](../packages/llm/token-meter), [`tools`](../packages/core/tools) | @@ -1927,17 +1932,14 @@ flowchart TD | [`acp`](../packages/acp/acp) | `acp` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`llm`](../packages/llm/llm), [`mcp-client`](../packages/mcp/mcp-client), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`token-meter`](../packages/llm/token-meter), [`user-approval`](../packages/interaction/user-approval) | | [`plugin-manager`](../packages/boot/plugin-manager) | `boot` | [`error`](../packages/util/error), [`hmr`](../packages/boot/hmr), [`host-plugin-inventory`](../packages/host/plugin-inventory), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner) | `compaction` | [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`token-meter`](../packages/llm/token-meter) | -| [`cua`](../packages/experimental/cua) | `experimental` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`scope`](../packages/core/scope), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) | -| [`experimental-auto-review`](../packages/experimental/auto-review) | `experimental` | [`agent`](../packages/core/agent), [`agent-instructions`](../packages/context/agent-instructions), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-browser-use-runtime`](../packages/experimental/browser-use-runtime) | `experimental` | [`agent`](../packages/core/agent), [`browser-use`](../packages/browser-use/browser-use), [`error`](../packages/util/error), [`mcp-client`](../packages/mcp/mcp-client), [`scope`](../packages/core/scope), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-claude-code-mods`](../packages/experimental/claude-code-mods) | `experimental` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`storage-domain`](../packages/storage/storage-domain), [`subprocess`](../packages/subprocess/subprocess), [`token-meter`](../packages/llm/token-meter), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`experimental-forge-session`](../packages/experimental/forge-session), [`subprocess`](../packages/subprocess/subprocess) | | [`experimental-worktree`](../packages/experimental/worktree) | `experimental` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-query`](../packages/session-query/session-query), [`settings`](../packages/settings/settings), [`subprocess`](../packages/subprocess/subprocess), [`working-directory`](../packages/session/working-directory), [`workspace`](../packages/workspace/workspace) | | [`forge-gitlab`](../packages/experimental/forge-gitlab) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`experimental-forge-session`](../packages/experimental/forge-session), [`subprocess`](../packages/subprocess/subprocess) | | [`tool-session-query`](../packages/experimental/tool-session-query) | `experimental` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-query`](../packages/session-query/session-query), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools) | -| [`webhook`](../packages/experimental/webhook) | `experimental` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`workspace`](../packages/workspace/workspace) | +| [`webhook-github`](../packages/experimental/webhook-github) | `experimental` | [`credentials`](../packages/credentials/credentials), [`host-webserver`](../packages/host/webserver), [`session`](../packages/core/session), [`webhook`](../packages/experimental/webhook) | | [`mcp-manager`](../packages/mcp/mcp-manager) | `mcp` | [`mcp-client`](../packages/mcp/mcp-client), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`util-values`](../packages/util/values) | -| [`ssh`](../packages/ssh/ssh) | `ssh` | [`brand`](../packages/util/brand), [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`fs-sandbox`](../packages/fs/fs-sandbox), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-local`](../packages/sandbox/sandbox-local), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session-projection`](../packages/session/session-projection), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local), [`util-values`](../packages/util/values) | | [`goal-round-driver`](../packages/goal/goal-round-driver) | `goal` | [`agent`](../packages/core/agent), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent) | | [`subagent-acp`](../packages/subagent/subagent-acp) | `subagent` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`subagent-claude-code`](../packages/subagent/subagent-claude-code) | `subagent` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | @@ -1957,11 +1959,7 @@ flowchart TD | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | `experimental` | [`experimental-worktree`](../packages/experimental/worktree), [`tools`](../packages/core/tools) | | [`hooks-claude-code`](../packages/experimental/hooks-claude-code) | `experimental` | [`agent`](../packages/core/agent), [`hook-protocol`](../packages/experimental/hook-protocol), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-ralph`](../packages/experimental/tool-ralph) | `experimental` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow) | -| [`webhook-github`](../packages/experimental/webhook-github) | `experimental` | [`credentials`](../packages/credentials/credentials), [`host-webserver`](../packages/host/webserver), [`session`](../packages/core/session), [`webhook`](../packages/experimental/webhook) | | [`sdk-protocol`](../packages/sdk/protocol) | `sdk` | [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-questions`](../packages/interaction/user-questions) | -| [`fs-ssh`](../packages/ssh/fs-ssh) | `ssh` | [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`ssh`](../packages/ssh/ssh) | -| [`sandbox-ssh`](../packages/ssh/sandbox-ssh) | `ssh` | [`sandbox`](../packages/sandbox/sandbox), [`ssh`](../packages/ssh/ssh) | -| [`subprocess-ssh`](../packages/ssh/subprocess-ssh) | `ssh` | [`ssh`](../packages/ssh/ssh), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local) | | [`agent-team`](../packages/team/agent-team) | `team` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`subagent`](../packages/subagent/subagent), [`typert-protocol`](../packages/typert/protocol) | | [`workflow-ptc`](../packages/workflow/workflow-ptc) | `workflow` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow), [`working-directory`](../packages/session/working-directory) | | [`tool-subagent-control`](../packages/subagent/tool-subagent-control) | `subagent` | [`agent`](../packages/core/agent), [`agent-team`](../packages/team/agent-team), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | diff --git a/docs/module-graph.zh.md b/docs/module-graph.zh.md index f0cbedbcf7..9bcf879edf 100644 --- a/docs/module-graph.zh.md +++ b/docs/module-graph.zh.md @@ -757,6 +757,11 @@ flowchart TD pkg_jobs --> pkg_error pkg_jobs --> pkg_session pkg_jobs --> pkg_workspace + pkg_sandbox_policy --> pkg_agent + pkg_sandbox_policy --> pkg_sandbox + pkg_sandbox_policy --> pkg_session + pkg_sandbox_policy --> pkg_session_projection + pkg_sandbox_policy --> pkg_system_prompt pkg_session_telemetry --> pkg_agent pkg_session_telemetry --> pkg_session pkg_session_title --> pkg_agent @@ -788,6 +793,10 @@ flowchart TD pkg_command_goal --> pkg_commands pkg_command_goal --> pkg_goal pkg_command_goal --> pkg_llm + pkg_fs_sandbox --> pkg_fs + pkg_fs_sandbox --> pkg_fs_local + pkg_fs_sandbox --> pkg_sandbox + pkg_fs_sandbox --> pkg_sandbox_policy pkg_compaction --> pkg_commands pkg_compaction --> pkg_llm pkg_compaction --> pkg_session @@ -795,14 +804,45 @@ flowchart TD pkg_command_feedback --> pkg_commands pkg_command_feedback --> pkg_session pkg_command_feedback --> pkg_typert_protocol + pkg_permission_presets --> pkg_agent + pkg_permission_presets --> pkg_commands + pkg_permission_presets --> pkg_sandbox + pkg_permission_presets --> pkg_sandbox_policy + pkg_permission_presets --> pkg_session + pkg_permission_presets --> pkg_session_projection + pkg_permission_presets --> pkg_shell + pkg_permission_presets --> pkg_typert_protocol + pkg_permission_presets --> pkg_user_approval pkg_jobs_local --> pkg_agent pkg_jobs_local --> pkg_jobs pkg_jobs_local --> pkg_scope pkg_jobs_local --> pkg_timeout + pkg_ptc_runtime_node --> pkg_fs + pkg_ptc_runtime_node --> pkg_ptc_runtime + pkg_ptc_runtime_node --> pkg_sandbox + pkg_ptc_runtime_node --> pkg_sandbox_policy + pkg_ptc_runtime_node --> pkg_session + pkg_ptc_runtime_node --> pkg_subprocess + pkg_ptc_runtime_node --> pkg_timeout pkg_session_title_llm --> pkg_llm pkg_session_title_llm --> pkg_session pkg_session_title_llm --> pkg_session_title pkg_session_title_llm --> pkg_timeout + pkg_bash_sandbox --> pkg_bash_local + pkg_bash_sandbox --> pkg_sandbox + pkg_bash_sandbox --> pkg_sandbox_policy + pkg_bash_sandbox --> pkg_shell + pkg_pwsh_sandbox --> pkg_pwsh_local + pkg_pwsh_sandbox --> pkg_sandbox + pkg_pwsh_sandbox --> pkg_sandbox_policy + pkg_pwsh_sandbox --> pkg_shell + pkg_terminal_bash --> pkg_agent + pkg_terminal_bash --> pkg_sandbox + pkg_terminal_bash --> pkg_sandbox_policy + pkg_terminal_bash --> pkg_session + pkg_terminal_bash --> pkg_subprocess + pkg_terminal_bash --> pkg_terminal + pkg_terminal_bash --> pkg_working_directory pkg_agent_loop --> pkg_agent pkg_agent_loop --> pkg_llm pkg_agent_loop --> pkg_scope @@ -813,12 +853,33 @@ flowchart TD pkg_agent_loop --> pkg_tools pkg_agent_tool_presentation --> pkg_tools pkg_tool_executor_native --> pkg_tools + pkg_tool_executor_ptc --> pkg_agent + pkg_tool_executor_ptc --> pkg_llm + pkg_tool_executor_ptc --> pkg_ptc_runtime + pkg_tool_executor_ptc --> pkg_sandbox + pkg_tool_executor_ptc --> pkg_sandbox_policy + pkg_tool_executor_ptc --> pkg_scope + pkg_tool_executor_ptc --> pkg_session + pkg_tool_executor_ptc --> pkg_tools + pkg_tool_executor_ptc --> pkg_user_approval + pkg_tool_executor_ptc --> pkg_working_directory pkg_tool_goal --> pkg_agent pkg_tool_goal --> pkg_goal pkg_tool_goal --> pkg_llm pkg_tool_goal --> pkg_session pkg_tool_goal --> pkg_system_prompt pkg_tool_goal --> pkg_tools + pkg_tool_fs --> pkg_attachment + pkg_tool_fs --> pkg_error + pkg_tool_fs --> pkg_fs + pkg_tool_fs --> pkg_llm + pkg_tool_fs --> pkg_sandbox + pkg_tool_fs --> pkg_sandbox_policy + pkg_tool_fs --> pkg_session + pkg_tool_fs --> pkg_system_prompt + pkg_tool_fs --> pkg_tools + pkg_tool_fs --> pkg_user_approval + pkg_tool_fs --> pkg_working_directory pkg_tool_fs_search --> pkg_llm pkg_tool_fs_search --> pkg_output_retention pkg_tool_fs_search --> pkg_session @@ -828,6 +889,11 @@ flowchart TD pkg_tool_fs_search --> pkg_timeout pkg_tool_fs_search --> pkg_tools pkg_tool_fs_search --> pkg_working_directory + pkg_tool_str_replace_editor --> pkg_fs + pkg_tool_str_replace_editor --> pkg_output_retention + pkg_tool_str_replace_editor --> pkg_sandbox + pkg_tool_str_replace_editor --> pkg_sandbox_policy + pkg_tool_str_replace_editor --> pkg_tools pkg_tool_skill --> pkg_agent pkg_tool_skill --> pkg_llm pkg_tool_skill --> pkg_skill @@ -995,13 +1061,6 @@ flowchart TD pkg_agent_preset_registry --> pkg_system_prompt pkg_agent_preset_registry --> pkg_tools pkg_agent_preset_registry --> pkg_typert_protocol - pkg_sandbox_policy --> pkg_agent - pkg_sandbox_policy --> pkg_fs - pkg_sandbox_policy --> pkg_sandbox - pkg_sandbox_policy --> pkg_session - pkg_sandbox_policy --> pkg_session_projection - pkg_sandbox_policy --> pkg_system_prompt - pkg_sandbox_policy --> pkg_tools pkg_session_checkpoint_policy --> pkg_agent pkg_session_checkpoint_policy --> pkg_llm pkg_session_checkpoint_policy --> pkg_session @@ -1028,6 +1087,17 @@ flowchart TD pkg_tool_pwsh_persistent --> pkg_timeout pkg_tool_pwsh_persistent --> pkg_tools pkg_tool_pwsh_persistent --> pkg_working_directory + pkg_ssh --> pkg_brand + pkg_ssh --> pkg_fs + pkg_ssh --> pkg_fs_local + pkg_ssh --> pkg_fs_sandbox + pkg_ssh --> pkg_sandbox + pkg_ssh --> pkg_sandbox_local + pkg_ssh --> pkg_sandbox_policy + pkg_ssh --> pkg_session_projection + pkg_ssh --> pkg_subprocess + pkg_ssh --> pkg_subprocess_local + pkg_ssh --> pkg_util_values pkg_llm_replay --> pkg_compaction pkg_llm_replay --> pkg_deepseek_llm_api_extensions pkg_llm_replay --> pkg_llm @@ -1051,36 +1121,6 @@ flowchart TD pkg_token_meter --> pkg_llm_retry pkg_token_meter --> pkg_session pkg_token_meter --> pkg_session_projection - pkg_tool_executor_ptc --> pkg_agent - pkg_tool_executor_ptc --> pkg_llm - pkg_tool_executor_ptc --> pkg_ptc_runtime - pkg_tool_executor_ptc --> pkg_sandbox - pkg_tool_executor_ptc --> pkg_sandbox_policy - pkg_tool_executor_ptc --> pkg_scope - pkg_tool_executor_ptc --> pkg_session - pkg_tool_executor_ptc --> pkg_tools - pkg_tool_executor_ptc --> pkg_user_approval - pkg_tool_executor_ptc --> pkg_working_directory - pkg_fs_sandbox --> pkg_fs - pkg_fs_sandbox --> pkg_fs_local - pkg_fs_sandbox --> pkg_sandbox - pkg_fs_sandbox --> pkg_sandbox_policy - pkg_tool_fs --> pkg_attachment - pkg_tool_fs --> pkg_error - pkg_tool_fs --> pkg_fs - pkg_tool_fs --> pkg_llm - pkg_tool_fs --> pkg_sandbox - pkg_tool_fs --> pkg_sandbox_policy - pkg_tool_fs --> pkg_session - pkg_tool_fs --> pkg_system_prompt - pkg_tool_fs --> pkg_tools - pkg_tool_fs --> pkg_user_approval - pkg_tool_fs --> pkg_working_directory - pkg_tool_str_replace_editor --> pkg_fs - pkg_tool_str_replace_editor --> pkg_output_retention - pkg_tool_str_replace_editor --> pkg_sandbox - pkg_tool_str_replace_editor --> pkg_sandbox_policy - pkg_tool_str_replace_editor --> pkg_tools pkg_session_query --> pkg_llm pkg_session_query --> pkg_session pkg_session_query --> pkg_session_persistence @@ -1095,9 +1135,23 @@ flowchart TD pkg_api_settings_controller --> pkg_settings pkg_api_settings_controller --> pkg_typert_protocol pkg_web_app --> pkg_shell_env + pkg_cua --> pkg_attachment + pkg_cua --> pkg_error + pkg_cua --> pkg_ptc_runtime_node + pkg_cua --> pkg_scope + pkg_cua --> pkg_tool_executor_ptc + pkg_cua --> pkg_tools + pkg_cua --> pkg_user_questions pkg_deepseek_chat_import --> pkg_session pkg_deepseek_chat_import --> pkg_session_title pkg_deepseek_chat_import --> pkg_tool_web + pkg_experimental_auto_review --> pkg_agent + pkg_experimental_auto_review --> pkg_agent_instructions + pkg_experimental_auto_review --> pkg_llm + pkg_experimental_auto_review --> pkg_permission_presets + pkg_experimental_auto_review --> pkg_session + pkg_experimental_auto_review --> pkg_tools + pkg_experimental_auto_review --> pkg_working_directory pkg_experimental_forge_session --> pkg_experimental_forge pkg_experimental_forge_session --> pkg_llm pkg_experimental_forge_session --> pkg_sandbox_policy @@ -1106,6 +1160,14 @@ flowchart TD pkg_experimental_forge_session --> pkg_shell pkg_experimental_forge_session --> pkg_shell_env pkg_experimental_forge_session --> pkg_tools + pkg_webhook --> pkg_agent + pkg_webhook --> pkg_agent_default_model + pkg_webhook --> pkg_agent_preset_registry + pkg_webhook --> pkg_llm + pkg_webhook --> pkg_permission_presets + pkg_webhook --> pkg_session + pkg_webhook --> pkg_session_title + pkg_webhook --> pkg_workspace pkg_tool_cordis --> pkg_agent pkg_tool_cordis --> pkg_app_boot pkg_tool_cordis --> pkg_cordis_host_runner @@ -1113,15 +1175,6 @@ flowchart TD pkg_host_plugin_inventory --> pkg_agent_preset_registry pkg_host_plugin_inventory --> pkg_brand pkg_host_plugin_inventory --> pkg_typert_protocol - pkg_permission_presets --> pkg_agent - pkg_permission_presets --> pkg_commands - pkg_permission_presets --> pkg_sandbox - pkg_permission_presets --> pkg_sandbox_policy - pkg_permission_presets --> pkg_session - pkg_permission_presets --> pkg_session_projection - pkg_permission_presets --> pkg_shell - pkg_permission_presets --> pkg_typert_protocol - pkg_permission_presets --> pkg_user_approval pkg_mcp_client --> pkg_attachment pkg_mcp_client --> pkg_credentials pkg_mcp_client --> pkg_error @@ -1133,13 +1186,6 @@ flowchart TD pkg_mcp_client --> pkg_timeout pkg_mcp_client --> pkg_tools pkg_agent_preset --> pkg_agent_preset_registry - pkg_ptc_runtime_node --> pkg_fs - pkg_ptc_runtime_node --> pkg_ptc_runtime - pkg_ptc_runtime_node --> pkg_sandbox - pkg_ptc_runtime_node --> pkg_sandbox_policy - pkg_ptc_runtime_node --> pkg_session - pkg_ptc_runtime_node --> pkg_subprocess - pkg_ptc_runtime_node --> pkg_timeout pkg_session_telemetry_otel --> pkg_anonymous_user_id pkg_session_telemetry_otel --> pkg_command_feedback pkg_session_telemetry_otel --> pkg_llm @@ -1147,14 +1193,6 @@ flowchart TD pkg_session_telemetry_otel --> pkg_otel pkg_session_telemetry_otel --> pkg_session pkg_session_telemetry_otel --> pkg_session_telemetry - pkg_bash_sandbox --> pkg_bash_local - pkg_bash_sandbox --> pkg_sandbox - pkg_bash_sandbox --> pkg_sandbox_policy - pkg_bash_sandbox --> pkg_shell - pkg_pwsh_sandbox --> pkg_pwsh_local - pkg_pwsh_sandbox --> pkg_sandbox - pkg_pwsh_sandbox --> pkg_sandbox_policy - pkg_pwsh_sandbox --> pkg_shell pkg_tool_bash --> pkg_agent pkg_tool_bash --> pkg_jobs pkg_tool_bash --> pkg_llm @@ -1179,13 +1217,15 @@ flowchart TD pkg_tool_pwsh --> pkg_tools pkg_tool_pwsh --> pkg_user_approval pkg_tool_pwsh --> pkg_working_directory - pkg_terminal_bash --> pkg_agent - pkg_terminal_bash --> pkg_sandbox - pkg_terminal_bash --> pkg_sandbox_policy - pkg_terminal_bash --> pkg_session - pkg_terminal_bash --> pkg_subprocess - pkg_terminal_bash --> pkg_terminal - pkg_terminal_bash --> pkg_working_directory + pkg_fs_ssh --> pkg_fs + pkg_fs_ssh --> pkg_sandbox + pkg_fs_ssh --> pkg_sandbox_policy + pkg_fs_ssh --> pkg_ssh + pkg_sandbox_ssh --> pkg_sandbox + pkg_sandbox_ssh --> pkg_ssh + pkg_subprocess_ssh --> pkg_ssh + pkg_subprocess_ssh --> pkg_subprocess + pkg_subprocess_ssh --> pkg_subprocess_local pkg_agent_loop_testkit --> pkg_agent pkg_agent_loop_testkit --> pkg_agent_loop pkg_agent_loop_testkit --> pkg_fs_local @@ -1253,20 +1293,6 @@ flowchart TD pkg_compaction_tool_result_pruner --> pkg_llm pkg_compaction_tool_result_pruner --> pkg_session pkg_compaction_tool_result_pruner --> pkg_token_meter - pkg_cua --> pkg_attachment - pkg_cua --> pkg_error - pkg_cua --> pkg_ptc_runtime_node - pkg_cua --> pkg_scope - pkg_cua --> pkg_tool_executor_ptc - pkg_cua --> pkg_tools - pkg_cua --> pkg_user_questions - pkg_experimental_auto_review --> pkg_agent - pkg_experimental_auto_review --> pkg_agent_instructions - pkg_experimental_auto_review --> pkg_llm - pkg_experimental_auto_review --> pkg_permission_presets - pkg_experimental_auto_review --> pkg_session - pkg_experimental_auto_review --> pkg_tools - pkg_experimental_auto_review --> pkg_working_directory pkg_experimental_browser_use_runtime --> pkg_agent pkg_experimental_browser_use_runtime --> pkg_browser_use pkg_experimental_browser_use_runtime --> pkg_error @@ -1315,29 +1341,14 @@ flowchart TD pkg_tool_session_query --> pkg_system_prompt pkg_tool_session_query --> pkg_timeout pkg_tool_session_query --> pkg_tools - pkg_webhook --> pkg_agent - pkg_webhook --> pkg_agent_default_model - pkg_webhook --> pkg_agent_preset_registry - pkg_webhook --> pkg_llm - pkg_webhook --> pkg_permission_presets - pkg_webhook --> pkg_session - pkg_webhook --> pkg_session_title - pkg_webhook --> pkg_workspace + pkg_webhook_github --> pkg_credentials + pkg_webhook_github --> pkg_host_webserver + pkg_webhook_github --> pkg_session + pkg_webhook_github --> pkg_webhook pkg_mcp_manager --> pkg_mcp_client pkg_mcp_manager --> pkg_tools pkg_mcp_manager --> pkg_typert_protocol pkg_mcp_manager --> pkg_util_values - pkg_ssh --> pkg_brand - pkg_ssh --> pkg_fs - pkg_ssh --> pkg_fs_local - pkg_ssh --> pkg_fs_sandbox - pkg_ssh --> pkg_sandbox - pkg_ssh --> pkg_sandbox_local - pkg_ssh --> pkg_sandbox_policy - pkg_ssh --> pkg_session_projection - pkg_ssh --> pkg_subprocess - pkg_ssh --> pkg_subprocess_local - pkg_ssh --> pkg_util_values pkg_goal_round_driver --> pkg_agent pkg_goal_round_driver --> pkg_goal pkg_goal_round_driver --> pkg_llm @@ -1476,24 +1487,11 @@ flowchart TD pkg_tool_ralph --> pkg_system_prompt pkg_tool_ralph --> pkg_tools pkg_tool_ralph --> pkg_workflow - pkg_webhook_github --> pkg_credentials - pkg_webhook_github --> pkg_host_webserver - pkg_webhook_github --> pkg_session - pkg_webhook_github --> pkg_webhook pkg_sdk_protocol --> pkg_commands pkg_sdk_protocol --> pkg_llm pkg_sdk_protocol --> pkg_session pkg_sdk_protocol --> pkg_subagent pkg_sdk_protocol --> pkg_user_questions - pkg_fs_ssh --> pkg_fs - pkg_fs_ssh --> pkg_sandbox - pkg_fs_ssh --> pkg_sandbox_policy - pkg_fs_ssh --> pkg_ssh - pkg_sandbox_ssh --> pkg_sandbox - pkg_sandbox_ssh --> pkg_ssh - pkg_subprocess_ssh --> pkg_ssh - pkg_subprocess_ssh --> pkg_subprocess - pkg_subprocess_ssh --> pkg_subprocess_local pkg_agent_team --> pkg_agent pkg_agent_team --> pkg_llm pkg_agent_team --> pkg_session @@ -1838,6 +1836,7 @@ flowchart TD | [`user-approval`](../packages/interaction/user-approval) | `interaction` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | | [`user-questions`](../packages/interaction/user-questions) | `interaction` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`typert-protocol`](../packages/typert/protocol) | | [`jobs`](../packages/jobs/jobs) | `jobs` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`session`](../packages/core/session), [`workspace`](../packages/workspace/workspace) | +| [`sandbox-policy`](../packages/sandbox/sandbox-policy) | `sandbox` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | | [`session-telemetry`](../packages/session/session-telemetry) | `session` | [`agent`](../packages/core/agent), [`session`](../packages/core/session) | | [`session-title`](../packages/session/session-title) | `session` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection) | | [`working-directory`](../packages/session/working-directory) | `session` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) | @@ -1846,15 +1845,24 @@ flowchart TD | [`workflow`](../packages/workflow/workflow) | `workflow` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`tools`](../packages/core/tools) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`user-approval`](../packages/interaction/user-approval) | | [`command-goal`](../packages/goal/command-goal) | `goal` | [`commands`](../packages/interaction/commands), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm) | +| [`fs-sandbox`](../packages/fs/fs-sandbox) | `fs` | [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy) | | [`compaction`](../packages/compaction/compaction) | `compaction` | [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`command-feedback`](../packages/feedback/command-feedback) | `feedback` | [`anonymous-user-id`](../packages/identity/anonymous-user-id), [`commands`](../packages/interaction/commands), [`session`](../packages/core/session), [`typert-protocol`](../packages/typert/protocol) | +| [`permission-presets`](../packages/interaction/permission-presets) | `interaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`jobs-local`](../packages/jobs/jobs-local) | `jobs` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`scope`](../packages/core/scope), [`timeout`](../packages/util/timeout) | +| [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node) | `ptc-runtime` | [`fs`](../packages/fs/fs), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`session-title-llm`](../packages/session/session-title-llm) | `session` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`timeout`](../packages/util/timeout) | +| [`bash-sandbox`](../packages/shell/bash-sandbox) | `shell` | [`bash-local`](../packages/shell/bash-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | +| [`pwsh-sandbox`](../packages/shell/pwsh-sandbox) | `shell` | [`pwsh-local`](../packages/shell/pwsh-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | +| [`terminal-bash`](../packages/terminal/terminal-bash) | `terminal` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`terminal`](../packages/terminal/terminal), [`working-directory`](../packages/session/working-directory) | | [`agent-loop`](../packages/core/agent-loop) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`agent-tool-presentation`](../packages/core/agent-tool-presentation) | `core` | [`tools`](../packages/core/tools) | | [`tool-executor-native`](../packages/core/tool-executor-native) | `core` | [`tools`](../packages/core/tools) | +| [`tool-executor-ptc`](../packages/core/tool-executor-ptc) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-goal`](../packages/goal/tool-goal) | `goal` | [`agent`](../packages/core/agent), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | +| [`tool-fs`](../packages/fs/tool-fs) | `fs` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-fs-search`](../packages/fs/tool-fs-search) | `fs` | [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`spill`](../packages/spill/spill), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | +| [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) | `fs` | [`fs`](../packages/fs/fs), [`output-retention`](../packages/util/output-retention), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tools`](../packages/core/tools) | | [`tool-skill`](../packages/skill/tool-skill) | `skill` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`skill`](../packages/skill/skill), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-workspace-dependencies`](../packages/skill/tool-workspace-dependencies) | `skill` | [`error`](../packages/util/error), [`tools`](../packages/core/tools) | | [`tool-web`](../packages/web/tool-web) | `web` | [`llm`](../packages/llm/llm), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`web`](../packages/web/web) | @@ -1889,38 +1897,35 @@ flowchart TD | [`tool-lsp`](../packages/lsp/tool-lsp) | `lsp` | [`llm`](../packages/llm/llm), [`lsp`](../packages/lsp/lsp), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`mcp-resources`](../packages/mcp/mcp-resources) | `mcp` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`agent-preset-registry`](../packages/preset/agent-preset-registry) | `preset` | [`agent`](../packages/core/agent), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`settings`](../packages/settings/settings), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol) | -| [`sandbox-policy`](../packages/sandbox/sandbox-policy) | `sandbox` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | | [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy) | `session` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`tools`](../packages/core/tools) | | [`session-title-first-prompt-llm`](../packages/session/session-title-first-prompt-llm) | `session` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`session-title-llm`](../packages/session/session-title-llm) | | [`shell-env`](../packages/shell/shell-env) | `shell` | [`app-boot`](../packages/boot/app-boot), [`error`](../packages/util/error), [`home-paths`](../packages/util/home-paths), [`shell`](../packages/shell/shell), [`tools`](../packages/core/tools) | | [`tool-bash-persistent`](../packages/shell/tool-bash-persistent) | `shell` | [`agent`](../packages/core/agent), [`output-retention`](../packages/util/output-retention), [`terminal`](../packages/terminal/terminal), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-pwsh-persistent`](../packages/shell/tool-pwsh-persistent) | `shell` | [`agent`](../packages/core/agent), [`output-retention`](../packages/util/output-retention), [`terminal`](../packages/terminal/terminal), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | +| [`ssh`](../packages/ssh/ssh) | `ssh` | [`brand`](../packages/util/brand), [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`fs-sandbox`](../packages/fs/fs-sandbox), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-local`](../packages/sandbox/sandbox-local), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session-projection`](../packages/session/session-projection), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local), [`util-values`](../packages/util/values) | | [`llm-replay`](../packages/test-support/llm-replay) | `test-support` | [`compaction`](../packages/compaction/compaction), [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) | | [`tool-testkit`](../packages/test-support/tool-testkit) | `test-support` | [`llm`](../packages/llm/llm), [`tools`](../packages/core/tools) | | [`tool-workflow`](../packages/workflow/tool-workflow) | `workflow` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow) | | [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | `llm` | [`agent`](../packages/core/agent), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions), [`session`](../packages/core/session) | | [`token-meter`](../packages/llm/token-meter) | `llm` | [`compaction`](../packages/compaction/compaction), [`compaction-image-offload`](../packages/compaction/compaction-image-offload), [`llm`](../packages/llm/llm), [`llm-retry`](../packages/llm/llm-retry), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection) | -| [`tool-executor-ptc`](../packages/core/tool-executor-ptc) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`fs-sandbox`](../packages/fs/fs-sandbox) | `fs` | [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy) | -| [`tool-fs`](../packages/fs/tool-fs) | `fs` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) | `fs` | [`fs`](../packages/fs/fs), [`output-retention`](../packages/util/output-retention), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`tools`](../packages/core/tools) | | [`session-query`](../packages/session-query/session-query) | `session-query` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-title`](../packages/session/session-title), [`tool-todo`](../packages/todo/tool-todo) | | [`api-settings-controller`](../packages/api/settings-controller) | `api` | [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`credentials`](../packages/credentials/credentials), [`native-command`](../packages/util/native-command), [`session`](../packages/core/session), [`settings`](../packages/settings/settings), [`typert-protocol`](../packages/typert/protocol) | | [`web-app`](../packages/bundle/web-app) | `bundle` | [`shell-env`](../packages/shell/shell-env) | +| [`cua`](../packages/experimental/cua) | `experimental` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`scope`](../packages/core/scope), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) | | [`deepseek-chat-import`](../packages/experimental/deepseek-chat-import) | `experimental` | [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`tool-web`](../packages/web/tool-web) | +| [`experimental-auto-review`](../packages/experimental/auto-review) | `experimental` | [`agent`](../packages/core/agent), [`agent-instructions`](../packages/context/agent-instructions), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-forge-session`](../packages/experimental/forge-session) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`llm`](../packages/llm/llm), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`tools`](../packages/core/tools) | +| [`webhook`](../packages/experimental/webhook) | `experimental` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`workspace`](../packages/workspace/workspace) | | [`tool-cordis`](../packages/extensions/tool-cordis) | `extensions` | [`agent`](../packages/core/agent), [`app-boot`](../packages/boot/app-boot), [`cordis-host-runner`](../packages/extensions/cordis-host-runner), [`tools`](../packages/core/tools) | | [`host-plugin-inventory`](../packages/host/plugin-inventory) | `host` | [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`brand`](../packages/util/brand), [`typert-protocol`](../packages/typert/protocol) | -| [`permission-presets`](../packages/interaction/permission-presets) | `interaction` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`shell`](../packages/shell/shell), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`mcp-client`](../packages/mcp/mcp-client) | `mcp` | [`attachment`](../packages/attachment/attachment), [`credentials`](../packages/credentials/credentials), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`mcp-resources`](../packages/mcp/mcp-resources), [`scope`](../packages/core/scope), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools) | | [`agent-preset`](../packages/preset/agent-preset) | `preset` | [`agent-preset-registry`](../packages/preset/agent-preset-registry) | -| [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node) | `ptc-runtime` | [`fs`](../packages/fs/fs), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`session-telemetry-otel`](../packages/session/session-telemetry-otel) | `session` | [`anonymous-user-id`](../packages/identity/anonymous-user-id), [`command-feedback`](../packages/feedback/command-feedback), [`llm`](../packages/llm/llm), [`message-feedback`](../packages/feedback/message-feedback), [`otel`](../packages/telemetry/otel), [`session`](../packages/core/session), [`session-telemetry`](../packages/session/session-telemetry) | -| [`bash-sandbox`](../packages/shell/bash-sandbox) | `shell` | [`bash-local`](../packages/shell/bash-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | -| [`pwsh-sandbox`](../packages/shell/pwsh-sandbox) | `shell` | [`pwsh-local`](../packages/shell/pwsh-local), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell) | | [`tool-bash`](../packages/shell/tool-bash) | `shell` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | | [`tool-pwsh`](../packages/shell/tool-pwsh) | `shell` | [`agent`](../packages/core/agent), [`jobs`](../packages/jobs/jobs), [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`shell`](../packages/shell/shell), [`shell-env`](../packages/shell/shell-env), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-approval`](../packages/interaction/user-approval), [`working-directory`](../packages/session/working-directory) | -| [`terminal-bash`](../packages/terminal/terminal-bash) | `terminal` | [`agent`](../packages/core/agent), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`terminal`](../packages/terminal/terminal), [`working-directory`](../packages/session/working-directory) | +| [`fs-ssh`](../packages/ssh/fs-ssh) | `ssh` | [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`ssh`](../packages/ssh/ssh) | +| [`sandbox-ssh`](../packages/ssh/sandbox-ssh) | `ssh` | [`sandbox`](../packages/sandbox/sandbox), [`ssh`](../packages/ssh/ssh) | +| [`subprocess-ssh`](../packages/ssh/subprocess-ssh) | `ssh` | [`ssh`](../packages/ssh/ssh), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local) | | [`agent-loop-testkit`](../packages/test-support/agent-loop-testkit) | `test-support` | [`agent`](../packages/core/agent), [`agent-loop`](../packages/core/agent-loop), [`fs-local`](../packages/fs/fs-local), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`subagent`](../packages/subagent/subagent) | `subagent` | [`agent`](../packages/core/agent), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`attachment`](../packages/attachment/attachment), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`session-query`](../packages/session-query/session-query), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval), [`util-time`](../packages/util/time), [`working-directory`](../packages/session/working-directory), [`workspace`](../packages/workspace/workspace) | | [`spill-policy`](../packages/spill/spill-policy) | `spill` | [`attachment`](../packages/attachment/attachment), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`output-retention`](../packages/util/output-retention), [`session`](../packages/core/session), [`spill`](../packages/spill/spill), [`token-meter`](../packages/llm/token-meter), [`tools`](../packages/core/tools) | @@ -1929,17 +1934,14 @@ flowchart TD | [`acp`](../packages/acp/acp) | `acp` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`llm`](../packages/llm/llm), [`mcp-client`](../packages/mcp/mcp-client), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`token-meter`](../packages/llm/token-meter), [`user-approval`](../packages/interaction/user-approval) | | [`plugin-manager`](../packages/boot/plugin-manager) | `boot` | [`error`](../packages/util/error), [`hmr`](../packages/boot/hmr), [`host-plugin-inventory`](../packages/host/plugin-inventory), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-approval`](../packages/interaction/user-approval) | | [`compaction-tool-result-pruner`](../packages/compaction/compaction-tool-result-pruner) | `compaction` | [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`token-meter`](../packages/llm/token-meter) | -| [`cua`](../packages/experimental/cua) | `experimental` | [`attachment`](../packages/attachment/attachment), [`error`](../packages/util/error), [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), [`scope`](../packages/core/scope), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) | -| [`experimental-auto-review`](../packages/experimental/auto-review) | `experimental` | [`agent`](../packages/core/agent), [`agent-instructions`](../packages/context/agent-instructions), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-browser-use-runtime`](../packages/experimental/browser-use-runtime) | `experimental` | [`agent`](../packages/core/agent), [`browser-use`](../packages/browser-use/browser-use), [`error`](../packages/util/error), [`mcp-client`](../packages/mcp/mcp-client), [`scope`](../packages/core/scope), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`experimental-claude-code-mods`](../packages/experimental/claude-code-mods) | `experimental` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`storage-domain`](../packages/storage/storage-domain), [`subprocess`](../packages/subprocess/subprocess), [`token-meter`](../packages/llm/token-meter), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) | | [`experimental-forge-github`](../packages/experimental/forge-github) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`experimental-forge-session`](../packages/experimental/forge-session), [`subprocess`](../packages/subprocess/subprocess) | | [`experimental-worktree`](../packages/experimental/worktree) | `experimental` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-query`](../packages/session-query/session-query), [`settings`](../packages/settings/settings), [`subprocess`](../packages/subprocess/subprocess), [`working-directory`](../packages/session/working-directory), [`workspace`](../packages/workspace/workspace) | | [`forge-gitlab`](../packages/experimental/forge-gitlab) | `experimental` | [`experimental-forge`](../packages/experimental/forge), [`experimental-forge-session`](../packages/experimental/forge-session), [`subprocess`](../packages/subprocess/subprocess) | | [`tool-session-query`](../packages/experimental/tool-session-query) | `experimental` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-query`](../packages/session-query/session-query), [`system-prompt`](../packages/core/system-prompt), [`timeout`](../packages/util/timeout), [`tools`](../packages/core/tools) | -| [`webhook`](../packages/experimental/webhook) | `experimental` | [`agent`](../packages/core/agent), [`agent-default-model`](../packages/core/agent-default-model), [`agent-preset-registry`](../packages/preset/agent-preset-registry), [`llm`](../packages/llm/llm), [`permission-presets`](../packages/interaction/permission-presets), [`session`](../packages/core/session), [`session-title`](../packages/session/session-title), [`workspace`](../packages/workspace/workspace) | +| [`webhook-github`](../packages/experimental/webhook-github) | `experimental` | [`credentials`](../packages/credentials/credentials), [`host-webserver`](../packages/host/webserver), [`session`](../packages/core/session), [`webhook`](../packages/experimental/webhook) | | [`mcp-manager`](../packages/mcp/mcp-manager) | `mcp` | [`mcp-client`](../packages/mcp/mcp-client), [`tools`](../packages/core/tools), [`typert-protocol`](../packages/typert/protocol), [`util-values`](../packages/util/values) | -| [`ssh`](../packages/ssh/ssh) | `ssh` | [`brand`](../packages/util/brand), [`fs`](../packages/fs/fs), [`fs-local`](../packages/fs/fs-local), [`fs-sandbox`](../packages/fs/fs-sandbox), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-local`](../packages/sandbox/sandbox-local), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session-projection`](../packages/session/session-projection), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local), [`util-values`](../packages/util/values) | | [`goal-round-driver`](../packages/goal/goal-round-driver) | `goal` | [`agent`](../packages/core/agent), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent) | | [`subagent-acp`](../packages/subagent/subagent-acp) | `subagent` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | | [`subagent-claude-code`](../packages/subagent/subagent-claude-code) | `subagent` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) | @@ -1959,11 +1961,7 @@ flowchart TD | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | `experimental` | [`experimental-worktree`](../packages/experimental/worktree), [`tools`](../packages/core/tools) | | [`hooks-claude-code`](../packages/experimental/hooks-claude-code) | `experimental` | [`agent`](../packages/core/agent), [`hook-protocol`](../packages/experimental/hook-protocol), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) | | [`tool-ralph`](../packages/experimental/tool-ralph) | `experimental` | [`agent`](../packages/core/agent), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow) | -| [`webhook-github`](../packages/experimental/webhook-github) | `experimental` | [`credentials`](../packages/credentials/credentials), [`host-webserver`](../packages/host/webserver), [`session`](../packages/core/session), [`webhook`](../packages/experimental/webhook) | | [`sdk-protocol`](../packages/sdk/protocol) | `sdk` | [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-questions`](../packages/interaction/user-questions) | -| [`fs-ssh`](../packages/ssh/fs-ssh) | `ssh` | [`fs`](../packages/fs/fs), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`ssh`](../packages/ssh/ssh) | -| [`sandbox-ssh`](../packages/ssh/sandbox-ssh) | `ssh` | [`sandbox`](../packages/sandbox/sandbox), [`ssh`](../packages/ssh/ssh) | -| [`subprocess-ssh`](../packages/ssh/subprocess-ssh) | `ssh` | [`ssh`](../packages/ssh/ssh), [`subprocess`](../packages/subprocess/subprocess), [`subprocess-local`](../packages/subprocess/subprocess-local) | | [`agent-team`](../packages/team/agent-team) | `team` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-persistence`](../packages/session/session-persistence), [`session-projection`](../packages/session/session-projection), [`subagent`](../packages/subagent/subagent), [`typert-protocol`](../packages/typert/protocol) | | [`workflow-ptc`](../packages/workflow/workflow-ptc) | `workflow` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`ptc-runtime`](../packages/ptc-runtime/ptc-runtime), [`sandbox`](../packages/sandbox/sandbox), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`tools`](../packages/core/tools), [`workflow`](../packages/workflow/workflow), [`working-directory`](../packages/session/working-directory) | | [`tool-subagent-control`](../packages/subagent/tool-subagent-control) | `subagent` | [`agent`](../packages/core/agent), [`agent-team`](../packages/team/agent-team), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) | diff --git a/docs/subsystems/sandbox.md b/docs/subsystems/sandbox.md index 6ca7144af3..eec53fd71e 100644 --- a/docs/subsystems/sandbox.md +++ b/docs/subsystems/sandbox.md @@ -77,7 +77,7 @@ interface SandboxExecutionPolicy { ```ts type-equiv /** Inputs that select the sandbox policy for one capability call. */ interface SandboxPolicyRequest { - /** Calling session; its workspace root becomes the workspace boundary. */ + /** Calling session; its immutable cwd becomes the workspace boundary. */ session?: Session /** Explicit approved mode override, which outranks session policy. */ mode?: SandboxMode @@ -201,26 +201,22 @@ Source: [`packages/sandbox/sandbox/src/index.ts`](../../packages/sandbox/sandbox ### `ctx.sandboxPolicy` — `SandboxPolicyService` -The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session's mode log and workspace root travel together to every enforcing capability. - -A session's workspace root comes from the working-directory service when it is mounted: the checkout the Session works in, which a worktree relocation moves. A linked checkout keeps its Git administration directory and the repository's common directory outside that root; prepare derives them through the execution-world filesystem once per root, and `resolve` adds the derived directories to `additionalWritableRoots`. Tool executions await that derivation in `tools/pre-execute`; Session creation and every directory change start it early. +The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session's mode log and immutable cwd travel together to every enforcing capability. ```ts cordis-catalog /** * Resolve the complete policy for one capability call. An approved explicit * mode outranks the session's last `sandbox/mode` event, which outranks the - * deployment default. A session's workspace root is its workspace-write - * boundary, and the Git administration directories {@link prepare} derived - * for that root join the configured extra writable directories; the - * configured root is the fallback for agentless calls and, without the - * working-directory service, sessions without a header directory. Configured - * extra roots, this Session's active registrations, and the derived Git - * directories are snapshotted together; existing operations and processes - * keep their policy. + * deployment default. A session's working directory is its workspace-write + * boundary, so a Host move of the Session moves the boundary; the configured + * root is the fallback for agentless calls and, without the working-directory + * service, sessions without a header directory. Configured extra roots and + * this Session's active registrations are snapshotted together; existing + * operations and processes keep their policy. * @param request - optional session and approved mode override. - * @returns the fully resolved per-call mode, absolute workspace root, and extra writable directories. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the selected root is relative or - * contains a NUL byte. + * @returns the fully resolved per-call mode and absolute workspace root. + * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's directory is + * relative or contains a NUL byte. */ resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy @@ -244,23 +240,6 @@ registerWritableRoot(session: Session, directory: string): () => void * @returns the last logged mode, or `undefined` without one. */ overrideOf(session: Session): SandboxMode | undefined - -/** - * Derive the Git administration directories a linked checkout writes outside itself, as - * `./linked-checkout.ts` reads them. For a Session the checkout is its workspace root, and the next - * {@link resolve} for that Session grants the result. For a named `directory`, a Host operation that - * runs in a checkout no Session works in adds the result to the policy it builds; `resolve` is - * unaffected. One derivation runs per directory and its result is kept once the layout was read, so a - * pointer written later does not widen a policy until a Host operation moves a Session's workspace to - * that directory again; a derived directory that disappears is derived again, and a failed read is - * logged once per directory and retried on the next call. - * @param target - Session whose workspace root is inspected, or the checkout directory itself. - * @param signal - caller cancellation, checked before and after the shared derivation. - * @returns the derived directories outside the checkout, canonical in the execution world. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the directory is relative or - * contains a NUL byte. - */ -async prepare(target: { session: Session } | { directory: string }, signal?: AbortSignal): Promise ``` Types: [Session](session.md) diff --git a/docs/subsystems/sandbox.zh.md b/docs/subsystems/sandbox.zh.md index aea07cb114..6176b98861 100644 --- a/docs/subsystems/sandbox.zh.md +++ b/docs/subsystems/sandbox.zh.md @@ -77,7 +77,7 @@ interface SandboxExecutionPolicy { ```ts type-equiv /** Inputs that select the sandbox policy for one capability call. */ interface SandboxPolicyRequest { - /** Calling session; its workspace root becomes the workspace boundary. */ + /** Calling session; its immutable cwd becomes the workspace boundary. */ session?: Session /** Explicit approved mode override, which outranks session policy. */ mode?: SandboxMode @@ -201,26 +201,22 @@ Source: [`packages/sandbox/sandbox/src/index.ts`](../../packages/sandbox/sandbox ### `ctx.sandboxPolicy` — `SandboxPolicyService` -The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session's mode log and workspace root travel together to every enforcing capability. - -A session's workspace root comes from the working-directory service when it is mounted: the checkout the Session works in, which a worktree relocation moves. A linked checkout keeps its Git administration directory and the repository's common directory outside that root; prepare derives them through the execution-world filesystem once per root, and `resolve` adds the derived directories to `additionalWritableRoots`. Tool executions await that derivation in `tools/pre-execute`; Session creation and every directory change start it early. +The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session's mode log and immutable cwd travel together to every enforcing capability. ```ts cordis-catalog /** * Resolve the complete policy for one capability call. An approved explicit * mode outranks the session's last `sandbox/mode` event, which outranks the - * deployment default. A session's workspace root is its workspace-write - * boundary, and the Git administration directories {@link prepare} derived - * for that root join the configured extra writable directories; the - * configured root is the fallback for agentless calls and, without the - * working-directory service, sessions without a header directory. Configured - * extra roots, this Session's active registrations, and the derived Git - * directories are snapshotted together; existing operations and processes - * keep their policy. + * deployment default. A session's working directory is its workspace-write + * boundary, so a Host move of the Session moves the boundary; the configured + * root is the fallback for agentless calls and, without the working-directory + * service, sessions without a header directory. Configured extra roots and + * this Session's active registrations are snapshotted together; existing + * operations and processes keep their policy. * @param request - optional session and approved mode override. - * @returns the fully resolved per-call mode, absolute workspace root, and extra writable directories. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the selected root is relative or - * contains a NUL byte. + * @returns the fully resolved per-call mode and absolute workspace root. + * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's directory is + * relative or contains a NUL byte. */ resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy @@ -244,23 +240,6 @@ registerWritableRoot(session: Session, directory: string): () => void * @returns the last logged mode, or `undefined` without one. */ overrideOf(session: Session): SandboxMode | undefined - -/** - * Derive the Git administration directories a linked checkout writes outside itself, as - * `./linked-checkout.ts` reads them. For a Session the checkout is its workspace root, and the next - * {@link resolve} for that Session grants the result. For a named `directory`, a Host operation that - * runs in a checkout no Session works in adds the result to the policy it builds; `resolve` is - * unaffected. One derivation runs per directory and its result is kept once the layout was read, so a - * pointer written later does not widen a policy until a Host operation moves a Session's workspace to - * that directory again; a derived directory that disappears is derived again, and a failed read is - * logged once per directory and retried on the next call. - * @param target - Session whose workspace root is inspected, or the checkout directory itself. - * @param signal - caller cancellation, checked before and after the shared derivation. - * @returns the derived directories outside the checkout, canonical in the execution world. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the directory is relative or - * contains a NUL byte. - */ -async prepare(target: { session: Session } | { directory: string }, signal?: AbortSignal): Promise ``` Types: [Session](session.zh.md) diff --git a/docs/subsystems/worktrees.i18n.yaml b/docs/subsystems/worktrees.i18n.yaml index 0d979e8e5b..58fdfa2521 100644 --- a/docs/subsystems/worktrees.i18n.yaml +++ b/docs/subsystems/worktrees.i18n.yaml @@ -6,8 +6,8 @@ en: a0def5edd90e9189 zh: 96c3f6fa48eb850d /git-worktrees/creation-and-retention: - en: 43aee0db00374ccf - zh: 38b4688031efaf4a + en: d33f26f44f51da9f + zh: 5c7577a1981b297c /git-worktrees/request-and-result: en: 5801c5909e1873a0 zh: 5c36a4c4ea97ecad diff --git a/docs/subsystems/worktrees.md b/docs/subsystems/worktrees.md index 64ed31defe..261a408ad8 100644 --- a/docs/subsystems/worktrees.md +++ b/docs/subsystems/worktrees.md @@ -8,7 +8,7 @@ The experimental [`dsh-experimental-worktree`](../../packages/experimental/workt The calling Session's current directory selects the source repository. Creation pins the requested local commit, branch, or tag before allocating the checkout; omission selects `HEAD`. A request may instead ask to fetch a remote-tracking branch of a configured remote first, which fetches only that branch and pins the fetched commit. Each name must identify a new branch and an unused checkout path. The operation neither fetches other commits or missing objects nor copies staged, unstaged, untracked, or ignored files from the source checkout. -The default destination is `/.agents/worktrees/`. `repositoryRoot` is the top-level directory of the caller’s current checkout; a linked checkout therefore contains its own pool. The service writes a `.gitignore` containing `*` and a trailing newline only when its allocation creates the configured pool directory. Existing files and ignore rules are preserved. The calling Session’s resolved sandbox policy must permit writes to the destination and shared Git administration directory; for a linked checkout the [sandbox policy](sandbox.md) grants that directory before creation writes. Successful Git setup precedes the working-directory change. +The default destination is `/.agents/worktrees/`. `repositoryRoot` is the top-level directory of the caller’s current checkout; a linked checkout therefore contains its own pool. The service writes a `.gitignore` containing `*` and a trailing newline only when its allocation creates the configured pool directory. Existing files and ignore rules are preserved. The calling Session’s existing sandbox policy must permit writes to the destination and shared Git administration directory. Successful Git setup precedes the working-directory change. `ctx.worktrees.enter(agent, { name })` moves the Session into an existing worktree in the pool of the checkout it works in. The `enter_worktree` tool calls it first for a named request without a start revision, and calls `create` only when it reports `WORKTREE_NOT_FOUND`. The directory must lie inside that pool and be a registered worktree of the repository: a missing name, an unregistered directory, and a link that leaves the pool fail with `WORKTREE_NOT_FOUND`. Entry changes neither Git state nor files and records itself in the Session log. diff --git a/docs/subsystems/worktrees.zh.md b/docs/subsystems/worktrees.zh.md index 62c14b0f04..668d19be62 100644 --- a/docs/subsystems/worktrees.zh.md +++ b/docs/subsystems/worktrees.zh.md @@ -8,7 +8,7 @@ 调用方 Session 的当前目录决定源仓库。创建操作在分配检出目录前,将请求的本地提交、分支或标签固定为具体提交;省略时选择 `HEAD`。请求也可以要求先获取某个已配置远程的远程跟踪分支,此时只获取这一个分支,并固定获取到的提交。每个名称必须对应新分支与未使用的检出路径。操作既不获取其他提交或缺失对象,也不复制源检出目录中的暂存、未暂存、未跟踪或被忽略文件。 -默认目标为 `/.agents/worktrees/`。`repositoryRoot` 是调用方当前检出目录的顶层目录;因此,链接检出目录会在自身内部保存工作树父目录。仅当服务的分配操作创建了配置指定的父目录时,服务才会写入内容为 `*` 加换行符的 `.gitignore`。已有文件与忽略规则保持不变。调用方 Session 解析后的沙箱策略必须允许写入目标目录与共享 Git 管理目录;对于链接检出目录,[沙箱策略](sandbox.zh.md)会在创建写入之前授权该目录。Git 初始化成功后才改变工作目录。 +默认目标为 `/.agents/worktrees/`。`repositoryRoot` 是调用方当前检出目录的顶层目录;因此,链接检出目录会在自身内部保存工作树父目录。仅当服务的分配操作创建了配置指定的父目录时,服务才会写入内容为 `*` 加换行符的 `.gitignore`。已有文件与忽略规则保持不变。调用方 Session 的现有沙箱策略必须允许写入目标目录与共享 Git 管理目录。Git 初始化成功后才改变工作目录。 `ctx.worktrees.enter(agent, { name })` 把 Session 移入它所在检出的池中已有的工作树。`enter_worktree` 工具对带名称且不带起始修订的请求先调用它,只有它报告 `WORKTREE_NOT_FOUND` 时才调用 `create`。该目录必须位于池内,并且是仓库已登记的工作树:名称不存在、目录未登记、链接指向池外都以 `WORKTREE_NOT_FOUND` 失败。进入不改变 Git 状态和文件,并在 Session 日志中记录这次进入。 diff --git a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.i18n.yaml b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.i18n.yaml index 0dfad91dcd..5790c42184 100644 --- a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.i18n.yaml +++ b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.i18n.yaml @@ -3,14 +3,14 @@ # After editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.md /: - en: e2b7f9676fd16434 - zh: 3bef7d3d4af02d01 + en: 8e9487f2e34d2fb5 + zh: 490859f7f2bda707 /the-workspace-write-boundary-follows-the-session-s-working-directory: en: 0bb89d78c6080f49 zh: 1f850e8fca4ab4b4 /the-workspace-write-boundary-follows-the-session-s-working-directory/change: - en: 56dcc3f10f0c75f2 - zh: 9f195772639dd0d0 + en: 6285cb3bb9343ae3 + zh: 216498974cd862f9 /the-workspace-write-boundary-follows-the-session-s-working-directory/migration: - en: 7883d340f041f4b6 - zh: dc4e938b95827206 + en: dc1cd896ea0e8dfc + zh: adfdfb550f71ebc9 diff --git a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.md b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.md index 14944a5bfd..63947bdd95 100644 --- a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.md +++ b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.md @@ -1,6 +1,6 @@ --- kind: upgrade-guide -description: "The workspace-write boundary follows the Session's working directory instead of its original project, and a linked worktree's Git directories become writable." +description: "The workspace-write boundary follows the Session's working directory instead of its original project, so a Session in a worktree can no longer write the repository's Git directory." --- # The `workspace-write` boundary follows the Session's working directory @@ -8,18 +8,18 @@ English | [中文](guide.zh.md) ## Change -`ctx.sandboxPolicy.resolve({ session })` returns the Session's working directory as `workspaceRoot`: the checkout the Session works in. Before, it returned the original project recorded in the Session header for the whole Session. A Session that enters a worktree through `enter_worktree` or the forge New worktree option can now write only inside that worktree; the original project is no longer writable as a whole. The boundary moves with every Host move of the Session's directory, including SDK `setWorkingDirectory` (`set_working_directory` in Python) and a child started through `ctx.subagents.start({ cwd })`; a `working-directory/change` recorded before this release does not move it. +`ctx.sandboxPolicy.resolve({ session })` returns the Session's working directory as `workspaceRoot`: the checkout the Session works in. Before, it returned the original project recorded in the Session header for the whole Session. A Session that enters a worktree through `enter_worktree` or the forge New worktree option can now write only inside that worktree; the original project is no longer writable. The boundary moves with every Host move of the Session's directory, including SDK `setWorkingDirectory` (`set_working_directory` in Python) and a child started through `ctx.subagents.start({ cwd })`; a `working-directory/change` recorded before this release does not move it. -For a linked worktree, the policy derives the repository's common directory from the checkout's `.git` pointer, accepting only the `/worktrees/` layout Git writes with its `commondir` and `gitdir` pointers, and adds it to `additionalWritableRoots`, so `git commit` and `git checkout` work inside a worktree under `workspace-write`. That grant also covers the shared `.git/hooks` and `.git/config`, as a Session in the main checkout already had. On Windows only the harness `write` and `edit` tools honor that grant; confined processes keep their workspace and private-temp permissions. +The repository's Git directory lies outside a linked worktree. Under `workspace-write`, `git add`, `git commit`, and other commands that write it are therefore denied inside a worktree unless a grant covers that directory. Before, a worktree inside the original project shared the project's boundary, which contained `.git`. The policy reads no Git files and derives no grant. The Files tree, directory listings and watches, deliverables and change summaries, open-in-app actions, and Session rows read the same directory. `WorkspaceChangesSummary.cwd` is the directory the turn started in, no longer the original project. -Who observes it: operators who relied on a worktree Session still writing its original project, deployments that granted a worktree's `.git` through `additionalWritableRoots`, and Host plugins that read `WorkspaceChangesSummary.cwd` as the original project. +Who observes it: operators and models that commit from a worktree Session under `workspace-write`, operators who relied on a worktree Session still writing its original project, and Host plugins that read `WorkspaceChangesSummary.cwd` as the original project. ## Migration -1. Remove `additionalWritableRoots` entries that only named a linked worktree's `.git/worktrees/` or common `.git` directory from `cordis.yml`; keep entries for unrelated directories. +1. To let worktree Sessions commit under `workspace-write`, add the repository's Git directory, such as `/repo/.git`, to `additionalWritableRoots` of `@deepseek-ai/dsh-sandbox-policy` in `cordis.yml`, or register it for one Session from a Host plugin with `ctx.sandboxPolicy.registerWritableRoot(session, directory)`. The grant also covers `.git/hooks` and `.git/config`; use it for trusted work only. Without a grant, the model requests escalation for each such command where approvals are enabled. 2. Where a task must write the original project after entering a worktree, leave with `exit_worktree()` or the forge panel's continue-in-project action, or keep the Session in the original project; the boundary follows that change. Where an SDK client moved the directory only to change where relative paths resolve, pass absolute paths or the shell's `workdir` instead. 3. In Host plugins that consume `ctx.workspaceChanges.summary`, read the original project from the Session header's `cwd`; `WorkspaceChangesSummary.cwd` is the directory listed `path` values are relative to. 4. Where `cordis.yml` sets the sandbox policy's `workspaceRoot` to bound Sessions without a header directory, set `defaultDirectory` of `@deepseek-ai/dsh-working-directory` to the same directory; that directory now bounds them. -5. Confirm: in a Session opened inside a linked worktree, `git commit` succeeds under `workspace-write`; after `enter_worktree`, a write to the original project outside the worktree is denied. The derived `.git` grant does not appear in the runtime context, which lists only configured extra directories. +5. Confirm: after `enter_worktree`, a write to the original project outside the worktree is denied, and `git commit` in the worktree succeeds once the grant of step 1 is in place. diff --git a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.zh.md b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.zh.md index dc1d69f2f6..7d9898fad4 100644 --- a/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.zh.md +++ b/docs/upgrade-guide/v0.2.2-rc.3/workspace-write-boundary-follows-root/guide.zh.md @@ -1,6 +1,6 @@ --- kind: upgrade-guide -description: "workspace-write 边界跟随 Session 的工作目录而不是原始项目,链接 worktree 的 Git 目录变为可写。" +description: "workspace-write 边界跟随 Session 的工作目录而不是原始项目,因此 worktree 中的 Session 不再能写入仓库的 Git 目录。" --- # `workspace-write` 边界跟随 Session 的工作目录 @@ -8,18 +8,18 @@ description: "workspace-write 边界跟随 Session 的工作目录而不是原 ## 变更 -`ctx.sandboxPolicy.resolve({ session })` 返回的 `workspaceRoot` 是 Session 的工作目录,即它所在的检出目录。此前整个 Session 期间返回的都是 Session header 记录的原始项目。通过 `enter_worktree` 或 forge 的"新建工作树"选项进入 worktree 的 Session 现在只能在该 worktree 内写入;原始项目不再整体可写。Host 每次移动 Session 的目录,边界都随之移动,包括 SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`)以及通过 `ctx.subagents.start({ cwd })` 启动的子代理;本版本之前记录的 `working-directory/change` 不移动边界。 +`ctx.sandboxPolicy.resolve({ session })` 返回的 `workspaceRoot` 是 Session 的工作目录,即它所在的检出目录。此前整个 Session 期间返回的都是 Session header 记录的原始项目。通过 `enter_worktree` 或 forge 的"新建工作树"选项进入 worktree 的 Session 现在只能在该 worktree 内写入;原始项目不再可写。Host 每次移动 Session 的目录,边界都随之移动,包括 SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`)以及通过 `ctx.subagents.start({ cwd })` 启动的子代理;本版本之前记录的 `working-directory/change` 不移动边界。 -对于链接 worktree,策略从检出目录的 `.git` 指针推导出仓库公共目录,只接受 Git 写出的 `/worktrees/` 布局及其 `commondir`、`gitdir` 指针,并加入 `additionalWritableRoots`,因此在 `workspace-write` 下可以在 worktree 内运行 `git commit` 与 `git checkout`。该授权也覆盖共享的 `.git/hooks` 与 `.git/config`,与主检出目录中的 Session 此前拥有的权限相同。在 Windows 上只有 harness 的 `write` 与 `edit` 工具执行该授权;受限进程保留工作区与私有临时目录权限。 +仓库的 Git 目录位于链接 worktree 之外。因此在 `workspace-write` 下,`git add`、`git commit` 等写入它的命令在 worktree 内会被拒绝,除非有授权覆盖该目录。此前,位于原始项目内的 worktree 共用项目的边界,其中包含 `.git`。策略不读取任何 Git 文件,也不推导授权。 文件树、目录列举与监听、交付物与变更摘要、在应用中打开操作和 Session 行读取同一个目录。`WorkspaceChangesSummary.cwd` 是该轮次开始时所在的目录,不再是原始项目。 -受影响者:依赖 worktree Session 仍可写入原始项目的运维人员、通过 `additionalWritableRoots` 授权 worktree `.git` 的部署,以及把 `WorkspaceChangesSummary.cwd` 当作原始项目读取的 Host 插件。 +受影响者:在 `workspace-write` 下从 worktree Session 提交的运维人员与模型、依赖 worktree Session 仍可写入原始项目的运维人员,以及把 `WorkspaceChangesSummary.cwd` 当作原始项目读取的 Host 插件。 ## 迁移 -1. 从 `cordis.yml` 中删除只为链接 worktree 的 `.git/worktrees/` 或公共 `.git` 目录而设置的 `additionalWritableRoots` 条目;保留无关目录的条目。 +1. 要让 worktree Session 在 `workspace-write` 下提交,请在 `cordis.yml` 中把仓库的 Git 目录(例如 `/repo/.git`)加入 `@deepseek-ai/dsh-sandbox-policy` 的 `additionalWritableRoots`,或在 Host 插件中用 `ctx.sandboxPolicy.registerWritableRoot(session, directory)` 为单个 Session 注册。该授权也覆盖 `.git/hooks` 与 `.git/config`,只用于可信任务。没有授权时,在启用审批的环境里模型会为每条这类命令请求提权。 2. 任务在进入 worktree 后仍需写入原始项目时,用 `exit_worktree()` 或 forge 面板的“在项目中继续”离开,或让 Session 留在原始项目中;边界跟随该变更。SDK 客户端若只是为了改变相对路径的解析位置而移动目录,请改传绝对路径或 shell 的 `workdir`。 3. 在消费 `ctx.workspaceChanges.summary` 的 Host 插件中,从 Session header 的 `cwd` 读取原始项目;`WorkspaceChangesSummary.cwd` 是所列 `path` 值相对的目录。 4. `cordis.yml` 若用沙箱策略的 `workspaceRoot` 限定 header 没有目录的 Session,请把 `@deepseek-ai/dsh-working-directory` 的 `defaultDirectory` 设为同一目录;现在由该目录限定这些 Session。 -5. 确认:在链接 worktree 内打开的 Session 中,`workspace-write` 下 `git commit` 成功;`enter_worktree` 之后,对 worktree 之外原始项目的写入被拒绝。推导出的 `.git` 授权不出现在运行时上下文中,上下文只列出配置的额外目录。 +5. 确认:`enter_worktree` 之后,对 worktree 之外原始项目的写入被拒绝;完成第 1 步的授权后,worktree 内的 `git commit` 成功。 diff --git a/packages/experimental/client-ui-forge/src/panel.ts b/packages/experimental/client-ui-forge/src/panel.ts index 6a49a41053..330019dddd 100644 --- a/packages/experimental/client-ui-forge/src/panel.ts +++ b/packages/experimental/client-ui-forge/src/panel.ts @@ -330,13 +330,11 @@ export class SessionPanel { /** Decide whether the Session's sandbox lets the worktree service write the checkout and its shared Git directory. */ private async blockerOf(inspection: Inspection): Promise { - await this.ctx.sandboxPolicy.prepare({ session: this.session }, this.lifetime.signal) const policy = this.ctx.sandboxPolicy.resolve({ session: this.session }) if (policy.mode === 'danger-full-access') return null if (policy.mode === 'read-only') return 'read-only' const root = this.ctx.fs.processPath(await this.ctx.fs.resolve(policy.workspaceRoot, { signal: this.lifetime.signal })) - const writable = [root, ...policy.additionalWritableRoots ?? []] - return within(root, inspection.checkout.root) && writable.some(directory => within(directory, inspection.commonDir)) ? null : 'outside-writable-root' + return within(root, inspection.checkout.root) && within(root, inspection.commonDir) ? null : 'outside-writable-root' } /** Measure the `branch` scope; a failed measurement only hides the local changes row. */ diff --git a/packages/experimental/client-ui-forge/tests/controller.host.spec.ts b/packages/experimental/client-ui-forge/tests/controller.host.spec.ts index 31fe791dc0..0343e01765 100644 --- a/packages/experimental/client-ui-forge/tests/controller.host.spec.ts +++ b/packages/experimental/client-ui-forge/tests/controller.host.spec.ts @@ -66,6 +66,12 @@ const UNAVAILABLE = { restoration: null, waiting: null, } +/** + * The same facts once the Session works in its worktree: its root no longer contains the repository's Git + * directory, which another worktree would have to write. The option that shows the blocker is hidden by then. + */ +const IN_WORKTREE = { ...UNAVAILABLE, blocker: 'outside-writable-root' as const } + /** Matches a generated branch name with the default prefix. */ const GENERATED_BRANCH: unknown = expect.stringMatching(/^dsh-[0-9a-f]{8}$/) /** Abbreviated commit object name Git prints for HEAD. */ @@ -920,11 +926,20 @@ describe('forgePanel worktree blockers', () => { expect(writable.worktree).toEqual(UNAVAILABLE) }) - it('blocks a worktree for a Session rooted in a subdirectory of its checkout until the Session gets full access', async () => { - const { repo } = await project() - const nested = join(repo, 'src') - await mkdir(nested) - const opened = await open(nested) + it.each([ + ['a linked worktree whose shared Git directory lies outside it', async (root: string, repo: string): Promise => { + const linked = join(root, 'linked') + await git(repo, 'worktree', 'add', '-b', 'feat', linked) + return linked + }], + ['a subdirectory of its checkout', async (_root: string, repo: string): Promise => { + const nested = join(repo, 'src') + await mkdir(nested) + return nested + }], + ])('blocks a worktree for a Session rooted in %s until the Session gets full access', async (_label, place) => { + const { root, repo } = await project() + const opened = await open(await place(root, repo)) const follower = reader(opened) const blocked = await follower.until(ready) @@ -936,21 +951,6 @@ describe('forgePanel worktree blockers', () => { expect(unblocked.worktree.blocker).toBeNull() }) - it('offers a worktree to a Session rooted in a linked worktree because the policy grants its shared Git directory', async () => { - const { root, repo } = await project() - const linked = join(root, 'linked') - await git(repo, 'worktree', 'add', '-b', 'feat', linked) - const opened = await open(linked) - const follower = reader(opened) - - const inspected = await follower.until(ready) - - expect(inspected.repository).toEqual(demo) - expect(inspected.checkout).toMatchObject({ state: 'ready', checkout: { root: linked, linked: true } }) - expect(inspected.worktree.blocker).toBeNull() - expect(opened.ctx.sandboxPolicy.resolve({ session: opened.session }).additionalWritableRoots).toEqual([join(repo, '.git')]) - }) - it('shows no blocker after an inspection fails', async () => { const opened = await open(await plain()) const follower = reader(opened) @@ -1086,7 +1086,7 @@ describe('forgePanel worktree requests', () => { repository: demo, readiness: { state: 'ready', message: null, signIn: null }, changeRequests: [], - worktree: { ...UNAVAILABLE, request: { from: null, name: null }, created }, + worktree: { ...IN_WORKTREE, request: { from: null, name: null }, created }, local: { base: created?.baseCommit.slice(0, 7), files: [] }, }) expect(opened.provider.probes).toEqual(['fake.test']) @@ -1242,7 +1242,7 @@ describe('forgePanel worktree creation while a message waits', () => { const waiting = { ...UNAVAILABLE, editable: true, request: { from: null, name: null }, waiting: 'creation' } expect(prepare.worktree).toEqual({ ...waiting, creation: { ...running, phase: 'prepare' } }) expect(checkout.worktree).toEqual({ ...waiting, creation: { ...running, phase: 'checkout' } }) - expect(moved.worktree).toEqual({ ...UNAVAILABLE, request: { from: null, name: null }, created }) + expect(moved.worktree).toEqual({ ...IN_WORKTREE, request: { from: null, name: null }, created }) expect(moved.checkout).toEqual({ state: 'ready', checkout: { root: created?.path, branch, linked: true, commit: COMMIT } }) expect(created).toEqual({ path: join(repo, '.agents', 'worktrees', ...branch.split('/')), @@ -1526,11 +1526,11 @@ describe('forgePanel removed worktrees', () => { await opened.agent.whenIdle() const restored = await restoration - expect(missing.worktree).toEqual({ ...UNAVAILABLE, request: { from: null, name: null }, created, missing: { branchExists: true }, waiting: 'restoration' }) + expect(missing.worktree).toEqual({ ...IN_WORKTREE, request: { from: null, name: null }, created, missing: { branchExists: true }, waiting: 'restoration' }) expect(preparing.worktree).toMatchObject({ missing: { branchExists: true }, restoration: { phase: 'prepare' }, waiting: 'restoration' }) expect(checkingOut.worktree.restoration).toEqual({ phase: 'checkout' }) expect(restored).toMatchObject({ directory: created.path, checkout: { state: 'ready', checkout: { root: created.path, branch: created.branch } } }) - expect(restored.worktree).toEqual({ ...UNAVAILABLE, request: { from: null, name: null }, created }) + expect(restored.worktree).toEqual({ ...IN_WORKTREE, request: { from: null, name: null }, created }) expect(await git(created.path, 'rev-parse', 'HEAD')).toBe(tip) expect(await readFile(join(created.path, 'later.txt'), 'utf8')).toBe('later.txt\n') expect(opened.ctx.workingDirectory.get(opened.session)).toBe(created.path) diff --git a/packages/experimental/worktree/README.i18n.yaml b/packages/experimental/worktree/README.i18n.yaml index e1184f2900..165526bb7d 100644 --- a/packages/experimental/worktree/README.i18n.yaml +++ b/packages/experimental/worktree/README.i18n.yaml @@ -18,8 +18,8 @@ en: a7f92c99db8e447d zh: b584674be711d238 /deepseek-ai-dsh-experimental-worktree/understand-the-implementation: - en: 4bdfbcafc7cba398 - zh: fae006fcc491b72c + en: 6971a7ca9073bef1 + zh: b977c28a75c7f963 /deepseek-ai-dsh-experimental-worktree/further-exploration: en: 5bcd45f0bba56207 zh: fd6342fd6bac5179 diff --git a/packages/experimental/worktree/README.md b/packages/experimental/worktree/README.md index fa94b9f940..5af3dddf78 100644 --- a/packages/experimental/worktree/README.md +++ b/packages/experimental/worktree/README.md @@ -54,7 +54,7 @@ The default checkout directory is `/.agents/worktrees/ Implementation internals — click to expand -Git and directory allocation run through the mounted subprocess and sandbox providers with the calling Session's existing file policy. Creation runs under the Session's resolved policy; the sandbox policy grants a linked source checkout's shared Git administration directory before the first write, and creation widens nothing else. Directory creation claims the destination exclusively; cancellation and failed setup can leave retained artifacts, whose path appears in the error. Service disposal aborts pending operations and waits for their settlement. +Git and directory allocation run through the mounted subprocess and sandbox providers with the calling Session's existing file policy. Creation does not widen write access to the destination or shared Git administration directory. Directory creation claims the destination exclusively; cancellation and failed setup can leave retained artifacts, whose path appears in the error. Service disposal aborts pending operations and waits for their settlement. | Source | Responsibility | |---|---| diff --git a/packages/experimental/worktree/README.zh.md b/packages/experimental/worktree/README.zh.md index fbeed94fb8..acf490de47 100644 --- a/packages/experimental/worktree/README.zh.md +++ b/packages/experimental/worktree/README.zh.md @@ -54,7 +54,7 @@ kind: "package-reference"
实现细节——点击展开 -Git 与目录分配通过挂载的子进程及沙箱提供方执行,沿用调用 Session 的文件策略。创建操作在 Session 解析后的策略下运行;沙箱策略会在首次写入前授权链接源检出目录的共享 Git 管理目录,创建操作不再扩大其他写权限。目录创建独占申请目标路径;取消或初始化失败可能留下已有产物,错误会包含其路径。服务销毁会中止待完成操作,并等待它们结束。 +Git 与目录分配通过挂载的子进程及沙箱提供方执行,沿用调用 Session 的文件策略。创建操作不会扩大目标目录或共享 Git 管理目录的写权限。目录创建独占申请目标路径;取消或初始化失败可能留下已有产物,错误会包含其路径。服务销毁会中止待完成操作,并等待它们结束。 | 源码 | 职责 | |---|---| diff --git a/packages/experimental/worktree/src/index.ts b/packages/experimental/worktree/src/index.ts index fa1b985ba7..26d9841d69 100644 --- a/packages/experimental/worktree/src/index.ts +++ b/packages/experimental/worktree/src/index.ts @@ -301,7 +301,7 @@ export class WorktreeService extends Service { ): Promise { const control = AbortSignal.any([this.lifetime.signal, signal]) control.throwIfAborted() - const policy = await this.sourcePolicy(session, request.repositoryRoot, control) + const policy = this.sourcePolicy(session, request.repositoryRoot) const git = { read: this.gitRunner(policy, control), scan: this.gitScanner(policy, control) } const operation = removeCheckout(this.ctx, this.config.directory, request, git, control, admit) this.pending.add(operation) @@ -343,10 +343,7 @@ export class WorktreeService extends Service { const rootTarget = await this.ctx.fs.resolve(rootOutput.stdout.replace(/\r?\n$/, ''), { cwd, signal }) const repositoryRoot = this.ctx.fs.processPath(rootTarget) if (fetch) { - // The fetch writes the remote-tracking branch into the Git directory, which a linked source checkout - // shares outside its root; the policy grants that directory before the write. - await this.ctx.sandboxPolicy.prepare({ session: agent.session }, signal) - await fetchRemoteBranch(this.gitRunner(this.ctx.sandboxPolicy.resolve({ session: agent.session }), signal), repositoryRoot, revision) + await fetchRemoteBranch(run, repositoryRoot, revision) onPhase?.('prepare') } const base = await run(repositoryRoot, ['rev-parse', '--verify', '--end-of-options', `${revision}^{commit}`]) @@ -359,15 +356,11 @@ export class WorktreeService extends Service { const path = this.ctx.fs.processPath(destination) if (await this.ctx.fs.lstat(path, undefined, signal) !== undefined) throw new WorktreeError(`worktree path already exists: ${path}`, 'WORKTREE_ALREADY_EXISTS') try { - // A linked source checkout writes its shared Git directory outside the root; the policy grants it before the first write. - await this.ctx.sandboxPolicy.prepare({ session: agent.session }, signal) - const writing = this.ctx.sandboxPolicy.resolve({ session: agent.session }) - const write = this.gitRunner(writing, signal) - await this.prepareDirectory(writing, repositoryRoot, poolPath, path, signal) - await write(repositoryRoot, ['--work-tree', repositoryRoot, 'worktree', 'add', '--no-checkout', '-b', branch, '--', path, baseCommit]) - const overrides = await filterOverrides(write, path) + await this.prepareDirectory(policy, repositoryRoot, poolPath, path, signal) + await run(repositoryRoot, ['--work-tree', repositoryRoot, 'worktree', 'add', '--no-checkout', '-b', branch, '--', path, baseCommit]) + const overrides = await filterOverrides(run, path) onPhase?.('checkout') - await write(path, ['--work-tree', path, 'reset', '--hard', '--no-recurse-submodules', baseCommit], undefined, overrides) + await run(path, ['--work-tree', path, 'reset', '--hard', '--no-recurse-submodules', baseCommit], undefined, overrides) const canonicalPath = await this.ctx.workingDirectory.set(agent, path, signal) const created: CreatedWorktree = { path: canonicalPath, branch, baseCommit, repositoryRoot } appendPluginRecord(agent.session, CREATED_RECORD, created) @@ -408,9 +401,9 @@ export class WorktreeService extends Service { onPhase: ((phase: Exclude) => void) | undefined, ): Promise { onPhase?.('prepare') - if (await this.ctx.fs.lstat(path, undefined, signal) !== undefined) throw new WorktreeError(`worktree path already exists: ${path}`, 'WORKTREE_ALREADY_EXISTS') - const policy = await this.sourcePolicy(agent.session, repositoryRoot, signal) + const policy = this.sourcePolicy(agent.session, repositoryRoot) const run = this.gitRunner(policy, signal) + if (await this.ctx.fs.lstat(path, undefined, signal) !== undefined) throw new WorktreeError(`worktree path already exists: ${path}`, 'WORKTREE_ALREADY_EXISTS') if (!relativePath(branch) || branch.startsWith('-')) throw new WorktreeError('worktree branch must be a relative Git branch name', 'WORKTREE_INVALID_ARGUMENT') if (!/^(?:[a-f\d]{40}|[a-f\d]{64})$/i.test(baseCommit)) throw new WorktreeError('worktree baseCommit must be a full commit object name', 'WORKTREE_INVALID_ARGUMENT') const identity = await checkoutIdentity(this.ctx, this.config.directory, { path, branch, baseCommit, repositoryRoot }, run, signal) @@ -447,13 +440,10 @@ export class WorktreeService extends Service { /** * The policy removal and restoration run under: the Session's mode and grants, bounded by the source * checkout of the recorded worktree instead of the Session's own root, which may be the worktree - * directory, removed or being removed. A linked source checkout's shared Git directory is granted too. + * directory, removed or being removed. */ - private async sourcePolicy(session: Session, repositoryRoot: string, signal: AbortSignal): Promise { - const shared = await this.ctx.sandboxPolicy.prepare({ directory: repositoryRoot }, signal) - const policy = this.ctx.sandboxPolicy.resolve({ session }) - const additional = [...new Set([...policy.additionalWritableRoots ?? [], ...shared])] - return { ...policy, workspaceRoot: repositoryRoot, ...additional.length === 0 ? {} : { additionalWritableRoots: additional } } + private sourcePolicy(session: Session, repositoryRoot: string): SandboxExecutionPolicy { + return { ...this.ctx.sandboxPolicy.resolve({ session }), workspaceRoot: repositoryRoot } } /** Confine Git commands to the caller's sandbox policy, collecting bounded stdout. */ diff --git a/packages/experimental/worktree/tests/archive.spec.ts b/packages/experimental/worktree/tests/archive.spec.ts index 194eab84ff..099bcad824 100644 --- a/packages/experimental/worktree/tests/archive.spec.ts +++ b/packages/experimental/worktree/tests/archive.spec.ts @@ -131,7 +131,6 @@ describe('archive-triggered worktree cleanup', () => { const head = await git(f.worktree.path, 'rev-parse', 'HEAD') const statuses: WorktreeCleanup['status'][] = [] f.ctx.on('worktree/cleanup', ({ cleanup }) => { statuses.push(cleanup.status) }) - const prepare = vi.spyOn(f.ctx.sandboxPolicy, 'prepare') await f.ctx.workspaceRegistry.archiveSession(f.session.id) expect(await f.ctx.worktrees.cleanupOf(f.session, null)).toMatchObject({ status: 'scheduled' }) expect(await settled(f)).toMatchObject({ status: 'removed' }) @@ -139,9 +138,8 @@ describe('archive-triggered worktree cleanup', () => { await expect(access(f.worktree.path)).rejects.toMatchObject({ code: 'ENOENT' }) expect(await git(f.root, 'rev-parse', f.worktree.branch)).toBe(head) expect(f.ctx.workspaceRegistry.archivedSessionIds).toContain(f.session.id) - // The creator's root is the checkout being removed; its commands are bounded by the source checkout instead. + // The creator's root is the checkout being removed; `sandbox.spec.ts` covers the source-checkout boundary of its commands. expect(f.ctx.workingDirectory.get(f.session)).toBe(f.worktree.path) - expect(prepare).toHaveBeenCalledWith({ directory: f.root }, expect.any(AbortSignal)) }) it('removes a clean checkout whose file listing exceeds maxOutputBytes', async () => { diff --git a/packages/experimental/worktree/tests/sandbox.spec.ts b/packages/experimental/worktree/tests/sandbox.spec.ts index 51240a12e0..abc29c7afd 100644 --- a/packages/experimental/worktree/tests/sandbox.spec.ts +++ b/packages/experimental/worktree/tests/sandbox.spec.ts @@ -1,10 +1,10 @@ import { access, mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' -import { pathToFileURL } from 'node:url' import { afterEach, describe, expect, it, vi } from 'vitest' import { Context } from '@deepseek-ai/cordis' import { SandboxUnavailableError } from '@deepseek-ai/dsh-sandbox' import LocalSandbox from '@deepseek-ai/dsh-sandbox-local' +import { runCommand } from '../src/process.ts' import { filterCommand, git, harness, repository, testAgent } from './harness.ts' let ctx: Context | undefined @@ -93,14 +93,27 @@ describe.skipIf(!sandboxUsable)('worktree standing sandbox policy', () => { expect(ctx.sandboxPolicy.resolve({ session: agent.session }).workspaceRoot).toBe(root) }) - it('creates from a linked checkout once the policy grants its shared Git administration directory', async () => { + it('does not widen a linked-checkout grant to the shared Git administration directory', async () => { + root = await repository(process.cwd()) + const linked = join(root, 'linked') + await git(root, 'worktree', 'add', '-b', 'linked', linked) + ctx = await harness(linked, {}, 'workspace-write') + const agent = testAgent(ctx, linked) + const confine = vi.spyOn(ctx.sandbox, 'confine') + await expect(ctx.worktrees.create(agent, { name: 'denied-admin' })).rejects.toThrow(/permission denied|operation not permitted|read-only file system/i) + expect(ctx.workingDirectory.get(agent.session)).toBe(linked) + expect(await git(root, 'branch', '--list', 'denied-admin')).toBe('') + expect(confine.mock.calls.every(call => call[1].mode === 'workspace-write' && call[1].workspaceRoot === linked)).toBe(true) + }) + + it('creates and restores from a linked checkout once a registered grant covers its shared Git administration directory', async () => { root = await repository(process.cwd()) const administration = join(root, '.git') const linked = join(root, 'linked') await git(root, 'worktree', 'add', '-b', 'linked', linked) ctx = await harness(linked, {}, 'workspace-write') const agent = testAgent(ctx, linked) - const confine = vi.spyOn(ctx.sandbox, 'confine') + ctx.sandboxPolicy.registerWritableRoot(agent.session, administration) const created = await ctx.worktrees.create(agent, { name: 'shared-admin' }) const checkout = join(linked, '.agents', 'worktrees', 'shared-admin') @@ -108,59 +121,37 @@ describe.skipIf(!sandboxUsable)('worktree standing sandbox policy', () => { expect(await git(checkout, 'branch', '--show-current')).toBe('shared-admin') expect(await git(root, 'worktree', 'list', '--porcelain')).toContain(`worktree ${checkout}`) expect(ctx.workingDirectory.get(agent.session)).toBe(checkout) - expect(confine.mock.calls.every(call => call[1].mode === 'workspace-write' && call[1].workspaceRoot === linked)).toBe(true) - // The registration write lands in the shared Git directory outside the linked root; only the derived grant admits it. - expect(confine.mock.calls.some(call => call[1].additionalWritableRoots?.includes(administration))).toBe(true) + + // The Session's root is now the removed checkout; restoration is bounded by the linked source checkout and keeps the grant. + await rm(checkout, { recursive: true, force: true }) + const confine = vi.spyOn(ctx.sandbox, 'confine') + expect(await ctx.worktrees.restore(agent, created)).toEqual({ path: checkout, branchRecreated: false }) + expect(await git(checkout, 'branch', '--show-current')).toBe('shared-admin') + expect(confine.mock.calls.length).toBeGreaterThan(0) + const bounded = confine.mock.calls + .every(call => call[1].workspaceRoot === linked && call[1].additionalWritableRoots?.includes(administration)) + expect(bounded).toBe(true) }) - it('fetches the remote base branch from a linked checkout under the granted shared Git administration directory', async () => { + it('denies a commit inside the Session\'s worktree under workspace-write until a grant covers the repository\'s Git directory', async () => { root = await repository(process.cwd()) - const clone = join(root, 'clone') - await git(root, 'clone', pathToFileURL(root).href, clone) - await git(clone, 'config', 'core.autocrlf', 'false') - const linked = join(clone, 'linked') - await git(clone, 'worktree', 'add', '-b', 'linked', linked) - await writeFile(join(root, 'tracked.txt'), 'remote\n') - await git(root, 'commit', '-am', 'remote') - const fetched = await git(root, 'rev-parse', 'HEAD') - ctx = await harness(linked, {}, 'workspace-write') - const agent = testAgent(ctx, linked) - const confine = vi.spyOn(ctx.sandbox, 'confine') + ctx = await harness(root, {}, 'workspace-write') + const agent = testAgent(ctx, root) + const created = await ctx.worktrees.create(agent, { name: 'committing' }) + const limits = { timeoutMs: 30_000, graceMs: 1_000, maxOutputBytes: 65_536 } + const commit = () => runCommand( + ctx!, limits, ctx!.sandboxPolicy.resolve({ session: agent.session }), created.path, + ['git', '-c', 'core.hooksPath=/dev/null', 'commit', '--allow-empty', '-m', 'from the worktree'], new AbortController().signal, + ) - const created = await ctx.worktrees.create(agent, { name: 'fetched', from: 'refs/remotes/origin/main', fetch: true }) + // The worktree's index and the repository's objects live in the source checkout's Git directory, outside the Session's root. + expect(ctx.sandboxPolicy.resolve({ session: agent.session }).workspaceRoot).toBe(created.path) + await expect(commit()).rejects.toThrow(/permission denied|operation not permitted|read-only file system/i) + expect(await git(created.path, 'rev-parse', 'HEAD')).toBe(created.baseCommit) - // The fetch writes the remote-tracking branch into the shared Git directory outside the linked root. - expect(created.baseCommit).toBe(fetched) - expect(await git(clone, 'rev-parse', 'refs/remotes/origin/main')).toBe(fetched) - const fetches = confine.mock.calls.filter(call => call[0].includes('fetch')) - expect(fetches).toHaveLength(1) - expect(fetches[0]![1]).toMatchObject({ mode: 'workspace-write', workspaceRoot: linked, additionalWritableRoots: [join(clone, '.git')] }) - }) - - it('restores a missing worktree of a linked source checkout in a process that never worked in it', async () => { - root = await repository(process.cwd()) - const linked = join(root, 'linked') - await git(root, 'worktree', 'add', '-b', 'linked', linked) - const first = await harness(linked, {}, 'workspace-write') - let created - try { - created = await first.worktrees.create(testAgent(first, linked), { name: 'cold' }) - } finally { - await first.fiber.dispose() - } - await rm(created.path, { recursive: true, force: true }) - // A new process: nothing is derived yet, and the Session's own root no longer exists. - ctx = await harness(linked, {}, 'workspace-write') - const agent = testAgent(ctx, linked, 'cold-resumed') - agent.session.append('workspace-root/change', { cwd: created.path }) - expect(ctx.workingDirectory.get(agent.session)).toBe(created.path) - const confine = vi.spyOn(ctx.sandbox, 'confine') - - expect(await ctx.worktrees.restore(agent, created)).toEqual({ path: created.path, branchRecreated: false }) - - // The source checkout's shared Git directory lies outside it; the worktree service adds the derived grant. - expect(await git(created.path, 'branch', '--show-current')).toBe('cold') - expect(confine.mock.calls.every(call => call[1].workspaceRoot === linked && call[1].additionalWritableRoots?.includes(join(root!, '.git')))).toBe(true) + ctx.sandboxPolicy.registerWritableRoot(agent.session, join(root, '.git')) + await commit() + expect(await git(created.path, 'log', '-1', '--format=%s')).toBe('from the worktree') }) it('restores a removed worktree under the source checkout boundary while the Session root is the removed directory', async () => { diff --git a/packages/extensions/tool-cordis/src/api-catalog.ts b/packages/extensions/tool-cordis/src/api-catalog.ts index 42bd456731..e7ae5e46d7 100644 --- a/packages/extensions/tool-cordis/src/api-catalog.ts +++ b/packages/extensions/tool-cordis/src/api-catalog.ts @@ -2888,7 +2888,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ { key: 'sandboxPolicy', summary: 'The sandbox-policy service (`ctx.sandboxPolicy`).', - description: 'The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session\'s mode log and workspace root travel together to every enforcing capability.\n\nA session\'s workspace root comes from the working-directory service when it is mounted: the checkout the Session works in, which a worktree relocation moves. A linked checkout keeps its Git administration directory and the repository\'s common directory outside that root; prepare derives them through the execution-world filesystem once per root, and `resolve` adds the derived directories to `additionalWritableRoots`. Tool executions await that derivation in `tools/pre-execute`; Session creation and every directory change start it early.', + description: 'The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mode, fallback workspace root, session-scoped directory grants, and request-time policy section. Tool layers call resolve for each execution so a session\'s mode log and immutable cwd travel together to every enforcing capability.', methods: [ { signature: 'readonly defaultMode: SandboxMode', @@ -2897,7 +2897,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ }, { signature: 'readonly workspaceRoot: string', - description: 'The absolute `workspace-write` fallback root for calls without a session root.', + description: 'The absolute `workspace-write` fallback root for calls without a session cwd.', parameters: [], }, { @@ -2907,10 +2907,10 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ }, { signature: 'resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy', - description: 'Resolve the complete policy for one capability call. An approved explicit mode outranks the session\'s last `sandbox/mode` event, which outranks the deployment default. A session\'s workspace root is its workspace-write boundary, and the Git administration directories prepare derived for that root join the configured extra writable directories; the configured root is the fallback for agentless calls and, without the working-directory service, sessions without a header directory. Configured extra roots, this Session\'s active registrations, and the derived Git directories are snapshotted together; existing operations and processes keep their policy.', + description: 'Resolve the complete policy for one capability call. An approved explicit mode outranks the session\'s last `sandbox/mode` event, which outranks the deployment default. A session\'s working directory is its workspace-write boundary, so a Host move of the Session moves the boundary; the configured root is the fallback for agentless calls and, without the working-directory service, sessions without a header directory. Configured extra roots and this Session\'s active registrations are snapshotted together; existing operations and processes keep their policy.', parameters: [{ name: 'request', description: 'optional session and approved mode override.' }], - returns: 'the fully resolved per-call mode, absolute workspace root, and extra writable directories.', - throws: ['`SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the selected root is relative or contains a NUL byte.'], + returns: 'the fully resolved per-call mode and absolute workspace root.', + throws: ['`SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session\'s directory is relative or contains a NUL byte.'], }, { signature: 'registerWritableRoot(session: Session, directory: string): () => void', @@ -2925,13 +2925,6 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [ parameters: [{ name: 'session', description: 'session whose log supplies the override.' }], returns: 'the last logged mode, or `undefined` without one.', }, - { - signature: 'async prepare(target: { session: Session } | { directory: string }, signal?: AbortSignal): Promise', - description: 'Derive the Git administration directories a linked checkout writes outside itself, as `./linked-checkout.ts` reads them. For a Session the checkout is its workspace root, and the next resolve for that Session grants the result. For a named `directory`, a Host operation that runs in a checkout no Session works in adds the result to the policy it builds; `resolve` is unaffected. One derivation runs per directory and its result is kept once the layout was read, so a pointer written later does not widen a policy until a Host operation moves a Session\'s workspace to that directory again; a derived directory that disappears is derived again, and a failed read is logged once per directory and retried on the next call.', - parameters: [{ name: 'target', description: 'Session whose workspace root is inspected, or the checkout directory itself.' }, { name: 'signal', description: 'caller cancellation, checked before and after the shared derivation.' }], - returns: 'the derived directories outside the checkout, canonical in the execution world.', - throws: ['`SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the directory is relative or contains a NUL byte.'], - }, ], }, { diff --git a/packages/sandbox/sandbox-policy/README.i18n.yaml b/packages/sandbox/sandbox-policy/README.i18n.yaml index 309a97ce27..30539bf7ac 100644 --- a/packages/sandbox/sandbox-policy/README.i18n.yaml +++ b/packages/sandbox/sandbox-policy/README.i18n.yaml @@ -21,14 +21,14 @@ en: 6704447e52ec295b zh: 9ed812d9e29d5533 /deepseek-ai-dsh-sandbox-policy/use-this-package/minimal-configuration: - en: e051a779f77a2ff1 - zh: f56a483fced4cc9b + en: 6a8e527fb4c08c9e + zh: 7aded9efad17c0a6 /deepseek-ai-dsh-sandbox-policy/use-this-package/registering-a-session-s-writable-directory: en: 841ea47ef1ed7ee6 zh: cd573e67a67742e2 /deepseek-ai-dsh-sandbox-policy/use-this-package/switching-a-session-s-mode: en: dabffeed89b56cc8 - zh: 8a0ca5051bd55725 + zh: 272680e5656e707c /deepseek-ai-dsh-sandbox-policy/use-this-package/failures-and-recovery: en: 9cef5f64a050f468 zh: 5dc42c148b2c902d @@ -36,17 +36,17 @@ en: 2d560aa6681fcfb8 zh: e1c6361a6fa40c63 /deepseek-ai-dsh-sandbox-policy/understand-the-implementation/resolution-precedence: - en: 9933eebcea794957 - zh: 3d0c7b6dd062a2ce + en: bc34dd3840f8c143 + zh: c6ffff0926278c93 /deepseek-ai-dsh-sandbox-policy/understand-the-implementation/the-per-session-store: - en: a2ff737890a75e54 - zh: b166e15ec95f3fd4 + en: 819edb63f3763f20 + zh: 6068d08827596b22 /deepseek-ai-dsh-sandbox-policy/understand-the-implementation/model-visible-text: en: af0d19c6de17a272 zh: d90e538f9ac85b77 /deepseek-ai-dsh-sandbox-policy/understand-the-implementation/source-map: - en: b5a0c99bb5dee846 - zh: 603887d9ea187e3e + en: cc7dd675c9915f7d + zh: d719c4f9de39873a /deepseek-ai-dsh-sandbox-policy/further-exploration: en: 7b110e18967f2754 zh: 823c261edeae750a diff --git a/packages/sandbox/sandbox-policy/README.md b/packages/sandbox/sandbox-policy/README.md index 3f3468f3e9..c63256dddd 100644 --- a/packages/sandbox/sandbox-policy/README.md +++ b/packages/sandbox/sandbox-policy/README.md @@ -48,7 +48,7 @@ Load the package with a default mode; the fail-safe default is `read-only`, and | `workspaceRoot` | `process.cwd()` | Absolute fallback root for agentless calls and, without the working-directory service, sessions without a header directory; relative values fail at load. Normal agent calls use the session's working directory; a relative root or one containing a NUL byte fails the call with `SANDBOX_INVALID_ROOT` | | `additionalWritableRoots` | `[]` | Physical absolute directories also writable under `workspace-write`; Windows file tools honor them, Windows subprocesses ignore them, and `read-only` grants no access | -A session's workspace root is the checkout it works in, read from the [working-directory service](../../session/working-directory/README.md): every Host move of the Session's directory, such as entering or leaving a worktree, moves the boundary with it. For a linked Git worktree, `prepare({ session })` reads the checkout's `.git` pointer through the execution-world filesystem and adds the repository's common directory to the resolved `additionalWritableRoots`, but only in the layout Git writes: the pointer names `/worktrees/`, whose `commondir` names `` and whose `gitdir` names the checkout's `.git` again. The checkout is writable under `workspace-write`, so its own pointer proves nothing; the reverse pointer lives in the directory being granted. Any other pointer, a missing `.git`, a `.git` directory, and a common directory containing the root grant nothing. Session creation, every directory change, and each tool execution start that derivation, tool executions wait for it, and a root's result is kept once its layout was read: a pointer written afterwards changes nothing until a Host operation moves a Session's workspace to that root, a derived directory that disappears is derived again, and a failed read is logged once per root. The derived directories are not part of the model-visible policy text. The policy grants no parent checkout beyond those directories. These grants are deployment configuration shared by the composition's sessions, rather than saved Session permissions. Granting the entire Git directory also permits changes to hooks and configuration that a later host Git invocation can execute outside the sandbox; use that grant only for trusted tasks. Use physical absolute directory paths. The enforcing host rejects missing paths, files, and symlinked roots, including a directory replaced by a symlink between calls. Remote grants are validated on the remote host. +A session's workspace root is the directory it works in, read from the [working-directory service](../../session/working-directory/README.md): every Host move of the Session's directory, such as entering or leaving a worktree, moves the boundary with it. For a linked Git worktree, the repository's Git directory lies outside that root, so Git commands that write it are denied under `workspace-write` until a grant covers it: the deployment can grant it to every session with `additionalWritableRoots`, and a Host plugin can grant it to one live Session with `registerWritableRoot`. The caller selects that directory explicitly; the policy does not inspect Git files or grant a parent checkout. These grants are deployment configuration shared by the composition's sessions, rather than saved Session permissions. Granting the entire Git directory also permits changes to hooks and configuration that a later host Git invocation can execute outside the sandbox; use that grant only for trusted tasks. Use physical absolute directory paths. The enforcing host rejects missing paths, non-directories, and symlinked directories on each call, including a directory replaced by a symlink between calls. Remote grants are validated on the remote host. The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-sandbox-policy) is the exhaustive source for every accepted field and its JSDoc. @@ -78,11 +78,11 @@ This section explains policy resolution, the per-session store, and the model-vi ### Resolution precedence -`resolve({ session, mode })` returns one complete per-call policy: an approved explicit mode outranks the session's last `sandbox/mode` event, which outranks the deployment default. The session's directory from the working-directory service supplies the boundary; without that service its header directory and then the configured root do; the derived Git administration directories of that root join the configured extra directories. `prepare({ directory })` derives the same directories for a checkout no session works in and changes no resolved policy: a Host operation that runs in that checkout, such as the worktree service removing or restoring a session's worktree from its source repository, adds the result to the policy it builds itself. Absolute execution-world spelling is preserved. Enforcing providers canonicalize the root on their own filesystem, so remote `symlink/..` paths are never resolved on the Harness host. +`resolve({ session, mode })` returns one complete per-call policy: an approved explicit mode outranks the session's last `sandbox/mode` event, which outranks the deployment default. The session's directory from the working-directory service supplies the workspace root; without that service its header directory and then the configured root do. Absolute execution-world spelling is preserved. Enforcing providers canonicalize the root on their own filesystem, so remote `symlink/..` paths are never resolved on the Harness host. ### The per-session store -A runtime switch is one log-only `sandbox/mode` event on the session it applies to — the switch IS its event, and nothing mutates mode state out of band. `effective = explicit grant ?? fold(events) ?? deployment default`, so an override survives restart by replay and two sessions never see each other's state. Workspace identity needs no event of its own: the working-directory service's `workingDirectory` projection names the root for every call in that session, and the derived Git administration directories are an in-memory fact of this process, read again after a restart. The event stays log-only; before each request, the owner contributes the current fact to the full runtime-context snapshot, and the agent loop logs that snapshot as a sourced `user/message`. +A runtime switch is one log-only `sandbox/mode` event on the session it applies to — the switch IS its event, and nothing mutates mode state out of band. `effective = explicit grant ?? fold(events) ?? deployment default`, so an override survives restart by replay and two sessions never see each other's state. Workspace identity needs no event of its own: the working-directory service's `workingDirectory` projection names the root for every call in that session. The event stays log-only; before each request, the owner contributes the current fact to the full runtime-context snapshot, and the agent loop logs that snapshot as a sourced `user/message`. ### Model-visible text @@ -94,7 +94,6 @@ The `sandbox:policy` contribution states the mode's capability-neutral file-effe |---|---| | [`src/index.ts`](src/index.ts) | Plugin entry: `SandboxPolicyService`, `Config` schema, policy resolution and context contribution | | [`src/session-mode.ts`](src/session-mode.ts) | The `sandbox/mode` event, its fold, and the write path | -| [`src/linked-checkout.ts`](src/linked-checkout.ts) | Reads of a linked checkout's Git administration layout through the filesystem; no service state |
diff --git a/packages/sandbox/sandbox-policy/README.zh.md b/packages/sandbox/sandbox-policy/README.zh.md index 31c2883144..ac7c0ab107 100644 --- a/packages/sandbox/sandbox-policy/README.zh.md +++ b/packages/sandbox/sandbox-policy/README.zh.md @@ -48,7 +48,7 @@ kind: "package-reference" | `workspaceRoot` | `process.cwd()` | 无 agent 调用所用的绝对回退根目录;未挂载工作目录服务时,header 没有目录的会话也使用它;相对值在加载时拒绝。普通 agent 调用使用会话的工作目录;根为相对路径或含 NUL 字节时调用以 `SANDBOX_INVALID_ROOT` 失败 | | `additionalWritableRoots` | `[]` | 在 `workspace-write` 下额外允许写入的物理绝对目录;Windows 文件工具执行这些授权,Windows 子进程忽略它们,`read-only` 不授予访问权限 | -会话的工作区根是它所在的检出目录,从[工作目录服务](../../session/working-directory/README.zh.md)读取:Host 每次移动 Session 的目录(例如进入或离开 worktree)都会一并移动边界。对于关联的 Git worktree,`prepare({ session })` 通过执行环境的文件系统读取检出目录的 `.git` 指针,把仓库公共目录加入解析出的 `additionalWritableRoots`,但只认 Git 写出的布局:指针指向 `/worktrees/`,该目录的 `commondir` 指向 ``、`gitdir` 指回检出目录的 `.git`。检出目录在 `workspace-write` 下可写,它自己的指针不能作为证据;反向指针位于将被授权的目录内。其他指针、缺失的 `.git`、`.git` 本身是目录,以及包含根的公共目录都不授权任何内容。会话创建、每次目录变更和每次工具执行都会启动该推导,工具执行会等待它完成;根的结果在读取布局后即固定:之后写入的指针在 Host 操作把某个 Session 的工作区移到该根之前不改变任何内容,已推导的目录消失时重新推导,读取失败每个根只记录一次。推导出的目录不进入模型可见的策略文本。除这些目录之外,策略不授权父检出目录。这些授权是组合中所有会话共享的部署配置,而非保存的 Session 权限。授权整个 Git 目录也允许修改钩子和配置,后续主机 Git 调用可能在沙箱之外执行它们;仅对可信任务使用此授权。使用物理绝对目录路径。执行限制的主机拒绝不存在的路径、文件和符号链接根目录,包括两次调用之间被替换为符号链接的目录。远端授权在远端主机上验证。 +会话的工作区根是它所在的目录,读取自[工作目录服务](../../session/working-directory/README.zh.md):Host 每次移动 Session 的目录(例如进入或离开 worktree),边界都随之移动。对于关联的 Git worktree,仓库的 Git 目录位于该根之外,因此在 `workspace-write` 下写入它的 Git 命令会被拒绝,直到有授权覆盖它:部署可以通过 `additionalWritableRoots` 向所有会话授权,Host 插件可以通过 `registerWritableRoot` 向单个 live Session 授权。调用方必须显式选择该目录;策略不会读取 Git 文件或授权父检出目录。这些授权是组合中所有会话共享的部署配置,而非保存的 Session 权限。授权整个 Git 目录也允许修改钩子和配置,后续主机 Git 调用可能在沙箱之外执行它们;仅对可信任务使用此授权。使用物理绝对目录路径。执行限制的主机在每次调用时拒绝不存在的路径、非目录和符号链接目录,包括两次调用之间被替换为符号链接的目录。远端授权在远端主机上验证。 生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-sandbox-policy)是每个受支持字段及其 JSDoc 的穷尽式真源。 @@ -60,7 +60,7 @@ kind: "package-reference" ### 切换会话模式 -会话的模式可以在运行时通过 UI 策略控件或显式切换来更改;切换记录在会话日志中,并在该会话的下一次受限调用时生效。切换通过回放跨重启保留,每个会话保持自己的模式——两个会话绝不会看到彼此状态。切换后的会话继续以工作区根作为写入边界。 +会话的模式可以在运行时通过 UI 策略控件或显式切换来更改;切换记录在会话日志中,并在该会话的下一次受限调用时生效。切换通过回放跨重启保留,每个会话保持自己的模式——两个会话绝不会看到彼此状态。切换后的会话继续以其工作区根作为写入边界。 ### 失败与恢复 @@ -78,11 +78,11 @@ kind: "package-reference" ### 解析优先级 -`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。工作目录服务给出的会话目录提供边界;没有该服务时依次使用 header 目录和配置的根;该根推导出的 Git 管理目录与配置的额外目录合并。`prepare({ directory })` 为没有会话在其中工作的检出目录推导同样的目录,不改变任何已解析的策略:在该检出目录中运行的 Host 操作(例如 worktree 服务从源仓库移除或恢复会话的 worktree)把结果加入它自己构造的策略。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。 +`resolve({ session, mode })` 返回一份完整的逐调用策略:已批准的显式模式优先于会话最后一条 `sandbox/mode` 事件,后者又优先于部署默认值。工作目录服务给出的会话目录提供工作区根目录;没有该服务时依次使用 header 目录和配置的根。执行环境中的绝对路径写法保持不变。执行限制的提供方在自己的文件系统上规范化根目录,因此远端 `symlink/..` 路径绝不会在 Harness 主机上解析。 ### 逐会话存储 -运行时切换是在对应会话日志中追加的一条仅写入日志的 `sandbox/mode` 事件——切换本身就是事件,任何机制都不会在带外修改模式状态。`effective = explicit grant ?? fold(events) ?? deployment default`,因此覆盖通过回放跨重启保留,两个会话也绝不会看到彼此状态。工作区标识无需自己的事件:工作目录服务的 `workingDirectory` 投影给出该会话每次调用使用的根,推导出的 Git 管理目录是本进程的内存事实,重启后重新读取。事件仍只进入日志;在每次请求前,归属方会把当前事实贡献给完整运行时上下文快照,agent loop(智能体循环)将该快照记录为一条带来源的 `user/message`。 +运行时切换是在对应会话日志中追加的一条仅写入日志的 `sandbox/mode` 事件——切换本身就是事件,任何机制都不会在带外修改模式状态。`effective = explicit grant ?? fold(events) ?? deployment default`,因此覆盖通过回放跨重启保留,两个会话也绝不会看到彼此状态。工作区标识无需自己的事件:工作目录服务的 `workingDirectory` 投影给出该会话每次调用使用的根。事件仍只进入日志;在每次请求前,归属方会把当前事实贡献给完整运行时上下文快照,agent loop(智能体循环)将该快照记录为一条带来源的 `user/message`。 ### 模型可见文本 @@ -94,7 +94,6 @@ kind: "package-reference" |---|---| | [`src/index.ts`](src/index.ts) | 插件入口:`SandboxPolicyService`、`Config` schema、策略解析与上下文贡献 | | [`src/session-mode.ts`](src/session-mode.ts) | `sandbox/mode` 事件、其 fold 与写入路径 | -| [`src/linked-checkout.ts`](src/linked-checkout.ts) | 通过文件系统读取链接检出目录的 Git 管理目录布局;不含服务状态 | diff --git a/packages/sandbox/sandbox-policy/package.json b/packages/sandbox/sandbox-policy/package.json index 435898715a..e570ba6bb2 100644 --- a/packages/sandbox/sandbox-policy/package.json +++ b/packages/sandbox/sandbox-policy/package.json @@ -34,12 +34,10 @@ "peerDependencies": { "@deepseek-ai/cordis": "workspace:~", "@deepseek-ai/dsh-agent": "workspace:*", - "@deepseek-ai/dsh-fs": "workspace:*", "@deepseek-ai/dsh-sandbox": "workspace:*", "@deepseek-ai/dsh-session": "workspace:*", "@deepseek-ai/dsh-session-projection": "workspace:*", - "@deepseek-ai/dsh-system-prompt": "workspace:*", - "@deepseek-ai/dsh-tools": "workspace:*" + "@deepseek-ai/dsh-system-prompt": "workspace:*" }, "dependencies": { "@deepseek-ai/schemastery": "workspace:~", @@ -50,14 +48,11 @@ "@deepseek-ai/dsh-brand": "workspace:*", "@deepseek-ai/dsh-agent": "workspace:*", "@deepseek-ai/dsh-agent-loop-testkit": "workspace:*", - "@deepseek-ai/dsh-fs": "workspace:*", "@deepseek-ai/dsh-fs-local": "workspace:*", "@deepseek-ai/dsh-sandbox": "workspace:*", "@deepseek-ai/dsh-session": "workspace:*", "@deepseek-ai/dsh-session-projection": "workspace:*", - "@deepseek-ai/dsh-subprocess-local": "workspace:*", "@deepseek-ai/dsh-system-prompt": "workspace:*", - "@deepseek-ai/dsh-tools": "workspace:*", "@deepseek-ai/dsh-user-approval": "workspace:*", "@deepseek-ai/dsh-working-directory": "workspace:*" } diff --git a/packages/sandbox/sandbox-policy/src/index.ts b/packages/sandbox/sandbox-policy/src/index.ts index f0c8ccbe8d..7f3db18d5a 100644 --- a/packages/sandbox/sandbox-policy/src/index.ts +++ b/packages/sandbox/sandbox-policy/src/index.ts @@ -2,10 +2,9 @@ * The sandbox POLICY home (`ctx.sandboxPolicy`): the single owner of the * deployment's sandbox fallbacks plus per-session resolution: the file-effect * {@link SandboxMode}, the `workspace-write` root, the explicit extra writable - * directories from configuration and live Session registrations, the Git - * administration directories a linked checkout writes outside that root, and - * the override kit (the `sandbox/mode` event, its fold, and its write path; - * the fold is the `sandboxMode` session-projection unit + * directories from configuration and live Session registrations, and the override + * kit (the `sandbox/mode` event, its fold, and its write path; the fold is the + * `sandboxMode` session-projection unit * registered here, while the event and write path come from * `./session-mode.ts`). * Before each agent request, the owner also contributes the resolved policy to @@ -28,15 +27,12 @@ import { Context, Service } from '@deepseek-ai/cordis' import { z as zod } from 'zod' import z from '@deepseek-ai/schemastery' import type {} from '@deepseek-ai/dsh-agent' -import type {} from '@deepseek-ai/dsh-fs' import { SandboxInvalidRootError } from '@deepseek-ai/dsh-sandbox' import type { SandboxExecutionPolicy, SandboxMode } from '@deepseek-ai/dsh-sandbox' import type { Session } from '@deepseek-ai/dsh-session' import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection' import type {} from '@deepseek-ai/dsh-system-prompt' -import type {} from '@deepseek-ai/dsh-tools' import type {} from '@deepseek-ai/dsh-working-directory' -import { linkedCheckoutAdministration, within } from './linked-checkout.ts' export { SANDBOX_MODES, setSandboxMode } from './session-mode.ts' @@ -45,18 +41,6 @@ function isExecutionWorldPath(path: string): boolean { return isAbsolute(path) && !path.includes('\0') } -/** - * The selected workspace root in its execution-world spelling; enforcing providers resolve filesystem - * identity on their host. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) for a relative root or one containing a NUL byte. - */ -function resolveWorkspaceRoot(path: string): string { - if (!isExecutionWorldPath(path)) { - throw new SandboxInvalidRootError(path, 'the Session working directory must be an absolute execution-world path without NUL bytes', 'sandbox workspace root') - } - return path -} - /** * Validate and detach the configured extra writable directories. They stay in * their execution-world spelling here: a local host must not canonicalize a @@ -120,11 +104,10 @@ export interface Config { workspaceRoot?: string /** * Extra physical absolute directories that `workspace-write` may also write under - * (default: none). The supervisor names them explicitly; the Git - * administration directories of a linked checkout are derived separately - * and need no entry here. Entries are execution-world paths: this service - * validates absoluteness and detaches the list, while the enforcing host - * rejects missing, non-directory, or symlinked paths. They grant nothing under + * (default: none). The supervisor names them explicitly; there is no + * automatic repository or gitfile discovery. Entries are execution-world + * paths: this service validates absoluteness and detaches the list, while + * the enforcing host rejects missing, non-directory, or symlinked paths. They grant nothing under * `read-only`. Windows process confinement ignores them; harness file tools honor them. */ additionalWritableRoots?: string[] @@ -132,7 +115,7 @@ export interface Config { /** Inputs that select the sandbox policy for one capability call. */ export interface SandboxPolicyRequest { - /** Calling session; its workspace root becomes the workspace boundary. */ + /** Calling session; its immutable cwd becomes the workspace boundary. */ session?: Session /** Explicit approved mode override, which outranks session policy. */ mode?: SandboxMode @@ -149,16 +132,7 @@ const sandboxModeStateSchema = zod.union([ * The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment * default mode, fallback workspace root, session-scoped directory grants, and * request-time policy section. Tool layers call {@link resolve} for each execution so a session's - * mode log and workspace root travel together to every enforcing capability. - * - * A session's workspace root comes from the working-directory service when - * it is mounted: the checkout the Session works in, which a worktree - * relocation moves. A linked checkout keeps its Git administration directory - * and the repository's common directory outside that root; {@link prepare} - * derives them through the execution-world filesystem once per root, and - * `resolve` adds the derived directories to `additionalWritableRoots`. Tool - * executions await that derivation in `tools/pre-execute`; Session creation and - * every directory change start it early. + * mode log and immutable cwd travel together to every enforcing capability. */ export class SandboxPolicyService extends Service { // Inline schema call: the config catalog walks `static Config` statically. @@ -174,20 +148,13 @@ export class SandboxPolicyService extends Service { /** The deployment default mode — the fallback beneath a session override. */ readonly defaultMode: SandboxMode - /** The absolute `workspace-write` fallback root for calls without a session root. */ + /** The absolute `workspace-write` fallback root for calls without a session cwd. */ readonly workspaceRoot: string /** The frozen extra writable directories shared by every resolved policy, or `undefined` for none. */ readonly additionalWritableRoots: readonly string[] | undefined /** Independently owned grants for each live Session; never restored from its log. */ private readonly writableRootRegistrations = new WeakMap>() private sandboxModeProjectionHandle!: ProjectionHandle - /** Derived Git administration directories by workspace root; present only once the root's `.git` entry was read. */ - private readonly gitAdministration = new Map() - /** Derivations in flight by workspace root. */ - private readonly derivations = new Map>() - /** Roots whose failed derivation was already logged; cleared by the next successful read. */ - private readonly derivationWarnings = new Set() - private readonly lifecycle = new AbortController() constructor(ctx: Context, config: Config) { super(ctx, 'sandboxPolicy') @@ -220,56 +187,56 @@ export class SandboxPolicyService extends Service { order: scope.systemPrompt.getContextOrder('SANDBOX_POLICY'), text: (context) => { const session = context.agent?.session - return session === undefined ? '' : renderPolicyContext(this.configuredPolicy(session)) + return session === undefined + ? '' + : renderPolicyContext(this.resolve({ session })) }, }) }) - ctx.on('session/created', (session) => { this.prewarm(session) }) - ctx.on('session/event', (session, event) => { - if (event.type !== 'workspace-root/change') return - // A Host move of the workspace reads the entered root's layout again: a root settled - // without administration directories may have become a linked worktree since. - this.gitAdministration.delete(this.rootOf(session)) - this.prewarm(session) - }) - ctx.on('tools/pre-execute', async (exec, next) => { - if (exec.agent !== undefined) await this.prepare({ session: exec.agent.session }, exec.signal) - return next() - }) - ctx.effect(() => async () => { - this.lifecycle.abort(new Error('sandbox-policy service disposed')) - await Promise.allSettled(this.derivations.values()) - }) } /** * Resolve the complete policy for one capability call. An approved explicit * mode outranks the session's last `sandbox/mode` event, which outranks the - * deployment default. A session's workspace root is its workspace-write - * boundary, and the Git administration directories {@link prepare} derived - * for that root join the configured extra writable directories; the - * configured root is the fallback for agentless calls and, without the - * working-directory service, sessions without a header directory. Configured - * extra roots, this Session's active registrations, and the derived Git - * directories are snapshotted together; existing operations and processes - * keep their policy. + * deployment default. A session's working directory is its workspace-write + * boundary, so a Host move of the Session moves the boundary; the configured + * root is the fallback for agentless calls and, without the working-directory + * service, sessions without a header directory. Configured extra roots and + * this Session's active registrations are snapshotted together; existing + * operations and processes keep their policy. * @param request - optional session and approved mode override. - * @returns the fully resolved per-call mode, absolute workspace root, and extra writable directories. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the selected root is relative or - * contains a NUL byte. + * @returns the fully resolved per-call mode and absolute workspace root. + * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's directory is + * relative or contains a NUL byte. */ resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy { const { session } = request - const workspaceRoot = resolveWorkspaceRoot(this.rootOf(session)) - const additional = this.writableRootsOf(session, session === undefined ? undefined : this.gitAdministration.get(workspaceRoot)) + const registrations = session === undefined ? undefined : this.writableRootRegistrations.get(session) + const additionalWritableRoots = registrations === undefined + ? this.additionalWritableRoots + : resolveAdditionalWritableRoots([...(this.additionalWritableRoots ?? []), ...registrations.values()]) return { mode: request.mode ?? (session === undefined ? undefined : this.overrideOf(session)) ?? this.defaultMode, - workspaceRoot, - ...additional === undefined ? {} : { additionalWritableRoots: additional }, + workspaceRoot: this.sessionWorkspaceRoot(session), + ...additionalWritableRoots === undefined ? {} : { additionalWritableRoots }, ...session === undefined ? {} : { sessionId: session.id }, } } + /** + * The workspace-write boundary: the session's directory from the working-directory service; without + * that service its header directory, else the configured root. + */ + private sessionWorkspaceRoot(session: Session | undefined): string { + if (session === undefined) return this.workspaceRoot + const cwd = this.ctx.get('workingDirectory')?.get(session) ?? session.header.cwd + if (cwd === undefined) return this.workspaceRoot + if (!isExecutionWorldPath(cwd)) { + throw new SandboxInvalidRootError(cwd, 'the Session working directory must be an absolute execution-world path without NUL bytes', 'sandbox workspace root') + } + return cwd + } + /** * Permit writes under one directory in this Session's future workspace-write * operations. The calling context owns the effect; disposal removes only this @@ -309,116 +276,6 @@ export class SandboxPolicyService extends Service { overrideOf(session: Session): SandboxMode | undefined { return this.sandboxModeProjectionHandle.stateOf(session) ?? undefined } - - /** - * Derive the Git administration directories a linked checkout writes outside itself, as - * `./linked-checkout.ts` reads them. For a Session the checkout is its workspace root, and the next - * {@link resolve} for that Session grants the result. For a named `directory`, a Host operation that - * runs in a checkout no Session works in adds the result to the policy it builds; `resolve` is - * unaffected. One derivation runs per directory and its result is kept once the layout was read, so a - * pointer written later does not widen a policy until a Host operation moves a Session's workspace to - * that directory again; a derived directory that disappears is derived again, and a failed read is - * logged once per directory and retried on the next call. - * @param target - Session whose workspace root is inspected, or the checkout directory itself. - * @param signal - caller cancellation, checked before and after the shared derivation. - * @returns the derived directories outside the checkout, canonical in the execution world. - * @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the directory is relative or - * contains a NUL byte. - */ - async prepare(target: { session: Session } | { directory: string }, signal?: AbortSignal): Promise { - signal?.throwIfAborted() - const root = resolveWorkspaceRoot('directory' in target ? target.directory : this.rootOf(target.session)) - const settled = this.gitAdministration.get(root) - if (settled !== undefined) { - if (await this.present(settled, signal)) return settled - this.gitAdministration.delete(root) - } - let derivation = this.derivations.get(root) - if (derivation === undefined) { - derivation = this.derive(root).finally(() => { this.derivations.delete(root) }) - this.derivations.set(root, derivation) - } - const derived = await derivation - signal?.throwIfAborted() - return derived - } - - private prewarm(session: Session): void { - // Failures are logged inside the derivation; disposal rejects the pending wait. - void this.prepare({ session }).catch(() => undefined) - } - - /** Whether every derived directory still exists; a vanished or uninspectable one invalidates the settled result. */ - private async present(directories: readonly string[], signal: AbortSignal | undefined): Promise { - const fs = this.ctx.get('fs') - if (directories.length === 0 || fs === undefined) return true - for (const directory of directories) { - try { - if ((await fs.lstat(directory, undefined, signal))?.type !== 'directory') return false - } catch (error) { - signal?.throwIfAborted() - // Deriving again reports the failure once per root. - this.ctx.logger.debug(`sandbox-policy: could not inspect ${JSON.stringify(directory)}: ${String(error)}`) - return false - } - } - return true - } - - private async derive(root: string): Promise { - const fs = this.ctx.get('fs') - if (fs === undefined) return [] - const signal = this.lifecycle.signal - try { - const outside = await linkedCheckoutAdministration(fs, root, signal) - signal.throwIfAborted() - // Distinct directories outside the root, keeping only those no other candidate already contains. - const candidates = [...new Set(outside)].filter(directory => !within(root, directory)) - const derived = Object.freeze(candidates.filter(directory => - !candidates.some(other => other !== directory && within(other, directory)))) - this.gitAdministration.set(root, derived) - this.derivationWarnings.delete(root) - return derived - } catch (error) { - if (signal.aborted) throw error - if (!this.derivationWarnings.has(root)) { - this.derivationWarnings.add(root) - this.ctx.logger.warn(`sandbox-policy: could not derive the Git administration directories of ${JSON.stringify(root)}: ${String(error)}`) - } - return [] - } - } - - /** - * The policy as the model sees it: configured roots and the Session's registered grants, which the model - * may use on purpose; the derived Git directories are a filesystem fact, not model-visible input. - */ - private configuredPolicy(session: Session): SandboxExecutionPolicy { - const { mode, workspaceRoot } = this.resolve({ session }) - const advertised = this.writableRootsOf(session) - return { mode, workspaceRoot, ...advertised === undefined ? {} : { additionalWritableRoots: advertised } } - } - - /** - * The configured extra roots, the Session's registered grants, and `derived` Git administration - * directories as one validated list; undefined when there is none. - */ - private writableRootsOf(session: Session | undefined, derived: readonly string[] = []): readonly string[] | undefined { - const registrations = session === undefined ? undefined : this.writableRootRegistrations.get(session) - return registrations === undefined && derived.length === 0 - ? this.additionalWritableRoots - : resolveAdditionalWritableRoots([...(this.additionalWritableRoots ?? []), ...(registrations?.values() ?? []), ...derived]) - } - - /** - * The session's workspace root: its directory from the working-directory service; without that service - * the header directory, else the deployment fallback. - */ - private rootOf(session: Session | undefined): string { - if (session === undefined) return this.workspaceRoot - return this.ctx.get('workingDirectory')?.get(session) ?? session.header.cwd ?? this.workspaceRoot - } - } export default SandboxPolicyService diff --git a/packages/sandbox/sandbox-policy/src/linked-checkout.ts b/packages/sandbox/sandbox-policy/src/linked-checkout.ts deleted file mode 100644 index 916c90ded9..0000000000 --- a/packages/sandbox/sandbox-policy/src/linked-checkout.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * The Git administration directories of a linked checkout, read through the - * execution-world filesystem. These functions hold no service state. - * @module - */ - -import { basename, dirname, isAbsolute, relative, sep } from 'node:path' -import type { FileSystem } from '@deepseek-ai/dsh-fs' - -/** - * Whether `path` is `root` or lies below it. Both are canonical absolute paths of one execution - * world; the test is lexical and never touches the filesystem. - * @param root - canonical absolute directory. - * @param path - canonical absolute path to test. - * @returns whether `root` contains `path`. - */ -export function within(root: string, path: string): boolean { - const rest = relative(root, path) - return rest === '' || (rest !== '..' && !rest.startsWith(`..${sep}`) && !isAbsolute(rest)) -} - -/** The `gitdir:` pointer line of a linked checkout's `.git` file. */ -const GITDIR_POINTER = /^gitdir:[ \t]*(.+?)[ \t\r]*$/m - -/** - * Read one short pointer file inside a Git administration directory. - * @param fs - execution-world filesystem. - * @param path - pointer file, absolute or relative to `cwd`. - * @param cwd - directory a relative `path` resolves from. - * @param signal - cancellation of the reads. - * @returns the text, or undefined when the path is not a regular file. - */ -export async function pointerText(fs: FileSystem, path: string, cwd: string, signal: AbortSignal): Promise { - const entry = await fs.lstat(path, { cwd }, signal) - if (entry?.type !== 'file') return undefined - return fs.readText(await fs.resolve(path, { cwd, signal }), signal) -} - -/** - * Resolve a pointer target to a canonical directory. - * @param fs - execution-world filesystem. - * @param path - pointer target, absolute or relative to `cwd`. - * @param cwd - directory a relative `path` resolves from. - * @param signal - cancellation of the reads. - * @returns the canonical directory, or undefined when the target is not an existing directory. - */ -export async function pointerDirectory(fs: FileSystem, path: string, cwd: string, signal: AbortSignal): Promise { - const target = await fs.resolve(path, { cwd, signal }) - const info = await fs.stat(target, signal) - return info?.type === 'directory' ? fs.processPath(target) : undefined -} - -/** - * The Git administration directories a linked checkout at `root` writes outside itself. Only the layout - * Git creates for a linked worktree yields them; the [README](../README.md#use-this-package) states why. - * @param fs - execution-world filesystem. - * @param root - canonical absolute checkout directory. - * @param signal - cancellation of the reads. - * @returns the common directory and the administration directory, canonical, or an empty list. - */ -export async function linkedCheckoutAdministration(fs: FileSystem, root: string, signal: AbortSignal): Promise { - const pointer = await fs.lstat('.git', { cwd: root }, signal) - if (pointer?.type !== 'file') return [] - const pointerTarget = await fs.resolve('.git', { cwd: root, signal }) - const target = GITDIR_POINTER.exec(await fs.readText(pointerTarget, signal))?.[1] - if (target === undefined) return [] - const gitDirectory = await pointerDirectory(fs, target, root, signal) - if (gitDirectory === undefined || basename(dirname(gitDirectory)) !== 'worktrees') return [] - const common = dirname(dirname(gitDirectory)) - const commonPointer = (await pointerText(fs, 'commondir', gitDirectory, signal))?.trim() - if (commonPointer === undefined || commonPointer.length === 0) return [] - if (await pointerDirectory(fs, commonPointer, gitDirectory, signal) !== common) return [] - const back = (await pointerText(fs, 'gitdir', gitDirectory, signal))?.trim() - if (back === undefined || back.length === 0) return [] - if (fs.processPath(await fs.resolve(back, { cwd: gitDirectory, signal })) !== fs.processPath(pointerTarget)) return [] - if (within(common, root)) return [] - return [common, gitDirectory] -} diff --git a/packages/sandbox/sandbox-policy/tests/linked-checkout.spec.ts b/packages/sandbox/sandbox-policy/tests/linked-checkout.spec.ts deleted file mode 100644 index 4663a0973d..0000000000 --- a/packages/sandbox/sandbox-policy/tests/linked-checkout.spec.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** The Git layout reads behind the sandbox policy's derived grants, against a real filesystem. */ -import { execFile } from 'node:child_process' -import { mkdir, mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { join, sep } from 'node:path' -import { promisify } from 'node:util' -import { afterEach, describe, expect, it } from 'vitest' -import { Context } from '@deepseek-ai/cordis' -import LocalFileSystem from '@deepseek-ai/dsh-fs-local' -import { linkedCheckoutAdministration, pointerDirectory, pointerText, within } from '../src/linked-checkout.ts' - -const execute = promisify(execFile) -const signal = new AbortController().signal - -const cleanups: Array<() => Promise> = [] -afterEach(async () => { - for (const cleanup of cleanups.reverse()) await cleanup() - cleanups.length = 0 -}) - -async function scratch() { - const base = await realpath(await mkdtemp(join(tmpdir(), 'dsh-linked-checkout-'))) - cleanups.push(() => rm(base, { recursive: true, force: true })) - const ctx = new Context() - cleanups.push(() => ctx.fiber.dispose()) - await ctx.plugin(LocalFileSystem, { cwd: base }) - return { base, fs: ctx.fs } -} - -describe('within', () => { - it('holds for the directory itself and paths below it, not for parents or siblings sharing a prefix', () => { - const root = join(sep, 'work', 'repo') - expect(within(root, root)).toBe(true) - expect(within(root, join(root, 'packages', 'a'))).toBe(true) - expect(within(root, join(sep, 'work'))).toBe(false) - expect(within(root, `${root}-sibling`)).toBe(false) - expect(within(root, join(root, '..', 'other'))).toBe(false) - }) -}) - -describe('pointer reads', () => { - it('reads a regular pointer file relative to its directory and nothing else', async () => { - const { base, fs } = await scratch() - await writeFile(join(base, 'commondir'), '../..\n') - await mkdir(join(base, 'directory')) - expect(await pointerText(fs, 'commondir', base, signal)).toBe('../..\n') - expect(await pointerText(fs, join(base, 'commondir'), tmpdir(), signal)).toBe('../..\n') - expect(await pointerText(fs, 'directory', base, signal)).toBeUndefined() - expect(await pointerText(fs, 'missing', base, signal)).toBeUndefined() - }) - - it('resolves a pointer target to the canonical directory it names, or to nothing', async () => { - const { base, fs } = await scratch() - const target = join(base, 'target') - await mkdir(target) - await symlink(target, join(base, 'link')) - await writeFile(join(base, 'file'), '') - expect(await pointerDirectory(fs, 'target', base, signal)).toBe(target) - expect(await pointerDirectory(fs, 'link', base, signal)).toBe(target) - expect(await pointerDirectory(fs, target, tmpdir(), signal)).toBe(target) - expect(await pointerDirectory(fs, 'file', base, signal)).toBeUndefined() - expect(await pointerDirectory(fs, 'missing', base, signal)).toBeUndefined() - }) -}) - -describe('linkedCheckoutAdministration', () => { - it('names the common and administration directories of a linked worktree and nothing for its main checkout', async () => { - const { base, fs } = await scratch() - const repo = join(base, 'repo') - await mkdir(repo) - const git = (...args: string[]) => execute('git', ['-c', 'core.hooksPath=/dev/null', ...args], { - cwd: repo, - env: { - ...process.env, GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '', GIT_DIR: undefined, GIT_WORK_TREE: undefined, - GIT_AUTHOR_NAME: 'Policy fixture', GIT_AUTHOR_EMAIL: 'policy@example.invalid', - GIT_COMMITTER_NAME: 'Policy fixture', GIT_COMMITTER_EMAIL: 'policy@example.invalid', - }, - }) - await git('init', '-q', '-b', 'main') - await git('config', 'commit.gpgSign', 'false') - await git('commit', '-q', '--allow-empty', '-m', 'initial') - const linked = join(base, 'linked') - await git('worktree', 'add', '-q', '-b', 'linked', linked) - - expect(await linkedCheckoutAdministration(fs, linked, signal)).toEqual([join(repo, '.git'), join(repo, '.git', 'worktrees', 'linked')]) - expect(await linkedCheckoutAdministration(fs, repo, signal)).toEqual([]) - expect(await linkedCheckoutAdministration(fs, base, signal)).toEqual([]) - }) -}) diff --git a/packages/sandbox/sandbox-policy/tests/workspace-root.spec.ts b/packages/sandbox/sandbox-policy/tests/workspace-root.spec.ts index 3897ff0008..603ebc9884 100644 --- a/packages/sandbox/sandbox-policy/tests/workspace-root.spec.ts +++ b/packages/sandbox/sandbox-policy/tests/workspace-root.spec.ts @@ -1,10 +1,10 @@ -/** The workspace-write boundary follows the Session's workspace root, and a linked checkout's Git administration directories join it. */ +/** The workspace-write boundary follows the Session's working directory. */ import { execFile } from 'node:child_process' import { mkdir, mkdtemp, realpath, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import { join } from 'node:path' import { promisify } from 'node:util' -import { afterEach, describe, expect, it, vi } from 'vitest' +import { afterEach, describe, expect, it } from 'vitest' import { Context } from '@deepseek-ai/cordis' import type { Agent } from '@deepseek-ai/dsh-agent' import { unsupportedInbox, unsupportedModel } from '@deepseek-ai/dsh-agent-loop-testkit' @@ -15,7 +15,6 @@ import { brandString } from '@deepseek-ai/dsh-brand' import type { Session } from '@deepseek-ai/dsh-session' import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection' import SystemPrompt from '@deepseek-ai/dsh-system-prompt' -import { renderContextSnapshot } from '@deepseek-ai/dsh-system-prompt' import WorkingDirectoryService from '@deepseek-ai/dsh-working-directory' const execute = promisify(execFile) @@ -53,9 +52,7 @@ async function scratch(): Promise<{ base: string; repo: string }> { return { base, repo } } -async function mounted( - base: string, config: { mode?: 'workspace-write'; additionalWritableRoots?: string[] } = {}, defaultDirectory?: string, -) { +async function mounted(base: string, defaultDirectory?: string) { const ctx = new Context() cleanups.push(() => ctx.fiber.dispose()) await ctx.plugin(SessionStore) @@ -63,8 +60,8 @@ async function mounted( await ctx.plugin(SystemPrompt) await ctx.plugin(LocalFileSystem, { cwd: base }) await ctx.plugin(WorkingDirectoryService, defaultDirectory === undefined ? {} : { defaultDirectory }) - const fiber = await ctx.plugin(SandboxPolicyService, { mode: 'workspace-write', workspaceRoot: base, ...config }) - return { ctx, fiber } + await ctx.plugin(SandboxPolicyService, { mode: 'workspace-write', workspaceRoot: base }) + return { ctx } } function agentFor(ctx: Context, session: Session): Agent { @@ -77,14 +74,8 @@ function agentFor(ctx: Context, session: Session): Agent { } } -/** Run the tool pre-execution waterfall the way the tool pipeline does for one Agent. */ -async function preExecute(ctx: Context, agent: Agent): Promise { - const exec = { agent, signal: new AbortController().signal } - await ctx.waterfall('tools/pre-execute', exec as never, () => Promise.resolve(undefined as never)) -} - describe('workspace root as the write boundary', () => { - it('follows the Session into a worktree and back to the original project', async () => { + it('follows the Session into a linked worktree and back, granting only what is configured or registered', async () => { const { base, repo } = await scratch() const { ctx } = await mounted(base) const worktree = join(repo, '.agents', 'worktrees', 'topic') @@ -99,264 +90,26 @@ describe('workspace root as the write boundary', () => { expect(ctx.workingDirectory.get(session)).toBe(repo) expect(ctx.sandboxPolicy.resolve({ session }).workspaceRoot).toBe(repo) + // The repository's Git directory lies outside the worktree, and the policy reads no Git layout to grant it. await ctx.workingDirectory.set(agent, worktree) - expect(ctx.sandboxPolicy.resolve({ session }).workspaceRoot).toBe(worktree) - // An agentless tool execution has no root to prepare and passes through. - await ctx.waterfall('tools/pre-execute', { signal: new AbortController().signal } as never, () => Promise.resolve(undefined as never)) - await preExecute(ctx, agent) + expect(ctx.sandboxPolicy.resolve({ session })).toEqual({ mode: 'workspace-write', workspaceRoot: worktree, sessionId: session.id }) + const revoke = ctx.sandboxPolicy.registerWritableRoot(session, join(repo, '.git')) expect(ctx.sandboxPolicy.resolve({ session })).toEqual({ mode: 'workspace-write', workspaceRoot: worktree, additionalWritableRoots: [join(repo, '.git')], sessionId: session.id, }) + revoke() await ctx.workingDirectory.set(agent, repo) expect(ctx.sandboxPolicy.resolve({ session })).toEqual({ mode: 'workspace-write', workspaceRoot: repo, sessionId: session.id }) }) - it('derives the Git administration of a named checkout for a Host operation and leaves Session policies as they are', async () => { - const { base, repo } = await scratch() - const extra = join(base, 'extra') - await mkdir(extra) - const { ctx } = await mounted(base, { additionalWritableRoots: [extra] }) - const worktree = join(base, 'wt') - await git(repo, 'worktree', 'add', '-q', '-b', 'wt', worktree) - const other = join(base, 'other') - await git(repo, 'worktree', 'add', '-q', '-b', 'other', other) - const session = ctx.sessions.create(brandString('maintenance'), { meta: { cwd: worktree } }) - expect(await ctx.sandboxPolicy.prepare({ session })).toEqual([join(repo, '.git')]) - // The source checkout keeps its Git directory inside itself, so nothing is derived for it. - expect(await ctx.sandboxPolicy.prepare({ directory: repo })).toEqual([]) - expect(await ctx.sandboxPolicy.prepare({ directory: other })).toEqual([join(repo, '.git')]) - expect(ctx.sandboxPolicy.resolve({ session })).toEqual({ - mode: 'workspace-write', workspaceRoot: worktree, additionalWritableRoots: [extra, join(repo, '.git')], sessionId: session.id, - }) - await expect(ctx.sandboxPolicy.prepare({ directory: 'relative' })).rejects.toThrow('absolute execution-world path') - }) - it('bounds a Session without a recorded directory by the directory service\'s default directory', async () => { const { base, repo } = await scratch() - const { ctx } = await mounted(base, {}, repo) + const { ctx } = await mounted(base, repo) const session = ctx.sessions.create(brandString('no-directory')) // Relative paths of such a Session resolve from that default, so it is the boundary; the policy's // configured root serves agentless calls. expect(ctx.sandboxPolicy.resolve({ session }).workspaceRoot).toBe(repo) expect(ctx.sandboxPolicy.resolve().workspaceRoot).toBe(base) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([]) - }) -}) - -describe('Git administration directories of a linked checkout', () => { - it('derives the common directory for a Session opened inside a linked worktree and merges configured extras', async () => { - const { base, repo } = await scratch() - const extra = join(base, 'extra') - await mkdir(extra) - const { ctx } = await mounted(base, { additionalWritableRoots: [extra] }) - const worktree = join(base, 'elsewhere', 'wt') - await mkdir(join(base, 'elsewhere')) - await git(repo, 'worktree', 'add', '-q', '-b', 'wt', worktree) - const session = ctx.sessions.create(brandString('linked'), { meta: { cwd: worktree } }) - // Session creation starts the derivation; a tool execution waits for it. - await preExecute(ctx, agentFor(ctx, session)) - const policy = ctx.sandboxPolicy.resolve({ session }) - expect(policy.workspaceRoot).toBe(worktree) - expect(policy.additionalWritableRoots).toEqual([extra, join(repo, '.git')]) - expect(Object.isFrozen(policy.additionalWritableRoots)).toBe(true) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([join(repo, '.git')]) - expect(ctx.sandboxPolicy.resolve()).toEqual({ mode: 'workspace-write', workspaceRoot: base, additionalWritableRoots: [extra] }) - }) - - it('settles a root once its layout was read and reads it again only when a Host operation moves a workspace into it', async () => { - const { base, repo } = await scratch() - const { ctx } = await mounted(base) - const plain = ctx.sessions.create(brandString('plain'), { meta: { cwd: repo } }) - expect(await ctx.sandboxPolicy.prepare({ session: plain })).toEqual([]) - expect(ctx.sandboxPolicy.resolve({ session: plain })).toEqual({ mode: 'workspace-write', workspaceRoot: repo, sessionId: plain.id }) - - // A directory that is no checkout yet settles as granting nothing; a worktree created there afterwards - // does not widen the policy of a Session already working in it, nor can a pointer written by the model. - const later = join(base, 'later') - const early = ctx.sessions.create(brandString('early'), { meta: { cwd: later } }) - expect(await ctx.sandboxPolicy.prepare({ session: early })).toEqual([]) - await git(repo, 'worktree', 'add', '-q', '-b', 'later', later) - expect(await ctx.sandboxPolicy.prepare({ session: early })).toEqual([]) - expect(ctx.sandboxPolicy.resolve({ session: early }).additionalWritableRoots).toBeUndefined() - - // A Host move of a workspace into the checkout reads its layout again. - const entering = ctx.sessions.create(brandString('entering'), { meta: { cwd: repo } }) - await ctx.workingDirectory.set(agentFor(ctx, entering), later) - expect(await ctx.sandboxPolicy.prepare({ session: entering })).toEqual([join(repo, '.git')]) - expect(await ctx.sandboxPolicy.prepare({ session: early })).toEqual([join(repo, '.git')]) - }) - - it('grants nothing for pointer files the checkout itself could have written', async () => { - const { base, repo } = await scratch() - const { ctx } = await mounted(base) - const sessionIn = (name: string) => ctx.sessions.create(brandString(name), { meta: { cwd: join(base, name) } }) - const checkout = async (name: string, pointer: string) => { - await mkdir(join(base, name), { recursive: true }) - await writeFile(join(base, name, '.git'), pointer) - return sessionIn(name) - } - - // A pointer to the filesystem root, to the home of the workspace, or to any directory outside Git's - // worktree layout names no administration directory. - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('root-pointer', 'gitdir: /\n') })).toEqual([]) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('base-pointer', `gitdir: ${base}\n`) })).toEqual([]) - const administration = join(base, 'administration') - await mkdir(administration) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('handmade', `gitdir: ${administration}\n`) })).toEqual([]) - - // A forged worktree layout whose commondir escapes, or whose administration directory does not point - // back at the checkout, grants nothing; a layout whose common directory contains the root grants nothing. - const forgedCommon = join(base, 'forged', 'worktrees', 'x') - await mkdir(forgedCommon, { recursive: true }) - await writeFile(join(forgedCommon, 'commondir'), '/\n') - await writeFile(join(forgedCommon, 'gitdir'), `${join(base, 'escaping', '.git')}\n`) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('escaping', `gitdir: ${forgedCommon}\n`) })).toEqual([]) - await writeFile(join(forgedCommon, 'commondir'), '../..\n') - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('unlinked', `gitdir: ${forgedCommon}\n`) })).toEqual([]) - const enclosing = join(base, 'worktrees', 'inner') - await mkdir(enclosing, { recursive: true }) - await writeFile(join(enclosing, 'commondir'), '../..\n') - await writeFile(join(enclosing, 'gitdir'), `${join(base, 'enclosed', '.git')}\n`) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('enclosed', `gitdir: ${enclosing}\n`) })).toEqual([]) - - // A missing commondir or gitdir file, a commondir that is a directory, and a missing gitdir text grant nothing. - const partial = join(base, 'partial', 'worktrees', 'z') - await mkdir(join(partial, 'commondir'), { recursive: true }) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('partial-checkout', `gitdir: ${partial}\n`) })).toEqual([]) - const noBack = join(base, 'no-back', 'worktrees', 'w') - await mkdir(noBack, { recursive: true }) - await writeFile(join(noBack, 'commondir'), '../..\n') - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('no-back-checkout', `gitdir: ${noBack}\n`) })).toEqual([]) - await writeFile(join(noBack, 'gitdir'), '\n') - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('blank-back-checkout', `gitdir: ${noBack}\n`) })).toEqual([]) - - // Dangling, blank, and malformed pointers grant nothing either. - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('dangling', `gitdir: ${join(base, 'missing-administration')}\n`) })).toEqual([]) - const blank = join(base, 'blank', 'worktrees', 'y') - await mkdir(blank, { recursive: true }) - await writeFile(join(blank, 'commondir'), '') - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('blank-checkout', `gitdir: ${blank}\n`) })).toEqual([]) - expect(await ctx.sandboxPolicy.prepare({ session: await checkout('malformed', 'not a pointer\n') })).toEqual([]) - - // The layout Git writes still grants the common directory, and nothing else. - const worktree = join(base, 'genuine') - await git(repo, 'worktree', 'add', '-q', '-b', 'genuine', worktree) - expect(await ctx.sandboxPolicy.prepare({ session: sessionIn('genuine') })).toEqual([join(repo, '.git')]) - }) - - it('derives again when a derived directory disappears and keeps confinement resolvable', async () => { - const { base, repo } = await scratch() - const { ctx } = await mounted(base) - const worktree = join(base, 'orphaned') - await git(repo, 'worktree', 'add', '-q', '-b', 'orphaned', worktree) - const session = ctx.sessions.create(brandString('orphaned'), { meta: { cwd: worktree } }) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([join(repo, '.git')]) - await rm(repo, { recursive: true, force: true }) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([]) - expect(ctx.sandboxPolicy.resolve({ session }).additionalWritableRoots).toBeUndefined() - - // An uninspectable directory invalidates the settled result the same way, and the derivation runs again. - const again = join(base, 'again') - await mkdir(join(base, 'again-repo')) - await git(join(base, 'again-repo'), 'init', '-q', '-b', 'main') - await git(join(base, 'again-repo'), 'commit', '-q', '--allow-empty', '-m', 'initial') - await git(join(base, 'again-repo'), 'worktree', 'add', '-q', '-b', 'again', again) - const other = ctx.sessions.create(brandString('again'), { meta: { cwd: again } }) - const common = join(base, 'again-repo', '.git') - expect(await ctx.sandboxPolicy.prepare({ session: other })).toEqual([common]) - const probe = vi.spyOn(ctx.fs, 'lstat').mockImplementationOnce(async () => { throw new Error('inspection denied') }) - try { - expect(await ctx.sandboxPolicy.prepare({ session: other })).toEqual([common]) - expect(probe.mock.calls[0]?.[0]).toBe(common) - expect(probe.mock.calls.length).toBeGreaterThan(1) - } finally { - probe.mockRestore() - } - }) - - it('renders the configured extra directories to the model, never the derived Git directories', async () => { - const { base, repo } = await scratch() - const extra = join(base, 'extra') - await mkdir(extra) - const worktree = join(base, 'rendered') - await git(repo, 'worktree', 'add', '-q', '-b', 'rendered', worktree) - for (const additionalWritableRoots of [undefined, [extra]]) { - const { ctx } = await mounted(base, additionalWritableRoots === undefined ? {} : { additionalWritableRoots }) - const session = ctx.sessions.create(brandString(`rendered-${additionalWritableRoots === undefined ? 'plain' : 'extra'}`), { meta: { cwd: worktree } }) - const agent = agentFor(ctx, session) - await preExecute(ctx, agent) - expect(ctx.sandboxPolicy.resolve({ session }).additionalWritableRoots).toEqual([...additionalWritableRoots ?? [], join(repo, '.git')]) - const text = renderContextSnapshot(await ctx.systemPrompt.assemble({ agent, scope: agent })) - expect(text).toContain(`may modify files under the session workspace: ${JSON.stringify(worktree)}.`) - expect(text).not.toContain(join(repo, '.git')) - if (additionalWritableRoots === undefined) expect(text).not.toContain('Additional writable directories') - else expect(text).toContain(`Additional writable directories: ${JSON.stringify(additionalWritableRoots)}.`) - } - }) - - it('logs a failed read once per root, grants nothing for it, and derives again on the next call', async () => { - const { base, repo } = await scratch() - const { ctx } = await mounted(base) - const worktree = join(base, 'retry') - await git(repo, 'worktree', 'add', '-q', '-b', 'retry', worktree) - const warn = vi.spyOn(ctx.logger, 'warn').mockImplementation(() => {}) - const lstat = vi.spyOn(ctx.fs, 'lstat') - .mockRejectedValueOnce(new Error('disk unavailable')) - .mockRejectedValueOnce(new Error('disk unavailable')) - try { - const session = ctx.sessions.create(brandString('retry'), { meta: { cwd: worktree } }) - await vi.waitFor(() => { expect(warn).toHaveBeenCalledTimes(1) }) - expect(warn.mock.calls[0]?.[0]).toContain('could not derive the Git administration directories') - expect(ctx.sandboxPolicy.resolve({ session }).additionalWritableRoots).toBeUndefined() - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([]) - expect(warn).toHaveBeenCalledTimes(1) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([join(repo, '.git')]) - } finally { - lstat.mockRestore() - warn.mockRestore() - } - }) - - it('shares one derivation between concurrent callers and rejects callers when the service is disposed first', async () => { - const { base, repo } = await scratch() - const { ctx, fiber } = await mounted(base) - const worktree = join(base, 'shared') - await git(repo, 'worktree', 'add', '-q', '-b', 'shared', worktree) - const entered = Promise.withResolvers() - const release = Promise.withResolvers() - const lstat = ctx.fs.lstat.bind(ctx.fs) - const probe = vi.spyOn(ctx.fs, 'lstat').mockImplementation(async (path, opts, signal) => { - entered.resolve(undefined) - await release.promise - signal?.throwIfAborted() - return lstat(path, opts, signal) - }) - try { - const session = ctx.sessions.create(brandString('shared'), { meta: { cwd: worktree } }) - await entered.promise - const first = ctx.sandboxPolicy.prepare({ session: session }) - const second = ctx.sandboxPolicy.prepare({ session: session }) - expect(probe).toHaveBeenCalledTimes(1) - const disposal = fiber.dispose() - release.resolve(undefined) - await expect(first).rejects.toThrow('sandbox-policy service disposed') - await expect(second).rejects.toThrow('sandbox-policy service disposed') - await disposal - } finally { - release.resolve(undefined) - probe.mockRestore() - } - }) - - it('derives nothing without a filesystem provider', async () => { - const ctx = new Context() - cleanups.push(() => ctx.fiber.dispose()) - await ctx.plugin(SessionStore) - await ctx.plugin(SessionProjectionRegistry) - await ctx.plugin(SandboxPolicyService, { mode: 'workspace-write', workspaceRoot: '/fallback' }) - const session = ctx.sessions.create(brandString('no-fs'), { meta: { cwd: '/projects/current' } }) - expect(await ctx.sandboxPolicy.prepare({ session: session })).toEqual([]) - expect(ctx.sandboxPolicy.resolve({ session })).toEqual({ mode: 'workspace-write', workspaceRoot: '/projects/current', sessionId: session.id }) }) }) diff --git a/packages/sandbox/sandbox-policy/tsconfig.json b/packages/sandbox/sandbox-policy/tsconfig.json index 48c63e92fa..1c9d13b753 100644 --- a/packages/sandbox/sandbox-policy/tsconfig.json +++ b/packages/sandbox/sandbox-policy/tsconfig.json @@ -32,12 +32,6 @@ { "path": "../../session/session-projection" }, - { - "path": "../../fs/fs" - }, - { - "path": "../../core/tools" - }, { "path": "../../session/working-directory" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1064686ff..4b901e1c07 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15479,9 +15479,6 @@ importers: '@deepseek-ai/dsh-brand': specifier: workspace:* version: link:../../util/brand - '@deepseek-ai/dsh-fs': - specifier: workspace:* - version: link:../../fs/fs '@deepseek-ai/dsh-fs-local': specifier: workspace:* version: link:../../fs/fs-local @@ -15494,15 +15491,9 @@ importers: '@deepseek-ai/dsh-session-projection': specifier: workspace:* version: link:../../session/session-projection - '@deepseek-ai/dsh-subprocess-local': - specifier: workspace:* - version: link:../../subprocess/subprocess-local '@deepseek-ai/dsh-system-prompt': specifier: workspace:* version: link:../../core/system-prompt - '@deepseek-ai/dsh-tools': - specifier: workspace:* - version: link:../../core/tools '@deepseek-ai/dsh-user-approval': specifier: workspace:* version: link:../../interaction/user-approval