Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetup.ts
4780 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { ICommandService } from '../../../../../platform/commands/common/commands.js';
7
import product from '../../../../../platform/product/common/product.js';
8
9
const defaultChat = {
10
completionsRefreshTokenCommand: product.defaultChatAgent?.completionsRefreshTokenCommand ?? '',
11
chatRefreshTokenCommand: product.defaultChatAgent?.chatRefreshTokenCommand ?? '',
12
};
13
14
export type InstallChatClassification = {
15
owner: 'bpasero';
16
comment: 'Provides insight into chat installation.';
17
installResult: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether the extension was installed successfully, cancelled or failed to install.' };
18
installDuration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The duration it took to install the extension.' };
19
signUpErrorCode: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The error code in case of an error signing up.' };
20
provider: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The provider used for the chat installation.' };
21
};
22
export type InstallChatEvent = {
23
installResult: 'installed' | 'alreadyInstalled' | 'cancelled' | 'failedInstall' | 'failedNotSignedIn' | 'failedSignUp' | 'failedNotTrusted' | 'failedNoSession' | 'failedMaybeLater' | 'failedEnterpriseSetup';
24
installDuration: number;
25
signUpErrorCode: number | undefined;
26
provider: string | undefined;
27
};
28
29
export enum ChatSetupAnonymous {
30
Disabled = 0,
31
EnabledWithDialog = 1,
32
EnabledWithoutDialog = 2
33
}
34
35
export enum ChatSetupStep {
36
Initial = 1,
37
SigningIn,
38
Installing
39
}
40
41
export enum ChatSetupStrategy {
42
Canceled = 0,
43
DefaultSetup = 1,
44
SetupWithoutEnterpriseProvider = 2,
45
SetupWithEnterpriseProvider = 3,
46
SetupWithGoogleProvider = 4,
47
SetupWithAppleProvider = 5
48
}
49
50
export type ChatSetupResultValue = boolean /* success */ | undefined /* canceled */;
51
52
export interface IChatSetupResult {
53
readonly success: ChatSetupResultValue;
54
readonly dialogSkipped: boolean;
55
}
56
57
export function refreshTokens(commandService: ICommandService): void {
58
// ugly, but we need to signal to the extension that entitlements changed
59
commandService.executeCommand(defaultChat.completionsRefreshTokenCommand);
60
commandService.executeCommand(defaultChat.chatRefreshTokenCommand);
61
}
62
63