[PR #8328] feat(plugin): align plugin tool types with built-in tool capabilities #12708

Closed
opened 2026-02-16 18:17:36 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8328

State: closed
Merged: No


What does this PR do?

Fixes: #8327

Related: #8269, #8380

Note

This is complementary to the v2 SDK upgrade in #8380. This PR improves type safety of the ToolContext used for developing custom tools in plugins. The other PR is focused on upgrading the client capabilities for plugins. Similar, but slightly different goals.

This PR aligns plugin tool types with the capabilities tools already have. Specifically:

  • Exposes ToolContext fields to plugin tools: callID, extra, metadata(), and ask() to give plugins the correct context types
  • Adds ExecuteResult type allowing plugin tools to return structured result objects with title, metadata, output, and attachments instead of only plain strings
  • Updates the registry to handle structured results from plugin tools, bypassing truncation when plugins return an ExecuteResult directly (assuming tools till truncate...we could add a check here?)
  • Exports all useful intermediate-types so plugin authors can use them more ergonomically.

This enables plugins to provide richer tool responses with proper metadata updates, closer matching the flexibility of built-in tools.

How did you verify your code works?

  • Ran the test suite
  • Ran TypeScript type checking
  • Verified locally with a plugin in development that required proper metadata updates from plugin tools

The types all align nicely in the registry:

Zight Recording 2026-01-13 at 09 43 34 PM

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8328 **State:** closed **Merged:** No --- ### What does this PR do? Fixes: #8327 Related: #8269, #8380 > [!NOTE] > This is complementary to the v2 SDK upgrade in #8380. This PR improves type safety of the `ToolContext` used for developing custom tools in plugins. The other PR is focused on upgrading the client capabilities for plugins. Similar, but slightly different goals. This PR aligns plugin tool types with the capabilities tools already have. Specifically: - Exposes `ToolContext` fields to plugin tools: `callID`, `extra`, ~`metadata()`~, and ~`ask()`~ to give plugins the correct context types - update: `metadata()` and `ask()` were added in #8269 - Adds `ExecuteResult` type allowing plugin tools to return structured result objects with `title`, `metadata`, `output`, and `attachments` instead of only plain strings - Updates the registry to handle structured results from plugin tools, bypassing truncation when plugins return an `ExecuteResult` directly (assuming tools till truncate...we could add a check here?) - Exports all useful intermediate-types so plugin authors can use them more ergonomically. This enables plugins to provide richer tool responses with proper metadata updates, closer matching the flexibility of built-in tools. ### How did you verify your code works? - Ran the test suite - Ran TypeScript type checking - Verified locally with a plugin in development that required proper metadata updates from plugin tools The types all align nicely in the registry: ![Zight Recording 2026-01-13 at 09 43 34 PM](https://github.com/user-attachments/assets/5dc1dc2a-9e8a-4b18-ad00-93d60555ee6b)
yindo added the pull-request label 2026-02-16 18:17:36 -05:00
yindo closed this issue 2026-02-16 18:17:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12708