/** * Hook Input Normalization * * Handles snake_case -> camelCase field mapping for Claude Code hook inputs. * Claude Code sends snake_case fields: tool_name, tool_input, tool_response, * session_id, cwd, hook_event_name. This module normalizes them to camelCase * with snake_case-first fallback. * * Uses Zod for structural validation to catch malformed inputs early. * Sensitive hooks use strict allowlists; others pass through unknown fields. */ import { z } from 'zod'; import type { HookInput } from './bridge.js'; /** Schema for the common hook input structure (supports both snake_case and camelCase) */ declare const HookInputSchema: z.ZodObject<{ tool_name: z.ZodOptional; tool_input: z.ZodOptional; tool_response: z.ZodOptional; session_id: z.ZodOptional; cwd: z.ZodOptional; hook_event_name: z.ZodOptional; toolName: z.ZodOptional; toolInput: z.ZodOptional; toolOutput: z.ZodOptional; toolResponse: z.ZodOptional; sessionId: z.ZodOptional; directory: z.ZodOptional; hookEventName: z.ZodOptional; prompt: z.ZodOptional; message: z.ZodOptional; }, "strip", z.ZodTypeAny, { content?: string | undefined; }, { content?: string | undefined; }>>; parts: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: string; text?: string | undefined; }, { type: string; text?: string | undefined; }>, "many">>; stop_reason: z.ZodOptional; stopReason: z.ZodOptional; user_requested: z.ZodOptional; userRequested: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ tool_name: z.ZodOptional; tool_input: z.ZodOptional; tool_response: z.ZodOptional; session_id: z.ZodOptional; cwd: z.ZodOptional; hook_event_name: z.ZodOptional; toolName: z.ZodOptional; toolInput: z.ZodOptional; toolOutput: z.ZodOptional; toolResponse: z.ZodOptional; sessionId: z.ZodOptional; directory: z.ZodOptional; hookEventName: z.ZodOptional; prompt: z.ZodOptional; message: z.ZodOptional; }, "strip", z.ZodTypeAny, { content?: string | undefined; }, { content?: string | undefined; }>>; parts: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: string; text?: string | undefined; }, { type: string; text?: string | undefined; }>, "many">>; stop_reason: z.ZodOptional; stopReason: z.ZodOptional; user_requested: z.ZodOptional; userRequested: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ tool_name: z.ZodOptional; tool_input: z.ZodOptional; tool_response: z.ZodOptional; session_id: z.ZodOptional; cwd: z.ZodOptional; hook_event_name: z.ZodOptional; toolName: z.ZodOptional; toolInput: z.ZodOptional; toolOutput: z.ZodOptional; toolResponse: z.ZodOptional; sessionId: z.ZodOptional; directory: z.ZodOptional; hookEventName: z.ZodOptional; prompt: z.ZodOptional; message: z.ZodOptional; }, "strip", z.ZodTypeAny, { content?: string | undefined; }, { content?: string | undefined; }>>; parts: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: string; text?: string | undefined; }, { type: string; text?: string | undefined; }>, "many">>; stop_reason: z.ZodOptional; stopReason: z.ZodOptional; user_requested: z.ZodOptional; userRequested: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Hooks where unknown fields are dropped (strict allowlist only) */ declare const SENSITIVE_HOOKS: Set; /** All known camelCase field names the system uses (post-normalization) */ declare const KNOWN_FIELDS: Set; /** Check if input is already camelCase-normalized and can skip Zod parsing */ declare function isAlreadyCamelCase(obj: Record): boolean; /** * Normalize hook input from Claude Code's snake_case format to the * camelCase HookInput interface used internally. * * Validates the input structure with Zod, then maps snake_case to camelCase. * Always reads snake_case first with camelCase fallback, per the * project convention documented in MEMORY.md. * * @param raw - Raw hook input (may be snake_case, camelCase, or mixed) * @param hookType - Optional hook type for sensitivity-aware filtering */ export declare function normalizeHookInput(raw: unknown, hookType?: string): HookInput; export { SENSITIVE_HOOKS, KNOWN_FIELDS, isAlreadyCamelCase, HookInputSchema }; //# sourceMappingURL=bridge-normalize.d.ts.map