import { z } from 'zod'; export declare const HookCommandSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{ type: z.ZodString; command: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>; export declare const ClaudeSettingsSchema: z.ZodObject<{ hooks: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">>>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ PreToolUse: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ matcher: z.ZodOptional; hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; SessionStart: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hooks: z.ZodOptional, z.objectInputType<{ type: z.ZodString; command: z.ZodString; }, z.ZodTypeAny, "passthrough">>]>, "many">>; }, z.ZodTypeAny, "passthrough">>, "many">>; }, z.ZodTypeAny, "passthrough">>>; }, z.ZodTypeAny, "passthrough">>; export type ParsedSettings = z.infer; /** PreToolUse matcher values Totem installs under. */ export type PreToolUseMatcher = 'Bash' | 'Write|Edit'; /** Outcome of a settings-merge attempt. */ export type ScaffoldOutcome = { action: 'created' | 'merged' | 'skipped'; err?: string; }; /** The `hooks.` lifecycle a merge targets. */ export type ClaudeHooksKey = 'PreToolUse' | 'SessionStart'; /** * Structural shape of a single hook entry. Widened from the closed * 3-template `ClaudeHookEntry` union that lived in init.ts so a * gate-wrapper entry (`{ matcher: 'Write|Edit', hooks: [{ type, command }] }`) * is a valid argument without enumerating every concrete template. Any entry * carrying a `hooks` array of `{ type, command }` objects (optionally a * `matcher` / `timeout`) is accepted; passthrough fields (e.g. `timeout`) are * preserved by the merge because the entry is written verbatim. */ export interface HostHookEntry { matcher?: string; hooks: Array<{ type: string; command: string; [k: string]: unknown; }>; [k: string]: unknown; } /** * Shared merge logic for installing a single hook entry into a Claude * settings JSON file (`settings.local.json` or `settings.json`) under * `hooks.`. Both `PreToolUse` and `SessionStart` lifecycles share * the same read → safeparse → idempotency probe → append → write shape; * this is the single source of truth. * * Idempotent: returns `'skipped'` if `alreadyInstalled(parsed)` is true. */ export declare function mergeClaudeHooksKey(filePath: string, hookKind: ClaudeHooksKey, entry: HostHookEntry, alreadyInstalled: (parsed: ParsedSettings) => boolean): ScaffoldOutcome; /** Outcome of a tier-aware `PreToolUse` command upsert. */ export type HookUpsertOutcome = { /** * `created` — fresh settings file written; `merged` — a new entry appended; * `updated` — an existing matching entry's command rewritten in place (e.g. * a tier switch); `skipped` — the desired command was already present (true * no-op) or the file had an unexpected shape (with `err`). */ action: 'created' | 'merged' | 'updated' | 'skipped'; err?: string; }; /** * Tier-AWARE upsert of a single `PreToolUse` command into a Claude settings * JSON file under `hooks.PreToolUse`. Unlike `mergeClaudeHooksKey` (which only * ever appends or no-ops), this guarantees AT MOST ONE entry can match * `(matcher, identifies)` and rewrites that entry's command in place when it * differs from `desiredEntry`'s command — so re-installing the same gate at a * different tier flips the baked command rather than silently no-opping or * duplicating the entry. * * `identifies(command)` decides whether an existing hook command is "the same * gate" (tier-INDEPENDENT). `desiredEntry` carries the canonical * matcher + the single hook whose `command` is the tier-correct target. * * Cases: * 1. no existing match → append `desiredEntry` → `merged` (or * `created` if the file did not exist) * 2. match, same command → no write → `skipped` * 3. match, different command → rewrite that hook's command → `updated` * * Result-returning (never throws past its own boundary), mirroring * `mergeClaudeHooksKey`'s contract so callers branch on `{ action, err }`. */ export declare function upsertClaudeHookCommand(filePath: string, matcher: PreToolUseMatcher, desiredEntry: HostHookEntry, identifies: (command: string) => boolean): HookUpsertOutcome; /** * True iff `parsed.hooks.PreToolUse` contains an entry under `matcher` * whose hook list satisfies `probe`. The idempotency primitive both the * shield-gate and gate-install installers key on. */ export declare function preToolUseHasMatcher(parsed: ParsedSettings, matcher: PreToolUseMatcher, probe: (entry: z.infer) => boolean): boolean; //# sourceMappingURL=host-hooks.d.ts.map