UNPKG

@hashgraphonline/conversational-agent

Version:

Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera. https://hol.org

108 lines (106 loc) 3.5 kB
import { ParameterPreprocessingCallback } from './form-aware-agent-executor'; import { BaseAgent, ConversationContext, ChatResponse, OperationalMode, UsageStats } from '../base-agent'; import { MCPConnectionStatus } from '../mcp/types'; import { FormSubmission } from '../forms/types'; export declare class LangChainAgent extends BaseAgent { private executor; private systemMessage; private mcpManager?; private smartMemory; private mcpConnectionStatus; private toolRegistry; private executionPipeline; private formEngine; private addToolRawToMemory; private persistToolRaw; private persistIntermediateSteps; private pendingParameterPreprocessingCallback; /** * Get inscription tool by capability instead of hardcoded name */ private getInscriptionTool; /** * Execute a tool directly with parameters, optionally using ExecutionPipeline */ private executeToolDirect; /** * Create a standard ChatResponse from tool output */ private createToolResponse; /** * Handle TOOL_EXECUTION format messages */ private handleToolExecution; /** * Handle direct tool execution commands */ private handleDirectToolExecution; /** * Handle JSON format tool calls and form submissions */ private handleJsonToolCalls; /** * Handle content-ref messages for inscription tools */ private handleContentRefMessages; /** * Process executor result and format response */ private processExecutorResult; /** * Normalize context messages into LangChain message instances and load into memory */ /** * Loads context messages into memory, merging with existing messages */ private loadContextMessages; boot(): Promise<void>; chat(message: string, context?: ConversationContext): Promise<ChatResponse>; shutdown(): Promise<void>; switchMode(mode: OperationalMode): void; getUsageStats(): UsageStats; getUsageLog(): UsageStats[]; clearUsageStats(): void; getMCPConnectionStatus(): Map<string, MCPConnectionStatus>; /** * Processes form submission and continues with tool execution */ processFormSubmission(submission: FormSubmission, context?: ConversationContext): Promise<ChatResponse>; /** * Check if the agent has pending forms that need to be completed */ hasPendingForms(): boolean; /** * Get information about pending forms */ getPendingFormsInfo(): Array<{ formId: string; toolName: string; }>; private createAgentKit; private createExecutor; /** * Set parameter preprocessing callback for tool parameter format conversion */ setParameterPreprocessingCallback(callback: ParameterPreprocessingCallback | undefined): void; private handleError; private initializeMCP; /** * Connect to MCP servers asynchronously after agent boot with background timeout pattern */ connectMCPServers(): Promise<void>; /** * Connect to a single MCP server in background with timeout */ private connectServerInBackground; /** * Detects and processes HashLink blocks from tool responses * @param parsedResponse - The parsed JSON response from a tool * @returns Metadata object containing hashLinkBlock if detected */ private processHashLinkBlocks; /** * Check if a string is valid JSON */ private isJSON; }