import { CancellationToken } from "../../../../../base/common/cancellation.js"; import { Event } from "../../../../../base/common/event.js"; import { Disposable, IDisposable } from "../../../../../base/common/lifecycle.js"; import { URI } from "../../../../../base/common/uri.js"; import { IMenuService } from "../../../../../platform/actions/common/actions.service.js"; import { IContextKeyService } from "../../../../../platform/contextkey/common/contextkey.service.js"; import { IInstantiationService, ServicesAccessor } from "../../../../../platform/instantiation/common/instantiation.js"; import { ILabelService } from "../../../../../platform/label/common/label.service.js"; import { ILogService } from "../../../../../platform/log/common/log.service.js"; import { IThemeService } from "../../../../../platform/theme/common/themeService.service.js"; import { IExtensionService } from "../../../../services/extensions/common/extensions.service.js"; import { IChatAgentAttachmentCapabilities } from "../../common/participants/chatAgents.js"; import { IChatAgentService } from "../../common/participants/chatAgents.service.js"; import { ChatSessionRefreshReason, ChatSessionStatus, IChatNewSessionRequest, IChatSession, IChatSessionCommitEvent, IChatSessionContentProvider, IChatSessionCustomizationItemGroup, IChatSessionCustomizationsProvider, IChatSessionForkOptions, IChatSessionHistoryItem, IChatSessionItem, IChatSessionItemController, IChatSessionItemsDelta, IChatSessionOptionsChangeEvent, IChatSessionProviderOptionGroup, IChatSessionProviderOptionItem, IChatSessionRequestHistoryItem, IChatSessionsExtensionPoint, IChatInputCompletionsParams, IChatInputCompletionsResult, ReadonlyChatSessionOptionsMap, ResolvedChatSessionsExtensionPoint } from "../../common/chatSessionsService.js"; import { IChatSessionsService } from "../../common/chatSessionsService.service.js"; import { IChatSideChatOrigin, IChatSideChatSelection } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/workbench/contrib/chat/common/chatSideChatService"; import { ResponseModelState } from "../../common/chatService/chatService.js"; import { IObservable } from "../../../../../base/common/observable.js"; import { IChatRequestVariableEntry } from "../../common/attachments/chatVariableEntries.js"; import { type IAgentHostImportConversation } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostImportConversationStore"; import { Target } from "../../common/promptSyntax/promptTypes.js"; import { IChatModel } from "../../common/model/chatModel.js"; export declare function applyCodexAgentHostPreference(contribution: IChatSessionsExtensionPoint): IChatSessionsExtensionPoint; export declare class ChatSessionsService extends Disposable implements IChatSessionsService { private readonly _logService; private readonly _chatAgentService; private readonly _extensionService; private readonly _contextKeyService; private readonly _menuService; private readonly _themeService; private readonly _labelService; private readonly _instantiationService; readonly _serviceBrand: undefined; private readonly _itemControllers; private readonly _asyncActivationRegistry; private readonly _contributions; private readonly _contributionDisposables; private readonly _contentProviders; private readonly _alternativeIdMap; private readonly _contextKeys; private readonly _onDidChangeItemsProviders; readonly onDidChangeItemsProviders: Event<{ readonly chatSessionType: string; }>; private readonly _onDidChangeSessionItems; readonly onDidChangeSessionItems: Event; private readonly _onDidCommitSession; readonly onDidCommitSession: Event; private readonly _onDidChangeAvailability; readonly onDidChangeAvailability: Event; private readonly _onDidChangeInProgress; get onDidChangeInProgress(): Event; private readonly _onDidChangeContentProviderSchemes; get onDidChangeContentProviderSchemes(): Event<{ readonly added: string[]; readonly removed: string[]; }>; private readonly _onDidChangeSessionOptions; get onDidChangeSessionOptions(): Event; private readonly _onDidChangeOptionGroups; get onDidChangeOptionGroups(): Event; private readonly inProgressMap; private readonly _sessionTypeOptions; private readonly _sessions; private readonly _sessionsChanged; private readonly _resourceAliases; private readonly _realResources; private readonly _pendingSessionResolutions; private readonly _customizationsProviders; private readonly _onDidChangeCustomizations; readonly onDidChangeCustomizations: Event<{ readonly chatSessionType: string; }>; private readonly _hasCanDelegateProvidersKey; constructor(_logService: ILogService, _chatAgentService: IChatAgentService, _extensionService: IExtensionService, _contextKeyService: IContextKeyService, _menuService: IMenuService, _themeService: IThemeService, _labelService: ILabelService, _instantiationService: IInstantiationService); private reportInProgress; getInProgress(): { chatSessionType: string; count: number; }[]; resolveChatSessionItem(chatSessionType: string, resource: URI, token: CancellationToken): Promise; canSetChatSessionItemArchived(sessionResource: URI): boolean; setChatSessionItemArchived(sessionResource: URI, archived: boolean): void; canSetChatSessionItemRead(sessionResource: URI): boolean; setChatSessionItemRead(sessionResource: URI, isRead: boolean): void; private updateInProgressStatus; private registerContribution; private _isContributionAvailable; /** * Type-keyed companion to {@link _isContributionAvailable}. Resolves the * session type (including alternative ids) to its contribution and reports * whether that contribution is currently enabled by its `when` clause. * * Session types with no contribution entry (e.g. the built-in `local` * provider, or item controllers registered without a matching contribution) * are treated as available, since there is no `when` clause gating them. */ private _isContributionAvailableForType; /** * Resolves a session type to its primary type, checking for alternative IDs. * @param sessionType The session type or alternative ID to resolve * @returns The primary session type, or undefined if not found or not available */ private _resolveToPrimaryType; private _registerMenuItems; /** * Resolves the command id of the primary create action contributed to * {@link MenuId.AgentSessionsCreateSubMenu} for the given session type, or * `undefined` when no such action is contributed (yet). Read at execution * time so it is unaffected by the ordering of extension menu registration. */ private _resolveCreateSubMenuCommandId; private _registerCommands; private _evaluateAvailability; private _enableContribution; /** * Disposes of all sessions that belong to a contribution * * @returns List of session resources that were disposed. */ private _disposeSessionsForContribution; private _registerAgent; getAllChatSessionContributions(): ResolvedChatSessionsExtensionPoint[]; private _updateHasCanDelegateProvidersContextKey; getChatSessionContribution(chatSessionType: string): ResolvedChatSessionsExtensionPoint | undefined; private resolveChatSessionContribution; private getContributionIcon; private resolveIconForCurrentColorTheme; registerChatSessionContribution(contribution: IChatSessionsExtensionPoint): IDisposable; activateChatSessionItemProvider(chatViewType: string): Promise; private doActivateChatSessionItemController; canResolveChatSession(sessionType: string): Promise; provideChatInputCompletions(sessionResource: URI, params: IChatInputCompletionsParams, token: CancellationToken): Promise; resolveChatResponseUri(sessionResource: URI, href: string, kind: "link" | "image"): string; updateChatSessionMetadata(sessionResource: URI, metadata: Record): boolean; getChatInputCompletionTriggerCharacters(sessionType: string): Promise; private tryActivateControllers; getChatSessionItems(providersToResolve: readonly string[] | undefined, token: CancellationToken, onError?: (error: unknown) => void): AsyncIterable<{ readonly chatSessionType: string; readonly items: readonly IChatSessionItem[]; }>; refreshChatSessionItems(providersToResolve: readonly string[] | undefined, token: CancellationToken, onError?: (error: unknown) => void, reason?: ChatSessionRefreshReason): Promise; getRegisteredChatSessionItemProviders(): readonly string[]; registerChatSessionItemController(chatSessionType: string, controller: IChatSessionItemController): IDisposable; registerChatSessionContentProvider(chatSessionType: string, provider: IChatSessionContentProvider): IDisposable; registerCustomizationsProvider(chatSessionType: string, provider: IChatSessionCustomizationsProvider): IDisposable; hasCustomizationsProvider(chatSessionType: string): boolean; getCustomizations(chatSessionType: string, token: CancellationToken): Promise; createNewChatSessionItem(chatSessionType: string, request: IChatNewSessionRequest, token: CancellationToken): Promise; notifySessionMaterialized(sessionResource: URI): void; deleteChatSessionItem(sessionResource: URI, token: CancellationToken): Promise; private _disposeSession; private _getChatSessionItemController; getOrCreateChatSession(sessionResource: URI, token: CancellationToken): Promise; private _waitForPendingSessionResolution; private _resolvePendingSession; private _getOrCreateChatSession; getChatSessionHistory(sessionResource: URI, token: CancellationToken): Promise; hasAnySessionOptions(sessionResource: URI): boolean; getSessionOptions(sessionResource: URI): Map | undefined; getSessionOption(sessionResource: URI, optionId: string): string | IChatSessionProviderOptionItem | undefined; setSessionOption(sessionResource: URI, optionId: string, value: string | IChatSessionProviderOptionItem): boolean; updateSessionOptions(sessionResource: URI, updates: ReadonlyChatSessionOptionsMap): boolean; /** * Resolve a resource through the alias map. If the resource is a real * resource that has been aliased to an untitled resource, return the * untitled resource (the canonical key in {@link _sessions}). */ private _resolveResource; registerSessionResourceAlias(untitledResource: URI, realResource: URI): void; setMaterializedSessionResource(untitledResource: URI, realResource: URI): void; getMaterializedSessionResource(untitledResource: URI): URI | undefined; clearMaterializedSessionResource(sessionResource: URI): void; fireSessionCommitted(original: URI, committed: URI): void; /** * Store option groups for a session type */ setOptionGroupsForSessionType(chatSessionType: string, handle: number, optionGroups?: IChatSessionProviderOptionGroup[]): void; /** * Get available option groups for a session type */ getOptionGroupsForSessionType(chatSessionType: string): IChatSessionProviderOptionGroup[] | undefined; getNewChatSessionInputState(chatSessionType: string, sessionResource: URI): Promise; /** * Get the capabilities for a specific session type */ getCapabilitiesForSessionType(chatSessionType: string): IChatAgentAttachmentCapabilities | undefined; /** * Get the customAgentTarget for a specific session type. * When set, the mode picker should show filtered custom agents matching this target. */ getCustomAgentTargetForSessionType(chatSessionType: string): Target; requiresCustomModelsForSessionType(chatSessionType: string): boolean; supportsAutoModelForSessionType(chatSessionType: string): boolean; supportsDelegationForSessionType(chatSessionType: string): boolean; requiresCopilotSignInForSessionType(chatSessionType: string): boolean; sessionSupportsFork(sessionResource: URI): boolean; forkChatSession(sessionResource: URI, request: IChatSessionRequestHistoryItem | undefined, token: CancellationToken, options?: IChatSessionForkOptions): Promise; sessionSupportsSideChat(sessionResource: URI): boolean; observeSideChatOrigin(sessionResource: URI): IObservable; createSideChat(sessionResource: URI, turnId: string, token: CancellationToken, selection?: IChatSideChatSelection): Promise; sessionSupportsRename(sessionResource: URI): boolean; renameChatSession(sessionResource: URI, title: string, token: CancellationToken): Promise; getContentProviderSchemes(): string[]; } export declare enum ChatSessionPosition { Editor = "editor", Sidebar = "sidebar" } type NewChatSessionSendOptions = { readonly prompt: string; readonly attachedContext?: IChatRequestVariableEntry[]; readonly initialSessionOptions?: ReadonlyChatSessionOptionsMap; readonly sessionToolIds?: readonly string[]; /** * A prior conversation to seed into the new session as real, editable turns * ("Continue in…" migration). Consumed once when the backend session is * created; see {@link IAgentHostImportConversationStore}. */ readonly importConversation?: IAgentHostImportConversation; }; export type NewChatSessionOpenOptions = { readonly type: string; readonly position: ChatSessionPosition; readonly displayName: string; /** Open a prepared session instead of allocating a new draft. */ readonly sessionResource?: URI; /** * When set, the editor showing this (source) session resource is replaced * in place with the newly opened session. The source resource is resolved * to its concrete editor at replace time, so the correct tab is replaced * even if the user activated a different editor during the async setup. */ readonly replaceEditorForResource?: URI; /** Revalidate the source after asynchronous setup, before changing its displayed conversation. */ readonly beforeOpen?: () => void; }; export declare function openChatSession(accessor: ServicesAccessor, openOptions: NewChatSessionOpenOptions, chatSendOptions?: NewChatSessionSendOptions): Promise; export declare function getResourceForNewChatSession(options: NewChatSessionOpenOptions): URI; export declare function getSessionStatusForModel(model: IChatModel): ChatSessionStatus | undefined; export declare function chatResponseStateToSessionStatus(state: ResponseModelState): ChatSessionStatus; export {};