GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Plugin SDK: permission.ask hook is never called · Issue #9229 · anomalyco/opencode

Plugin SDK: permission.ask hook is never called #9229

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Plugin SDK: permission.ask hook is never called#9229
Copy link
Assignees
thdxr

Description

@schickling
schickling
opened on Jan 18, 2026
Issue body actions

Summary

The permission.ask hook defined in the @opencode-ai/plugin SDK is never triggered because OpenCode's permission system uses PermissionNext.ask() which emits Bus events instead of calling Plugin.trigger("permission.ask", ...).

Expected Behavior

When a permission check requires user approval, plugins should receive the permission.ask hook callback as documented in the SDK.

Actual Behavior

The permission.ask hook is never called. Instead, permission.asked events are emitted via the Bus system and can only be captured through the generic event hook.

Root Cause Analysis

OpenCode has two permission modules:

  1. permission/index.ts (legacy/unused) - Contains Permission.ask() that calls Plugin.trigger("permission.ask", ...) at line 134
  2. permission/next.ts (actively used) - Contains PermissionNext.ask() that publishes Bus.publish(Event.Asked, info) at line 140

All actual permission checks use PermissionNext.ask(), which:

  • Emits permission.asked via the Bus system (triggers generic event hook)
  • Does NOT call Plugin.trigger("permission.ask", ...)

Code Evidence

// packages/opencode/src/permission/next.ts:128-141 (ACTIVELY USED)
if (rule.action === "ask") {
  const id = input.id ?? Identifier.ascending("permission")
  return new Promise<void>((resolve, reject) => {
    const info: Request = {
      id,
      ...request,
    }
    s.pending[id] = {
      info,
      resolve,
      reject,
    }
    Bus.publish(Event.Asked, info)  // <-- Emits "permission.asked", NOT "permission.ask" hook
  })
}

Suggested Fix

Either:

  1. Add Plugin.trigger("permission.ask", info) call in PermissionNext.ask() before/after the Bus publish
  2. Or document that plugins should use the event hook with type: "permission.asked" instead

Workaround

Plugins can listen to permission events via the generic event hook:

export default {
  name: "my-plugin",
  hooks: {
    event: async (event) => {
      if (event.type === "permission.asked") {
        // Handle permission request
        console.log("Permission requested:", event.properties)
      }
    }
  }
}

Environment

  • OpenCode version: latest (dev branch)
  • Discovered while building an external agent manager that tracks session state
Reacted by Jacob Daitzman
Reacted by Jacob Daitzman

Activity

  1. github-actions
    assigned
    thdxr
    on Jan 18, 2026
  2. github-actions commented on Jan 18, 2026

    @github-actions
    github-actionsBot
    on Jan 18, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • permission.ask plugin hook is defined but not triggered #7006: permission.ask plugin hook is defined but not triggered

    This appears to be the same issue with identical root cause analysis and suggested fixes. Feel free to ignore if your specific case differs.

  3. schickling
    closed this as a duplicateof permission.ask plugin hook is defined but not triggered #7006 on Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.