Fix sandbox launch with OpenCode v2 background service

OpenCode v2.2 starts a background service on 127.0.0.1:49374, which nono
blocks unless a localhost port is granted. Give the sandbox its own service
on 49376 with isolated config/state, and clean up its lifecycle.

- Grant localhost ports 49376 (sandboxed service) and 3301 (Tinfoil proxy)
- Add sandbox config/state dirs and XDG_STATE_HOME/OPENCODE_CONFIG_DIR
- Wrapper mirrors real config, pins the sandbox service port, and stops
  stale/orphaned services so they never outlive the nono proxy
- Remove deprecated commands.allow/deny and the redundant SSH key glob deny
- Update installer, uninstall cleanup, and README
This commit is contained in:
2026-11-09 15:33:48 +00:00
parent 95405fcd14
commit 391c3265f4
5 changed files with 368 additions and 97 deletions
+19 -41
View File
@@ -6,39 +6,6 @@
"groups": {
"include": ["deny_credentials"]
},
"commands": {
"allow": [
"git",
"node",
"npm",
"npx",
"bun",
"python3",
"python",
"pip",
"pip3",
"cargo",
"rustc",
"go",
"tinfoil"
],
"deny": [
"sudo",
"su",
"doas",
"pkexec",
"passwd",
"chsh",
"usermod",
"useradd",
"deluser",
"rm -rf /",
"mkfs",
"dd",
"fdisk",
"parted"
]
},
"workdir": {
"access": "readwrite"
},
@@ -48,7 +15,10 @@
],
"read": [
"$HOME/.config/opencode",
"$HOME/.config/opencode-sandbox",
"$HOME/.local/share/opencode",
"$HOME/.local/state/opencode-sandbox",
"$HOME/.cache/opencode",
"$HOME/.opencode",
"$HOME/.claude",
"$HOME/.gitconfig",
@@ -62,13 +32,15 @@
],
"write": [
"$HOME/.config/opencode",
"$HOME/.config/opencode-sandbox",
"$HOME/.local/share/opencode",
"$HOME/.local/state/opencode-sandbox",
"$HOME/.cache/opencode",
"$HOME/.opencode",
"$HOME/.claude",
"/tmp"
],
"deny": [
"$HOME/.ssh/id_*",
"$HOME/.gnupg",
"$HOME/.aws",
"$HOME/.azure",
@@ -84,6 +56,10 @@
},
"network": {
"block": false,
"open_port": [
49376, // OpenCode background service, kept separate from the host service on 49374
3301 // Tinfoil local proxy http://127.0.0.1:3301/v1
],
"allow_domain": [
"api.openai.com",
"api.anthropic.com",
@@ -142,15 +118,17 @@
},
"environment": {
"set_vars": {
"OPENCODE_CONFIG_DIR": "$HOME/.config/opencode",
"XDG_STATE_HOME": "$HOME/.local/state/opencode-sandbox",
"OPENCODE_CONFIG_DIR": "$HOME/.config/opencode-sandbox/opencode",
"TINFOIL_CONFIG_DIR": "$HOME/.tinfoil"
},
"deny_vars": [
"AWS_SECRET_ACCESS_KEY",
"AWS_ACCESS_KEY_ID",
"AZURE_CLIENT_SECRET",
"GCP_PRIVATE_KEY",
"KUBECONFIG"
"AWS_*",
"GOOGLE_*",
"AZURE_*",
"GCP_*",
"KUBECONFIG",
"SSH_AUTH_SOCK"
]
}
}
}