Repository navigation
Nexus: ACP engine transport + Landlock engine sandbox - #35
Merged
Merged
Conversation
ACP (Agent Client Protocol) for engines that speak it (opencode, gemini): - lib/nexus/acp-client.js: zero-dep JSON-RPC/NDJSON client; streams text, thinking and tool calls into the TUI's tool cards; real token usage from the prompt result; session/cancel before any kill; falls back to the classic one-shot run when the handshake fails (once per session). - The engine asks before acting (session/request_permission) and Nexus answers from its own rules: plan mode rejects anything but read/search/ think/fetch (and selects the engine's own plan mode), /permissions deny rules and the destructive-command guard apply to execute calls, a guard warning asks the user in normal mode, and touching a path outside the project asks even in auto-accept. Client fs reads/writes stay in the project jail and are refused in plan mode. - opencode tools are set to "ask" via OPENCODE_CONFIG_CONTENT, never overriding a permission the user configured; gemini's ACP flag is detected from --help. - /acp auto|off (default auto, persisted, NEXUS_ACP). Sandbox (Linux Landlock, unprivileged; bubblewrap is blocked by the AppArmor userns restriction on Ubuntu 24.04+): - lib/nexus/landlock.py: stdlib python3 launcher that restricts itself and execs the engine. Reads the system, never ~/.ssh, cloud/CLI tokens, browser profiles or shell history (symlinks resolved, so a link to / or $HOME cannot widen the grant); writes only the project (not in plan mode), the temp dir and engine state dirs. Network stays open. - lib/nexus/sandbox.js: policy, probe, spawn wrap. Applied to claude turns, classic CLI engine turns, ACP turns and the local agent's run_command. - /sandbox auto|always|off (default auto = plan mode + untrusted repos, persisted, NEXUS_SANDBOX). Falls back unsandboxed where Landlock or python3 is missing; only an explicit "always" warns about that. Verified live: opencode 1.17.9 over ACP (handshake, streaming, a real request_permission + fs/write_text_file, plan agent selection) plain and sandboxed; Claude Code runs sandboxed in plan mode. Tests: test/acp-sandbox.test.js (fake ACP agent + live Landlock checks).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #34 (base
fix/audit-security). Merge #34 first; this PR then retargets tomain.ACP engine transport
Engines that speak the Agent Client Protocol (opencode now, and gemini when its CLI has the flag, detected from
--help) run over ACP instead of a one-shotrun "<prompt>":/permissionsdeny rules and/guardapply to the engine's shell commands./acp auto|off, defaultauto. It is saved, andNEXUS_ACPoverrides it for one launch.Engine sandbox (Linux Landlock)
~/.ssh, cloud or CLI tokens, browser profiles or shell history. Symlinks are resolved, so a link to/can't get around this. It can write only the project (not in plan mode), the temp dir and its own state dirs. Network stays open.run_command./sandbox auto|always|off, defaultauto, which covers plan mode and untrusted repos. It is saved, andNEXUS_SANDBOXoverrides it for one launch.always.Verified
session/request_permissionplusfs/write_text_file, and plan-agent selection. Checked both plain and sandboxed, and in the TUI (tool card, file count,undo #1).test/acp-sandbox.test.jshas 47 checks, using a scripted fake ACP agent plus live Landlock checks.npm testpasses with a temp HOME.Not in this PR
nexus acpserver.