/** * Graph Context Manager — Persists conversation history as entities in the Trellis graph. * * Implements the ContextManager interface but backs every message with a * kernel entity, making conversations queryable via EQL-S and persistent * across sessions and devices. * * @module trellis/plugins/agent-memory */ import type { LLMMessage } from '../../llm/types.js'; import type { ContextManager } from '../../context/types.js'; import type { TrellisKernel } from '../../core/kernel/trellis-kernel.js'; export interface ConversationOptions { title: string; agentId?: string; model?: string; createdBy?: string; } export declare class GraphContextManager implements ContextManager { private kernel; private conversationId; private messageCounter; /** * In-memory cache of active messages for fast getHistory() reads. * Always kept in sync with the graph via addMessage/prune/resume. */ private cache; /** In-flight graph writes from fire-and-forget addMessage/prune calls. */ private pendingWrites; constructor(kernel: TrellisKernel); /** * Create a new conversation entity and set it as the active context. * Returns the conversation entity ID. */ createConversation(opts: ConversationOptions): Promise; /** * Resume an existing conversation by loading its messages from the graph. */ resumeConversation(conversationId: string): Promise; /** * Get the active conversation ID, or null if none is set. */ getConversationId(): string | null; /** * Archive the active conversation and clear local state. */ archiveConversation(): Promise; addMessage(message: LLMMessage): void; getHistory(): LLMMessage[]; prune(targetTokenCount: number): Promise; summarize(): Promise; injectRagContext(query: string, limit?: number): Promise; calculateTokenCount(message: LLMMessage): number; /** * List all conversations, optionally filtered by status. */ listConversations(status?: 'active' | 'archived'): Array<{ id: string; title: string; status: string; createdAt: string; messageCount: number; }>; /** * Get the total message count for the active conversation. */ getMessageCount(): number; /** * Get the total estimated token count for the active conversation. */ getTotalTokenCount(): number; /** Wait for in-flight graph writes (tests and graceful shutdown). */ awaitPersistence(): Promise; private trackWrite; /** * Load messages from the graph for a given conversation, sorted by timestamp. */ private _loadMessagesFromGraph; } //# sourceMappingURL=graph-context-manager.d.ts.map