import { Event, URI } from '@theia/core'; import { FileService } from '@theia/filesystem/lib/browser/file-service'; import { FileChangesEvent } from '@theia/filesystem/lib/common/files'; import { MonacoWorkspace } from '@theia/monaco/lib/browser/monaco-workspace'; import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service'; import { FileReadTracker } from '../common/file-read-tracker'; /** The content an agent saw, and whether anything has since signalled a possible change. */ interface TrackedFile { /** `undefined` until the read determining it returns, so that it matches no content. */ seenHash?: number; maybeStale: boolean; } export declare class FileReadTrackerImpl implements FileReadTracker { protected readonly fileService: FileService; protected readonly monacoWorkspace: MonacoWorkspace; protected readonly workspaceService: WorkspaceService; /** Session id -> tracked file uri -> state. Both levels are insertion ordered and bounded. */ protected readonly sessions: Map>; /** * Arbitrary bounds. Sessions are never disposed here, as that would mean depending on the `ChatService` * that owns the agents using this service, so the least recently used are evicted; that only loses a notice. */ protected readonly maxSessions: number; protected readonly maxFilesPerSession: number; /** A file grown past this is not read to compare, so a flagged one stays reported as changed. The read tools hand an agent far less. */ protected readonly maxComparedFileSize: number; /** Only flags entries; reading and hashing happens in {@link isStale} and {@link getChangedFiles}. */ protected init(): void; protected get fileChanges(): Event; /** Uris of documents whose unsaved content changed, which never reaches the file system. */ protected get documentChanges(): Event; recordRead(sessionId: string, uri: URI, content?: string): Promise; isStale(sessionId: string, uri: URI): Promise; getChangedFiles(sessionId: string): Promise; /** * Flags the tracked files the event touched, by uri lookup rather than {@link FileChangesEvent.contains}, * which scans the whole change list. A deleted parent folder is therefore only noticed on the next read. */ protected handleFileChanges(event: FileChangesEvent): void; /** Compares a flagged file against what the agent saw, clearing the flag when the contents match again. */ protected recheck(files: Map, key: string, tracked: TrackedFile): Promise<'unchanged' | 'changed' | 'gone'>; protected isFileNotFound(error: unknown): boolean; /** `undefined` when the content cannot be read at all. */ protected resolveContent(uri: URI): Promise; /** The content the agent would be handed now, preferring the open editor document as `getFileContent` does. */ protected readCurrentContent(uri: URI): Promise; /** A path the agent can pass back to `getFileContent`, which takes `/` as well as a uri. */ protected getLabel(uri: URI): string; protected invalidate(uriString: string): void; protected touchSession(sessionId: string): Map; /** Drops entries from the front, which insertion order makes the least recently used ones. */ protected evictOverflow(entries: Map, limit: number): void; } export {}; //# sourceMappingURL=file-read-tracker-impl.d.ts.map