import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "../agents/agent.js"; import type { Context } from "../aigne/context.js"; import type { MessagePayload } from "../aigne/message-queue.js"; import { MemoryRecorder, type MemoryRecorderInput, type MemoryRecorderOptions, type MemoryRecorderOutput } from "./recorder.js"; import { MemoryRetriever, type MemoryRetrieverInput, type MemoryRetrieverOptions, type MemoryRetrieverOutput } from "./retriever.js"; export interface Memory { id: string; sessionId?: string | null; content: unknown; createdAt: string; } export declare const newMemoryId: () => string; export interface MemoryAgentOptions extends Partial>, Pick { recorder?: MemoryRecorder | MemoryRecorderOptions["process"] | MemoryRecorderOptions; retriever?: MemoryRetriever | MemoryRetrieverOptions["process"] | MemoryRetrieverOptions; } /** * A specialized agent responsible for managing, storing, and retrieving memories within the agent system. * * MemoryAgent serves as a bridge between application logic and memory storage/retrieval mechanisms. * It delegates the actual memory operations to specialized recorder and retriever agents that * are attached as skills. This agent doesn't directly process messages like other agents but * instead provides memory management capabilities to the system. */ export declare class MemoryAgent extends Agent { tag: string; /** * Creates a new MemoryAgent instance. */ constructor(options: MemoryAgentOptions); private _retriever?; /** * Agent used for retrieving memories from storage. * * This retriever is automatically added to the agent's skills when set. * Setting a new retriever will remove any previously set retriever from skills. */ get retriever(): MemoryRetriever | undefined; set retriever(value: MemoryRetriever | undefined); private _recorder?; /** * Agent used for recording and storing new memories. * * This recorder is automatically added to the agent's skills when set. * Setting a new recorder will remove any previously set recorder from skills. */ get recorder(): MemoryRecorder | undefined; set recorder(value: MemoryRecorder | undefined); /** * Controls whether to automatically update the memory when agent call completes. * * When true, the agent will automatically record any relevant information * after completing operations, creating a history of interactions. */ autoUpdate?: boolean; /** * Indicates whether this agent can be directly called. * * MemoryAgent is designed to be used as a supporting component rather than * being directly invoked for processing, so this returns false. */ get isCallable(): boolean; /** * The standard message processing method required by the Agent interface. * * MemoryAgent doesn't directly process messages like other agents, so this method * throws an error when called. Use the specialized retrieve() and record() methods instead. */ process(_input: Message, _options: AgentInvokeOptions): Promise; /** * Retrieves memories based on the provided input criteria. * * Delegates the actual retrieval operation to the configured retriever agent. * * @param input - The retrieval parameters (can include search terms, limits, etc.) * @param context - The execution context * @returns A promise resolving to the retrieved memories * @throws Error - If no retriever has been initialized */ retrieve(input: MemoryRetrieverInput, context: Context): Promise; /** * Records new memories based on the provided input content. * * Delegates the actual recording operation to the configured recorder agent. * * @param input - The content to be recorded as memories * @param context - The execution context * @returns A promise resolving to the recorded memories * @throws Error - If no recorder has been initialized */ record(input: MemoryRecorderInput, context: Context): Promise; onMessage({ role, source, message, context }: MessagePayload): Promise; }