/**
 * Tool runtime contract for the pi harness.
 *
 * Tool names match the Claude Agent SDK's so the existing system prompt
 * (`worker/prompts/...`) — which advertises Read / Write / Edit / Bash —
 * keeps working without rewriting prompts per harness. Schemas are JSON
 * Schema in the shape Google's `functionDeclarations.parameters` accepts.
 */

export interface PiToolResult {
  /** Text shown back to the model as the tool's output. */
  output: string;
  /** Mark `true` when the tool failed; the loop tells the model so it can recover. */
  isError?: boolean;
}

export interface PiToolContext {
  /** Workspace root — every tool resolves paths against this. */
  cwd: string;
  /** Aborted when the session ends so long-running tools stop fast. */
  signal?: AbortSignal;
}

export interface PiTool {
  name: string;
  description: string;
  inputSchema: Record<string, any>;
  run(input: any, ctx: PiToolContext): Promise<PiToolResult>;
}
