/** * Codex hook event payload delivered on stdin. * * Codex uses a subprocess hook model (JSON stdin/stdout). Hooks ship in the * plugin (declared via `hooks` in plugin.json); Codex requires the user to * trust freshly installed plugin hooks before they run. * * Canonical `tool_name` values: * - `"Bash"` * - `"apply_patch"` — canonical name for file edits. `Write`/`Edit` are * matcher aliases only; the serialized name is always `apply_patch`. * - `"webrun"` for web access. * - `"mcp____"` for MCP tools. * - `"spawn_agent"` for a Codex collaboration Sub-Agent spawn. * * Supported events: SessionStart, PreToolUse, PostToolUse, PermissionRequest, * UserPromptSubmit, Stop. */ export interface CodexHookInput { hook_event_name: string; session_id: string; cwd: string; transcript_path?: string; turn_id?: string; tool_name?: string; tool_input?: Record; tool_use_id?: string; tool_response?: Record; source?: "startup" | "resume" | "clear"; model?: string; permission_mode?: "default" | "acceptEdits" | "plan" | "dontAsk" | "bypassPermissions"; prompt?: string; last_assistant_message?: string; stop_hook_active?: boolean; } /** * Codex hook output written to stdout. * * Codex parses every event's output with a `deny_unknown_fields` schema, so * only documented fields may appear; an unknown field turns the whole output * into a hook error. Allow is implicit (empty output). PreToolUse denies with * `hookSpecificOutput.permissionDecision: "deny"`; PermissionRequest uses the * structured `hookSpecificOutput.decision` shape and has no top-level * `decision` or `reason`. * * `additionalContext` is supported on SessionStart, UserPromptSubmit, * PreToolUse, and PostToolUse. */ export interface CodexHookOutput { continue?: boolean; decision?: "block"; reason?: string; systemMessage?: string; suppressOutput?: boolean; stopReason?: string; hookSpecificOutput?: CodexHookSpecificOutput; } export interface CodexHookSpecificOutput { hookEventName?: string; permissionDecision?: "allow" | "deny" | "ask"; permissionDecisionReason?: string; decision?: { behavior: "allow" | "deny"; message?: string; }; additionalContext?: string; }