/** * JSON-Schema validation for tool arguments at the HTTP dispatcher layer. * * Why a separate layer when lib/tools.ts already validates required args: * - lib/tools.ts only checks presence (closes the prod 22P02 bug from #47). * - This module checks types, formats, ranges, and enums per inputSchema — * so an AI agent that passes guests:"six" or guests:-1 gets a clear * field-level error instead of a Supabase coercion failure or silent * bad-data result. * * Source of truth is TOOLS[].inputSchema in api/mcp.ts. Validators are * compiled once at module load — fast path on every tools/call. * * Defense-in-depth: lib/tools.ts continues to enforce required args even if * this layer is bypassed. */ export interface ToolDescriptor { name: string; inputSchema: object; } /** * Pre-compile validators for every tool. Idempotent — calling twice with the * same name is a no-op. Call once at module load with the canonical TOOLS array. */ export declare function registerToolSchemas(tools: readonly ToolDescriptor[]): void; export interface FieldError { /** JSON Pointer-ish path, e.g. "/guests" or "/propertyIds/0". */ path: string; /** Human-readable message. */ message: string; } export interface ValidateArgsResult { ok: boolean; errors?: FieldError[]; } /** * Validate `args` against the registered schema for `toolName`. * * Returns { ok: true } when: * - no schema is registered for `toolName` (forwards-compatibility — a new * tool added at runtime is still callable; lib/tools.ts will catch missing * required fields, and unknown names are already rejected upstream). * - the schema accepts the args. */ export declare function validateToolArgs(toolName: string, args: unknown): ValidateArgsResult; /** Test-only helper. Reset compiled validators between test files. */ export declare function _resetForTests(): void;