import { a as GQP } from '../../engine-CGhQCS5X.js'; import { y as ToolCallParams, z as ToolCallResult } from '../../types-CqJN-Ev5.js'; /** * LangChain Bridge for GQP * Creates LangChain tools from GQP graph */ /** * LangChain tool options */ interface LangChainBridgeOptions { /** Custom tool name */ name?: string; /** Custom description */ description?: string; /** Description style */ descriptionStyle?: "concise" | "verbose"; /** Max traversal depth */ maxDepth?: number; /** Enable cursor for session continuity */ enableCursor?: boolean; } /** * Create a LangChain DynamicStructuredTool from GQP * * @example * ```typescript * import { createTool } from '@mzhub/gqp/langchain'; * import { ChatOpenAI } from 'langchain/chat_models/openai'; * * const tool = createTool(graph); * * const agent = createToolCallingAgent({ * llm: new ChatOpenAI({ modelName: 'gpt-4' }), * tools: [tool] * }); * ``` */ declare function createTool(graph: GQP, options?: LangChainBridgeOptions): Promise; /** * Create multiple LangChain tools (one per action) for simpler agent interactions */ declare function createActionTools(graph: GQP, options?: LangChainBridgeOptions): Promise; /** * Create a simple function wrapper for use with LangChain * This is useful when you want to handle the tool definition yourself */ declare function createToolFunction(graph: GQP): (params: ToolCallParams) => Promise; /** * Get tool definition in LangChain format */ declare function getToolDefinition(graph: GQP, options?: LangChainBridgeOptions): { name: string; description: string; parameters: object; }; interface WrappedTool { /** The actual tool instance (DynamicStructuredTool or similar) */ tool: unknown; /** Tool name */ name: string; /** Tool description */ description: string; /** Tool schema/parameters (zod schema) */ schema?: unknown; } /** * A node in the tool graph */ interface ToolGraphNode { /** Human-readable description of this node */ description?: string; /** Map of operation names to tools */ tools: Record; /** Relations to other nodes */ relations?: Record; } /** * Full tool graph configuration */ interface ToolGraph { [nodeName: string]: ToolGraphNode; } /** * Configuration for wrapTools */ interface WrapToolsConfig { /** The tool graph structure */ graph: ToolGraph; /** Custom tool name (default: navigate_tools) */ toolName?: string; /** Custom tool description */ toolDescription?: string; } /** * Result from tool wrapper operations */ interface WrapperResult { [key: string]: unknown; } /** * Tool Graph Wrapper - the core engine for tool consolidation */ declare class ToolGraphWrapper { private graph; private toolIndex; constructor(graph: ToolGraph); /** * Build an index of all tools for fast lookup */ private buildIndex; /** * Explore: Show available nodes */ explore(): WrapperResult; /** * Navigate: Show operations for a specific node */ navigate(nodeName: string): WrapperResult; /** * Execute: Run the actual tool */ execute(nodeName: string, operation: string, params?: Record): Promise; /** * Get suggestions for next actions based on current node */ private getSuggestions; /** * Extract tool info from various tool formats */ private extractToolInfo; /** * Convert zod schema to simple parameter description */ private schemaToParams; /** * Get tool definition for the wrapper */ getToolDefinition(name: string, description: string): { name: string; description: string; inputSchema: object; }; /** * Handle a tool call */ handleToolCall(params: { action: "explore" | "navigate" | "execute"; node?: string; operation?: string; params?: Record; }): Promise; } /** * Wrap existing LangChain tools into ONE navigable interface * * @example * ```typescript * import { wrapTools } from '@mzhub/gqp/langchain'; * import { * searchProductsTool, * getProductDetailsTool, * searchVendorsTool, * listOrdersTool * } from './tools'; * * const gqpTool = await wrapTools({ * graph: { * Product: { * description: 'Product catalog', * tools: { * search: searchProductsTool, * getDetails: getProductDetailsTool * }, * relations: { * vendor: 'Vendor' * } * }, * Vendor: { * description: 'Vendor search', * tools: { * search: searchVendorsTool * } * }, * Order: { * description: 'Order history', * tools: { * list: listOrdersTool * } * } * } * }); * * // Now use ONE tool instead of many * const agent = createReactAgent({ * llm, * tools: [ * gqpTool, // Wraps all read tools * createOrderTool, // Keep action tools separate * ] * }); * ``` */ declare function wrapTools(config: WrapToolsConfig): Promise; /** * Create wrapper without LangChain dependency (for other frameworks) */ declare function createToolWrapper(config: WrapToolsConfig): ToolGraphWrapper; export { type LangChainBridgeOptions, type ToolGraph, type ToolGraphNode, ToolGraphWrapper, type WrapToolsConfig, type WrappedTool, createActionTools, createTool, createToolFunction, createToolWrapper, getToolDefinition, wrapTools };