@codingame/monaco-vscode-katex-common 28.4.1 → 29.1.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 (154) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/platform/actions/browser/buttonbar.js +2 -2
  3. package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatAccessibilityProvider.js +17 -15
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContinueInAction.d.ts +2 -2
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContinueInAction.js +9 -9
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatElicitationActions.js +1 -1
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.d.ts +3 -1
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +158 -47
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +22 -17
  10. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionHoverWidget.js +8 -8
  11. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.d.ts +16 -4
  12. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.js +121 -14
  13. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsFilter.d.ts +8 -1
  14. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsFilter.js +15 -8
  15. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsOpener.js +1 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.d.ts +29 -13
  17. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.js +349 -109
  18. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/media/agentsessionsviewer.css +47 -23
  19. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.d.ts +6 -1
  20. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentWidgets.js +104 -62
  21. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatImplicitContext.js +1 -3
  22. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/implicitContextAttachment.js +13 -11
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.js +34 -40
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +21 -16
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +7 -7
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationWidget.js +14 -14
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionPickerActionItem.d.ts +8 -1
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionPickerActionItem.js +13 -4
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.d.ts +29 -50
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.js +261 -282
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/searchableOptionPickerActionItem.d.ts +2 -1
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/searchableOptionPickerActionItem.js +7 -5
  33. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatAgentHover.js +2 -2
  34. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatArtifactsWidget.d.ts +31 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatArtifactsWidget.js +184 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentMarkdownRenderer.js +4 -2
  37. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatAgentCommandContentPart.js +1 -1
  38. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatAnonymousRateLimitedPart.js +2 -2
  39. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatChangesSummaryPart.js +1 -1
  40. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatCodeCitationContentPart.js +1 -1
  41. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatCommandContentPart.js +1 -1
  42. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatConfirmationContentPart.js +2 -2
  43. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatConfirmationWidget.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatDisabledClaudeHooksContentPart.js +4 -3
  45. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatExtensionsContentPart.js +1 -1
  46. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatHookContentPart.js +1 -1
  47. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.d.ts +3 -2
  48. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.js +42 -34
  49. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.d.ts +1 -0
  50. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.js +14 -18
  51. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMcpServersInteractionContentPart.js +11 -9
  52. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMultiDiffContentPart.js +4 -4
  53. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatProgressContentPart.js +6 -2
  54. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.d.ts +25 -2
  55. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.js +332 -114
  56. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuotaExceededPart.js +4 -4
  57. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatReferencesContentPart.d.ts +1 -0
  58. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatReferencesContentPart.js +7 -7
  59. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatResourceGroupWidget.d.ts +2 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatResourceGroupWidget.js +10 -5
  61. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.d.ts +1 -1
  62. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.js +11 -16
  63. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.d.ts +7 -1
  64. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSuggestNextWidget.js +66 -7
  65. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatTextEditContentPart.js +1 -1
  66. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.d.ts +28 -3
  67. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.js +272 -107
  68. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingExternalResourcesWidget.d.ts +18 -0
  69. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingExternalResourcesWidget.js +70 -0
  70. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatTipContentPart.js +9 -9
  71. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatTodoListWidget.js +17 -17
  72. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatToolInputOutputContentPart.d.ts +1 -1
  73. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatToolInputOutputContentPart.js +6 -3
  74. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatTreeContentPart.js +1 -1
  75. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatWorkspaceEditContentPart.js +3 -3
  76. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/codeBlockPart.js +14 -14
  77. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatConfirmationWidget.css +151 -0
  78. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatInlineAnchorWidget.css +6 -6
  79. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatQuestionCarousel.css +96 -10
  80. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatTerminalToolProgressPart.css +6 -1
  81. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatThinkingContent.css +86 -10
  82. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/abstractToolConfirmationSubPart.d.ts +7 -0
  83. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/abstractToolConfirmationSubPart.js +5 -2
  84. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatExtensionsInstallToolSubPart.js +4 -4
  85. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatInputOutputMarkdownProgressPart.d.ts +1 -1
  86. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatInputOutputMarkdownProgressPart.js +8 -6
  87. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatMcpAppModel.js +1 -1
  88. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatMcpAppSubPart.js +3 -3
  89. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatModifiedFilesConfirmationSubPart.d.ts +28 -0
  90. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatModifiedFilesConfirmationSubPart.js +273 -0
  91. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatSimpleToolProgressPart.js +3 -2
  92. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.js +28 -16
  93. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.d.ts +22 -1
  94. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.js +81 -32
  95. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.d.ts +1 -0
  96. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.js +20 -7
  97. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolInvocationPart.js +11 -1
  98. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolOutputPart.js +2 -2
  99. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolPartUtilities.d.ts +6 -0
  100. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolPartUtilities.js +21 -7
  101. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolPostExecuteConfirmationPart.js +5 -5
  102. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolProgressPart.js +2 -12
  103. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatDragAndDrop.js +12 -12
  104. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.d.ts +0 -6
  105. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.js +112 -163
  106. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatListWidget.js +11 -1
  107. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatWidget.d.ts +9 -1
  108. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatWidget.js +137 -52
  109. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatFollowups.js +1 -1
  110. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.d.ts +12 -0
  111. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.js +108 -38
  112. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatModelPicker.d.ts +9 -3
  113. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatModelPicker.js +385 -247
  114. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/delegationSessionPickerActionItem.d.ts +5 -1
  115. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/delegationSessionPickerActionItem.js +23 -7
  116. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/modePickerActionItem.js +6 -6
  117. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/modelPickerActionItem.d.ts +4 -1
  118. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/modelPickerActionItem2.js +4 -2
  119. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/permissionPickerActionItem.js +23 -23
  120. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/sessionTargetPickerActionItem.js +3 -3
  121. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/workspacePickerActionItem.js +3 -3
  122. package/vscode/src/vs/workbench/contrib/chat/browser/widget/media/chat.css +124 -17
  123. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatContextUsageDetails.d.ts +4 -0
  124. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatContextUsageDetails.js +24 -7
  125. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatContextUsageWidget.js +30 -11
  126. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/media/chatContextUsageDetails.css +84 -0
  127. package/vscode/src/vs/workbench/contrib/chat/common/chatImageExtraction.d.ts +31 -0
  128. package/vscode/src/vs/workbench/contrib/chat/common/chatImageExtraction.js +170 -0
  129. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/internalCustomizations/internalPromptFileSystem.d.ts +47 -0
  130. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/internalCustomizations/internalPromptFileSystem.js +95 -0
  131. package/vscode/src/vs/workbench/contrib/chat/common/widget/annotations.js +4 -1
  132. package/vscode/src/vs/workbench/contrib/chat/common/widget/chatColors.js +15 -15
  133. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.d.ts +1 -1
  134. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAffordance.js +4 -3
  135. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.d.ts +2 -0
  136. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +38 -6
  137. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatEditorAffordance.d.ts +1 -0
  138. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatEditorAffordance.js +31 -0
  139. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.d.ts +12 -3
  140. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatOverlayWidget.js +130 -23
  141. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.d.ts +23 -0
  142. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.js +41 -0
  143. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +5 -5
  144. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.js +1 -1
  145. package/vscode/src/vs/workbench/contrib/inlineChat/browser/media/inlineChatOverlayWidget.css +55 -3
  146. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.d.ts +4 -1
  147. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +50 -39
  148. package/vscode/src/vs/workbench/contrib/interactive/browser/replInputHintContentWidget.js +3 -3
  149. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +7 -7
  150. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +2 -2
  151. package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditor.js +1 -1
  152. package/vscode/src/vs/workbench/contrib/replNotebook/browser/replEditorInput.js +1 -1
  153. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatQuestionCarouselAutoReply.d.ts +0 -35
  154. package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatQuestionCarouselAutoReply.js +0 -440
