Repository navigation
Replies: 2 comments
|
Implementation: #8691. It adds
|
0 replies
|
We merged #10786, which adds the hooks this discussion asks for:
A hook can wrap the command but can't replace it. The plugin docs in that PR describe the rules. It will be in the next beta, before stable. The Updates page shows how to join the beta. If you try it with workspace-sandbox, please say here whether it covers what you need. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What I'm trying to do
I maintain workspace-sandbox, a plugin in the plugin registry that runs a workspace's agents and terminals inside a sandbox: a Podman or Docker container, a devcontainer, a microsandbox microVM, or a Bubblewrap or Apptainer sandbox. The sandbox sees only the workspace, the agents' own state, and folders the user adds. The goal is to be able to open an untrusted repository in Paseo without its code, or an agent working on it, reaching the rest of the machine.
Agents are covered through
agent.create.beforeandagent.open.before. Everything else Paseo starts in a workspace runs on the host, because no hook reaches it:paseo.jsonscripts and servicesHow I do it today
Terminals. The plugin adds its own Sandbox workspace panel with a terminal launcher. It calls
paseo.terminals.createwith the plugin's wrapper script as the command (sandbox-run terminal --title <name> [command...]), and the wrapper joins the workspace's sandbox. To offer terminal profiles in that launcher, the plugin readsterminalProfilesthroughpaseo.config.get()and reimplements Paseo's default profiles and the{{{prompt}}}handling, since the SDK doesn't export the profile format. The wrapper finds its workspace fromPASEO_WORKSPACE_IDin the terminal's environment. Paseo's own terminal button and profiles are still right there in the same workspace and still open host shells, so the user has to remember which one to use.Commands. No workaround. The plugin's README lists setup, scripts, and services as running on the host, with the warning that for an untrusted repository, setup alone defeats the sandbox: it runs the repository's own commands on the host before any agent starts.
Agents. These work, with more machinery than they'd need:
agent.open.beforecan change onlyenv,tools, andmcpServers, not the launch command. So the plugin creates a derived provider profile for each provider (claude-sandbox,codex-sandbox, ...) whosecommandis[sandbox-run, agent, <the provider's command>]. It mirrors the daemon's built-in default commands to do so, andagent.create.beforerewrites each new agent'sproviderto the derived one. Providers that can't be extended this way (OpenCode, plugin providers) are refused.agent.create.beforehas no workspace id (Plugin API: pass the target workspaceId to the agent.create before-hook #8017), so the plugin finds the sandbox fromconfig.cwd. A workspace that shares its directory with other workspaces, such as severallocalworkspaces on one checkout, can't be told apart that way. So for a sandboxed directory workspace, the plugin creates a per-workspace symlink to the project directory inside its data folder and opens the workspace at the link, purely so its cwd is unique.Where Paseo gets in the way
Paseo has no hook for processes it starts in a workspace other than agents. A plugin can add a second, sandboxed way of opening a terminal, but can't change the first one. It can't do anything about setup, scripts, or services.
The hooks that do exist identify the workspace inconsistently:
agent.open.beforehasworkspaceId, whileagent.create.beforehas only the cwd (#8017).What would a better workflow look like?
Two waiting hooks, in the style of
worktree.create.before, each with the workspace id:terminal.create.before, for every terminal Paseo creates in a workspace: New terminal, terminal profiles, terminals from Paseo tools and the CLI, and those created by plugins. Something like:The handler may replace
command,args, andenv, or throw to refuse.command.run.before(name to taste), for the non-interactive commands Paseo runs in a workspace on the user's behalf: worktree setup and teardown,paseo.jsonscripts, and services.The handler may return a replacement command (for example, the original prefixed with a wrapper) and environment, or throw to refuse. Git commands the daemon runs itself are out of scope.
The workspace id in both. Both hooks need
workspaceId, for the reason #8017 gives: the cwd doesn't identify the workspace. The same field inagent.create.before, as #8017 asks, would make all the hooks consistent.A few details that would matter for a sandboxing plugin:
worktree.create.afterandworkspace.create.after, so a plugin can create the sandbox first.How this would change workspace-sandbox
workspaceIdinagent.create.before(Plugin API: pass the target workspaceId to the agent.create before-hook #8017), the per-workspace symlink for sandboxed directories could go, and agents would be routed by workspace rather than by directory.Separately, if
agent.open.beforecould also wrap the launch command (for example, acommandPrefix), the derived provider profiles and the copy of the daemon's default provider commands could go, and OpenCode and plugin providers could be sandboxed too. That's a bigger change, and less important than the two hooks above.Built against Paseo 0.14.0. Related: #8017, #7729, and the sandboxing discussions #3084 and #4801. A plugin with these hooks would cover much of what those discussions describe, without sandboxing in core.
All reactions