import { FunctionDeclaration } from '@google/generative-ai'; export { formatResult } from './client.js'; import { d as WarpGrepToolConfig, b as WarpGrepResult, g as GitHubSearchToolConfig, h as GitHubReadFileToolConfig, e as GitHubReadFileInput, f as GitHubReadFileResult } from '../../types-qwD753FR.js'; import './agent/types.js'; import '../utils/resilience.js'; import '../../core/client.js'; import '../../core/resource.js'; import './providers/types.js'; /** * Google Gemini SDK adapter for morph-warp-grep tool * * Requires @google/generative-ai as a peer dependency. * Install with: npm install @google/generative-ai */ /** * Gemini-native warp grep function declaration * * @example * ```typescript * import { GoogleGenerativeAI } from '@google/generative-ai'; * import { warpGrepFunctionDeclaration, execute } from '@morphllm/morphsdk/tools/warp-grep/gemini'; * * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY); * const model = genAI.getGenerativeModel({ * model: 'gemini-2.0-flash', * tools: [{ functionDeclarations: [warpGrepFunctionDeclaration] }] * }); * * const chat = model.startChat(); * const result = await chat.sendMessage('Find authentication middleware'); * * // Handle function call * const call = result.response.functionCalls()?.[0]; * if (call) { * const searchResult = await execute(call.args, { repoRoot: '.' }); * console.log(searchResult); * } * ``` */ declare const warpGrepFunctionDeclaration: FunctionDeclaration; /** * Execute warp grep search * * @param input - Tool input with search_term * @param config - Configuration with repoRoot and optional provider * @returns Search results */ declare function execute(input: { search_term: string; } | string, config: WarpGrepToolConfig): Promise; /** * Gemini tool with execute method attached */ interface GeminiWarpGrepTool extends FunctionDeclaration { execute: (input: unknown) => Promise; formatResult: (result: WarpGrepResult) => string; } /** * Create a custom warp grep tool with configuration and methods * * @param config - Configuration options * @returns Function declaration with execute and formatResult methods * * @example Local usage * ```typescript * import { GoogleGenerativeAI } from '@google/generative-ai'; * import { createMorphWarpGrepTool } from '@morphllm/morphsdk/tools/warp-grep/gemini'; * * const tool = createMorphWarpGrepTool({ repoRoot: '.' }); * * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY); * const model = genAI.getGenerativeModel({ * model: 'gemini-2.0-flash', * tools: [{ functionDeclarations: [tool] }] * }); * * const chat = model.startChat(); * const result = await chat.sendMessage('Find authentication middleware'); * * // Handle function call * const call = result.response.functionCalls()?.[0]; * if (call && call.name === tool.name) { * const searchResult = await tool.execute(call.args); * console.log(tool.formatResult(searchResult)); * * // Send result back to model * await chat.sendMessage([{ * functionResponse: { * name: call.name, * response: { result: tool.formatResult(searchResult) } * } * }]); * } * ``` * * @example Remote sandbox (E2B, Modal, etc.) * ```typescript * const tool = createMorphWarpGrepTool({ * repoRoot: '/home/repo', * remoteCommands: { * grep: async (pattern, path) => (await sandbox.run(`rg '${pattern}' '${path}'`)).stdout, * read: async (path, start, end) => (await sandbox.run(`sed -n '${start},${end}p' '${path}'`)).stdout, * listDir: async (path, maxDepth) => (await sandbox.run(`find '${path}' -maxdepth ${maxDepth}`)).stdout, * }, * }); * ``` */ declare function createWarpGrepTool(config: WarpGrepToolConfig): GeminiWarpGrepTool; declare const createMorphWarpGrepTool: typeof createWarpGrepTool; /** * Create a GitHub search tool for Google Gemini SDK * * @param config - Configuration options (morphApiKey, morphApiUrl, codeSearchUrl, timeout) * @returns Gemini FunctionDeclaration with execute and formatResult methods * * @example * ```typescript * import { GoogleGenerativeAI } from '@google/generative-ai'; * import { createGitHubSearchTool } from '@morphllm/morphsdk/tools/warp-grep/gemini'; * * const tool = createGitHubSearchTool({ morphApiKey: process.env.MORPH_API_KEY }); * * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY); * const model = genAI.getGenerativeModel({ * model: 'gemini-2.0-flash', * tools: [{ functionDeclarations: [tool] }] * }); * * // Execute * const result = await tool.execute({ search_term: 'auth middleware', github_url: 'https://github.com/vercel/next.js' }); * console.log(tool.formatResult(result)); * ``` */ declare function createGitHubSearchTool(config: GitHubSearchToolConfig): FunctionDeclaration & { execute: (input: { search_term: string; github_url?: string; owner_repo?: string; branch?: string; }) => Promise; formatResult: (result: WarpGrepResult) => string; }; /** * Create a GitHub read file tool for Google Gemini SDK * * @param config - Optional configuration (timeout) * @returns Gemini FunctionDeclaration with execute and formatResult methods * * @example * ```typescript * import { GoogleGenerativeAI } from '@google/generative-ai'; * import { createGitHubReadFileTool } from '@morphllm/morphsdk/tools/warp-grep/gemini'; * * const tool = createGitHubReadFileTool(); * * const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY); * const model = genAI.getGenerativeModel({ * model: 'gemini-2.0-flash', * tools: [{ functionDeclarations: [tool] }] * }); * * const result = await tool.execute({ github: 'vercel/next.js', path: 'package.json' }); * console.log(tool.formatResult(result)); * ``` */ declare function createGitHubReadFileTool(config?: GitHubReadFileToolConfig): FunctionDeclaration & { execute: (input: GitHubReadFileInput) => Promise; formatResult: (result: GitHubReadFileResult) => string; }; export { type GeminiWarpGrepTool, createGitHubReadFileTool, createGitHubSearchTool, createMorphWarpGrepTool, createWarpGrepTool, warpGrepFunctionDeclaration as default, execute, warpGrepFunctionDeclaration };