import type { InspectApplyPayload } from '../editor/inspect.js'; import type { InspectApplyResult, InspectPreviewResult } from '../editor/host.js'; export type SourceWriteErrorCode = 'invalid-path' | 'empty-change' | 'excluded-source' | 'empty-diff' | 'unexpected-file' | 'missing-file' | 'review-required' | 'stale-preview' | 'busy' | 'not-applied'; export declare class SourceWriteError extends Error { readonly code: SourceWriteErrorCode; readonly path?: string; constructor(code: SourceWriteErrorCode, message: string, path?: string); } export interface SourceWritePolicy { /** Repository-owned recovery outputs that must never count as source changes. */ excludedSourcePrefixes?: readonly string[]; requireBranch?: boolean; /** Optional workspace identity; a change invalidates a reviewed payload. */ scope?: () => string; } export interface InspectSourceRuntime { previewVisual(payload: InspectApplyPayload): Promise; applyVisual(payload: InspectApplyPayload): Promise; } /** Payloads must be JSON-serializable. Each runtime call receives an independent snapshot. */ export interface ReviewedSourceOperationRuntime { preview(payload: TPayload): Promise; apply(payload: TPayload): Promise; } export interface ReviewedSourceOperationFiles { /** Existing inputs whose paths must satisfy the source policy, including read-only dependencies. */ proofFiles: readonly string[]; /** The only files this operation may change, including newly created files. */ changedFiles: readonly string[]; } export interface ReviewedSourceOperationPolicy extends SourceWritePolicy { /** A synchronous, side-effect-free declaration for the captured payload. */ files(payload: TPayload): ReviewedSourceOperationFiles; /** Additional payload validation, run before preview and apply. */ validate?(payload: TPayload): void; /** Require each changed file exactly once in both diffs and affectedFiles. Defaults to false. */ requireCompletePreview?: boolean; } export declare function inspectPayloadSourceFiles(payload: InspectApplyPayload): string[]; export declare function assertInspectSourcePayload(payload: InspectApplyPayload, policy?: SourceWritePolicy): void; /** Review tickets are single-use and survive neither a new preview nor a workspace change. */ export declare function createReviewedSourceOperation(runtime: ReviewedSourceOperationRuntime, policy: ReviewedSourceOperationPolicy): { preview: (payload: TPayload) => Promise; apply: (payload: TPayload) => Promise; }; /** Compatibility adapter for visual Inspect payloads; unchanged files may be omitted from a preview. */ export declare function createReviewedSourceWriter(runtime: InspectSourceRuntime, policy?: SourceWritePolicy): { preview: (payload: InspectApplyPayload) => Promise; apply: (payload: InspectApplyPayload) => Promise; };