import { ChatCompletionTool } from 'openai/resources/chat/completions'; import { EditFileInput, EditFileConfig, EditFileResult } from './tools/fastapply/types.js'; /** * OpenAI SDK adapter for edit_file tool */ /** * OpenAI-native tool definition for edit_file * * @example * ```ts * import OpenAI from 'openai'; * import { editFileTool } from 'morphsdk/tools/openai'; * * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); * * const response = await client.chat.completions.create({ * model: "gpt-4o", * tools: [editFileTool], * messages: [{ role: "user", content: "Fix the bug in app.ts" }] * }); * ``` */ declare const editFileTool: ChatCompletionTool; /** * Execute an edit_file tool call * * @param input - The tool input from GPT (parsed from tool_calls) * @param config - Optional configuration * @returns The result of the edit operation * * @example * ```ts * const args = JSON.parse(toolCall.function.arguments); * const result = await execute(args); * console.log('Changes applied:', result.udiff); * ``` */ declare function execute(input: EditFileInput, config?: EditFileConfig): Promise; /** * Get the system prompt for edit_file usage * * Add this to your system message to guide GPT on using edit_file properly. * * @example * ```ts * const response = await client.chat.completions.create({ * model: "gpt-4o", * messages: [ * { role: "system", content: getSystemPrompt() }, * { role: "user", content: "Fix bugs" } * ], * tools: [editFileTool] * }); * ``` */ declare function getSystemPrompt(): string; /** * Format the result for passing back to GPT * * @param result - The edit result * @returns Formatted string for tool message */ declare function formatResult(result: EditFileResult): string; /** * Create a custom edit_file tool with configuration and methods * * @param config - Configuration options * @returns Tool definition with execute and formatResult methods * * @example * ```ts * import OpenAI from 'openai'; * import { createEditFileTool } from 'morphsdk/tools/fastapply/openai'; * * const tool = createEditFileTool({ * baseDir: './src', * generateUdiff: true, * description: 'Custom tool description for your use case' * }); * * const client = new OpenAI(); * * const response = await client.chat.completions.create({ * model: 'gpt-4o', * tools: [tool], // tool itself is the ChatCompletionTool * messages: [{ role: 'user', content: 'Fix bug in app.ts' }] * }); * * // Execute and format * const result = await tool.execute(toolCallArgs); * const formatted = tool.formatResult(result); * ``` */ declare function createEditFileTool(config?: EditFileConfig): ChatCompletionTool & { execute: (input: EditFileInput | string) => Promise; formatResult: (result: EditFileResult) => string; getSystemPrompt: () => string; }; declare const openai_createEditFileTool: typeof createEditFileTool; declare const openai_editFileTool: typeof editFileTool; declare const openai_execute: typeof execute; declare const openai_formatResult: typeof formatResult; declare const openai_getSystemPrompt: typeof getSystemPrompt; declare namespace openai { export { openai_createEditFileTool as createEditFileTool, editFileTool as default, openai_editFileTool as editFileTool, openai_execute as execute, openai_formatResult as formatResult, openai_getSystemPrompt as getSystemPrompt }; } export { execute as a, createEditFileTool as c, editFileTool as e, formatResult as f, getSystemPrompt as g, openai as o };