@codingame/monaco-vscode-api 1.85.0-next.2 → 1.85.1
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/README.md +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +2540 -2533
- package/package.json +6 -6
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { asArray, firstOrDefault } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
3
|
+
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
4
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
5
|
+
import { isMarkdownString, MarkdownString } from 'monaco-editor/esm/vs/base/common/htmlContent.js';
|
|
6
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
7
|
+
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
8
|
+
import { basename } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
9
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
10
|
+
import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
11
|
+
import { OffsetRange } from 'monaco-editor/esm/vs/editor/common/core/offsetRange.js';
|
|
12
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
13
|
+
import { IChatAgentService } from './chatAgents.js';
|
|
14
|
+
import { reviveParsedChatRequest, ChatRequestTextPart } from './chatParserTypes.js';
|
|
15
|
+
import { isIUsedContext } from './chatService.js';
|
|
16
|
+
class ChatRequestModel {
|
|
17
|
+
static { this.nextId = 0; }
|
|
18
|
+
get id() {
|
|
19
|
+
return this._id;
|
|
20
|
+
}
|
|
21
|
+
get username() {
|
|
22
|
+
return this.session.requesterUsername;
|
|
23
|
+
}
|
|
24
|
+
get avatarIconUri() {
|
|
25
|
+
return this.session.requesterAvatarIconUri;
|
|
26
|
+
}
|
|
27
|
+
constructor(session, message) {
|
|
28
|
+
this.session = session;
|
|
29
|
+
this.message = message;
|
|
30
|
+
this._id = 'request_' + ChatRequestModel.nextId++;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class Response {
|
|
34
|
+
get onDidChangeValue() {
|
|
35
|
+
return this._onDidChangeValue.event;
|
|
36
|
+
}
|
|
37
|
+
get value() {
|
|
38
|
+
return this._responseParts;
|
|
39
|
+
}
|
|
40
|
+
constructor(value) {
|
|
41
|
+
this._onDidChangeValue = ( new Emitter());
|
|
42
|
+
this._responseParts = ( asArray(value).map((v) => (isMarkdownString(v) ?
|
|
43
|
+
{ content: v, kind: 'markdownContent' } :
|
|
44
|
+
'kind' in v ? v : { kind: 'treeData', treeData: v })));
|
|
45
|
+
this._updateRepr(true);
|
|
46
|
+
}
|
|
47
|
+
asString() {
|
|
48
|
+
return this._responseRepr;
|
|
49
|
+
}
|
|
50
|
+
clear() {
|
|
51
|
+
this._responseParts = [];
|
|
52
|
+
this._updateRepr(true);
|
|
53
|
+
}
|
|
54
|
+
updateContent(progress, quiet) {
|
|
55
|
+
if (progress.kind === 'content' || progress.kind === 'markdownContent') {
|
|
56
|
+
const responsePartLength = this._responseParts.length - 1;
|
|
57
|
+
const lastResponsePart = this._responseParts[responsePartLength];
|
|
58
|
+
if (!lastResponsePart || lastResponsePart.kind !== 'markdownContent') {
|
|
59
|
+
if (progress.kind === 'content') {
|
|
60
|
+
this._responseParts.push({ content: ( new MarkdownString(progress.content)), kind: 'markdownContent' });
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this._responseParts.push(progress);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (progress.kind === 'markdownContent') {
|
|
67
|
+
const lastPartEnabledCommands = typeof lastResponsePart.content.isTrusted === 'object' ?
|
|
68
|
+
lastResponsePart.content.isTrusted.enabledCommands :
|
|
69
|
+
[];
|
|
70
|
+
const thisPartEnabledCommands = typeof progress.content.isTrusted === 'object' ?
|
|
71
|
+
progress.content.isTrusted.enabledCommands :
|
|
72
|
+
[];
|
|
73
|
+
const enabledCommands = [...lastPartEnabledCommands, ...thisPartEnabledCommands];
|
|
74
|
+
this._responseParts[responsePartLength] = { content: ( new MarkdownString(
|
|
75
|
+
lastResponsePart.content.value + progress.content.value,
|
|
76
|
+
{ isTrusted: { enabledCommands } }
|
|
77
|
+
)), kind: 'markdownContent' };
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this._responseParts[responsePartLength] = { content: ( new MarkdownString(
|
|
81
|
+
lastResponsePart.content.value + progress.content,
|
|
82
|
+
lastResponsePart.content
|
|
83
|
+
)), kind: 'markdownContent' };
|
|
84
|
+
}
|
|
85
|
+
this._updateRepr(quiet);
|
|
86
|
+
}
|
|
87
|
+
else if (progress.kind === 'asyncContent') {
|
|
88
|
+
const responsePosition = this._responseParts.push(progress) - 1;
|
|
89
|
+
this._updateRepr(quiet);
|
|
90
|
+
progress.resolvedContent?.then((content) => {
|
|
91
|
+
if (typeof content === 'string') {
|
|
92
|
+
this._responseParts[responsePosition] = { content: ( new MarkdownString(content)), kind: 'markdownContent' };
|
|
93
|
+
}
|
|
94
|
+
else if (isMarkdownString(content)) {
|
|
95
|
+
this._responseParts[responsePosition] = { content, kind: 'markdownContent' };
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this._responseParts[responsePosition] = content;
|
|
99
|
+
}
|
|
100
|
+
this._updateRepr(quiet);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else if (progress.kind === 'treeData' || progress.kind === 'inlineReference' || progress.kind === 'markdownVuln') {
|
|
104
|
+
this._responseParts.push(progress);
|
|
105
|
+
this._updateRepr(quiet);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_updateRepr(quiet) {
|
|
109
|
+
this._responseRepr = ( this._responseParts.map(part => {
|
|
110
|
+
if (part.kind === 'treeData') {
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
else if (part.kind === 'inlineReference') {
|
|
114
|
+
return basename('uri' in part.inlineReference ? part.inlineReference.uri : part.inlineReference);
|
|
115
|
+
}
|
|
116
|
+
else if (part.kind === 'asyncContent') {
|
|
117
|
+
return part.content;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return part.content.value;
|
|
121
|
+
}
|
|
122
|
+
})).join('\n\n');
|
|
123
|
+
if (!quiet) {
|
|
124
|
+
this._onDidChangeValue.fire();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class ChatResponseModel extends Disposable {
|
|
129
|
+
static { this.nextId = 0; }
|
|
130
|
+
get id() {
|
|
131
|
+
return this._id;
|
|
132
|
+
}
|
|
133
|
+
get isComplete() {
|
|
134
|
+
return this._isComplete;
|
|
135
|
+
}
|
|
136
|
+
get isCanceled() {
|
|
137
|
+
return this._isCanceled;
|
|
138
|
+
}
|
|
139
|
+
get vote() {
|
|
140
|
+
return this._vote;
|
|
141
|
+
}
|
|
142
|
+
get followups() {
|
|
143
|
+
return this._followups;
|
|
144
|
+
}
|
|
145
|
+
get response() {
|
|
146
|
+
return this._response;
|
|
147
|
+
}
|
|
148
|
+
get errorDetails() {
|
|
149
|
+
return this._errorDetails;
|
|
150
|
+
}
|
|
151
|
+
get providerId() {
|
|
152
|
+
return this.session.providerId;
|
|
153
|
+
}
|
|
154
|
+
get username() {
|
|
155
|
+
return this.session.responderUsername;
|
|
156
|
+
}
|
|
157
|
+
get avatarIconUri() {
|
|
158
|
+
return this.session.responderAvatarIconUri;
|
|
159
|
+
}
|
|
160
|
+
get agent() {
|
|
161
|
+
return this._agent;
|
|
162
|
+
}
|
|
163
|
+
get slashCommand() {
|
|
164
|
+
return this._slashCommand;
|
|
165
|
+
}
|
|
166
|
+
get usedContext() {
|
|
167
|
+
return this._usedContext;
|
|
168
|
+
}
|
|
169
|
+
get contentReferences() {
|
|
170
|
+
return this._contentReferences;
|
|
171
|
+
}
|
|
172
|
+
get progressMessages() {
|
|
173
|
+
return this._progressMessages;
|
|
174
|
+
}
|
|
175
|
+
constructor(_response, session, agent, requestId, _isComplete = false, _isCanceled = false, _vote, _errorDetails, followups) {
|
|
176
|
+
super();
|
|
177
|
+
this.session = session;
|
|
178
|
+
this.requestId = requestId;
|
|
179
|
+
this._isComplete = _isComplete;
|
|
180
|
+
this._isCanceled = _isCanceled;
|
|
181
|
+
this._vote = _vote;
|
|
182
|
+
this._errorDetails = _errorDetails;
|
|
183
|
+
this._onDidChange = this._register(( new Emitter()));
|
|
184
|
+
this.onDidChange = this._onDidChange.event;
|
|
185
|
+
this._contentReferences = [];
|
|
186
|
+
this._progressMessages = [];
|
|
187
|
+
this._agent = agent;
|
|
188
|
+
this._followups = followups ? [...followups] : undefined;
|
|
189
|
+
this._response = ( new Response(_response));
|
|
190
|
+
this._register(this._response.onDidChangeValue(() => this._onDidChange.fire()));
|
|
191
|
+
this._id = 'response_' + ChatResponseModel.nextId++;
|
|
192
|
+
}
|
|
193
|
+
updateContent(responsePart, quiet) {
|
|
194
|
+
this._response.updateContent(responsePart, quiet);
|
|
195
|
+
}
|
|
196
|
+
applyProgress(progress) {
|
|
197
|
+
if (progress.kind === 'usedContext') {
|
|
198
|
+
this._usedContext = progress;
|
|
199
|
+
}
|
|
200
|
+
else if (progress.kind === 'reference') {
|
|
201
|
+
this._contentReferences.push(progress);
|
|
202
|
+
this._onDidChange.fire();
|
|
203
|
+
}
|
|
204
|
+
else if (progress.kind === 'progressMessage') {
|
|
205
|
+
this._progressMessages.push(progress);
|
|
206
|
+
this._onDidChange.fire();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
setAgent(agent, slashCommand) {
|
|
210
|
+
this._agent = agent;
|
|
211
|
+
this._slashCommand = slashCommand;
|
|
212
|
+
this._onDidChange.fire();
|
|
213
|
+
}
|
|
214
|
+
setErrorDetails(errorDetails) {
|
|
215
|
+
this._errorDetails = errorDetails;
|
|
216
|
+
this._onDidChange.fire();
|
|
217
|
+
}
|
|
218
|
+
complete(errorDetails) {
|
|
219
|
+
if (errorDetails?.responseIsRedacted) {
|
|
220
|
+
this._response.clear();
|
|
221
|
+
}
|
|
222
|
+
this._isComplete = true;
|
|
223
|
+
this._onDidChange.fire();
|
|
224
|
+
}
|
|
225
|
+
cancel() {
|
|
226
|
+
this._isComplete = true;
|
|
227
|
+
this._isCanceled = true;
|
|
228
|
+
this._onDidChange.fire();
|
|
229
|
+
}
|
|
230
|
+
setFollowups(followups) {
|
|
231
|
+
this._followups = followups;
|
|
232
|
+
this._onDidChange.fire();
|
|
233
|
+
}
|
|
234
|
+
setVote(vote) {
|
|
235
|
+
this._vote = vote;
|
|
236
|
+
this._onDidChange.fire();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function isExportableSessionData(obj) {
|
|
240
|
+
const data = obj;
|
|
241
|
+
return typeof data === 'object' &&
|
|
242
|
+
typeof data.providerId === 'string' &&
|
|
243
|
+
typeof data.requesterUsername === 'string' &&
|
|
244
|
+
typeof data.responderUsername === 'string';
|
|
245
|
+
}
|
|
246
|
+
function isSerializableSessionData(obj) {
|
|
247
|
+
const data = obj;
|
|
248
|
+
return isExportableSessionData(obj) &&
|
|
249
|
+
typeof data.creationDate === 'number' &&
|
|
250
|
+
typeof data.sessionId === 'string' &&
|
|
251
|
+
obj.requests.every((request) => !request.usedContext || isIUsedContext(request.usedContext));
|
|
252
|
+
}
|
|
253
|
+
var ChatModelInitState;
|
|
254
|
+
( (function(ChatModelInitState) {
|
|
255
|
+
ChatModelInitState[ChatModelInitState["Created"] = 0] = "Created";
|
|
256
|
+
ChatModelInitState[ChatModelInitState["Initializing"] = 1] = "Initializing";
|
|
257
|
+
ChatModelInitState[ChatModelInitState["Initialized"] = 2] = "Initialized";
|
|
258
|
+
})(ChatModelInitState || (ChatModelInitState = {})));
|
|
259
|
+
let ChatModel = class ChatModel extends Disposable {
|
|
260
|
+
get session() {
|
|
261
|
+
return this._session;
|
|
262
|
+
}
|
|
263
|
+
get welcomeMessage() {
|
|
264
|
+
return this._welcomeMessage;
|
|
265
|
+
}
|
|
266
|
+
get sessionId() {
|
|
267
|
+
return this._sessionId;
|
|
268
|
+
}
|
|
269
|
+
get inputPlaceholder() {
|
|
270
|
+
return this._session?.inputPlaceholder;
|
|
271
|
+
}
|
|
272
|
+
get requestInProgress() {
|
|
273
|
+
const lastRequest = this._requests[this._requests.length - 1];
|
|
274
|
+
return !!lastRequest && !!lastRequest.response && !lastRequest.response.isComplete;
|
|
275
|
+
}
|
|
276
|
+
get creationDate() {
|
|
277
|
+
return this._creationDate;
|
|
278
|
+
}
|
|
279
|
+
get requesterUsername() {
|
|
280
|
+
return this._session?.requesterUsername ?? this.initialData?.requesterUsername ?? '';
|
|
281
|
+
}
|
|
282
|
+
get responderUsername() {
|
|
283
|
+
return this._session?.responderUsername ?? this.initialData?.responderUsername ?? '';
|
|
284
|
+
}
|
|
285
|
+
get requesterAvatarIconUri() {
|
|
286
|
+
return this._session ? this._session.requesterAvatarIconUri : this._initialRequesterAvatarIconUri;
|
|
287
|
+
}
|
|
288
|
+
get responderAvatarIconUri() {
|
|
289
|
+
return this._session ? this._session.responderAvatarIconUri : this._initialResponderAvatarIconUri;
|
|
290
|
+
}
|
|
291
|
+
get initState() {
|
|
292
|
+
return this._initState;
|
|
293
|
+
}
|
|
294
|
+
get isImported() {
|
|
295
|
+
return this._isImported;
|
|
296
|
+
}
|
|
297
|
+
get title() {
|
|
298
|
+
const firstRequestMessage = firstOrDefault(this._requests)?.message;
|
|
299
|
+
const message = firstRequestMessage?.text ?? '';
|
|
300
|
+
return message.split('\n')[0].substring(0, 50);
|
|
301
|
+
}
|
|
302
|
+
constructor(providerId, initialData, logService, chatAgentService) {
|
|
303
|
+
super();
|
|
304
|
+
this.providerId = providerId;
|
|
305
|
+
this.initialData = initialData;
|
|
306
|
+
this.logService = logService;
|
|
307
|
+
this.chatAgentService = chatAgentService;
|
|
308
|
+
this._onDidDispose = this._register(( new Emitter()));
|
|
309
|
+
this.onDidDispose = this._onDidDispose.event;
|
|
310
|
+
this._onDidChange = this._register(( new Emitter()));
|
|
311
|
+
this.onDidChange = this._onDidChange.event;
|
|
312
|
+
this._initState = ChatModelInitState.Created;
|
|
313
|
+
this._isInitializedDeferred = ( new DeferredPromise());
|
|
314
|
+
this._isImported = false;
|
|
315
|
+
this._isImported = (!!initialData && !isSerializableSessionData(initialData)) || (initialData?.isImported ?? false);
|
|
316
|
+
this._sessionId = (isSerializableSessionData(initialData) && initialData.sessionId) || generateUuid();
|
|
317
|
+
this._requests = initialData ? this._deserialize(initialData) : [];
|
|
318
|
+
this._creationDate = (isSerializableSessionData(initialData) && initialData.creationDate) || Date.now();
|
|
319
|
+
this._initialRequesterAvatarIconUri = initialData?.requesterAvatarIconUri && URI.revive(initialData.requesterAvatarIconUri);
|
|
320
|
+
this._initialResponderAvatarIconUri = initialData?.responderAvatarIconUri && URI.revive(initialData.responderAvatarIconUri);
|
|
321
|
+
}
|
|
322
|
+
_deserialize(obj) {
|
|
323
|
+
const requests = obj.requests;
|
|
324
|
+
if (!Array.isArray(requests)) {
|
|
325
|
+
this.logService.error(`Ignoring malformed session data: ${JSON.stringify(obj)}`);
|
|
326
|
+
return [];
|
|
327
|
+
}
|
|
328
|
+
if (obj.welcomeMessage) {
|
|
329
|
+
const content = ( obj.welcomeMessage.map(item => typeof item === 'string' ? ( new MarkdownString(item)) : item));
|
|
330
|
+
this._welcomeMessage = ( new ChatWelcomeMessageModel(this, content, []));
|
|
331
|
+
}
|
|
332
|
+
try {
|
|
333
|
+
return ( requests.map((raw) => {
|
|
334
|
+
const parsedRequest = typeof raw.message === 'string'
|
|
335
|
+
? this.getParsedRequestFromString(raw.message)
|
|
336
|
+
: reviveParsedChatRequest(raw.message);
|
|
337
|
+
const request = ( new ChatRequestModel(this, parsedRequest));
|
|
338
|
+
if (raw.response || raw.responseErrorDetails) {
|
|
339
|
+
const agent = (raw.agent && 'metadata' in raw.agent) ?
|
|
340
|
+
revive(raw.agent) : undefined;
|
|
341
|
+
request.response = ( new ChatResponseModel(raw.response ?? [( new MarkdownString(raw.response))], this, agent, request.id, true, raw.isCanceled, raw.vote, raw.responseErrorDetails, raw.followups));
|
|
342
|
+
if (raw.usedContext) {
|
|
343
|
+
request.response.applyProgress(raw.usedContext);
|
|
344
|
+
}
|
|
345
|
+
if (raw.contentReferences) {
|
|
346
|
+
raw.contentReferences.forEach(r => request.response.applyProgress(r));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return request;
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
this.logService.error('Failed to parse chat data', error);
|
|
354
|
+
return [];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
getParsedRequestFromString(message) {
|
|
358
|
+
const parts = [( new ChatRequestTextPart(( new OffsetRange(0, message.length)), { startColumn: 1, startLineNumber: 1, endColumn: 1, endLineNumber: 1 }, message))];
|
|
359
|
+
return {
|
|
360
|
+
text: message,
|
|
361
|
+
parts
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
startInitialize() {
|
|
365
|
+
if (this.initState !== ChatModelInitState.Created) {
|
|
366
|
+
throw new Error(`ChatModel is in the wrong state for startInitialize: ${ChatModelInitState[this.initState]}`);
|
|
367
|
+
}
|
|
368
|
+
this._initState = ChatModelInitState.Initializing;
|
|
369
|
+
}
|
|
370
|
+
deinitialize() {
|
|
371
|
+
this._session = undefined;
|
|
372
|
+
this._initState = ChatModelInitState.Created;
|
|
373
|
+
this._isInitializedDeferred = ( new DeferredPromise());
|
|
374
|
+
}
|
|
375
|
+
initialize(session, welcomeMessage) {
|
|
376
|
+
if (this.initState !== ChatModelInitState.Initializing) {
|
|
377
|
+
throw new Error(`ChatModel is in the wrong state for initialize: ${ChatModelInitState[this.initState]}`);
|
|
378
|
+
}
|
|
379
|
+
this._initState = ChatModelInitState.Initialized;
|
|
380
|
+
this._session = session;
|
|
381
|
+
if (!this._welcomeMessage) {
|
|
382
|
+
this._welcomeMessage = welcomeMessage;
|
|
383
|
+
}
|
|
384
|
+
this._isInitializedDeferred.complete();
|
|
385
|
+
this._onDidChange.fire({ kind: 'initialize' });
|
|
386
|
+
}
|
|
387
|
+
setInitializationError(error) {
|
|
388
|
+
if (this.initState !== ChatModelInitState.Initializing) {
|
|
389
|
+
throw new Error(`ChatModel is in the wrong state for setInitializationError: ${ChatModelInitState[this.initState]}`);
|
|
390
|
+
}
|
|
391
|
+
if (!this._isInitializedDeferred.isSettled) {
|
|
392
|
+
this._isInitializedDeferred.error(error);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
waitForInitialization() {
|
|
396
|
+
return this._isInitializedDeferred.p;
|
|
397
|
+
}
|
|
398
|
+
getRequests() {
|
|
399
|
+
return this._requests;
|
|
400
|
+
}
|
|
401
|
+
addRequest(message, chatAgent) {
|
|
402
|
+
if (!this._session) {
|
|
403
|
+
throw new Error('addRequest: No session');
|
|
404
|
+
}
|
|
405
|
+
const request = ( new ChatRequestModel(this, message));
|
|
406
|
+
request.response = ( new ChatResponseModel([], this, chatAgent, request.id));
|
|
407
|
+
this._requests.push(request);
|
|
408
|
+
this._onDidChange.fire({ kind: 'addRequest', request });
|
|
409
|
+
return request;
|
|
410
|
+
}
|
|
411
|
+
acceptResponseProgress(request, progress, quiet) {
|
|
412
|
+
if (!this._session) {
|
|
413
|
+
throw new Error('acceptResponseProgress: No session');
|
|
414
|
+
}
|
|
415
|
+
if (!request.response) {
|
|
416
|
+
request.response = ( new ChatResponseModel([], this, undefined, request.id));
|
|
417
|
+
}
|
|
418
|
+
if (request.response.isComplete) {
|
|
419
|
+
throw new Error('acceptResponseProgress: Adding progress to a completed response');
|
|
420
|
+
}
|
|
421
|
+
if (progress.kind === 'vulnerability') {
|
|
422
|
+
request.response.updateContent({ kind: 'markdownVuln', content: { value: progress.content }, vulnerabilities: progress.vulnerabilities }, quiet);
|
|
423
|
+
}
|
|
424
|
+
else if (progress.kind === 'content' || progress.kind === 'markdownContent' || progress.kind === 'asyncContent' || progress.kind === 'treeData' || progress.kind === 'inlineReference' || progress.kind === 'markdownVuln') {
|
|
425
|
+
request.response.updateContent(progress, quiet);
|
|
426
|
+
}
|
|
427
|
+
else if (progress.kind === 'usedContext' || progress.kind === 'reference' || progress.kind === 'progressMessage') {
|
|
428
|
+
request.response.applyProgress(progress);
|
|
429
|
+
}
|
|
430
|
+
else if (progress.kind === 'agentDetection') {
|
|
431
|
+
const agent = this.chatAgentService.getAgent(progress.agentName);
|
|
432
|
+
if (agent) {
|
|
433
|
+
request.response.setAgent(agent, progress.command);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
this.logService.error(`Couldn't handle progress: ${JSON.stringify(progress)}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
removeRequest(id) {
|
|
441
|
+
const index = this._requests.findIndex(request => request.id === id);
|
|
442
|
+
const request = this._requests[index];
|
|
443
|
+
if (index !== -1) {
|
|
444
|
+
this._onDidChange.fire({ kind: 'removeRequest', requestId: request.id, responseId: request.response?.id });
|
|
445
|
+
this._requests.splice(index, 1);
|
|
446
|
+
request.response?.dispose();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
cancelRequest(request) {
|
|
450
|
+
if (request.response) {
|
|
451
|
+
request.response.cancel();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
setResponse(request, rawResponse) {
|
|
455
|
+
if (!this._session) {
|
|
456
|
+
throw new Error('completeResponse: No session');
|
|
457
|
+
}
|
|
458
|
+
if (!request.response) {
|
|
459
|
+
request.response = ( new ChatResponseModel([], this, undefined, request.id));
|
|
460
|
+
}
|
|
461
|
+
request.response.setErrorDetails(rawResponse.errorDetails);
|
|
462
|
+
}
|
|
463
|
+
completeResponse(request, errorDetails) {
|
|
464
|
+
if (!request.response) {
|
|
465
|
+
throw new Error('Call setResponse before completeResponse');
|
|
466
|
+
}
|
|
467
|
+
request.response.complete(errorDetails);
|
|
468
|
+
}
|
|
469
|
+
setFollowups(request, followups) {
|
|
470
|
+
if (!request.response) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
request.response.setFollowups(followups);
|
|
474
|
+
}
|
|
475
|
+
setResponseModel(request, response) {
|
|
476
|
+
request.response = response;
|
|
477
|
+
this._onDidChange.fire({ kind: 'addResponse', response });
|
|
478
|
+
}
|
|
479
|
+
toExport() {
|
|
480
|
+
return {
|
|
481
|
+
requesterUsername: this.requesterUsername,
|
|
482
|
+
requesterAvatarIconUri: this.requesterAvatarIconUri,
|
|
483
|
+
responderUsername: this.responderUsername,
|
|
484
|
+
responderAvatarIconUri: this.responderAvatarIconUri,
|
|
485
|
+
welcomeMessage: this._welcomeMessage?.content.map(c => {
|
|
486
|
+
if (Array.isArray(c)) {
|
|
487
|
+
return c;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
return c.value;
|
|
491
|
+
}
|
|
492
|
+
}),
|
|
493
|
+
requests: ( this._requests.map((r) => {
|
|
494
|
+
return {
|
|
495
|
+
message: r.message,
|
|
496
|
+
response: r.response ?
|
|
497
|
+
( r.response.response.value.map(item => {
|
|
498
|
+
if (item.kind === 'treeData') {
|
|
499
|
+
return item.treeData;
|
|
500
|
+
}
|
|
501
|
+
else if (item.kind === 'markdownContent') {
|
|
502
|
+
return item.content;
|
|
503
|
+
}
|
|
504
|
+
else if (item.kind === 'asyncContent') {
|
|
505
|
+
return ( new MarkdownString(item.content));
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
return item;
|
|
509
|
+
}
|
|
510
|
+
}))
|
|
511
|
+
: undefined,
|
|
512
|
+
responseErrorDetails: r.response?.errorDetails,
|
|
513
|
+
followups: r.response?.followups,
|
|
514
|
+
isCanceled: r.response?.isCanceled,
|
|
515
|
+
vote: r.response?.vote,
|
|
516
|
+
agent: r.response?.agent ? { id: r.response.agent.id, metadata: r.response.agent.metadata } : undefined,
|
|
517
|
+
slashCommand: r.response?.slashCommand,
|
|
518
|
+
usedContext: r.response?.usedContext,
|
|
519
|
+
contentReferences: r.response?.contentReferences
|
|
520
|
+
};
|
|
521
|
+
})),
|
|
522
|
+
providerId: this.providerId,
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
toJSON() {
|
|
526
|
+
return {
|
|
527
|
+
...this.toExport(),
|
|
528
|
+
sessionId: this.sessionId,
|
|
529
|
+
creationDate: this._creationDate,
|
|
530
|
+
isImported: this._isImported
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
dispose() {
|
|
534
|
+
this._session?.dispose?.();
|
|
535
|
+
this._requests.forEach(r => r.response?.dispose());
|
|
536
|
+
this._onDidDispose.fire();
|
|
537
|
+
super.dispose();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
ChatModel = ( __decorate([
|
|
541
|
+
( __param(2, ILogService)),
|
|
542
|
+
( __param(3, IChatAgentService))
|
|
543
|
+
], ChatModel));
|
|
544
|
+
class ChatWelcomeMessageModel {
|
|
545
|
+
static { this.nextId = 0; }
|
|
546
|
+
get id() {
|
|
547
|
+
return this._id;
|
|
548
|
+
}
|
|
549
|
+
constructor(session, content, sampleQuestions) {
|
|
550
|
+
this.session = session;
|
|
551
|
+
this.content = content;
|
|
552
|
+
this.sampleQuestions = sampleQuestions;
|
|
553
|
+
this._id = 'welcome_' + ChatWelcomeMessageModel.nextId++;
|
|
554
|
+
}
|
|
555
|
+
get username() {
|
|
556
|
+
return this.session.responderUsername;
|
|
557
|
+
}
|
|
558
|
+
get avatarIconUri() {
|
|
559
|
+
return this.session.responderAvatarIconUri;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
export { ChatModel, ChatModelInitState, ChatRequestModel, ChatResponseModel, ChatWelcomeMessageModel, Response, isExportableSessionData, isSerializableSessionData };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { revive } from 'monaco-editor/esm/vs/base/common/marshalling.js';
|
|
2
|
+
import { OffsetRange } from 'monaco-editor/esm/vs/editor/common/core/offsetRange.js';
|
|
1
3
|
class ChatRequestTextPart {
|
|
2
4
|
static { this.Kind = 'text'; }
|
|
3
5
|
constructor(range, editorRange, text) {
|
|
@@ -91,4 +93,32 @@ class ChatRequestDynamicVariablePart {
|
|
|
91
93
|
return ``;
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
|
|
96
|
+
function reviveParsedChatRequest(serialized) {
|
|
97
|
+
return {
|
|
98
|
+
text: serialized.text,
|
|
99
|
+
parts: ( serialized.parts.map(part => {
|
|
100
|
+
if (part.kind === ChatRequestTextPart.Kind) {
|
|
101
|
+
return ( new ChatRequestTextPart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.text));
|
|
102
|
+
}
|
|
103
|
+
else if (part.kind === ChatRequestVariablePart.Kind) {
|
|
104
|
+
return ( new ChatRequestVariablePart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.variableName, part.variableArg));
|
|
105
|
+
}
|
|
106
|
+
else if (part.kind === ChatRequestAgentPart.Kind) {
|
|
107
|
+
return ( new ChatRequestAgentPart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.agent));
|
|
108
|
+
}
|
|
109
|
+
else if (part.kind === ChatRequestAgentSubcommandPart.Kind) {
|
|
110
|
+
return ( new ChatRequestAgentSubcommandPart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.command));
|
|
111
|
+
}
|
|
112
|
+
else if (part.kind === ChatRequestSlashCommandPart.Kind) {
|
|
113
|
+
return ( new ChatRequestSlashCommandPart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.slashCommand));
|
|
114
|
+
}
|
|
115
|
+
else if (part.kind === ChatRequestDynamicVariablePart.Kind) {
|
|
116
|
+
return ( new ChatRequestDynamicVariablePart(( new OffsetRange(part.range.start, part.range.endExclusive)), part.editorRange, part.text, revive(part.data)));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error(`Unknown chat request part: ${part.kind}`);
|
|
120
|
+
}
|
|
121
|
+
}))
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestDynamicVariablePart, ChatRequestSlashCommandPart, ChatRequestTextPart, ChatRequestVariablePart, chatAgentLeader, chatSubcommandLeader, chatVariableLeader, reviveParsedChatRequest };
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
import { toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
1
2
|
import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
2
3
|
const IChatProviderService = ( createDecorator('chatProviderService'));
|
|
3
|
-
|
|
4
|
+
class ChatProviderService {
|
|
5
|
+
constructor() {
|
|
6
|
+
this._providers = ( new Map());
|
|
7
|
+
}
|
|
8
|
+
lookupChatResponseProvider(identifier) {
|
|
9
|
+
return this._providers.get(identifier)?.metadata;
|
|
10
|
+
}
|
|
11
|
+
registerChatResponseProvider(identifier, provider) {
|
|
12
|
+
if (( this._providers.has(identifier))) {
|
|
13
|
+
throw new Error(`Chat response provider with identifier ${identifier} is already registered.`);
|
|
14
|
+
}
|
|
15
|
+
this._providers.set(identifier, provider);
|
|
16
|
+
return toDisposable(() => this._providers.delete(identifier));
|
|
17
|
+
}
|
|
18
|
+
fetchChatResponse(identifier, messages, options, progress, token) {
|
|
19
|
+
const provider = this._providers.get(identifier);
|
|
20
|
+
if (!provider) {
|
|
21
|
+
throw new Error(`Chat response provider with identifier ${identifier} is not registered.`);
|
|
22
|
+
}
|
|
23
|
+
return provider.provideChatResponse(messages, options, progress, token);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export { ChatProviderService, IChatProviderService };
|