/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { BaseDeclarativeTool, type ToolInvocation, type ToolResult } from './tools.js';
import type { MessageBus } from '../confirmation-bus/message-bus.js';
import { ToolErrorType } from './tool-error.js';
import { type Config } from '../config/config.js';
import { type ModifiableDeclarativeTool, type ModifyContext } from './modifiable-tool.js';
export declare function applyReplacement(currentContent: string | null, oldString: string, newString: string, isNewFile: boolean): string;
interface ReplacementContext {
    params: EditToolParams;
    currentContent: string;
    abortSignal: AbortSignal;
}
interface ReplacementResult {
    newContent: string;
    occurrences: number;
    finalOldString: string;
    finalNewString: string;
}
export declare function calculateReplacement(context: ReplacementContext): Promise<ReplacementResult>;
export declare function getErrorReplaceResult(params: EditToolParams, occurrences: number, expectedReplacements: number, finalOldString: string, finalNewString: string): {
    display: string;
    raw: string;
    type: ToolErrorType;
} | undefined;
/**
 * Parameters for the Edit tool
 */
export interface EditToolParams {
    /**
     * The absolute path to the file to modify
     */
    file_path: string;
    /**
     * The text to replace
     */
    old_string: string;
    /**
     * The text to replace it with
     */
    new_string: string;
    /**
     * The instruction for what needs to be done.
     */
    instruction: string;
    /**
     * Whether the edit was modified manually by the user.
     */
    modified_by_user?: boolean;
    /**
     * Initially proposed string.
     */
    ai_proposed_string?: string;
}
/**
 * Implementation of the Edit tool logic
 */
export declare class SmartEditTool extends BaseDeclarativeTool<EditToolParams, ToolResult> implements ModifiableDeclarativeTool<EditToolParams> {
    private readonly config;
    static readonly Name = "replace";
    constructor(config: Config, messageBus?: MessageBus);
    /**
     * Quickly checks if the file path can be resolved directly against the workspace root.
     * @param filePath The relative file path to check.
     * @returns The absolute path if the file exists, otherwise null.
     */
    private findDirectPath;
    /**
     * Searches for a file across all configured workspace directories.
     * @param filePath The file path (can be partial) to search for.
     * @returns A list of absolute paths for all matching files found.
     */
    private findAmbiguousPaths;
    /**
     * Attempts to correct a relative file path to an absolute path.
     * This function modifies `params.file_path` in place if successful.
     * @param params The tool parameters containing the file_path to correct.
     * @returns An error message string if correction fails, otherwise null.
     */
    private correctPath;
    /**
     * Validates the parameters for the Edit tool
     * @param params Parameters to validate
     * @returns Error message string or null if valid
     */
    protected validateToolParamValues(params: EditToolParams): string | null;
    protected createInvocation(params: EditToolParams, messageBus?: MessageBus): ToolInvocation<EditToolParams, ToolResult>;
    getModifyContext(_: AbortSignal): ModifyContext<EditToolParams>;
}
export {};
