Expose TypeScript signatures in Code Mode's ALL_TOOLS (#64939)

## Why

Code Mode embeds TypeScript declarations in tool descriptions, so scripts
that want to inspect a tool's argument and return types have to extract
the declaration from the description.

## What changed

Enable `features.code_mode_all_tools_schema` to expose callable names,
descriptions, and TypeScript signatures as separate fields in `ALL_TOOLS`.
Update the `exec` guidance to match the selected format, including when
resuming a session. The flag is off by default.

Carry signatures over gRPC and stdio. Reject execution requests with
signatures when the host does not advertise support for them.

## Testing

Add coverage for both catalog formats, `exec` guidance on resume, and
signature preservation over gRPC and stdio.

GitOrigin-RevId: dedaeec4a2563c23d432c324187ef20f6a0e5ea3
This commit is contained in:
Alex Daley
2026-12-01 06:54:13 +00:00
committed by copyberry
parent 936ac6dbe6
commit a54018ff36
45 changed files with 703 additions and 37 deletions
@@ -114,6 +114,7 @@ clearTimeout(earlyTimer); setTimeout(() => {}, 60000);
stored_values: HashMap::new(),
stored_value_writes: HashMap::new(),
enabled_tools: Arc::from([Arc::new(EnabledToolMetadata {
signature: None,
global_name: "echo".into(),
description: String::new(),
tool_name,
@@ -166,6 +166,9 @@ fn build_all_tools_value<'s>(
let description_key = v8::String::new(scope, "description")
.ok_or_else(|| "failed to allocate ALL_TOOLS description key".to_string())?;
let signature_key = v8::String::new(scope, "signature")
.ok_or_else(|| "failed to allocate ALL_TOOLS signature key".to_string())?;
for tool in enabled_tools {
let item = v8::Object::new(scope);
let name = v8::String::new(scope, &tool.global_name)
@@ -181,6 +184,15 @@ fn build_all_tools_value<'s>(
{
return Err("failed to set ALL_TOOLS description".to_string());
}
if let Some(signature) = &tool.signature {
let signature = v8::String::new(scope, signature)
.ok_or_else(|| "failed to allocate ALL_TOOLS signature".to_string())?;
if item.create_data_property(scope, signature_key.into(), signature.into())
!= Some(true)
{
return Err("failed to set ALL_TOOLS signature".to_string());
}
}
items.push(item.into());
}
@@ -114,6 +114,7 @@ impl InProcessCodeModeSession {
global_name: normalize_code_mode_identifier(&tool.name),
tool_name: tool.tool_name,
description: tool.description,
signature: tool.signature,
kind: tool.kind,
})
.collect();
@@ -174,6 +174,7 @@ fn blocking_tool() -> ToolDefinition {
description: String::new(),
kind: CodeModeToolKind::Function,
input_schema: None,
signature: None,
input_schema_max_bytes: None,
output_schema: None,
}
@@ -543,6 +543,7 @@ fn echo_tool() -> ToolDefinition {
description: String::new(),
kind: CodeModeToolKind::Function,
input_schema: None,
signature: None,
input_schema_max_bytes: None,
output_schema: None,
}