import type { OperationManifest } from "../core/types.js"; export interface ToolExecuteBeforeInput { tool: string; sessionID: string; callID: string; agent?: string; } export interface ToolExecuteBeforeOutput { args: unknown; } export type WriteDenialReason = "manifest-unavailable" | "session-expired" | "unclassified-command" | "path-required" | "project-boundary" | "manifest-scope" | "parallel-relative-path" | "parallel-git-mutation" | "parallel-remote-mutation" | "parallel-validation" | "session-released" | "repeated-denial"; export declare class WriteDeniedError extends Error { readonly reason: WriteDenialReason; constructor(reason: WriteDenialReason, path: string, options?: ErrorOptions); } export interface ProjectPaths { readonly root: string; absolute(relativePath: string): string; contains(path: string): Promise; toRelativePath(path: string): Promise; } export interface WriteGate { check(input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput): Promise; checkPath(path: string): Promise; toRelativePath(path: string): Promise; } interface Extraction { applies: boolean; ambiguous: boolean; paths: string[]; createdDirectories?: string[]; requiredDirectories?: string[]; gitCommit?: boolean; gitMutation?: boolean; remoteMutation?: boolean; issue?: CommandIssue; } interface CommandIssue { segment: string; cause: string; hint: string; } export declare function safePath(path: string): string; export declare function resolveProjectRoot(input: { directory: string; worktree?: string; }): string; export declare function describeUnclassifiedCommand(tool: string, args: unknown): string | undefined; /** Extract known write destinations; unknown shell executables fail closed as ambiguous. */ export declare function extractWritePaths(tool: string, args: unknown): Extraction; /** * Bootstrap is intentionally narrower than the normal write extractor: only one native Write or * one single-file apply_patch envelope exposes enough structure to authorize a missing control file. */ export declare function bootstrapWritePaths(tool: string, args: unknown): readonly string[] | undefined; export declare function isGitMutation(tool: string, args: unknown): boolean; export declare function isRemoteMutation(tool: string, args: unknown): boolean; /** * Quoted segments keep their contents; every unquoted whitespace run collapses to one space so the * same command written with different spacing compares equal. */ export declare function normalizeCommand(command: string): string; /** Canonicalize only an exact or unambiguous basename-shortened sequence of declared validations. */ export declare function canonicalDeclaredValidationSequence(command: string, declared: ReadonlySet): string | undefined; /** Unbound sessions may invoke only tools whose complete input is known to be read-only. */ export declare function isKnownReadOnlyTool(tool: string, args: unknown, additionalReadOnlyTools?: ReadonlySet): boolean; /** Canonical scopes let sibling worker bindings reject equal or ancestor ownership. */ export declare function canonicalManifestWriteScopes(project: ProjectPaths, manifest: OperationManifest): Promise; export declare function canonicalManifestReadScopes(project: ProjectPaths, manifest: OperationManifest): Promise; export declare function writeScopesOverlap(left: readonly string[], right: readonly string[]): boolean; export declare function createProjectPaths(rootCandidate: string): Promise; export declare function createWriteGate(project: ProjectPaths, value: unknown, toolDirectory?: string): Promise; export {};