/** * Adapter payload parser. One file because all three adapters (CC, Cursor, * Codex) share most of their PreToolUse / PostToolUse field names (Codex's * field names match CC's directly) and Cursor's deltas are small enough to * branch inline. * * The parser is intentionally tolerant: every field reads through `pickStr`, * `pickNum`, etc., so a missing key returns `undefined` instead of throwing. * Phase 2 ship criterion is "parser correctness across thousands of real * events without affecting behavior": fail-soft beats fail-hard. */ import type { Adapter } from "../../adapter.js"; export interface ParsedPayload { hook_event_name?: string; session_id?: string; agent_id?: string; subagent_id?: string; conversation_id?: string; parent_session_id?: string; turn_id?: string; parent_turn_id?: string; transcript_path?: string; cwd?: string; pid?: number; model?: string; /** CC stamps the effective effort level ({level}) on tool hooks and Stop; * absent on SessionStart/UserPromptSubmit and on models with no dial. */ effort?: string; source?: string; prompt?: string; agent_message?: string; tool_name?: string; tool_input?: unknown; tool_response?: unknown; tool_use_id?: string; stop_hook_active?: boolean; clean_exit?: boolean; exit_status?: string; reason?: string; /** Privacy-safe Cursor execution surface, derived from native lifecycle metadata. */ cursor_mode?: "local" | "cloud" | "unknown"; /** original parsed object, preserved for callers that need a field we didn't pluck. */ raw: Record; } /** * Parse the raw stdin payload string for any adapter. Returns null when JSON * parse fails (Cursor occasionally fires hooks with no payload). */ export declare function parsePayload(raw: string, adapter: Adapter): ParsedPayload | null; /** * Pull the bash command string out of a Bash/Shell tool_input. Returns * undefined for non-shell tools. */ export declare function extractBashCommand(toolName: string | undefined, toolInput: unknown): string | undefined; /** * Pull the model's description string out of a tool_input. Only Claude Code's * Bash tool requires this field; falls back to undefined elsewhere. */ export declare function extractToolDescription(toolInput: unknown): string | undefined; /** * Each adapter uses a slightly different name for the "same" lifecycle event. * Map the CLI-arg event-name (kebab-case, set by us in the wiring) to one of * the canonical event_types. Phase 2's CLI passes the kebab event * name; this returns the canonical event_type or null when the event has no * canonical equivalent. Cursor's shell-specific hooks are retained as reliable * remote/CLI fallbacks and normalized to the same tool events as generic hooks. */ export declare function normalizeEventName(eventName: string): { event_type: NormalizedEventType; intra_turn: boolean; } | null; export type NormalizedEventType = "session.started" | "session.ended" | "turn.started" | "turn.completed" | "agent.started" | "agent.completed" | "tool.requested" | "wait.started" | "tool.completed" | "context.compaction_started" | "context.compaction_completed"; //# sourceMappingURL=parse.d.ts.map