/** * Pluggable Backend API for Named Blackboards * * Defines the `BlackboardBackend` interface that abstracts the storage layer * used by `SharedBlackboard`. Two built-in implementations are provided: * * - `FileBackend` — persisted to disk via LockedBlackboard (default) * - `MemoryBackend` — pure in-memory, no disk writes (testing / ephemeral boards) * * Custom backends (Redis, CRDT, cloud storage, etc.) can be implemented by * satisfying the `BlackboardBackend` interface and passing the instance to * `orchestrator.getBlackboard(name, { backend: myBackend })`. * * @module BlackboardBackend * @version 1.0.0 * @license MIT */ import type { BlackboardEntry } from './locked-blackboard'; export type { BlackboardEntry }; /** * Storage abstraction for a `SharedBlackboard` instance. * * Implement this interface to plug in any storage backend: * file system, Redis, an in-memory Map, a cloud KV store, etc. * * @example * ```typescript * class RedisBackend implements BlackboardBackend { * constructor(private client: RedisClient) {} * read(key: string) { ... } * write(key, value, sourceAgent, ttl) { ... } * delete(key) { ... } * listKeys() { ... } * getSnapshot() { ... } * } * const board = orchestrator.getBlackboard('prod', { backend: new RedisBackend(client) }); * ``` */ export interface BlackboardBackend { /** * Read a single entry. Returns `null` if not found or expired. */ read(key: string): BlackboardEntry | null; /** * Write a value. Returns the stored entry including generated metadata. * @param key The entry key * @param value Any JSON-serializable value * @param sourceAgent The agent performing the write * @param ttl Optional time-to-live in seconds */ write(key: string, value: unknown, sourceAgent: string, ttl?: number): BlackboardEntry; /** * Delete an entry by key. Returns `true` if it existed. */ delete(key: string): boolean; /** * Return all non-expired keys. */ listKeys(): string[]; /** * Return a full snapshot of all non-expired entries, keyed by entry key. */ getSnapshot(): Record; } /** * File-backed persistent storage using `LockedBlackboard`. * * All writes are atomic and file-locked. Data survives process restarts. * This is the default backend used when no `backend` option is provided to * `orchestrator.getBlackboard()`. * * @example * ```typescript * const board = orchestrator.getBlackboard('reports', { * backend: new FileBackend('./data/reports'), * }); * ``` */ export declare class FileBackend implements BlackboardBackend { private lb; constructor(basePath: string); read(key: string): BlackboardEntry | null; write(key: string, value: unknown, sourceAgent: string, ttl?: number): BlackboardEntry; delete(key: string): boolean; listKeys(): string[]; getSnapshot(): Record; } /** * Pure in-memory backend — data lives only for the lifetime of the process. * * Ideal for: * - Unit testing (no temp directories, instant, isolated) * - Short-lived ephemeral boards * - Read-heavy caches that don't need persistence * * Thread-safety note: Node.js is single-threaded; no locking is needed for * in-process use. For multi-process scenarios use `FileBackend` or a * distributed backend (Redis, etc.). * * @example * ```typescript * const board = orchestrator.getBlackboard('ephemeral', { * backend: new MemoryBackend(), * }); * ``` */ export declare class MemoryBackend implements BlackboardBackend { private store; private isExpired; read(key: string): BlackboardEntry | null; write(key: string, value: unknown, sourceAgent: string, ttl?: number): BlackboardEntry; delete(key: string): boolean; listKeys(): string[]; getSnapshot(): Record; /** * Clear all entries. Useful for test teardown. */ clear(): void; /** * Returns the current entry count (including expired entries not yet evicted). */ size(): number; } //# sourceMappingURL=blackboard-backend.d.ts.map