@codingame/monaco-vscode-chat-service-override 13.1.6 → 14.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.
- package/index.js +9 -9
- package/package.json +20 -20
- package/vscode/src/vs/base/common/objectCache.d.ts +13 -0
- package/vscode/src/vs/base/common/objectCache.js +39 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +12 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +95 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +10 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +81 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +144 -66
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +17 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +8 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +11 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +168 -167
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +116 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.js +34 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +105 -70
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +17 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +154 -83
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +0 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +150 -130
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +13 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +11 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +449 -229
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +7 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +11 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +7 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +76 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +5 -18
- package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +4 -122
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -4
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +42 -11
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +24 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +73 -17
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +22 -0
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +9 -6
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +39 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +314 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +34 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -334
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +0 -46
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +0 -29
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -168
|
@@ -17,8 +17,10 @@ class ChatToolInvocation {
|
|
|
17
17
|
get isConfirmed() {
|
|
18
18
|
return this._isConfirmed;
|
|
19
19
|
}
|
|
20
|
-
constructor(invocationMessage, _confirmationMessages) {
|
|
20
|
+
constructor(invocationMessage, pastTenseMessage, tooltip, _confirmationMessages) {
|
|
21
21
|
this.invocationMessage = invocationMessage;
|
|
22
|
+
this.pastTenseMessage = pastTenseMessage;
|
|
23
|
+
this.tooltip = tooltip;
|
|
22
24
|
this._confirmationMessages = _confirmationMessages;
|
|
23
25
|
this.kind = 'toolInvocation';
|
|
24
26
|
this._isComplete = false;
|
|
@@ -31,9 +33,6 @@ class ChatToolInvocation {
|
|
|
31
33
|
this._confirmDeferred.p.then(confirmed => {
|
|
32
34
|
this._isConfirmed = confirmed;
|
|
33
35
|
this._confirmationMessages = undefined;
|
|
34
|
-
if (!confirmed) {
|
|
35
|
-
this._isCompleteDeferred.complete();
|
|
36
|
-
}
|
|
37
36
|
});
|
|
38
37
|
this._isCompleteDeferred.p.then(() => {
|
|
39
38
|
this._isComplete = true;
|
|
@@ -46,6 +45,8 @@ class ChatToolInvocation {
|
|
|
46
45
|
return {
|
|
47
46
|
kind: 'toolInvocationSerialized',
|
|
48
47
|
invocationMessage: this.invocationMessage,
|
|
48
|
+
pastTenseMessage: this.pastTenseMessage,
|
|
49
|
+
tooltip: this.tooltip,
|
|
49
50
|
isConfirmed: this._isConfirmed ?? false,
|
|
50
51
|
isComplete: this._isComplete,
|
|
51
52
|
};
|
|
@@ -8,11 +8,12 @@ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log
|
|
|
8
8
|
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
9
9
|
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
10
10
|
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
11
|
+
import { IWorkbenchAssignmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service";
|
|
11
12
|
import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
|
|
12
13
|
import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents";
|
|
13
14
|
import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
|
|
14
|
-
import { ChatModel, IChatModel, IChatRequestModel, IChatRequestVariableData, IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-
|
|
15
|
-
import { IParsedChatRequest } from "@codingame/monaco-vscode-
|
|
15
|
+
import { ChatModel, IChatModel, IChatRequestModel, IChatRequestVariableData, IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel";
|
|
16
|
+
import { IParsedChatRequest } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatParserTypes";
|
|
16
17
|
import { IChatCompleteResponse, IChatDetail, IChatSendRequestData, IChatSendRequestOptions, IChatTransferredSessionData, IChatUserActionEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService";
|
|
17
18
|
import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service";
|
|
18
19
|
import { IChatSlashCommandService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service";
|
|
@@ -28,6 +29,7 @@ export declare class ChatService extends Disposable implements IChatService {
|
|
|
28
29
|
private readonly chatVariablesService;
|
|
29
30
|
private readonly chatAgentService;
|
|
30
31
|
private readonly configurationService;
|
|
32
|
+
private readonly experimentService;
|
|
31
33
|
_serviceBrand: undefined;
|
|
32
34
|
private readonly _sessionModels;
|
|
33
35
|
private readonly _pendingRequests;
|
|
@@ -44,7 +46,7 @@ export declare class ChatService extends Disposable implements IChatService {
|
|
|
44
46
|
}>;
|
|
45
47
|
private readonly _sessionFollowupCancelTokens;
|
|
46
48
|
private readonly _chatServiceTelemetry;
|
|
47
|
-
constructor(storageService: IStorageService, logService: ILogService, extensionService: IExtensionService, instantiationService: IInstantiationService, telemetryService: ITelemetryService, workspaceContextService: IWorkspaceContextService, chatSlashCommandService: IChatSlashCommandService, chatVariablesService: IChatVariablesService, chatAgentService: IChatAgentService, configurationService: IConfigurationService);
|
|
49
|
+
constructor(storageService: IStorageService, logService: ILogService, extensionService: IExtensionService, instantiationService: IInstantiationService, telemetryService: ITelemetryService, workspaceContextService: IWorkspaceContextService, chatSlashCommandService: IChatSlashCommandService, chatVariablesService: IChatVariablesService, chatAgentService: IChatAgentService, configurationService: IConfigurationService, experimentService: IWorkbenchAssignmentService);
|
|
48
50
|
isEnabled(location: ChatAgentLocation): boolean;
|
|
49
51
|
private saveState;
|
|
50
52
|
private syncEmptyWindowChats;
|
|
@@ -68,6 +70,7 @@ export declare class ChatService extends Disposable implements IChatService {
|
|
|
68
70
|
private parseChatRequest;
|
|
69
71
|
private refreshFollowupsCancellationToken;
|
|
70
72
|
private _sendRequestAsync;
|
|
73
|
+
private checkAgentAllowed;
|
|
71
74
|
private attachmentKindsForTelemetry;
|
|
72
75
|
private getHistoryEntriesFromModel;
|
|
73
76
|
removeRequest(sessionId: string, requestId: string): Promise<void>;
|
|
@@ -21,38 +21,47 @@ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode
|
|
|
21
21
|
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
22
22
|
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
23
23
|
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
24
|
+
import { IWorkbenchAssignmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service';
|
|
24
25
|
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
25
26
|
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
|
|
26
27
|
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
27
|
-
import { normalizeSerializableChatData, ChatModel, ChatRequestRemovalReason, updateRanges, toChatHistoryContent, ChatRequestModel } from '@codingame/monaco-vscode-
|
|
28
|
-
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from '@codingame/monaco-vscode-
|
|
28
|
+
import { normalizeSerializableChatData, ChatModel, ChatRequestRemovalReason, updateRanges, toChatHistoryContent, ChatRequestModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
29
|
+
import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
29
30
|
import { ChatRequestParser } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
|
|
30
31
|
import { ChatServiceTelemetry } from './chatServiceTelemetry.js';
|
|
31
32
|
import { IChatSlashCommandService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
|
|
32
33
|
import { IChatVariablesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
|
|
33
34
|
import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
35
|
+
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
34
36
|
|
|
35
37
|
const serializedChatKey = 'interactive.sessions';
|
|
36
38
|
const globalChatKey = 'chat.workspaceTransfer';
|
|
37
39
|
const SESSION_TRANSFER_EXPIRATION_IN_MILLISECONDS = 1000 * 60;
|
|
38
40
|
const maxPersistedSessions = 25;
|
|
39
|
-
class CancellableRequest {
|
|
40
|
-
constructor(cancellationTokenSource, requestId) {
|
|
41
|
+
let CancellableRequest = class CancellableRequest {
|
|
42
|
+
constructor(cancellationTokenSource, requestId, toolsService) {
|
|
41
43
|
this.cancellationTokenSource = cancellationTokenSource;
|
|
42
44
|
this.requestId = requestId;
|
|
45
|
+
this.toolsService = toolsService;
|
|
43
46
|
}
|
|
44
47
|
dispose() {
|
|
45
48
|
this.cancellationTokenSource.dispose();
|
|
46
49
|
}
|
|
47
50
|
cancel() {
|
|
51
|
+
if (this.requestId) {
|
|
52
|
+
this.toolsService.cancelToolCallsForRequest(this.requestId);
|
|
53
|
+
}
|
|
48
54
|
this.cancellationTokenSource.cancel();
|
|
49
55
|
}
|
|
50
|
-
}
|
|
56
|
+
};
|
|
57
|
+
CancellableRequest = ( __decorate([
|
|
58
|
+
( __param(2, ILanguageModelToolsService))
|
|
59
|
+
], CancellableRequest));
|
|
51
60
|
let ChatService = class ChatService extends Disposable {
|
|
52
61
|
get transferredSessionData() {
|
|
53
62
|
return this._transferredSessionData;
|
|
54
63
|
}
|
|
55
|
-
constructor(storageService, logService, extensionService, instantiationService, telemetryService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService, configurationService) {
|
|
64
|
+
constructor(storageService, logService, extensionService, instantiationService, telemetryService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService, configurationService, experimentService) {
|
|
56
65
|
super();
|
|
57
66
|
this.storageService = storageService;
|
|
58
67
|
this.logService = logService;
|
|
@@ -64,6 +73,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
64
73
|
this.chatVariablesService = chatVariablesService;
|
|
65
74
|
this.chatAgentService = chatAgentService;
|
|
66
75
|
this.configurationService = configurationService;
|
|
76
|
+
this.experimentService = experimentService;
|
|
67
77
|
this._sessionModels = this._register(( new DisposableMap()));
|
|
68
78
|
this._pendingRequests = this._register(( new DisposableMap()));
|
|
69
79
|
this._deletedChatIds = ( new Set());
|
|
@@ -246,7 +256,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
246
256
|
const liveSessionItems = ( Array.from(( this._sessionModels.values()))
|
|
247
257
|
.filter(session => !session.isImported && session.initialLocation !== ChatAgentLocation.EditingSession)
|
|
248
258
|
.map(session => {
|
|
249
|
-
const title = session.title || ( localize(
|
|
259
|
+
const title = session.title || ( localize(4757, "New Chat"));
|
|
250
260
|
return {
|
|
251
261
|
sessionId: session.sessionId,
|
|
252
262
|
title,
|
|
@@ -345,12 +355,16 @@ let ChatService = class ChatService extends Disposable {
|
|
|
345
355
|
locationData: request.locationData,
|
|
346
356
|
attachedContext: request.attachedContext,
|
|
347
357
|
workingSet: request.workingSet,
|
|
358
|
+
hasInstructionAttachments: options?.hasInstructionAttachments ?? false,
|
|
348
359
|
};
|
|
349
360
|
await this._sendRequestAsync(model, model.sessionId, request.message, attempt, enableCommandDetection, defaultAgent, location, resendOptions).responseCompletePromise;
|
|
350
361
|
}
|
|
351
362
|
async sendRequest(sessionId, request, options) {
|
|
352
363
|
this.trace('sendRequest', `sessionId: ${sessionId}, message: ${request.substring(0, 20)}${request.length > 20 ? '[...]' : ''}}`);
|
|
353
|
-
if (!request.trim() &&
|
|
364
|
+
if (!request.trim() && options?.hasInstructionAttachments) {
|
|
365
|
+
request = 'Follow these instructions.';
|
|
366
|
+
}
|
|
367
|
+
if (!request.trim() && !options?.slashCommand && !options?.agentId && !options?.hasInstructionAttachments) {
|
|
354
368
|
this.trace('sendRequest', 'Rejected empty message');
|
|
355
369
|
return;
|
|
356
370
|
}
|
|
@@ -363,6 +377,13 @@ let ChatService = class ChatService extends Disposable {
|
|
|
363
377
|
this.trace('sendRequest', `Session ${sessionId} already has a pending request`);
|
|
364
378
|
return;
|
|
365
379
|
}
|
|
380
|
+
const requests = model.getRequests();
|
|
381
|
+
for (let i = requests.length - 1; i >= 0; i -= 1) {
|
|
382
|
+
const request = requests[i];
|
|
383
|
+
if (request.shouldBeRemovedOnSend) {
|
|
384
|
+
this.removeRequest(sessionId, request.id);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
366
387
|
const location = options?.location ?? model.initialLocation;
|
|
367
388
|
const attempt = options?.attempt ?? 0;
|
|
368
389
|
const defaultAgent = this.chatAgentService.getDefaultAgent(location);
|
|
@@ -508,6 +529,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
508
529
|
const agent = (detectedAgent ?? agentPart?.agent ?? defaultAgent);
|
|
509
530
|
const command = detectedCommand ?? agentSlashCommandPart?.command;
|
|
510
531
|
await this.extensionService.activateByEvent(`onChatParticipant:${agent.id}`);
|
|
532
|
+
await this.checkAgentAllowed(agent);
|
|
511
533
|
const history = this.getHistoryEntriesFromModel(requests, model.sessionId, location, agent.id);
|
|
512
534
|
const requestProps = await prepareChatAgentRequest(agent, command, enableCommandDetection, request , !!detectedAgent);
|
|
513
535
|
const pendingRequest = this._pendingRequests.get(sessionId);
|
|
@@ -547,7 +569,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
547
569
|
else {
|
|
548
570
|
if (!rawResult) {
|
|
549
571
|
this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
|
|
550
|
-
rawResult = { errorDetails: { message: ( localize(
|
|
572
|
+
rawResult = { errorDetails: { message: ( localize(4758, "Provider returned null response")) } };
|
|
551
573
|
}
|
|
552
574
|
const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
|
|
553
575
|
rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
|
|
@@ -618,7 +640,7 @@ let ChatService = class ChatService extends Disposable {
|
|
|
618
640
|
}
|
|
619
641
|
};
|
|
620
642
|
const rawResponsePromise = sendRequestInternal();
|
|
621
|
-
this._pendingRequests.set(model.sessionId, (
|
|
643
|
+
this._pendingRequests.set(model.sessionId, this.instantiationService.createInstance(CancellableRequest, source, undefined));
|
|
622
644
|
rawResponsePromise.finally(() => {
|
|
623
645
|
this._pendingRequests.deleteAndDispose(model.sessionId);
|
|
624
646
|
});
|
|
@@ -627,6 +649,14 @@ let ChatService = class ChatService extends Disposable {
|
|
|
627
649
|
responseCompletePromise: rawResponsePromise,
|
|
628
650
|
};
|
|
629
651
|
}
|
|
652
|
+
async checkAgentAllowed(agent) {
|
|
653
|
+
if (agent.isToolsAgent) {
|
|
654
|
+
const enabled = await this.experimentService.getTreatment('chatAgentEnabled');
|
|
655
|
+
if (enabled === false) {
|
|
656
|
+
throw ( new Error('Agent is currently disabled'));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
630
660
|
attachmentKindsForTelemetry(variableData) {
|
|
631
661
|
return ( variableData.variables.map(v => {
|
|
632
662
|
if (v.kind === 'implicit') {
|
|
@@ -807,7 +837,8 @@ ChatService = ( __decorate([
|
|
|
807
837
|
( __param(6, IChatSlashCommandService)),
|
|
808
838
|
( __param(7, IChatVariablesService)),
|
|
809
839
|
( __param(8, IChatAgentService)),
|
|
810
|
-
( __param(9, IConfigurationService))
|
|
840
|
+
( __param(9, IConfigurationService)),
|
|
841
|
+
( __param(10, IWorkbenchAssignmentService))
|
|
811
842
|
], ChatService));
|
|
812
843
|
function getCodeBlocks(text) {
|
|
813
844
|
const lines = text.split('\n');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
|
|
2
|
+
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
3
|
+
import { PromptContentsProviderBase } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase";
|
|
4
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
5
|
+
import { ReadableStream } from "@codingame/monaco-vscode-api/vscode/vs/base/common/stream";
|
|
6
|
+
import { IModelContentChangedEvent } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/textModelEvents";
|
|
7
|
+
export declare class TextModelContentsProvider extends PromptContentsProviderBase<IModelContentChangedEvent> {
|
|
8
|
+
private readonly model;
|
|
9
|
+
readonly uri: import("@codingame/monaco-vscode-api/vscode/vs/base/common/uri").URI;
|
|
10
|
+
constructor(model: ITextModel);
|
|
11
|
+
protected getContentsStream(_event: IModelContentChangedEvent | "full", cancellationToken?: CancellationToken): Promise<ReadableStream<VSBuffer>>;
|
|
12
|
+
toString(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
3
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
+
import { PromptContentsProviderBase } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
|
|
5
|
+
import { newWriteableStream } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stream';
|
|
6
|
+
|
|
7
|
+
class TextModelContentsProvider extends PromptContentsProviderBase {
|
|
8
|
+
constructor(model) {
|
|
9
|
+
super();
|
|
10
|
+
this.model = model;
|
|
11
|
+
this.uri = this.model.uri;
|
|
12
|
+
this._register(this.model.onWillDispose(this.dispose.bind(this)));
|
|
13
|
+
this._register(this.model.onDidChangeContent(this.onChangeEmitter.fire));
|
|
14
|
+
}
|
|
15
|
+
async getContentsStream(_event, cancellationToken) {
|
|
16
|
+
const stream = newWriteableStream(null);
|
|
17
|
+
const linesCount = this.model.getLineCount();
|
|
18
|
+
let i = 1;
|
|
19
|
+
const interval = setInterval(() => {
|
|
20
|
+
if (i >= linesCount) {
|
|
21
|
+
clearInterval(interval);
|
|
22
|
+
stream.end();
|
|
23
|
+
stream.destroy();
|
|
24
|
+
}
|
|
25
|
+
if (this.model.isDisposed() || cancellationToken?.isCancellationRequested) {
|
|
26
|
+
clearInterval(interval);
|
|
27
|
+
stream.error(( new CancellationError()));
|
|
28
|
+
stream.destroy();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
stream.write(VSBuffer.fromString(this.model.getLineContent(i)));
|
|
33
|
+
if (i !== linesCount) {
|
|
34
|
+
stream.write(VSBuffer.fromString(this.model.getEOL()));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.log(this.uri, i, error);
|
|
39
|
+
}
|
|
40
|
+
i++;
|
|
41
|
+
}, 1);
|
|
42
|
+
return stream;
|
|
43
|
+
}
|
|
44
|
+
toString() {
|
|
45
|
+
return `text-model-prompt-contents-provider:${this.uri.path}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { TextModelContentsProvider };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
2
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
3
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
4
|
+
import { ILinksList, LinkProvider } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
|
|
5
|
+
import { ILanguageFeaturesService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures";
|
|
6
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
7
|
+
export declare class PromptLinkProvider extends Disposable implements LinkProvider {
|
|
8
|
+
private readonly initService;
|
|
9
|
+
private readonly languageService;
|
|
10
|
+
private readonly parserProvider;
|
|
11
|
+
constructor(initService: IInstantiationService, languageService: ILanguageFeaturesService);
|
|
12
|
+
private createParser;
|
|
13
|
+
provideLinks(model: ITextModel, token: CancellationToken): Promise<ILinksList>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
|
|
4
|
+
import { assertDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
5
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { NonPromptSnippetFile } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptFileReferenceErrors';
|
|
7
|
+
import { ObjectCache } from '../../../../../../base/common/objectCache.js';
|
|
8
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
9
|
+
import { TextModelPromptParser } from '../parsers/textModelPromptParser.js';
|
|
10
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
11
|
+
import { LifecyclePhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
12
|
+
import { PROMPT_SNIPPET_FILE_EXTENSION } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase';
|
|
13
|
+
import { ILanguageFeaturesService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/languageFeatures';
|
|
14
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
15
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
16
|
+
|
|
17
|
+
const languageSelector = {
|
|
18
|
+
pattern: `**/*${PROMPT_SNIPPET_FILE_EXTENSION}`,
|
|
19
|
+
};
|
|
20
|
+
let PromptLinkProvider = class PromptLinkProvider extends Disposable {
|
|
21
|
+
constructor(initService, languageService) {
|
|
22
|
+
super();
|
|
23
|
+
this.initService = initService;
|
|
24
|
+
this.languageService = languageService;
|
|
25
|
+
this.languageService.linkProvider.register(languageSelector, this);
|
|
26
|
+
this.parserProvider = this._register(( new ObjectCache(this.createParser.bind(this))));
|
|
27
|
+
}
|
|
28
|
+
createParser(model) {
|
|
29
|
+
const parser = this.initService.createInstance(TextModelPromptParser, model, []);
|
|
30
|
+
parser.assertNotDisposed('Created prompt parser must not be disposed.');
|
|
31
|
+
return parser;
|
|
32
|
+
}
|
|
33
|
+
async provideLinks(model, token) {
|
|
34
|
+
assert(!token.isCancellationRequested, ( new CancellationError()));
|
|
35
|
+
const parser = this.parserProvider.get(model);
|
|
36
|
+
assert(!parser.disposed, 'Prompt parser must not be disposed.');
|
|
37
|
+
const { references } = await parser
|
|
38
|
+
.start()
|
|
39
|
+
.settled();
|
|
40
|
+
assert(!token.isCancellationRequested, ( new CancellationError()));
|
|
41
|
+
const links = ( references
|
|
42
|
+
.filter((reference) => {
|
|
43
|
+
const { errorCondition, linkRange } = reference;
|
|
44
|
+
if (!errorCondition && linkRange) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return errorCondition instanceof NonPromptSnippetFile;
|
|
48
|
+
})
|
|
49
|
+
.map((reference) => {
|
|
50
|
+
const { linkRange } = reference;
|
|
51
|
+
assertDefined(linkRange, 'Link range must be defined.');
|
|
52
|
+
return {
|
|
53
|
+
range: linkRange,
|
|
54
|
+
url: reference.uri,
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
return {
|
|
58
|
+
links,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
PromptLinkProvider = ( __decorate([
|
|
63
|
+
( __param(0, IInstantiationService)),
|
|
64
|
+
( __param(1, ILanguageFeaturesService))
|
|
65
|
+
], PromptLinkProvider));
|
|
66
|
+
( Registry.as(Extensions.Workbench))
|
|
67
|
+
.registerWorkbenchContribution(PromptLinkProvider, LifecyclePhase.Eventually);
|
|
68
|
+
|
|
69
|
+
export { PromptLinkProvider };
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BasePromptParser } from "@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser";
|
|
2
|
+
import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
|
|
3
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
4
|
+
import { TextModelContentsProvider } from "../contentProviders/textModelContentsProvider.js";
|
|
5
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
6
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
7
|
+
export declare class TextModelPromptParser extends BasePromptParser<TextModelContentsProvider> {
|
|
8
|
+
constructor(model: ITextModel, seenReferences: string[] | undefined, initService: IInstantiationService, configService: IConfigurationService, logService: ILogService);
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { BasePromptParser } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser';
|
|
4
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
5
|
+
import { TextModelContentsProvider } from '../contentProviders/textModelContentsProvider.js';
|
|
6
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
7
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
8
|
+
|
|
9
|
+
let TextModelPromptParser = class TextModelPromptParser extends BasePromptParser {
|
|
10
|
+
constructor(model, seenReferences = [], initService, configService, logService) {
|
|
11
|
+
const contentsProvider = initService.createInstance(TextModelContentsProvider, model);
|
|
12
|
+
super(contentsProvider, seenReferences, initService, configService, logService);
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `text-model-prompt:${this.uri.path}`;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
TextModelPromptParser = ( __decorate([
|
|
19
|
+
( __param(2, IInstantiationService)),
|
|
20
|
+
( __param(3, IConfigurationService)),
|
|
21
|
+
( __param(4, ILogService))
|
|
22
|
+
], TextModelPromptParser));
|
|
23
|
+
|
|
24
|
+
export { TextModelPromptParser };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import {
|
|
3
|
+
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
4
|
+
import { DisposableMap, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
5
|
import { joinPath } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
5
6
|
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
6
7
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
7
8
|
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
9
|
+
import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/descriptors';
|
|
8
10
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
9
|
-
import {
|
|
11
|
+
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
12
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
|
|
13
|
+
import { isProposedApiEnabled } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions';
|
|
10
14
|
import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
15
|
+
import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
|
|
11
16
|
import { toolsParametersSchemaSchemaId } from './languageModelToolsParametersSchema.js';
|
|
12
17
|
|
|
13
18
|
const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
@@ -19,7 +24,7 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
19
24
|
},
|
|
20
25
|
jsonSchema: {
|
|
21
26
|
description: ( localize(
|
|
22
|
-
|
|
27
|
+
4773,
|
|
23
28
|
'Contributes a tool that can be invoked by a language model in a chat session, or from a standalone command. Registered tools can be used by all extensions.'
|
|
24
29
|
)),
|
|
25
30
|
type: 'array',
|
|
@@ -45,15 +50,15 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
45
50
|
properties: {
|
|
46
51
|
name: {
|
|
47
52
|
description: ( localize(
|
|
48
|
-
|
|
53
|
+
4774,
|
|
49
54
|
"A unique name for this tool. This name must be a globally unique identifier, and is also used as a name when presenting this tool to a language model."
|
|
50
55
|
)),
|
|
51
56
|
type: 'string',
|
|
52
|
-
pattern: '^[\\w-]+$'
|
|
57
|
+
pattern: '^(?!copilot_|vscode_)[\\w-]+$'
|
|
53
58
|
},
|
|
54
59
|
toolReferenceName: {
|
|
55
60
|
markdownDescription: ( localize(
|
|
56
|
-
|
|
61
|
+
4775,
|
|
57
62
|
"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.",
|
|
58
63
|
'`canBeReferencedInPrompt`'
|
|
59
64
|
)),
|
|
@@ -62,32 +67,32 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
62
67
|
},
|
|
63
68
|
displayName: {
|
|
64
69
|
description: ( localize(
|
|
65
|
-
|
|
70
|
+
4776,
|
|
66
71
|
"A human-readable name for this tool that may be used to describe it in the UI."
|
|
67
72
|
)),
|
|
68
73
|
type: 'string'
|
|
69
74
|
},
|
|
70
75
|
userDescription: {
|
|
71
|
-
description: ( localize(
|
|
76
|
+
description: ( localize(4777, "A description of this tool that may be shown to the user.")),
|
|
72
77
|
type: 'string'
|
|
73
78
|
},
|
|
74
79
|
modelDescription: {
|
|
75
80
|
description: ( localize(
|
|
76
|
-
|
|
81
|
+
4778,
|
|
77
82
|
"A description of this tool that may be used by a language model to select it."
|
|
78
83
|
)),
|
|
79
84
|
type: 'string'
|
|
80
85
|
},
|
|
81
86
|
inputSchema: {
|
|
82
87
|
description: ( localize(
|
|
83
|
-
|
|
88
|
+
4779,
|
|
84
89
|
"A JSON schema for the input this tool accepts. The input must be an object at the top level. A particular language model may not support all JSON schema features. See the documentation for the language model family you are using for more information."
|
|
85
90
|
)),
|
|
86
91
|
$ref: toolsParametersSchemaSchemaId
|
|
87
92
|
},
|
|
88
93
|
canBeReferencedInPrompt: {
|
|
89
94
|
markdownDescription: ( localize(
|
|
90
|
-
|
|
95
|
+
4780,
|
|
91
96
|
"If true, this tool shows up as an attachment that the user can add manually to their request. Chat participants will receive the tool in {0}.",
|
|
92
97
|
'`ChatRequest#toolReferences`'
|
|
93
98
|
)),
|
|
@@ -95,7 +100,7 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
95
100
|
},
|
|
96
101
|
icon: {
|
|
97
102
|
markdownDescription: ( localize(
|
|
98
|
-
|
|
103
|
+
4781,
|
|
99
104
|
"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)`"
|
|
100
105
|
)),
|
|
101
106
|
anyOf: [{
|
|
@@ -105,11 +110,11 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
105
110
|
type: 'object',
|
|
106
111
|
properties: {
|
|
107
112
|
light: {
|
|
108
|
-
description: ( localize(
|
|
113
|
+
description: ( localize(4782, 'Icon path when a light theme is used')),
|
|
109
114
|
type: 'string'
|
|
110
115
|
},
|
|
111
116
|
dark: {
|
|
112
|
-
description: ( localize(
|
|
117
|
+
description: ( localize(4783, 'Icon path when a dark theme is used')),
|
|
113
118
|
type: 'string'
|
|
114
119
|
}
|
|
115
120
|
}
|
|
@@ -117,19 +122,20 @@ const languageModelToolsExtensionPoint = ExtensionsRegistry.registerExtensionPoi
|
|
|
117
122
|
},
|
|
118
123
|
when: {
|
|
119
124
|
markdownDescription: ( localize(
|
|
120
|
-
|
|
125
|
+
4784,
|
|
121
126
|
"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."
|
|
122
127
|
)),
|
|
123
128
|
type: 'string'
|
|
124
129
|
},
|
|
125
130
|
tags: {
|
|
126
131
|
description: ( localize(
|
|
127
|
-
|
|
132
|
+
4785,
|
|
128
133
|
"A set of tags that roughly describe the tool's capabilities. A tool user may use these to filter the set of tools to just ones that are relevant for the task at hand, or they may want to pick a tag that can be used to identify just the tools contributed by this extension."
|
|
129
134
|
)),
|
|
130
135
|
type: 'array',
|
|
131
136
|
items: {
|
|
132
|
-
type: 'string'
|
|
137
|
+
type: 'string',
|
|
138
|
+
pattern: '^(?!copilot_|vscode_)'
|
|
133
139
|
}
|
|
134
140
|
}
|
|
135
141
|
}
|
|
@@ -158,6 +164,14 @@ let LanguageModelToolsExtensionPointHandler = class LanguageModelToolsExtensionP
|
|
|
158
164
|
logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool with 'canBeReferencedInPrompt' set without a 'toolReferenceName': ${JSON.stringify(rawTool)}`);
|
|
159
165
|
continue;
|
|
160
166
|
}
|
|
167
|
+
if ((rawTool.name.startsWith('copilot_') || rawTool.name.startsWith('vscode_')) && !isProposedApiEnabled(extension.description, 'chatParticipantPrivate')) {
|
|
168
|
+
logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool with name starting with "vscode_" or "copilot_"`);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (rawTool.tags?.some(tag => tag.startsWith('copilot_') || tag.startsWith('vscode_')) && !isProposedApiEnabled(extension.description, 'chatParticipantPrivate')) {
|
|
172
|
+
logService.error(`Extension '${extension.description.identifier.value}' CANNOT register tool with tags starting with "vscode_" or "copilot_"`);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
161
175
|
const rawIcon = rawTool.icon;
|
|
162
176
|
let icon;
|
|
163
177
|
if (typeof rawIcon === 'string') {
|
|
@@ -196,5 +210,47 @@ LanguageModelToolsExtensionPointHandler = ( __decorate([
|
|
|
196
210
|
( __param(0, ILanguageModelToolsService)),
|
|
197
211
|
( __param(1, ILogService))
|
|
198
212
|
], LanguageModelToolsExtensionPointHandler));
|
|
213
|
+
class LanguageModelToolDataRenderer extends Disposable {
|
|
214
|
+
constructor() {
|
|
215
|
+
super(...arguments);
|
|
216
|
+
this.type = 'table';
|
|
217
|
+
}
|
|
218
|
+
shouldRender(manifest) {
|
|
219
|
+
return !!manifest.contributes?.languageModelTools;
|
|
220
|
+
}
|
|
221
|
+
render(manifest) {
|
|
222
|
+
const contribs = manifest.contributes?.languageModelTools ?? [];
|
|
223
|
+
if (!contribs.length) {
|
|
224
|
+
return { data: { headers: [], rows: [] }, dispose: () => { } };
|
|
225
|
+
}
|
|
226
|
+
const headers = [
|
|
227
|
+
( localize(4786, "Name")),
|
|
228
|
+
( localize(4787, "Display Name")),
|
|
229
|
+
( localize(4788, "Description")),
|
|
230
|
+
];
|
|
231
|
+
const rows = ( contribs.map(t => {
|
|
232
|
+
return [
|
|
233
|
+
( new MarkdownString(`\`${t.name}\``)),
|
|
234
|
+
t.displayName,
|
|
235
|
+
t.userDescription ?? t.modelDescription,
|
|
236
|
+
];
|
|
237
|
+
}));
|
|
238
|
+
return {
|
|
239
|
+
data: {
|
|
240
|
+
headers,
|
|
241
|
+
rows
|
|
242
|
+
},
|
|
243
|
+
dispose: () => { }
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
( Registry.as(Extensions.ExtensionFeaturesRegistry)).registerExtensionFeature({
|
|
248
|
+
id: 'languageModelTools',
|
|
249
|
+
label: ( localize(4789, "Language Model Tools")),
|
|
250
|
+
access: {
|
|
251
|
+
canToggle: false
|
|
252
|
+
},
|
|
253
|
+
renderer: ( new SyncDescriptor(LanguageModelToolDataRenderer)),
|
|
254
|
+
});
|
|
199
255
|
|
|
200
256
|
export { LanguageModelToolsExtensionPointHandler };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
|
|
4
|
+
import { ILanguageModelToolsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service";
|
|
5
|
+
export declare class BuiltinToolsContribution extends Disposable implements IWorkbenchContribution {
|
|
6
|
+
static readonly ID = "chat.builtinTools";
|
|
7
|
+
constructor(toolsService: ILanguageModelToolsService, instantiationService: IInstantiationService);
|
|
8
|
+
}
|
|
9
|
+
export interface IToolInputProcessor {
|
|
10
|
+
processInput(input: any): any;
|
|
11
|
+
}
|