/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { BaseDeclarativeTool, type ToolInvocation, type ToolResult } from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { type Config } from '../config/config.js'; import { type ModifiableDeclarativeTool, type ModifyContext } from './modifiable-tool.js'; 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; 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 implements ModifiableDeclarativeTool { private readonly config; static readonly Name: "edit"; constructor(config: Config); /** * 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): ToolInvocation; getModifyContext(_: AbortSignal): ModifyContext; } export {};