@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.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 (147) hide show
  1. package/index.js +11 -8
  2. package/package.json +29 -20
  3. package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
  4. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
  24. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  25. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
  26. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
  27. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
  28. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
  29. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
  30. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
  31. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
  54. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
  55. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
  56. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
  58. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
  64. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
  65. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
  67. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
  69. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
  70. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
  71. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
  72. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
  73. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
  74. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
  75. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
  76. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
  77. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
  78. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
  79. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
  80. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
  81. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
  82. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
  83. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
  84. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
  85. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
  86. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
  87. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
  88. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
  89. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
  90. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
  91. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
  92. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
  93. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
  94. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
  95. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
  96. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
  97. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +2 -2
  98. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
  99. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
  100. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
  101. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +5 -3
  102. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
  103. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
  104. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
  105. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
  106. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
  107. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
  108. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
  109. package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
  110. package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
  111. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
  112. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
  113. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
  114. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
  115. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
  116. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
  117. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
  118. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
  119. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
  120. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
  121. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
  122. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
  123. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
  124. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
  125. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
  126. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
  127. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
  128. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
  129. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +10 -0
  130. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
  131. package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
  132. package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
  133. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
  134. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
  135. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
  136. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
  137. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
  138. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
  139. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
  140. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
  141. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
  142. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
  143. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
  144. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
  145. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
  146. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
  147. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
