/** * Shared types for the Coppermind local daemon (coppermindd) * * Architecture contract: * - All writes go to the WAL first (durability before ack) * - Sync to cloud is always async (never on hot path) * - Local daemon state may live in SQLite even when memory authority moves elsewhere */ export interface ProjectState { id: string; userId: string; projectKey: string; state: Record; updatedAt: string; } export interface TaskState { id: string; userId: string; projectId: string; taskKey: string; status: "open" | "in_progress" | "done" | "cancelled"; state: Record; updatedAt: string; } export interface SessionSummary { id: string; userId: string; sessionId: string; summary: string; tokenCount: number; endedAt: string; } export interface CachedMemoryEntry { id: string; userId: string; scope: string; content: string; metadata: Record; embedding: number[] | null; tags: string[]; importance: number; lastRetrievedAt: string; createdAt: string; updatedAt: string; retrievalPriority?: number; } export interface DaemonConfig { key: string; value: string; updatedAt: string; } export type EventType = "memory.ingest" | "memory.update" | "memory.delete" | "project.update" | "task.update" | "session.end" | "config.set"; export type SyncStatus = "pending" | "syncing" | "synced" | "failed"; export interface WALEvent { id: number; eventId: string; eventType: EventType; userId: string; scope: string; payload: string; createdAt: string; syncStatus: SyncStatus; syncAttempts: number; lastSyncAt: string | null; lastSyncError: string | null; } export type QueueStatus = "pending" | "retrying" | "dead"; export interface SyncQueueEntry { id: number; eventId: string; eventType: EventType; payload: string; userId: string; scope: string; status: QueueStatus; retryCount: number; maxRetries: number; nextRetryAt: string | null; backoffMs: number; lastError: string | null; createdAt: string; updatedAt: string; } export type EvictionPolicy = "lru" | "importance" | "hybrid"; export type CompactionTrigger = "size" | "count" | "manual"; export interface EvictionConfig { policy: EvictionPolicy; maxEntries: number; maxDiskMb: number; evictBelowImportance: number; evictAfterDays: number; compactionIntervalHours: number; lastCompactionAt: string | null; } export interface CompactionStats { evictedCount: number; freedKb: number; remainingCount: number; durationMs: number; } export declare const CONFIG_KEYS: { readonly EVICTION_CONFIG: "eviction_config"; readonly LAST_SYNC_AT: "last_sync_at"; readonly LAST_EXTRACTION_STATUS: "last_extraction_status"; readonly GATEWAY_URL: "gateway_url"; readonly API_KEY: "api_key"; readonly SYNC_ENABLED: "sync_enabled"; }; export interface Store { getProject(userId: string, projectKey: string): ProjectState | null; upsertProject(entry: ProjectState): void; getTask(userId: string, taskKey: string): TaskState | null; upsertTask(entry: TaskState): void; getConfig(key: string): DaemonConfig | null; setConfig(key: string, value: string): void; appendWALEvent(event: Omit): WALEvent; getWALEventByEventId(eventId: string): WALEvent | null; getWALEvents(sinceId: number, limit?: number): WALEvent[]; updateWALEventSyncStatus(id: number, status: SyncStatus, error?: string): void; markWALEventsSyncing(ids: number[]): void; getWALStats(): { total: number; pending: number; synced: number; failed: number; }; enqueueSync(eventId: string, eventType: EventType, payload: string, userId: string, scope: string): SyncQueueEntry; getSyncQueue(limit?: number): SyncQueueEntry[]; getSyncQueueEntry(id: number): SyncQueueEntry | null; updateSyncEntry(id: number, updates: Partial>): void; removeSyncEntry(id: number): void; getSyncQueueStats(): { pending: number; retrying: number; dead: number; }; getEvictionConfig(): EvictionConfig; setEvictionConfig(cfg: EvictionConfig): void; runCompaction(cfg: EvictionConfig): CompactionStats; getDiskUsageKb(): number; close(): void; } //# sourceMappingURL=types.d.ts.map