import type { Database as DatabaseType } from "better-sqlite3"; import type { ConfigRepo } from "../repositories/config.repo.js"; import type { EnrolledEntry, InstanceEntry, InstanceRegistry, InstanceStats, SharingMode } from "../types.js"; export declare class InstanceRegistryService { private config; private projectRoot; private db; private dbFileName; private intervalId; private instanceId; constructor(config: ConfigRepo, projectRoot: string, db: DatabaseType, dbFileName?: string); /** Get this instance's ID from config (cached after first call) */ getInstanceId(): string; /** Read the full registry from disk. Returns empty registry if file missing. */ readRegistry(): InstanceRegistry; /** Write the registry back to disk atomically */ private writeRegistry; /** Collect lightweight stats from this instance's DB */ collectStats(): InstanceStats; /** Build this instance's registry entry from config + live data */ private buildEntry; /** Returns true if this instance has opted into permanent enrollment (visible=true). */ private isVisible; /** Build the minimal enrolled entry from current config (no stats, no PID). */ private buildEnrolledEntry; /** Upsert this instance's enrolled entry (preserves enrolled_at if already present). */ private upsertEnrolled; /** Remove this instance from the enrolled map (called when visibility is set to false). */ private removeEnrolled; /** * Register this instance in ~/.engram/instances.json. * Creates the registry if it doesn't exist. Upserts this instance's entry. */ register(): void; /** * Update heartbeat timestamp and stats for this instance. * If visible=true, also upserts the permanent enrolled entry. */ heartbeat(): void; /** * Start the periodic heartbeat (every HEARTBEAT_INTERVAL_MS). * Safe to call multiple times — subsequent calls are no-ops. */ startHeartbeat(): void; /** * Stop heartbeat and mark this instance as stopped in the registry. * For visible=true instances, also updates last_seen in the enrolled entry * so the offline card shows an accurate timestamp. * Called on process exit / graceful shutdown. */ shutdown(): void; /** * Get the full registry with live status enrichment. * Entries with stale heartbeats or dead PIDs are marked accordingly. */ getRegistry(): InstanceRegistry; /** * Get just this instance's info (always from live config, not registry). */ getSelf(): InstanceEntry; /** * List all known instances sorted by last heartbeat (newest first). * Enriches each entry with live status (active/stale/stopped). */ listInstances(includeStale?: boolean): InstanceEntry[]; /** * Remove entries with heartbeat older than PRUNE_THRESHOLD_MS (7 days). * Returns the number of entries pruned. */ pruneStale(): number; /** * Return enrolled instances that are NOT currently in the heartbeat list. * These are visible=true instances that have gone offline — suitable * for displaying as offline cards in the dashboard. */ getEnrolledOffline(): EnrolledEntry[]; /** * Return ALL enrolled instances (online or offline). * Used by dashboard to show the full visible fleet. */ getEnrolledAll(): EnrolledEntry[]; /** * Set this instance's visibility (permanent enrollment opt-in). * visible=true → writes enrollment entry on next heartbeat (within 60s). * visible=false → immediately removes enrollment entry; falls back to heartbeat-only. */ setVisibility(visible: boolean): void; /** * Update this instance's human-readable label. * Writes to both config table and registry. */ setLabel(label: string): void; /** * Update this instance's sharing configuration. * Writes to both config table and registry. */ setSharing(mode: SharingMode, types?: string[]): void; /** Get the registry file path (useful for diagnostics) */ static getRegistryPath(): string; } //# sourceMappingURL=instance-registry.service.d.ts.map