Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/log/vscode-node/extensionStateCommand.ts
13399 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 * as vscode from 'vscode';
7
import { IAuthenticationService } from '../../../platform/authentication/common/authentication';
8
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
9
import { ILogService } from '../../../platform/log/common/logService';
10
import { ITelemetryService } from '../../../platform/telemetry/common/telemetry';
11
import { Disposable } from '../../../util/vs/base/common/lifecycle';
12
import { IExtensionContribution } from '../../common/contributions';
13
import { IToolsService } from '../../tools/common/toolsService';
14
15
export class ExtensionStateCommandContribution extends Disposable implements IExtensionContribution {
16
id = 'extensionStateCommand';
17
18
constructor(
19
@ILogService private readonly _logService: ILogService,
20
@IAuthenticationService private readonly _authenticationService: IAuthenticationService,
21
@IEndpointProvider private readonly _endpointProvider: IEndpointProvider,
22
@IToolsService private readonly _toolsService: IToolsService,
23
@ITelemetryService private readonly _telemetryService: ITelemetryService,
24
) {
25
super();
26
27
this._register(vscode.commands.registerCommand('github.copilot.debug.extensionState', async () => {
28
await this._logExtensionState();
29
}));
30
}
31
32
private async _logExtensionState(): Promise<void> {
33
const lines: string[] = [
34
'[ExtensionState] ===============================================================',
35
'[ExtensionState] INCLUDE THIS INFORMATION IF YOU ARE OPENING AN ISSUE',
36
'[ExtensionState] ===============================================================',
37
];
38
39
// Auth state
40
const hasAnySession = !!this._authenticationService.anyGitHubSession;
41
const hasPermissiveSession = !!this._authenticationService.permissiveGitHubSession;
42
const hasCopilotToken = !!this._authenticationService.copilotToken;
43
lines.push(` Auth: anyGitHubSession=${hasAnySession}, repoGitHubSession=${hasPermissiveSession}, copilotToken=${hasCopilotToken}`);
44
45
// Username
46
const session = this._authenticationService.anyGitHubSession;
47
if (session) {
48
lines.push(` Username: ${session.account.label}`);
49
} else {
50
lines.push(' Username: (not signed in) - check the GitHub Authentication output channel for more details');
51
}
52
53
// Proxy setup
54
const proxySupport = vscode.workspace.getConfiguration('http').get<string>('proxySupport', 'override');
55
const proxyUrl = vscode.workspace.getConfiguration('http').get<string>('proxy', '');
56
const proxyConfigured = proxyUrl ? 'true' : 'false';
57
lines.push(` Proxy: http.proxySupport=${proxySupport}, http.proxy=${proxyUrl ? '(configured)' : '(not configured)'}`);
58
59
let languageModelsLoaded = 'false';
60
let languageModelCount = 0;
61
let copilotProviderRegistered = 'false';
62
let copilotModelCount = 0;
63
let copilotEmbeddingsRegistered = 'false';
64
let toolCount = 0;
65
66
if (session) {
67
// Language models
68
try {
69
const endpoints = await this._endpointProvider.getAllChatEndpoints();
70
languageModelCount = endpoints.length;
71
languageModelsLoaded = String(endpoints.length > 0);
72
lines.push(` Language models loaded: ${endpoints.length > 0} (count: ${endpoints.length})`);
73
} catch (e) {
74
lines.push(` Language models loaded: false (error: ${e})`);
75
}
76
77
// Copilot chat provider registration
78
try {
79
const copilotModels = await vscode.lm.selectChatModels({ vendor: 'copilot' });
80
copilotModelCount = copilotModels.length;
81
copilotProviderRegistered = String(copilotModels.length > 0);
82
lines.push(` Copilot chat provider registered: ${copilotModels.length > 0} (models: ${copilotModels.length})`);
83
} catch (e) {
84
lines.push(` Copilot chat provider registered: false (error: ${e})`);
85
}
86
87
// Copilot embeddings model registration
88
const copilotEmbeddings = vscode.lm.embeddingModels.filter(m => m.startsWith('copilot.'));
89
copilotEmbeddingsRegistered = String(copilotEmbeddings.length > 0);
90
lines.push(` Copilot embeddings model registered: ${copilotEmbeddings.length > 0} (models: [${copilotEmbeddings.join(', ')}])`);
91
92
// Tools
93
toolCount = this._toolsService.tools.length;
94
lines.push(` Tools loaded: ${toolCount > 0} (count: ${toolCount})`);
95
}
96
97
lines.push('[ExtensionState] ===============================================================');
98
99
this._logService.info(lines.join('\n'));
100
101
/* __GDPR__
102
"extensionState" : {
103
"owner": "TylerLeonhardt",
104
"comment": "Extension state diagnostic information",
105
"hasAnySession": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether a GitHub session exists" },
106
"hasPermissiveSession": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether a permissive GitHub session exists" },
107
"hasCopilotToken": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether a Copilot token exists" },
108
"proxySupport": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "The http.proxySupport setting value" },
109
"proxyConfigured": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether an http proxy is configured" },
110
"languageModelsLoaded": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether language models are loaded" },
111
"copilotProviderRegistered": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the Copilot chat provider is registered" },
112
"copilotEmbeddingsRegistered": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether Copilot embeddings models are registered" },
113
"languageModelCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Number of language models loaded", "isMeasurement": true },
114
"copilotModelCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Number of Copilot chat models", "isMeasurement": true },
115
"toolCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Number of tools loaded", "isMeasurement": true }
116
}
117
*/
118
this._telemetryService.sendMSFTTelemetryEvent(
119
'extensionState',
120
{
121
hasAnySession: String(hasAnySession),
122
hasPermissiveSession: String(hasPermissiveSession),
123
hasCopilotToken: String(hasCopilotToken),
124
proxySupport,
125
proxyConfigured,
126
languageModelsLoaded,
127
copilotProviderRegistered,
128
copilotEmbeddingsRegistered,
129
},
130
{
131
languageModelCount,
132
copilotModelCount,
133
toolCount,
134
}
135
);
136
}
137
}
138
139