opencode
opencode copied to clipboard
plugin hook types not aligned with runtime triggers and missing v2 sdk
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:
- Use the v2 SDK flattened API (sessionID instead of path.id, no body wrapper)
- Access the new PermissionRequest type for permission hooks
- 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