import { useEffect } from "react"; export interface McpConfirmSpec { tool: string; args: unknown; reason: string | null; /** Human-readable summary of what's about to happen, computed by the * per-tool handler (e.g. "rename pane 'shell' to 'build'"). */ summary: string; } interface McpConfirmProps { spec: McpConfirmSpec; onAccept: () => void; onReject: () => void; /** Approve this call AND add the bare tool name to the policy allow list * so future calls of this tool skip the prompt. */ onAlwaysAllow: () => void | Promise; } export default function McpConfirm({ spec, onAccept, onReject, onAlwaysAllow }: McpConfirmProps) { useEffect(() => { function onKey(e: KeyboardEvent) { if (e.key === "Escape") { e.preventDefault(); onReject(); } else if (e.key === "Enter") { e.preventDefault(); onAccept(); } } window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onAccept, onReject]); const argsJson = JSON.stringify(spec.args, null, 2); return ( <> ); }