@codingame/monaco-vscode-chat-service-override 9.0.2 → 10.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 (41) hide show
  1. package/chat.js +8 -2
  2. package/package.json +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +24 -25
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +5 -7
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +100 -293
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +115 -26
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +6 -8
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -7
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +448 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +58 -43
  14. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +2 -4
  15. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +7 -2
  16. package/vscode/src/vs/workbench/contrib/chat/browser/chatGettingStarted.js +131 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.js +88 -88
  18. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +26 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +4 -2
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +6 -22
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -17
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +21 -14
  23. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  24. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +7 -1
  25. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +27 -0
  26. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +52 -0
  27. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +25 -29
  28. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +8 -1
  29. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +1 -2
  30. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +7 -8
  31. package/vscode/src/vs/workbench/contrib/chat/common/languageModelToolsService.js +70 -20
  32. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +172 -0
  33. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +30 -12
  34. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
  35. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +11 -15
  36. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -2
  37. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +5 -6
  38. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +5 -6
  39. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +5 -8
  40. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatContextAttachments.js +0 -58
  41. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +0 -412
@@ -1,7 +1,6 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
3
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
5
4
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
6
5
  import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
7
6
  import { Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
@@ -21,7 +20,7 @@ let LanguageModelStatsService = class LanguageModelStatsService extends Disposab
21
20
  this._onDidChangeStats = this._register(( (new Emitter())));
22
21
  this.onDidChangeLanguageMoelStats = this._onDidChangeStats.event;
23
22
  this.sessionStats = ( (new Map()));
24
- this._register(_storageService.onDidChangeValue(StorageScope.APPLICATION, undefined, this._store)(e => {
23
+ this._register(_storageService.onDidChangeValue(-1 , undefined, this._store)(e => {
25
24
  const model = this.getModel(e.key);
26
25
  if (model) {
27
26
  this._onDidChangeStats.fire(model);
@@ -48,12 +47,12 @@ let LanguageModelStatsService = class LanguageModelStatsService extends Disposab
48
47
  const extensions = this.getAccessExtensions(model);
49
48
  if (!extensions.includes(extensionId)) {
50
49
  extensions.push(extensionId);
51
- this._storageService.store(this.getAccessKey(model), JSON.stringify(extensions), StorageScope.APPLICATION, StorageTarget.USER);
50
+ this._storageService.store(this.getAccessKey(model), JSON.stringify(extensions), -1 , 0 );
52
51
  }
53
52
  }
54
53
  getAccessExtensions(model) {
55
54
  const key = this.getAccessKey(model);
56
- const data = this._storageService.get(key, StorageScope.APPLICATION);
55
+ const data = this._storageService.get(key, -1 );
57
56
  try {
58
57
  if (data) {
59
58
  const parsed = JSON.parse(data);
@@ -69,7 +68,7 @@ let LanguageModelStatsService = class LanguageModelStatsService extends Disposab
69
68
  async write(model, extensionId, participant, tokenCount) {
70
69
  const modelStats = await this.read(model);
71
70
  this.add(modelStats, extensionId, participant, tokenCount);
72
- this._storageService.store(this.getKey(model), JSON.stringify(modelStats), StorageScope.APPLICATION, StorageTarget.USER);
71
+ this._storageService.store(this.getKey(model), JSON.stringify(modelStats), -1 , 0 );
73
72
  }
74
73
  add(modelStats, extensionId, participant, tokenCount) {
75
74
  let extensionStats = modelStats.extensions.find(e => ExtensionIdentifier.equals(e.extensionId, extensionId));
@@ -93,7 +92,7 @@ let LanguageModelStatsService = class LanguageModelStatsService extends Disposab
93
92
  }
94
93
  async read(model) {
95
94
  try {
96
- const value = this._storageService.get(this.getKey(model), StorageScope.APPLICATION);
95
+ const value = this._storageService.get(this.getKey(model), -1 );
97
96
  if (value) {
98
97
  return JSON.parse(value);
99
98
  }
@@ -121,8 +120,8 @@ LanguageModelStatsService = LanguageModelStatsService_1 = ( (__decorate([
121
120
  ], LanguageModelStatsService)));
122
121
  ( (Registry.as(Extensions.ExtensionFeaturesRegistry))).registerExtensionFeature({
123
122
  id: 'languageModels',
124
- label: ( localize(3060, "Language Models")),
125
- description: ( localize(3061, "Language models usage statistics of this extension.")),
123
+ label: ( localize(3130, "Language Models")),
124
+ description: ( localize(3131, "Language models usage statistics of this extension.")),
126
125
  access: {
127
126
  canToggle: false
128
127
  },
@@ -1,21 +1,26 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
3
+ import { CancellationError } from 'vscode/vscode/vs/base/common/errors';
3
4
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
5
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
5
6
  import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
7
+ import { localize } from 'vscode/vscode/vs/nls';
6
8
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
7
9
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
10
+ import { ChatToolInvocation } from './chatProgressTypes/chatToolInvocation.js';
11
+ import { IChatService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatService.service';
8
12
 
9
13
  let LanguageModelToolsService = class LanguageModelToolsService extends Disposable {
10
- constructor(_extensionService, _contextKeyService) {
14
+ constructor(_extensionService, _contextKeyService, _chatService) {
11
15
  super();
12
16
  this._extensionService = _extensionService;
13
17
  this._contextKeyService = _contextKeyService;
14
- this._onDidChangeTools = ( new Emitter());
18
+ this._chatService = _chatService;
19
+ this._onDidChangeTools = ( (new Emitter()));
15
20
  this.onDidChangeTools = this._onDidChangeTools.event;
16
- this._onDidChangeToolsScheduler = ( new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750));
17
- this._tools = ( new Map());
18
- this._toolContextKeys = ( new Set());
21
+ this._onDidChangeToolsScheduler = ( (new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750)));
22
+ this._tools = ( (new Map()));
23
+ this._toolContextKeys = ( (new Set()));
19
24
  this._register(this._contextKeyService.onDidChangeContext(e => {
20
25
  if (e.affectsSome(this._toolContextKeys)) {
21
26
  this._onDidChangeToolsScheduler.schedule();
@@ -23,8 +28,11 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
23
28
  }));
24
29
  }
25
30
  registerToolData(toolData) {
26
- if (( this._tools.has(toolData.id))) {
27
- throw ( new Error(`Tool "${toolData.id}" is already registered.`));
31
+ if (( (this._tools.has(toolData.id)))) {
32
+ throw ( (new Error(`Tool "${toolData.id}" is already registered.`)));
33
+ }
34
+ if (!toolData.supportedContentTypes.includes('text/plain')) {
35
+ toolData.supportedContentTypes.push('text/plain');
28
36
  }
29
37
  this._tools.set(toolData.id, { data: toolData });
30
38
  this._onDidChangeToolsScheduler.schedule();
@@ -37,17 +45,17 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
37
45
  }
38
46
  _refreshAllToolContextKeys() {
39
47
  this._toolContextKeys.clear();
40
- for (const tool of ( this._tools.values())) {
48
+ for (const tool of ( (this._tools.values()))) {
41
49
  tool.data.when?.keys().forEach(key => this._toolContextKeys.add(key));
42
50
  }
43
51
  }
44
- registerToolImplementation(name, tool) {
45
- const entry = this._tools.get(name);
52
+ registerToolImplementation(id, tool) {
53
+ const entry = this._tools.get(id);
46
54
  if (!entry) {
47
- throw ( new Error(`Tool "${name}" was not contributed.`));
55
+ throw ( (new Error(`Tool "${id}" was not contributed.`)));
48
56
  }
49
57
  if (entry.impl) {
50
- throw ( new Error(`Tool "${name}" already has an implementation.`));
58
+ throw ( (new Error(`Tool "${id}" already has an implementation.`)));
51
59
  }
52
60
  entry.impl = tool;
53
61
  return toDisposable(() => {
@@ -55,7 +63,7 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
55
63
  });
56
64
  }
57
65
  getTools() {
58
- const toolDatas = ( Iterable.map(( this._tools.values()), i => i.data));
66
+ const toolDatas = ( (Iterable.map( (this._tools.values()), i => i.data)));
59
67
  return Iterable.filter(toolDatas, toolData => !toolData.when || this._contextKeyService.contextMatchesRules(toolData.when));
60
68
  }
61
69
  getTool(id) {
@@ -81,21 +89,63 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
81
89
  async invokeTool(dto, countTokens, token) {
82
90
  let tool = this._tools.get(dto.toolId);
83
91
  if (!tool) {
84
- throw ( new Error(`Tool ${dto.toolId} was not contributed`));
92
+ throw ( (new Error(`Tool ${dto.toolId} was not contributed`)));
85
93
  }
86
94
  if (!tool.impl) {
87
95
  await this._extensionService.activateByEvent(`onLanguageModelTool:${dto.toolId}`);
88
96
  tool = this._tools.get(dto.toolId);
89
97
  if (!tool?.impl) {
90
- throw ( new Error(`Tool ${dto.toolId} does not have an implementation registered.`));
98
+ throw ( (new Error(`Tool ${dto.toolId} does not have an implementation registered.`)));
99
+ }
100
+ }
101
+ let toolInvocation;
102
+ if (dto.context) {
103
+ const model = this._chatService.getSession(dto.context?.sessionId);
104
+ const request = model.getRequests().at(-1);
105
+ const participantName = request.response?.agent?.fullName ?? '';
106
+ const getConfirmationMessages = async () => {
107
+ if (!tool.data.requiresConfirmation) {
108
+ return undefined;
109
+ }
110
+ return (await tool.impl.provideToolConfirmationMessages(participantName, dto.parameters, token)) ?? {
111
+ title: ( localize(3136, "Use {0}?", `"${tool.data.displayName ?? tool.data.id}"`)),
112
+ message: ( localize(
113
+ 3137,
114
+ "{0} will use {1}.",
115
+ participantName,
116
+ `"${tool.data.displayName ?? tool.data.id}"`
117
+ )),
118
+ };
119
+ };
120
+ const [invocationMessage, confirmationMessages] = await Promise.all([
121
+ tool.impl.provideToolInvocationMessage(dto.parameters, token),
122
+ getConfirmationMessages()
123
+ ]);
124
+ const defaultMessage = ( localize(3138, "Using {0}", `"${tool.data.displayName ?? tool.data.id}"`));
125
+ toolInvocation = ( (new ChatToolInvocation(invocationMessage ?? defaultMessage, confirmationMessages)));
126
+ token.onCancellationRequested(() => {
127
+ toolInvocation.confirmed.complete(false);
128
+ });
129
+ model.acceptResponseProgress(request, toolInvocation);
130
+ if (tool.data.requiresConfirmation) {
131
+ const userConfirmed = await toolInvocation.confirmed.p;
132
+ if (!userConfirmed) {
133
+ throw ( (new CancellationError()));
134
+ }
91
135
  }
92
136
  }
93
- return tool.impl.invoke(dto, countTokens, token);
137
+ try {
138
+ return tool.impl.invoke(dto, countTokens, token);
139
+ }
140
+ finally {
141
+ toolInvocation?.complete();
142
+ }
94
143
  }
95
144
  };
96
- LanguageModelToolsService = ( __decorate([
97
- ( __param(0, IExtensionService)),
98
- ( __param(1, IContextKeyService))
99
- ], LanguageModelToolsService));
145
+ LanguageModelToolsService = ( (__decorate([
146
+ ( (__param(0, IExtensionService))),
147
+ ( (__param(1, IContextKeyService))),
148
+ ( (__param(2, IChatService)))
149
+ ], LanguageModelToolsService)));
100
150
 
101
151
  export { LanguageModelToolsService };
@@ -0,0 +1,172 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
+ import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
4
+ import { DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { isFalsyOrWhitespace } from 'vscode/vscode/vs/base/common/strings';
6
+ import { localize } from 'vscode/vscode/vs/nls';
7
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
8
+ import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
9
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
10
+ import { isProposedApiEnabled } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
11
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
12
+ import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
13
+ import { CONTEXT_LANGUAGE_MODELS_ARE_USER_SELECTABLE } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
14
+
15
+ const languageModelType = {
16
+ type: 'object',
17
+ properties: {
18
+ vendor: {
19
+ type: 'string',
20
+ description: ( localize(3122, "A globally unique vendor of language models."))
21
+ }
22
+ }
23
+ };
24
+ const languageModelExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
25
+ extensionPoint: 'languageModels',
26
+ jsonSchema: {
27
+ description: ( localize(3123, "Contribute language models of a specific vendor.")),
28
+ oneOf: [
29
+ languageModelType,
30
+ {
31
+ type: 'array',
32
+ items: languageModelType
33
+ }
34
+ ]
35
+ },
36
+ activationEventsGenerator: (contribs, result) => {
37
+ for (const contrib of contribs) {
38
+ result.push(`onLanguageModelChat:${contrib.vendor}`);
39
+ }
40
+ }
41
+ });
42
+ let LanguageModelsService = class LanguageModelsService {
43
+ constructor(_extensionService, _logService, _contextKeyService) {
44
+ this._extensionService = _extensionService;
45
+ this._logService = _logService;
46
+ this._contextKeyService = _contextKeyService;
47
+ this._store = ( (new DisposableStore()));
48
+ this._providers = ( (new Map()));
49
+ this._vendors = ( (new Set()));
50
+ this._onDidChangeProviders = this._store.add(( (new Emitter())));
51
+ this.onDidChangeLanguageModels = this._onDidChangeProviders.event;
52
+ this._hasUserSelectableModels = CONTEXT_LANGUAGE_MODELS_ARE_USER_SELECTABLE.bindTo(this._contextKeyService);
53
+ this._store.add(languageModelExtensionPoint.setHandler((extensions) => {
54
+ this._vendors.clear();
55
+ for (const extension of extensions) {
56
+ if (!isProposedApiEnabled(extension.description, 'chatProvider')) {
57
+ extension.collector.error(( localize(3124, "This contribution point requires the 'chatProvider' proposal.")));
58
+ continue;
59
+ }
60
+ for (const item of Iterable.wrap(extension.value)) {
61
+ if (( (this._vendors.has(item.vendor)))) {
62
+ extension.collector.error(( localize(
63
+ 3125,
64
+ "The vendor '{0}' is already registered and cannot be registered twice",
65
+ item.vendor
66
+ )));
67
+ continue;
68
+ }
69
+ if (isFalsyOrWhitespace(item.vendor)) {
70
+ extension.collector.error(( localize(3126, "The vendor field cannot be empty.")));
71
+ continue;
72
+ }
73
+ if (item.vendor.trim() !== item.vendor) {
74
+ extension.collector.error(( localize(3127, "The vendor field cannot start or end with whitespace.")));
75
+ continue;
76
+ }
77
+ this._vendors.add(item.vendor);
78
+ }
79
+ }
80
+ const removed = [];
81
+ for (const [identifier, value] of this._providers) {
82
+ if (!( (this._vendors.has(value.metadata.vendor)))) {
83
+ this._providers.delete(identifier);
84
+ removed.push(identifier);
85
+ }
86
+ }
87
+ if (removed.length > 0) {
88
+ this._onDidChangeProviders.fire({ removed });
89
+ }
90
+ }));
91
+ }
92
+ dispose() {
93
+ this._store.dispose();
94
+ this._providers.clear();
95
+ }
96
+ getLanguageModelIds() {
97
+ return Array.from(( (this._providers.keys())));
98
+ }
99
+ lookupLanguageModel(identifier) {
100
+ return this._providers.get(identifier)?.metadata;
101
+ }
102
+ async selectLanguageModels(selector) {
103
+ if (selector.vendor) {
104
+ await this._extensionService.activateByEvent(`onLanguageModelChat:${selector.vendor}}`);
105
+ }
106
+ else {
107
+ const all = ( (Array.from(this._vendors).map(
108
+ vendor => this._extensionService.activateByEvent(`onLanguageModelChat:${vendor}`)
109
+ )));
110
+ await Promise.all(all);
111
+ }
112
+ const result = [];
113
+ for (const [identifier, model] of this._providers) {
114
+ if ((selector.vendor === undefined || model.metadata.vendor === selector.vendor)
115
+ && (selector.family === undefined || model.metadata.family === selector.family)
116
+ && (selector.version === undefined || model.metadata.version === selector.version)
117
+ && (selector.identifier === undefined || model.metadata.id === selector.identifier)
118
+ && (!model.metadata.targetExtensions || ( (model.metadata.targetExtensions.some(candidate => ExtensionIdentifier.equals(candidate, selector.extension)))))) {
119
+ result.push(identifier);
120
+ }
121
+ }
122
+ this._logService.trace('[LM] selected language models', selector, result);
123
+ return result;
124
+ }
125
+ registerLanguageModelChat(identifier, provider) {
126
+ this._logService.trace('[LM] registering language model chat', identifier, provider.metadata);
127
+ if (!( (this._vendors.has(provider.metadata.vendor)))) {
128
+ throw ( (new Error(`Chat response provider uses UNKNOWN vendor ${provider.metadata.vendor}.`)));
129
+ }
130
+ if (( (this._providers.has(identifier)))) {
131
+ throw ( (new Error(
132
+ `Chat response provider with identifier ${identifier} is already registered.`
133
+ )));
134
+ }
135
+ this._providers.set(identifier, provider);
136
+ this._onDidChangeProviders.fire({ added: [{ identifier, metadata: provider.metadata }] });
137
+ this.updateUserSelectableModelsContext();
138
+ return toDisposable(() => {
139
+ this.updateUserSelectableModelsContext();
140
+ if (this._providers.delete(identifier)) {
141
+ this._onDidChangeProviders.fire({ removed: [identifier] });
142
+ this._logService.trace('[LM] UNregistered language model chat', identifier, provider.metadata);
143
+ }
144
+ });
145
+ }
146
+ updateUserSelectableModelsContext() {
147
+ const hasUserSelectableModels = ( (Array.from(( (this._providers.values()))).some(p => p.metadata.isUserSelectable && !p.metadata.isDefault)));
148
+ const hasDefaultModel = ( (Array.from(( (this._providers.values()))).some(p => p.metadata.isDefault)));
149
+ this._hasUserSelectableModels.set(hasUserSelectableModels && hasDefaultModel);
150
+ }
151
+ async sendChatRequest(identifier, from, messages, options, token) {
152
+ const provider = this._providers.get(identifier);
153
+ if (!provider) {
154
+ throw ( (new Error(`Chat response provider with identifier ${identifier} is not registered.`)));
155
+ }
156
+ return provider.sendChatRequest(messages, from, options, token);
157
+ }
158
+ computeTokenLength(identifier, message, token) {
159
+ const provider = this._providers.get(identifier);
160
+ if (!provider) {
161
+ throw ( (new Error(`Chat response provider with identifier ${identifier} is not registered.`)));
162
+ }
163
+ return provider.provideTokenCount(message, token);
164
+ }
165
+ };
166
+ LanguageModelsService = ( (__decorate([
167
+ ( (__param(0, IExtensionService))),
168
+ ( (__param(1, ILogService))),
169
+ ( (__param(2, IContextKeyService)))
170
+ ], LanguageModelsService)));
171
+
172
+ export { LanguageModelsService, languageModelExtensionPoint };
@@ -16,7 +16,7 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
16
16
  }
17
17
  },
18
18
  jsonSchema: {
19
- description: ( localize(7163, 'Contributes a tool that can be invoked by a language model.')),
19
+ description: ( localize(7275, 'Contributes a tool that can be invoked by a language model.')),
20
20
  type: 'array',
21
21
  items: {
22
22
  additionalProperties: false,
@@ -25,13 +25,13 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
25
25
  required: ['id', 'modelDescription'],
26
26
  properties: {
27
27
  id: {
28
- description: ( localize(7164, "A unique id for this tool.")),
28
+ description: ( localize(7276, "A unique id for this tool.")),
29
29
  type: 'string',
30
30
  pattern: '^[\\w-]+$'
31
31
  },
32
32
  name: {
33
33
  description: ( localize(
34
- 7165,
34
+ 7277,
35
35
  "If {0} is enabled for this tool, the user may use '#' with this name to invoke the tool in a query. Otherwise, the name is not required. Name must not contain whitespace.",
36
36
  '`canBeInvokedManually`'
37
37
  )),
@@ -40,34 +40,34 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
40
40
  },
41
41
  displayName: {
42
42
  description: ( localize(
43
- 7166,
43
+ 7278,
44
44
  "A human-readable name for this tool that may be used to describe it in the UI."
45
45
  )),
46
46
  type: 'string'
47
47
  },
48
48
  userDescription: {
49
- description: ( localize(7167, "A description of this tool that may be shown to the user.")),
49
+ description: ( localize(7279, "A description of this tool that may be shown to the user.")),
50
50
  type: 'string'
51
51
  },
52
52
  modelDescription: {
53
- description: ( localize(7168, "A description of this tool that may be passed to a language model.")),
53
+ description: ( localize(7280, "A description of this tool that may be passed to a language model.")),
54
54
  type: 'string'
55
55
  },
56
56
  parametersSchema: {
57
- description: ( localize(7169, "A JSON schema for the parameters this tool accepts.")),
57
+ description: ( localize(7281, "A JSON schema for the parameters this tool accepts.")),
58
58
  type: 'object',
59
59
  $ref: 'http://json-schema.org/draft-07/schema#'
60
60
  },
61
61
  canBeInvokedManually: {
62
62
  description: ( localize(
63
- 7170,
63
+ 7282,
64
64
  "Whether this tool can be invoked manually by the user through the chat UX."
65
65
  )),
66
66
  type: 'boolean'
67
67
  },
68
68
  icon: {
69
69
  description: ( localize(
70
- 7171,
70
+ 7283,
71
71
  "An icon that represents this tool. Either a file path, an object with file paths for dark and light themes, or a theme icon reference, like `\\$(zap)`"
72
72
  )),
73
73
  anyOf: [{
@@ -77,11 +77,11 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
77
77
  type: 'object',
78
78
  properties: {
79
79
  light: {
80
- description: ( localize(7172, 'Icon path when a light theme is used')),
80
+ description: ( localize(7284, 'Icon path when a light theme is used')),
81
81
  type: 'string'
82
82
  },
83
83
  dark: {
84
- description: ( localize(7173, 'Icon path when a dark theme is used')),
84
+ description: ( localize(7285, 'Icon path when a dark theme is used')),
85
85
  type: 'string'
86
86
  }
87
87
  }
@@ -89,10 +89,27 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
89
89
  },
90
90
  when: {
91
91
  markdownDescription: ( localize(
92
- 7174,
92
+ 7286,
93
93
  "Condition which must be true for this tool to be enabled. Note that a tool may still be invoked by another extension even when its `when` condition is false."
94
94
  )),
95
95
  type: 'string'
96
+ },
97
+ supportedContentTypes: {
98
+ markdownDescription: ( localize(
99
+ 7287,
100
+ "The list of content types that this tool can return. It's required that tools support `text/plain`, and that is assumed even if not specified here. Another example could be the contentType exported by the `@vscode/prompt-tsx` library."
101
+ )),
102
+ type: 'array',
103
+ items: {
104
+ type: 'string'
105
+ }
106
+ },
107
+ requiresConfirmation: {
108
+ description: ( localize(
109
+ 7288,
110
+ "Whether this tool requires user confirmation before being executed."
111
+ )),
112
+ type: 'boolean'
96
113
  }
97
114
  }
98
115
  }
@@ -138,6 +155,7 @@ let LanguageModelToolsExtensionPointHandler = class LanguageModelToolsExtensionP
138
155
  ...rawTool,
139
156
  icon,
140
157
  when: rawTool.when ? ContextKeyExpr.deserialize(rawTool.when) : undefined,
158
+ supportedContentTypes: rawTool.supportedContentTypes ? rawTool.supportedContentTypes : [],
141
159
  };
142
160
  const disposable = languageModelToolsService.registerToolData(tool);
143
161
  this._registrationDisposables.set(toToolKey(extension.description.identifier, rawTool.id), disposable);
@@ -20,7 +20,7 @@ var PhraseTextType;
20
20
  const VoiceChatInProgress = ( (new RawContextKey(
21
21
  'voiceChatInProgress',
22
22
  false,
23
- { type: 'boolean', description: ( localize(7175, "A speech-to-text session is in progress for chat.")) }
23
+ { type: 'boolean', description: ( localize(7289, "A speech-to-text session is in progress for chat.")) }
24
24
  )));
25
25
  let VoiceChatService = class VoiceChatService extends Disposable {
26
26
  static { VoiceChatService_1 = this; }
@@ -1,13 +1,11 @@
1
- import { registerEditorContribution, EditorContributionInstantiation } from 'vscode/vscode/vs/editor/browser/editorExtensions';
1
+ import { registerEditorContribution } from 'vscode/vscode/vs/editor/browser/editorExtensions';
2
2
  import { registerAction2, MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
3
3
  import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
4
4
  import { StartSessionAction, CloseAction, ConfigureInlineChatAction, UnstashSessionAction, DiscardHunkAction, DiscardAction, RerunAction, MoveToNextHunk, MoveToPreviousHunk, ArrowOutUpAction, ArrowOutDownAction, FocusInlineChat, ViewInChatAction, ToggleDiffForChange, AcceptChanges } from 'vscode/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatActions';
5
- import { INLINE_CHAT_ID, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_EDITING, MENU_INLINE_CHAT_CONTENT_STATUS, MENU_INLINE_CHAT_WIDGET_STATUS } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
6
- import 'vscode/vscode/vs/platform/instantiation/common/extensions';
5
+ import { INLINE_CHAT_ID, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, CTX_INLINE_CHAT_EDITING, MENU_INLINE_CHAT_WIDGET_STATUS } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
7
6
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
8
- import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
9
7
  import { InlineChatNotebookContribution } from './inlineChatNotebook.js';
10
- import { Extensions, registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
8
+ import { Extensions, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
11
9
  import './inlineChatSavingServiceImpl.js';
12
10
  import { InlineChatAccessibleView } from './inlineChatAccessibleView.js';
13
11
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
@@ -20,15 +18,15 @@ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/cont
20
18
  import { InlineChatAccessibilityHelp } from './inlineChatAccessibilityHelp.js';
21
19
  import { InlineChatExansionContextKey, InlineChatExpandLineAction } from './inlineChatCurrentLine.js';
22
20
 
23
- registerEditorContribution(INLINE_CHAT_ID, InlineChatController, EditorContributionInstantiation.Eager);
24
- registerEditorContribution(InlineChatExansionContextKey.Id, InlineChatExansionContextKey, EditorContributionInstantiation.BeforeFirstInteraction);
21
+ registerEditorContribution(INLINE_CHAT_ID, InlineChatController, 0 );
22
+ registerEditorContribution(InlineChatExansionContextKey.Id, InlineChatExansionContextKey, 2 );
25
23
  registerAction2(InlineChatExpandLineAction);
26
24
  const editActionMenuItem = {
27
25
  group: '0_main',
28
26
  order: 0,
29
27
  command: {
30
28
  id: SubmitAction.ID,
31
- title: ( localize(3076, "Edit Code")),
29
+ title: ( localize(3132, "Edit Code")),
32
30
  },
33
31
  when: ( (ContextKeyExpr.and(
34
32
  CONTEXT_CHAT_INPUT_HAS_TEXT,
@@ -41,7 +39,7 @@ const generateActionMenuItem = {
41
39
  order: 0,
42
40
  command: {
43
41
  id: SubmitAction.ID,
44
- title: ( localize(3077, "Generate")),
42
+ title: ( localize(3133, "Generate")),
45
43
  },
46
44
  when: ( (ContextKeyExpr.and(
47
45
  CONTEXT_CHAT_INPUT_HAS_TEXT,
@@ -49,8 +47,6 @@ const generateActionMenuItem = {
49
47
  (CTX_INLINE_CHAT_EDITING.toNegated())
50
48
  ))),
51
49
  };
52
- MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_CONTENT_STATUS, editActionMenuItem);
53
- MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_CONTENT_STATUS, generateActionMenuItem);
54
50
  MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, editActionMenuItem);
55
51
  MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, generateActionMenuItem);
56
52
  const cancelActionMenuItem = {
@@ -58,8 +54,8 @@ const cancelActionMenuItem = {
58
54
  order: 0,
59
55
  command: {
60
56
  id: CancelAction.ID,
61
- title: ( localize(3078, "Stop Request")),
62
- shortTitle: ( localize(3079, "Stop")),
57
+ title: ( localize(3134, "Cancel Request")),
58
+ shortTitle: ( localize(3135, "Cancel")),
63
59
  },
64
60
  when: ( (ContextKeyExpr.and(CTX_INLINE_CHAT_REQUEST_IN_PROGRESS))),
65
61
  };
@@ -80,7 +76,7 @@ registerAction2(ViewInChatAction);
80
76
  registerAction2(ToggleDiffForChange);
81
77
  registerAction2(AcceptChanges);
82
78
  const workbenchContributionsRegistry = ( (Registry.as(Extensions.Workbench)));
83
- workbenchContributionsRegistry.registerWorkbenchContribution(InlineChatNotebookContribution, LifecyclePhase.Restored);
84
- registerWorkbenchContribution2(InlineChatEnabler.Id, InlineChatEnabler, WorkbenchPhase.AfterRestored);
79
+ workbenchContributionsRegistry.registerWorkbenchContribution(InlineChatNotebookContribution, 3 );
80
+ registerWorkbenchContribution2(InlineChatEnabler.Id, InlineChatEnabler, 3 );
85
81
  AccessibleViewRegistry.register(( (new InlineChatAccessibleView())));
86
82
  AccessibleViewRegistry.register(( (new InlineChatAccessibilityHelp())));
@@ -1,5 +1,4 @@
1
1
  import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
2
- import { AccessibleViewType } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
3
2
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
4
3
  import { getChatAccessibilityHelpProvider } from '../../chat/browser/actions/chatAccessibilityHelp.js';
5
4
  import { CONTEXT_CHAT_INPUT_HAS_FOCUS } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
@@ -9,7 +8,7 @@ class InlineChatAccessibilityHelp {
9
8
  constructor() {
10
9
  this.priority = 106;
11
10
  this.name = 'inlineChat';
12
- this.type = AccessibleViewType.Help;
11
+ this.type = "help" ;
13
12
  this.when = ( ContextKeyExpr.or(CTX_INLINE_CHAT_RESPONSE_FOCUSED, CONTEXT_CHAT_INPUT_HAS_FOCUS));
14
13
  }
15
14
  getProvider(accessor) {
@@ -2,17 +2,16 @@ import { InlineChatController } from 'vscode/vscode/vs/workbench/contrib/inlineC
2
2
  import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
3
3
  import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
4
4
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
5
- import { AccessibleViewType, AccessibleContentProvider, AccessibleViewProviderId } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
5
+ import { AccessibleContentProvider } from 'vscode/vscode/vs/platform/accessibility/browser/accessibleView';
6
6
  import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
7
7
  import { renderMarkdownAsPlaintext } from 'vscode/vscode/vs/base/browser/markdownRenderer';
8
- import { AccessibilityVerbositySettingId } from 'vscode/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
9
8
 
10
9
  class InlineChatAccessibleView {
11
10
  constructor() {
12
11
  this.priority = 100;
13
12
  this.name = 'inlineChat';
14
13
  this.when = ( ContextKeyExpr.or(CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED));
15
- this.type = AccessibleViewType.View;
14
+ this.type = "view" ;
16
15
  }
17
16
  getProvider(accessor) {
18
17
  const codeEditorService = accessor.get(ICodeEditorService);
@@ -29,11 +28,11 @@ class InlineChatAccessibleView {
29
28
  return;
30
29
  }
31
30
  return ( new AccessibleContentProvider(
32
- AccessibleViewProviderId.InlineChat,
33
- { type: AccessibleViewType.View },
31
+ "inlineChat" ,
32
+ { type: "view" },
34
33
  () => renderMarkdownAsPlaintext(( new MarkdownString(responseContent)), true),
35
34
  () => controller.focus(),
36
- AccessibilityVerbositySettingId.InlineChat
35
+ "accessibility.verbosity.inlineChat"
37
36
  ));
38
37
  }
39
38
  }