Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

5.3 KB
Raw Blame

Command confinement, with backends as plugins

  • Date: 2026-08-22
  • Type: feature
  • Scope: core, server, plugins, docs
  • PR: #354
  • Breaking: yes — extensions.json is read no longer and both SDK subpaths moved to /plugin; the plugin contract is closed, so context.terminals needs a cast

中文版

Shell commands an agent runs can now be confined. The harness gained its own sandbox interface — argv rewriting, honest enforcement reporting, fail-closed — naming three dimensions: fs-write, network and mask-paths. No backend is part of the harness: each is a plugin package a deployment installs and names in plugins.json, which is why this builds on the plugin mechanism — shipped in 0.2.8 as the extension mechanism and renamed here. A default deployment names none and confines nothing.

Details

  • The seam is in core. confineSpawn is threaded along the existing proxyEnv line and applied in ManagedSession immediately before spawn: it receives the exact argv, cwd and workspaceDir, and returns the argv to spawn instead. Mechanism only — it never interprets the argv.
  • Routing cannot silently drop a dimension. A backend declares which dimensions it implements (declaring none means filesystem-only) and the service routes each policy to one that covers what it requires. A requirement nothing covers fails closed, naming what each mounted backend does cover. confine must return enforcing argv or throw; a throw aborts the spawn and surfaces as the command's spawn error, so a command never runs unconfined because a backend failed.
  • Four backends ship as packages: plugin-sandbox-dsh (the portable DSH adaptor, file effects on all three platforms), plus plugin-sandbox-bwrap (Linux), -seatbelt (macOS) and -mxc (Windows, through Microsoft MXC's processcontainer) — the three native ones implementing all three dimensions. Each declares Apache-2.0 and ships a README.md documenting what it actually enforces, down to bwrap's mount ordering and Seatbelt's rule precedence: a deployment chooses a backend by exactly that. With no backend inside the platform bundle, the bundle no longer inlines any native-adjacent module, and deploy.mjs's runtime-resolved-natives shim is gone. Confinement settings ride the parked platform context, so a hot push cannot silently un-confine a deployment.
  • The plugin contract is closed, and owns the sandbox vocabulary. PenguinContext and PenguinInterface name every member instead of being reopened by declare module: a plugin checking against the contract used to compile against members only one embedder supplies. SandboxPolicy, SandboxProvider, ConfinedArgv and the mode/dimension unions live in @prismshadow/penguin-core/plugin now, since a backend is written against those names and nothing else — while the helpers that read them stay in the server package, which keeps both plugin subpaths emitting types and nothing else. A backend therefore names core alone: all four dropped @prismshadow/penguin-server from their dependencies and can no longer resolve it, and the server's plugin subpath narrowed to the one member it owns, HarnessContext.
  • One word for the mechanism: plugin. What 0.2.8 shipped as the extension mechanism is the plugin mechanism from here on, so a reader meets the same term wherever the concept appears. The config file is <root>/plugins.json with a plugins key; the SDK subpaths are @prismshadow/penguin-core/plugin and @prismshadow/penguin-server/plugin; the contract names Plugin / PluginContext / PluginEvents, and the harness PluginHost; the four backends are @prismshadow/penguin-plugin-sandbox-* under plugins/. PenguinContext, PenguinInterface, HarnessContext and the whole sandbox vocabulary keep their names. The word stays taken elsewhere and none of it moved: file extensions, remark/micromark syntax extensions, the composer's "+" extension menu, and the SDK's own "Extension seams". Nor is it cordis's plugin — the DSH adaptor mounts DSH's chain through cordis's Context.plugin, and the two vocabularies share nothing but the word.

Compatibility

An extensions.json already on disk is not read and not migrated. A deployment that configured plugins under the old name keeps running with none of them loaded and their capability silently unavailable — for these sandbox backends, that means commands spawn unconfined. Rename the file to plugins.json and its "extensions" key to "plugins"; the specifiers inside change only where they name this repository's sandbox backends, whose packages are now @prismshadow/penguin-plugin-sandbox-*. A package compiled against @prismshadow/penguin-core/extension or @prismshadow/penguin-server/extension no longer resolves: point the import at /plugin and rename the three types it uses.

terminals is a harness class and cannot be in the contract. It is named on HarnessContext, which extends it, so the emitted value still satisfies the contract and the seam is unchanged — but a plugin reading context.terminals now writes ctx as HarnessContext, stating where it is used that it depends on this embedder.

Nothing about the wire format, the database or any other on-disk document changes.