import type { InstanceRegistryService } from "./instance-registry.service.js"; import type { InstanceEntry, CrossInstanceSearchResult } from "../types.js"; export declare class CrossInstanceService { private registry; private dbCache; constructor(registry: InstanceRegistryService); /** * List all instances with their stats and sharing config. * Enriches with live status from registry. */ discoverInstances(includeStale?: boolean): InstanceEntry[]; /** * Resolve the actual DB file path for a foreign instance. * Falls back to scanning /.engram/ for memory*.db files when * db_path is absent (registry entries written by older Engram versions). */ private resolveDbPath; /** * Verify that a target instance allows the requested query type. * Returns the instance entry if allowed, throws descriptive error if not. */ private checkPermission; /** * Check whether a target instance allows importing (requires 'full' mode). */ private checkImportPermission; /** * Open a read-only connection to another instance's database. * Uses a cache with TTL to avoid excessive open/close cycles. */ private openReadOnly; /** Close the oldest cached DB handle */ private closeOldest; /** Close all expired DB handles (maintenance) */ closeExpired(): void; /** Close all cached DB handles (called on service shutdown) */ closeAll(): void; /** * Query decisions from another instance. */ queryDecisions(instanceId: string, options?: { query?: string; limit?: number; status?: string; }): { source: InstanceEntry; results: Record[]; }; /** * Query conventions from another instance. */ queryConventions(instanceId: string, options?: { category?: string; enforced?: boolean; }): { source: InstanceEntry; results: Record[]; }; /** * Query file notes from another instance. */ queryFileNotes(instanceId: string, options?: { filePath?: string; limit?: number; }): { source: InstanceEntry; results: Record[]; }; /** * Query tasks from another instance. */ queryTasks(instanceId: string, options?: { status?: string; limit?: number; }): { source: InstanceEntry; results: Record[]; }; /** * Query sessions from another instance. */ querySessions(instanceId: string, options?: { limit?: number; }): { source: InstanceEntry; results: Record[]; }; /** * Query changes from another instance. */ queryChanges(instanceId: string, options?: { limit?: number; filePath?: string; }): { source: InstanceEntry; results: Record[]; }; /** * Search across ALL sharing instances at once. * Queries each instance that has sharing_mode != 'none' and includes * the requested scope in sharing_types. */ searchAll(query: string, options?: { scope?: string; limit?: number; }): CrossInstanceSearchResult[]; /** * Import specific records from another instance into the local database. * Requires the source instance to have sharing_mode='full'. * Records are tagged with provenance (source_instance_id, imported_at). * * NOTE: Actual write to local DB must be done by the caller (dispatcher). * This method only extracts and returns the records for import. */ extractForImport(instanceId: string, type: string, ids?: number[]): { source: InstanceEntry; records: Record[]; }; /** * Get stats from another instance directly (without opening its DB). * Uses the registry's cached stats instead. */ getInstanceStats(instanceId: string): InstanceEntry | null; } //# sourceMappingURL=cross-instance.service.d.ts.map