Stop a force-push and ask before risky commands in opencode
See, control, and price every tool call opencode makes: the bash commands, the file edits, the web fetches, and the model calls behind them. One command, no code changes.
Every tool opencode runs (bash, edit, webfetch, MCP tools) is checked against your workspace policy before it executes. Allow runs it. Deny blocks it and shows the reason. Ask blocks it in opencode and holds it for approval on the console Approvals page or from the approval email. Then you ask opencode to retry. The hold reaches opencode as a blocked call, and that applies even to tools your permission block sets to allow.
A second part needs no account at all. Local metering records the tokens and cost of every model call to a database on your machine.
Will it stop the agent from wrecking a box it can reach?
That is usually the question behind the click. With the plugin installed, bash set to ask, and the workspace in enforce mode:
- A command that runs somewhere the hook cannot see, such as
ssh host 'sudo pct destroy 300',docker exec ...,pct exec ..., orqm guest exec ..., is held for your approval. reboot,shutdown, and the rest of the always-blocked list are blocked outright. No approval click reaches them.- Everything else runs and lands in the activity log. One approval can become a standing rule, so you are not reviewing the same shape twice. How approvals work →
In audit mode (the default for a new workspace) the remote-command holds are recorded, not held. The always-blocked list still blocks. The safety floor still holds force-push, destructive SQL, curl | sh and recursive deletes outside the project, in every mode. The rules page has the full list.
This is a guard against accidents and casual re-spellings. It is not a sandbox. A restricted account and sudoers on the target machine are still the floor, and this sits on top of them.
Install
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
irm https://agenticcontrolplane.com/install.ps1 | iex
Three things you get the moment it's running — click any to see it full-size:
rm -rf on home or system folders always blocked; force-push, destructive SQL, and curl | sh held for your OK. Enforced at the call, outside the model.See your first governed call →Free up to 5 agents · full install below
The installer detects opencode (~/.config/opencode or the opencode binary). It registers the acp-opencode plugin and a permission gate in ~/.config/opencode/opencode.json, then opens your browser to set up a workspace. Restart opencode. It installs the plugin from npm on the next start. After that, every tool call is checked against your policy and lands in one activity log, with the cost X-ray next to it. Free up to 5 agents.
On Windows, run irm https://agenticcontrolplane.com/install.ps1 | iex in PowerShell. It detects opencode and writes the same plugin and permission entries to %USERPROFILE%\.config\opencode\opencode.json.
Want it fully on-device? opencode is cloud-only today. The acp-opencode plugin needs a workspace, so the installer’s --local flag skips opencode and says so. What does run without an account is local metering: every model call’s tokens and cost go to ~/.acp/opencode-local.db, and you read them with npx acp-opencode report. That ledger stays on the one machine. It has no workspace policy and no shared activity view.
To wire it by hand, add two blocks to ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["acp-opencode"],
"permission": {
"bash": "ask",
"edit": "ask",
"webfetch": "ask"
}
}
Then set your ACP key (export ACP_BEARER_TOKEN="gsk_yourslug_...", or write it to ~/.acp/credentials). The permission block matters; the next section says why.
How it works
Claude Code, Cursor, and Codex run a hook script that reads the call from stdin. opencode is different. It has a plugin system, where a module’s hooks run inside the opencode process. acp-opencode registers four:
| Hook | What it does |
|---|---|
permission.ask |
The main check. It POSTs to /govern/tool-use. An ACP allow sets the permission to allow, so opencode’s own prompt is skipped. A deny blocks. An ask blocks the call until you approve it on the console Approvals page or from the approval email. Then you ask opencode to retry. |
tool.execute.before |
A deny-only backstop for tools that don’t go through the permission system. An ACP deny throws, which is how opencode blocks a call. It also caches the arguments so permission.ask can attach them. |
tool.execute.after |
Sends the result to /govern/tool-output for audit and scanning (PII, injection, secrets). It is best-effort and never blocks. |
chat.headers |
Stamps X-GS-Session and X-GS-Client on every model request, so proxy-metered spend joins the audit rows for the same session. |
All four send X-GS-Client: opencode-plugin/<version>, so the dashboard can tell opencode traffic from Claude Code and Cursor.
Why the permission block matters. permission.ask only fires for a tool whose permission is "ask". Without the block you still get the deny-only backstop and the audit trail, but an ACP allow can’t pre-approve opencode’s own prompt away. The installer sets bash, edit and webfetch to ask for you. It fills gaps only and never overrides a choice you made yourself.
What gets installed and where
| Path | Contents |
|---|---|
~/.config/opencode/opencode.json |
plugin and permission entries added (existing config kept) |
~/.cache/opencode/.../acp-opencode/ |
The plugin package, installed from npm by opencode at startup |
~/.acp/credentials |
Your bearer token (the same credential every ACP integration uses) |
~/.acp/opencode-local.db |
Local metering database (created on first run, no account needed) |
One install.sh run covers opencode alongside Claude Code, Cursor, and the rest. To uninstall, remove the plugin entry from opencode.json.
Local metering: no account required
The checks above need a workspace key. Metering doesn’t. With no credentials, acp-opencode listens to opencode’s events and records every model call to SQLite at ~/.acp/opencode-local.db. It stores tokens (including cache read and write), the model, and the cost opencode computed. It also stores every tool result. Read it back:
npx acp-opencode report # spend by model, cache hit rate, tool errors, per-task cost
npx acp-opencode report --json # machine-readable, so an agent can read its own economics
npx acp-opencode report --days 30 # widen the window (default 7)
It keeps no price table. Cost comes from opencode’s own pricing data. When opencode reports no cost (an unknown model, or subscription-included auth), the call is stored with the cost blank and the tokens exact. Money is never guessed. Turn metering off with ACP_LOCAL_METERING=off. If storage fails, it disables itself with one warning instead of interrupting your agent.
Add the cost X-ray
Local metering runs on your machine. The cost X-ray puts priced spend, prompt-cache hit rate, and the loop-vs-leaf breakdown on the team dashboard, metered at the gateway. Start opencode with opencode-acp instead of opencode, the same way you use claude-acp and codex-acp:
opencode-acp
The installer already wrote the acp provider into ~/.config/opencode/opencode.json and left your default model alone, so plain opencode is untouched. opencode-acp reads your workspace key from ~/.acp/credentials, exports it as ACP_BEARER_TOKEN, and selects acp/gemini-3.5-flash for that launch only. ACP_OPENCODE_MODEL=<id> picks another. The proxy routes gpt-*, claude-* and gemini-* by model id and forwards to the real provider unchanged. If the ACP gateway is unreachable, it starts plain opencode and says so.
What the installer wrote:
// ~/.config/opencode/opencode.json (provider only, no top-level "model" change)
{
"provider": {
"acp": {
"npm": "@ai-sdk/openai-compatible",
"name": "Agentic Control Plane",
"options": {
"baseURL": "https://api.agenticcontrolplane.com/v1",
"apiKey": "{env:ACP_BEARER_TOKEN}"
},
"models": { "gemini-3.5-flash": {} }
}
}
}
The plugin’s X-GS-Session header ties that spend to the tool-audit rows for the same session. Full walkthrough: Turn on Cost X-Ray.
If the gateway is unreachable
On a network error, a timeout (over 2 seconds), a non-2xx response, or a malformed body, the plugin lets the call through and prints one loud warning per session. If every call is being blocked, that is a deny policy, not an outage. Check the dashboard.
To block whenever the gateway is unreachable, turn on fail-closed. It is the same setting the shared hook uses for the other non-Claude-Code harnesses, so one setting covers them and opencode on that machine:
export ACP_FAIL_MODE=closed # or: echo closed > ~/.acp/failmode
A policy deny always blocks, whatever the fail mode. A machine with no credentials is always a no-op, so fail-closed never blocks before you’ve connected. To turn the whole plugin off without touching your config:
export ACP_OPENCODE=off
Setting up policy
Three kinds of policy apply to opencode, as on every harness:
- Tool policies (Policies → Tool Policies): a workspace-wide tool allowlist and required scopes.
- Agent policies (Policies → Agent Policies): rules per tier.
- User policies (Policies → User Policies): overrides per person.
The most restrictive rule wins. Start in audit mode for a few days to see what your agents do, then switch to enforce mode.
Policy keys for opencode’s tools. opencode spells its tools in lowercase, and workspace rules use canonical names. The gateway maps the native spelling first, so a rule you already have on Bash.rm or Edit applies to opencode calls with no opencode-specific copy. A rule written against the native spelling keeps working too.
| opencode tool | Policy key |
|---|---|
bash |
Bash, split by leading command: Bash.git, Bash.rm, Bash.curl, … |
edit, patch |
Edit |
write |
Write |
read |
Read |
grep |
Grep |
webfetch |
WebFetch |
websearch |
WebSearch |
task |
Agent |
Your permission block decides which calls reach permission.ask and which only meet the backstop. The opencode permissions reference has every key, the defaults, and the config layers.
Limitations
What the opencode integration cannot do today:
- Context composition isn’t broken out. Per-call token buckets, cache splits and cost are all recorded. The split of each prompt into system, user, assistant and tool parts is not, because opencode 1.18.4 exposes the outgoing messages only through an unstable experimental hook. The report’s composition section will fill in once a stable hook exists.
- Per-request model duration isn’t exposed per step. Message-level fallback rows carry wall-clock time and step rows record 0. Proxy-side metering covers durations for routed traffic.
- Tier attribution is coarse. opencode’s hooks don’t tell the plugin whether the
buildorplanagent is running, so calls report at theinteractivetier. - Output scanning only flags. The plugin blocks a call or allows it. On the output path it flags findings and does not redact.
Troubleshooting
Plugin isn’t firing. Restart opencode completely, because plugins load at startup. Confirm "plugin": ["acp-opencode"] is in ~/.config/opencode/opencode.json and that opencode installed it (look under ~/.cache/opencode).
Prompts still appear for every tool. That is the ask path with no ACP decision yet: no credentials, or a policy that says ask. Set ~/.acp/credentials and check your Tool Policies.
acp-opencode report shows no price. opencode reported no cost for that model (unknown model, or subscription-included auth). Token counts are still exact. Route through the proxy for priced spend.
Nothing in the dashboard. The Activity page is per workspace. Check that the workspace tied to your token is the one selected in the top-right dropdown. Local metering is separate and works with or without an account.
Related integrations
- Hermes Agent: native Python plugin, the same two-part design
- Claude Code: hook-based, the most complete integration
- OpenClaw: native plugin, like opencode
- OpenAI Codex CLI: Claude-style hooks, currently Bash-only
- Turn on Cost X-Ray: meter spend across any harness through the proxy
- opencode permissions reference: every key in the
permissionblock, defaults, auto-approve, worked examples - opencode permissions, explained: the native control model and where it ends
Protected in 3 steps
Out of the box, ACP records every tool call your agents make. A short safety floor applies in every mode: catastrophic commands (rm -rf on your home or system folders, disk wipes) are always blocked, and force-push, destructive SQL, piping a download into a shell, and deleting outside your project are held for your approval. Your own rules (ask first / never) start applying when you turn on enforce. No rule can loosen the floor; a workspace owner or admin can switch it off on the Policies page (you were asked at install). With --local the always-blocked list is narrower: rm -rf on your home or root, disk wipes, fork bombs.
-
1
Install. One command, then approve this machine in the browser.
curl -fsSL https://agenticcontrolplane.com/install.sh | bash -
2
Turn on your rules. Run
/acp-enforcein your agent. The starter rules start applying:rmand keychain reads are held for your approval (you approve on the console Approvals page or from the approval email); everything else keeps running and is recorded. Add your own with/acp-ask Bash.curl,/acp-deny Bash.git.push,/acp-allow Bash.npm, or on the Policies page. With--localthere is no mode switch: the rules in~/.acp/policy.jsonapply from the first call, and the starter file asks beforerm,curl,git push,chmodandchown. -
3
See it work. Ask your agent to do something risky, for example
git push --forceon a scratch repo. ACP holds the call for your approval; the call and your answer land in the audit log (/acp-whyfor the last hold, the console Activity page, or~/.acp/audit.jsonlwith--local). In OpenCode, a held call shows as a block in the agent; approve it on the console Approvals page or from the approval email, then ask the agent to retry.
Copy-paste rules for the things people are most afraid of (force-push, prod database, rm -rf, a secret in a curl, overnight runs, a cost cap): Rules that stop the scary things.

