import type { DaemonRuntimeConfig } from "./config.js"; import type { DaemonLogger } from "./logger.js"; import type { LocalMemoryBackend } from "./memory-backend.js"; import type { CachedMemoryEntry, ProjectState, SessionSummary, Store, SyncQueueEntry, TaskState } from "./types.js"; export type SyncEntityKind = "cached_memory" | "project_state" | "task_state" | "session_summary"; export interface RemoteCachedMemoryChange extends CachedMemoryEntry { kind: "cached_memory"; } export interface RemoteProjectChange extends ProjectState { kind: "project_state"; } export interface RemoteTaskChange extends TaskState { kind: "task_state"; } export interface RemoteSessionChange extends SessionSummary { kind: "session_summary"; } export type RemoteMemoryChange = RemoteCachedMemoryChange | RemoteProjectChange | RemoteTaskChange | RemoteSessionChange; export interface SyncTransportFlushRequest { cursor: string | null; events: SyncQueueEntry[]; } export interface SyncTransportFlushAck { eventId: string; remoteRevision?: string | number | null; } export interface SyncTransportConflict { eventId: string; remote: RemoteMemoryChange; reason?: string; } export interface SyncTransportRetry { eventId: string; error: string; retryAfterMs?: number; } export interface SyncTransportFlushResponse { applied?: SyncTransportFlushAck[]; duplicates?: string[]; conflicts?: SyncTransportConflict[]; retries?: SyncTransportRetry[]; remoteChanges?: RemoteMemoryChange[]; cursor?: string | null; } export interface SyncTransportPullRequest { cursor: string | null; limit: number; } export interface SyncTransportPullResponse { changes?: RemoteMemoryChange[]; cursor?: string | null; } export interface SyncTransport { flush(request: SyncTransportFlushRequest): Promise; pull(request: SyncTransportPullRequest): Promise; } export interface SyncPushResult { synced: number; failed: number; skipped: number; } export interface SyncPullResult { applied: number; conflicts: number; skipped: number; } export interface SyncResult { push: SyncPushResult; pull: SyncPullResult; totalDurationMs: number; } export interface SyncCoordinatorStatus { isSyncing: boolean; lastSyncAt: string | null; lastSyncSucceeded: boolean; pendingEvents: number; consecutiveFailures: number; lastError: string | null; syncCursor: string | null; } export interface SyncCoordinator { push(): Promise; pull(): Promise; sync(): Promise; wake(): void; start(): void; stop(): void; isSyncing(): boolean; getStatus(): SyncCoordinatorStatus; } export interface SyncCoordinatorDependencies { config: Pick; store: Store; memoryBackend?: Pick; fetchImpl?: typeof fetch; batchSize?: number; logger?: Pick; transport?: SyncTransport; } export declare function createHttpSyncTransport(syncUrl: string, apiKey?: string | null, fetchImpl?: typeof fetch): SyncTransport; export declare function createSyncCoordinator(dependencies: SyncCoordinatorDependencies): SyncCoordinator; //# sourceMappingURL=sync.d.ts.map