import type { SqliteDatabase, SqliteValue, StorageDescriptor } from "./database.js"; import type { RunJournal } from "./run-journal.js"; import type { SessionStore } from "./session/types.js"; export type SecretRef = { readonly env: string; } | { readonly file: string; }; export type AdapterOptions = Readonly>; export type RunJournalOption = { path: string; prefix?: string; } | { database: SqliteDatabase; prefix?: string; } | { memory: true; } | { adapter: string; options?: AdapterOptions; secrets?: Readonly>; prefix?: string; } | RunJournal; export type StorageSelection = { readonly kind: "memory"; } | { readonly kind: "jsonl"; readonly dir: string; } | { readonly kind: "sqlite"; readonly path: string; readonly prefix?: string; } | { readonly kind: "database"; readonly database: SqliteDatabase; readonly prefix?: string; } | { readonly kind: "adapter"; readonly module: string; readonly options?: AdapterOptions; readonly secrets?: Readonly>; readonly prefix?: string; }; export interface StorageOpenContext { readonly agentDir: string; /** `intercom`: the shared Intercom broker state that multi-node brokers open on the top-level selection. */ readonly domain: "sessions" | "journal" | "intercom"; readonly signal?: AbortSignal; } export interface StorageAdapterModule { readonly atomicStorageAdapter: 1; openDatabase?(options: AdapterOptions, context: StorageOpenContext): Promise; openSessionStore?(options: AdapterOptions, context: StorageOpenContext, storage: { readonly prefix?: string; }): Promise; openRunJournal?(options: AdapterOptions, context: StorageOpenContext, storage: { readonly prefix?: string; }): Promise; } export interface JournalFactories { memory(descriptor: StorageDescriptor): RunJournal; sql(database: SqliteDatabase, options: { readonly prefix?: string; }): Promise; } export declare function storageSelectionKey(selection: StorageSelection, agentDir?: string): string; /** * Loads an adapter module the way the extension loader loads extensions: `@bastani/atomic/storage` (and * `@bastani/atomic`) resolve to this host's own modules, so adapters need no installed copy of Atomic and share its * error classes. A package name selects an adapter listed by an installed Atomic package; other specifiers, and * package names no installed package lists, resolve from the agent directory. */ export declare function loadStorageAdapter(module: string, context: StorageOpenContext): Promise; /** The adapter's options with every `secrets` reference resolved, as the provider passes them to its hooks. */ export declare function resolveAdapterOptions(selection: Extract, context: StorageOpenContext): Promise; export interface StorageProvider { openSessionStore(selection: StorageSelection, context: StorageOpenContext): Promise; openRunJournal(selection: StorageSelection, context: StorageOpenContext): Promise; } export declare const StorageProvider: new (journals?: JournalFactories) => StorageProvider; //# sourceMappingURL=provider.d.ts.map