@@ -1,440 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
4
- import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
5
- import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
6
- import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
- import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
8
- import { hasKey } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
9
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
10
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
11
- import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
12
- import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
13
- import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
14
- import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
15
- import { ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
16
- import { ChatMessageRole, getTextResponseFromStream } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
17
- import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
18
- import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
19
-
20
- var AutoReplyStorageKeys;
21
- (function(AutoReplyStorageKeys) {
22
- AutoReplyStorageKeys["AutoReplyOptIn"] = "chat.autoReply.optIn";
23
- })(AutoReplyStorageKeys || (AutoReplyStorageKeys = {}));
24
- let ChatQuestionCarouselAutoReply = class ChatQuestionCarouselAutoReply extends Disposable {
25
- constructor(
26
- configService,
27
- dialogService,
28
- logService,
29
- storageService,
30
- languageModelsService
31
- ) {
32
- super();
33
- this.configService = configService;
34
- this.dialogService = dialogService;
35
- this.logService = logService;
36
- this.storageService = storageService;
37
- this.languageModelsService = languageModelsService;
38
- this._register(Event.runAndSubscribe(this.configService.onDidChangeConfiguration, e => {
39
- if (!e || e.affectsConfiguration(ChatConfiguration.AutoReply)) {
40
- if (this.configService.getValue(ChatConfiguration.AutoReply) !== true) {
41
- this.storageService.remove(AutoReplyStorageKeys.AutoReplyOptIn, StorageScope.APPLICATION);
42
- }
43
- }
44
- }));
45
- }
46
- async shouldAutoReply() {
47
- if (!this.configService.getValue(ChatConfiguration.AutoReply)) {
48
- return false;
49
- }
50
- return this.checkOptIn();
51
- }
52
- async autoReply(carousel, submit, modelName, requestMessageText, token) {
53
- if (token.isCancellationRequested || carousel.isUsed || carousel.questions.length === 0) {
54
- return;
55
- }
56
- const fallbackAnswers = this.buildFallbackCarouselAnswers(carousel, requestMessageText);
57
- let resolvedAnswers = fallbackAnswers;
58
- const modelId = await this.getModelId(modelName);
59
- if (modelId && !token.isCancellationRequested) {
60
- try {
61
- const parsedAnswers = await this.requestAnswers(modelId, carousel, requestMessageText, token);
62
- if (parsedAnswers.size > 0) {
63
- resolvedAnswers = this.mergeAnswers(carousel, parsedAnswers, fallbackAnswers);
64
- }
65
- } catch (err) {
66
- this.logService.debug("#ChatQuestionCarousel: Failed to resolve auto reply", toErrorMessage(err));
67
- }
68
- }
69
- if (token.isCancellationRequested || carousel.isUsed) {
70
- return;
71
- }
72
- await submit(resolvedAnswers);
73
- }
74
- async checkOptIn() {
75
- const optedIn = this.storageService.getBoolean(AutoReplyStorageKeys.AutoReplyOptIn, StorageScope.APPLICATION, false);
76
- if (optedIn) {
77
- return true;
78
- }
79
- const promptResult = await this.dialogService.prompt({
80
- type: Severity.Warning,
81
- message: ( localize(6755, "Enable chat auto reply?")),
82
- buttons: [{
83
- label: ( localize(6756, "Enable")),
84
- run: () => true
85
- }, {
86
- label: ( localize(6757, "Disable")),
87
- run: () => false
88
- }],
89
- custom: {
90
- icon: Codicon.warning,
91
- disableCloseAction: true,
92
- markdownDetails: [{
93
- markdown: ( new MarkdownString(( localize(
94
- 6758,
95
- "Chat auto reply answers question carousels using the current model and may make unintended choices. Review your settings and outputs carefully."
96
- ))))
97
- }]
98
- }
99
- });
100
- if (promptResult.result !== true) {
101
- await this.configService.updateValue(ChatConfiguration.AutoReply, false);
102
- return false;
103
- }
104
- this.storageService.store(
105
- AutoReplyStorageKeys.AutoReplyOptIn,
106
- true,
107
- StorageScope.APPLICATION,
108
- StorageTarget.USER
109
- );
110
- return true;
111
- }
112
- async getModelId(modelName) {
113
- if (!modelName) {
114
- return undefined;
115
- }
116
- let models = await this.languageModelsService.selectLanguageModels({
117
- id: modelName
118
- });
119
- if (models.length > 0) {
120
- return models[0];
121
- }
122
- if (modelName.startsWith("copilot/")) {
123
- models = await this.languageModelsService.selectLanguageModels({
124
- vendor: "copilot",
125
- family: modelName.replace(/^copilot\//, "")
126
- });
127
- return models[0];
128
- }
129
- return undefined;
130
- }
131
- buildPrompt(carousel, requestMessageText, strict) {
132
- const questions = ( carousel.questions.map(question => ({
133
- id: question.id,
134
- type: question.type,
135
- title: question.title,
136
- message: typeof question.message === "string" ? question.message : question.message?.value,
137
- options: question.options?.map(option => ({
138
- id: option.id,
139
- label: option.label
140
- })) ?? [],
141
- allowFreeformInput: question.allowFreeformInput ?? false
142
- })));
143
- const contextLines = [];
144
- if (requestMessageText) {
145
- contextLines.push(`Original user request: ${JSON.stringify(requestMessageText)}`);
146
- }
147
- return [
148
- "Choose default answers for the following questions.",
149
- "Return a JSON object keyed by question id.",
150
- "For text questions, the value should be a string.",
151
- "For singleSelect questions, the value should be { \"selectedId\": string } or { \"freeform\": string }.",
152
- "For multiSelect questions, the value should be { \"selectedIds\": string[] } and may include { \"freeform\": string }.",
153
- "If a question allows freeform input and has no options, return a freeform answer based on the user request when possible.",
154
- "Use option ids from the provided options.",
155
- ...contextLines,
156
- "Questions:",
157
- JSON.stringify(questions),
158
- strict ? "Return ONLY valid JSON. Do not include markdown or explanations." : undefined
159
- ].filter(Boolean).join("\n");
160
- }
161
- async requestAnswers(modelId, carousel, requestMessageText, token) {
162
- const prompt = this.buildPrompt(carousel, requestMessageText, false);
163
- const response = await this.languageModelsService.sendChatRequest(modelId, undefined, [{
164
- role: ChatMessageRole.User,
165
- content: [{
166
- type: "text",
167
- value: prompt
168
- }]
169
- }], {}, token);
170
- const responseText = await getTextResponseFromStream(response);
171
- const parsedAnswers = this.parseAnswers(responseText, carousel);
172
- if (parsedAnswers.size > 0 || token.isCancellationRequested) {
173
- return parsedAnswers;
174
- }
175
- const retryPrompt = this.buildPrompt(carousel, requestMessageText, true);
176
- const retryResponse = await this.languageModelsService.sendChatRequest(modelId, undefined, [{
177
- role: ChatMessageRole.User,
178
- content: [{
179
- type: "text",
180
- value: retryPrompt
181
- }]
182
- }], {}, token);
183
- const retryText = await getTextResponseFromStream(retryResponse);
184
- return this.parseAnswers(retryText, carousel);
185
- }
186
- parseAnswers(responseText, carousel) {
187
- const parsed = this.tryParseJsonObject(responseText);
188
- if (!parsed) {
189
- return ( new Map());
190
- }
191
- const answers = ( new Map());
192
- for (const question of carousel.questions) {
193
- const rawAnswer = parsed[question.id];
194
- const resolved = this.resolveAnswerFromRaw(question, rawAnswer);
195
- if (resolved !== undefined) {
196
- answers.set(question.id, resolved);
197
- }
198
- }
199
- return answers;
200
- }
201
- mergeAnswers(carousel, resolvedAnswers, fallbackAnswers) {
202
- const merged = ( new Map());
203
- for (const question of carousel.questions) {
204
- const fallback = fallbackAnswers.get(question.id);
205
- if (this.hasDefaultValue(question) && fallback !== undefined) {
206
- merged.set(question.id, fallback);
207
- continue;
208
- }
209
- if (( resolvedAnswers.has(question.id))) {
210
- merged.set(question.id, resolvedAnswers.get(question.id));
211
- continue;
212
- }
213
- if (fallback !== undefined) {
214
- merged.set(question.id, fallback);
215
- }
216
- }
217
- return merged;
218
- }
219
- hasDefaultValue(question) {
220
- switch (question.type) {
221
- case "text":
222
- return question.defaultValue !== undefined;
223
- case "singleSelect":
224
- return typeof question.defaultValue === "string";
225
- case "multiSelect":
226
- return Array.isArray(question.defaultValue) ? question.defaultValue.length > 0 : typeof question.defaultValue === "string";
227
- }
228
- }
229
- resolveAnswerFromRaw(question, raw) {
230
- switch (question.type) {
231
- case "text":
232
- {
233
- if (typeof raw === "string") {
234
- const value = raw.trim();
235
- return value.length > 0 ? value : undefined;
236
- }
237
- if (raw && typeof raw === "object" && hasKey(raw, {
238
- value: true
239
- }) && typeof raw.value === "string") {
240
- const value = raw.value.trim();
241
- return value.length > 0 ? value : undefined;
242
- }
243
- return undefined;
244
- }
245
- case "singleSelect":
246
- {
247
- let selectedInput;
248
- let freeformInput;
249
- if (typeof raw === "string") {
250
- selectedInput = raw;
251
- } else if (raw && typeof raw === "object") {
252
- if (hasKey(raw, {
253
- selectedId: true
254
- }) && typeof raw.selectedId === "string") {
255
- selectedInput = raw.selectedId;
256
- } else if (hasKey(raw, {
257
- selectedLabel: true
258
- }) && typeof raw.selectedLabel === "string") {
259
- selectedInput = raw.selectedLabel;
260
- }
261
- if (hasKey(raw, {
262
- freeform: true
263
- }) && typeof raw.freeform === "string") {
264
- freeformInput = raw.freeform;
265
- }
266
- }
267
- if (freeformInput && freeformInput.trim().length > 0) {
268
- return {
269
- selectedValue: undefined,
270
- freeformValue: freeformInput.trim()
271
- };
272
- }
273
- const match = selectedInput ? this.matchQuestionOption(question, selectedInput) : undefined;
274
- if (match) {
275
- return {
276
- selectedValue: match.value,
277
- freeformValue: undefined
278
- };
279
- }
280
- return undefined;
281
- }
282
- case "multiSelect":
283
- {
284
- let selectedInputs = [];
285
- let freeformInput;
286
- if (Array.isArray(raw)) {
287
- selectedInputs = raw.filter(item => typeof item === "string");
288
- } else if (typeof raw === "string") {
289
- selectedInputs = ( raw.split(",").map(item => item.trim())).filter(item => item.length > 0);
290
- } else if (raw && typeof raw === "object") {
291
- if (hasKey(raw, {
292
- selectedIds: true
293
- })) {
294
- const selectedIdsValue = raw.selectedIds;
295
- if (Array.isArray(selectedIdsValue)) {
296
- selectedInputs = selectedIdsValue.filter(item => typeof item === "string");
297
- }
298
- }
299
- if (hasKey(raw, {
300
- freeform: true
301
- }) && typeof raw.freeform === "string") {
302
- freeformInput = raw.freeform;
303
- }
304
- }
305
- const selectedValues = ( selectedInputs.map(input => this.matchQuestionOption(question, input)?.value)).filter(value => value !== undefined);
306
- const freeformValue = freeformInput?.trim();
307
- if (selectedValues.length > 0 || (freeformValue && freeformValue.length > 0)) {
308
- return {
309
- selectedValues,
310
- freeformValue
311
- };
312
- }
313
- return undefined;
314
- }
315
- }
316
- }
317
- matchQuestionOption(question, rawInput) {
318
- const options = question.options ?? [];
319
- if (!options.length) {
320
- return undefined;
321
- }
322
- const normalized = rawInput.trim().toLowerCase();
323
- const numeric = Number.parseInt(normalized, 10);
324
- if (!Number.isNaN(numeric) && numeric > 0 && numeric <= options.length) {
325
- const option = options[numeric - 1];
326
- return {
327
- id: option.id,
328
- value: option.value
329
- };
330
- }
331
- const exactId = options.find(option => option.id.toLowerCase() === normalized);
332
- if (exactId) {
333
- return {
334
- id: exactId.id,
335
- value: exactId.value
336
- };
337
- }
338
- const exactLabel = options.find(option => option.label.toLowerCase() === normalized);
339
- if (exactLabel) {
340
- return {
341
- id: exactLabel.id,
342
- value: exactLabel.value
343
- };
344
- }
345
- const partialLabel = options.find(option => option.label.toLowerCase().includes(normalized));
346
- if (partialLabel) {
347
- return {
348
- id: partialLabel.id,
349
- value: partialLabel.value
350
- };
351
- }
352
- return undefined;
353
- }
354
- buildFallbackCarouselAnswers(carousel, requestMessageText) {
355
- const answers = ( new Map());
356
- for (const question of carousel.questions) {
357
- const answer = this.getFallbackAnswerForQuestion(question, requestMessageText);
358
- if (answer !== undefined) {
359
- answers.set(question.id, answer);
360
- }
361
- }
362
- return answers;
363
- }
364
- getFallbackAnswerForQuestion(question, requestMessageText) {
365
- const fallbackFreeform = requestMessageText?.trim() || ( localize(6759, "OK"));
366
- switch (question.type) {
367
- case "text":
368
- return question.defaultValue ?? fallbackFreeform;
369
- case "singleSelect":
370
- {
371
- const defaultOptionId = typeof question.defaultValue === "string" ? question.defaultValue : undefined;
372
- const defaultOption = defaultOptionId ? question.options?.find(opt => opt.id === defaultOptionId) : undefined;
373
- if (defaultOption) {
374
- return {
375
- selectedValue: defaultOption.value,
376
- freeformValue: undefined
377
- };
378
- }
379
- if (question.options && question.options.length > 0) {
380
- return {
381
- selectedValue: question.options[0].value,
382
- freeformValue: undefined
383
- };
384
- }
385
- if (question.allowFreeformInput) {
386
- return {
387
- selectedValue: undefined,
388
- freeformValue: fallbackFreeform
389
- };
390
- }
391
- return undefined;
392
- }
393
- case "multiSelect":
394
- {
395
- const defaultIds = Array.isArray(question.defaultValue) ? question.defaultValue : (typeof question.defaultValue === "string" ? [question.defaultValue] : []);
396
- const selectedValues = question.options?.filter(opt => defaultIds.includes(opt.id)).map(opt => opt.value).filter(value => value !== undefined) ?? [];
397
- if (selectedValues.length > 0) {
398
- return {
399
- selectedValues,
400
- freeformValue: undefined
401
- };
402
- }
403
- if (question.options && question.options.length > 0) {
404
- return {
405
- selectedValues: [question.options[0].value],
406
- freeformValue: undefined
407
- };
408
- }
409
- if (question.allowFreeformInput) {
410
- return {
411
- selectedValues: [],
412
- freeformValue: fallbackFreeform
413
- };
414
- }
415
- return undefined;
416
- }
417
- }
418
- }
419
- tryParseJsonObject(text) {
420
- const trimmed = text.trim();
421
- if (!trimmed) {
422
- return undefined;
423
- }
424
- const start = trimmed.indexOf("{");
425
- const end = trimmed.lastIndexOf("}");
426
- const candidate = start >= 0 && end > start ? trimmed.slice(start, end + 1) : trimmed;
427
- try {
428
- const parsed = JSON.parse(candidate);
429
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
430
- return parsed;
431
- }
432
- } catch {
433
- return undefined;
434
- }
435
- return undefined;
436
- }
437
- };
438
- ChatQuestionCarouselAutoReply = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IDialogService)), ( __param(2, ILogService)), ( __param(3, IStorageService)), ( __param(4, ILanguageModelsService))], ChatQuestionCarouselAutoReply));
439
-
440
- export { ChatQuestionCarouselAutoReply };