UNPKG

@phren/cli

Version:

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

54 lines (53 loc) • 2.27 kB
import { type Json } from "./protocol.js"; type Stamp = { signature: string; statusSignature?: string; lastChangedAt: string; statusSince: string; }; type StatusRow = { workspace: unknown; tab: unknown; status: unknown; }; export type TabActivityStamp = Pick<Stamp, "lastChangedAt" | "statusSince">; export type TabActivityObservation = { generation: number; stamps: ReadonlyMap<string, TabActivityStamp>; }; export declare const tabActivityKey: (workspace: unknown, tab: unknown) => string; /** Panes grouped once per snapshot, preserving terminal order and workspace scope. */ export declare function panesByTab(snapshot: Json): Map<string, Json[]>; /** A clock for Herdr's clockless state counters. Only successful snapshots * prune tabs; each activity pass also prunes missing servers. Writes are ordered * and atomic, and an unchanged poll never rewrites the file. */ export declare class TabActivityStore { private readonly file; private readonly now; private entries; private loaded; private dirty; private pending; private writes; private writing; private idle; private nextGeneration; private committedGeneration; constructor(file?: string, now?: () => Date); observe(server: string, snapshot: Json): Promise<TabActivityObservation>; /** The status clock follows the final `agentStatus` the overview sends, after * background work and other decoration change it. Keep this off `observe`: * the background activity timer polls raw snapshots and must not reset it. * `generation` comes from the observation that started this enrichment, so an * older snapshot that finishes later cannot overwrite a newer one. */ recordStatus(server: string, rows: readonly StatusRow[], generation: number): Promise<ReadonlyMap<string, TabActivityStamp>>; /** Cache writes are fire-and-forget and ordered; at most 8 wait, the oldest dropped since each writes the latest state. */ private persistSoon; private drainWrites; /** Waits for queued cache writes; the live path never does, since this is a cache. */ flush(): Promise<void>; private load; private persist; pruneServers(servers: string[]): Promise<void>; } export {};