import { CancellationToken } from "../../../../../base/common/cancellation.js"; import { IObservable } from "../../../../../base/common/observable.js"; import { URI, Event } from "../../../../../sessions/sessions.web.main.internal.js"; import { ChatAgentLocation, SessionTypeSelectionReason } from "../constants.js"; import { IChatEditingSession } from "../editing/chatEditingService.js"; import { IChatModel, IExportableChatData, ISerializableChatData, IChatRequestModel, IChatRequestVariableData } from "../model/chatModel.js"; import { IChatModelReferenceDebugSnapshot } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/workbench/contrib/chat/common/model/chatModelStore"; import { IParsedChatRequest } from "../requestParser/chatParserTypes.js"; import { IChatRequestSubmittedEvent, IChatRequestAcceptedEvent, IChatSessionStartOptions, IChatModelReference, IChatSendRequestOptions, ChatSendResult, IChatProgress, ChatRequestQueueKind, IRemotePendingRequest, IChatCompleteResponse, IChatDetail, IChatUserActionEvent, IChatQuestionAnswers } from "./chatService.js"; export declare const IChatService: import("../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier; export interface IChatService { _serviceBrand: undefined; transferredSessionResource: URI | undefined; readonly onDidSubmitRequest: Event; readonly onDidAcceptRequest: Event; readonly onDidCreateModel: Event; /** * An observable containing all live chat models. */ readonly chatModels: IObservable>; readonly editingSessions: readonly IChatEditingSession[]; isEnabled(location: ChatAgentLocation): boolean; hasSessions(): boolean; /** * Starts a new chat session at the given location. * * @returns A reference to the session's model. */ startNewLocalSession(location: ChatAgentLocation, options?: IChatSessionStartOptions): IChatModelReference; /** * Get an active session without holding a reference to it. * * @returns The session's model, or undefined if no active session exists. */ getSession(sessionResource: URI): IChatModel | undefined; /** * Acquire a reference to an active session. * * @returns A reference to the session's model or undefined if there is no active session for the given resource. */ acquireExistingSession(sessionResource: URI, debugOwner?: string): IChatModelReference | undefined; /** * Tries to acquire an existing a chat session for the resource. If no session exists, tries to load one for the given * session resource and location. This may load the session from an external provider. * * @returns A reference to the session's model, or undefined if the session could not be loaded */ acquireOrLoadSession(sessionResource: URI, location: ChatAgentLocation, token: CancellationToken, debugOwner?: string, sessionTypeSelectionReason?: SessionTypeSelectionReason): Promise; /** * Loads a session from exported chat data */ loadSessionFromData(data: IExportableChatData | ISerializableChatData, debugOwner?: string, sessionTypeSelectionReason?: SessionTypeSelectionReason): IChatModelReference; getChatModelReferenceDebugInfo(): IChatModelReferenceDebugSnapshot; /** * Sends a chat request for the given session. * @returns A result indicating whether the request was sent, queued, or rejected. */ sendRequest(sessionResource: URI, message: string, options?: IChatSendRequestOptions): Promise; getSessionTitle(sessionResource: URI): string | undefined; setSessionTitle(sessionResource: URI, title: string): void; appendProgress(request: IChatRequestModel, progress: IChatProgress): void; resendRequest(request: IChatRequestModel, options?: IChatSendRequestOptions, preserveRequestId?: boolean): Promise; adoptRequest(sessionResource: URI, request: IChatRequestModel): Promise; removeRequest(sessionResource: URI, requestId: string): Promise; cancelCurrentRequestForSession(sessionResource: URI, source?: string): Promise; /** * Migrates all in-flight and queued pending requests from one session to another. * Cancels the in-flight request on the original session, removes queued requests, * and re-sends them all on the target session preserving their original send options. */ migrateRequests(originalResource: URI, targetResource: URI): void; /** * Sets yieldRequested on the active request for the given session. */ setYieldRequested(sessionResource: URI): void; /** * Removes a pending request from the session's queue. */ removePendingRequest(sessionResource: URI, requestId: string): void; /** * Sets the pending requests for a session, allowing for deletions/reordering. * Adding new requests should go through sendRequest with the queue option. */ setPendingRequests(sessionResource: URI, requests: readonly { requestId: string; kind: ChatRequestQueueKind; }[]): void; /** * Atomically reconciles the pending queue with messages authored by another client. * Preserves remote ids and existing matching requests, and no-ops when already equal. */ syncPendingRequestsFromRemote(sessionResource: URI, requests: readonly IRemotePendingRequest[]): void; /** * Ensures pending requests for the session are processing. If restoring from * storage or after an error, pending requests may be present without an * active chat message 'loop' happening. THis triggers the loop to happen * as needed. Idempotent, safe to call at any time. */ processPendingRequests(sessionResource: URI): void; /** * Cancels the in-flight request and immediately sends a single pending * (queued or steering) request. Local sessions move it to the front and * dequeue it; server-managed (agent host) sessions re-send it as a normal * turn, since the server does not drain its queue on cancellation. */ sendPendingRequestImmediately(sessionResource: URI, requestId: string): Promise; addCompleteRequest(sessionResource: URI, message: IParsedChatRequest | string, variableData: IChatRequestVariableData | undefined, attempt: number | undefined, response: IChatCompleteResponse): void; setChatSessionTitle(sessionResource: URI, title: string): void; getLocalSessionHistory(): Promise; clearAllHistoryEntries(): Promise; removeHistoryEntry(sessionResource: URI): Promise; getChatStorageFolder(): URI; logChatIndex(): void; getLiveSessionItems(): Promise; getHistorySessionItems(): Promise; getMetadataForSession(sessionResource: URI): Promise; readonly onDidPerformUserAction: Event; notifyUserAction(event: IChatUserActionEvent): void; readonly onDidReceiveQuestionCarouselAnswer: Event<{ requestId: string; resolveId: string; answers: IChatQuestionAnswers | undefined; }>; notifyQuestionCarouselAnswer(requestId: string, resolveId: string, answers: IChatQuestionAnswers | undefined): void; /** Fires on model unload (`disposed`) or explicit session deletion (`cleared`). Unload does not delete persisted history. */ readonly onDidDisposeSession: Event<{ readonly sessionResources: readonly URI[]; readonly reason: "cleared" | "disposed"; }>; transferChatSession(transferredSessionResource: URI, toWorkspace: URI): Promise; activateDefaultAgent(location: ChatAgentLocation): Promise; readonly requestInProgressObs: IObservable; /** * Returns the contributed session types with a request that is materializing or in progress. */ getPendingRequestSessionTypes(): readonly string[]; /** * For tests only! */ setSaveModelsEnabled(enabled: boolean): void; /** * For tests only! */ waitForModelDisposals(): Promise; }