feat: add agent tools and sanitize tool names for Anthropic API

Add 8 new agent-callable tools (sessions.list/history/create/delete,
agents.list, message.send, cron.list/trigger) and sanitize tool names
at the API boundary (dots → underscores) to comply with Anthropic's
`^[a-zA-Z0-9_-]{1,128}` requirement. Reverse-maps sanitized names
back to internal names for hook callbacks and tool execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
William Valentin
2026-02-07 12:23:09 -08:00
parent f0e3987d1c
commit 6bb424cddc
13 changed files with 656 additions and 124 deletions
+4 -3
View File
@@ -161,11 +161,12 @@ export class NativeAgent {
// Execute each tool call and collect results
const toolResultBlocks: unknown[] = [];
for (const tc of response.toolCalls) {
this.onToolUse?.({ type: 'start', tool: tc.name, args: tc.args });
const internalName = this.toolRegistry!.getByApiName(tc.name)?.name ?? tc.name;
this.onToolUse?.({ type: 'start', tool: internalName, args: tc.args });
const result = await this.toolExecutor!.execute(tc.name, tc.args, this._toolPolicyContext);
const result = await this.toolExecutor!.execute(internalName, tc.args, this._toolPolicyContext);
this.onToolUse?.({ type: 'end', tool: tc.name, result });
this.onToolUse?.({ type: 'end', tool: internalName, result });
toolResultBlocks.push({
type: 'tool_result',