@codingame/monaco-vscode-chat-service-override 19.1.4 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -8
- package/package.json +36 -31
- package/vscode/src/vs/base/common/policy.d.ts +14 -0
- package/vscode/src/vs/base/common/policy.js +11 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +53 -43
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +54 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +37 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.js +23 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.js +83 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.js +421 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +215 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +9 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentResolveService.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentResolveService.js +18 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +20 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +6 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +9 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +11 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +16 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +7 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +58 -326
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.js +33 -30
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelChangeService.d.ts +12 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelChangeService.js +39 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTimeline.d.ts +55 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTimeline.js +380 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +3 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +9 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +44 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.js +145 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +34 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +36 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.d.ts +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.js +407 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.js +738 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +142 -151
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +54 -54
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +5 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +23 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +13 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/media/apple-dark.svg +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/apple-light.svg +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSessions.css +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +7 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +19 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionContribution.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionOverlay.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.js +10 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveToPromptAction.d.ts +1 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveToPromptAction.js +52 -90
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +6 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.js +9 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +11 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +137 -30
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +8 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatTodoListService.d.ts +27 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatTodoListService.js +44 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/config/configMigration.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/filePromptContentsProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/promptContentsProviderBase.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderDiagnosticsProvider.js +3 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderHovers.js +14 -14
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptLinkDiagnosticsProvider.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptPathAutocompletion.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/providerInstanceManagerBase.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/basePromptParser.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/headerBase.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/instructionsHeader.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/metadata/applyTo.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/metadata/base/enum.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/metadata/base/string.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/metadata/tools.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/modeHeader.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/promptHeader.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/promptHeader/promptHeader.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/topError.js +9 -9
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.js +8 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +27 -27
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +9 -9
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.d.ts +104 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +667 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +14 -14
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +2 -2
- package/vscode/src/vs/workbench/contrib/remoteCodingAgents/browser/remoteCodingAgents.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/media/terminalChatWidget.css +56 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminal.chat.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminal.chat.contribution.js +14 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.js +111 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibleView.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibleView.js +52 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.js +262 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.d.ts +35 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.js +129 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatControllerHolder.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatControllerHolder.js +8 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatEnabler.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatEnabler.js +30 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.d.ts +72 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.js +411 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/alternativeRecommendation.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/alternativeRecommendation.js +59 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/bufferOutputPolling.d.ts +51 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/bufferOutputPolling.js +163 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandLineAutoApprover.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandLineAutoApprover.js +164 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.js +101 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.d.ts +16 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.js +52 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.js +71 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.js +94 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/getTerminalOutputTool.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/getTerminalOutputTool.js +44 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/outputHelpers.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/outputHelpers.js +18 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.js +13 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalTool.d.ts +55 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalTool.js +603 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/subCommands.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/subCommands.js +113 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/createAndRunTaskTool.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/createAndRunTaskTool.js +227 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/getTaskOutputTool.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/getTaskOutputTool.js +88 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/runTaskTool.d.ts +21 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/runTaskTool.js +140 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/taskHelpers.d.ts +22 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task/taskHelpers.js +80 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task.chatAgentTools.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/task.chatAgentTools.contribution.js +40 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.js +36 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.js +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/google-mono-dark.svg +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/media/google-mono-light.svg +0 -3
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
|
|
2
|
+
import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
4
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
+
import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
|
|
6
|
+
import { ChatElicitationRequestPart } from '@codingame/monaco-vscode-dc3fa21d-a483-5b99-a7ab-173235644a34-common/vscode/vs/workbench/contrib/chat/browser/chatElicitationRequestPart';
|
|
7
|
+
import { ChatModel } from '@codingame/monaco-vscode-c2deffc4-ad68-5e63-8f95-9b89e0fc6898-common/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
8
|
+
import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
|
|
9
|
+
|
|
10
|
+
var PollingConsts;
|
|
11
|
+
(function (PollingConsts) {
|
|
12
|
+
PollingConsts[PollingConsts["MinNoDataEvents"] = 2] = "MinNoDataEvents";
|
|
13
|
+
PollingConsts[PollingConsts["MinPollingDuration"] = 500] = "MinPollingDuration";
|
|
14
|
+
PollingConsts[PollingConsts["FirstPollingMaxDuration"] = 20000] = "FirstPollingMaxDuration";
|
|
15
|
+
PollingConsts[PollingConsts["ExtendedPollingMaxDuration"] = 120000] = "ExtendedPollingMaxDuration";
|
|
16
|
+
PollingConsts[PollingConsts["MaxPollingIntervalDuration"] = 2000] = "MaxPollingIntervalDuration";
|
|
17
|
+
})(PollingConsts || (PollingConsts = {}));
|
|
18
|
+
async function racePollingOrPrompt(pollFn, promptFn, originalResult, token, languageModelsService, execution) {
|
|
19
|
+
const pollPromise = pollFn();
|
|
20
|
+
const { promise: promptPromise, part } = promptFn();
|
|
21
|
+
let promptResolved = false;
|
|
22
|
+
const pollPromiseWrapped = pollPromise.then(async (result) => {
|
|
23
|
+
if (!promptResolved && part) {
|
|
24
|
+
part.hide();
|
|
25
|
+
}
|
|
26
|
+
return { type: 'poll', result };
|
|
27
|
+
});
|
|
28
|
+
const promptPromiseWrapped = promptPromise.then(result => {
|
|
29
|
+
promptResolved = true;
|
|
30
|
+
return { type: 'prompt', result };
|
|
31
|
+
});
|
|
32
|
+
const raceResult = await Promise.race([
|
|
33
|
+
pollPromiseWrapped,
|
|
34
|
+
promptPromiseWrapped
|
|
35
|
+
]);
|
|
36
|
+
if (raceResult.type === 'poll') {
|
|
37
|
+
return raceResult.result;
|
|
38
|
+
}
|
|
39
|
+
else if (raceResult.type === 'prompt') {
|
|
40
|
+
const promptResult = raceResult.result;
|
|
41
|
+
if (promptResult) {
|
|
42
|
+
return await pollForOutputAndIdle(execution, true, token, languageModelsService);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return originalResult;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return await pollFn();
|
|
49
|
+
}
|
|
50
|
+
function getOutput(instance, startMarker) {
|
|
51
|
+
if (!instance.xterm || !instance.xterm.raw) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
const lines = [];
|
|
55
|
+
for (let y = Math.min(startMarker?.line ?? 0, 0); y < instance.xterm.raw.buffer.active.length; y++) {
|
|
56
|
+
const line = instance.xterm.raw.buffer.active.getLine(y);
|
|
57
|
+
if (!line) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
lines.push(line.translateToString(true));
|
|
61
|
+
}
|
|
62
|
+
return lines.join('\n');
|
|
63
|
+
}
|
|
64
|
+
async function pollForOutputAndIdle(execution, extendedPolling, token, languageModelsService) {
|
|
65
|
+
const maxWaitMs = extendedPolling ? PollingConsts.ExtendedPollingMaxDuration : PollingConsts.FirstPollingMaxDuration;
|
|
66
|
+
const maxInterval = PollingConsts.MaxPollingIntervalDuration;
|
|
67
|
+
let currentInterval = PollingConsts.MinPollingDuration;
|
|
68
|
+
const pollStartTime = Date.now();
|
|
69
|
+
let lastBufferLength = 0;
|
|
70
|
+
let noNewDataCount = 0;
|
|
71
|
+
let buffer = '';
|
|
72
|
+
let terminalExecutionIdleBeforeTimeout = false;
|
|
73
|
+
while (true) {
|
|
74
|
+
if (token.isCancellationRequested) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
const elapsed = now - pollStartTime;
|
|
79
|
+
const timeLeft = maxWaitMs - elapsed;
|
|
80
|
+
if (timeLeft <= 0) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const waitTime = Math.min(currentInterval, timeLeft);
|
|
84
|
+
await timeout(waitTime);
|
|
85
|
+
if (Date.now() - pollStartTime >= maxWaitMs) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
currentInterval = Math.min(currentInterval * 2, maxInterval);
|
|
89
|
+
buffer = execution.getOutput();
|
|
90
|
+
const currentBufferLength = buffer.length;
|
|
91
|
+
if (currentBufferLength === lastBufferLength) {
|
|
92
|
+
noNewDataCount++;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
noNewDataCount = 0;
|
|
96
|
+
lastBufferLength = currentBufferLength;
|
|
97
|
+
}
|
|
98
|
+
if (noNewDataCount >= PollingConsts.MinNoDataEvents) {
|
|
99
|
+
if (execution.isActive && ((await execution.isActive()) === true)) {
|
|
100
|
+
noNewDataCount = 0;
|
|
101
|
+
lastBufferLength = currentBufferLength;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
terminalExecutionIdleBeforeTimeout = true;
|
|
105
|
+
const modelOutputEvalResponse = await assessOutputForErrors(buffer, token, languageModelsService);
|
|
106
|
+
return { modelOutputEvalResponse, terminalExecutionIdleBeforeTimeout, output: buffer, pollDurationMs: Date.now() - pollStartTime + (extendedPolling ? PollingConsts.FirstPollingMaxDuration : 0) };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { terminalExecutionIdleBeforeTimeout: false, output: buffer, pollDurationMs: Date.now() - pollStartTime + (extendedPolling ? PollingConsts.FirstPollingMaxDuration : 0) };
|
|
110
|
+
}
|
|
111
|
+
function promptForMorePolling(command, token, context, chatService) {
|
|
112
|
+
if (token.isCancellationRequested) {
|
|
113
|
+
return { promise: Promise.resolve(false) };
|
|
114
|
+
}
|
|
115
|
+
const chatModel = chatService.getSession(context.sessionId);
|
|
116
|
+
if (chatModel instanceof ChatModel) {
|
|
117
|
+
const request = chatModel.getRequests().at(-1);
|
|
118
|
+
if (request) {
|
|
119
|
+
let part = undefined;
|
|
120
|
+
const promise = ( new Promise(resolve => {
|
|
121
|
+
const thePart = part = ( new ChatElicitationRequestPart(( new MarkdownString(( localize(11254, "Continue waiting for `{0}` to finish?", command)))), ( new MarkdownString(( localize(
|
|
122
|
+
11255,
|
|
123
|
+
"Copilot will continue to poll for output to determine when the terminal becomes idle for up to 2 minutes."
|
|
124
|
+
)))), '', ( localize(11256, 'Yes')), ( localize(11257, 'No')), async () => {
|
|
125
|
+
thePart.state = 'accepted';
|
|
126
|
+
thePart.hide();
|
|
127
|
+
resolve(true);
|
|
128
|
+
}, async () => {
|
|
129
|
+
thePart.state = 'rejected';
|
|
130
|
+
thePart.hide();
|
|
131
|
+
resolve(false);
|
|
132
|
+
}));
|
|
133
|
+
chatModel.acceptResponseProgress(request, thePart);
|
|
134
|
+
}));
|
|
135
|
+
return { promise, part };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return { promise: Promise.resolve(false) };
|
|
139
|
+
}
|
|
140
|
+
async function assessOutputForErrors(buffer, token, languageModelsService) {
|
|
141
|
+
const models = await languageModelsService.selectLanguageModels({ vendor: 'copilot', family: 'gpt-4o-mini' });
|
|
142
|
+
if (!models.length) {
|
|
143
|
+
return 'No models available';
|
|
144
|
+
}
|
|
145
|
+
const response = await languageModelsService.sendChatRequest(models[0], ( new ExtensionIdentifier('Github.copilot-chat')), [{ role: ChatMessageRole.Assistant, content: [{ type: 'text', value: `Evaluate this terminal output to determine if there were errors or if the command ran successfully: ${buffer}.` }] }], {}, token);
|
|
146
|
+
const streaming = (async () => {
|
|
147
|
+
for await (const part of response.stream) {
|
|
148
|
+
if (Array.isArray(part)) {
|
|
149
|
+
for (const p of part) {
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})();
|
|
154
|
+
try {
|
|
155
|
+
await Promise.all([response.result, streaming]);
|
|
156
|
+
return response.result;
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
return 'Error occurred ' + err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { PollingConsts, assessOutputForErrors, getOutput, pollForOutputAndIdle, promptForMorePolling, racePollingOrPrompt };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import type { OperatingSystem } from "@codingame/monaco-vscode-api/vscode/vs/base/common/platform";
|
|
3
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
4
|
+
export type ICommandApprovalResult = "approved" | "denied" | "noMatch";
|
|
5
|
+
export declare class CommandLineAutoApprover extends Disposable {
|
|
6
|
+
private readonly _configurationService;
|
|
7
|
+
private _denyListRules;
|
|
8
|
+
private _allowListRules;
|
|
9
|
+
private _allowListCommandLineRules;
|
|
10
|
+
private _denyListCommandLineRules;
|
|
11
|
+
constructor(_configurationService: IConfigurationService);
|
|
12
|
+
updateConfiguration(): void;
|
|
13
|
+
isCommandAutoApproved(command: string, shell: string, os: OperatingSystem): {
|
|
14
|
+
result: ICommandApprovalResult;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
isCommandLineAutoApproved(commandLine: string): {
|
|
18
|
+
result: ICommandApprovalResult;
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
private _commandMatchesRegex;
|
|
22
|
+
private _mapAutoApproveConfigToRules;
|
|
23
|
+
private _convertAutoApproveEntryToRegex;
|
|
24
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { regExpLeadsToEndlessLoop } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
5
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
6
|
+
import { TerminalChatAgentToolsSettingId } from '@codingame/monaco-vscode-6883db80-c313-54eb-8fbc-5872c56b0326-common/vscode/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration';
|
|
7
|
+
import { isPowerShell } from './runInTerminalHelpers.js';
|
|
8
|
+
|
|
9
|
+
const neverMatchRegex = /(?!.*)/;
|
|
10
|
+
let CommandLineAutoApprover = class CommandLineAutoApprover extends Disposable {
|
|
11
|
+
constructor(_configurationService) {
|
|
12
|
+
super();
|
|
13
|
+
this._configurationService = _configurationService;
|
|
14
|
+
this._denyListRules = [];
|
|
15
|
+
this._allowListRules = [];
|
|
16
|
+
this._allowListCommandLineRules = [];
|
|
17
|
+
this._denyListCommandLineRules = [];
|
|
18
|
+
this.updateConfiguration();
|
|
19
|
+
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
20
|
+
if (e.affectsConfiguration(TerminalChatAgentToolsSettingId.AutoApprove) ||
|
|
21
|
+
e.affectsConfiguration(TerminalChatAgentToolsSettingId.DeprecatedAutoApproveCompatible)) {
|
|
22
|
+
this.updateConfiguration();
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
updateConfiguration() {
|
|
27
|
+
let configValue = this._configurationService.getValue(TerminalChatAgentToolsSettingId.AutoApprove);
|
|
28
|
+
const deprecatedValue = this._configurationService.getValue(TerminalChatAgentToolsSettingId.DeprecatedAutoApproveCompatible);
|
|
29
|
+
if (deprecatedValue && typeof deprecatedValue === 'object' && configValue && typeof configValue === 'object') {
|
|
30
|
+
configValue = {
|
|
31
|
+
...configValue,
|
|
32
|
+
...deprecatedValue
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const { denyListRules, allowListRules, allowListCommandLineRules, denyListCommandLineRules } = this._mapAutoApproveConfigToRules(configValue);
|
|
36
|
+
this._allowListRules = allowListRules;
|
|
37
|
+
this._denyListRules = denyListRules;
|
|
38
|
+
this._allowListCommandLineRules = allowListCommandLineRules;
|
|
39
|
+
this._denyListCommandLineRules = denyListCommandLineRules;
|
|
40
|
+
}
|
|
41
|
+
isCommandAutoApproved(command, shell, os) {
|
|
42
|
+
for (const rule of this._denyListRules) {
|
|
43
|
+
if (this._commandMatchesRegex(rule.regex, command, shell, os)) {
|
|
44
|
+
return { result: 'denied', reason: `Command '${command}' is denied by deny list rule: ${rule.sourceText}` };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (const rule of this._allowListRules) {
|
|
48
|
+
if (this._commandMatchesRegex(rule.regex, command, shell, os)) {
|
|
49
|
+
return { result: 'approved', reason: `Command '${command}' is approved by allow list rule: ${rule.sourceText}` };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { result: 'noMatch', reason: `Command '${command}' has no matching auto approve entries` };
|
|
53
|
+
}
|
|
54
|
+
isCommandLineAutoApproved(commandLine) {
|
|
55
|
+
for (const rule of this._denyListCommandLineRules) {
|
|
56
|
+
if (rule.regex.test(commandLine)) {
|
|
57
|
+
return { result: 'denied', reason: `Command line '${commandLine}' is denied by deny list rule: ${rule.sourceText}` };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const rule of this._allowListCommandLineRules) {
|
|
61
|
+
if (rule.regex.test(commandLine)) {
|
|
62
|
+
return { result: 'approved', reason: `Command line '${commandLine}' is approved by allow list rule: ${rule.sourceText}` };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { result: 'noMatch', reason: `Command line '${commandLine}' has no matching auto approve entries` };
|
|
66
|
+
}
|
|
67
|
+
_commandMatchesRegex(regex, command, shell, os) {
|
|
68
|
+
if (regex.test(command)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
else if (isPowerShell(shell, os) && command.startsWith('(')) {
|
|
72
|
+
if (regex.test(command.slice(1))) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
_mapAutoApproveConfigToRules(config) {
|
|
79
|
+
if (!config || typeof config !== 'object') {
|
|
80
|
+
return {
|
|
81
|
+
denyListRules: [],
|
|
82
|
+
allowListRules: [],
|
|
83
|
+
allowListCommandLineRules: [],
|
|
84
|
+
denyListCommandLineRules: []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const denyListRules = [];
|
|
88
|
+
const allowListRules = [];
|
|
89
|
+
const allowListCommandLineRules = [];
|
|
90
|
+
const denyListCommandLineRules = [];
|
|
91
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
92
|
+
if (typeof value === 'boolean') {
|
|
93
|
+
const regex = this._convertAutoApproveEntryToRegex(key);
|
|
94
|
+
if (value === true) {
|
|
95
|
+
allowListRules.push({ regex, sourceText: key });
|
|
96
|
+
}
|
|
97
|
+
else if (value === false) {
|
|
98
|
+
denyListRules.push({ regex, sourceText: key });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (typeof value === 'object' && value !== null) {
|
|
102
|
+
const objectValue = value;
|
|
103
|
+
if (typeof objectValue.approve === 'boolean') {
|
|
104
|
+
const regex = this._convertAutoApproveEntryToRegex(key);
|
|
105
|
+
if (objectValue.approve === true) {
|
|
106
|
+
if (objectValue.matchCommandLine === true) {
|
|
107
|
+
allowListCommandLineRules.push({ regex, sourceText: key });
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
allowListRules.push({ regex, sourceText: key });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (objectValue.approve === false) {
|
|
114
|
+
if (objectValue.matchCommandLine === true) {
|
|
115
|
+
denyListCommandLineRules.push({ regex, sourceText: key });
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
denyListRules.push({ regex, sourceText: key });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
denyListRules,
|
|
126
|
+
allowListRules,
|
|
127
|
+
allowListCommandLineRules,
|
|
128
|
+
denyListCommandLineRules
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
_convertAutoApproveEntryToRegex(value) {
|
|
132
|
+
const regexMatch = value.match(/^\/(?<pattern>.+)\/(?<flags>[dgimsuvy]*)$/);
|
|
133
|
+
const regexPattern = regexMatch?.groups?.pattern;
|
|
134
|
+
if (regexPattern) {
|
|
135
|
+
let flags = regexMatch.groups?.flags;
|
|
136
|
+
if (flags) {
|
|
137
|
+
flags = flags.replaceAll('g', '');
|
|
138
|
+
}
|
|
139
|
+
if (regexPattern === '.*') {
|
|
140
|
+
return ( new RegExp(regexPattern));
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const regex = ( new RegExp(regexPattern, flags || undefined));
|
|
144
|
+
if (regExpLeadsToEndlessLoop(regex)) {
|
|
145
|
+
return neverMatchRegex;
|
|
146
|
+
}
|
|
147
|
+
return regex;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return neverMatchRegex;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (value === '') {
|
|
154
|
+
return neverMatchRegex;
|
|
155
|
+
}
|
|
156
|
+
const sanitizedValue = value.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
|
|
157
|
+
return ( new RegExp(`^${sanitizedValue}\\b`));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
CommandLineAutoApprover = ( __decorate([
|
|
161
|
+
( __param(0, IConfigurationService))
|
|
162
|
+
], CommandLineAutoApprover));
|
|
163
|
+
|
|
164
|
+
export { CommandLineAutoApprover };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
+
import type { ICommandDetectionCapability } from "@codingame/monaco-vscode-a9da9abe-278d-5ce6-9418-99c7c07c5c37-common/vscode/vs/platform/terminal/common/capabilities/capabilities";
|
|
3
|
+
import { ITerminalLogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service";
|
|
4
|
+
import type { ITerminalInstance } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
5
|
+
import { type ITerminalExecuteStrategy, type ITerminalExecuteStrategyResult } from "./executeStrategy.js";
|
|
6
|
+
export declare class BasicExecuteStrategy implements ITerminalExecuteStrategy {
|
|
7
|
+
private readonly _instance;
|
|
8
|
+
private readonly _commandDetection;
|
|
9
|
+
private readonly _logService;
|
|
10
|
+
readonly type = "basic";
|
|
11
|
+
constructor(_instance: ITerminalInstance, _commandDetection: ICommandDetectionCapability, _logService: ITerminalLogService);
|
|
12
|
+
execute(commandLine: string, token: CancellationToken): Promise<ITerminalExecuteStrategyResult>;
|
|
13
|
+
private _log;
|
|
14
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
5
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { isNumber } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
7
|
+
import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
|
|
8
|
+
import { trackIdleOnPrompt, waitForIdle } from './executeStrategy.js';
|
|
9
|
+
|
|
10
|
+
let BasicExecuteStrategy = class BasicExecuteStrategy {
|
|
11
|
+
constructor(_instance, _commandDetection, _logService) {
|
|
12
|
+
this._instance = _instance;
|
|
13
|
+
this._commandDetection = _commandDetection;
|
|
14
|
+
this._logService = _logService;
|
|
15
|
+
this.type = 'basic';
|
|
16
|
+
}
|
|
17
|
+
async execute(commandLine, token) {
|
|
18
|
+
const store = ( new DisposableStore());
|
|
19
|
+
try {
|
|
20
|
+
const idlePromptPromise = trackIdleOnPrompt(this._instance, 1000, store);
|
|
21
|
+
const onDone = Promise.race([
|
|
22
|
+
Event.toPromise(this._commandDetection.onCommandFinished, store).then(e => {
|
|
23
|
+
this._log('onDone 1 of 2 via end event, waiting for short idle prompt');
|
|
24
|
+
return idlePromptPromise.then(() => {
|
|
25
|
+
this._log('onDone 2 of 2 via short idle prompt');
|
|
26
|
+
return e;
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
Event.toPromise(token.onCancellationRequested, store).then(() => {
|
|
30
|
+
this._log('onDone via cancellation');
|
|
31
|
+
}),
|
|
32
|
+
trackIdleOnPrompt(this._instance, 3000, store).then(() => {
|
|
33
|
+
this._log('onDone long idle prompt');
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
this._log('Waiting for xterm');
|
|
37
|
+
const xterm = await this._instance.xtermReadyPromise;
|
|
38
|
+
if (!xterm) {
|
|
39
|
+
throw ( new Error('Xterm is not available'));
|
|
40
|
+
}
|
|
41
|
+
this._log('Waiting for idle');
|
|
42
|
+
await waitForIdle(this._instance.onData, 1000);
|
|
43
|
+
let startMarker = store.add(xterm.raw.registerMarker());
|
|
44
|
+
store.add(startMarker.onDispose(() => {
|
|
45
|
+
this._log(`Start marker was disposed, recreating`);
|
|
46
|
+
startMarker = xterm.raw.registerMarker();
|
|
47
|
+
}));
|
|
48
|
+
this._log(`Executing command line \`${commandLine}\``);
|
|
49
|
+
this._instance.sendText(commandLine, true);
|
|
50
|
+
const finishedCommand = await onDone;
|
|
51
|
+
this._log('Waiting for idle');
|
|
52
|
+
await waitForIdle(this._instance.onData, 1000);
|
|
53
|
+
if (token.isCancellationRequested) {
|
|
54
|
+
throw ( new CancellationError());
|
|
55
|
+
}
|
|
56
|
+
const endMarker = store.add(xterm.raw.registerMarker());
|
|
57
|
+
let output;
|
|
58
|
+
const additionalInformationLines = [];
|
|
59
|
+
if (finishedCommand) {
|
|
60
|
+
const commandOutput = finishedCommand?.getOutput();
|
|
61
|
+
if (commandOutput !== undefined) {
|
|
62
|
+
this._log('Fetched output via finished command');
|
|
63
|
+
output = commandOutput;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (output === undefined) {
|
|
67
|
+
try {
|
|
68
|
+
output = xterm.getContentsAsText(startMarker, endMarker);
|
|
69
|
+
this._log('Fetched output via markers');
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
this._log('Failed to fetch output via markers');
|
|
73
|
+
additionalInformationLines.push('Failed to retrieve command output');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (output !== undefined && output.trim().length === 0) {
|
|
77
|
+
additionalInformationLines.push('Command produced no output');
|
|
78
|
+
}
|
|
79
|
+
const exitCode = finishedCommand?.exitCode;
|
|
80
|
+
if (isNumber(exitCode) && exitCode > 0) {
|
|
81
|
+
additionalInformationLines.push(`Command exited with code ${exitCode}`);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
output,
|
|
85
|
+
additionalInformation: additionalInformationLines.length > 0 ? additionalInformationLines.join('\n') : undefined,
|
|
86
|
+
exitCode,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
store.dispose();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_log(message) {
|
|
94
|
+
this._logService.debug(`RunInTerminalTool#Basic: ${message}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
BasicExecuteStrategy = ( __decorate([
|
|
98
|
+
( __param(2, ITerminalLogService))
|
|
99
|
+
], BasicExecuteStrategy));
|
|
100
|
+
|
|
101
|
+
export { BasicExecuteStrategy };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
+
import type { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
3
|
+
import { DisposableStore } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
4
|
+
import type { ITerminalInstance } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
5
|
+
export interface ITerminalExecuteStrategy {
|
|
6
|
+
readonly type: "rich" | "basic" | "none";
|
|
7
|
+
execute(commandLine: string, token: CancellationToken): Promise<ITerminalExecuteStrategyResult>;
|
|
8
|
+
}
|
|
9
|
+
export interface ITerminalExecuteStrategyResult {
|
|
10
|
+
output: string | undefined;
|
|
11
|
+
additionalInformation?: string;
|
|
12
|
+
exitCode?: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function waitForIdle(onData: Event<unknown>, idleDurationMs: number): Promise<void>;
|
|
16
|
+
export declare function trackIdleOnPrompt(instance: ITerminalInstance, idleDurationMs: number, store: DisposableStore): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
import { DeferredPromise, RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
|
|
5
|
+
async function waitForIdle(onData, idleDurationMs) {
|
|
6
|
+
const store = ( new DisposableStore());
|
|
7
|
+
const deferred = ( new DeferredPromise());
|
|
8
|
+
const scheduler = store.add(( new RunOnceScheduler(() => deferred.complete(), idleDurationMs)));
|
|
9
|
+
store.add(onData(() => scheduler.schedule()));
|
|
10
|
+
scheduler.schedule();
|
|
11
|
+
return deferred.p.finally(() => store.dispose());
|
|
12
|
+
}
|
|
13
|
+
async function trackIdleOnPrompt(instance, idleDurationMs, store) {
|
|
14
|
+
const idleOnPrompt = ( new DeferredPromise());
|
|
15
|
+
const onData = instance.onData;
|
|
16
|
+
const scheduler = store.add(( new RunOnceScheduler(() => {
|
|
17
|
+
idleOnPrompt.complete();
|
|
18
|
+
}, idleDurationMs)));
|
|
19
|
+
let TerminalState;
|
|
20
|
+
(function (TerminalState) {
|
|
21
|
+
TerminalState[TerminalState["Initial"] = 0] = "Initial";
|
|
22
|
+
TerminalState[TerminalState["Prompt"] = 1] = "Prompt";
|
|
23
|
+
TerminalState[TerminalState["Executing"] = 2] = "Executing";
|
|
24
|
+
TerminalState[TerminalState["PromptAfterExecuting"] = 3] = "PromptAfterExecuting";
|
|
25
|
+
})(TerminalState || (TerminalState = {}));
|
|
26
|
+
let state = TerminalState.Initial;
|
|
27
|
+
store.add(onData(e => {
|
|
28
|
+
const matches = e.matchAll(/(?:\x1b\]|\x9d)[16]33;(?<type>[ACD])(?:;.*)?(?:\x1b\\|\x07|\x9c)/g);
|
|
29
|
+
for (const match of matches) {
|
|
30
|
+
if (match.groups?.type === 'A') {
|
|
31
|
+
if (state === TerminalState.Initial) {
|
|
32
|
+
state = TerminalState.Prompt;
|
|
33
|
+
}
|
|
34
|
+
else if (state === TerminalState.Executing) {
|
|
35
|
+
state = TerminalState.PromptAfterExecuting;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (match.groups?.type === 'C' || match.groups?.type === 'D') {
|
|
39
|
+
state = TerminalState.Executing;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (state === TerminalState.PromptAfterExecuting) {
|
|
43
|
+
scheduler.schedule();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
scheduler.cancel();
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
return idleOnPrompt.p;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { trackIdleOnPrompt, waitForIdle };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
+
import { ITerminalLogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service";
|
|
3
|
+
import type { ITerminalInstance } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
4
|
+
import { type ITerminalExecuteStrategy, type ITerminalExecuteStrategyResult } from "./executeStrategy.js";
|
|
5
|
+
export declare class NoneExecuteStrategy implements ITerminalExecuteStrategy {
|
|
6
|
+
private readonly _instance;
|
|
7
|
+
private readonly _logService;
|
|
8
|
+
readonly type = "none";
|
|
9
|
+
constructor(_instance: ITerminalInstance, _logService: ITerminalLogService);
|
|
10
|
+
execute(commandLine: string, token: CancellationToken): Promise<ITerminalExecuteStrategyResult>;
|
|
11
|
+
private _log;
|
|
12
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
4
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
|
|
6
|
+
import { waitForIdle } from './executeStrategy.js';
|
|
7
|
+
|
|
8
|
+
let NoneExecuteStrategy = class NoneExecuteStrategy {
|
|
9
|
+
constructor(_instance, _logService) {
|
|
10
|
+
this._instance = _instance;
|
|
11
|
+
this._logService = _logService;
|
|
12
|
+
this.type = 'none';
|
|
13
|
+
}
|
|
14
|
+
async execute(commandLine, token) {
|
|
15
|
+
const store = ( new DisposableStore());
|
|
16
|
+
try {
|
|
17
|
+
if (token.isCancellationRequested) {
|
|
18
|
+
throw ( new CancellationError());
|
|
19
|
+
}
|
|
20
|
+
this._log('Waiting for xterm');
|
|
21
|
+
const xterm = await this._instance.xtermReadyPromise;
|
|
22
|
+
if (!xterm) {
|
|
23
|
+
throw ( new Error('Xterm is not available'));
|
|
24
|
+
}
|
|
25
|
+
this._log('Waiting for idle');
|
|
26
|
+
await waitForIdle(this._instance.onData, 1000);
|
|
27
|
+
if (token.isCancellationRequested) {
|
|
28
|
+
throw ( new CancellationError());
|
|
29
|
+
}
|
|
30
|
+
let startMarker = store.add(xterm.raw.registerMarker());
|
|
31
|
+
store.add(startMarker.onDispose(() => {
|
|
32
|
+
this._log(`Start marker was disposed, recreating`);
|
|
33
|
+
startMarker = xterm.raw.registerMarker();
|
|
34
|
+
}));
|
|
35
|
+
this._log(`Executing command line \`${commandLine}\``);
|
|
36
|
+
this._instance.sendText(commandLine, true);
|
|
37
|
+
this._log('Waiting for idle');
|
|
38
|
+
await waitForIdle(this._instance.onData, 1000);
|
|
39
|
+
if (token.isCancellationRequested) {
|
|
40
|
+
throw ( new CancellationError());
|
|
41
|
+
}
|
|
42
|
+
const endMarker = store.add(xterm.raw.registerMarker());
|
|
43
|
+
let output;
|
|
44
|
+
const additionalInformationLines = [];
|
|
45
|
+
try {
|
|
46
|
+
output = xterm.getContentsAsText(startMarker, endMarker);
|
|
47
|
+
this._log('Fetched output via markers');
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
this._log('Failed to fetch output via markers');
|
|
51
|
+
additionalInformationLines.push('Failed to retrieve command output');
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
output,
|
|
55
|
+
additionalInformation: additionalInformationLines.length > 0 ? additionalInformationLines.join('\n') : undefined,
|
|
56
|
+
exitCode: undefined,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
store.dispose();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_log(message) {
|
|
64
|
+
this._logService.debug(`RunInTerminalTool#None: ${message}`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
NoneExecuteStrategy = ( __decorate([
|
|
68
|
+
( __param(1, ITerminalLogService))
|
|
69
|
+
], NoneExecuteStrategy));
|
|
70
|
+
|
|
71
|
+
export { NoneExecuteStrategy };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
+
import type { ICommandDetectionCapability } from "@codingame/monaco-vscode-a9da9abe-278d-5ce6-9418-99c7c07c5c37-common/vscode/vs/platform/terminal/common/capabilities/capabilities";
|
|
3
|
+
import { ITerminalLogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service";
|
|
4
|
+
import type { ITerminalInstance } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
5
|
+
import { type ITerminalExecuteStrategy, type ITerminalExecuteStrategyResult } from "./executeStrategy.js";
|
|
6
|
+
export declare class RichExecuteStrategy implements ITerminalExecuteStrategy {
|
|
7
|
+
private readonly _instance;
|
|
8
|
+
private readonly _commandDetection;
|
|
9
|
+
private readonly _logService;
|
|
10
|
+
readonly type = "rich";
|
|
11
|
+
constructor(_instance: ITerminalInstance, _commandDetection: ICommandDetectionCapability, _logService: ITerminalLogService);
|
|
12
|
+
execute(commandLine: string, token: CancellationToken): Promise<ITerminalExecuteStrategyResult>;
|
|
13
|
+
private _log;
|
|
14
|
+
}
|