feat(coding-agent): type ToolCallEvent.input per tool

Matches ToolResultEvent pattern with typed inputs via discriminated union.

- Export *ToolInput types from tool schemas
- Add *ToolCallEvent interfaces for each built-in tool
- Add isToolCallEventType() guard with overloads for built-ins

Direct narrowing (event.toolName === "bash") doesn't work due to
CustomToolCallEvent.toolName: string overlapping with literals.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
G 2026-02-01 15:19:24 +01:00 committed by Mario Zechner
parent 469fb5d27c
commit a8a0f4b9fb
13 changed files with 219 additions and 19 deletions

View file

@ -1,6 +1,6 @@
import { createInterface } from "node:readline";
import type { AgentTool } from "@mariozechner/pi-agent-core";
import { Type } from "@sinclair/typebox";
import { type Static, Type } from "@sinclair/typebox";
import { spawn } from "child_process";
import { readFileSync, statSync } from "fs";
import path from "path";
@ -29,6 +29,8 @@ const grepSchema = Type.Object({
limit: Type.Optional(Type.Number({ description: "Maximum number of matches to return (default: 100)" })),
});
export type GrepToolInput = Static<typeof grepSchema>;
const DEFAULT_LIMIT = 100;
export interface GrepToolDetails {