Repository navigation
Conversation
The agent runs shell commands without approvals, and OpenCode's rules limit only its file tools. In a test run, the agent searched the whole disk with find, read files in another repo, and read the ldcli access token with `ldcli config get`. On macOS, ldcli now starts OpenCode with sandbox-exec and a Seatbelt profile for each run. The sandbox applies to OpenCode and to every command that it runs. It denies the home folder, except the project, OpenCode's own folders, package caches, and toolchains. Other repos, ~/.config/ldcli, and ~/.ssh stay unreadable. System folders and the network stay open. The profile uses resolved paths, because Seatbelt matches the real path behind a symlink. OpenCode's rules also deny `ldcli` and `npx skills` now. Linux and Windows run without a sandbox for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atornsii
added this pull request to stack #902
October 20, 2026 15:48
… atorns/agent-3-macos-sandbox
The sandbox now opens Library/Application Support/go/env for reading, and the file that GOENV names. Go commands in the sandbox then use the user's GOPROXY and GOPRIVATE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On first use, a folder such as ~/.local/share/opencode or ~/.cache/uv can be missing, and the sandbox denied the creation of its parents. The profile now allows only the creation of those parent folders. Nothing else can be written in them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
installDir compared the unresolved home folder with the resolved OpenCode path. With a symlink in HOME, such as /var to /private/var, the check missed the shared ~/.local folder and opened it. The sandbox now resolves the home folder first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 21, 2026
This was referenced Oct 21, 2026
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.
This runs the setup agent in a macOS sandbox. The agent runs shell commands without approvals, and OpenCode's rules limit only its file tools. In a test run without the sandbox, the agent searched the whole disk with
find /, read files in another repo, and read the ldcli access token withldcli config get.What changed
sandbox-execand a Seatbelt profile that it writes for each run. The sandbox applies to OpenCode and to every command that it runs.~/.gitconfigfor reading. IfXDG_CONFIG_HOMEis set, only itsopencodefolder opens. System folders and the network stay open./var/folders.ldcliandnpx skills.~/Library/Application Support/go/env, or the file thatGOENVnames) opens for reading, so Go commands use the user'sGOPROXYandGOPRIVATE.HOMEcannot make it open all of~/.local.Linux and Windows run without a sandbox for now.
Two review points were checked and need no change. The firmlink path
/System/Volumes/Data/Users/<name>is denied too, because Seatbelt checks the resolved path. Andsandbox-execreads its profile before it applies the sandbox, so a profile in a denied folder still loads.Testing
A macOS test runs real sandboxed commands with a fake home folder: they read and write in the project, and they get "Operation not permitted" for a fake ldcli config, an SSH key, and another repo's file. Other real sandbox tests check the creation of missing cache folders and a home path with a symlink. Unit tests cover the profile order, quoting, the Go settings file, and the install folder rule. The real OpenCode starts in the sandbox.
Diagram
Blue boxes are new files, orange boxes are changed files, dashed boxes are files from an earlier PR, and purple boxes are outside ldcli. A solid arrow goes from the caller to the code that it calls. A dashed arrow shows data that moves without a direct call.
server.gonow askssandbox.gohow to start OpenCode.sandboxCommandbuilds the lists of open folders, resolves symlinks, writes the Seatbelt profile to a temporary.sbfile, and returns asandbox-execcommand.server.goruns that command, so OpenCode and every command that it runs get the same file rules. When the run stops,server.goremoves the profile. On Linux and Windows,sandboxCommandreturns the plain OpenCode command.opencode_config.goalso deniesldcliandnpx skills.This PR changes only how
server.gofrom #894 starts the process. The adapter interface and the wizard from #895 do not change.Stack
This is one of seven PRs for the
ldcli setupagent. Review and merge them in order, after #877 (Go 1.26):The gonfalon side is launchdarkly/gonfalon#75196 to #75199 (the SDK relay) and launchdarkly/gonfalon#75426 (the model relay). This stack replaces #876 and #878, which are closed.
🤖 Generated with Claude Code
Note
Overview
On macOS, the setup agent now launches OpenCode through
sandbox-execwith a per-run Seatbelt profile so every shell command inherits filesystem limits, not just OpenCode’s file tools.sandbox.gobuilds a deny-home profile with targeted read/write exceptions (project dir, package caches, OpenCode state, toolchain paths), resolves symlinks for Seatbelt, writes a temp*.sbfile, and returns a cleanup hook.server.gouses that wrapper when startingopencode serveand removes the profile on start failure or process exit. Linux/Windows still run the binary directly when sandboxing isn’t available.OpenCode bash rules also deny
ldcli*andnpx skills*so the agent can’t invoke the CLI or skills installer from the shell. Tests cover profile ordering, path allowlists, and real sandboxed reads/writes on macOS.Reviewed by Cursor Bugbot for commit f08f4d1. Bugbot is set up for automated code reviews on this repo. Configure here.