Parent: #1802 — Pluggable Tool Registry
Sub-issue 3 of the Pluggable Tool Registry tracking issue.
Goal
Define a RuntimeTool trait that makes code-execution backends (Python, Node.js, dotnet, go, rustc) pluggable through a shared interface compatible with the ToolSpec trait and the ExternalTool abstraction (PR #1821).
Today code_execution hardcodes Python, js_execution hardcodes Node. Adding dotnet (already implemented as DotNet ExternalTool in PR #1821) requires touching the tool catalog, the dispatcher, and the execution path.
After RuntimeTool:
- Each runtime implements one trait.
- The catalog auto-discovers available runtimes.
- Adding
go or rustc is ~15 lines of impl RuntimeTool.
- The model sees
code_execution with a runtime parameter (or separate tool names per runtime — TBD).
Design sketch
/// A code-execution backend discoverable via ExternalTool + ToolSpec.
#[async_trait]
pub trait RuntimeTool: ExternalTool + Send + Sync {
/// Human-readable runtime name (e.g. "Python", "Node.js", "dotnet").
fn runtime_name() -> &'static str;
/// File extension for this runtime (e.g. "py", "js", "cs").
fn file_extension() -> &'static str;
/// Default code template — wraps user code for this runtime.
fn wrap_code(code: &str) -> String;
/// Execute code with this runtime. Returns stdout/stderr/exit code.
async fn execute(code: &str, timeout: Duration, cwd: &Path) -> RuntimeResult;
}
Callers (tool catalog, dispatcher) interact through the trait, not through individual Command::new("python3") / Command::new("node") calls.
Backends to implement
| Runtime |
Status |
Notes |
| Python |
Already exists (Python ExternalTool + code_execution.rs) |
Refactor to impl RuntimeTool |
| Node.js |
Already exists (Node ExternalTool + js_execution.rs) |
Refactor to impl RuntimeTool |
| dotnet |
DotNet ExternalTool in PR #1821, dotnet_execution.rs tool |
Refactor to impl RuntimeTool |
| Go |
Done |
New: go run via RuntimeTool |
| Rust (rustc) |
Done |
New: rustc with temp project |
| TypeScript |
Done |
New: tsx/ts-node/deno via RuntimeTool |
Dependencies
Delivery
PR #1845 delivers:
- RuntimeTool trait in crates/tui/src/tools/runtime_tool.rs
- go_execution — Go sandbox via go run file.go
- ts_execution — TypeScript sandbox (tsx/tsx.cmd/ts-node/deno)
- rust_execution — Rust sandbox via rustc compile-then-run
- Windows .cmd probe fix for npm global installs
- All existing tools continue working
Closes #1822
Parent: #1802 — Pluggable Tool Registry
Sub-issue 3 of the Pluggable Tool Registry tracking issue.
Goal
Define a
RuntimeTooltrait that makes code-execution backends (Python, Node.js, dotnet, go, rustc) pluggable through a shared interface compatible with theToolSpectrait and theExternalToolabstraction (PR #1821).Today
code_executionhardcodes Python,js_executionhardcodes Node. Adding dotnet (already implemented asDotNetExternalTool in PR #1821) requires touching the tool catalog, the dispatcher, and the execution path.After
RuntimeTool:goorrustcis ~15 lines ofimpl RuntimeTool.code_executionwith aruntimeparameter (or separate tool names per runtime — TBD).Design sketch
Callers (tool catalog, dispatcher) interact through the trait, not through individual
Command::new("python3")/Command::new("node")calls.Backends to implement
Dependencies
Delivery
PR #1845 delivers:
Closes #1822