import type { ObserverWatch, ToolResultEvent } from "../schema.ts"; /** * True if the observer's `watch` filter accepts this event. No watch * → matches everything. Semantics per ADR "Observer schema": * * - `toolName` — exact match against `event.toolName`. * - `inputMatches` — every declared key's Pattern must match against * `event.input[key]` if that key exists AND the value is a string. * Keys absent from the event's input (or non-string values) make * the whole filter fail — documented fail-closed choice: subset * checks don't silently pass when the expected field isn't present. * - `exitCode` — `"success"` → 0, `"failure"` → non-zero, * `"any"`/omitted → pass, numeric → exact match. `exitCode` is * sourced from the event's `exitCode` field (bash only via pi's * `details.exitCode` after projection to the schema shape); other * tool results leave it `undefined` and satisfy everything except * a numeric `exitCode:` (treated as "no match" — bash-specific * filter). * * Wrapper-aware command matching (ADR §12): when `inputMatches.command` * is set AND the event is a bash event, the pattern matches if EITHER * the raw outer `event.input.command` OR any extracted command ref * text matches. So `sh -c 'brazil ws sync'` with pattern * `/^brazil\s+ws\s+sync$/` fires the observer — the outer raw command * starts with `sh`, but the walker-extracted ref `brazil ws sync` does * hit the anchored pattern. * * Performance: when multiple observers share the same event (the * production dispatch path), pass a memoizing `refTextsProvider` to * parse the bash command once across observers. Standalone callers * (e.g. `testObserver` evaluating one observer in isolation, or the * evaluator's speculative-allow synthesizing one event per prior * `&&` ref) can omit it — the default provider parses on demand. */ export declare function matchesWatch(watch: ObserverWatch | undefined, event: ToolResultEvent, refTextsProvider?: () => readonly string[] | null): boolean; /** * Extract per-ref flattened text (basename + args joined with spaces) * from a bash tool_result's outer command, mirroring the evaluator's * `prepareBashState` text projection so observer watch patterns match * the same strings rule patterns see for the same command. * * Returns `null` when the event isn't a bash tool_result, the raw * command is missing/non-string, or the walker throws while parsing * (hard-to-parse command — fall back to raw-only matching without * blowing up dispatch). Unlike the evaluator we don't walk trackers: * observers don't receive `walkerState`, so the parse+extract+expand * stages suffice. * * Exported so the production dispatcher can memoize the parse across * observers on the same event (see `dispatchEventInner`'s * `getRefTexts` cache). Chain-aware speculative-allow already * synthesizes one event per prior ref and doesn't need memoization — * it calls {@link matchesWatch} without a provider. */ export declare function extractRefTextsForBash(event: ToolResultEvent): readonly string[] | null; //# sourceMappingURL=watch-matcher.d.ts.map