/** * Zoe SDK — Session persistence * * Provides composable persistence backends for storing conversation history. * Built-in "file" and "memory" backends are registered by default. Custom * backends (Redis, SQLite, etc.) can be registered via `registerBackend()`. * * Legacy `SessionStore`-based API is preserved for backward compatibility. */ import type { Message, PersistenceBackend, PersistenceConfig, ProviderType, SessionData, SessionStore } from "./types.js"; /** * File-backed persistence backend. Each session is stored as a JSON file * at `{basePath}/{sessionId}.json`. */ export declare class FilePersistenceBackend implements PersistenceBackend { readonly __persistenceBackend: true; private basePath; constructor(basePath: string); private filePath; private ensureDir; save(id: string, data: SessionData): Promise; load(id: string): Promise; delete(id: string): Promise; list(): Promise; private loadFromDisk; } /** * In-memory persistence backend backed by a Map. Useful for testing. */ export declare class MemoryPersistenceBackend implements PersistenceBackend { readonly __persistenceBackend: true; private store; save(id: string, data: SessionData): Promise; load(id: string): Promise; delete(id: string): Promise; list(): Promise; } export type BackendFactory = (config: PersistenceConfig) => PersistenceBackend; /** * Register a custom persistence backend factory. * * @param type Unique backend identifier (e.g., "redis", "sqlite") * @param factory Factory function that creates a `PersistenceBackend` from config */ export declare function registerBackend(type: string, factory: BackendFactory): void; /** * Create a persistence backend from a config object. * Uses the `type` field to look up the registered factory. * * @throws Error if `type` is not registered */ export declare function createPersistenceBackend(config: PersistenceConfig): PersistenceBackend; /** * Persist a session's messages to the backend. * * Single source of truth for the save step shared by all adapters (SDK, CLI, * Server). The backend owns `createdAt` (assigns it on first save, preserves * it on overwrite — see FilePersistenceBackend / MemoryPersistenceBackend) and * merges optional `provider`/`model`/`metadata` fields, so callers only pass * what they know. Adapters that don't track provider/model (the SDK) omit them * and the persisted values are left untouched. */ export declare function persistSession(backend: PersistenceBackend, sessionId: string, messages: Message[], opts?: { provider?: ProviderType; model?: string; metadata?: Record; }): Promise; /** * @deprecated Use `createPersistenceBackend({ type: "file", path })` instead. */ export declare function createSessionStore(path?: string): SessionStore; /** * @deprecated Use `createPersistenceBackend({ type: "memory" })` instead. */ export declare function createMemoryStore(): SessionStore;