Path: blob/main/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetup.ts
4780 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { ICommandService } from '../../../../../platform/commands/common/commands.js';6import product from '../../../../../platform/product/common/product.js';78const defaultChat = {9completionsRefreshTokenCommand: product.defaultChatAgent?.completionsRefreshTokenCommand ?? '',10chatRefreshTokenCommand: product.defaultChatAgent?.chatRefreshTokenCommand ?? '',11};1213export type InstallChatClassification = {14owner: 'bpasero';15comment: 'Provides insight into chat installation.';16installResult: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the extension was installed successfully, cancelled or failed to install.' };17installDuration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The duration it took to install the extension.' };18signUpErrorCode: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The error code in case of an error signing up.' };19provider: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The provider used for the chat installation.' };20};21export type InstallChatEvent = {22installResult: 'installed' | 'alreadyInstalled' | 'cancelled' | 'failedInstall' | 'failedNotSignedIn' | 'failedSignUp' | 'failedNotTrusted' | 'failedNoSession' | 'failedMaybeLater' | 'failedEnterpriseSetup';23installDuration: number;24signUpErrorCode: number | undefined;25provider: string | undefined;26};2728export enum ChatSetupAnonymous {29Disabled = 0,30EnabledWithDialog = 1,31EnabledWithoutDialog = 232}3334export enum ChatSetupStep {35Initial = 1,36SigningIn,37Installing38}3940export enum ChatSetupStrategy {41Canceled = 0,42DefaultSetup = 1,43SetupWithoutEnterpriseProvider = 2,44SetupWithEnterpriseProvider = 3,45SetupWithGoogleProvider = 4,46SetupWithAppleProvider = 547}4849export type ChatSetupResultValue = boolean /* success */ | undefined /* canceled */;5051export interface IChatSetupResult {52readonly success: ChatSetupResultValue;53readonly dialogSkipped: boolean;54}5556export function refreshTokens(commandService: ICommandService): void {57// ugly, but we need to signal to the extension that entitlements changed58commandService.executeCommand(defaultChat.completionsRefreshTokenCommand);59commandService.executeCommand(defaultChat.chatRefreshTokenCommand);60}616263