Plugin System Internals
Host architecture and security boundaries. Plugin authors want Writing plugins and the Plugin API reference instead.
Components
| Area | Source |
|---|---|
| Public manifest types | aoe-plugin-api/ |
| Registry and contributions | src/plugin/registry.rs, contributions.rs |
| Install and update | install.rs, fetch.rs, integrity.rs, lockfile.rs |
| Discovery | discover.rs, featured.rs, update_check.rs |
| Worker launch and supervision | launch.rs, host.rs, protocol.rs |
| Worker RPCs | host_api.rs, session_api.rs |
| Provider-native integrations | src/plugin/agent_integration.rs, src/session/instance/status_update.rs |
| Host-rendered UI state | ui_state.rs |
| Automation policy | automation_policy.rs |
src/plugin/mod.rs owns a lazily loaded process-wide registry; reloading it after a config change updates the CLI, TUI, and web views from one PluginView. The standalone aoe-plugin-api crate is the source of truth for aoe-plugin.toml, and parsing is strict: unknown fields, unsupported API versions, invalid ids, and malformed contributions are rejected. api_version describes the manifest schema; aoe_version constrains the host application.
Per-plugin settings live under [plugins."<id>".settings] in config.toml and per-session metadata in Instance.plugin_meta[<id>]. Disabling preserves both. Uninstall removes external plugin configuration; stale staged settings must not recreate it or alter a replacement installation.
Installation and trust
Sources are local paths or GitHub references. Installation stages content in the app directory, validates the manifest and host compatibility, runs declared build steps, then atomically places the plugin under plugins/<id>/. Build outputs go under .aoe-build/, excluded from source integrity. The lockfile pins installed source identity, resolved revision, content hash, manifest hash, and grants, and an update that changes capabilities requires approval. Featured plugins additionally match the repository’s pinned source hash and may claim reserved namespaces.
execution.rs gives preparation/application one fixed two-hour wall-clock
budget across Git and approved builds. A private spawn-only owned-child wrapper
keeps the direct child unreaped, reserving its original PGID through settlement.
Signal failures retain custody through bounded observation; success requires
physical child exit and no executing original-group member.
Its ephemeral descendant tree borrows that custody instead of requiring a
historical root audit token across exec. Owned macOS descendants retain the
kernel’s exec-stable physical birth ID after parent-birth ancestry proof.
Observation distinguishes that birth from the execution token; each signal
checks a fresh audit token against the retained birth. Previously admitted
escaped descendants remain owned across exec. Recovered trees and runners
keep their original identity fences. Physically exited history is pruned
through a PID index.
Tree and target metadata roll back together; the old tree remains until config
and lock writes commit. Unproven settlement/restoration or post-commit backup
cleanup retains exclusion, evidence and an in-process recovery fence, including
failed marker writes. Admission checks recovery under the operation flock;
every external worker launch checks it too. See
manual recovery.
This is lifecycle supervision, not a malicious-code sandbox.
Local staging retains directory descriptors, rejects unsupported entries before opening, opens regular files nonblocking without following links, and validates opened identities before copying handles. Iterator errors propagate. Release assets keep their bytes, metadata, staging owner, and operation lease through async download and blocking hash/extract; the tree hash remains pre-injection. Preview never builds, provisions Node, grants capabilities, or publishes an install. Preview-only transport adds ten minutes to the shared execution budget. Network resolution and release metadata each allow 60 seconds, asset transfer 300 seconds, and the two possible changelog requests 30 seconds each, within that allowance.
TUI update review pins one verified local HTTP client. Approval submits the existing Daemon job exactly once; that job owns both apply and worker restart, independently of the TUI runtime. A watch snapshot coalesces accepted id, latest shared log and terminal outcome; closing its receiver stops observation only. Job responses carry the real host log path, never a job-id-derived filename. Other manager lifecycle actions are unchanged. Settings merge only user-owned plugin leaves under operation-then-config lock order, compare source/dev/full grant against their baseline, and adopt persisted values. Delayed live refresh rereads persisted intent and never replays stale enabled values. The lifecycle comparison is conservative, not absolute ABA proof. Active text/list editors capture field identity and owning lifecycle before resync, cancel on replacement/removal/field disappearance, and rebind unchanged editors by identity rather than position.
Every worker needs runtime.worker; other capabilities gate host RPCs and are checked before dispatch. A plugin reaches only its own settings and metadata unless granted more. Capability checks are an API boundary, not an OS sandbox: workers run as ordinary child processes through NoSandbox, so only trusted plugin code should be installed.
Contributions
Static manifest contributions are collected from active plugins: settings join the single settings schema and keep plugin ownership, themes resolve within the plugin directory, commands and keybindings are namespaced with core names taking precedence, status definitions provide host-rendered labels, the pane, home-pane, and composer-action slots render typed worker state, and a page slot serves its declared HTML entry. agent_integrations connects an agent tool to the generic session status and prompt protocol; optional launch metadata expose plugin-provided agents to the CLI, TUI, and dashboard while the host keeps session lifecycle and secure argument handling.
API 21 agent declarations are resolved against an owned registry snapshot. Built-in agents and configured custom agents retain precedence. A declared OMP capture backend uses the selected pane-scoped context; unsupported contexts never start capture. A disabled or absent integration leaves built-in OMP launch, pane detection, and capture available.
Host-rendered slots run no plugin code in a frontend: workers publish typed state, the host stores the latest generation, and the web or daemon-connected TUI renders it; generation ids stop a stopped worker’s late cleanup from deleting a newer worker’s state. Pane actions return to the worker as JSON-RPC notifications. A page is the exception: its own HTML and inline script run in a sandboxed frame with an opaque origin, never on the dashboard origin.
Worker host
The worker host exists only in aoe serve, where session storage and the event store are available. For each active plugin with a runtime it resolves the entrypoint, launches one child process, and speaks newline-delimited JSON-RPC 2.0 over stdio. Command runtimes resolve plugin-relative executables inside the install tree, bare interpreter names may resolve on PATH, and release-binary runtimes use the platform asset the installer placed; build steps follow the same policy.
Workers are tied to the daemon lifetime, with no reattach socket or durable runner record. Supervision reaps the whole process group, limits concurrency, and stops retrying after three crashes in 60 seconds; disabling and re-enabling a plugin clears its crash tombstone. Worker stderr goes to per-plugin files under <app_dir>/plugin-workers/, pruned in src/plugin/worker_logs.rs; see Worker logs. PluginHost::reconcile is the idempotent lifecycle entrypoint used at daemon startup and after enable or disable, and local CLI and TUI toggles route through a running daemon when possible so workers change immediately.
Host APIs and events
The host exposes capability-checked RPCs for the plugin event bus, private session metadata, plugin settings, session listing, UI state, ACP capability discovery, and plugin-created sessions; the methods and payloads are in the Plugin API reference. The event bus uses the protocol-neutral store in src/events/ with its own schema and replay cursor. Session writes take the storage lock and become visible to other processes on their next reload. Each caller’s plugin id comes from its host context, never from request parameters.
Unattended plugin sessions
Workers may create structured-view sessions and send turns, but the host keeps the security decisions:
session.createandsession.promptgrant the basic operations, whilesession.unattendedis separately required for a host-classified bypass or auto-write mode, and unknown approval modes classify as unattended;- repository hooks still require repository trust, which a plugin cannot grant;
- turns may target only sessions the calling plugin created;
session.messageis the one exception:sessions.message.sendreaches any session, so the capability grant is its only gate. It wakes stopped sessions but never archived or trashed ones, runs the same prompt path as the web composer for structured sessions, and refuses terminal targets in CityHall mode;- idempotency keys are scoped to the plugin and session lifetime;
- per-plugin create, active-session, turn, and message limits survive daemon restarts in a private audit ledger;
- disabling the plugin stops its worker and its automation.
The create RPC accepts structured fields only: no raw agent arguments, no arbitrary environment variables, no trust bypass.
Discovery and updates
Discovery merges the featured index with exact GitHub sources the user configured; search does not crawl GitHub. Update checks compare the installed lockfile with the resolved source or release and never mutate installation state. Auto-update uses the same staging, validation, build, integrity, and grant path as an explicit update, so changes needing approval stay pending. Plugin screenshots and identity assets are validated as relative image paths; installed icons are served from canonicalized paths inside the install tree, and marketplace assets resolve against the pinned GitHub source.