import type * as vscode from 'vscode'; import { IConfigurationService } from '../../../platform/configuration/common/configurationService'; import { DocumentId } from '../../../platform/inlineEdits/common/dataTypes/documentId'; import { InlineEditRequestLogContext } from '../../../platform/inlineEdits/common/inlineEditLogContext'; import { IInlineEditsModelService } from '../../../platform/inlineEdits/common/inlineEditsModelService'; import { ObservableWorkspace } from '../../../platform/inlineEdits/common/observableWorkspace'; import { IStatelessNextEditProvider } from '../../../platform/inlineEdits/common/statelessNextEditProvider'; import { IHistoryContextProvider } from '../../../platform/inlineEdits/common/workspaceEditTracker/historyContextProvider'; import { NesXtabHistoryTracker } from '../../../platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker'; import { ILogService } from '../../../platform/log/common/logService'; import { IRequestLogger } from '../../../platform/requestLogger/common/requestLogger'; import { ISnippyService } from '../../../platform/snippy/common/snippyService'; import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService'; import { CancellationToken } from '../../../util/vs/base/common/cancellation'; import { Disposable, IDisposable } from '../../../util/vs/base/common/lifecycle'; import { NesChangeHint } from '../common/nesTriggerHint'; import { DebugRecorder } from './debugRecorder'; import { LlmNESTelemetryBuilder } from './nextEditProviderTelemetry'; import { INextEditResult, NextEditResult } from './nextEditResult'; export interface NESInlineCompletionContext extends vscode.InlineCompletionContext { enforceCacheDelay: boolean; changeHint?: NesChangeHint; } export declare enum NesOutcome { Accepted = "accepted", Rejected = "rejected", Ignored = "ignored" } export interface INextEditProvider extends IDisposable { readonly ID: string; getNextEdit(docId: DocumentId, context: NESInlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: TTelemetry, data?: TData): Promise; handleShown(suggestion: T): void; handleAcceptance(docId: DocumentId, suggestion: T): void; handleRejection(docId: DocumentId, suggestion: T): void; handleIgnored(docId: DocumentId, suggestion: T, supersededBy: INextEditResult | undefined): void; lastRejectionTime: number; lastTriggerTime: number; lastOutcome: NesOutcome | undefined; } export declare class NextEditProvider extends Disposable implements INextEditProvider { private readonly _workspace; private readonly _statelessNextEditProvider; private readonly _historyContextProvider; private readonly _xtabHistoryTracker; private readonly _debugRecorder; private readonly _modelService; private readonly _configService; private readonly _snippyService; private readonly _logService; private readonly _expService; private readonly _requestLogger; readonly ID: string; private readonly _rejectionCollector; private readonly _nextEditCache; private _pendingStatelessNextEditRequest; private readonly _specManager; private _lastShownTime; /** The requestId of the last shown suggestion. We store only the requestId (not the object) to avoid preventing garbage collection. */ private _lastShownSuggestionId; private _lastRejectionTime; get lastRejectionTime(): number; private _lastTriggerTime; get lastTriggerTime(): number; private _lastOutcome; get lastOutcome(): NesOutcome | undefined; private _lastNextEditResult; private _shouldExpandEditWindow; private _logger; constructor(_workspace: ObservableWorkspace, _statelessNextEditProvider: IStatelessNextEditProvider, _historyContextProvider: IHistoryContextProvider, _xtabHistoryTracker: NesXtabHistoryTracker, _debugRecorder: DebugRecorder | undefined, _modelService: IInlineEditsModelService, _configService: IConfigurationService, _snippyService: ISnippyService, _logService: ILogService, _expService: IExperimentationService, _requestLogger: IRequestLogger); /** * Cancels the in-flight stateless next-edit request when the document it * was issued for has diverged from the request's expected post-edit state. * * Invoked from the per-document `runOnChange` autorun in the constructor * whenever an open document's value changes. The pending request was built * against a specific snapshot (`documentAfterEdits`); if the user has since * typed something that makes the current value differ from that snapshot, * the result would no longer be applicable and is cancelled eagerly. * * Skipped when: * - the `InlineEditsAsyncCompletions` experiment is enabled (that path * tolerates divergence and rebases later), or * - there is no pending request, or * - the changed document is not the one the pending request targets. * * Note: this only handles the regular pending stateless request. Speculative * requests have their own divergence handling via * `SpeculativeRequestManager.onActiveDocumentChanged` (trajectory check). */ private _cancelPendingRequestDueToDocChange; getNextEdit(docId: DocumentId, context: NESInlineCompletionContext, logContext: InlineEditRequestLogContext, cancellationToken: CancellationToken, telemetryBuilder: LlmNESTelemetryBuilder): Promise; private _getNextEditCanThrow; /** * Cross-file NES: when the first streamed edit targets a document other than the active * one, also cache an `activeDoc (content + edit window) -> suggestion-in-targetDoc` * association. This lets the cross-file suggestion be re-served from cache while the cursor * is still in the active document (the regular path only caches it under the target * document, which is reachable from cache only after the user jumps there). * * The entry is stored without `userEditSince`, so it is never tracked/rebased: its edit is * in the target document's coordinate space and is served by exact content match only. */ private _maybeCacheCrossFileEditUnderActiveDoc; private determineNesConfigs; private _processDoc; private fetchNextEdit; private _joinNextEditRequest; private _logRebaseFailure; /** * Shared core of both the regular ({@link _executeNewNextEditRequest}) and speculative * ({@link _runSpeculativeProviderCall}) stream loops: rebases a single streamed edit onto * the edits applied so far for its target document, populates the cache, stores any * cross-file association, and advances the target document's running contents. Returns * `undefined` when the edit could not be rebased. * * The full per-edit state transition (including advancing `docContents`) is owned here; * `docContentsBeforeEdit` is returned so callers can log the first edit against the * pre-edit contents. Orchestration that differs between the two paths (resolving * `firstEdit`, stream-end handling) stays with the callers. */ private _rebaseAndCacheStreamedEdit; private _executeNewNextEditRequest; private _hookupCancellation; private computeMinimumResponseDelay; handleShown(suggestion: NextEditResult): void; private _triggerSpeculativeRequest; /** * Creates and starts a speculative request for the post-edit document state. * The request will populate the cache so that when the user accepts the suggestion, * the next NES request can reuse or find the result in cache. */ private _createSpeculativeRequest; /** * Runs the provider call for a speculative request and caches results. */ private _runSpeculativeProviderCall; private static shiftSelectionAfterEditWindow; handleAcceptance(docId: DocumentId, suggestion: NextEditResult): void; handleRejection(docId: DocumentId, suggestion: NextEditResult): void; handleIgnored(docId: DocumentId, suggestion: NextEditResult, supersededBy: INextEditResult | undefined): void; private runSnippy; private _isRejectedEditMemoryEnabled; private _addLiveLogContextEntry; clearCache(): void; } export declare class NextEditFetchRequest { readonly opportunityId: string; readonly log: InlineEditRequestLogContext; readonly providerRequestStartDateTime: number | undefined; readonly isSpeculative: boolean; readonly headerRequestId: string; constructor(opportunityId: string, log: InlineEditRequestLogContext, providerRequestStartDateTime: number | undefined, isSpeculative: boolean, headerRequestId?: string); } //# sourceMappingURL=nextEditProvider.d.ts.map