/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import * as Diff from 'diff'; import { BaseDeclarativeTool, type ToolInvocation, type ToolResult } from './tools.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; import { Config } from '../config/config.js'; /** * Type representing a parsed patch operation */ export type PatchOperation = Diff.StructuredPatch; /** * Classifies patch operations to determine which files have content writes. * Patches with hunks represent content modifications/creations. * Patches without hunks are treated as rename/delete-only operations. * * @param operations - Array of parsed patch operations * @returns Object containing content write file paths and boolean flag */ export declare function classifyPatchOperations(operations: PatchOperation[]): { contentWriteFiles: string[]; hasAnyContentWrites: boolean; }; /** * Parameters for the ApplyPatch tool */ export interface ApplyPatchToolParams { /** * The absolute path to the file to modify */ absolute_path?: string; /** * Alternative parameter name for absolute_path (for compatibility) * Not shown in schema - internal use only */ file_path?: string; /** * The unified diff format patch content to apply */ patch_content: string; /** * Whether the edit was modified manually by the user. */ modified_by_user?: boolean; /** * Initially proposed content. */ ai_proposed_content?: string; } /** * Implementation of the ApplyPatch tool logic */ export declare class ApplyPatchTool extends BaseDeclarativeTool { private readonly config; static readonly Name = "apply_patch"; constructor(config: Config, messageBus?: MessageBus); /** * Validates the parameters for the ApplyPatch tool */ protected validateToolParamValues(params: ApplyPatchToolParams): string | null; protected createInvocation(params: ApplyPatchToolParams, messageBus?: MessageBus): ToolInvocation; }