feat(plugin): add programmatic tool invocation support (PTC) #8180
+277
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Introduce Programmatic Tool Calling (PTC) support for plugins, enabling plugins to invoke tools directly within a session without relying on LLM vendor-specific APIs.
This change exposes a unified tool invocation API that:
To support this, the JS SDK (v1/v2) is regenerated to expose the new
executeAPI and related types, allowing plugin authors to implement PTC in a provider-agnostic way.Without this change, plugins in opencode can only achieve PTC via vendor-dependent LLM APIs and cannot invoke tools directly.
[1] https://platform.claude.com/cookbook/tool-use-programmatic-tool-calling-ptc
Closes #4713
How did you verify your code works?
I've written a POC plugin to wrap the tools into async javascript functions, and the model is able to create 10k TODOs or 10 subtasks concurrently with the new interface.
Because it currently depends on a local SDK version, it has not been released yet. I will complete it as soon as possible and open-source it under the MIT license.