/** * surreal-local.ts * * Manages the daemon-owned SurrealDB companion process for the authoritative local * memory plane. Coppermind owns startup, health monitoring, repair, and localhost * binding — same product posture as the SurrealDB runtime. * * Phase 2: credentialed SurrealDB with daemon-owned --user/--pass. * - Credentials auto-provisioned on first start and persisted to surrealAuthPath * - SurrealDB started with --user/--pass (NOT --unauthenticated) * - Connections use NS/DB level auth with provisioned credentials */ import type { DaemonRuntimeConfig } from "./config.js"; export interface LocalSurrealAuthState { username: string; password: string; createdAt: string; updatedAt: string; } export declare function provisionSurrealAuth(config: Pick): LocalSurrealAuthState; export declare function getSurrealAuth(config: Pick): LocalSurrealAuthState; export declare function looksLikeCoppermindManagedSurrealProcess(pid: number, config: Pick): boolean; export type LocalSurrealState = "disabled" | "missing-binary" | "stopped" | "port-conflict-foreign" | "unhealthy" | "healthy"; export type LocalSurrealRepairStatus = "applied" | "skipped" | "failed"; export interface LocalSurrealHealthSnapshot { url: string; reachable: boolean; status: number | null; error: string | null; } export interface LocalSurrealSnapshot { enabled: boolean; autoProvision: boolean; state: LocalSurrealState; host: string; port: number; rootDir: string; dataDir: string; logPath: string; pidPath: string; binaryPath: string | null; installed: boolean; pid: number | null; pidAlive: boolean; stalePidFile: boolean; portOwnerPid: number | null; portOwnerClassification: "none" | "owned" | "foreign"; health: LocalSurrealHealthSnapshot; nextAction: string; } export interface LocalSurrealRepairAction { action: string; status: LocalSurrealRepairStatus; detail: string; } export interface EnsureLocalSurrealOptions { ensureInstalled?: boolean; ensureRunning?: boolean; repair?: boolean; fetchImpl?: typeof fetch; /** Override the port for this call only. Falls back to config.surrealPort. */ surrealPort?: number; } export declare function resolveLocalSurrealBinaryPath(config: Pick): string; export declare function buildSurrealDownloadUrl(version: string, platform: NodeJS.Platform, arch: string): string | null; export declare function buildLocalSurrealSnapshot(config: DaemonRuntimeConfig, fetchImpl?: typeof fetch, surrealPortOverride?: number): Promise; /** * Kill the SurrealDB companion process without wiping its data directory. * Used during clean daemon shutdown so SurrealDB doesn't become orphaned. * Data on disk persists for the next daemon start. */ export declare function killSurrealCompanion(config: Pick): void; export declare function wipeSurrealData(config: DaemonRuntimeConfig): Promise; export declare function ensureLocalSurrealCompanion(config: DaemonRuntimeConfig, options?: EnsureLocalSurrealOptions): Promise<{ snapshot: LocalSurrealSnapshot; actions: LocalSurrealRepairAction[]; }>; //# sourceMappingURL=surreal-local.d.ts.map