/** * surreal-memory-plane.ts * * SurrealDB-backed authoritative local memory plane. * * Phase 2: credentialed SurrealDB with daemon-owned --user/--pass. * All data stored at ~/.coppermind/surrealdb/ via `surreal start --user/--pass`. * Credentials auto-provisioned and persisted to ~/.coppermind/surrealdb/auth.json. */ import type { DaemonRuntimeConfig } from "./config.js"; import type { DaemonLogger } from "./logger.js"; import type { LocalMemoryBackend } from "./memory-backend.js"; import type { SyncCoordinator } from "./sync.js"; import type { Store } from "./types.js"; import { runCandidateCompressionTask } from "./local-ai/tasks/candidate-compression.js"; import { runEpisodeTriageTask } from "./local-ai/tasks/episode-triage.js"; export interface SurrealMemoryAdmissionTaskRunners { runEpisodeTriageTask?: typeof runEpisodeTriageTask; runCandidateCompressionTask?: typeof runCandidateCompressionTask; } export type LocalMemoryBackendType = "surrealdb"; export type LocalMemoryHealth = "healthy" | "migrating" | "repair-required"; /** * Legacy phase values — retained for reading pre-v2 state files. */ export type LocalMemoryPlanePhase = "migrating" | "surrealdb-authoritative" | "repair-required"; export interface LocalMemoryPlaneState { version: 2; /** Which backend is authoritative. Only "surrealdb" is valid for current installs. */ backend: LocalMemoryBackendType; /** Current health/migration state. */ health: LocalMemoryHealth; /** Human-readable backend label. Null for SurrealDB. */ moduleName: string | null; lastMigratedAt: string | null; lastVerifiedAt: string | null; lastRepairAt: string | null; lastRecoveryMode: "verification-only" | "import-only" | "reset-reimport" | null; lastError: string | null; /** The port SurrealDB is bound to. Persisted so doctor/setup stays deterministic after first boot. */ surrealPort: number; } export interface LocalMemoryPlaneRepairAction { action: string; status: "applied" | "skipped" | "failed"; detail: string; } export declare function readLocalMemoryPlaneState(config: DaemonRuntimeConfig): LocalMemoryPlaneState | null; export declare function writeLocalMemoryPlaneState(config: DaemonRuntimeConfig, state: LocalMemoryPlaneState): void; /** * Provision the SurrealDB schema (namespace, database, tables, indexes, fields). * Idempotent — safe to call multiple times against an already-initialized DB. * Call this directly when connecting to a pre-existing SurrealDB that wasn't * started by the daemon's own ensureLocalSurrealCompanion flow. */ export declare function provisionSurrealSchema(config: Pick): Promise; export declare function ensureLocalSurrealMemoryPlane(config: DaemonRuntimeConfig, options?: { fetchImpl?: typeof fetch; store?: Store; }): Promise<{ state: LocalMemoryPlaneState; actions: LocalMemoryPlaneRepairAction[]; }>; interface SurrealMemoryBackendDependencies { config: DaemonRuntimeConfig; store: Store; fetchImpl?: typeof fetch; logger?: DaemonLogger; syncCoordinator?: SyncCoordinator; admission?: SurrealMemoryAdmissionTaskRunners; } export declare function createSurrealLocalMemoryBackend(dependencies: SurrealMemoryBackendDependencies): LocalMemoryBackend; export {}; //# sourceMappingURL=surreal-memory-plane.d.ts.map