import { AgentCoreConfig, LLMConfig, Instruction, LoggingConfig, QueryPreProcessor } from "./configs"; import { Message } from "./Message"; import { Tool, ToolOptions, ToolOutput } from "./Tool"; import { ExecutionContext } from "./ExecutionContext"; import { OpenAI } from "openai"; import { IAgentPromptTemplate } from "./IPromptTemplate"; import { Session } from "./Session"; import { SessionContext } from "./SessionContext"; import { IClassifier } from "./IClassifier"; import { ConversationDataHandler } from "./ConversationDataHandler"; export type StreamCallback = (delta: string, control?: { type: 'completion'; reason: string; }, sessionId?: string) => void; export declare class AgentCore { id: string; name: string; role: string; goal: string; capabilities: string; instructions: Instruction[]; llmConfig: LLMConfig | null; executionContext: ExecutionContext; promptTemplate: IAgentPromptTemplate; private streamCallbacks; streamBuffer: string; llmClient: OpenAI; toolRegistry: Map>; instructionToolMap: { [key: string]: string; }; queryPreProcessor: QueryPreProcessor | null; private memories; private inbox; private promptManager; private sessionContextManager; private classifier; private conversationHandlers; private shutdownSubject; private logger; private promptLogger; constructor(config: AgentCoreConfig, llmConfig: LLMConfig, promptTemplate: IAgentPromptTemplate, classifier: IClassifier, loggingConfig?: LoggingConfig); getCapabilities(): string; setQueryPreProcessor(processor: QueryPreProcessor | null): void; addInstruction(name: string, description: string, schemaTemplate?: string): void; getInstructions(): Instruction[]; getInstructionByName(name: string): Instruction | undefined; /** * Register a conversation data handler * @param handler The handler to register */ registerConversationDataHandler(handler: ConversationDataHandler): void; /** * Unregister a conversation data handler * @param handler The handler to unregister * @returns Whether the handler was found and removed */ unregisterConversationDataHandler(handler: ConversationDataHandler): boolean; /** * Process message through all registered conversation handlers * @param message The message to process * @private */ private processConversationHandlers; handleInstructionWithTool(instructionName: string, toolName: string): void; getToolForInstruction(instructionName: string): string | undefined; receive(message: Message): Promise; start(): Promise; setAgentPromptTemplate(promptTemplate: IAgentPromptTemplate): void; debugPrompt(sessionContext: SessionContext, message: string, context: any): Object; private cleanLLMResponse; handleLLMResponse(response: string, session: Session): void; registerStreamCallback(callback: StreamCallback): void; removeStreamCallback(callback: StreamCallback): void; processStreamBuffer(force?: boolean, sessionId?: string): void; private processMessage; private isRecoverableLLMError; private calculateBackoff; private sleep; private escalateLLMErrorToUser; private remember; getOrCreateSessionContext(message: Message): Promise; private promptLLM; createSession(owner: string, description: string): Promise; getSessionContext(sessionId: string): SessionContext; private initSessionContext; /** * Reconstructs complete tool calls from stream chunks. * OpenAI streams tool calls piece by piece, so we need to accumulate and reconstruct them. */ private reconstructToolCalls; registerTool(tool: Tool): void; getTool(name: string): Tool | undefined; toJSON(): string; log(sessionId: string, message: string): void; setLoggingConfig(loggingConfig: LoggingConfig): void; shutdown(): Promise; handleError(error: Error): void; run(): Promise; hasToolForCurrentInstruction(messageType?: string): boolean; private static formatHistory; private static parseNestedJson; }