feat: plugin: add plugin interfaces for Programmatic Tool Calling (PTC) #8022
+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?
Programmatic Tool Calling (PTC)[1] lets code invoke tools directly in the execution environment, cutting model round-trips, latency, and tokens. Without an execution API, models could not programmatically invoke tools and had to fall back to provider-native tool calling, which blocks PTC on other models.
Introduce a tool execution API to run a tool by id with session/message context, provider/agent filtering, and permission gating, returning title/output/metadata.
Regenerate the JS SDK (v1/v2) to expose the new execute API and types so plugins can implement PTC regardless of the underlying model provider.
[1] https://platform.claude.com/cookbook/tool-use-programmatic-tool-calling-ptc
Closes #4713
How did you verify your code works?
I've writing a POC plugin to wrap the tools into async javascript functions, and the model is able to create 10k TODOs 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.