import {
  EDIT_FILE_SYSTEM_PROMPT,
  EDIT_FILE_TOOL_DESCRIPTION
} from "./chunk-63WE2C5R.js";
import {
  executeEditFile
} from "./chunk-SFIMDGVL.js";
import {
  __export
} from "./chunk-PZ5AY32C.js";

// tools/fastapply/vercel.ts
var vercel_exports = {};
__export(vercel_exports, {
  createEditFileTool: () => createEditFileTool,
  default: () => vercel_default,
  editFileTool: () => editFileTool,
  getSystemPrompt: () => getSystemPrompt
});
import { tool } from "ai";
import { z } from "zod";
var editFileSchema = z.object({
  target_filepath: z.string().describe("The path of the target file to modify"),
  instruction: z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
  code_edit: z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
});
var editFileTool = tool({
  description: EDIT_FILE_TOOL_DESCRIPTION,
  inputSchema: editFileSchema,
  execute: async (params) => {
    const result = await executeEditFile({
      target_filepath: params.target_filepath,
      instruction: params.instruction,
      code_edit: params.code_edit
    });
    if (!result.success) {
      throw new Error(`Failed to edit file: ${result.error}`);
    }
    return {
      success: true,
      filepath: result.filepath,
      changes: result.changes,
      udiff: result.udiff
    };
  }
});
function getSystemPrompt() {
  return EDIT_FILE_SYSTEM_PROMPT;
}
function createEditFileTool(config = {}) {
  const schema = z.object({
    target_filepath: z.string().describe("The path of the target file to modify"),
    instruction: z.string().describe("A single sentence written in the first person describing what the agent is changing. Used to help disambiguate uncertainty in the edit."),
    code_edit: z.string().describe("Specify ONLY the precise lines of code that you wish to edit. Use `// ... existing code ...` for unchanged sections.")
  });
  return tool({
    description: config.description || EDIT_FILE_TOOL_DESCRIPTION,
    inputSchema: schema,
    execute: async (params) => {
      const result = await executeEditFile(
        {
          target_filepath: params.target_filepath,
          instruction: params.instruction,
          code_edit: params.code_edit
        },
        config
      );
      if (!result.success) {
        throw new Error(`Failed to edit file: ${result.error}`);
      }
      return {
        success: true,
        filepath: result.filepath,
        changes: result.changes,
        udiff: result.udiff
      };
    }
  });
}
var vercel_default = editFileTool;

export {
  editFileTool,
  getSystemPrompt,
  createEditFileTool,
  vercel_default,
  vercel_exports
};
//# sourceMappingURL=chunk-23FOG3FG.js.map