/** * The compiled-hook RUNTIME — `vigiles hook-runtime run-program `, the * process the harness spawns on every matching tool call. * * WHY IT IS ITS OWN MODULE, and why that is the whole point (#216): this code * used to live in `src/cli.ts` beside `compile` / `lint` / `audit` / `eval`, and * CommonJS resolves a module's top-level imports before a single argument is * parsed — so deciding `allow` on `ls -la` loaded the report template loader, the * linter catalogs, the adapter registry and ~30 more barrels. MEASURED * 2026-09-08 (Node 22.22.2, `tools/measure-hook-startup.mjs`, median of 20 * spawns): `require("dist/cli.js")` cost 623 ms against a 42 ms bare Node start, * and a real `run-program` spawn cost 610-661 ms. A shell hook doing the same job * costs ~12 ms. * * So `src/cli.ts` is now a dispatcher shim that `require`s THIS file for * `hook-runtime run-program` and the verb barrel for everything else. The * emitted command is unchanged and MUST stay unchanged — it is baked into every * already-emitted settings block and into the SHA stamp beside each hook. * * KEEP THIS MODULE'S TOP-LEVEL IMPORTS MINIMAL. Everything imported here is paid * on every gated tool call. Two deliberately-lazy edges, each with the measurement * at its call site: `@iarna/toml` (compile-time only, in `core/hook-program.ts` * and `hook-install.ts`) and `mvdan-sh` (bash predicates only, in * `core/bash-effects.ts`). `src/hook-runtime-graph.test.ts` asserts the graph * deterministically, because a timing threshold on a shared CI runner would be * flaky and would be the first thing quarantined. * * Harness-neutral: the gate protocol (deny → exit 2) is byte-identical on Claude * Code and Codex, and the ONE harness-specific fact the runtime needs — which * events accept injected context — is read from the resolved adapter's * `HookProtocol.injectableEvents`, never a literal. That resolution is itself a * lazy `require` because only the react role needs it (the adapter registry * measured 279 ms on its own). * * This is COMPOSITION-ROOT code (`src/` root), not `src/core/`: it does real I/O * (stdin, the stamp sidecar, state writes, `spawnSync`) and reaches the adapter * registry, so `core ⊄ adapter` keeps it out of the domain layer. */ import { type RegisteredProvider } from "./core/hook-providers.js"; import { loadHook } from "./load-hook.js"; /** * Load a compiled-hook program's default export — the SHARED loader, also the * public `vigiles` `loadHook` a `.harness.mjs` test uses, so a hook that * loads in a test loads identically here (one loader, no drift). */ export declare const loadHookProgram: typeof loadHook; /** Load a registered provider (`.vigiles/providers/.provider.`) → its definition. */ export declare function loadProvider(file: string, root?: string): Promise; /** Path of the tamper-evident stamp sidecar for a hook file. */ export declare function hookStampPath(file: string, root?: string): string; /** * `vigiles hook-runtime run-program ` — the runtime the compiled hooks block * points at. Reads the live event on stdin, loads the typed program, verifies * its stamp, and dispatches by role: a gate exits 2 + reason on `deny`; an * inject prints `additionalContext`; a react runs its effect-classified * command. A hook that won't load — or whose stamp is stale — fails CLOSED * (exit 2), never silent-allow, with two loudly-announced exceptions: the repair * action itself ({@link isStampRepairEvent}), and — on a LOAD failure only — the * load-path repair WRITE ({@link isLoadPathRepairEvent}), or the repo wedges * with no way to fix whatever broke the load path. * * INJECT-HOOK-SPECIFIC: An inject hook that fails to load is a harness failure, * not a decision failure. Unlike gates (which must be conservative and block on * any error), an inject is pure context addition. It degrades gracefully: if it * cannot load, the session continues without the injected context, and the error * is logged for debugging. This prevents a single broken inject from wedging all * sessions. */ export declare function runHookProgramCommand(file: string | undefined): Promise; //# sourceMappingURL=hook-runtime.d.ts.map