feat(python): ScriptedTool bindings + LangChain integration#219
Merged
Conversation
- Add ScriptedTool Python class wrapping Rust ScriptedTool via PyO3 - add_tool() registers Python callbacks as bash builtins - Callbacks receive (params: dict, stdin: str | None) -> str - JSON<->Python conversion for typed flag parsing (int, bool, str) - execute/execute_sync run bash scripts with all registered tools - Introspection: system_prompt(), help(), description(), schemas - Add ScriptedToolLangChain wrapper and create_scripted_tool() factory - Add k8s_orchestrator.py example: 12 fake kubectl commands, 6 demos - get_nodes, get_namespaces, get_pods, get_deployments, get_services - describe_pod, get_logs, get_configmaps, get_secrets, get_events - scale_deployment, rollout_status - Optional LangChain ReAct agent integration (--langchain flag) - Add 26 Python tests covering construction, execution, pipelines, jq integration, error handling, stdin, env vars, loops, conditionals, async, introspection, and 12-tool orchestration - Enable scripted_tool feature in bashkit-python Cargo.toml - Update type stubs and __init__.py exports https://claude.ai/code/session_0117wzNc2aRc5chtBgfwgdCd
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
(params: dict, stdin: str | None)with typed flag parsing (integers, booleans, strings coerced per JSON schema).ScriptedToolLangChainwrapper +create_scripted_tool()factory for use with LangChain ReAct agents.--langchainflag for ReAct agent demo.Test plan
cargo fmt --checkpassescargo clippy --all-targets --all-features -- -D warningspassescargo test --all-featurespasses (68 passed)ruff check+ruff format --checkpassespytest tests/ -vpasses (47 tests: 21 existing + 26 new)python examples/k8s_orchestrator.pyruns and prints correct output for all 6 demos