Expose strongly-typed result for exec_command (#14183)

Summary
- document output types for the various tool handlers and registry so
the API exposes richer descriptions
- update unified execution helpers and client tests to align with the
new output metadata
- clean up unused helpers across tool dispatch paths

Testing
- Not run (not requested)
This commit is contained in:
pakrym-oai
2026-03-10 09:54:34 -07:00
committed by Michael Bolin
parent f9cba5cb16
commit 00ea8aa7ee
12 changed files with 278 additions and 154 deletions

View File

@@ -14,7 +14,7 @@ use core_test_support::skip_if_no_network;
use core_test_support::test_codex::TestCodex;
use core_test_support::test_codex::test_codex;
use pretty_assertions::assert_eq;
use regex_lite::Regex;
use serde_json::Value;
use std::fs;
use wiremock::MockServer;
@@ -75,7 +75,7 @@ async fn code_mode_can_return_exec_command_output() -> Result<()> {
r#"
import { exec_command } from "tools.js";
add_content(await exec_command({ cmd: "printf code_mode_exec_marker" }));
add_content(JSON.stringify(await exec_command({ cmd: "printf code_mode_exec_marker" })));
"#,
false,
)
@@ -88,19 +88,20 @@ add_content(await exec_command({ cmd: "printf code_mode_exec_marker" }));
Some(false),
"code_mode call failed unexpectedly: {output}"
);
let regex = Regex::new(
r#"(?ms)^Chunk ID: [[:xdigit:]]+
Wall time: [0-9]+(?:\.[0-9]+)? seconds
Process exited with code 0
Original token count: [0-9]+
Output:
code_mode_exec_marker
?$"#,
)?;
let parsed: Value = serde_json::from_str(&output)?;
assert!(
regex.is_match(&output),
"expected exec_command output envelope to match regex, got: {output}"
parsed
.get("chunk_id")
.and_then(Value::as_str)
.is_some_and(|chunk_id| !chunk_id.is_empty())
);
assert_eq!(
parsed.get("output").and_then(Value::as_str),
Some("code_mode_exec_marker"),
);
assert_eq!(parsed.get("exit_code").and_then(Value::as_i64), Some(0));
assert!(parsed.get("wall_time_seconds").is_some());
assert!(parsed.get("session_id").is_none());
Ok(())
}