You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #7006 (permission.ask plugin hook defined but never triggered) — traced that report to the actual source rather than taking it on faith: packages/core/src/permission.ts's assert/ask/reply functions (the real enforcement path, called from bash.ts, edit.ts, write.ts, read.ts, and 7 more tools) have zero references to the plugin system. The hook type in packages/plugin/src/index.ts is real; nothing calls it.
This issue isn't about that bug specifically — it's a proposal for a documented pattern that works today, without waiting on a fix, plus a request to confirm it's the intended way to do this.
The working pattern
Every permission request that needs a decision publishes permission.v2.asked (packages/schema/src/permission.ts), and every plugin gets a full SDK client in PluginInput that can call the same reply endpoint the TUI uses:
POST /api/session/{sessionID}/permission/{requestID}/reply
{ "reply": "once" | "always" | "reject" }
So a plugin can implement automated permission decisions today via the generic event hook (confirmed working) + this reply call, without permission.ask ever needing to fire. A no-op (no reply) leaves the request pending for a human exactly as intended.
Every API shape (Plugin type, PluginInput.client, event hook, permission.v2.asked schema, reply endpoint body) checked against the actual generated SDK/schema code in this repo, not guessed.
Built the monorepo, ran a real headless opencode serve, confirmed via server logs that a test project's opencode.json (declaring the plugin) loaded correctly.
Stopped short of a full live agent-turn round-trip in my environment for reasons unrelated to opencode itself (documented honestly in the gist) — the event-subscription + reply-call wiring itself is verified against your real source, not assumed.
Ask
Is event + reply-call the intended workaround until permission.ask is wired up, or is there a more direct path I'm missing?
Summary
Related to #7006 (
permission.askplugin hook defined but never triggered) — traced that report to the actual source rather than taking it on faith:packages/core/src/permission.ts'sassert/ask/replyfunctions (the real enforcement path, called frombash.ts,edit.ts,write.ts,read.ts, and 7 more tools) have zero references to the plugin system. The hook type inpackages/plugin/src/index.tsis real; nothing calls it.This issue isn't about that bug specifically — it's a proposal for a documented pattern that works today, without waiting on a fix, plus a request to confirm it's the intended way to do this.
The working pattern
Every permission request that needs a decision publishes
permission.v2.asked(packages/schema/src/permission.ts), and every plugin gets a full SDKclientinPluginInputthat can call the same reply endpoint the TUI uses:So a plugin can implement automated permission decisions today via the generic
eventhook (confirmed working) + this reply call, withoutpermission.askever needing to fire. A no-op (no reply) leaves the request pending for a human exactly as intended.What I built and verified
A reference plugin gating tool-call permissions through a three-way admission decision (
allow/ask/reject), backed by a locally-served model — gist with the plugin, the full source trace, and what was/wasn't verified:Plugintype,PluginInput.client,eventhook,permission.v2.askedschema, reply endpoint body) checked against the actual generated SDK/schema code in this repo, not guessed.opencode serve, confirmed via server logs that a test project'sopencode.json(declaring the plugin) loaded correctly.Ask
event+ reply-call the intended workaround untilpermission.askis wired up, or is there a more direct path I'm missing?permission.askplugin hook is defined but not triggered #7006 getting fixed?Happy to open that PR if useful.