import { type WorkflowSourceObservation } from "./workspace-watcher.js"; /** * Normalize an `fs.watch`-reported relative path to forward-slash form. * * `fs.watch` reports NATIVE separators (`node_modules\\pkg\\index.ts` on * Windows) while the skip-dir comparisons here are POSIX. Splitting on * `path.sep` (not a blanket backslash replace) keeps POSIX filenames that * legitimately CONTAIN a backslash intact. Exported, with the separator * injectable, so the Windows behavior is provable from POSIX CI. */ export declare function normalizeWatchPath(filename: string, sep?: string): string; export interface WorkspaceWatchCallbacks { /** Current registry roots inside this root; read lazily on every poll. */ listSourceRoots: () => readonly string[]; listSourceObservations?: () => readonly WorkflowSourceObservation[]; onSourceChange: ( /** Null when the platform can only report a workspace-level change. */ sourcePaths: readonly string[] | null) => void | Promise; onInventoryChange: () => void | Promise; /** Synchronous raw-event fail-close hook, before debounce or async I/O. */ onPotentialChange?: (sourcePaths: readonly string[] | null) => void; } export interface WorkspaceWatchHandle { close(): void; on(event: "error", listener: (error: Error) => void): WorkspaceWatchHandle; } export type WorkspaceWatchFactory = (root: string, listener: (event: "rename" | "change", filename: string | null) => void) => WorkspaceWatchHandle; export interface WorkspaceWatchOptions { /** Absolute host-owned metadata roots whose native events are not edits. */ ignoredEventRoots?: readonly string[]; sourceDebounceMs?: number; inventoryDebounceMs?: number; inventoryRetryBaseMs?: number; maxInventoryRetries?: number; maxSourceRetries?: number; pollIntervalMs?: number; /** Deterministic test seam for the supported polling fallback. */ forcePolling?: boolean; /** Deterministic test seam for native event routing and watcher errors. */ watchFactory?: WorkspaceWatchFactory; /** Deterministic lifecycle seam: the native handle is armed before this. */ beforeInitialSnapshot?: () => void | Promise; /** Deterministic test seams for proving one owned polling baseline. */ snapshotWorkspace?: (root: string) => Promise; snapshotSources?: (roots: readonly string[], observations: readonly WorkflowSourceObservation[]) => Promise>; } export interface SharedWorkspaceWatchBrokerOptions extends WorkspaceWatchOptions { /** Fresh process-local proof expires when the final continuous lease ends. */ onLastLeaseReleased?: (canonicalRoot: string) => void; } export interface SharedWorkspaceWatchSubscriber extends WorkspaceWatchCallbacks { root: string; } export interface SharedWorkspaceWatchBrokerLike { subscribe(key: object, subscriber: SharedWorkspaceWatchSubscriber): Promise; unsubscribe(key: object): void; } export declare class WorkspaceRootWatcher { readonly root: string; private readonly callbacks; private readonly options; private readonly ignoredEventRoots; private watcher; private pollTimer; private sourceTimer; private sourceRetryTimer; private inventoryTimer; private inventoryRetryTimer; private closed; private sourcePaths; private ambiguousSourceChange; private lastSourceSnapshots; private lastSourceRequest; private lastInventorySnapshot; private failedInventorySnapshot; private inventoryGeneration; private inventoryCheckInFlight; private inventoryCheckPending; private inventoryReconcilePending; private pollInFlight; private initialized; private polling; private callbackQueue; private rawGeneration; private sourceGeneration; private constructor(); static begin(root: string, callbacks: WorkspaceWatchCallbacks, options: WorkspaceWatchOptions): { watcher: WorkspaceRootWatcher; ready: Promise; }; private initialize; private snapshotWorkspace; private snapshotSources; private readSourceSnapshotRequest; private sampleSourceSnapshots; private sourceSampleIsCurrent; private acceptSourceSample; private enqueue; private enqueueSource; private scheduleSourceChange; private dispatchSourceChange; private dispatchInventoryChange; private scheduleInventoryRetry; private scheduleInventoryCheck; private checkInventoryAsync; private arm; private fallBackToPolling; close(): void; } /** * Process-wide watcher/fingerprint lease keyed by canonical workspace root. * Session and graph consumers share one native handle, one polling baseline, * and one bounded metadata traversal; callbacks fan out only after that shared * observation has been accepted. */ export declare class SharedWorkspaceWatchBroker implements SharedWorkspaceWatchBrokerLike { private readonly options; private readonly leases; private readonly rootBySubscriber; constructor(options?: SharedWorkspaceWatchBrokerOptions); subscribe(key: object, subscriber: SharedWorkspaceWatchSubscriber): Promise; unsubscribe(key: object): void; get size(): number; } //# sourceMappingURL=workspace-watch-broker.d.ts.map