import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation"; import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event"; import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle"; import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable"; import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri"; import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service"; import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation"; import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service"; import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service"; import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service"; import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service"; import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service"; import { IChatEntitlementService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service"; import { IChatDebugService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatDebugService.service"; import { IMcpService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service"; import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/participants/chatAgents.service"; import { ChatModel, IChatModel, IChatRequestModel, IChatRequestVariableData, IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatModel"; import { IParsedChatRequest } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/requestParser/chatParserTypes"; import { ChatRequestQueueKind, ChatSendResult, IChatCompleteResponse, IChatDetail, IChatModelReference, IChatProgress, IChatQuestionAnswers, IChatSendRequestOptions, IChatSessionStartOptions, IChatUserActionEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService"; import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService.service"; import { IChatSessionsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService.service"; import { IChatSlashCommandService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/participants/chatSlashCommands.service"; import { IChatTransferService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatTransferService.service"; import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants"; import { ILanguageModelsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service"; import { IPromptsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service"; export declare class ChatService extends Disposable implements IChatService { private readonly storageService; private readonly logService; private readonly telemetryService; private readonly extensionService; private readonly instantiationService; private readonly workspaceContextService; private readonly chatSlashCommandService; private readonly chatAgentService; private readonly configurationService; private readonly chatTransferService; private readonly chatSessionService; private readonly mcpService; private readonly promptsService; private readonly chatEntitlementService; private readonly languageModelsService; private readonly chatDebugService; _serviceBrand: undefined; private readonly _sessionModels; private readonly _pendingRequests; private readonly _queuedRequestDeferreds; /** * In-flight untitled→real materializations, keyed by the original untitled * chat session resource. A first send to an untitled contributed session * stores the promise that resolves to the newly minted real resource (or * `undefined` on failure). A concurrent second send for the same untitled * resource awaits this instead of materializing a second real session. * * The committed (settled) untitled→real mapping is owned by * {@link IChatSessionsService} (published via `setMaterializedSessionResource` * and read via `getMaterializedSessionResource`); this map only tracks the * transient in-flight serialization. */ private readonly _inFlightUntitledMaterializations; private _saveModelsEnabled; private _transferredSessionResource; get transferredSessionResource(): URI | undefined; private readonly _onDidSubmitRequest; readonly onDidSubmitRequest: Event<{ readonly chatSessionResource: URI; readonly message?: IParsedChatRequest; }>; get onDidCreateModel(): Event; private readonly _onDidPerformUserAction; readonly onDidPerformUserAction: Event; private readonly _onDidReceiveQuestionCarouselAnswer; readonly onDidReceiveQuestionCarouselAnswer: Event<{ requestId: string; resolveId: string; answers: IChatQuestionAnswers | undefined; }>; private readonly _onDidDisposeSession; readonly onDidDisposeSession: Event<{ readonly sessionResources: URI[]; reason: "cleared"; }>; private readonly _sessionFollowupCancelTokens; private readonly _chatServiceTelemetry; private readonly _chatSessionStore; readonly requestInProgressObs: IObservable; readonly chatModels: IObservable>; /** * For test use only */ setSaveModelsEnabled(enabled: boolean): void; /** * For test use only */ waitForModelDisposals(): Promise; private get isEmptyWindow(); constructor(storageService: IStorageService, logService: ILogService, telemetryService: ITelemetryService, extensionService: IExtensionService, instantiationService: IInstantiationService, workspaceContextService: IWorkspaceContextService, chatSlashCommandService: IChatSlashCommandService, chatAgentService: IChatAgentService, configurationService: IConfigurationService, chatTransferService: IChatTransferService, chatSessionService: IChatSessionsService, mcpService: IMcpService, promptsService: IPromptsService, chatEntitlementService: IChatEntitlementService, languageModelsService: ILanguageModelsService, chatDebugService: IChatDebugService); get editingSessions(): import("@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/editing/chatEditingService").IChatEditingSession[]; isEnabled(location: ChatAgentLocation): boolean; private migrateData; private saveState; /** * Only persist local sessions from chat that are not imported. */ private shouldStoreSession; notifyUserAction(action: IChatUserActionEvent): void; notifyQuestionCarouselAnswer(requestId: string, resolveId: string, answers: IChatQuestionAnswers | undefined): void; setChatSessionTitle(sessionResource: URI, title: string): Promise; private trace; private info; private error; private deserializeChats; /** * Returns an array of chat details for all persisted chat sessions that have at least one request. * Chat sessions that have already been loaded into the chat view are excluded from the result. * Imported chat sessions are also excluded from the result. * TODO this is only used by the old "show chats" command which can be removed when the pre-agents view * options are removed. */ getLocalSessionHistory(): Promise; /** * Returns an array of chat details for all local live chat sessions. */ getLiveSessionItems(): Promise; /** * Returns an array of chat details for all local chat sessions in history (not currently loaded). */ getHistorySessionItems(): Promise; getMetadataForSession(sessionResource: URI): Promise; private shouldBeInHistory; removeHistoryEntry(sessionResource: URI): Promise; clearAllHistoryEntries(): Promise; startNewLocalSession(location: ChatAgentLocation, options?: IChatSessionStartOptions): IChatModelReference; private _startSession; private initializeSession; activateDefaultAgent(location: ChatAgentLocation): Promise; getSession(sessionResource: URI): IChatModel | undefined; acquireExistingSession(sessionResource: URI, debugOwner?: string): IChatModelReference | undefined; getChatModelReferenceDebugInfo(): import("../model/chatModelStore.js").IChatModelReferenceDebugSnapshot; private acquireOrRestoreLocalSession; getSessionTitle(sessionResource: URI): string | undefined; loadSessionFromData(data: IExportableChatData | ISerializableChatData, debugOwner?: string): IChatModelReference; acquireOrLoadSession(sessionResource: URI, location: ChatAgentLocation, token: CancellationToken, debugOwner?: string): Promise; private loadRemoteSession; resendRequest(request: IChatRequestModel, options?: IChatSendRequestOptions): Promise; private queuePendingRequest; sendRequest(sessionResource: URI, request: string, options?: IChatSendRequestOptions): Promise; /** * Converts an untitled contributed chat session into its real session on the * first send and returns the real model/resource so the caller can re-target * the request. Serialized per untitled resource: a first send stores an * in-flight promise, and a concurrent second send awaits it and converges on * the same real session (where the caller's pending-request check then rejects * the duplicate) instead of minting a second real session. * * Returns `undefined` when no conversion happened — either there is no * `newChatSessionItem` handler / the handler declined, or a concurrent * materialization failed — in which case the caller keeps using the untitled * session (the original behavior). */ private _materializeUntitledSession; private getAttachmentCapabilitiesForParser; private parseChatRequest; private refreshFollowupsCancellationToken; private _sendRequestAsync; processPendingRequests(sessionResource: URI): void; /** * Returns true if the session is backed by an agent host server, which * controls queued-message dequeuing on the server side. */ private _isServerManagedQueue; /** * Process the next pending request from the model's queue, if any. * Called after a request completes to continue processing queued requests. * Multiple consecutive steering requests are combined into a single request. */ private processNextPendingRequest; private generateInitialChatTitleIfNeeded; private prepareContext; private getHistoryEntriesFromModel; removeRequest(sessionResource: URI, requestId: string): Promise; adoptRequest(sessionResource: URI, request: IChatRequestModel): Promise; addCompleteRequest(sessionResource: URI, message: IParsedChatRequest | string, variableData: IChatRequestVariableData | undefined, attempt: number | undefined, response: IChatCompleteResponse): Promise; cancelCurrentRequestForSession(sessionResource: URI, source?: string): Promise; setYieldRequested(sessionResource: URI): void; migrateRequests(originalResource: URI, targetResource: URI): void; removePendingRequest(sessionResource: URI, requestId: string): void; setPendingRequests(sessionResource: URI, requests: readonly { requestId: string; kind: ChatRequestQueueKind; }[]): void; sendPendingRequestImmediately(sessionResource: URI, requestId: string): Promise; hasSessions(): boolean; transferChatSession(transferredSessionResource: URI, toWorkspace: URI): Promise; getChatStorageFolder(): URI; logChatIndex(): void; setSessionTitle(sessionResource: URI, title: string): void; appendProgress(request: IChatRequestModel, progress: IChatProgress): void; private toLocalSessionId; } export declare function chatModelToChatDetail(model: IChatModel): Promise;