opencode
opencode copied to clipboard
fix: auto-deny permissions and emit events in non-interactive mode
Fixes issues where permissions requests block indefinitely in CI/GitHub Actions, with no output indicating why. I keep running into this in CI runs, especially when the harness is trying to solve a problem or I'm testing/building plugins.
Since there's no way to prompt a user, it should just auto-deny by default + emit this to the logs so users can understand what happened.
Changes
- Add
isInteractive()utility - checksCIenv var,OPENCODE_CLIENT, and TTY state - Auto-deny permission requests when
!isInteractive()(no one to approve) - Emit
permission.askedevents before denying so they're visible in logs - Subscribe to permission events in
github.tsandrun.tswith actionable guidance on how to allow - Add
OPENCODE_EMIT_SUBAGENT_EVENTSflag for verbose subagent output in CI - Add
emit_subagent_eventsinput to GitHub Action - Deny
questionpermission by default in GitHub Action sessions (merged from dev)
isInteractive() Logic
Only auto-denies for the CLI client in non-TTY/CI environments:
-
OPENCODE_FORCE_INTERACTIVE=true→ interactive (for tests) -
CI=true→ non-interactive (auto-deny) -
OPENCODE_CLIENTis notcli(e.g.desktop) → interactive (GUI handles permissions) - Otherwise, check
stdin.isTTY && stdout.isTTY
current possible OPENCODE_CLIENT values: cli (default), desktop
Example Output
When a permission is denied in CI:
| Denied external_directory: /tmp/opencode-source
To allow, add to opencode.json: { "permission": { "external_directory": "allow" } }
Merge Conflict Resolution
Resolved conflict with dev branch - combined:
- Permission config from dev (deny
questionprompts in GitHub Action context) - Event unsubscribe cleanup from this PR branch