Support tool-specific JavaScript preloads in Code Mode (#62430)

## What changed

Let in-process sessions and hosts using stdio or gRPC supply trusted
JavaScript helpers. Run each helper before the cell's module in the same V8
context, only when the cell exposes a unique matching binding with the
expected tool name and namespace.

Report ambiguous bindings and preload failures as bounded cell errors.
Suppress V8 diagnostics on stdout so they cannot corrupt stdio protocol frames.

## Testing

Add coverage for per-session helper selection, exact tool matching, ambiguous
bindings, and bounded compile and execution errors. A stdio subprocess test
checks that a failed preload leaves another session on the same connection
usable. Allow more time for existing CLI and MCP integration tests to connect,
start their test server, or shut down.

GitOrigin-RevId: f9f037de7f9d6018ae755b38475c4131ca7ba1f0
This commit is contained in:
Henry Levy
2026-11-19 04:48:49 +00:00
committed by copyberry
parent b5d9f7116e
commit d64451b049
18 changed files with 613 additions and 31 deletions
+3 -2
View File
@@ -635,8 +635,9 @@ trust_level = "trusted"
} else {
session.terminate();
}
let exit =
tokio::time::timeout(Duration::from_secs(/*secs*/ 10), spawned.exit_rx).await??;
let exit = tokio::time::timeout(Duration::from_secs(/*secs*/ 30), spawned.exit_rx)
.await
.context("timed out waiting for the worktree TUI to exit")??;
// Include shutdown output: ConPTY can retain the channel after process exit.
let _ = tokio::time::timeout(Duration::from_secs(/*secs*/ 1), async {
while let Some(bytes) = stdout.recv().await {