@codingame/monaco-vscode-chat-service-override 4.5.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/chat.js +6 -6
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClear.js +2 -2
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +32 -45
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +52 -12
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +3 -3
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -12
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +35 -72
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +83 -6
  10. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +23 -13
  11. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +3 -23
  12. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +2 -1
  13. package/vscode/src/vs/workbench/contrib/chat/browser/{chatContributionServiceImpl.js → chatParticipantContributions.js} +43 -139
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +33 -26
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +48 -40
  16. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +5 -5
  17. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +76 -122
  18. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +5 -4
  19. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +131 -0
  20. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +7 -0
  21. package/vscode/src/vs/workbench/contrib/chat/common/voiceChat.js +4 -4
  22. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +1 -4
@@ -2,6 +2,7 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
3
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
4
4
  import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
5
+ import { CHAT_PROVIDER_ID } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatParticipantContribTypes';
5
6
 
6
7
  let ChatWidgetHistoryService = class ChatWidgetHistoryService {
7
8
  constructor(storageService) {
@@ -14,14 +15,14 @@ let ChatWidgetHistoryService = class ChatWidgetHistoryService {
14
15
  }
15
16
  this.viewState = loadedState;
16
17
  }
17
- getHistory(providerId) {
18
- return this.viewState.history?.[providerId] ?? [];
18
+ getHistory() {
19
+ return this.viewState.history?.[CHAT_PROVIDER_ID] ?? [];
19
20
  }
20
- saveHistory(providerId, history) {
21
+ saveHistory(history) {
21
22
  if (!this.viewState.history) {
22
23
  this.viewState.history = {};
23
24
  }
24
- this.viewState.history[providerId] = history;
25
+ this.viewState.history[CHAT_PROVIDER_ID] = history;
25
26
  this.memento.saveMemento();
26
27
  }
27
28
  clearHistory() {
@@ -0,0 +1,131 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
5
+ import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
6
+ import { Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
7
+ import { IExtensionFeaturesManagementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures.service';
8
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
9
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
10
+
11
+ var LanguageModelStatsService_1;
12
+ const _moduleId = "vs/workbench/contrib/chat/common/languageModelStats";
13
+ let LanguageModelStatsService = class LanguageModelStatsService extends Disposable {
14
+ static { LanguageModelStatsService_1 = this; }
15
+ static { this.MODEL_STATS_STORAGE_KEY_PREFIX = 'languageModelStats.'; }
16
+ static { this.MODEL_ACCESS_STORAGE_KEY_PREFIX = 'languageModelAccess.'; }
17
+ constructor(extensionFeaturesManagementService, _storageService) {
18
+ super();
19
+ this.extensionFeaturesManagementService = extensionFeaturesManagementService;
20
+ this._storageService = _storageService;
21
+ this._onDidChangeStats = this._register(( (new Emitter())));
22
+ this.onDidChangeLanguageMoelStats = this._onDidChangeStats.event;
23
+ this.sessionStats = ( (new Map()));
24
+ this._register(_storageService.onDidChangeValue(-1 , undefined, this._store)(e => {
25
+ const model = this.getModel(e.key);
26
+ if (model) {
27
+ this._onDidChangeStats.fire(model);
28
+ }
29
+ }));
30
+ }
31
+ hasAccessedModel(extensionId, model) {
32
+ return this.getAccessExtensions(model).includes(extensionId.toLowerCase());
33
+ }
34
+ async update(model, extensionId, agent, tokenCount) {
35
+ await this.extensionFeaturesManagementService.getAccess(extensionId, 'languageModels');
36
+ this.addAccess(model, extensionId.value);
37
+ let sessionStats = this.sessionStats.get(model);
38
+ if (!sessionStats) {
39
+ sessionStats = { extensions: [] };
40
+ this.sessionStats.set(model, sessionStats);
41
+ }
42
+ this.add(sessionStats, extensionId.value, agent, tokenCount);
43
+ this.write(model, extensionId.value, agent, tokenCount);
44
+ this._onDidChangeStats.fire(model);
45
+ }
46
+ addAccess(model, extensionId) {
47
+ extensionId = extensionId.toLowerCase();
48
+ const extensions = this.getAccessExtensions(model);
49
+ if (!extensions.includes(extensionId)) {
50
+ extensions.push(extensionId);
51
+ this._storageService.store(this.getAccessKey(model), JSON.stringify(extensions), -1 , 0 );
52
+ }
53
+ }
54
+ getAccessExtensions(model) {
55
+ const key = this.getAccessKey(model);
56
+ const data = this._storageService.get(key, -1 );
57
+ try {
58
+ if (data) {
59
+ const parsed = JSON.parse(data);
60
+ if (Array.isArray(parsed)) {
61
+ return parsed;
62
+ }
63
+ }
64
+ }
65
+ catch (e) {
66
+ }
67
+ return [];
68
+ }
69
+ async write(model, extensionId, participant, tokenCount) {
70
+ const modelStats = await this.read(model);
71
+ this.add(modelStats, extensionId, participant, tokenCount);
72
+ this._storageService.store(this.getKey(model), JSON.stringify(modelStats), -1 , 0 );
73
+ }
74
+ add(modelStats, extensionId, participant, tokenCount) {
75
+ let extensionStats = modelStats.extensions.find(e => ExtensionIdentifier.equals(e.extensionId, extensionId));
76
+ if (!extensionStats) {
77
+ extensionStats = { extensionId, requestCount: 0, tokenCount: 0, participants: [] };
78
+ modelStats.extensions.push(extensionStats);
79
+ }
80
+ if (participant) {
81
+ let participantStats = extensionStats.participants.find(p => p.id === participant);
82
+ if (!participantStats) {
83
+ participantStats = { id: participant, requestCount: 0, tokenCount: 0 };
84
+ extensionStats.participants.push(participantStats);
85
+ }
86
+ participantStats.requestCount++;
87
+ participantStats.tokenCount += tokenCount ?? 0;
88
+ }
89
+ else {
90
+ extensionStats.requestCount++;
91
+ extensionStats.tokenCount += tokenCount ?? 0;
92
+ }
93
+ }
94
+ async read(model) {
95
+ try {
96
+ const value = this._storageService.get(this.getKey(model), -1 );
97
+ if (value) {
98
+ return JSON.parse(value);
99
+ }
100
+ }
101
+ catch (error) {
102
+ }
103
+ return { extensions: [] };
104
+ }
105
+ getModel(key) {
106
+ if (key.startsWith(LanguageModelStatsService_1.MODEL_STATS_STORAGE_KEY_PREFIX)) {
107
+ return key.substring(LanguageModelStatsService_1.MODEL_STATS_STORAGE_KEY_PREFIX.length);
108
+ }
109
+ return undefined;
110
+ }
111
+ getKey(model) {
112
+ return `${LanguageModelStatsService_1.MODEL_STATS_STORAGE_KEY_PREFIX}${model}`;
113
+ }
114
+ getAccessKey(model) {
115
+ return `${LanguageModelStatsService_1.MODEL_ACCESS_STORAGE_KEY_PREFIX}${model}`;
116
+ }
117
+ };
118
+ LanguageModelStatsService = LanguageModelStatsService_1 = ( (__decorate([
119
+ ( (__param(0, IExtensionFeaturesManagementService))),
120
+ ( (__param(1, IStorageService)))
121
+ ], LanguageModelStatsService)));
122
+ ( (Registry.as(Extensions.ExtensionFeaturesRegistry))).registerExtensionFeature({
123
+ id: 'languageModels',
124
+ label: ( localizeWithPath(_moduleId, 0, "Language Models")),
125
+ description: ( localizeWithPath(_moduleId, 1, "Language models usage statistics of this extension.")),
126
+ access: {
127
+ canToggle: false
128
+ },
129
+ });
130
+
131
+ export { LanguageModelStatsService };
@@ -38,6 +38,13 @@ class LanguageModelsService {
38
38
  }
39
39
  return provider.provideChatResponse(messages, from, options, progress, token);
40
40
  }
41
+ computeTokenLength(identifier, message, token) {
42
+ const provider = this._providers.get(identifier);
43
+ if (!provider) {
44
+ throw ( new Error(`Chat response provider with identifier ${identifier} is not registered.`));
45
+ }
46
+ return provider.provideTokenCount(message, token);
47
+ }
41
48
  }
42
49
 
43
50
  export { LanguageModelsService };
@@ -35,13 +35,13 @@ let VoiceChatService = class VoiceChatService extends Disposable {
35
35
  createPhrases(model) {
36
36
  const phrases = ( new Map());
37
37
  for (const agent of this.chatAgentService.getActivatedAgents()) {
38
- const agentPhrase = `${VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.AGENT_PREFIX]} ${VoiceChatService_1.CHAT_AGENT_ALIAS.get(agent.id) ?? agent.id}`.toLowerCase();
39
- phrases.set(agentPhrase, { agent: agent.id });
38
+ const agentPhrase = `${VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.AGENT_PREFIX]} ${VoiceChatService_1.CHAT_AGENT_ALIAS.get(agent.name) ?? agent.name}`.toLowerCase();
39
+ phrases.set(agentPhrase, { agent: agent.name });
40
40
  for (const slashCommand of agent.slashCommands) {
41
41
  const slashCommandPhrase = `${VoiceChatService_1.PHRASES_LOWER[VoiceChatService_1.COMMAND_PREFIX]} ${slashCommand.name}`.toLowerCase();
42
- phrases.set(slashCommandPhrase, { agent: agent.id, command: slashCommand.name });
42
+ phrases.set(slashCommandPhrase, { agent: agent.name, command: slashCommand.name });
43
43
  const agentSlashCommandPhrase = `${agentPhrase} ${slashCommandPhrase}`.toLowerCase();
44
- phrases.set(agentSlashCommandPhrase, { agent: agent.id, command: slashCommand.name });
44
+ phrases.set(agentSlashCommandPhrase, { agent: agent.name, command: slashCommand.name });
45
45
  }
46
46
  }
47
47
  return phrases;
@@ -1,7 +1,7 @@
1
1
  import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
2
2
  import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
3
3
  import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
4
- import { InlineAccessibilityHelpContribution, StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, ReRunRequestAction, ReRunRequestWithIntentDetectionAction, DiscardHunkAction, DiscardAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, CancelSessionAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, ReportIssueForBugCommand, AcceptChanges, CopyRecordings } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
4
+ import { InlineAccessibilityHelpContribution, StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, DiscardAction, DiscardToClipboardAction, DiscardUndoToNewFileAction, CancelSessionAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges, CopyRecordings } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
5
5
  import { INLINE_CHAT_ID, INTERACTIVE_EDITOR_ACCESSIBILITY_HELP_ID } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
6
6
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
7
  import '../common/inlineChatServiceImpl.js';
@@ -18,8 +18,6 @@ registerAction2(StartSessionAction);
18
18
  registerAction2(CloseAction);
19
19
  registerAction2(ConfigureInlineChatAction);
20
20
  registerAction2(UnstashSessionAction);
21
- registerAction2(ReRunRequestAction);
22
- registerAction2(ReRunRequestWithIntentDetectionAction);
23
21
  registerAction2(DiscardHunkAction);
24
22
  registerAction2(DiscardAction);
25
23
  registerAction2(DiscardToClipboardAction);
@@ -32,7 +30,6 @@ registerAction2(ArrowOutDownAction);
32
30
  registerAction2(FocusInlineChat);
33
31
  registerAction2(ViewInChatAction);
34
32
  registerAction2(ToggleDiffForChange);
35
- registerAction2(ReportIssueForBugCommand);
36
33
  registerAction2(AcceptChanges);
37
34
  registerAction2(CopyRecordings);
38
35
  const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));