forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add remote permission approval via plugin hook#1
Open
replee-codes[bot] wants to merge 1 commit intodev from
Open
feat: add remote permission approval via plugin hook #1replee-codes[bot] wants to merge 1 commit intodev from
replee-codes[bot] wants to merge 1 commit intodev from
Conversation
- Add new hook to the plugin system that allows plugins to handle permissions asynchronously (e.g., via webhook) - Update both Permission (legacy) and PermissionNext systems to call the new hook before falling through to built-in UI - Add example plugin demonstrating webhook-based permission approval with configurable timeout and fallback behavior The new hook enables: - Sending permission requests to external webhooks - Waiting for async approval from external systems (Slack, Discord, etc.) - Configurable timeout with fallback to deny/allow/ask - Integration with custom approval workflows Closes REPL-23012
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.
Summary
Adds a new
permission.remoteplugin hook that enables OpenCode to ask for permission via an external system (like a webhook), similar to how Claude Code requests permission through its plugin system.Changes
New Plugin Hook:
permission.remoteAdded to
packages/plugin/src/index.ts:The hook is called when a permission request would normally be shown to the user. Plugins can:
{ handled: true, decision: "allow" }to immediately allow{ handled: true, decision: "deny", message?: "reason" }to deny{ handled: false }to fall through to built-in UIPermission System Updates
Both permission systems now call the hook:
packages/opencode/src/permission/index.ts(legacy)packages/opencode/src/permission/next.ts(current)Example Plugin
Added
packages/plugin/src/example-remote-permission.tsdemonstrating:Configuration (Example Plugin)
Environment variables:
OPENCODE_PERMISSION_WEBHOOK_URL- URL to POST permission requests toOPENCODE_PERMISSION_WEBHOOK_SECRET- Bearer token for webhook authOPENCODE_PERMISSION_TIMEOUT_MS- Timeout in ms (default: 60000)OPENCODE_PERMISSION_TIMEOUT_ACTION- Fallback: "deny" | "allow" | "ask" (default: "deny")Use Cases
Testing
handled: falseCloses REPL-23012