import { t as AgentPermissionPolicy } from "./schema-BXTTXvJl.mjs"; import { c as PermissionPolicy } from "./evaluate-DXlKxvts.mjs"; //#region src/loader.d.ts export interface PolicyLoadOptions { /** Starting directory for walk-up discovery. */ cwd: string; } /** One source of policy: a name for provenance, its policy, and whether it bounds deeper layers. */ export interface PolicyLayer { /** What the layer came from, usually a file path; it is what `explain` reports for its rules. */ source: string; policy: AgentPermissionPolicy; /** The layer's allow rules bound what the layers after it can allow. */ ceiling?: boolean; } /** * Merge layers, outermost first, into one policy. * * - Rules from every layer are collected and deduplicated deny-first; each rule remembers its layer. * - The default mode is the innermost layer's, except after a ceiling layer, where a deeper layer can * only make it stricter. * - Delegation limits tighten: the shallowest `maxDepth`, every `nonDelegable` rule. * - A ceiling layer that allows something bounds the allow rules of the layers after it (see * {@link PermissionPolicy.layers}). */ export declare function mergeLayerPolicies(layers: readonly PolicyLayer[]): PermissionPolicy; /** * Load and merge permission policy from all sources. * * @throws PolicyLoadError if a layer file exists but cannot be read, parsed or validated. Skipping it * would drop its rules, and the policy left could be looser than the one written. * * Two-pass process: * * 1. Discover canonical files, resolve `up`/`with`/`without` from them. * 2. Re-discover all files (canonical + native) using resolved config, decode, and merge. */ export declare function loadPolicy(options: PolicyLoadOptions): Promise; /** Thrown by `loadPolicy`, and given to `watchPolicy`'s error callback, when a layer file is there but cannot be used. */ export declare class PolicyLoadError extends Error { /** One line per file that could not be read, parsed or validated. */ readonly failures: readonly string[]; constructor(failures: readonly string[]); } /** A running watch. */ export interface PolicyWatcher { /** Stop watching; no callback runs after this returns. */ close(): void; } /** * Watch the layer files of a walk up from `options.cwd`. `onChange` is called with the policy as it * first loads, and again each time a reload gives a different one, so a host needs no separate * {@link loadPolicy} call: one that loaded the policy first could miss a change made while the * watch was starting. * * A layer file that is there but cannot be read, parsed or validated (an editor mid-write, say) is * reported to `onError` as a {@link PolicyLoadError}, and no policy is reported until every file * loads again: a policy missing that layer would be looser than the one in force. */ export declare function watchPolicy(options: PolicyLoadOptions, onChange: (policy: PermissionPolicy) => void, onError: (error: Error) => void): PolicyWatcher; //#endregion //# sourceMappingURL=loader.d.mts.map