UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

61 lines (60 loc) • 2.52 kB
import { type SyncStatus } from "../governance/policy.js"; import { type AheadBehind } from "./outcome.js"; import { type RunStoreGit } from "./store-merge.js"; export type StoreSyncStatus = "unchanged" | "updated" | "pushed" | "conflict" | "busy" | "error" | "skipped"; export interface StoreSyncOutcome { status: StoreSyncStatus; detail: string; counts?: AheadBehind; backupRef?: string; /** Abandoned state removed before syncing, one line each. */ cleaned: string[]; } export interface StoreSyncOptions { git?: RunStoreGit; now?: number; /** A pull-only store never pushes. */ push?: boolean; /** Names the caller in background-sync.log. */ source?: string; } /** Hook store sync cadence; `PHREN_STORE_SYNC_SECONDS=0` turns it off. */ export declare const DEFAULT_STORE_SYNC_SECONDS = 300; export declare function storeSyncSeconds(env?: NodeJS.ProcessEnv): number; export declare function syncStore(store: string, options?: StoreSyncOptions): Promise<StoreSyncOutcome>; /** Every store this computer has, in turn: a readonly or pull-only store only pulls. */ export declare function syncAllStores(primary: string, options?: Omit<StoreSyncOptions, "push">): Promise<Array<{ name: string; outcome: StoreSyncOutcome; }>>; /** The Hook's sync loop: the first pass a minute after start, then every `seconds`. */ export declare function startStoreSyncLoop(primary: string, seconds?: number): { stop: () => void; }; /** A store with a remote that has not synced for this long is flagged. */ export declare const STORE_STALE_MS: number; /** Diverged, stale and failing in one sentence, most urgent first. */ export declare function storeWarning(store: { name: string; ahead?: number; behind?: number; diverged?: boolean; stale?: boolean; error?: string; lastSyncedAt?: string; }, now?: number): string | undefined; /** The newest successful pull or push in a store's sync record. */ export declare function lastSyncedAt(sync: SyncStatus | undefined): string | undefined; export interface StoreSyncState { name: string; upstream?: string; ahead?: number; behind?: number; lastSyncedAt?: string; diverged: boolean; stale: boolean; error?: string; warning?: string; } /** Where a store stands against its last-fetched upstream and its sync record; nothing is fetched. */ export declare function storeSyncState(name: string, store: string, git?: RunStoreGit, now?: number): Promise<StoreSyncState>;