import type { AgentWorkContract } from "../../features/agent-work-contracts/types.js"; /** * Dependencies for the contract enforcement hook. */ export interface ContractEnforcementDeps { /** Look up the active (running) contract for a given agent name. */ getActiveContractByAgent: (projectRoot: string, agentName: string) => AgentWorkContract | undefined; /** Resolve an agent name from a session ID. Returns undefined if unresolvable. */ resolveAgentName: (sessionID: string) => string | undefined; /** Project root for reading contract store. */ projectRoot: string; /** Optional logging callback. */ logWarn?: (message: string) => void; } /** * Create a `tool.execute.before` hook that enforces contract allowedSurfaces. * * Per D-06 to D-08, contracts enforce tool restrictions at runtime. * Per D-23, enforcement is a hard block (throw error), not best-effort. * Per D-26, no contract = no restriction. * * @param deps - Injected dependencies at composition time. * @returns Async hook function matching tool.execute.before signature. */ export declare function createContractEnforcementHook(deps: ContractEnforcementDeps): (input: unknown, output: unknown) => Promise; /** * Extract file paths from tool args for enforcement checking. * * Only file-modifying tools (write, edit) are enforced. * Read-only tools (read, glob), bash, and unknown tools return empty. * * @param toolName - Name of the tool being executed. * @param output - The tool output/args from tool.execute.before. * @returns Array of file paths, or empty array if tool is not file-modifying. */ export declare function extractFilePaths(toolName: string, output: unknown): string[]; /** * Check if a file path is within any of the allowed surfaces. * * Uses path prefix matching with path.resolve normalization to * prevent path traversal attacks. * * @param filePath - Absolute path to check. * @param allowedSurfaces - List of allowed surface prefixes. * @returns True if the file path is within any allowed surface. */ export declare function isPathAllowed(filePath: string, allowedSurfaces: string[]): boolean; //# sourceMappingURL=contract-enforcement.d.ts.map