feat(scripted_tool): add ToolImpl combining ToolDef + sync/async exec#1284
Merged
feat(scripted_tool): add ToolImpl combining ToolDef + sync/async exec#1284
Conversation
Introduce ToolImpl as the unified type that pairs a ToolDef (metadata) with optional sync and async execution callbacks. ToolImpl implements Builtin, so it can be registered in both Bash and ScriptedTool contexts. - New tool_def module with ToolDef, ToolArgs, ToolImpl, SyncToolExec, AsyncToolExec, and parse_flags (extracted from scripted_tool) - ToolImpl implements Builtin with automatic flag parsing via schema - ScriptedToolBuilder::tool(ToolImpl) accepts the new unified type - Existing .tool(def, cb) renamed to .tool_fn(def, cb) for clarity - Backward-compatible type aliases: ToolCallback = SyncToolExec, AsyncToolCallback = AsyncToolExec
Consistent terminology: use "exec" instead of "callback" throughout the public API surface — doc comments, parameter names, type docs.
Verify ToolImpl works end-to-end in ScriptedToolBuilder and ScriptingToolSetBuilder — sync exec, async exec, mixed with tool_fn, exclusive mode, and discovery mode.
Add ToolImpl section and update module location to reflect tool_def.rs extraction.
8015895 to
863d83b
Compare
tool_def.rs is pub(crate), so rustdoc can't resolve cross-module links to ScriptedToolBuilder and ScriptedTool. Use plain text instead of doc links.
8a1c622 to
64810a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ToolImplas the unified type pairingToolDef(metadata) with optional sync (SyncToolExec) and async (AsyncToolExec) exec functionsToolImplimplementsBuiltin, so it can be registered directly in bothBashandScriptedTool/ScriptingToolSettool_def.rsmodule extractsToolDef,ToolArgs,ToolImpl, exec types, andparse_flagsout ofscripted_tool/to break circular dependenciesScriptedToolBuilder::tool(ToolImpl)andScriptingToolSetBuilder::tool(ToolImpl)accept the new unified type(ToolDef, callback)API renamed to.tool_fn()/.async_tool_fn()for clarityToolCallback = SyncToolExec,AsyncToolCallback = AsyncToolExecWhy
A tool is a specialization of a builtin — it trades full
Contextaccess for automatic schema-based flag parsing and a simpler exec signature. Before this change,ToolDefand callbacks were separate concepts stitched together by an internal adapter. NowToolImplis the public, reusable unit that works uniformly acrossBash,ScriptedTool, andScriptingToolSet.Test plan
tool_def::tests— parse_flags, ToolImpl construction, Builtin impl, async exec, no-exec errorscripted_tool::tests— ToolImpl sync, async, mixed with tool_fn in ScriptedTooltoolset::tests— ToolImpl registration in ScriptingToolSetBuilder (exclusive + discovery modes)cargo fmt,cargo clippy -- -D warningscleanscripted_toolruns end-to-end