import { ChatCompletionTool } from 'openai/resources/chat/completions';
import { CodebaseSearchConfig, CodebaseSearchInput, CodebaseSearchResult } from './types.js';
import '../utils/resilience.js';

/**
 * OpenAI SDK adapter for codebase_search tool
 */

/**
 * Direct codebase_search tool definition
 * Use this when you want to pass config at execute time
 */
declare const codebaseSearchTool: ChatCompletionTool;
/**
 * Create OpenAI-native codebase_search tool with execute and formatResult methods
 *
 * @param config - Configuration with repoId
 * @returns OpenAI ChatCompletionTool definition with methods
 *
 * @example
 * ```ts
 * import OpenAI from 'openai';
 * import { createCodebaseSearchTool } from 'morphsdk/tools/openai';
 *
 * const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
 * const tool = createCodebaseSearchTool({ repoId: 'my-project' });
 *
 * const response = await client.chat.completions.create({
 *   model: "gpt-4o",
 *   tools: [tool], // tool itself is the ChatCompletionTool
 *   messages: [{ role: "user", content: "Find authentication code" }]
 * });
 *
 * // Execute and format
 * const result = await tool.execute(toolCallArgs);
 * const formatted = tool.formatResult(result);
 * ```
 */
declare function createCodebaseSearchTool(config: CodebaseSearchConfig): ChatCompletionTool & {
    execute: (input: CodebaseSearchInput | string) => Promise<CodebaseSearchResult>;
    formatResult: (result: CodebaseSearchResult) => string;
    getSystemPrompt: () => string;
};
/**
 * Execute codebase_search tool call
 *
 * @param input - Tool input from GPT (parsed from tool_calls)
 * @param config - Configuration with repoId (REQUIRED)
 * @returns Search results
 *
 * @example
 * ```ts
 * // Handle tool calls from GPT:
 * if (response.choices[0].message.tool_calls) {
 *   for (const toolCall of response.choices[0].message.tool_calls) {
 *     const args = JSON.parse(toolCall.function.arguments);
 *     const result = await execute(args, { repoId: 'my-project' });
 *     console.log(`Found ${result.results.length} matches`);
 *   }
 * }
 * ```
 */
declare function execute(input: CodebaseSearchInput, config: CodebaseSearchConfig): Promise<CodebaseSearchResult>;
/**
 * Format search results for GPT
 *
 * @param result - Search result from endpoint
 * @returns Formatted string for tool message
 */
declare function formatResult(result: CodebaseSearchResult): string;
/**
 * Get the system prompt for codebase_search usage
 *
 * @returns System prompt to guide GPT
 */
declare function getSystemPrompt(): string;
/**
 * Default export for convenience
 */
declare const _default: {
    createCodebaseSearchTool: typeof createCodebaseSearchTool;
    execute: typeof execute;
    formatResult: typeof formatResult;
    getSystemPrompt: typeof getSystemPrompt;
};

export { codebaseSearchTool, createCodebaseSearchTool, _default as default, execute, formatResult, getSystemPrompt };
