@codingame/monaco-vscode-chat-service-override 25.1.2 → 26.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 +24 -3
- package/package.json +5 -5
- package/vscode/src/vs/platform/browserElements/common/browserElements.d.ts +23 -3
- package/vscode/src/vs/platform/browserElements/common/browserElements.js +13 -6
- package/vscode/src/vs/platform/domWidget/browser/domWidget.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatAccessibilityService.js +42 -27
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatResponseAccessibleView.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatResponseAccessibleView.js +218 -74
- package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatTerminalOutputAccessibleView.js +6 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityActions.js +14 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +165 -168
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAgentRecommendationActions.js +27 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +141 -140
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +189 -121
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +14 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCustomizationDiagnosticsAction.d.ts +60 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCustomizationDiagnosticsAction.js +435 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +28 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +10 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +37 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +54 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.js +73 -34
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +71 -30
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatNewActions.js +151 -89
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPromptNavigationActions.js +12 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +39 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.js +90 -125
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.d.ts +5 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.js +263 -143
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +188 -126
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.js +37 -28
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.d.ts +21 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.js +392 -226
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +31 -27
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsQuickAccess.js +25 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.js +1 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjection.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjection.js +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionActions.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionActions.js +83 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionService.d.ts +68 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionService.js +319 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionsExperiments.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionsExperiments.contribution.js +215 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentTitleBarStatusWidget.d.ts +179 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentTitleBarStatusWidget.js +951 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/media/agentsessionprojection.css +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/media/agenttitlebarstatuswidget.css +388 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/media/unifiedQuickAccess.css +195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccess.d.ts +120 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccess.js +394 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccessActions.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccessActions.js +95 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.d.ts +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/localAgentSessionsProvider.js +31 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentResolveService.js +49 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatVariables.js +4 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/media/simpleBrowserOverlay.css +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/attachments/simpleBrowserEditorOverlay.js +188 -151
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +1012 -639
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCheckpointTimelineImpl.js +256 -151
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +8 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +182 -101
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.d.ts +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingDeletedFileEntry.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.js +9 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationModelManager.d.ts +68 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationModelManager.js +253 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +69 -50
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +52 -33
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +5 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +274 -155
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingOperations.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +2 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +130 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +12 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +385 -160
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.js +53 -36
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelChangeService.js +112 -75
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +19 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/media/chatEditorController.css +31 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +39 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNewNotebookContentEdits.js +10 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +25 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +265 -203
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +29 -26
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +114 -60
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +16 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.js +44 -30
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagement.contribution.js +119 -45
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.js +152 -136
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.js +12 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.d.ts +51 -31
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.js +323 -217
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.js +653 -401
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.js +52 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatModelsWidget.css +22 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.d.ts +5 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.js +43 -28
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +182 -136
- package/vscode/src/vs/workbench/contrib/chat/browser/chatRepoInfo.d.ts +33 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatRepoInfo.js +548 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.js +222 -138
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupController.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupController.js +151 -113
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupProviders.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupProviders.js +453 -217
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupRunner.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupRunner.js +162 -88
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/media/chatSetup.css +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatus.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatus.js +1 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.js +309 -233
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusEntry.js +55 -53
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusItemService.js +3 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatTipService.d.ts +37 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatTipService.js +109 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWindowNotifier.js +35 -23
- package/vscode/src/vs/workbench/contrib/chat/browser/contextContrib/chatContextService.d.ts +9 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/contextContrib/chatContextService.js +73 -33
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.js +333 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.js +39 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionContribution.js +9 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionOverlay.js +23 -20
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptFileActions.js +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +20 -16
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.js +65 -57
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.js +48 -36
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveAsPromptFileActions.js +20 -12
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/skillActions.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/skillActions.js +52 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsConfirmationService.js +155 -159
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.d.ts +24 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.js +521 -246
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.js +107 -76
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +28 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownAnchorService.js +10 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolOutputStateCache.d.ts +16 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolOutputStateCache.js +57 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatLayoutService.js +4 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/chatWidgetService.js +56 -44
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatStatusWidget.d.ts +0 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatStatusWidget.js +37 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatEditorInputContentProvider.js +5 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.js +1284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorContrib.js +179 -125
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorHover.js +9 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/editorHoverWrapper.js +7 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/chatQuick.js +96 -78
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditor.js +58 -53
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.d.ts +25 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.js +484 -292
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.d.ts +1 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +65 -92
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/media/chatViewPane.css +16 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/media/chatViewTitleControl.css +1 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.d.ts +9 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.js +331 -189
- package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceTelemetry.js +81 -93
- package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +1 -3
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatModelStore.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatModelStore.js +6 -7
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.d.ts +36 -8
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.js +169 -31
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionOperationLog.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionOperationLog.js +141 -0
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionStore.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionStore.js +218 -144
- package/vscode/src/vs/workbench/contrib/chat/common/model/chatTransferService.js +20 -10
- package/vscode/src/vs/workbench/contrib/chat/common/model/objectMutationLog.d.ts +109 -0
- package/vscode/src/vs/workbench/contrib/chat/common/model/objectMutationLog.js +349 -0
- package/vscode/src/vs/workbench/contrib/chat/common/participants/chatSlashCommands.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.js +139 -36
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/PromptHeaderDefinitionProvider.js +3 -6
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptBodyAutocompletion.js +64 -51
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptCodeActions.js +49 -34
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptDocumentSemanticTokensProvider.js +21 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.js +125 -97
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHovers.js +91 -131
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptLinkProvider.js +8 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.js +488 -222
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/promptFileContributions.js +32 -12
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.d.ts +58 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.js +717 -200
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +79 -18
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +371 -130
- package/vscode/src/vs/workbench/contrib/chat/common/tools/chatTodoListService.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/chatTodoListService.js +3 -7
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +79 -61
- package/vscode/src/vs/workbench/contrib/chat/common/widget/chatResponseResourceFileSystemProvider.js +27 -21
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/aiEditTelemetry/aiEditTelemetryServiceImpl.js +7 -10
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +26 -32
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +2 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.d.ts +8 -60
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +115 -426
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDefaultModel.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDefaultModel.js +127 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -37
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.d.ts +16 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.js +21 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +51 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +334 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.d.ts +41 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.js +424 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.js +58 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +195 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +368 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +7 -0
- 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 +1 -1
- package/vscode/src/vs/workbench/contrib/remoteCodingAgents/browser/remoteCodingAgents.contribution.js +23 -25
- package/vscode/src/vs/workbench/contrib/remoteCodingAgents/common/remoteCodingAgentsService.js +7 -8
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.js +34 -38
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibleView.js +8 -12
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.js +103 -95
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.js +28 -16
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatEnabler.js +4 -5
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.d.ts +12 -8
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.js +65 -54
- package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.js +86 -60
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/alternativeRecommendation.js +13 -26
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/commandFileWriteParser.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/sedFileWriteParser.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/sedFileWriteParser.js +142 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.js +56 -46
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.js +63 -31
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.js +35 -30
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.js +44 -37
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.js +3 -4
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/outputHelpers.js +3 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.js +70 -50
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalToolTelemetry.js +26 -394
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/taskHelpers.js +85 -49
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.js +68 -27
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.js +67 -45
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/awaitTerminalTool.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/awaitTerminalTool.js +106 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.js +177 -97
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/npmScriptAutoApprover.js +136 -49
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAnalyzer.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.js +128 -112
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.js +51 -49
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineSandboxAnalyzer.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineSandboxAnalyzer.js +25 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/commandLinePresenter.d.ts +41 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/nodeCommandLinePresenter.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/nodeCommandLinePresenter.js +37 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/pythonCommandLinePresenter.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/pythonCommandLinePresenter.js +37 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.js +44 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/sandboxedCommandLinePresenter.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/sandboxedCommandLinePresenter.js +21 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineCdPrefixRewriter.js +5 -14
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePreventHistoryRewriter.js +2 -4
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineRewriter.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineSandboxRewriter.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineSandboxRewriter.js +29 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalLastCommandTool.js +30 -31
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.js +16 -17
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalSelectionTool.js +19 -20
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/killTerminalTool.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/killTerminalTool.js +58 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.d.ts +31 -3
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.js +325 -199
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/types.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/types.js +1 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.js +33 -38
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.d.ts +45 -5
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.js +746 -456
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/createAndRunTaskTool.js +145 -98
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/getTaskOutputTool.js +88 -37
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/runTaskTool.js +120 -51
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/taskHelpers.js +25 -28
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/terminalCommandArtifactCollector.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/terminalCommandArtifactCollector.js +58 -12
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/toolIds.d.ts +12 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/toolIds.js +17 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.d.ts +8 -1
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.js +47 -28
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.d.ts +37 -0
- package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.js +171 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.d.ts +0 -58
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl.js +0 -213
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsFilter.d.ts +0 -39
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsFilter.js +0 -243
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsOpener.d.ts +0 -7
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsOpener.js +0 -41
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.d.ts +0 -166
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.js +0 -607
- package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/media/agentsessionsviewer.css +0 -255
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +0 -46
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +0 -396
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.d.ts +0 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +0 -379
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/media/chatEditingEditorOverlay.css +0 -117
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.d.ts +0 -141
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.js +0 -961
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +0 -36
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +0 -447
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +0 -251
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +0 -10
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +0 -42
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { timeout, DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
4
4
|
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
5
5
|
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
6
6
|
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
7
7
|
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
8
8
|
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
9
9
|
import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
10
|
-
import {
|
|
10
|
+
import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
|
|
11
|
+
import { basename, win32, posix } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
|
|
11
12
|
import { OS, OperatingSystem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
12
13
|
import { count } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
13
14
|
import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
|
|
14
15
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
15
16
|
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
16
17
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
|
+
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
17
19
|
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
18
20
|
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
19
21
|
import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
@@ -31,18 +33,26 @@ import { BasicExecuteStrategy } from '../executeStrategy/basicExecuteStrategy.js
|
|
|
31
33
|
import { NoneExecuteStrategy } from '../executeStrategy/noneExecuteStrategy.js';
|
|
32
34
|
import { RichExecuteStrategy } from '../executeStrategy/richExecuteStrategy.js';
|
|
33
35
|
import { getOutput } from '../outputHelpers.js';
|
|
34
|
-
import { isWindowsPowerShell, isPowerShell, isZsh, isFish } from '../runInTerminalHelpers.js';
|
|
36
|
+
import { isWindowsPowerShell, isPowerShell, isZsh, isFish, extractCdPrefix } from '../runInTerminalHelpers.js';
|
|
37
|
+
import { NodeCommandLinePresenter } from './commandLinePresenter/nodeCommandLinePresenter.js';
|
|
38
|
+
import { PythonCommandLinePresenter } from './commandLinePresenter/pythonCommandLinePresenter.js';
|
|
39
|
+
import { RubyCommandLinePresenter } from './commandLinePresenter/rubyCommandLinePresenter.js';
|
|
40
|
+
import { SandboxedCommandLinePresenter } from './commandLinePresenter/sandboxedCommandLinePresenter.js';
|
|
35
41
|
import { RunInTerminalToolTelemetry } from '../runInTerminalToolTelemetry.js';
|
|
36
42
|
import { ToolTerminalCreator, ShellIntegrationQuality } from '../toolTerminalCreator.js';
|
|
37
43
|
import { TreeSitterCommandParser, TreeSitterCommandParserLanguage } from '../treeSitterCommandParser.js';
|
|
38
44
|
import { CommandLineAutoApproveAnalyzer } from './commandLineAnalyzer/commandLineAutoApproveAnalyzer.js';
|
|
39
45
|
import { CommandLineFileWriteAnalyzer } from './commandLineAnalyzer/commandLineFileWriteAnalyzer.js';
|
|
46
|
+
import { CommandLineSandboxAnalyzer } from './commandLineAnalyzer/commandLineSandboxAnalyzer.js';
|
|
40
47
|
import { OutputMonitor } from './monitoring/outputMonitor.js';
|
|
41
48
|
import { OutputMonitorState } from './monitoring/types.js';
|
|
42
|
-
import { LocalChatSessionUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatUri';
|
|
49
|
+
import { LocalChatSessionUri, chatSessionResourceToId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatUri';
|
|
50
|
+
import { TerminalToolId } from './toolIds.js';
|
|
51
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
43
52
|
import { CommandLineCdPrefixRewriter } from './commandLineRewriter/commandLineCdPrefixRewriter.js';
|
|
44
53
|
import { CommandLinePreventHistoryRewriter } from './commandLineRewriter/commandLinePreventHistoryRewriter.js';
|
|
45
54
|
import { CommandLinePwshChainOperatorRewriter } from './commandLineRewriter/commandLinePwshChainOperatorRewriter.js';
|
|
55
|
+
import { CommandLineSandboxRewriter } from './commandLineRewriter/commandLineSandboxRewriter.js';
|
|
46
56
|
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
47
57
|
import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
|
|
48
58
|
import { TerminalCommandArtifactCollector } from './terminalCommandArtifactCollector.js';
|
|
@@ -50,50 +60,52 @@ import { isNumber, isString } from '@codingame/monaco-vscode-api/vscode/vs/base/
|
|
|
50
60
|
import { ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
51
61
|
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
52
62
|
import { TerminalChatCommandId } from '@codingame/monaco-vscode-xterm-common/vscode/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat';
|
|
63
|
+
import { clamp } from '@codingame/monaco-vscode-api/vscode/vs/base/common/numbers';
|
|
53
64
|
|
|
54
65
|
var RunInTerminalTool_1;
|
|
55
|
-
const TOOL_REFERENCE_NAME =
|
|
56
|
-
const LEGACY_TOOL_REFERENCE_FULL_NAMES = [
|
|
66
|
+
const TOOL_REFERENCE_NAME = "runInTerminal";
|
|
67
|
+
const LEGACY_TOOL_REFERENCE_FULL_NAMES = ["runCommands/runInTerminal"];
|
|
57
68
|
function createPowerShellModelDescription(shell) {
|
|
58
69
|
const isWinPwsh = isWindowsPowerShell(shell);
|
|
59
70
|
return [
|
|
60
|
-
`This tool allows you to execute ${isWinPwsh ?
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
isWinPwsh ?
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
71
|
+
`This tool allows you to execute ${isWinPwsh ? "Windows PowerShell 5.1" : "PowerShell"} commands in a persistent terminal session, preserving environment variables, working directory, and other context across multiple commands.`,
|
|
72
|
+
"",
|
|
73
|
+
"Command Execution:",
|
|
74
|
+
isWinPwsh ? "- Use semicolons ; to chain commands on one line, NEVER use && even when asked explicitly" : "- Prefer ; when chaining commands on one line",
|
|
75
|
+
"- Prefer pipelines | for object-based data flow",
|
|
76
|
+
"- Never create a sub-shell (eg. powershell -c \"command\") unless explicitly asked",
|
|
77
|
+
"",
|
|
78
|
+
"Directory Management:",
|
|
79
|
+
"- Prefer relative paths when navigating directories, only use absolute when the path is far away or the current cwd is not expected",
|
|
80
|
+
"- Remember when isBackground=false is specified, that the shell and cwd are reused until it is moved to the background",
|
|
81
|
+
"- Use $PWD or Get-Location for current directory",
|
|
82
|
+
"- Use Push-Location/Pop-Location for directory stack",
|
|
83
|
+
"",
|
|
84
|
+
"Program Execution:",
|
|
85
|
+
"- Supports .NET, Python, Node.js, and other executables",
|
|
86
|
+
"- Install modules via Install-Module, Install-Package",
|
|
87
|
+
"- Use Get-Command to verify cmdlet/function availability",
|
|
88
|
+
"",
|
|
89
|
+
"Background Processes:",
|
|
90
|
+
"- For long-running tasks (e.g., servers), set isBackground=true",
|
|
91
|
+
"- Returns a terminal ID for checking status and runtime later",
|
|
92
|
+
"- Use Start-Job for background PowerShell jobs",
|
|
93
|
+
"",
|
|
94
|
+
"Output Management:",
|
|
95
|
+
"- Output is automatically truncated if longer than 60KB to prevent context overflow",
|
|
96
|
+
"- Use Select-Object, Where-Object, Format-Table to filter output",
|
|
97
|
+
"- Use -First/-Last parameters to limit results",
|
|
98
|
+
"- For pager commands, add | Out-String or | Format-List",
|
|
99
|
+
"",
|
|
100
|
+
"Best Practices:",
|
|
101
|
+
"- Use proper cmdlet names instead of aliases in scripts",
|
|
102
|
+
"- Quote paths with spaces: \"C:\\Path With Spaces\"",
|
|
103
|
+
"- Prefer PowerShell cmdlets over external commands when available",
|
|
104
|
+
"- Prefer idiomatic PowerShell like Get-ChildItem instead of dir or ls for file listings",
|
|
105
|
+
"- Use Test-Path to check file/directory existence",
|
|
106
|
+
"- Be specific with Select-Object properties to avoid excessive output",
|
|
107
|
+
"- Avoid printing credentials unless absolutely required"
|
|
108
|
+
].join("\n");
|
|
97
109
|
}
|
|
98
110
|
const genericDescription = `
|
|
99
111
|
Command Execution:
|
|
@@ -102,7 +114,8 @@ Command Execution:
|
|
|
102
114
|
- Never create a sub-shell (eg. bash -c "command") unless explicitly asked
|
|
103
115
|
|
|
104
116
|
Directory Management:
|
|
105
|
-
-
|
|
117
|
+
- Prefer relative paths when navigating directories, only use absolute when the path is far away or the current cwd is not expected
|
|
118
|
+
- Remember when isBackground=false is specified, that shell and cwd is reused until it is moved to the background
|
|
106
119
|
- Use $PWD for current directory references
|
|
107
120
|
- Consider using pushd/popd for directory stack management
|
|
108
121
|
- Supports directory shortcuts like ~ and -
|
|
@@ -129,37 +142,37 @@ Best Practices:
|
|
|
129
142
|
- Avoid printing credentials unless absolutely required`;
|
|
130
143
|
function createBashModelDescription() {
|
|
131
144
|
return [
|
|
132
|
-
|
|
145
|
+
"This tool allows you to execute shell commands in a persistent bash terminal session, preserving environment variables, working directory, and other context across multiple commands.",
|
|
133
146
|
genericDescription,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
].join(
|
|
147
|
+
"- Use [[ ]] for conditional tests instead of [ ]",
|
|
148
|
+
"- Prefer $() over backticks for command substitution",
|
|
149
|
+
"- Use set -e at start of complex commands to exit on errors"
|
|
150
|
+
].join("\n");
|
|
138
151
|
}
|
|
139
152
|
function createZshModelDescription() {
|
|
140
153
|
return [
|
|
141
|
-
|
|
154
|
+
"This tool allows you to execute shell commands in a persistent zsh terminal session, preserving environment variables, working directory, and other context across multiple commands.",
|
|
142
155
|
genericDescription,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
].join(
|
|
156
|
+
"- Use type to check command type (builtin, function, alias)",
|
|
157
|
+
"- Use jobs, fg, bg for job control",
|
|
158
|
+
"- Use [[ ]] for conditional tests instead of [ ]",
|
|
159
|
+
"- Prefer $() over backticks for command substitution",
|
|
160
|
+
"- Use setopt errexit for strict error handling",
|
|
161
|
+
"- Take advantage of zsh globbing features (**, extended globs)"
|
|
162
|
+
].join("\n");
|
|
150
163
|
}
|
|
151
164
|
function createFishModelDescription() {
|
|
152
165
|
return [
|
|
153
|
-
|
|
166
|
+
"This tool allows you to execute shell commands in a persistent fish terminal session, preserving environment variables, working directory, and other context across multiple commands.",
|
|
154
167
|
genericDescription,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
].join(
|
|
168
|
+
"- Use type to check command type (builtin, function, alias)",
|
|
169
|
+
"- Use jobs, fg, bg for job control",
|
|
170
|
+
"- Use test expressions for conditionals (no [[ ]] syntax)",
|
|
171
|
+
"- Prefer command substitution with () syntax",
|
|
172
|
+
"- Variables are arrays by default, use $var[1] for first element",
|
|
173
|
+
"- Use set -e for strict error handling",
|
|
174
|
+
"- Take advantage of fish's autosuggestions and completions"
|
|
175
|
+
].join("\n");
|
|
163
176
|
}
|
|
164
177
|
async function createRunInTerminalToolData(accessor) {
|
|
165
178
|
const instantiationService = accessor.get(IInstantiationService);
|
|
@@ -169,74 +182,105 @@ async function createRunInTerminalToolData(accessor) {
|
|
|
169
182
|
let modelDescription;
|
|
170
183
|
if (shell && os && isPowerShell(shell, os)) {
|
|
171
184
|
modelDescription = createPowerShellModelDescription(shell);
|
|
172
|
-
}
|
|
173
|
-
else if (shell && os && isZsh(shell, os)) {
|
|
185
|
+
} else if (shell && os && isZsh(shell, os)) {
|
|
174
186
|
modelDescription = createZshModelDescription();
|
|
175
|
-
}
|
|
176
|
-
else if (shell && os && isFish(shell, os)) {
|
|
187
|
+
} else if (shell && os && isFish(shell, os)) {
|
|
177
188
|
modelDescription = createFishModelDescription();
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
189
|
+
} else {
|
|
180
190
|
modelDescription = createBashModelDescription();
|
|
181
191
|
}
|
|
182
192
|
return {
|
|
183
|
-
id:
|
|
193
|
+
id: TerminalToolId.RunInTerminal,
|
|
184
194
|
toolReferenceName: TOOL_REFERENCE_NAME,
|
|
185
195
|
legacyToolReferenceFullNames: LEGACY_TOOL_REFERENCE_FULL_NAMES,
|
|
186
|
-
displayName: ( localize(
|
|
196
|
+
displayName: ( localize(12392, "Run in Terminal")),
|
|
187
197
|
modelDescription,
|
|
188
|
-
userDescription: ( localize(
|
|
198
|
+
userDescription: ( localize(12393, "Run commands in the terminal")),
|
|
189
199
|
source: ToolDataSource.Internal,
|
|
190
200
|
icon: Codicon.terminal,
|
|
191
201
|
inputSchema: {
|
|
192
|
-
type:
|
|
202
|
+
type: "object",
|
|
193
203
|
properties: {
|
|
194
204
|
command: {
|
|
195
|
-
type:
|
|
196
|
-
description:
|
|
205
|
+
type: "string",
|
|
206
|
+
description: "The command to run in the terminal."
|
|
197
207
|
},
|
|
198
208
|
explanation: {
|
|
199
|
-
type:
|
|
200
|
-
description:
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "A one-sentence description of what the command does. This will be shown to the user before the command is run."
|
|
211
|
+
},
|
|
212
|
+
goal: {
|
|
213
|
+
type: "string",
|
|
214
|
+
description: "A short description of the goal or purpose of the command (e.g., \"Install dependencies\", \"Start development server\")."
|
|
201
215
|
},
|
|
202
216
|
isBackground: {
|
|
203
|
-
type:
|
|
204
|
-
description:
|
|
217
|
+
type: "boolean",
|
|
218
|
+
description: `Whether the command starts a background process.\n\n- If true, a new shell will be spawned where the cwd is the workspace directory and will run asynchronously in the background and you will not see the output.\n\n- If false, a single shell is shared between all non-background terminals where the cwd starts at the workspace directory and is remembered until that terminal is moved to the background, the tool call will block on the command finishing and only then you will get the output.\n\nExamples of background processes: building in watch mode, starting a server. You can check the output of a background process later on by using ${TerminalToolId.GetTerminalOutput}.`
|
|
205
219
|
},
|
|
220
|
+
timeout: {
|
|
221
|
+
type: "number",
|
|
222
|
+
description: "An optional timeout in milliseconds. When provided, the tool will stop tracking the command after this duration and return the output collected so far. Be conservative with the timeout duration, give enough time that the command would complete on a low-end machine. Use 0 for no timeout. If it's not clear how long the command will take then use 0 to avoid prematurely terminating it, never guess too low."
|
|
223
|
+
}
|
|
206
224
|
},
|
|
207
|
-
required: [
|
|
208
|
-
'command',
|
|
209
|
-
'explanation',
|
|
210
|
-
'isBackground',
|
|
211
|
-
]
|
|
225
|
+
required: ["command", "explanation", "goal", "isBackground", "timeout"]
|
|
212
226
|
}
|
|
213
227
|
};
|
|
214
228
|
}
|
|
215
229
|
var TerminalToolStorageKeysInternal;
|
|
216
|
-
(function
|
|
230
|
+
(function(TerminalToolStorageKeysInternal) {
|
|
217
231
|
TerminalToolStorageKeysInternal["TerminalSession"] = "chat.terminalSessions";
|
|
218
232
|
})(TerminalToolStorageKeysInternal || (TerminalToolStorageKeysInternal = {}));
|
|
219
233
|
const telemetryIgnoredSequences = [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const altBufferMessage = ( localize(12060, "The command opened the alternate buffer."));
|
|
234
|
+
"\u001b[I",
|
|
235
|
+
"\u001b[O"];
|
|
236
|
+
const altBufferMessage = ( localize(12394, "The command opened the alternate buffer."));
|
|
224
237
|
let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
225
|
-
static {
|
|
226
|
-
|
|
238
|
+
static {
|
|
239
|
+
RunInTerminalTool_1 = this;
|
|
240
|
+
}
|
|
241
|
+
static {
|
|
242
|
+
this._activeExecutions = ( new Map());
|
|
243
|
+
}
|
|
227
244
|
static getBackgroundOutput(id) {
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
230
|
-
throw ( new Error(
|
|
245
|
+
const execution = RunInTerminalTool_1._activeExecutions.get(id);
|
|
246
|
+
if (!execution) {
|
|
247
|
+
throw ( new Error("Invalid terminal ID"));
|
|
248
|
+
}
|
|
249
|
+
return execution.getOutput();
|
|
250
|
+
}
|
|
251
|
+
static getExecution(id) {
|
|
252
|
+
return RunInTerminalTool_1._activeExecutions.get(id);
|
|
253
|
+
}
|
|
254
|
+
static removeExecution(id) {
|
|
255
|
+
const execution = RunInTerminalTool_1._activeExecutions.get(id);
|
|
256
|
+
if (!execution) {
|
|
257
|
+
return false;
|
|
231
258
|
}
|
|
232
|
-
|
|
259
|
+
execution.dispose();
|
|
260
|
+
RunInTerminalTool_1._activeExecutions.delete(id);
|
|
261
|
+
return true;
|
|
233
262
|
}
|
|
234
|
-
constructor(
|
|
263
|
+
constructor(
|
|
264
|
+
_chatService,
|
|
265
|
+
_configurationService,
|
|
266
|
+
_historyService,
|
|
267
|
+
_instantiationService,
|
|
268
|
+
_labelService,
|
|
269
|
+
_languageModelToolsService,
|
|
270
|
+
_remoteAgentService,
|
|
271
|
+
_storageService,
|
|
272
|
+
_terminalChatService,
|
|
273
|
+
_logService,
|
|
274
|
+
_terminalService,
|
|
275
|
+
_workspaceContextService,
|
|
276
|
+
_chatWidgetService
|
|
277
|
+
) {
|
|
235
278
|
super();
|
|
236
279
|
this._chatService = _chatService;
|
|
237
280
|
this._configurationService = _configurationService;
|
|
238
281
|
this._historyService = _historyService;
|
|
239
282
|
this._instantiationService = _instantiationService;
|
|
283
|
+
this._labelService = _labelService;
|
|
240
284
|
this._languageModelToolsService = _languageModelToolsService;
|
|
241
285
|
this._remoteAgentService = _remoteAgentService;
|
|
242
286
|
this._storageService = _storageService;
|
|
@@ -245,7 +289,7 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
245
289
|
this._terminalService = _terminalService;
|
|
246
290
|
this._workspaceContextService = _workspaceContextService;
|
|
247
291
|
this._chatWidgetService = _chatWidgetService;
|
|
248
|
-
this._sessionTerminalAssociations = ( new
|
|
292
|
+
this._sessionTerminalAssociations = ( new ResourceMap());
|
|
249
293
|
this._osBackend = this._remoteAgentService.getEnvironment().then(remoteEnv => remoteEnv?.os ?? OS);
|
|
250
294
|
this._terminalToolCreator = this._instantiationService.createInstance(ToolTerminalCreator);
|
|
251
295
|
this._treeSitterCommandParser = this._register(this._instantiationService.createInstance(TreeSitterCommandParser));
|
|
@@ -254,57 +298,80 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
254
298
|
this._profileFetcher = this._instantiationService.createInstance(TerminalProfileFetcher);
|
|
255
299
|
this._commandLineRewriters = [
|
|
256
300
|
this._register(this._instantiationService.createInstance(CommandLineCdPrefixRewriter)),
|
|
257
|
-
this._register(
|
|
258
|
-
|
|
301
|
+
this._register(
|
|
302
|
+
this._instantiationService.createInstance(CommandLinePwshChainOperatorRewriter, this._treeSitterCommandParser)
|
|
303
|
+
),
|
|
304
|
+
this._register(
|
|
305
|
+
this._instantiationService.createInstance(CommandLinePreventHistoryRewriter)
|
|
306
|
+
),
|
|
307
|
+
this._register(this._instantiationService.createInstance(CommandLineSandboxRewriter))
|
|
259
308
|
];
|
|
260
|
-
this._commandLineAnalyzers = [
|
|
261
|
-
|
|
262
|
-
this.
|
|
309
|
+
this._commandLineAnalyzers = [this._register(this._instantiationService.createInstance(
|
|
310
|
+
CommandLineFileWriteAnalyzer,
|
|
311
|
+
this._treeSitterCommandParser,
|
|
312
|
+
(message, args) => this._logService.info(`RunInTerminalTool#CommandLineFileWriteAnalyzer: ${message}`, args)
|
|
313
|
+
)), this._register(this._instantiationService.createInstance(
|
|
314
|
+
CommandLineAutoApproveAnalyzer,
|
|
315
|
+
this._treeSitterCommandParser,
|
|
316
|
+
this._telemetry,
|
|
317
|
+
(message, args) => this._logService.info(`RunInTerminalTool#CommandLineAutoApproveAnalyzer: ${message}`, args)
|
|
318
|
+
)), this._register(this._instantiationService.createInstance(CommandLineSandboxAnalyzer))];
|
|
319
|
+
this._commandLinePresenters = [
|
|
320
|
+
this._instantiationService.createInstance(SandboxedCommandLinePresenter),
|
|
321
|
+
( new NodeCommandLinePresenter()),
|
|
322
|
+
( new PythonCommandLinePresenter()),
|
|
323
|
+
( new RubyCommandLinePresenter())
|
|
263
324
|
];
|
|
264
|
-
this._register(
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
this.
|
|
325
|
+
this._register(
|
|
326
|
+
Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {
|
|
327
|
+
if (!e || e.affectsConfiguration(TerminalChatAgentToolsSettingId.EnableAutoApprove)) {
|
|
328
|
+
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) !== true) {
|
|
329
|
+
this._storageService.remove(
|
|
330
|
+
TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted,
|
|
331
|
+
StorageScope.APPLICATION
|
|
332
|
+
);
|
|
333
|
+
}
|
|
268
334
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
335
|
+
})
|
|
336
|
+
);
|
|
271
337
|
this._restoreTerminalAssociations();
|
|
272
338
|
this._register(this._terminalService.onDidDisposeInstance(e => {
|
|
273
|
-
for (const [
|
|
339
|
+
for (const [sessionResource, toolTerminal] of this._sessionTerminalAssociations.entries()) {
|
|
274
340
|
if (e === toolTerminal.instance) {
|
|
275
|
-
this._sessionTerminalAssociations.delete(
|
|
341
|
+
this._sessionTerminalAssociations.delete(sessionResource);
|
|
276
342
|
}
|
|
277
343
|
}
|
|
278
344
|
}));
|
|
279
345
|
this._register(this._chatService.onDidDisposeSession(e => {
|
|
280
346
|
for (const resource of e.sessionResource) {
|
|
281
|
-
|
|
282
|
-
if (localSessionId) {
|
|
283
|
-
this._cleanupSessionTerminals(localSessionId);
|
|
284
|
-
}
|
|
347
|
+
this._cleanupSessionTerminals(resource);
|
|
285
348
|
}
|
|
286
349
|
}));
|
|
287
350
|
}
|
|
288
351
|
async prepareToolInvocation(context, token) {
|
|
289
352
|
const args = context.parameters;
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
this.
|
|
294
|
-
(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
353
|
+
const chatSessionResource = context.chatSessionResource ?? (context.chatSessionId ? LocalChatSessionUri.forSession(context.chatSessionId) : undefined);
|
|
354
|
+
let instance;
|
|
355
|
+
if (chatSessionResource) {
|
|
356
|
+
const toolTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
|
|
357
|
+
if (toolTerminal && !toolTerminal.isBackground) {
|
|
358
|
+
instance = toolTerminal.instance;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const [os, shell, cwd] = await Promise.all([this._osBackend, this._profileFetcher.getCopilotShell(), (async () => {
|
|
362
|
+
let cwd = await instance?.getCwdResource();
|
|
363
|
+
if (!cwd) {
|
|
364
|
+
const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
|
|
365
|
+
const workspaceFolder = activeWorkspaceRootUri ? this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
|
|
366
|
+
cwd = workspaceFolder?.uri;
|
|
367
|
+
}
|
|
368
|
+
return cwd;
|
|
369
|
+
})()]);
|
|
370
|
+
const language = os === OperatingSystem.Windows ? "pwsh" : "sh";
|
|
305
371
|
const terminalToolSessionId = generateUuid();
|
|
306
372
|
const terminalCommandId = `tool-${generateUuid()}`;
|
|
307
373
|
let rewrittenCommand = args.command;
|
|
374
|
+
let forDisplayCommand = undefined;
|
|
308
375
|
for (const rewriter of this._commandLineRewriters) {
|
|
309
376
|
const rewriteResult = await rewriter.rewrite({
|
|
310
377
|
commandLine: rewrittenCommand,
|
|
@@ -314,18 +381,24 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
314
381
|
});
|
|
315
382
|
if (rewriteResult) {
|
|
316
383
|
rewrittenCommand = rewriteResult.rewritten;
|
|
317
|
-
|
|
384
|
+
forDisplayCommand = rewriteResult.forDisplay;
|
|
385
|
+
this._logService.info(
|
|
386
|
+
`RunInTerminalTool: Command rewritten by ${rewriter.constructor.name}: ${rewriteResult.reasoning}`
|
|
387
|
+
);
|
|
318
388
|
}
|
|
319
389
|
}
|
|
320
390
|
const toolSpecificData = {
|
|
321
|
-
kind:
|
|
391
|
+
kind: "terminal",
|
|
322
392
|
terminalToolSessionId,
|
|
323
393
|
terminalCommandId,
|
|
324
394
|
commandLine: {
|
|
325
395
|
original: args.command,
|
|
326
|
-
toolEdited: rewrittenCommand === args.command ? undefined : rewrittenCommand
|
|
396
|
+
toolEdited: rewrittenCommand === args.command ? undefined : rewrittenCommand,
|
|
397
|
+
forDisplay: forDisplayCommand
|
|
327
398
|
},
|
|
399
|
+
cwd,
|
|
328
400
|
language,
|
|
401
|
+
isBackground: args.isBackground
|
|
329
402
|
};
|
|
330
403
|
const alternativeRecommendation = getRecommendedToolsOverRunInTerminal(args.command, this._languageModelToolsService);
|
|
331
404
|
if (alternativeRecommendation) {
|
|
@@ -333,13 +406,13 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
333
406
|
return {
|
|
334
407
|
confirmationMessages: undefined,
|
|
335
408
|
presentation: ToolInvocationPresentation.Hidden,
|
|
336
|
-
toolSpecificData
|
|
409
|
+
toolSpecificData
|
|
337
410
|
};
|
|
338
411
|
}
|
|
339
412
|
const commandLine = rewrittenCommand ?? args.command;
|
|
340
413
|
const isEligibleForAutoApproval = () => {
|
|
341
414
|
const config = this._configurationService.getValue(ChatConfiguration.EligibleForAutoApproval);
|
|
342
|
-
if (config && typeof config ===
|
|
415
|
+
if (config && typeof config === "object") {
|
|
343
416
|
if (Object.prototype.hasOwnProperty.call(config, TOOL_REFERENCE_NAME)) {
|
|
344
417
|
return config[TOOL_REFERENCE_NAME];
|
|
345
418
|
}
|
|
@@ -352,7 +425,11 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
352
425
|
return true;
|
|
353
426
|
};
|
|
354
427
|
const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;
|
|
355
|
-
const isAutoApproveWarningAccepted = this._storageService.getBoolean(
|
|
428
|
+
const isAutoApproveWarningAccepted = this._storageService.getBoolean(
|
|
429
|
+
TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted,
|
|
430
|
+
StorageScope.APPLICATION,
|
|
431
|
+
false
|
|
432
|
+
);
|
|
356
433
|
const isAutoApproveAllowed = isEligibleForAutoApproval() && isAutoApproveEnabled && isAutoApproveWarningAccepted;
|
|
357
434
|
const commandLineAnalyzerOptions = {
|
|
358
435
|
commandLine,
|
|
@@ -361,90 +438,175 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
361
438
|
shell,
|
|
362
439
|
treeSitterLanguage: isPowerShell(shell, os) ? TreeSitterCommandParserLanguage.PowerShell : TreeSitterCommandParserLanguage.Bash,
|
|
363
440
|
terminalToolSessionId,
|
|
364
|
-
|
|
441
|
+
chatSessionResource
|
|
365
442
|
};
|
|
366
443
|
const commandLineAnalyzerResults = await Promise.all(( this._commandLineAnalyzers.map(e => e.analyze(commandLineAnalyzerOptions))));
|
|
367
444
|
const disclaimersRaw = ( commandLineAnalyzerResults.map(e => e.disclaimers)).filter(e => !!e).flatMap(e => e);
|
|
368
445
|
let disclaimer;
|
|
369
446
|
if (disclaimersRaw.length > 0) {
|
|
370
|
-
const disclaimerTexts = ( disclaimersRaw.map(d => typeof d ===
|
|
371
|
-
const hasMarkdownDisclaimer = ( disclaimersRaw.some(d => typeof d !==
|
|
372
|
-
const mdOptions = hasMarkdownDisclaimer
|
|
373
|
-
|
|
374
|
-
: {
|
|
375
|
-
|
|
447
|
+
const disclaimerTexts = ( disclaimersRaw.map(d => typeof d === "string" ? d : d.value));
|
|
448
|
+
const hasMarkdownDisclaimer = ( disclaimersRaw.some(d => typeof d !== "string"));
|
|
449
|
+
const mdOptions = hasMarkdownDisclaimer ? {
|
|
450
|
+
supportThemeIcons: true,
|
|
451
|
+
isTrusted: {
|
|
452
|
+
enabledCommands: [TerminalChatCommandId.OpenTerminalSettingsLink]
|
|
453
|
+
}
|
|
454
|
+
} : {
|
|
455
|
+
supportThemeIcons: true
|
|
456
|
+
};
|
|
457
|
+
disclaimer = ( new MarkdownString(`$(${Codicon.info.id}) ` + disclaimerTexts.join(" "), mdOptions));
|
|
376
458
|
}
|
|
377
459
|
const analyzersIsAutoApproveAllowed = commandLineAnalyzerResults.every(e => e.isAutoApproveAllowed);
|
|
378
460
|
const customActions = isEligibleForAutoApproval() && analyzersIsAutoApproveAllowed ? ( commandLineAnalyzerResults.map(e => e.customActions ?? [])).flat() : undefined;
|
|
379
|
-
let shellType = basename(shell,
|
|
380
|
-
if (shellType ===
|
|
381
|
-
shellType =
|
|
461
|
+
let shellType = basename(shell, ".exe");
|
|
462
|
+
if (shellType === "powershell") {
|
|
463
|
+
shellType = "pwsh";
|
|
382
464
|
}
|
|
383
|
-
const wouldBeAutoApproved =
|
|
465
|
+
const wouldBeAutoApproved =
|
|
384
466
|
(( commandLineAnalyzerResults.some(e => e.isAutoApproved)) &&
|
|
385
|
-
|
|
386
|
-
analyzersIsAutoApproveAllowed)
|
|
387
|
-
const isFinalAutoApproved =
|
|
467
|
+
commandLineAnalyzerResults.every(e => e.isAutoApproved !== false) &&
|
|
468
|
+
analyzersIsAutoApproveAllowed);
|
|
469
|
+
const isFinalAutoApproved =
|
|
388
470
|
(isAutoApproveAllowed &&
|
|
389
|
-
wouldBeAutoApproved));
|
|
471
|
+
wouldBeAutoApproved) || ( commandLineAnalyzerResults.some(e => e.forceAutoApproval));
|
|
390
472
|
if (isFinalAutoApproved || (isAutoApproveEnabled && ( commandLineAnalyzerResults.some(e => e.autoApproveInfo)))) {
|
|
391
473
|
toolSpecificData.autoApproveInfo = commandLineAnalyzerResults.find(e => e.autoApproveInfo)?.autoApproveInfo;
|
|
392
474
|
}
|
|
475
|
+
const commandToDisplay = (toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original).trimStart();
|
|
476
|
+
const extractedCd = extractCdPrefix(commandToDisplay, shell, os);
|
|
477
|
+
let confirmationTitle;
|
|
478
|
+
if (extractedCd && cwd) {
|
|
479
|
+
const isAbsolutePath = os === OperatingSystem.Windows ? win32.isAbsolute(extractedCd.directory) : posix.isAbsolute(extractedCd.directory);
|
|
480
|
+
const directoryUri = isAbsolutePath ? ( URI.from({
|
|
481
|
+
scheme: cwd.scheme,
|
|
482
|
+
authority: cwd.authority,
|
|
483
|
+
path: extractedCd.directory
|
|
484
|
+
})) : URI.joinPath(cwd, extractedCd.directory);
|
|
485
|
+
const directoryLabel = this._labelService.getUriLabel(directoryUri);
|
|
486
|
+
const cdPrefix = commandToDisplay.substring(0, commandToDisplay.length - extractedCd.command.length);
|
|
487
|
+
toolSpecificData.confirmation = {
|
|
488
|
+
commandLine: extractedCd.command,
|
|
489
|
+
cwdLabel: directoryLabel,
|
|
490
|
+
cdPrefix
|
|
491
|
+
};
|
|
492
|
+
confirmationTitle = args.isBackground ? ( localize(
|
|
493
|
+
12395,
|
|
494
|
+
"Run `{0}` command in background within `{1}`?",
|
|
495
|
+
shellType,
|
|
496
|
+
directoryLabel
|
|
497
|
+
)) : ( localize(12396, "Run `{0}` command within `{1}`?", shellType, directoryLabel));
|
|
498
|
+
} else {
|
|
499
|
+
toolSpecificData.confirmation = {
|
|
500
|
+
commandLine: commandToDisplay
|
|
501
|
+
};
|
|
502
|
+
confirmationTitle = args.isBackground ? ( localize(12397, "Run `{0}` command in background?", shellType)) : ( localize(12398, "Run `{0}` command?", shellType));
|
|
503
|
+
}
|
|
504
|
+
const commandForPresenter = extractedCd?.command ?? commandToDisplay;
|
|
505
|
+
let presenterInput = commandForPresenter;
|
|
506
|
+
for (const presenter of this._commandLinePresenters) {
|
|
507
|
+
const presenterResult = await presenter.present({
|
|
508
|
+
commandLine: {
|
|
509
|
+
original: args.command,
|
|
510
|
+
forDisplay: presenterInput
|
|
511
|
+
},
|
|
512
|
+
shell,
|
|
513
|
+
os
|
|
514
|
+
});
|
|
515
|
+
if (presenterResult) {
|
|
516
|
+
toolSpecificData.presentationOverrides = {
|
|
517
|
+
commandLine: presenterResult.commandLine,
|
|
518
|
+
language: presenterResult.language ?? undefined
|
|
519
|
+
};
|
|
520
|
+
if (extractedCd && toolSpecificData.confirmation?.cwdLabel) {
|
|
521
|
+
confirmationTitle = args.isBackground ? ( localize(
|
|
522
|
+
12399,
|
|
523
|
+
"Run `{0}` command in `{1}` in background within `{2}`?",
|
|
524
|
+
presenterResult.languageDisplayName,
|
|
525
|
+
shellType,
|
|
526
|
+
toolSpecificData.confirmation.cwdLabel
|
|
527
|
+
)) : ( localize(
|
|
528
|
+
12400,
|
|
529
|
+
"Run `{0}` command in `{1}` within `{2}`?",
|
|
530
|
+
presenterResult.languageDisplayName,
|
|
531
|
+
shellType,
|
|
532
|
+
toolSpecificData.confirmation.cwdLabel
|
|
533
|
+
));
|
|
534
|
+
} else {
|
|
535
|
+
confirmationTitle = args.isBackground ? ( localize(
|
|
536
|
+
12401,
|
|
537
|
+
"Run `{0}` command in `{1}` in background?",
|
|
538
|
+
presenterResult.languageDisplayName,
|
|
539
|
+
shellType
|
|
540
|
+
)) : ( localize(
|
|
541
|
+
12402,
|
|
542
|
+
"Run `{0}` command in `{1}`?",
|
|
543
|
+
presenterResult.languageDisplayName,
|
|
544
|
+
shellType
|
|
545
|
+
));
|
|
546
|
+
}
|
|
547
|
+
if (!presenterResult.processOtherPresenters) {
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
presenterInput = presenterResult.commandLine;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
393
553
|
const confirmationMessages = isFinalAutoApproved ? undefined : {
|
|
394
|
-
title:
|
|
395
|
-
|
|
396
|
-
: ( localize(12062, "Run `{0}` command?", shellType)),
|
|
397
|
-
message: ( new MarkdownString(args.explanation)),
|
|
554
|
+
title: confirmationTitle,
|
|
555
|
+
message: ( new MarkdownString(( localize(12403, "Explanation: {0}\n\nGoal: {1}", args.explanation, args.goal)))),
|
|
398
556
|
disclaimer,
|
|
399
|
-
terminalCustomActions: customActions
|
|
557
|
+
terminalCustomActions: customActions
|
|
400
558
|
};
|
|
401
559
|
return {
|
|
402
560
|
confirmationMessages,
|
|
403
|
-
toolSpecificData
|
|
561
|
+
toolSpecificData
|
|
404
562
|
};
|
|
405
563
|
}
|
|
406
564
|
async invoke(invocation, _countTokens, _progress, token) {
|
|
407
565
|
const toolSpecificData = invocation.toolSpecificData;
|
|
408
566
|
if (!toolSpecificData) {
|
|
409
|
-
throw ( new Error(
|
|
567
|
+
throw ( new Error("toolSpecificData must be provided for this tool"));
|
|
410
568
|
}
|
|
411
569
|
const commandId = toolSpecificData.terminalCommandId;
|
|
412
570
|
if (toolSpecificData.alternativeRecommendation) {
|
|
413
571
|
return {
|
|
414
572
|
content: [{
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
573
|
+
kind: "text",
|
|
574
|
+
value: toolSpecificData.alternativeRecommendation
|
|
575
|
+
}]
|
|
418
576
|
};
|
|
419
577
|
}
|
|
420
578
|
const args = invocation.parameters;
|
|
421
579
|
this._logService.debug(`RunInTerminalTool: Invoking with options ${JSON.stringify(args)}`);
|
|
422
580
|
let toolResultMessage;
|
|
423
|
-
const
|
|
581
|
+
const chatSessionResource = invocation.context?.sessionResource ?? LocalChatSessionUri.forSession(invocation.context?.sessionId ?? "no-chat-session");
|
|
582
|
+
const chatSessionId = chatSessionResourceToId(chatSessionResource);
|
|
424
583
|
const command = toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original;
|
|
425
|
-
const didUserEditCommand = (toolSpecificData.commandLine.userEdited !== undefined &&
|
|
426
|
-
|
|
427
|
-
const didToolEditCommand = (!didUserEditCommand &&
|
|
428
|
-
toolSpecificData.commandLine.toolEdited !== undefined &&
|
|
429
|
-
toolSpecificData.commandLine.toolEdited !== toolSpecificData.commandLine.original);
|
|
584
|
+
const didUserEditCommand = (toolSpecificData.commandLine.userEdited !== undefined && toolSpecificData.commandLine.userEdited !== toolSpecificData.commandLine.original);
|
|
585
|
+
const didToolEditCommand = (!didUserEditCommand && toolSpecificData.commandLine.toolEdited !== undefined && toolSpecificData.commandLine.toolEdited !== toolSpecificData.commandLine.original);
|
|
430
586
|
if (token.isCancellationRequested) {
|
|
431
587
|
throw ( new CancellationError());
|
|
432
588
|
}
|
|
433
589
|
let error;
|
|
434
|
-
const isNewSession = !args.isBackground && !( this._sessionTerminalAssociations.has(
|
|
590
|
+
const isNewSession = !args.isBackground && !( this._sessionTerminalAssociations.has(chatSessionResource));
|
|
435
591
|
const timingStart = Date.now();
|
|
436
592
|
const termId = generateUuid();
|
|
437
593
|
const terminalToolSessionId = toolSpecificData.terminalToolSessionId;
|
|
438
594
|
const store = ( new DisposableStore());
|
|
439
|
-
this._logService.debug(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
595
|
+
this._logService.debug(
|
|
596
|
+
`RunInTerminalTool: Creating ${args.isBackground ? "background" : "foreground"} terminal. termId=${termId}, chatSessionId=${chatSessionId}`
|
|
597
|
+
);
|
|
598
|
+
const toolTerminal = await this._initTerminal(
|
|
599
|
+
chatSessionResource,
|
|
600
|
+
termId,
|
|
601
|
+
terminalToolSessionId,
|
|
602
|
+
args.isBackground,
|
|
603
|
+
token
|
|
604
|
+
);
|
|
605
|
+
this._handleTerminalVisibility(toolTerminal, chatSessionResource);
|
|
444
606
|
const timingConnectMs = Date.now() - timingStart;
|
|
445
607
|
const xterm = await toolTerminal.instance.xtermReadyPromise;
|
|
446
608
|
if (!xterm) {
|
|
447
|
-
throw ( new Error(
|
|
609
|
+
throw ( new Error("Instance was disposed before xterm.js was ready"));
|
|
448
610
|
}
|
|
449
611
|
const commandDetection = toolTerminal.instance.capabilities.get(TerminalCapability.CommandDetection);
|
|
450
612
|
let inputUserChars = 0;
|
|
@@ -453,34 +615,94 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
453
615
|
if (!telemetryIgnoredSequences.includes(data)) {
|
|
454
616
|
inputUserChars += data.length;
|
|
455
617
|
}
|
|
456
|
-
inputUserSigint ||= data ===
|
|
618
|
+
inputUserSigint ||= data === "\u0003";
|
|
457
619
|
}));
|
|
620
|
+
let terminalResult = "";
|
|
621
|
+
let outputLineCount = -1;
|
|
622
|
+
let exitCode;
|
|
623
|
+
let altBufferResult;
|
|
624
|
+
let didTimeout = false;
|
|
625
|
+
let didMoveToBackground = args.isBackground;
|
|
626
|
+
let timeoutPromise;
|
|
458
627
|
let outputMonitor;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
628
|
+
let pollingResult;
|
|
629
|
+
const executeCancellation = store.add(( new CancellationTokenSource(token)));
|
|
630
|
+
const timeoutValue = args.timeout !== undefined ? clamp(args.timeout, 0, Number.MAX_SAFE_INTEGER) : undefined;
|
|
631
|
+
if (!args.isBackground && timeoutValue !== undefined && timeoutValue > 0) {
|
|
632
|
+
const shouldEnforceTimeout = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnforceTimeoutFromModel) === true;
|
|
633
|
+
if (shouldEnforceTimeout) {
|
|
634
|
+
timeoutPromise = timeout(timeoutValue);
|
|
635
|
+
timeoutPromise.then(() => {
|
|
636
|
+
if (!executeCancellation.token.isCancellationRequested) {
|
|
637
|
+
didTimeout = true;
|
|
638
|
+
executeCancellation.cancel();
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
let continueInBackgroundResolve;
|
|
644
|
+
const continueInBackgroundPromise = ( new Promise(resolve => {
|
|
645
|
+
continueInBackgroundResolve = resolve;
|
|
646
|
+
}));
|
|
647
|
+
if (terminalToolSessionId) {
|
|
648
|
+
store.add(this._terminalChatService.onDidContinueInBackground(sessionId => {
|
|
649
|
+
if (sessionId === terminalToolSessionId) {
|
|
650
|
+
const execution = RunInTerminalTool_1._activeExecutions.get(termId);
|
|
651
|
+
if (execution) {
|
|
652
|
+
execution.setBackground();
|
|
653
|
+
}
|
|
654
|
+
didMoveToBackground = true;
|
|
655
|
+
continueInBackgroundResolve?.();
|
|
656
|
+
}
|
|
657
|
+
}));
|
|
658
|
+
}
|
|
659
|
+
let executionPromise;
|
|
660
|
+
try {
|
|
661
|
+
const execution = this._instantiationService.createInstance(
|
|
662
|
+
ActiveTerminalExecution,
|
|
663
|
+
chatSessionId,
|
|
664
|
+
termId,
|
|
665
|
+
toolTerminal,
|
|
666
|
+
commandDetection,
|
|
667
|
+
args.isBackground
|
|
668
|
+
);
|
|
669
|
+
if (toolTerminal.shellIntegrationQuality === ShellIntegrationQuality.None) {
|
|
670
|
+
toolResultMessage = "$(info) Enable [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) to improve command detection";
|
|
671
|
+
}
|
|
672
|
+
this._logService.debug(
|
|
673
|
+
`RunInTerminalTool: Using \`${execution.strategy.type}\` execute strategy for command \`${command}\``
|
|
674
|
+
);
|
|
675
|
+
store.add(execution);
|
|
676
|
+
RunInTerminalTool_1._activeExecutions.set(termId, execution);
|
|
677
|
+
const startMarkerPromise = Event.toPromise(execution.strategy.onDidCreateStartMarker);
|
|
678
|
+
store.add(execution.strategy.onDidCreateStartMarker(startMarker => {
|
|
679
|
+
if (!outputMonitor) {
|
|
680
|
+
outputMonitor = store.add(this._instantiationService.createInstance(OutputMonitor, {
|
|
681
|
+
instance: toolTerminal.instance,
|
|
682
|
+
sessionId: invocation.context?.sessionId,
|
|
683
|
+
getOutput: marker => execution.getOutput(marker ?? startMarker)
|
|
684
|
+
}, undefined, invocation.context, token, command));
|
|
685
|
+
}
|
|
686
|
+
}));
|
|
687
|
+
executionPromise = execution.start(command, executeCancellation.token, commandId);
|
|
688
|
+
if (args.isBackground) {
|
|
462
689
|
this._logService.debug(`RunInTerminalTool: Starting background execution \`${command}\``);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
690
|
+
await startMarkerPromise;
|
|
691
|
+
if (outputMonitor) {
|
|
692
|
+
await Event.toPromise(outputMonitor.onDidFinishCommand);
|
|
693
|
+
pollingResult = outputMonitor.pollingResult;
|
|
694
|
+
}
|
|
695
|
+
await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
|
|
468
696
|
if (token.isCancellationRequested) {
|
|
469
697
|
throw ( new CancellationError());
|
|
470
698
|
}
|
|
471
|
-
await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
|
|
472
699
|
const state = toolSpecificData.terminalCommandState ?? {};
|
|
473
700
|
state.timestamp = state.timestamp ?? timingStart;
|
|
474
701
|
toolSpecificData.terminalCommandState = state;
|
|
475
|
-
let resultText = (didUserEditCommand
|
|
476
|
-
? `Note: The user manually edited the command to \`${command}\`, and that command is now running in terminal with ID=${termId}`
|
|
477
|
-
: didToolEditCommand
|
|
478
|
-
? `Note: The tool simplified the command to \`${command}\`, and that command is now running in terminal with ID=${termId}`
|
|
479
|
-
: `Command is running in terminal with ID=${termId}`);
|
|
702
|
+
let resultText = (didUserEditCommand ? `Note: The user manually edited the command to \`${command}\`, and that command is now running in terminal with ID=${termId}` : didToolEditCommand ? `Note: The tool simplified the command to \`${command}\`, and that command is now running in terminal with ID=${termId}` : `Command is running in terminal with ID=${termId}`);
|
|
480
703
|
if (pollingResult && pollingResult.modelOutputEvalResponse) {
|
|
481
704
|
resultText += `\n\ The command became idle with output:\n${pollingResult.modelOutputEvalResponse}`;
|
|
482
|
-
}
|
|
483
|
-
else if (pollingResult) {
|
|
705
|
+
} else if (pollingResult) {
|
|
484
706
|
resultText += `\n\ The command is still running, with output:\n${pollingResult.output}`;
|
|
485
707
|
}
|
|
486
708
|
return {
|
|
@@ -488,230 +710,211 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
488
710
|
exitCode: undefined
|
|
489
711
|
},
|
|
490
712
|
content: [{
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
713
|
+
kind: "text",
|
|
714
|
+
value: resultText
|
|
715
|
+
}]
|
|
494
716
|
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
exitCode: undefined,
|
|
516
|
-
isNewSession: true,
|
|
517
|
-
timingExecuteMs,
|
|
518
|
-
timingConnectMs,
|
|
519
|
-
terminalExecutionIdleBeforeTimeout: pollingResult?.state === OutputMonitorState.Idle,
|
|
520
|
-
outputLineCount: 0,
|
|
521
|
-
pollDurationMs: pollingResult?.pollDurationMs,
|
|
522
|
-
inputUserChars,
|
|
523
|
-
inputUserSigint,
|
|
524
|
-
inputToolManualAcceptCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolManualAcceptCount,
|
|
525
|
-
inputToolManualRejectCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolManualRejectCount,
|
|
526
|
-
inputToolManualChars: outputMonitor?.outputMonitorTelemetryCounters.inputToolManualChars,
|
|
527
|
-
inputToolAutoAcceptCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolAutoAcceptCount,
|
|
528
|
-
inputToolAutoChars: outputMonitor?.outputMonitorTelemetryCounters.inputToolAutoChars,
|
|
529
|
-
inputToolManualShownCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolManualShownCount,
|
|
530
|
-
inputToolFreeFormInputCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolFreeFormInputCount,
|
|
531
|
-
inputToolFreeFormInputShownCount: outputMonitor?.outputMonitorTelemetryCounters.inputToolFreeFormInputShownCount
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
let terminalResult = '';
|
|
537
|
-
let outputLineCount = -1;
|
|
538
|
-
let exitCode;
|
|
539
|
-
let altBufferResult;
|
|
540
|
-
const executeCancellation = store.add(( new CancellationTokenSource(token)));
|
|
541
|
-
try {
|
|
542
|
-
let strategy;
|
|
543
|
-
switch (toolTerminal.shellIntegrationQuality) {
|
|
544
|
-
case ShellIntegrationQuality.None: {
|
|
545
|
-
strategy = this._instantiationService.createInstance(NoneExecuteStrategy, toolTerminal.instance, () => toolTerminal.receivedUserInput ?? false);
|
|
546
|
-
toolResultMessage = '$(info) Enable [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) to improve command detection';
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
case ShellIntegrationQuality.Basic: {
|
|
550
|
-
strategy = this._instantiationService.createInstance(BasicExecuteStrategy, toolTerminal.instance, () => toolTerminal.receivedUserInput ?? false, commandDetection);
|
|
551
|
-
break;
|
|
717
|
+
} else {
|
|
718
|
+
const raceResult = await Promise.race([executionPromise.then(result => ({
|
|
719
|
+
type: "completed",
|
|
720
|
+
result
|
|
721
|
+
})), continueInBackgroundPromise.then(() => ({
|
|
722
|
+
type: "background"
|
|
723
|
+
}))]);
|
|
724
|
+
if (raceResult.type === "background") {
|
|
725
|
+
this._logService.debug(
|
|
726
|
+
`RunInTerminalTool: Continue in background triggered, returning output collected so far`
|
|
727
|
+
);
|
|
728
|
+
error = "continueInBackground";
|
|
729
|
+
const backgroundOutput = execution.getOutput();
|
|
730
|
+
outputLineCount = backgroundOutput ? count(backgroundOutput.trim(), "\n") + 1 : 0;
|
|
731
|
+
terminalResult = backgroundOutput;
|
|
732
|
+
} else {
|
|
733
|
+
const executeResult = raceResult.result;
|
|
734
|
+
toolTerminal.receivedUserInput = false;
|
|
735
|
+
if (token.isCancellationRequested) {
|
|
736
|
+
throw ( new CancellationError());
|
|
552
737
|
}
|
|
553
|
-
|
|
554
|
-
strategy = this._instantiationService.createInstance(RichExecuteStrategy, toolTerminal.instance, commandDetection);
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
this._logService.debug(`RunInTerminalTool: Using \`${strategy.type}\` execute strategy for command \`${command}\``);
|
|
559
|
-
store.add(strategy.onDidCreateStartMarker(startMarker => {
|
|
560
|
-
if (!outputMonitor) {
|
|
561
|
-
outputMonitor = store.add(this._instantiationService.createInstance(OutputMonitor, { instance: toolTerminal.instance, sessionId: invocation.context?.sessionId, getOutput: (marker) => getOutput(toolTerminal.instance, marker ?? startMarker) }, undefined, invocation.context, token, command));
|
|
562
|
-
}
|
|
563
|
-
}));
|
|
564
|
-
const executeResult = await strategy.execute(command, executeCancellation.token, commandId);
|
|
565
|
-
toolTerminal.receivedUserInput = false;
|
|
566
|
-
if (token.isCancellationRequested) {
|
|
567
|
-
throw ( new CancellationError());
|
|
568
|
-
}
|
|
569
|
-
if (executeResult.didEnterAltBuffer) {
|
|
570
|
-
const state = toolSpecificData.terminalCommandState ?? {};
|
|
571
|
-
state.timestamp = state.timestamp ?? timingStart;
|
|
572
|
-
toolSpecificData.terminalCommandState = state;
|
|
573
|
-
toolResultMessage = altBufferMessage;
|
|
574
|
-
outputLineCount = 0;
|
|
575
|
-
error = executeResult.error ?? 'alternateBuffer';
|
|
576
|
-
altBufferResult = {
|
|
577
|
-
toolResultMessage,
|
|
578
|
-
toolMetadata: {
|
|
579
|
-
exitCode: undefined
|
|
580
|
-
},
|
|
581
|
-
content: [{
|
|
582
|
-
kind: 'text',
|
|
583
|
-
value: altBufferMessage,
|
|
584
|
-
}]
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
|
|
589
|
-
{
|
|
738
|
+
if (executeResult.didEnterAltBuffer) {
|
|
590
739
|
const state = toolSpecificData.terminalCommandState ?? {};
|
|
591
740
|
state.timestamp = state.timestamp ?? timingStart;
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
741
|
+
toolSpecificData.terminalCommandState = state;
|
|
742
|
+
toolResultMessage = altBufferMessage;
|
|
743
|
+
outputLineCount = 0;
|
|
744
|
+
error = executeResult.error ?? "alternateBuffer";
|
|
745
|
+
altBufferResult = {
|
|
746
|
+
toolResultMessage,
|
|
747
|
+
toolMetadata: {
|
|
748
|
+
exitCode: undefined
|
|
749
|
+
},
|
|
750
|
+
content: [{
|
|
751
|
+
kind: "text",
|
|
752
|
+
value: altBufferMessage
|
|
753
|
+
}]
|
|
754
|
+
};
|
|
755
|
+
} else {
|
|
756
|
+
await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
|
|
757
|
+
{
|
|
758
|
+
const state = toolSpecificData.terminalCommandState ?? {};
|
|
759
|
+
state.timestamp = state.timestamp ?? timingStart;
|
|
760
|
+
if (executeResult.exitCode !== undefined) {
|
|
761
|
+
state.exitCode = executeResult.exitCode;
|
|
762
|
+
if (state.timestamp !== undefined) {
|
|
763
|
+
state.duration = state.duration ?? Math.max(0, Date.now() - state.timestamp);
|
|
764
|
+
}
|
|
596
765
|
}
|
|
766
|
+
toolSpecificData.terminalCommandState = state;
|
|
597
767
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
768
|
+
this._logService.debug(
|
|
769
|
+
`RunInTerminalTool: Finished \`${execution.strategy.type}\` execute strategy with exitCode \`${executeResult.exitCode}\`, result.length \`${executeResult.output?.length}\`, error \`${executeResult.error}\``
|
|
770
|
+
);
|
|
771
|
+
outputLineCount = executeResult.output === undefined ? 0 : count(executeResult.output.trim(), "\n") + 1;
|
|
772
|
+
exitCode = executeResult.exitCode;
|
|
773
|
+
error = executeResult.error;
|
|
774
|
+
const resultArr = [];
|
|
775
|
+
if (executeResult.output !== undefined) {
|
|
776
|
+
resultArr.push(executeResult.output);
|
|
777
|
+
}
|
|
778
|
+
if (executeResult.additionalInformation) {
|
|
779
|
+
resultArr.push(executeResult.additionalInformation);
|
|
780
|
+
}
|
|
781
|
+
terminalResult = resultArr.join("\n\n");
|
|
610
782
|
}
|
|
611
|
-
terminalResult = resultArr.join('\n\n');
|
|
612
783
|
}
|
|
613
784
|
}
|
|
614
|
-
|
|
785
|
+
} catch (e) {
|
|
786
|
+
if (didTimeout && e instanceof CancellationError) {
|
|
787
|
+
this._logService.debug(`RunInTerminalTool: Timeout reached, returning output collected so far`);
|
|
788
|
+
error = "timeout";
|
|
789
|
+
const timeoutOutput = getOutput(toolTerminal.instance, undefined);
|
|
790
|
+
outputLineCount = timeoutOutput ? count(timeoutOutput.trim(), "\n") + 1 : 0;
|
|
791
|
+
terminalResult = timeoutOutput ?? "";
|
|
792
|
+
} else {
|
|
615
793
|
this._logService.debug(`RunInTerminalTool: Threw exception`);
|
|
794
|
+
if (e instanceof CancellationError) {
|
|
795
|
+
await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
|
|
796
|
+
}
|
|
797
|
+
RunInTerminalTool_1._activeExecutions.get(termId)?.dispose();
|
|
798
|
+
RunInTerminalTool_1._activeExecutions.delete(termId);
|
|
616
799
|
toolTerminal.instance.dispose();
|
|
617
|
-
error = e instanceof CancellationError ?
|
|
800
|
+
error = e instanceof CancellationError ? "canceled" : "unexpectedException";
|
|
618
801
|
throw e;
|
|
619
802
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
isBackground: false,
|
|
628
|
-
shellIntegrationQuality: toolTerminal.shellIntegrationQuality,
|
|
629
|
-
error,
|
|
630
|
-
isNewSession,
|
|
631
|
-
outputLineCount,
|
|
632
|
-
exitCode,
|
|
633
|
-
timingExecuteMs,
|
|
634
|
-
timingConnectMs,
|
|
635
|
-
inputUserChars,
|
|
636
|
-
inputUserSigint,
|
|
637
|
-
terminalExecutionIdleBeforeTimeout: undefined,
|
|
638
|
-
pollDurationMs: undefined,
|
|
639
|
-
inputToolManualAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualAcceptCount,
|
|
640
|
-
inputToolManualRejectCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualRejectCount,
|
|
641
|
-
inputToolManualChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualChars,
|
|
642
|
-
inputToolAutoAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoAcceptCount,
|
|
643
|
-
inputToolAutoChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoChars,
|
|
644
|
-
inputToolManualShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualShownCount,
|
|
645
|
-
inputToolFreeFormInputCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputCount,
|
|
646
|
-
inputToolFreeFormInputShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputShownCount
|
|
803
|
+
} finally {
|
|
804
|
+
timeoutPromise?.cancel();
|
|
805
|
+
if (didMoveToBackground && executionPromise) {
|
|
806
|
+
executionPromise.catch(e => {
|
|
807
|
+
if (!(e instanceof CancellationError)) {
|
|
808
|
+
this._logService.error(`RunInTerminalTool: Background execution error`, e);
|
|
809
|
+
}
|
|
647
810
|
});
|
|
811
|
+
} else {
|
|
812
|
+
RunInTerminalTool_1._activeExecutions.get(termId)?.dispose();
|
|
813
|
+
RunInTerminalTool_1._activeExecutions.delete(termId);
|
|
648
814
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
815
|
+
store.dispose();
|
|
816
|
+
const timingExecuteMs = Date.now() - timingStart;
|
|
817
|
+
this._telemetry.logInvoke(toolTerminal.instance, {
|
|
818
|
+
terminalToolSessionId: toolSpecificData.terminalToolSessionId,
|
|
819
|
+
didUserEditCommand,
|
|
820
|
+
didToolEditCommand,
|
|
821
|
+
isBackground: args.isBackground,
|
|
822
|
+
shellIntegrationQuality: toolTerminal.shellIntegrationQuality,
|
|
823
|
+
error,
|
|
824
|
+
isNewSession,
|
|
825
|
+
outputLineCount,
|
|
826
|
+
exitCode,
|
|
827
|
+
timingExecuteMs,
|
|
828
|
+
timingConnectMs,
|
|
829
|
+
inputUserChars,
|
|
830
|
+
inputUserSigint,
|
|
831
|
+
terminalExecutionIdleBeforeTimeout: pollingResult?.state === OutputMonitorState.Idle,
|
|
832
|
+
pollDurationMs: pollingResult?.pollDurationMs,
|
|
833
|
+
inputToolManualAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualAcceptCount,
|
|
834
|
+
inputToolManualRejectCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualRejectCount,
|
|
835
|
+
inputToolManualChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualChars,
|
|
836
|
+
inputToolAutoAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoAcceptCount,
|
|
837
|
+
inputToolAutoChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoChars,
|
|
838
|
+
inputToolManualShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualShownCount,
|
|
839
|
+
inputToolFreeFormInputCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputCount,
|
|
840
|
+
inputToolFreeFormInputShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputShownCount
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
if (altBufferResult) {
|
|
844
|
+
return altBufferResult;
|
|
845
|
+
}
|
|
846
|
+
const resultText = [];
|
|
847
|
+
if (didUserEditCommand) {
|
|
848
|
+
resultText.push(
|
|
849
|
+
`Note: The user manually edited the command to \`${command}\`, and this is the output of running that command instead:\n`
|
|
850
|
+
);
|
|
851
|
+
} else if (didToolEditCommand) {
|
|
852
|
+
resultText.push(
|
|
853
|
+
`Note: The tool simplified the command to \`${command}\`, and this is the output of running that command instead:\n`
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
if (didMoveToBackground && !args.isBackground) {
|
|
857
|
+
resultText.push(
|
|
858
|
+
`Note: This terminal execution was moved to the background using the ID ${termId}\n`
|
|
859
|
+
);
|
|
670
860
|
}
|
|
861
|
+
resultText.push(terminalResult);
|
|
862
|
+
const isError = exitCode !== undefined && exitCode !== 0;
|
|
863
|
+
return {
|
|
864
|
+
toolResultMessage,
|
|
865
|
+
toolMetadata: {
|
|
866
|
+
exitCode: exitCode
|
|
867
|
+
},
|
|
868
|
+
toolResultDetails: isError ? {
|
|
869
|
+
input: command,
|
|
870
|
+
output: [{
|
|
871
|
+
type: "embed",
|
|
872
|
+
isText: true,
|
|
873
|
+
value: terminalResult
|
|
874
|
+
}],
|
|
875
|
+
isError: true
|
|
876
|
+
} : undefined,
|
|
877
|
+
content: [{
|
|
878
|
+
kind: "text",
|
|
879
|
+
value: resultText.join("")
|
|
880
|
+
}]
|
|
881
|
+
};
|
|
671
882
|
}
|
|
672
|
-
_handleTerminalVisibility(toolTerminal,
|
|
673
|
-
const chatSessionOpenInWidget = !!this._chatWidgetService.getWidgetBySessionResource(
|
|
674
|
-
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.OutputLocation) ===
|
|
883
|
+
_handleTerminalVisibility(toolTerminal, chatSessionResource) {
|
|
884
|
+
const chatSessionOpenInWidget = !!this._chatWidgetService.getWidgetBySessionResource(chatSessionResource);
|
|
885
|
+
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.OutputLocation) === "terminal" && chatSessionOpenInWidget) {
|
|
675
886
|
this._terminalService.setActiveInstance(toolTerminal.instance);
|
|
676
887
|
this._terminalService.revealTerminal(toolTerminal.instance, true);
|
|
677
888
|
}
|
|
678
889
|
}
|
|
679
|
-
async
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
throw ( new CancellationError());
|
|
691
|
-
}
|
|
692
|
-
await this._setupProcessIdAssociation(toolTerminal, chatSessionId, termId, true);
|
|
693
|
-
return toolTerminal;
|
|
694
|
-
}
|
|
695
|
-
async _initForegroundTerminal(chatSessionId, termId, terminalToolSessionId, token) {
|
|
696
|
-
const cachedTerminal = this._sessionTerminalAssociations.get(chatSessionId);
|
|
697
|
-
if (cachedTerminal) {
|
|
698
|
-
this._logService.debug(`RunInTerminalTool: Using cached foreground terminal with session ID \`${chatSessionId}\``);
|
|
699
|
-
this._terminalToolCreator.refreshShellIntegrationQuality(cachedTerminal);
|
|
700
|
-
this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, cachedTerminal.instance);
|
|
701
|
-
return cachedTerminal;
|
|
890
|
+
async _initTerminal(chatSessionResource, termId, terminalToolSessionId, isBackground, token) {
|
|
891
|
+
if (!isBackground) {
|
|
892
|
+
const cachedTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
|
|
893
|
+
if (cachedTerminal && !cachedTerminal.isBackground) {
|
|
894
|
+
this._logService.debug(
|
|
895
|
+
`RunInTerminalTool: Using cached terminal with session resource \`${chatSessionResource}\``
|
|
896
|
+
);
|
|
897
|
+
this._terminalToolCreator.refreshShellIntegrationQuality(cachedTerminal);
|
|
898
|
+
this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, cachedTerminal.instance);
|
|
899
|
+
return cachedTerminal;
|
|
900
|
+
}
|
|
702
901
|
}
|
|
902
|
+
this._logService.debug(
|
|
903
|
+
`RunInTerminalTool: Creating ${isBackground ? "background" : "foreground"} terminal with ID=${termId}`
|
|
904
|
+
);
|
|
703
905
|
const profile = await this._profileFetcher.getCopilotProfile();
|
|
704
906
|
const os = await this._osBackend;
|
|
705
907
|
const toolTerminal = await this._terminalToolCreator.createTerminal(profile, os, token);
|
|
908
|
+
toolTerminal.isBackground = isBackground;
|
|
706
909
|
this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, toolTerminal.instance);
|
|
707
|
-
this._terminalChatService.registerTerminalInstanceWithChatSession(
|
|
910
|
+
this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionResource, toolTerminal.instance);
|
|
708
911
|
this._registerInputListener(toolTerminal);
|
|
709
|
-
this._sessionTerminalAssociations.set(
|
|
912
|
+
this._sessionTerminalAssociations.set(chatSessionResource, toolTerminal);
|
|
710
913
|
if (token.isCancellationRequested) {
|
|
711
914
|
toolTerminal.instance.dispose();
|
|
712
915
|
throw ( new CancellationError());
|
|
713
916
|
}
|
|
714
|
-
await this._setupProcessIdAssociation(toolTerminal,
|
|
917
|
+
await this._setupProcessIdAssociation(toolTerminal, chatSessionResource, termId, isBackground);
|
|
715
918
|
return toolTerminal;
|
|
716
919
|
}
|
|
717
920
|
_registerInputListener(toolTerminal) {
|
|
@@ -723,48 +926,68 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
723
926
|
this._register(toolTerminal.instance.onDisposed(() => disposable.dispose()));
|
|
724
927
|
}
|
|
725
928
|
_restoreTerminalAssociations() {
|
|
726
|
-
const storedAssociations = this._storageService.get(
|
|
929
|
+
const storedAssociations = this._storageService.get(
|
|
930
|
+
TerminalToolStorageKeysInternal.TerminalSession,
|
|
931
|
+
StorageScope.WORKSPACE,
|
|
932
|
+
"{}"
|
|
933
|
+
);
|
|
727
934
|
try {
|
|
728
935
|
const associations = JSON.parse(storedAssociations);
|
|
729
936
|
for (const instance of this._terminalService.instances) {
|
|
730
937
|
if (instance.processId) {
|
|
731
938
|
const association = associations[instance.processId];
|
|
732
939
|
if (association) {
|
|
733
|
-
|
|
940
|
+
const chatSessionResource = LocalChatSessionUri.forSession(association.sessionId);
|
|
941
|
+
this._logService.debug(
|
|
942
|
+
`RunInTerminalTool: Restored terminal association for PID ${instance.processId}, session ${association.sessionId}`
|
|
943
|
+
);
|
|
734
944
|
const toolTerminal = {
|
|
735
945
|
instance,
|
|
736
|
-
shellIntegrationQuality: association.shellIntegrationQuality
|
|
946
|
+
shellIntegrationQuality: association.shellIntegrationQuality,
|
|
947
|
+
isBackground: association.isBackground
|
|
737
948
|
};
|
|
738
|
-
this._sessionTerminalAssociations.set(
|
|
739
|
-
this._terminalChatService.registerTerminalInstanceWithChatSession(
|
|
949
|
+
this._sessionTerminalAssociations.set(chatSessionResource, toolTerminal);
|
|
950
|
+
this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionResource, instance);
|
|
740
951
|
this._register(instance.onDisposed(() => {
|
|
741
952
|
this._removeProcessIdAssociation(instance.processId);
|
|
742
953
|
}));
|
|
743
954
|
}
|
|
744
955
|
}
|
|
745
956
|
}
|
|
746
|
-
}
|
|
747
|
-
catch (error) {
|
|
957
|
+
} catch (error) {
|
|
748
958
|
this._logService.debug(`RunInTerminalTool: Failed to restore terminal associations: ${error}`);
|
|
749
959
|
}
|
|
750
960
|
}
|
|
751
|
-
async _setupProcessIdAssociation(toolTerminal,
|
|
752
|
-
await this._associateProcessIdWithSession(
|
|
961
|
+
async _setupProcessIdAssociation(toolTerminal, chatSessionResource, termId, isBackground) {
|
|
962
|
+
await this._associateProcessIdWithSession(
|
|
963
|
+
toolTerminal.instance,
|
|
964
|
+
chatSessionResource,
|
|
965
|
+
termId,
|
|
966
|
+
toolTerminal.shellIntegrationQuality,
|
|
967
|
+
isBackground
|
|
968
|
+
);
|
|
753
969
|
this._register(toolTerminal.instance.onDisposed(() => {
|
|
754
970
|
if (toolTerminal.instance.processId) {
|
|
755
971
|
this._removeProcessIdAssociation(toolTerminal.instance.processId);
|
|
756
972
|
}
|
|
757
973
|
}));
|
|
758
974
|
}
|
|
759
|
-
async _associateProcessIdWithSession(terminal,
|
|
975
|
+
async _associateProcessIdWithSession(terminal, chatSessionResource, id, shellIntegrationQuality, isBackground) {
|
|
760
976
|
try {
|
|
761
977
|
const pid = await Promise.race([
|
|
762
978
|
terminal.processReady.then(() => terminal.processId),
|
|
763
|
-
timeout(5000).then(() => {
|
|
979
|
+
timeout(5000).then(() => {
|
|
980
|
+
throw ( new Error("Timeout"));
|
|
981
|
+
})
|
|
764
982
|
]);
|
|
765
983
|
if (isNumber(pid)) {
|
|
766
|
-
const storedAssociations = this._storageService.get(
|
|
984
|
+
const storedAssociations = this._storageService.get(
|
|
985
|
+
TerminalToolStorageKeysInternal.TerminalSession,
|
|
986
|
+
StorageScope.WORKSPACE,
|
|
987
|
+
"{}"
|
|
988
|
+
);
|
|
767
989
|
const associations = JSON.parse(storedAssociations);
|
|
990
|
+
const sessionId = chatSessionResourceToId(chatSessionResource);
|
|
768
991
|
const existingAssociation = associations[pid] || {};
|
|
769
992
|
associations[pid] = {
|
|
770
993
|
...existingAssociation,
|
|
@@ -773,77 +996,145 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
|
|
|
773
996
|
id,
|
|
774
997
|
isBackground
|
|
775
998
|
};
|
|
776
|
-
this._storageService.store(
|
|
777
|
-
|
|
999
|
+
this._storageService.store(
|
|
1000
|
+
TerminalToolStorageKeysInternal.TerminalSession,
|
|
1001
|
+
JSON.stringify(associations),
|
|
1002
|
+
StorageScope.WORKSPACE,
|
|
1003
|
+
StorageTarget.USER
|
|
1004
|
+
);
|
|
1005
|
+
this._logService.debug(
|
|
1006
|
+
`RunInTerminalTool: Associated terminal PID ${pid} with session ${sessionId}`
|
|
1007
|
+
);
|
|
778
1008
|
}
|
|
779
|
-
}
|
|
780
|
-
catch (error) {
|
|
1009
|
+
} catch (error) {
|
|
781
1010
|
this._logService.debug(`RunInTerminalTool: Failed to associate terminal with session: ${error}`);
|
|
782
1011
|
}
|
|
783
1012
|
}
|
|
784
1013
|
async _removeProcessIdAssociation(pid) {
|
|
785
1014
|
try {
|
|
786
|
-
const storedAssociations = this._storageService.get(
|
|
1015
|
+
const storedAssociations = this._storageService.get(
|
|
1016
|
+
TerminalToolStorageKeysInternal.TerminalSession,
|
|
1017
|
+
StorageScope.WORKSPACE,
|
|
1018
|
+
"{}"
|
|
1019
|
+
);
|
|
787
1020
|
const associations = JSON.parse(storedAssociations);
|
|
788
1021
|
if (associations[pid]) {
|
|
789
1022
|
delete associations[pid];
|
|
790
|
-
this._storageService.store(
|
|
1023
|
+
this._storageService.store(
|
|
1024
|
+
TerminalToolStorageKeysInternal.TerminalSession,
|
|
1025
|
+
JSON.stringify(associations),
|
|
1026
|
+
StorageScope.WORKSPACE,
|
|
1027
|
+
StorageTarget.USER
|
|
1028
|
+
);
|
|
791
1029
|
this._logService.debug(`RunInTerminalTool: Removed terminal association for PID ${pid}`);
|
|
792
1030
|
}
|
|
793
|
-
}
|
|
794
|
-
catch (error) {
|
|
1031
|
+
} catch (error) {
|
|
795
1032
|
this._logService.debug(`RunInTerminalTool: Failed to remove terminal association: ${error}`);
|
|
796
1033
|
}
|
|
797
1034
|
}
|
|
798
|
-
_cleanupSessionTerminals(
|
|
799
|
-
const toolTerminal = this._sessionTerminalAssociations.get(
|
|
1035
|
+
_cleanupSessionTerminals(chatSessionResource) {
|
|
1036
|
+
const toolTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
|
|
800
1037
|
if (toolTerminal) {
|
|
801
|
-
this._logService.debug(
|
|
802
|
-
|
|
1038
|
+
this._logService.debug(
|
|
1039
|
+
`RunInTerminalTool: Cleaning up terminal for disposed chat session ${chatSessionResource}`
|
|
1040
|
+
);
|
|
1041
|
+
this._sessionTerminalAssociations.delete(chatSessionResource);
|
|
803
1042
|
toolTerminal.instance.dispose();
|
|
804
1043
|
const terminalToRemove = [];
|
|
805
|
-
for (const [termId, execution] of RunInTerminalTool_1.
|
|
1044
|
+
for (const [termId, execution] of RunInTerminalTool_1._activeExecutions.entries()) {
|
|
806
1045
|
if (execution.instance === toolTerminal.instance) {
|
|
807
1046
|
execution.dispose();
|
|
808
1047
|
terminalToRemove.push(termId);
|
|
809
1048
|
}
|
|
810
1049
|
}
|
|
811
1050
|
for (const termId of terminalToRemove) {
|
|
812
|
-
RunInTerminalTool_1.
|
|
1051
|
+
RunInTerminalTool_1._activeExecutions.delete(termId);
|
|
813
1052
|
}
|
|
814
1053
|
}
|
|
815
1054
|
}
|
|
816
1055
|
};
|
|
817
|
-
RunInTerminalTool = RunInTerminalTool_1 = ( __decorate([
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1056
|
+
RunInTerminalTool = RunInTerminalTool_1 = ( __decorate([( __param(0, IChatService)), ( __param(1, IConfigurationService)), ( __param(2, IHistoryService)), ( __param(3, IInstantiationService)), ( __param(4, ILabelService)), ( __param(5, ILanguageModelToolsService)), ( __param(6, IRemoteAgentService)), ( __param(7, IStorageService)), ( __param(8, ITerminalChatService)), ( __param(9, ITerminalLogService)), ( __param(10, ITerminalService)), ( __param(11, IWorkspaceContextService)), ( __param(12, IChatWidgetService))], RunInTerminalTool));
|
|
1057
|
+
let ActiveTerminalExecution = class ActiveTerminalExecution extends Disposable {
|
|
1058
|
+
get completionPromise() {
|
|
1059
|
+
return this._completionDeferred.p;
|
|
1060
|
+
}
|
|
1061
|
+
get isBackground() {
|
|
1062
|
+
return this._isBackground;
|
|
1063
|
+
}
|
|
1064
|
+
get startMarker() {
|
|
1065
|
+
return this._startMarker;
|
|
1066
|
+
}
|
|
1067
|
+
get instance() {
|
|
1068
|
+
return this._toolTerminal.instance;
|
|
1069
|
+
}
|
|
1070
|
+
constructor(
|
|
1071
|
+
sessionId,
|
|
1072
|
+
termId,
|
|
1073
|
+
toolTerminal,
|
|
1074
|
+
commandDetection,
|
|
1075
|
+
isBackground,
|
|
1076
|
+
_instantiationService
|
|
1077
|
+
) {
|
|
833
1078
|
super();
|
|
834
|
-
this.instance = instance;
|
|
835
|
-
this._xterm = _xterm;
|
|
836
|
-
this._commandLine = _commandLine;
|
|
837
1079
|
this.sessionId = sessionId;
|
|
838
|
-
this.
|
|
839
|
-
this.
|
|
1080
|
+
this.termId = termId;
|
|
1081
|
+
this._instantiationService = _instantiationService;
|
|
1082
|
+
this._toolTerminal = toolTerminal;
|
|
1083
|
+
this._isBackground = isBackground;
|
|
1084
|
+
this._completionDeferred = ( new DeferredPromise());
|
|
1085
|
+
this.strategy = this._register(this._createStrategy(commandDetection));
|
|
1086
|
+
this._register(this.strategy.onDidCreateStartMarker(marker => {
|
|
1087
|
+
if (marker) {
|
|
1088
|
+
this._startMarker = marker;
|
|
1089
|
+
}
|
|
1090
|
+
}));
|
|
1091
|
+
}
|
|
1092
|
+
_createStrategy(commandDetection) {
|
|
1093
|
+
switch (this._toolTerminal.shellIntegrationQuality) {
|
|
1094
|
+
case ShellIntegrationQuality.None:
|
|
1095
|
+
return this._instantiationService.createInstance(
|
|
1096
|
+
NoneExecuteStrategy,
|
|
1097
|
+
this._toolTerminal.instance,
|
|
1098
|
+
() => this._toolTerminal.receivedUserInput ?? false
|
|
1099
|
+
);
|
|
1100
|
+
case ShellIntegrationQuality.Basic:
|
|
1101
|
+
return this._instantiationService.createInstance(
|
|
1102
|
+
BasicExecuteStrategy,
|
|
1103
|
+
this._toolTerminal.instance,
|
|
1104
|
+
() => this._toolTerminal.receivedUserInput ?? false,
|
|
1105
|
+
commandDetection
|
|
1106
|
+
);
|
|
1107
|
+
case ShellIntegrationQuality.Rich:
|
|
1108
|
+
return this._instantiationService.createInstance(RichExecuteStrategy, this._toolTerminal.instance, commandDetection);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
async start(commandLine, token, commandId) {
|
|
1112
|
+
try {
|
|
1113
|
+
const result = await this.strategy.execute(commandLine, token, commandId);
|
|
1114
|
+
this._completionDeferred.complete(result);
|
|
1115
|
+
return result;
|
|
1116
|
+
} catch (e) {
|
|
1117
|
+
this._completionDeferred.error(e);
|
|
1118
|
+
throw e;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
setForeground() {
|
|
1122
|
+
this._isBackground = false;
|
|
1123
|
+
}
|
|
1124
|
+
setBackground() {
|
|
1125
|
+
this._isBackground = true;
|
|
840
1126
|
}
|
|
841
1127
|
getOutput(marker) {
|
|
842
1128
|
return getOutput(this.instance, marker ?? this._startMarker);
|
|
843
1129
|
}
|
|
844
|
-
}
|
|
1130
|
+
};
|
|
1131
|
+
ActiveTerminalExecution = ( __decorate([( __param(5, IInstantiationService))], ActiveTerminalExecution));
|
|
845
1132
|
let TerminalProfileFetcher = class TerminalProfileFetcher {
|
|
846
|
-
constructor(
|
|
1133
|
+
constructor(
|
|
1134
|
+
_configurationService,
|
|
1135
|
+
_terminalProfileResolverService,
|
|
1136
|
+
_remoteAgentService
|
|
1137
|
+
) {
|
|
847
1138
|
this._configurationService = _configurationService;
|
|
848
1139
|
this._terminalProfileResolverService = _terminalProfileResolverService;
|
|
849
1140
|
this._remoteAgentService = _remoteAgentService;
|
|
@@ -859,14 +1150,17 @@ let TerminalProfileFetcher = class TerminalProfileFetcher {
|
|
|
859
1150
|
os,
|
|
860
1151
|
remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority
|
|
861
1152
|
});
|
|
862
|
-
if (basename(defaultProfile.path) ===
|
|
1153
|
+
if (basename(defaultProfile.path) === "cmd.exe") {
|
|
863
1154
|
return {
|
|
864
1155
|
...defaultProfile,
|
|
865
|
-
path:
|
|
866
|
-
profileName:
|
|
1156
|
+
path: "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
|
1157
|
+
profileName: "PowerShell"
|
|
867
1158
|
};
|
|
868
1159
|
}
|
|
869
|
-
return {
|
|
1160
|
+
return {
|
|
1161
|
+
...defaultProfile,
|
|
1162
|
+
icon: undefined
|
|
1163
|
+
};
|
|
870
1164
|
}
|
|
871
1165
|
async getCopilotShell() {
|
|
872
1166
|
return (await this.getCopilotProfile()).path;
|
|
@@ -874,16 +1168,16 @@ let TerminalProfileFetcher = class TerminalProfileFetcher {
|
|
|
874
1168
|
_getChatTerminalProfile(os) {
|
|
875
1169
|
let profileSetting;
|
|
876
1170
|
switch (os) {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1171
|
+
case OperatingSystem.Windows:
|
|
1172
|
+
profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileWindows;
|
|
1173
|
+
break;
|
|
1174
|
+
case OperatingSystem.Macintosh:
|
|
1175
|
+
profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileMacOs;
|
|
1176
|
+
break;
|
|
1177
|
+
case OperatingSystem.Linux:
|
|
1178
|
+
default:
|
|
1179
|
+
profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileLinux;
|
|
1180
|
+
break;
|
|
887
1181
|
}
|
|
888
1182
|
const profile = this._configurationService.getValue(profileSetting);
|
|
889
1183
|
if (this._isValidChatAgentTerminalProfile(profile)) {
|
|
@@ -892,19 +1186,15 @@ let TerminalProfileFetcher = class TerminalProfileFetcher {
|
|
|
892
1186
|
return undefined;
|
|
893
1187
|
}
|
|
894
1188
|
_isValidChatAgentTerminalProfile(profile) {
|
|
895
|
-
if (profile === null || profile === undefined || typeof profile !==
|
|
1189
|
+
if (profile === null || profile === undefined || typeof profile !== "object") {
|
|
896
1190
|
return false;
|
|
897
1191
|
}
|
|
898
|
-
if (
|
|
1192
|
+
if ("path" in profile && isString(profile.path)) {
|
|
899
1193
|
return true;
|
|
900
1194
|
}
|
|
901
1195
|
return false;
|
|
902
1196
|
}
|
|
903
1197
|
};
|
|
904
|
-
TerminalProfileFetcher = ( __decorate([
|
|
905
|
-
( __param(0, IConfigurationService)),
|
|
906
|
-
( __param(1, ITerminalProfileResolverService)),
|
|
907
|
-
( __param(2, IRemoteAgentService))
|
|
908
|
-
], TerminalProfileFetcher));
|
|
1198
|
+
TerminalProfileFetcher = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, ITerminalProfileResolverService)), ( __param(2, IRemoteAgentService))], TerminalProfileFetcher));
|
|
909
1199
|
|
|
910
1200
|
export { RunInTerminalTool, TerminalProfileFetcher, createRunInTerminalToolData };
|