Export tools module into code mode runner (#14167)

**Summary**
- allow `code_mode` to pass enabled tools metadata to the runner and
expose them via `tools.js`
- import tools inside JavaScript rather than relying only on globals or
proxies for nested tool calls
- update specs, docs, and tests to exercise the new bridge and explain
the tooling changes

**Testing**
- Not run (not requested)
This commit is contained in:
pakrym-oai
2026-03-09 22:59:09 -06:00
committed by GitHub
parent 772259b01f
commit 710682598d
5 changed files with 131 additions and 55 deletions

View File

@@ -73,6 +73,8 @@ async fn code_mode_can_return_exec_command_output() -> Result<()> {
&server,
"use code_mode to run exec_command",
r#"
import { exec_command } from "tools.js";
add_content(await exec_command({ cmd: "printf code_mode_exec_marker" }));
"#,
false,
@@ -112,7 +114,9 @@ async fn code_mode_can_apply_patch_via_nested_tool() -> Result<()> {
let patch = format!(
"*** Begin Patch\n*** Add File: {file_name}\n+hello from code_mode\n*** End Patch\n"
);
let code = format!("const items = await apply_patch({patch:?});\nadd_content(items);\n");
let code = format!(
"import {{ apply_patch }} from \"tools.js\";\nconst items = await apply_patch({patch:?});\nadd_content(items);\n"
);
let (test, second_mock) =
run_code_mode_turn(&server, "use code_mode to run apply_patch", &code, true).await?;