import type { TSchema } from "@oh-my-pi/pi-ai"; import type { CustomTool, CustomToolResult } from "../extensibility/custom-tools/types.js"; import { type CallMcpOptions } from "../mcp/json-rpc.js"; import type { ExaSearchResponse, MCPTool, MCPToolWrapperConfig } from "./types.js"; type MCPWrappedToolDetails = { response?: ExaSearchResponse; error?: string; toolName?: string; raw?: unknown; }; /** Find EXA_API_KEY from Bun.env or .env files */ export declare function findApiKey(): string | null; /** * Normalize tools/call payloads across MCP servers. * * Exa currently returns different shapes depending on deployment/environment: * - direct payload in result * - structured payload under result.structuredContent / result.data / result.result * - JSON payload embedded as text in result.content[] */ export declare function normalizeMcpToolPayload(payload: unknown): unknown; /** Fetch available tools from Exa MCP */ export declare function fetchExaTools(apiKey: string | null, toolNames: string[]): Promise; /** Fetch available tools from Websets MCP */ export declare function fetchWebsetsTools(apiKey: string): Promise; /** Call a tool on Exa MCP (simplified: toolName as first arg for easier use) */ export declare function callExaTool(toolName: string, args: Record, apiKey: string | null, options?: CallMcpOptions): Promise; /** Call a tool on Websets MCP */ export declare function callWebsetsTool(apiKey: string, toolName: string, args: Record): Promise; /** Format search results for LLM */ export declare function formatSearchResults(data: ExaSearchResponse): string; /** * Format a non-search MCP response as human-readable text. * Handles objects, arrays, primitives, and common MCP response shapes. */ export declare function formatGenericResponse(data: unknown): string; /** Check if result is a search response */ export declare function isSearchResponse(data: unknown): data is ExaSearchResponse; /** Fetch and cache MCP tool schema */ export declare function fetchMCPToolSchema(apiKey: string, mcpToolName: string, isWebsetsTool?: boolean): Promise; /** * CustomTool dynamically created from MCP tool metadata. * * This allows tools to be generated from MCP server schemas without hardcoding, * reducing drift when MCP servers add new parameters. */ export declare class MCPWrappedTool implements CustomTool { private readonly config; readonly parameters: TSchema; readonly description: string; readonly name: string; readonly label: string; constructor(config: MCPToolWrapperConfig, parameters: TSchema, description: string); execute(_toolCallId: string, params: unknown, _onUpdate?: unknown, _ctx?: unknown, _signal?: AbortSignal): Promise>; } /** * Create a CustomTool by fetching schema from MCP server. * * Falls back to provided fallback schema if MCP fetch fails. */ export declare function createMCPToolFromServer(apiKey: string, config: MCPToolWrapperConfig, fallbackSchema: TSchema, fallbackDescription: string): Promise; export {};