/**
 * Streaming edit preview strategies.
 *
 * Each edit mode owns a strategy that knows how to:
 * - collapse partial-JSON args to the subset safe to preview
 *   (`extractCompleteEdits`),
 * - compute unified diff previews for the in-flight args
 *   (`computeDiffPreview`), and
 * - render a text placeholder while no diff exists yet
 *   (`renderStreamingFallback`).
 *
 * The shared renderer / `ToolExecutionComponent` consult the strategy via
 * the injected `editMode` rather than probing argument shape.
 */
import { type SnapshotStore } from "@pk-nerdsaver-ai/hashline";
import type { Theme } from "../modes/theme/theme";
import { type EditMode, resolveEditMode } from "../utils/edit-mode";
export interface PerFileDiffPreview {
    path: string;
    diff?: string;
    firstChangedLine?: number;
    error?: string;
}
export interface StreamingDiffContext {
    cwd: string;
    signal: AbortSignal;
    snapshots: SnapshotStore;
    fuzzyThreshold?: number;
    allowFuzzy?: boolean;
    /**
     * True while the tool's arguments are still streaming in. Strategies that
     * accept free-form text input (apply_patch, hashline) trim the trailing
     * partial line so per-character growth of an in-flight `+added` line does
     * not flicker in the preview.
     */
    isStreaming?: boolean;
}
export interface EditStreamingStrategy<Args = unknown> {
    /**
     * Return the args restricted to edits that are "complete enough" to
     * compute a diff against. Strategies drop the trailing incomplete entry
     * when `partialJson` indicates its closing `}` hasn't arrived yet.
     */
    extractCompleteEdits(args: Args, partialJson: string | undefined): Args;
    /**
     * Compute diff(s) for the given partial args. Returns `null` when args
     * do not yet carry enough structure to compute anything.
     */
    computeDiffPreview(args: Args, ctx: StreamingDiffContext): Promise<PerFileDiffPreview[] | null>;
    /**
     * Rendered inline while the diff hasn't been computed yet (or when the
     * compute returned `null` because args are still too partial).
     */
    renderStreamingFallback(args: Args, uiTheme: Theme): string;
    /**
     * Project the (potentially partial) args onto the plain text the edit
     * introduces into files — added lines without patch grammar — so stream
     * matchers (TTSR rules) can run source-level patterns against real content
     * instead of the mode-specific wire format. Returns `undefined` when the
     * args don't yet carry any content.
     */
    matcherDigest(args: Args): string | undefined;
}
/**
 * Given an edits array parsed from partial JSON, drop the last entry when the
 * corresponding object in `partialJson` does not yet end with a closed `}`.
 *
 * This guards against `partial-json` silently coercing truncated tails like
 * `"write":nu` / `"write":nul` into `{ write: null }`, which would make the
 * last entry render a spurious null-write error until the value finishes
 * streaming.
 */
export declare function dropIncompleteLastEdit<T>(edits: readonly T[], partialJson: string | undefined, listKey: string): T[];
export declare const EDIT_MODE_STRATEGIES: Record<EditMode, EditStreamingStrategy<unknown>>;
export { resolveEditMode };
