/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */ import type { CodeChunkMode } from './code-index-chunking.js'; import type { CodeIndexStats } from './code-index-store.js'; /** Default per-path debounce window: long enough to coalesce a burst of edits to one file, short enough that the index trails the working tree by well under a second. */ export declare const DEFAULT_REINDEX_DEBOUNCE_MS = 300; /** The subset of CodeIndexStore this scheduler drives, kept structural so tests can supply a minimal fake. */ export interface CodeIndexReindexTarget { reindexFile(absPath: string): Promise<{ indexed: boolean; mode: CodeChunkMode; }>; stats(): Pick; } /** Honest record of the most recent reindex the scheduler actually ran (gate passed). */ export interface CodeIndexReindexActivity { /** Absolute path that was reindexed. */ readonly path: string; /** Completion timestamp (ms since epoch). */ readonly at: number; /** 'indexed' when chunks were (re)written; 'skipped' when the file was ignored/too-large/removed (reindexFile returned indexed:false); 'error' when reindexFile threw. */ readonly status: 'indexed' | 'skipped' | 'error'; /** The chunk mode reindexFile reported (absent on error). */ readonly mode?: CodeChunkMode | undefined; /** Present exactly when status==='error': the contained failure message. */ readonly error?: string | undefined; } export interface CodeIndexReindexSchedulerDeps { readonly target: CodeIndexReindexTarget; /** Root directory tool-arg paths are resolved against (absolute paths pass through). */ readonly workingDirectory: string; /** Live gate for the embedder's storage.codeIndexEnabled setting. Default: always enabled. */ readonly isEnabled?: (() => boolean) | undefined; /** Per-path debounce window in ms. Default DEFAULT_REINDEX_DEBOUNCE_MS. */ readonly debounceMs?: number | undefined; /** Injectable clock for deterministic activity timestamps in tests. */ readonly now?: (() => number) | undefined; } /** * Tool names whose successful execution touches files worth reindexing, and the * argument shapes that carry the touched path(s). `write` carries `files[].path`; * `edit` carries `edits[].path` plus an optional `notebook_operations.path`. A * top-level `path`/`file_path` is also honored for robustness against tool * variants. Anything else yields no paths (no-op). */ export declare function extractReindexPaths(toolName: string, args: Record): string[]; export declare class CodeIndexReindexScheduler { private readonly deps; private readonly timers; private readonly inFlight; private last; private readonly debounceMs; private readonly now; constructor(deps: CodeIndexReindexSchedulerDeps); /** * Entry point wired into both tool-execution loops. A no-op for a failed call * or a non-file tool. Extracts touched paths and schedules each (debounced). * Returns immediately, never awaits a reindex. */ onToolExecuted(toolName: string, args: Record, success: boolean): void; /** Arm (or reset) the per-path debounce timer for one absolute path. */ schedule(absPath: string): void; /** The most recent reindex the scheduler actually ran, or null if none has completed. */ lastActivity(): CodeIndexReindexActivity | null; /** Count of paths with a pending (debouncing) reindex. */ pendingCount(): number; /** Test/shutdown helper: fire every pending debounce timer now and await all in-flight reindexes. */ flush(): Promise; /** Cancel every pending timer (does not touch in-flight reindexes). */ dispose(): void; private track; private runReindex; } //# sourceMappingURL=code-index-reindex.d.ts.map