opencode icon indicating copy to clipboard operation
opencode copied to clipboard

plugin hook types not aligned with runtime triggers and missing v2 sdk

Open aryasaatvik opened this issue 4 days ago • 1 comments

Summary

The current @opencode-ai/plugin package imports types from @opencode-ai/sdk (v1), which uses nested path/body/query parameters. The v2 SDK introduced flattened parameters and new permission types (PermissionRequest with reply: once/always/reject), but there is no way for plugins to access these v2 types.

Use Case

When building plugins that need to:

  1. Use the v2 SDK flattened API (sessionID instead of path.id, no body wrapper)
  2. Access the new PermissionRequest type for permission hooks
  3. Import FilePart from the v2 SDK for tool attachments

Currently plugins must import from @opencode-ai/sdk directly and manually align types, which is error-prone and defeats the purpose of the plugin package.

Proposed Solution

Add v2 subpath exports to @opencode-ai/plugin:

  • @opencode-ai/plugin/v2 - Plugin types importing from @opencode-ai/sdk/v2
  • @opencode-ai/plugin/v2/tool - Tool definition with v2 FilePart

This allows plugins to migrate incrementally while maintaining backward compatibility with v1.

Related

PR: #7639

aryasaatvik avatar Jan 10 '26 13:01 aryasaatvik