@@ -0,0 +1,19 @@
1
+ import { IChatStatusItemService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatStatusItemService.service";
2
+ export interface IChatStatusItemChangeEvent {
3
+ readonly entry: ChatStatusEntry;
4
+ }
5
+ export type ChatStatusEntry = {
6
+ id: string;
7
+ label: string;
8
+ description: string;
9
+ detail: string | undefined;
10
+ };
11
+ export declare class ChatStatusItemService implements IChatStatusItemService {
12
+ readonly _serviceBrand: undefined;
13
+ private readonly _entries;
14
+ private readonly _onDidChange;
15
+ readonly onDidChange: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<IChatStatusItemChangeEvent>;
16
+ setOrUpdateEntry(entry: ChatStatusEntry): void;
17
+ deleteEntry(id: string): void;
18
+ getEntries(): Iterable<ChatStatusEntry>;
19
+ }
@@ -0,0 +1,27 @@
1
+
2
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
3
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
4
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
5
+
6
+ class ChatStatusItemService {
7
+ constructor() {
8
+ this._entries = ( new Map());
9
+ this._onDidChange = ( new Emitter());
10
+ this.onDidChange = this._onDidChange.event;
11
+ }
12
+ setOrUpdateEntry(entry) {
13
+ const isUpdate = ( this._entries.has(entry.id));
14
+ this._entries.set(entry.id, entry);
15
+ if (isUpdate) {
16
+ this._onDidChange.fire({ entry });
17
+ }
18
+ }
19
+ deleteEntry(id) {
20
+ this._entries.delete(id);
21
+ }
22
+ getEntries() {
23
+ return ( this._entries.values());
24
+ }
25
+ }
26
+
27
+ export { ChatStatusItemService };
@@ -1,17 +1,19 @@
1
1
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
2
  import { Location } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
3
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
3
4
  import { IViewsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service";
4
- import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents";
5
5
  import { IChatRequestVariableData, IChatRequestVariableEntry } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
6
6
  import { IParsedChatRequest } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes";
7
7
  import { IDynamicVariable } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables";
8
8
  import { IChatVariablesService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables.service";
9
+ import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants";
9
10
  import { IChatWidgetService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service";
10
11
  export declare class ChatVariablesService implements IChatVariablesService {
11
12
  private readonly chatWidgetService;
12
13
  private readonly viewsService;
14
+ private readonly configurationService;
13
15
  _serviceBrand: undefined;
14
- constructor(chatWidgetService: IChatWidgetService, viewsService: IViewsService);
16
+ constructor(chatWidgetService: IChatWidgetService, viewsService: IViewsService, configurationService: IConfigurationService);
15
17
  resolveVariables(prompt: IParsedChatRequest, attachedContextVariables: IChatRequestVariableEntry[] | undefined): IChatRequestVariableData;
16
18
  getDynamicVariables(sessionId: string): ReadonlyArray<IDynamicVariable>;
17
19
  attachContext(name: string, value: string | URI | Location, location: ChatAgentLocation): Promise<void>;
@@ -2,17 +2,19 @@
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
3
  import { coalesce } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
4
4
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
5
6
  import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
6
- import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
7
7
  import { ChatRequestDynamicVariablePart, ChatRequestToolPart } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
8
+ import { ChatAgentLocation, ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
8
9
  import { showEditsView, showChatView } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chat';
9
10
  import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
10
- import { ChatDynamicVariableModel } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
11
+ import { ChatDynamicVariableModel } from '@codingame/monaco-vscode-bba55be6-41a2-50cd-a3cc-8bafa35bfa89-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
11
12
 
12
13
  let ChatVariablesService = class ChatVariablesService {
13
- constructor(chatWidgetService, viewsService) {
14
+ constructor(chatWidgetService, viewsService, configurationService) {
14
15
  this.chatWidgetService = chatWidgetService;
15
16
  this.viewsService = viewsService;
17
+ this.configurationService = configurationService;
16
18
  }
17
19
  resolveVariables(prompt, attachedContextVariables) {
18
20
  let resolvedVariables = [];
@@ -46,7 +48,8 @@ let ChatVariablesService = class ChatVariablesService {
46
48
  if (location !== ChatAgentLocation.Panel && location !== ChatAgentLocation.EditingSession) {
47
49
  return;
48
50
  }
49
- const widget = location === ChatAgentLocation.EditingSession
51
+ const unifiedViewEnabled = !!this.configurationService.getValue(ChatConfiguration.UnifiedChatView);
52
+ const widget = location === ChatAgentLocation.EditingSession && !unifiedViewEnabled
50
53
  ? await showEditsView(this.viewsService)
51
54
  : (this.chatWidgetService.lastFocusedWidget ?? (await showChatView(this.viewsService)));
52
55
  if (!widget || !widget.viewModel) {
@@ -56,14 +59,19 @@ let ChatVariablesService = class ChatVariablesService {
56
59
  if (key === 'file' && typeof value !== 'string') {
57
60
  const uri = URI.isUri(value) ? value : value.uri;
58
61
  const range = 'range' in value ? value.range : undefined;
59
- widget.attachmentModel.addFile(uri, range);
62
+ await widget.attachmentModel.addFile(uri, range);
63
+ return;
64
+ }
65
+ if (key === 'folder' && URI.isUri(value)) {
66
+ widget.attachmentModel.addFolder(value);
60
67
  return;
61
68
  }
62
69
  }
63
70
  };
64
71
  ChatVariablesService = ( __decorate([
65
72
  ( __param(0, IChatWidgetService)),
66
- ( __param(1, IViewsService))
73
+ ( __param(1, IViewsService)),
74
+ ( __param(2, IConfigurationService))
67
75
  ], ChatVariablesService));
68
76
 
69
77
  export { ChatVariablesService };
@@ -22,7 +22,7 @@ import { chatSlashCommandBackground, chatSlashCommandForeground } from '@codinga
22
22
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestToolPart, chatAgentLeader, chatSubcommandLeader } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
23
23
  import { ChatRequestParser } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
24
24
  import { ChatWidget } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
25
- import { dynamicVariableDecorationType } from '@codingame/monaco-vscode-e4d0fd26-1b26-5583-b3f7-582e08d7b389-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
25
+ import { dynamicVariableDecorationType } from '@codingame/monaco-vscode-bba55be6-41a2-50cd-a3cc-8bafa35bfa89-common/vscode/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables';
26
26
 
27
27
  const decorationDescription = 'chat';
28
28
  const placeholderDecorationType = 'chat-session-detail';
@@ -99,7 +99,7 @@ let InputEditorDecorations = class InputEditorDecorations extends Disposable {
99
99
  return;
100
100
  }
101
101
  if (!inputValue) {
102
- const defaultAgent = this.chatAgentService.getDefaultAgent(this.widget.location);
102
+ const defaultAgent = this.chatAgentService.getDefaultAgent(this.widget.location, this.widget.input.currentMode);
103
103
  const decoration = [
104
104
  {
105
105
  range: {
@@ -258,7 +258,7 @@ let ChatTokenDeleter = class ChatTokenDeleter extends Disposable {
258
258
  }
259
259
  const change = e.changes[0];
260
260
  if (!change.text && this.widget.viewModel) {
261
- const previousParsedValue = parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue, widget.location, { selectedAgent: previousSelectedAgent });
261
+ const previousParsedValue = parser.parseChatRequest(this.widget.viewModel.sessionId, previousInputValue, widget.location, { selectedAgent: previousSelectedAgent, mode: this.widget.input.currentMode });
262
262
  const deletableTokens = previousParsedValue.parts.filter(p => p instanceof ChatRequestAgentPart || p instanceof ChatRequestAgentSubcommandPart || p instanceof ChatRequestSlashCommandPart || p instanceof ChatRequestToolPart);
263
263
  deletableTokens.forEach(token => {
264
264
  const deletedRangeOfToken = Range.intersectRanges(token.editorRange, change.range);
@@ -5,7 +5,7 @@ import { HoverAnchor, IEditorHoverParticipant, IEditorHoverRenderContext, IHover
5
5
  import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
6
6
  import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
7
7
  import { IChatWidgetService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service";
8
- import { IChatAgentData } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents";
8
+ import { IChatAgentData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatAgents";
9
9
  export declare class ChatAgentHoverParticipant implements IEditorHoverParticipant<ChatAgentHoverPart> {
10
10
  private readonly editor;
11
11
  private readonly instantiationService;
@@ -58,7 +58,7 @@ let ChatAgentHoverParticipant = class ChatAgentHoverParticipant {
58
58
  return ( new RenderedHoverParts([renderedHoverPart]));
59
59
  }
60
60
  getAccessibleContent(hoverPart) {
61
- return localize(4788, 'There is a chat agent hover part here.');
61
+ return localize(4902, 'There is a chat agent hover part here.');
62
62
  }
63
63
  };
64
64
  ChatAgentHoverParticipant = ( __decorate([
@@ -1,4 +1,4 @@
1
- import { IHoverAction } from "@codingame/monaco-vscode-view-status-bar-service-override/vscode/vs/base/browser/ui/hover/hover";
1
+ import { IHoverAction } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hover";
2
2
  import { IKeybindingService } from "@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service";
3
3
  export declare class ChatEditorHoverWrapper {
4
4
  private readonly keybindingService;
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import './media/editorHoverWrapper.css.js';
3
+ import './media/editorHoverWrapper.css';
4
4
  import { $ as $$1, h as h$1 } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
5
5
  import '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hoverWidget';
6
6
  import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
@@ -0,0 +1,3 @@
1
+ .chat-editor-hover-wrapper-content {
2
+ padding: 2px 8px;
3
+ }
@@ -1,7 +1,10 @@
1
1
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
2
  import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
+ import { IAccessibilityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service";
4
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
3
5
  import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
4
6
  import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service";
7
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
5
8
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
6
9
  import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
7
10
  import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
@@ -9,20 +12,27 @@ import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/c
9
12
  import { CountTokensCallback, IToolData, IToolImpl, IToolInvocation, IToolResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService";
10
13
  import { ILanguageModelToolsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service";
11
14
  export declare class LanguageModelToolsService extends Disposable implements ILanguageModelToolsService {
15
+ private readonly _instantiationService;
12
16
  private readonly _extensionService;
13
17
  private readonly _contextKeyService;
14
18
  private readonly _chatService;
15
19
  private readonly _dialogService;
16
20
  private readonly _telemetryService;
17
21
  private readonly _logService;
22
+ private readonly _configurationService;
23
+ private readonly _accessibilityService;
18
24
  _serviceBrand: undefined;
19
25
  private _onDidChangeTools;
20
26
  readonly onDidChangeTools: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<void>;
21
27
  private _onDidChangeToolsScheduler;
22
28
  private _tools;
23
29
  private _toolContextKeys;
30
+ private readonly _ctxToolsCount;
24
31
  private _callsByRequestId;
25
- constructor(_extensionService: IExtensionService, _contextKeyService: IContextKeyService, _chatService: IChatService, _dialogService: IDialogService, _telemetryService: ITelemetryService, _logService: ILogService);
32
+ private _workspaceToolConfirmStore;
33
+ private _profileToolConfirmStore;
34
+ private _memoryToolConfirmStore;
35
+ constructor(_instantiationService: IInstantiationService, _extensionService: IExtensionService, _contextKeyService: IContextKeyService, _chatService: IChatService, _dialogService: IDialogService, _telemetryService: ITelemetryService, _logService: ILogService, _configurationService: IConfigurationService, _accessibilityService: IAccessibilityService);
26
36
  registerToolData(toolData: IToolData): IDisposable;
27
37
  private _refreshAllToolContextKeys;
28
38
  registerToolImplementation(id: string, tool: IToolImpl): IDisposable;
@@ -30,7 +40,13 @@ export declare class LanguageModelToolsService extends Disposable implements ILa
30
40
  getTool(id: string): IToolData | undefined;
31
41
  private _getToolEntry;
32
42
  getToolByName(name: string): IToolData | undefined;
43
+ setToolAutoConfirmation(toolId: string, scope: "workspace" | "profile" | "memory", autoConfirm?: boolean): void;
44
+ resetToolAutoConfirmation(): void;
33
45
  invokeTool(dto: IToolInvocation, countTokens: CountTokensCallback, token: CancellationToken): Promise<IToolResult>;
46
+ private prepareToolInvocation;
47
+ private ensureToolDetails;
48
+ private toolResultToString;
49
+ private shouldAutoConfirm;
34
50
  private cleanupCallDisposables;
35
51
  cancelToolCallsForRequest(requestId: string): void;
36
52
  dispose(): void;
@@ -3,48 +3,95 @@ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib
3
3
  import { renderStringAsPlaintext } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/markdownRenderer';
4
4
  import { RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
5
5
  import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
6
+ import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
6
7
  import { CancellationError, isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
8
  import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
9
+ import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
8
10
  import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
9
- import { Disposable, toDisposable, DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
11
+ import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
12
+ import { Disposable, DisposableStore, toDisposable, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
13
+ import { LRUCache } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
14
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
15
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
16
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
17
+ import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
18
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
10
19
  import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
11
20
  import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
21
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
22
+ import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/platform/jsonschemas/common/jsonContributionRegistry';
12
23
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
24
+ import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
25
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
26
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
13
27
  import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
14
28
  import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
29
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
15
30
  import { ChatToolInvocation } from '../common/chatProgressTypes/chatToolInvocation.js';
16
31
  import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
32
+ import { ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
33
+ import { stringifyPromptTsxPart } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService';
17
34
 
35
+ var ToolConfirmStore_1;
36
+ const jsonSchemaRegistry = ( Registry.as(Extensions.JSONContribution));
18
37
  let LanguageModelToolsService = class LanguageModelToolsService extends Disposable {
19
- constructor(_extensionService, _contextKeyService, _chatService, _dialogService, _telemetryService, _logService) {
38
+ constructor(_instantiationService, _extensionService, _contextKeyService, _chatService, _dialogService, _telemetryService, _logService, _configurationService, _accessibilityService) {
20
39
  super();
40
+ this._instantiationService = _instantiationService;
21
41
  this._extensionService = _extensionService;
22
42
  this._contextKeyService = _contextKeyService;
23
43
  this._chatService = _chatService;
24
44
  this._dialogService = _dialogService;
25
45
  this._telemetryService = _telemetryService;
26
46
  this._logService = _logService;
47
+ this._configurationService = _configurationService;
48
+ this._accessibilityService = _accessibilityService;
27
49
  this._onDidChangeTools = ( new Emitter());
28
50
  this.onDidChangeTools = this._onDidChangeTools.event;
29
51
  this._onDidChangeToolsScheduler = ( new RunOnceScheduler(() => this._onDidChangeTools.fire(), 750));
30
52
  this._tools = ( new Map());
31
53
  this._toolContextKeys = ( new Set());
32
54
  this._callsByRequestId = ( new Map());
55
+ this._memoryToolConfirmStore = ( new Set());
56
+ this._workspaceToolConfirmStore = ( new Lazy(
57
+ () => this._register(this._instantiationService.createInstance(ToolConfirmStore, StorageScope.WORKSPACE))
58
+ ));
59
+ this._profileToolConfirmStore = ( new Lazy(
60
+ () => this._register(this._instantiationService.createInstance(ToolConfirmStore, StorageScope.PROFILE))
61
+ ));
33
62
  this._register(this._contextKeyService.onDidChangeContext(e => {
34
63
  if (e.affectsSome(this._toolContextKeys)) {
35
64
  this._onDidChangeToolsScheduler.schedule();
36
65
  }
37
66
  }));
67
+ this._register(this._configurationService.onDidChangeConfiguration(e => {
68
+ if (e.affectsConfiguration(ChatConfiguration.ExtensionToolsEnabled)) {
69
+ this._onDidChangeToolsScheduler.schedule();
70
+ }
71
+ }));
72
+ this._ctxToolsCount = ChatContextKeys.Tools.toolsCount.bindTo(_contextKeyService);
38
73
  }
39
74
  registerToolData(toolData) {
40
75
  if (( this._tools.has(toolData.id))) {
41
76
  throw ( new Error(`Tool "${toolData.id}" is already registered.`));
42
77
  }
43
78
  this._tools.set(toolData.id, { data: toolData });
79
+ this._ctxToolsCount.set(this._tools.size);
44
80
  this._onDidChangeToolsScheduler.schedule();
45
81
  toolData.when?.keys().forEach(key => this._toolContextKeys.add(key));
82
+ let store;
83
+ if (toolData.inputSchema) {
84
+ store = ( new DisposableStore());
85
+ const schemaUrl = ( ( URI.from(
86
+ { scheme: Schemas.vscode, authority: 'schemas', path: `/lm/tool/${toolData.id}` }
87
+ )).toString());
88
+ jsonSchemaRegistry.registerSchema(schemaUrl, toolData.inputSchema, store);
89
+ store.add(jsonSchemaRegistry.registerSchemaAssociation(schemaUrl, `/lm/tool/${toolData.id}/tool_input.json`));
90
+ }
46
91
  return toDisposable(() => {
92
+ store?.dispose();
47
93
  this._tools.delete(toolData.id);
94
+ this._ctxToolsCount.set(this._tools.size);
48
95
  this._refreshAllToolContextKeys();
49
96
  this._onDidChangeToolsScheduler.schedule();
50
97
  });
@@ -70,7 +117,14 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
70
117
  }
71
118
  getTools() {
72
119
  const toolDatas = ( Iterable.map(( this._tools.values()), i => i.data));
73
- return Iterable.filter(toolDatas, toolData => !toolData.when || this._contextKeyService.contextMatchesRules(toolData.when));
120
+ const extensionToolsEnabled = this._configurationService.getValue(ChatConfiguration.ExtensionToolsEnabled);
121
+ return Iterable.filter(toolDatas, toolData => {
122
+ const satisfiesWhenClause = !toolData.when || this._contextKeyService.contextMatchesRules(toolData.when);
123
+ const satisfiesExternalToolCheck = toolData.source.type === 'extension' && !extensionToolsEnabled ?
124
+ !toolData.source.isExternalTool :
125
+ true;
126
+ return satisfiesWhenClause && satisfiesExternalToolCheck;
127
+ });
74
128
  }
75
129
  getTool(id) {
76
130
  return this._getToolEntry(id)?.data;
@@ -92,6 +146,22 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
92
146
  }
93
147
  return undefined;
94
148
  }
149
+ setToolAutoConfirmation(toolId, scope, autoConfirm = true) {
150
+ if (scope === 'workspace') {
151
+ this._workspaceToolConfirmStore.value.setAutoConfirm(toolId, autoConfirm);
152
+ }
153
+ else if (scope === 'profile') {
154
+ this._profileToolConfirmStore.value.setAutoConfirm(toolId, autoConfirm);
155
+ }
156
+ else {
157
+ this._memoryToolConfirmStore.add(toolId);
158
+ }
159
+ }
160
+ resetToolAutoConfirmation() {
161
+ this._workspaceToolConfirmStore.value.reset();
162
+ this._profileToolConfirmStore.value.reset();
163
+ this._memoryToolConfirmStore.clear();
164
+ }
95
165
  async invokeTool(dto, countTokens, token) {
96
166
  this._logService.trace(`[LanguageModelToolsService#invokeTool] Invoking tool ${dto.toolId} with parameters ${JSON.stringify(dto.parameters)}`);
97
167
  let tool = this._tools.get(dto.toolId);
@@ -118,6 +188,7 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
118
188
  }
119
189
  const request = model.getRequests().at(-1);
120
190
  requestId = request.id;
191
+ dto.modelId = request.modelId;
121
192
  if (!( this._callsByRequestId.has(requestId))) {
122
193
  this._callsByRequestId.set(requestId, []);
123
194
  }
@@ -134,23 +205,27 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
134
205
  toolInvocation?.confirmed.complete(false);
135
206
  }));
136
207
  token = source.token;
137
- const prepared = tool.impl.prepareToolInvocation ?
138
- await tool.impl.prepareToolInvocation(dto.parameters, token)
139
- : undefined;
140
- toolInvocation = ( new ChatToolInvocation(prepared, tool.data));
208
+ const prepared = await this.prepareToolInvocation(tool, dto, token);
209
+ toolInvocation = ( new ChatToolInvocation(prepared, tool.data, dto.callId));
210
+ if (this.shouldAutoConfirm(tool.data.id, tool.data.runsInWorkspace)) {
211
+ toolInvocation.confirmed.complete(true);
212
+ }
141
213
  model.acceptResponseProgress(request, toolInvocation);
142
214
  if (prepared?.confirmationMessages) {
215
+ this._accessibilityService.alert(( localize(4905, "Action required: {0}", prepared.confirmationMessages.title)));
143
216
  const userConfirmed = await toolInvocation.confirmed.p;
144
217
  if (!userConfirmed) {
145
218
  throw ( new CancellationError());
146
219
  }
147
220
  dto.toolSpecificData = toolInvocation?.toolSpecificData;
221
+ if (dto.toolSpecificData?.kind === 'input') {
222
+ dto.parameters = dto.toolSpecificData.rawInput;
223
+ dto.toolSpecificData = undefined;
224
+ }
148
225
  }
149
226
  }
150
227
  else {
151
- const prepared = tool.impl.prepareToolInvocation ?
152
- await tool.impl.prepareToolInvocation(dto.parameters, token)
153
- : undefined;
228
+ const prepared = await this.prepareToolInvocation(tool, dto, token);
154
229
  if (prepared?.confirmationMessages) {
155
230
  const result = await this._dialogService.confirm({ message: prepared.confirmationMessages.title, detail: renderStringAsPlaintext(prepared.confirmationMessages.message) });
156
231
  if (!result.confirmed) {
@@ -162,11 +237,13 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
162
237
  throw ( new CancellationError());
163
238
  }
164
239
  toolResult = await tool.impl.invoke(dto, countTokens, token);
240
+ this.ensureToolDetails(dto, toolResult, tool.data);
165
241
  this._telemetryService.publicLog2('languageModelToolInvoked', {
166
242
  result: 'success',
167
243
  chatSessionId: dto.context?.sessionId,
168
244
  toolId: tool.data.id,
169
- toolExtensionId: tool.data.extensionId?.value,
245
+ toolExtensionId: tool.data.source.type === 'extension' ? tool.data.source.extensionId.value : undefined,
246
+ toolSourceKind: tool.data.source.type,
170
247
  });
171
248
  return toolResult;
172
249
  }
@@ -176,8 +253,10 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
176
253
  result,
177
254
  chatSessionId: dto.context?.sessionId,
178
255
  toolId: tool.data.id,
179
- toolExtensionId: tool.data.extensionId?.value,
256
+ toolExtensionId: tool.data.source.type === 'extension' ? tool.data.source.extensionId.value : undefined,
257
+ toolSourceKind: tool.data.source.type,
180
258
  });
259
+ this._logService.error(`[LanguageModelToolsService#invokeTool] Error from tool ${dto.toolId}: ${toErrorMessage(err)}. With parameters ${JSON.stringify(dto.parameters)}`);
181
260
  throw err;
182
261
  }
183
262
  finally {
@@ -187,6 +266,76 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
187
266
  }
188
267
  }
189
268
  }
269
+ async prepareToolInvocation(tool, dto, token) {
270
+ let prepared = tool.impl.prepareToolInvocation ?
271
+ await tool.impl.prepareToolInvocation(dto.parameters, token)
272
+ : undefined;
273
+ if (!prepared?.confirmationMessages && tool.data.requiresConfirmation && tool.data.source.type === 'extension') {
274
+ if (!prepared) {
275
+ prepared = {};
276
+ }
277
+ const toolWarning = ( localize(
278
+ 4906,
279
+ "{0} This tool is from the extension `{1}`. Please carefully review any requested actions.",
280
+ '$(info)',
281
+ tool.data.source.extensionId.value
282
+ ));
283
+ prepared.confirmationMessages = {
284
+ title: ( localize(4907, "Run {0}", `"${tool.data.displayName}"`)),
285
+ message: ( new MarkdownString(
286
+ (tool.data.userDescription ?? tool.data.modelDescription) + '\n\n' + toolWarning,
287
+ { supportThemeIcons: true }
288
+ )),
289
+ allowAutoConfirm: true,
290
+ };
291
+ }
292
+ if (prepared?.confirmationMessages) {
293
+ if (prepared.toolSpecificData?.kind !== 'terminal' && typeof prepared.confirmationMessages.allowAutoConfirm !== 'boolean') {
294
+ prepared.confirmationMessages.allowAutoConfirm = true;
295
+ }
296
+ if (!prepared.toolSpecificData && tool.data.alwaysDisplayInputOutput) {
297
+ prepared.toolSpecificData = {
298
+ kind: 'input',
299
+ rawInput: dto.parameters,
300
+ };
301
+ }
302
+ }
303
+ return prepared;
304
+ }
305
+ ensureToolDetails(dto, toolResult, toolData) {
306
+ if (!toolResult.toolResultDetails && toolData.alwaysDisplayInputOutput) {
307
+ toolResult.toolResultDetails = {
308
+ input: JSON.stringify(dto.parameters, undefined, 2),
309
+ output: this.toolResultToString(toolResult),
310
+ };
311
+ }
312
+ }
313
+ toolResultToString(toolResult) {
314
+ const strs = [];
315
+ for (const part of toolResult.content) {
316
+ if (part.kind === 'text') {
317
+ strs.push(part.value);
318
+ }
319
+ else if (part.kind === 'promptTsx') {
320
+ strs.push(stringifyPromptTsxPart(part));
321
+ }
322
+ }
323
+ return strs.join('');
324
+ }
325
+ shouldAutoConfirm(toolId, runsInWorkspace) {
326
+ if (this._workspaceToolConfirmStore.value.getAutoConfirm(toolId) || this._profileToolConfirmStore.value.getAutoConfirm(toolId) || ( this._memoryToolConfirmStore.has(toolId))) {
327
+ return true;
328
+ }
329
+ const config = this._configurationService.inspect('chat.tools.autoApprove');
330
+ let value = config.value ?? config.defaultValue;
331
+ if (typeof runsInWorkspace === 'boolean') {
332
+ value = config.userLocalValue ?? config.applicationValue;
333
+ if (runsInWorkspace) {
334
+ value = config.workspaceValue ?? config.workspaceFolderValue ?? config.userRemoteValue ?? value;
335
+ }
336
+ }
337
+ return value === true || (typeof value === 'object' && value.hasOwnProperty(toolId) && value[toolId] === true);
338
+ }
190
339
  cleanupCallDisposables(requestId, store) {
191
340
  const disposables = this._callsByRequestId.get(requestId);
192
341
  if (disposables) {
@@ -210,15 +359,65 @@ let LanguageModelToolsService = class LanguageModelToolsService extends Disposab
210
359
  dispose() {
211
360
  super.dispose();
212
361
  this._callsByRequestId.forEach(calls => dispose(calls));
362
+ this._ctxToolsCount.reset();
213
363
  }
214
364
  };
215
365
  LanguageModelToolsService = ( __decorate([
216
- ( __param(0, IExtensionService)),
217
- ( __param(1, IContextKeyService)),
218
- ( __param(2, IChatService)),
219
- ( __param(3, IDialogService)),
220
- ( __param(4, ITelemetryService)),
221
- ( __param(5, ILogService))
366
+ ( __param(0, IInstantiationService)),
367
+ ( __param(1, IExtensionService)),
368
+ ( __param(2, IContextKeyService)),
369
+ ( __param(3, IChatService)),
370
+ ( __param(4, IDialogService)),
371
+ ( __param(5, ITelemetryService)),
372
+ ( __param(6, ILogService)),
373
+ ( __param(7, IConfigurationService)),
374
+ ( __param(8, IAccessibilityService))
222
375
  ], LanguageModelToolsService));
376
+ let ToolConfirmStore = class ToolConfirmStore extends Disposable {
377
+ static { ToolConfirmStore_1 = this; }
378
+ static { this.STORED_KEY = 'chat/autoconfirm'; }
379
+ constructor(_scope, storageService) {
380
+ super();
381
+ this._scope = _scope;
382
+ this.storageService = storageService;
383
+ this._autoConfirmTools = ( new LRUCache(100));
384
+ this._didChange = false;
385
+ const stored = storageService.getObject(ToolConfirmStore_1.STORED_KEY, this._scope);
386
+ if (stored) {
387
+ for (const key of stored) {
388
+ this._autoConfirmTools.set(key, true);
389
+ }
390
+ }
391
+ this._register(storageService.onWillSaveState(() => {
392
+ if (this._didChange) {
393
+ this.storageService.store(ToolConfirmStore_1.STORED_KEY, [...( this._autoConfirmTools.keys())], this._scope, StorageTarget.MACHINE);
394
+ this._didChange = false;
395
+ }
396
+ }));
397
+ }
398
+ reset() {
399
+ this._autoConfirmTools.clear();
400
+ this._didChange = true;
401
+ }
402
+ getAutoConfirm(toolId) {
403
+ if (this._autoConfirmTools.get(toolId)) {
404
+ this._didChange = true;
405
+ return true;
406
+ }
407
+ return false;
408
+ }
409
+ setAutoConfirm(toolId, autoConfirm) {
410
+ if (autoConfirm) {
411
+ this._autoConfirmTools.set(toolId, true);
412
+ }
413
+ else {
414
+ this._autoConfirmTools.delete(toolId);
415
+ }
416
+ this._didChange = true;
417
+ }
418
+ };
419
+ ToolConfirmStore = ToolConfirmStore_1 = ( __decorate([
420
+ ( __param(1, IStorageService))
421
+ ], ToolConfirmStore));
223
422
 
224
423
  export { LanguageModelToolsService };