import { Context, Effect, Layer } from 'effect'; import type { Prompt } from '@effect/ai'; import type { ConversationContext, ConversationMetadata, ConversationPolicy, ContextStorage, SessionSummary } from './context'; import { ContextNotFoundError, ContextStorageError } from './errors'; /** * ContextStorageService interface for Effect-based conversation management */ export interface ContextStorageService { /** * Generate a unique conversation ID */ generateConversationId(): Effect.Effect; /** * Get or create a conversation context * In strict mode, throws if conversationId provided but not found */ getContext(conversationId?: string, options?: { strict?: boolean; }): Effect.Effect; /** * Get conversation context by ID (returns null if not found) */ getContextById(conversationId: string): Effect.Effect; /** * Add a message to the conversation context */ addMessage(conversationId: string, message: Prompt.MessageEncoded): Effect.Effect; /** * Add multiple messages to the conversation context */ addMessages(conversationId: string, messages: Prompt.MessageEncoded[]): Effect.Effect; /** * Get conversation history */ getHistory(conversationId: string): Effect.Effect; /** * Update conversation metadata */ updateMetadata(conversationId: string, metadata: Partial): Effect.Effect; /** * Clear conversation context */ clearContext(conversationId: string): Effect.Effect; /** * Clear and return whether context existed */ resetContext(conversationId: string): Effect.Effect; /** * Clear all conversation contexts */ clearAll(): Effect.Effect; /** * Set default policy for new contexts */ setDefaultPolicy(policy: ConversationPolicy): Effect.Effect; /** * Set a policy for an existing context */ setContextPolicy(conversationId: string, policy: ConversationPolicy): Effect.Effect; /** * Replace the storage adapter at runtime (e.g. swap in-memory for SQLite/Postgres). */ replaceStorage(adapter: ContextStorage): Effect.Effect; /** * List session summaries from the currently active storage adapter. * Returns an empty array when no persistent adapter is configured * (the default in-memory storage is not queryable this way). */ listSessions(): Effect.Effect; } export declare const ContextStorageService: Context.Tag; /** Live layer providing ContextStorageService (in-memory). */ export declare const ContextStorageServiceLive: Layer.Layer; /** Live layer backed by an explicitly owned external adapter. */ export declare const ContextStorageServiceLiveWithAdapter: (adapter: ContextStorage) => Layer.Layer; //# sourceMappingURL=service.d.ts.map