import { type ToolCallPayload } from '../hook/runtime.js';
/**
 * `totem hook run --tool <name> --args <args>` — the PreToolUse runtime
 * entrypoint (ADR-104 § Decisions 1, 2, 3 + § Convergence).
 *
 * Loads `.totem/compiled-hooks.json`, evaluates each compiled hook against
 * the tool-call payload, and emits a structured `[totem:hook-block]`
 * rejection to stderr (exit code 2) on the first match. Allow path is exit
 * code 0 with no output.
 *
 * The runtime is deterministic Node.js — no LLM calls in this path
 * (Tenet 15 corollary, ADR-103 § 8). The engine bootstrap (AST/language
 * registration via `loadInstalledPacks`) is intentionally NOT invoked here
 * because hook evaluation is regex-only in V1 and the bootstrap pulls
 * heavy runtime deps that we cannot afford on every tool call.
 *
 * Failure modes are best-effort per ADR-104 § Decision 3 + Tenet 4 carve-out:
 * - Missing manifest (fresh repo, no installed pack hooks): exit 0 silently.
 * - Stale pack versions, schemaVersion mismatch, corrupt JSON: emit
 *   structured warnings/errors to stderr, allow the tool call.
 * - Only an explicit `reject` decision from `evaluateHook` blocks.
 */
export interface HookRunCommandOptions {
    tool: string;
    args: string;
}
/**
 * Side-effect-free result for the command driver. Returns the exit code
 * the CLI wrapper should propagate, plus the stderr lines that should
 * accompany it. Keeps `executeHookRun` testable without spying on
 * `process.exit` or `console.error`.
 */
export interface HookRunResult {
    exitCode: 0 | 2;
    stderr: string[];
}
/**
 * Injectable inputs for `executeHookRun`. The CLI wrapper resolves these
 * from the working directory; tests construct them directly to avoid
 * touching the real filesystem or `process.cwd()`.
 */
export interface HookRunInputs {
    manifestPath: string;
    installedPackVersions: Record<string, string>;
    payload: ToolCallPayload;
}
/**
 * The exit code Claude Code's PreToolUse hook convention treats as "block
 * the tool call." Exported so test suites assert against the same constant
 * rather than against a magic number that could drift.
 */
export declare const EXIT_ALLOW: 0;
export declare const PRE_TOOL_USE_BLOCK_EXIT_CODE: 2;
export declare function hookRunCommand(opts: HookRunCommandOptions): Promise<void>;
/**
 * Pure synchronous core. Given resolved inputs, returns the exit code and
 * stderr lines the wrapper should emit. No process state is touched.
 *
 * Two-phase contract:
 * 1. Load + emit diagnostics (warnings, structured errors) regardless of
 *    whether any hooks loaded successfully.
 * 2. Walk loaded hooks until the first reject; allow when none reject.
 *
 * Order in `stderr` is preserved: load-time diagnostics come before any
 * rejection line, so an operator inspecting stderr sees the staleness or
 * schema-mismatch context that may explain why a rejection fired.
 */
export declare function executeHookRun(inputs: HookRunInputs): HookRunResult;
/**
 * Scan `<projectRoot>/node_modules/@mmnto/pack-*` and read each pack's
 * `package.json` version field. Returns a `packName → version` map for
 * the compiled-hooks loader's staleness check.
 *
 * Bounded cost: one `readdirSync` plus N `readFileSync` calls (N = number
 * of installed `@mmnto/pack-*` packages, typically <5). Expected per-pack
 * read/parse failures (ENOENT/ENOTDIR/EPERM/EACCES on the package.json,
 * SyntaxError on malformed JSON) are skipped so the loader can emit
 * `[totem:hook-stale]` warnings for missing/invalid packs — the correct
 * signal for an operator who has uninstalled a pack but not re-run
 * `totem sync`. Unexpected exceptions (IO timeout, OOM, etc.) are
 * rethrown to surface real faults. The outer `readdirSync` on the
 * `@mmnto` scope dir applies the same discipline: ENOENT returns empty;
 * any other errno surfaces as a thrown error.
 *
 * Workspace setups (pnpm workspace, yarn workspaces) symlink the pack
 * directory into `node_modules/@mmnto/`, so the `readdirSync` + JSON
 * read traverses the symlink transparently and reads the source-of-truth
 * `package.json`. No special case needed.
 */
export declare function resolveInstalledPackVersions(projectRoot: string): Record<string, string>;
//# sourceMappingURL=hook-run.d.ts.map