@codingame/monaco-vscode-chat-service-override 30.0.0 → 31.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/index.js +21 -3
  2. package/package.json +5 -5
  3. package/vscode/src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.d.ts +125 -0
  4. package/vscode/src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.js +393 -0
  5. package/vscode/src/vs/platform/agentHost/browser/remoteAgentHostServiceImpl.d.ts +65 -0
  6. package/vscode/src/vs/platform/agentHost/browser/remoteAgentHostServiceImpl.js +453 -0
  7. package/vscode/src/vs/platform/agentHost/browser/webSocketClientTransport.d.ts +28 -0
  8. package/vscode/src/vs/platform/agentHost/browser/webSocketClientTransport.js +81 -0
  9. package/vscode/src/vs/platform/agentHost/common/agentHostFileSystemProvider.d.ts +75 -0
  10. package/vscode/src/vs/platform/agentHost/common/agentHostFileSystemProvider.js +180 -0
  11. package/vscode/src/vs/platform/agentHost/common/agentService.d.ts +202 -51
  12. package/vscode/src/vs/platform/agentHost/common/state/agentSubscription.d.ts +182 -0
  13. package/vscode/src/vs/platform/agentHost/common/state/agentSubscription.js +282 -0
  14. package/vscode/src/vs/platform/agentHost/common/state/protocol/commands.d.ts +303 -32
  15. package/vscode/src/vs/platform/agentHost/common/state/protocol/commands.js +14 -0
  16. package/vscode/src/vs/platform/agentHost/common/state/protocol/errors.d.ts +1 -1
  17. package/vscode/src/vs/platform/agentHost/common/state/protocol/errors.js +9 -0
  18. package/vscode/src/vs/platform/agentHost/common/state/protocol/reducers.d.ts +30 -0
  19. package/vscode/src/vs/platform/agentHost/common/state/protocol/reducers.js +662 -0
  20. package/vscode/src/vs/platform/agentHost/common/state/sessionActions.d.ts +12 -5
  21. package/vscode/src/vs/platform/agentHost/common/state/sessionActions.js +9 -0
  22. package/vscode/src/vs/platform/agentHost/common/state/sessionCapabilities.d.ts +17 -0
  23. package/vscode/src/vs/platform/agentHost/common/state/sessionCapabilities.js +5 -0
  24. package/vscode/src/vs/platform/agentHost/common/state/sessionProtocol.d.ts +5 -5
  25. package/vscode/src/vs/platform/agentHost/common/state/sessionProtocol.js +14 -0
  26. package/vscode/src/vs/platform/agentHost/common/state/sessionTransport.d.ts +42 -0
  27. package/vscode/src/vs/platform/agentHost/common/state/sessionTransport.js +7 -0
  28. package/vscode/src/vs/platform/agentPlugins/common/pluginParsers.d.ts +118 -0
  29. package/vscode/src/vs/platform/agentPlugins/common/pluginParsers.js +551 -0
  30. package/vscode/src/vs/platform/networkFilter/common/networkFilterService.d.ts +22 -0
  31. package/vscode/src/vs/platform/networkFilter/common/networkFilterService.js +83 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatAccessibilityService.js +2 -2
  33. package/vscode/src/vs/workbench/contrib/chat/browser/accessibility/chatResponseAccessibleView.js +16 -16
  34. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityActions.js +8 -8
  35. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +59 -59
  36. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAgentRecommendationActions.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +12 -12
  38. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +2 -1
  39. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +17 -15
  40. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.d.ts +8 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +113 -9
  42. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +81 -4
  43. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
  44. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatForkActions.js +47 -26
  45. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +15 -10
  46. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.js +13 -13
  47. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +6 -6
  48. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatNewActions.js +14 -14
  49. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatOpenAgentDebugPanelAction.js +13 -14
  50. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.js +15 -14
  51. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPromptNavigationActions.js +2 -2
  52. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQueueActions.d.ts +5 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQueueActions.js +58 -23
  54. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +8 -8
  55. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +18 -18
  56. package/vscode/src/vs/workbench/contrib/chat/browser/actions/createPluginAction.d.ts +2 -1
  57. package/vscode/src/vs/workbench/contrib/chat/browser/actions/createPluginAction.js +24 -22
  58. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginActions.js +8 -8
  59. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginEditor/agentPluginEditor.js +2 -2
  60. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginEditor/agentPluginEditorInput.js +2 -2
  61. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginRepositoryService.d.ts +3 -1
  62. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginRepositoryService.js +29 -20
  63. package/vscode/src/vs/workbench/contrib/chat/browser/agentPluginsView.js +16 -16
  64. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionWorkingDirectoryResolver.d.ts +9 -0
  65. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionWorkingDirectoryResolver.js +23 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.contribution.js +3 -3
  67. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.d.ts +2 -2
  68. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsActions.js +65 -55
  69. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsPicker.js +5 -5
  70. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsQuickAccess.js +1 -1
  71. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjection.js +1 -1
  72. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionActions.js +4 -4
  73. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionProjectionService.js +1 -1
  74. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentSessionsExperiments.contribution.js +5 -5
  75. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/agentTitleBarStatusWidget.js +28 -28
  76. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccess.js +17 -17
  77. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/experiments/unifiedQuickAccessActions.js +4 -4
  78. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationDebugPanel.d.ts +10 -3
  79. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationDebugPanel.js +80 -15
  80. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationIcons.d.ts +20 -14
  81. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationIcons.js +30 -15
  82. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationItemSource.d.ts +131 -0
  83. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationItemSource.js +363 -0
  84. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.d.ts +31 -76
  85. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.js +374 -764
  86. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidgetUtils.d.ts +8 -0
  87. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidgetUtils.js +11 -1
  88. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagement.contribution.js +222 -44
  89. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.d.ts +20 -11
  90. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditor.js +269 -123
  91. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationManagementEditorInput.js +1 -1
  92. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePage.d.ts +40 -0
  93. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePage.js +40 -0
  94. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePagePromptLaunchers.d.ts +26 -0
  95. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePagePromptLaunchers.js +249 -0
  96. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWorkspaceService.d.ts +3 -0
  97. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWorkspaceService.js +3 -0
  98. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationHarnessService.d.ts +4 -3
  99. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/customizationHarnessService.js +5 -17
  100. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/mcpListWidget.d.ts +14 -1
  101. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/mcpListWidget.js +113 -58
  102. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/media/aiCustomizationManagement.css +202 -68
  103. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/media/aiCustomizationWelcomePromptLaunchers.css +246 -0
  104. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/pluginListWidget.d.ts +15 -1
  105. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/pluginListWidget.js +162 -50
  106. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/promptsServiceCustomizationItemProvider.d.ts +24 -0
  107. package/vscode/src/vs/workbench/contrib/chat/browser/aiCustomization/promptsServiceCustomizationItemProvider.js +306 -0
  108. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatAttachmentResolveService.js +1 -1
  109. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +581 -257
  110. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatCustomizationDiscoveryRenderer.d.ts +15 -1
  111. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatCustomizationDiscoveryRenderer.js +245 -26
  112. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugDetailPanel.js +25 -7
  113. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEditor.d.ts +1 -1
  114. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEditor.js +3 -5
  115. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEditorInput.js +2 -2
  116. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEventDetailRenderer.js +19 -19
  117. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugEventList.js +7 -7
  118. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFilters.js +6 -6
  119. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFlowChartView.js +7 -7
  120. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFlowGraph.js +103 -28
  121. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugFlowLayout.js +3 -2
  122. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugHomeView.d.ts +11 -1
  123. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugHomeView.js +80 -29
  124. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugHookContentRenderer.js +17 -17
  125. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugLogsView.d.ts +20 -3
  126. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugLogsView.js +128 -65
  127. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugMessageContentRenderer.js +8 -8
  128. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugModelTurnContentRenderer.js +23 -23
  129. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugOverviewView.js +28 -28
  130. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugToolCallContentRenderer.js +11 -11
  131. package/vscode/src/vs/workbench/contrib/chat/browser/chatDebug/media/chatDebug.css +18 -0
  132. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +1 -1
  133. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingExplanationModelManager.js +3 -3
  134. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +2 -2
  135. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +1 -1
  136. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +1 -0
  137. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +11 -1
  138. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +3 -3
  139. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +6 -5
  140. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +1 -1
  141. package/vscode/src/vs/workbench/contrib/chat/browser/chatImageCarouselService.js +1 -1
  142. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagement.contribution.js +10 -27
  143. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.d.ts +4 -41
  144. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.js +4 -310
  145. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.d.ts +0 -12
  146. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.js +3 -30
  147. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.js +2 -2
  148. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.d.ts +1 -0
  149. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.js +61 -53
  150. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatManagementEditor.css +0 -110
  151. package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.js +3 -3
  152. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +31 -31
  153. package/vscode/src/vs/workbench/contrib/chat/browser/chatRepoInfo.js +2 -2
  154. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.js +46 -34
  155. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupController.d.ts +4 -4
  156. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupController.js +17 -18
  157. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupGrowthSession.js +6 -6
  158. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupProviders.d.ts +1 -0
  159. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupProviders.js +96 -82
  160. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupRunner.d.ts +2 -1
  161. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupRunner.js +21 -14
  162. package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommands.js +18 -18
  163. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatus.js +1 -1
  164. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.d.ts +15 -8
  165. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.js +315 -263
  166. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusEntry.js +14 -14
  167. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus/media/chatStatus.css +196 -24
  168. package/vscode/src/vs/workbench/contrib/chat/browser/chatTipCatalog.js +56 -17
  169. package/vscode/src/vs/workbench/contrib/chat/browser/chatTipEligibilityTracker.d.ts +2 -2
  170. package/vscode/src/vs/workbench/contrib/chat/browser/chatTipService.js +2 -2
  171. package/vscode/src/vs/workbench/contrib/chat/browser/chatWindowNotifier.js +8 -4
  172. package/vscode/src/vs/workbench/contrib/chat/browser/claudePluginRecommendations.js +2 -2
  173. package/vscode/src/vs/workbench/contrib/chat/browser/defaultModelContribution.js +4 -4
  174. package/vscode/src/vs/workbench/contrib/chat/browser/enablementActions.js +4 -4
  175. package/vscode/src/vs/workbench/contrib/chat/browser/enablementStatusWidget.js +2 -2
  176. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelsConfigurationService.js +1 -1
  177. package/vscode/src/vs/workbench/contrib/chat/browser/pluginGitCommandService.d.ts +18 -0
  178. package/vscode/src/vs/workbench/contrib/chat/browser/pluginGitCommandService.js +31 -0
  179. package/vscode/src/vs/workbench/contrib/chat/browser/pluginInstallService.js +26 -25
  180. package/vscode/src/vs/workbench/contrib/chat/browser/pluginSources.d.ts +3 -1
  181. package/vscode/src/vs/workbench/contrib/chat/browser/pluginSources.js +48 -57
  182. package/vscode/src/vs/workbench/contrib/chat/browser/pluginUrlHandler.js +6 -6
  183. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.js +6 -6
  184. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/hookActions.js +26 -26
  185. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/hookUtils.d.ts +2 -2
  186. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/hookUtils.js +3 -3
  187. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionOverlay.js +2 -2
  188. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +2 -2
  189. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.js +8 -8
  190. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.js +7 -7
  191. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveAsPromptFileActions.js +3 -3
  192. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/skillActions.js +3 -3
  193. package/vscode/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.d.ts +11 -6
  194. package/vscode/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.js +226 -36
  195. package/vscode/src/vs/workbench/contrib/chat/browser/telemetry/chatModelCountTelemetry.d.ts +23 -0
  196. package/vscode/src/vs/workbench/contrib/chat/browser/telemetry/chatModelCountTelemetry.js +82 -0
  197. package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsConfirmationService.d.ts +3 -1
  198. package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsConfirmationService.js +108 -56
  199. package/vscode/src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.js +24 -24
  200. package/vscode/src/vs/workbench/contrib/chat/browser/tools/renameTool.js +6 -6
  201. package/vscode/src/vs/workbench/contrib/chat/browser/tools/usagesTool.js +7 -7
  202. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
  203. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatQueuePickerActionItem.js +9 -9
  204. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatStatusWidget.d.ts +3 -4
  205. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/chatStatusWidget.js +9 -16
  206. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.js +21 -80
  207. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorContrib.js +26 -59
  208. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputEditorHover.js +1 -1
  209. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/chatQuick.js +4 -3
  210. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditor.js +9 -1
  211. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.d.ts +2 -1
  212. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.js +46 -14
  213. package/vscode/src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewTitleControl.js +2 -2
  214. package/vscode/src/vs/workbench/contrib/chat/common/chatDebugEvents.d.ts +40 -0
  215. package/vscode/src/vs/workbench/contrib/chat/common/chatDebugEvents.js +60 -0
  216. package/vscode/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.d.ts +32 -5
  217. package/vscode/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.js +152 -26
  218. package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.d.ts +5 -9
  219. package/vscode/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.js +265 -261
  220. package/vscode/src/vs/workbench/contrib/chat/common/model/chatModelStore.d.ts +28 -2
  221. package/vscode/src/vs/workbench/contrib/chat/common/model/chatModelStore.js +75 -7
  222. package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionOperationLog.js +9 -1
  223. package/vscode/src/vs/workbench/contrib/chat/common/model/chatSessionStore.js +6 -5
  224. package/vscode/src/vs/workbench/contrib/chat/common/model/objectMutationLog.d.ts +18 -0
  225. package/vscode/src/vs/workbench/contrib/chat/common/model/objectMutationLog.js +32 -4
  226. package/vscode/src/vs/workbench/contrib/chat/common/plugins/agentPluginService.d.ts +10 -25
  227. package/vscode/src/vs/workbench/contrib/chat/common/plugins/agentPluginServiceImpl.d.ts +7 -52
  228. package/vscode/src/vs/workbench/contrib/chat/common/plugins/agentPluginServiceImpl.js +58 -466
  229. package/vscode/src/vs/workbench/contrib/chat/common/plugins/workspacePluginSettingsService.js +3 -1
  230. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.js +36 -18
  231. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptCodeActions.js +5 -5
  232. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.js +5 -5
  233. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHovers.js +12 -12
  234. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.d.ts +0 -1
  235. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.js +168 -182
  236. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.d.ts +49 -29
  237. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.js +491 -462
  238. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +16 -6
  239. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +18 -12
  240. package/vscode/src/vs/workbench/contrib/chat/common/tools/chatArtifactsService.d.ts +24 -4
  241. package/vscode/src/vs/workbench/contrib/chat/common/tools/chatArtifactsService.js +145 -68
  242. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
  243. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/aiEditTelemetry/aiEditTelemetryServiceImpl.js +2 -2
  244. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
  245. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +25 -25
  246. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatDefaultModel.js +2 -2
  247. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatHistoryService.d.ts +2 -4
  248. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatHistoryService.js +19 -17
  249. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.d.ts +1 -1
  250. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +3 -3
  251. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +5 -17
  252. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +77 -157
  253. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.js +14 -14
  254. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.js +1 -1
  255. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +10 -10
  256. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +5 -5
  257. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +1 -1
  258. package/vscode/src/vs/workbench/contrib/remoteCodingAgents/browser/remoteCodingAgents.contribution.js +7 -7
  259. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.js +17 -17
  260. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibleView.js +1 -1
  261. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.js +21 -21
  262. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatEnabler.js +1 -1
  263. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.d.ts +4 -1
  264. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.js +29 -7
  265. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.js +2 -2
  266. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/taskHelpers.d.ts +1 -1
  267. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/taskHelpers.js +3 -3
  268. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.js +12 -14
  269. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalLastCommandTool.js +4 -4
  270. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.d.ts +5 -1
  271. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.js +49 -12
  272. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalSelectionTool.js +4 -4
  273. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/killTerminalTool.js +9 -8
  274. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.d.ts +2 -2
  275. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.js +13 -8
  276. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sendToTerminalTool.d.ts +53 -0
  277. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sendToTerminalTool.js +319 -0
  278. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/createAndRunTaskTool.js +15 -15
  279. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/getTaskOutputTool.js +8 -8
  280. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/runTaskTool.js +15 -15
  281. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/taskHelpers.d.ts +1 -1
  282. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/taskHelpers.js +2 -2
  283. package/vscode/src/vs/workbench/services/agentHost/common/agentHostFileSystemService.d.ts +21 -0
  284. package/vscode/src/vs/workbench/services/agentHost/common/agentHostFileSystemService.js +35 -0
  285. package/vscode/src/vs/platform/agentHost/common/agentService.service.d.ts +0 -94
  286. package/vscode/src/vs/platform/agentHost/common/state/protocol/action-origin.generated.d.ts +0 -16
  287. package/vscode/src/vs/platform/agentHost/common/state/protocol/actions.d.ts +0 -578
  288. package/vscode/src/vs/platform/agentHost/common/state/protocol/messages.d.ts +0 -206
  289. package/vscode/src/vs/platform/agentHost/common/state/protocol/notifications.d.ts +0 -114
  290. package/vscode/src/vs/platform/agentHost/common/state/protocol/state.d.ts +0 -860
  291. package/vscode/src/vs/platform/agentHost/common/state/sessionState.d.ts +0 -27
  292. package/vscode/src/vs/platform/browserElements/common/browserElements.d.ts +0 -58
  293. package/vscode/src/vs/platform/browserElements/common/browserElements.js +0 -16
  294. package/vscode/src/vs/platform/sandbox/common/sandboxHelperIpc.d.ts +0 -18
  295. package/vscode/src/vs/platform/sandbox/common/sandboxHelperIpc.js +0 -13
  296. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/media/simpleBrowserOverlay.css +0 -85
  297. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/simpleBrowserEditorOverlay.d.ts +0 -9
  298. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/simpleBrowserEditorOverlay.js +0 -443
  299. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.d.ts +0 -17
  300. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.js +0 -132
  301. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatUsageWidget.css +0 -69
  302. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetup.d.ts +0 -65
  303. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup/chatSetup.js +0 -66
  304. package/vscode/src/vs/workbench/contrib/chat/common/chatArtifactExtraction.d.ts +0 -8
  305. package/vscode/src/vs/workbench/contrib/chat/common/chatArtifactExtraction.js +0 -158
  306. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/alternativeRecommendation.d.ts +0 -2
  307. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/alternativeRecommendation.js +0 -41
  308. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/commandFileWriteParser.d.ts +0 -24
  309. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/sedFileWriteParser.d.ts +0 -26
  310. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandParsers/sedFileWriteParser.js +0 -142
  311. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.d.ts +0 -45
  312. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.js +0 -164
  313. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.d.ts +0 -50
  314. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.js +0 -163
  315. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.d.ts +0 -27
  316. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.js +0 -142
  317. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.d.ts +0 -29
  318. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.js +0 -137
  319. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.d.ts +0 -40
  320. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.js +0 -174
  321. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/outputHelpers.d.ts +0 -3
  322. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/outputHelpers.js +0 -39
  323. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.d.ts +0 -32
  324. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.js +0 -249
  325. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalToolTelemetry.d.ts +0 -41
  326. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalToolTelemetry.js +0 -92
  327. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.d.ts +0 -40
  328. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.js +0 -209
  329. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/awaitTerminalTool.d.ts +0 -12
  330. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/awaitTerminalTool.js +0 -106
  331. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.d.ts +0 -31
  332. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/commandLineAutoApprover.js +0 -392
  333. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/npmScriptAutoApprover.d.ts +0 -45
  334. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/autoApprove/npmScriptAutoApprover.js +0 -243
  335. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAnalyzer.d.ts +0 -52
  336. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAnalyzer.js +0 -10
  337. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.d.ts +0 -20
  338. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.js +0 -310
  339. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.d.ts +0 -19
  340. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.js +0 -168
  341. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineSandboxAnalyzer.d.ts +0 -8
  342. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineSandboxAnalyzer.js +0 -25
  343. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/commandLinePresenter.d.ts +0 -41
  344. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/nodeCommandLinePresenter.d.ts +0 -19
  345. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/nodeCommandLinePresenter.js +0 -37
  346. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/pythonCommandLinePresenter.d.ts +0 -19
  347. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/pythonCommandLinePresenter.js +0 -37
  348. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.d.ts +0 -19
  349. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/rubyCommandLinePresenter.js +0 -44
  350. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/sandboxedCommandLinePresenter.d.ts +0 -13
  351. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLinePresenter/sandboxedCommandLinePresenter.js +0 -21
  352. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineCdPrefixRewriter.d.ts +0 -5
  353. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineCdPrefixRewriter.js +0 -27
  354. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePreventHistoryRewriter.d.ts +0 -14
  355. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePreventHistoryRewriter.js +0 -29
  356. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePwshChainOperatorRewriter.d.ts +0 -8
  357. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePwshChainOperatorRewriter.js +0 -33
  358. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineRewriter.d.ts +0 -20
  359. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineSandboxRewriter.d.ts +0 -8
  360. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineSandboxRewriter.js +0 -28
  361. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.d.ts +0 -118
  362. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.js +0 -1019
  363. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/types.d.ts +0 -49
  364. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/types.js +0 -23
  365. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/outputAnalyzer.d.ts +0 -9
  366. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.d.ts +0 -150
  367. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.js +0 -1619
  368. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sandboxOutputAnalyzer.d.ts +0 -22
  369. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sandboxOutputAnalyzer.js +0 -41
  370. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/terminalCommandArtifactCollector.d.ts +0 -17
  371. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/terminalCommandArtifactCollector.js +0 -118
  372. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/toolIds.d.ts +0 -12
  373. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/toolIds.js +0 -17
  374. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.d.ts +0 -25
  375. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.js +0 -130
  376. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.d.ts +0 -122
  377. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.js +0 -482
@@ -1,1619 +0,0 @@
1
-
2
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { timeout, DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
- import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
5
- import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
6
- import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
- import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
8
- import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
9
- import { Disposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
10
- import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
11
- import { getMediaMime } from '@codingame/monaco-vscode-api/vscode/vs/base/common/mime';
12
- import { basename, win32, posix } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
13
- import { OS, OperatingSystem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
14
- import { count } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
15
- import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
16
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
17
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
18
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
19
- import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
20
- import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
21
- import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
22
- import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
23
- import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
24
- import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
25
- import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
26
- import { TerminalToolConfirmationStorageKeys } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart';
27
- import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService.service';
28
- import { ToolDataSource, ToolInvocationPresentation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService';
29
- import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/tools/languageModelToolsService.service';
30
- import { ITerminalChatService, ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
31
- import { ITerminalProfileResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service';
32
- import { TerminalChatAgentToolsSettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration';
33
- import { getRecommendedToolsOverRunInTerminal } from '../alternativeRecommendation.js';
34
- import { BasicExecuteStrategy } from '../executeStrategy/basicExecuteStrategy.js';
35
- import { NoneExecuteStrategy } from '../executeStrategy/noneExecuteStrategy.js';
36
- import { RichExecuteStrategy } from '../executeStrategy/richExecuteStrategy.js';
37
- import { getOutput } from '../outputHelpers.js';
38
- import { isWindowsPowerShell, isPowerShell, isZsh, isFish, normalizeTerminalCommandForDisplay, extractCdPrefix } from '../runInTerminalHelpers.js';
39
- import { NodeCommandLinePresenter } from './commandLinePresenter/nodeCommandLinePresenter.js';
40
- import { PythonCommandLinePresenter } from './commandLinePresenter/pythonCommandLinePresenter.js';
41
- import { RubyCommandLinePresenter } from './commandLinePresenter/rubyCommandLinePresenter.js';
42
- import { SandboxedCommandLinePresenter } from './commandLinePresenter/sandboxedCommandLinePresenter.js';
43
- import { RunInTerminalToolTelemetry } from '../runInTerminalToolTelemetry.js';
44
- import { ToolTerminalCreator, ShellIntegrationQuality } from '../toolTerminalCreator.js';
45
- import { TreeSitterCommandParser, TreeSitterCommandParserLanguage } from '../treeSitterCommandParser.js';
46
- import { CommandLineAutoApproveAnalyzer } from './commandLineAnalyzer/commandLineAutoApproveAnalyzer.js';
47
- import { CommandLineFileWriteAnalyzer } from './commandLineAnalyzer/commandLineFileWriteAnalyzer.js';
48
- import { CommandLineSandboxAnalyzer } from './commandLineAnalyzer/commandLineSandboxAnalyzer.js';
49
- import { OutputMonitor } from './monitoring/outputMonitor.js';
50
- import { OutputMonitorState } from './monitoring/types.js';
51
- import { LocalChatSessionUri, chatSessionResourceToId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/model/chatUri';
52
- import { TerminalToolId } from './toolIds.js';
53
- import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
54
- import { CommandLineCdPrefixRewriter } from './commandLineRewriter/commandLineCdPrefixRewriter.js';
55
- import { CommandLinePreventHistoryRewriter } from './commandLineRewriter/commandLinePreventHistoryRewriter.js';
56
- import { CommandLinePwshChainOperatorRewriter } from './commandLineRewriter/commandLinePwshChainOperatorRewriter.js';
57
- import { CommandLineSandboxRewriter } from './commandLineRewriter/commandLineSandboxRewriter.js';
58
- import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
59
- import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
60
- import { TerminalCommandArtifactCollector } from './terminalCommandArtifactCollector.js';
61
- import { isNumber, isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
62
- import { ChatConfiguration, isAutoApproveLevel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
63
- import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
64
- import { TerminalChatCommandId } from '@codingame/monaco-vscode-xterm-common/vscode/vs/workbench/contrib/terminalContrib/chat/browser/terminalChat';
65
- import { clamp } from '@codingame/monaco-vscode-api/vscode/vs/base/common/numbers';
66
- import { SandboxOutputAnalyzer } from './sandboxOutputAnalyzer.js';
67
- import { IAgentSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.service';
68
- import { TerminalSandboxPrerequisiteCheck } from '../../common/terminalSandboxService.js';
69
- import { ITerminalSandboxService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.service';
70
- import { LanguageModelPartAudience } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
71
-
72
- var RunInTerminalTool_1;
73
- const TERMINAL_SANDBOX_DOCUMENTATION_URL = "https://aka.ms/vscode-sandboxing";
74
- const TOOL_REFERENCE_NAME = "runInTerminal";
75
- const LEGACY_TOOL_REFERENCE_FULL_NAMES = ["runCommands/runInTerminal"];
76
- function createPowerShellModelDescription(shell, isSandboxEnabled, networkDomains) {
77
- const isWinPwsh = isWindowsPowerShell(shell);
78
- const parts = [
79
- `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.`,
80
- "",
81
- "Command Execution:",
82
- isWinPwsh ? "- Use semicolons ; to chain commands on one line, NEVER use && even when asked explicitly" : "- Prefer ; when chaining commands on one line",
83
- "- Prefer pipelines | for object-based data flow",
84
- "- Never create a sub-shell (eg. powershell -c \"command\") unless explicitly asked",
85
- "",
86
- "Directory Management:",
87
- "- Prefer relative paths when navigating directories, only use absolute when the path is far away or the current cwd is not expected",
88
- "- Remember when isBackground=false is specified, that the shell and cwd are reused until it is moved to the background",
89
- "- Use $PWD or Get-Location for current directory",
90
- "- Use Push-Location/Pop-Location for directory stack",
91
- "",
92
- "Program Execution:",
93
- "- Supports .NET, Python, Node.js, and other executables",
94
- "- Install modules via Install-Module, Install-Package",
95
- "- Use Get-Command to verify cmdlet/function availability",
96
- "",
97
- "Background Processes:",
98
- "- For long-running tasks (e.g., servers), set isBackground=true",
99
- "- Returns a terminal ID for checking status and runtime later",
100
- "- Use Start-Job for background PowerShell jobs"
101
- ];
102
- if (isSandboxEnabled) {
103
- parts.push(...createSandboxLines(networkDomains));
104
- }
105
- parts.push(
106
- "",
107
- "Output Management:",
108
- "- Output is automatically truncated if longer than 60KB to prevent context overflow",
109
- "- Use Select-Object, Where-Object, Format-Table to filter output",
110
- "- Use -First/-Last parameters to limit results",
111
- "- For pager commands, add | Out-String or | Format-List",
112
- "",
113
- "Best Practices:",
114
- "- Use proper cmdlet names instead of aliases in scripts",
115
- "- Quote paths with spaces: \"C:\\Path With Spaces\"",
116
- "- Prefer PowerShell cmdlets over external commands when available",
117
- "- Prefer idiomatic PowerShell like Get-ChildItem instead of dir or ls for file listings",
118
- "- Use Test-Path to check file/directory existence",
119
- "- Be specific with Select-Object properties to avoid excessive output",
120
- "- Avoid printing credentials unless absolutely required",
121
- `- NEVER run Start-Sleep or similar wait commands. If you need to wait for a background process, use ${TerminalToolId.AwaitTerminal} or ${TerminalToolId.GetTerminalOutput} instead`
122
- );
123
- return parts.join("\n");
124
- }
125
- function createSandboxLines(networkDomains) {
126
- const lines = [
127
- "",
128
- "Sandboxing:",
129
- "- ATTENTION: Terminal sandboxing is enabled, commands run in a sandbox by default",
130
- "- When executing commands within the sandboxed environment, all operations requiring a temporary directory must utilize the $TMPDIR environment variable. The /tmp directory is not guaranteed to be accessible or writable and must be avoided",
131
- "- Tools and scripts should respect the TMPDIR environment variable, which is automatically set to an appropriate path within the sandbox",
132
- "- When a command fails due to sandbox restrictions, immediately re-run it with requestUnsandboxedExecution=true. Do NOT ask the user for permission — setting this flag automatically shows a confirmation prompt to the user",
133
- "- Only set requestUnsandboxedExecution=true when there is evidence of failures caused by the sandbox, e.g. 'Operation not permitted' errors, network failures, or file access errors, etc",
134
- "- When setting requestUnsandboxedExecution=true, also provide requestUnsandboxedExecutionReason explaining why the command needs unsandboxed access"
135
- ];
136
- if (networkDomains) {
137
- const deniedSet = ( new Set(networkDomains.deniedDomains));
138
- const effectiveAllowed = networkDomains.allowedDomains.filter(d => !( deniedSet.has(d)));
139
- if (effectiveAllowed.length === 0) {
140
- lines.push("- All network access is blocked in the sandbox");
141
- } else {
142
- lines.push(
143
- `- Only the following domains are accessible in the sandbox (all other network access is blocked): ${effectiveAllowed.join(", ")}`
144
- );
145
- }
146
- if (networkDomains.deniedDomains.length > 0) {
147
- lines.push(
148
- `- The following domains are explicitly blocked in the sandbox: ${networkDomains.deniedDomains.join(", ")}`
149
- );
150
- }
151
- }
152
- return lines;
153
- }
154
- function createGenericDescription(isSandboxEnabled, networkDomains) {
155
- const parts = [`
156
- Command Execution:
157
- - Use && to chain simple commands on one line
158
- - Prefer pipelines | over temporary files for data flow
159
- - Never create a sub-shell (eg. bash -c "command") unless explicitly asked
160
-
161
- Directory Management:
162
- - Prefer relative paths when navigating directories, only use absolute when the path is far away or the current cwd is not expected
163
- - Remember when isBackground=false is specified, that shell and cwd is reused until it is moved to the background
164
- - Use $PWD for current directory references
165
- - Consider using pushd/popd for directory stack management
166
- - Supports directory shortcuts like ~ and -
167
-
168
- Program Execution:
169
- - Supports Python, Node.js, and other executables
170
- - Install packages via package managers (brew, apt, etc.)
171
- - Use which or command -v to verify command availability
172
-
173
- Background Processes:
174
- - For long-running tasks (e.g., servers), set isBackground=true
175
- - Returns a terminal ID for checking status and runtime later`];
176
- if (isSandboxEnabled) {
177
- parts.push(createSandboxLines(networkDomains).join("\n"));
178
- }
179
- parts.push(`
180
-
181
- Output Management:
182
- - Output is automatically truncated if longer than 60KB to prevent context overflow
183
- - Use head, tail, grep, awk to filter and limit output size
184
- - For pager commands, disable paging: git --no-pager or add | cat
185
- - Use wc -l to count lines before displaying large outputs
186
-
187
- Best Practices:
188
- - Quote variables: "$var" instead of $var to handle spaces
189
- - Use find with -exec or xargs for file operations
190
- - Be specific with commands to avoid excessive output
191
- - Avoid printing credentials unless absolutely required
192
- - NEVER run sleep or similar wait commands in a terminal. If you need to wait for a background process, use ${TerminalToolId.AwaitTerminal} or ${TerminalToolId.GetTerminalOutput} instead`);
193
- return parts.join("");
194
- }
195
- function createBashModelDescription(isSandboxEnabled, networkDomains) {
196
- return [
197
- "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.",
198
- createGenericDescription(isSandboxEnabled, networkDomains),
199
- "- Use [[ ]] for conditional tests instead of [ ]",
200
- "- Prefer $() over backticks for command substitution",
201
- "- Use set -e at start of complex commands to exit on errors"
202
- ].join("\n");
203
- }
204
- function createZshModelDescription(isSandboxEnabled, networkDomains) {
205
- return [
206
- "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.",
207
- createGenericDescription(isSandboxEnabled, networkDomains),
208
- "- Use type to check command type (builtin, function, alias)",
209
- "- Use jobs, fg, bg for job control",
210
- "- Use [[ ]] for conditional tests instead of [ ]",
211
- "- Prefer $() over backticks for command substitution",
212
- "- Use setopt errexit for strict error handling",
213
- "- Take advantage of zsh globbing features (**, extended globs)"
214
- ].join("\n");
215
- }
216
- function createFishModelDescription(isSandboxEnabled, networkDomains) {
217
- return [
218
- "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.",
219
- createGenericDescription(isSandboxEnabled, networkDomains),
220
- "- Use type to check command type (builtin, function, alias)",
221
- "- Use jobs, fg, bg for job control",
222
- "- Use test expressions for conditionals (no [[ ]] syntax)",
223
- "- Prefer command substitution with () syntax",
224
- "- Variables are arrays by default, use $var[1] for first element",
225
- "- Use set -e for strict error handling",
226
- "- Take advantage of fish's autosuggestions and completions"
227
- ].join("\n");
228
- }
229
- async function createRunInTerminalToolData(accessor) {
230
- const instantiationService = accessor.get(IInstantiationService);
231
- const terminalSandboxService = accessor.get(ITerminalSandboxService);
232
- const profileFetcher = instantiationService.createInstance(TerminalProfileFetcher);
233
- const [shell, os, isSandboxEnabled] = await Promise.all([
234
- profileFetcher.getCopilotShell(),
235
- profileFetcher.osBackend,
236
- terminalSandboxService.isEnabled()
237
- ]);
238
- const networkDomains = isSandboxEnabled ? terminalSandboxService.getResolvedNetworkDomains() : undefined;
239
- let modelDescription;
240
- if (shell && os && isPowerShell(shell, os)) {
241
- modelDescription = createPowerShellModelDescription(shell, isSandboxEnabled, networkDomains);
242
- } else if (shell && os && isZsh(shell, os)) {
243
- modelDescription = createZshModelDescription(isSandboxEnabled, networkDomains);
244
- } else if (shell && os && isFish(shell, os)) {
245
- modelDescription = createFishModelDescription(isSandboxEnabled, networkDomains);
246
- } else {
247
- modelDescription = createBashModelDescription(isSandboxEnabled, networkDomains);
248
- }
249
- return {
250
- id: TerminalToolId.RunInTerminal,
251
- toolReferenceName: TOOL_REFERENCE_NAME,
252
- legacyToolReferenceFullNames: LEGACY_TOOL_REFERENCE_FULL_NAMES,
253
- displayName: ( localize(13907, "Run in Terminal")),
254
- modelDescription,
255
- userDescription: ( localize(13908, "Run commands in the terminal")),
256
- source: ToolDataSource.Internal,
257
- icon: Codicon.terminal,
258
- inputSchema: {
259
- type: "object",
260
- properties: {
261
- command: {
262
- type: "string",
263
- description: "The command to run in the terminal."
264
- },
265
- explanation: {
266
- type: "string",
267
- description: "A one-sentence description of what the command does. This will be shown to the user before the command is run."
268
- },
269
- goal: {
270
- type: "string",
271
- description: "A short description of the goal or purpose of the command (e.g., \"Install dependencies\", \"Start development server\")."
272
- },
273
- isBackground: {
274
- type: "boolean",
275
- 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}. If unsure whether a command will be long-running, prefer isBackground=true.`
276
- },
277
- timeout: {
278
- type: "number",
279
- 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 with a timeout indicator. 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."
280
- },
281
- ...(isSandboxEnabled ? {
282
- requestUnsandboxedExecution: {
283
- type: "boolean",
284
- description: "Request that this command run outside the terminal sandbox. Only set this when the command clearly needs unsandboxed access. The user will be prompted before the command runs unsandboxed."
285
- },
286
- requestUnsandboxedExecutionReason: {
287
- type: "string",
288
- description: "A short explanation of why this command must run outside the terminal sandbox. Only provide this when requestUnsandboxedExecution is true."
289
- }
290
- } : {})
291
- },
292
- required: ["command", "explanation", "goal", "isBackground"]
293
- }
294
- };
295
- }
296
- var TerminalToolStorageKeysInternal;
297
- (function(TerminalToolStorageKeysInternal) {
298
- TerminalToolStorageKeysInternal["TerminalSession"] = "chat.terminalSessions";
299
- })(TerminalToolStorageKeysInternal || (TerminalToolStorageKeysInternal = {}));
300
- const telemetryIgnoredSequences = [
301
- "\u001b[I",
302
- "\u001b[O"];
303
- const altBufferMessage = "\n" + ( localize(13909, "The command opened the alternate buffer."));
304
- let RunInTerminalTool = class RunInTerminalTool extends Disposable {
305
- static {
306
- RunInTerminalTool_1 = this;
307
- }
308
- static {
309
- this._activeExecutions = ( new Map());
310
- }
311
- static getBackgroundOutput(id) {
312
- const execution = RunInTerminalTool_1._activeExecutions.get(id);
313
- if (!execution) {
314
- throw ( new Error("Invalid terminal ID"));
315
- }
316
- return execution.getOutput();
317
- }
318
- static getExecution(id) {
319
- return RunInTerminalTool_1._activeExecutions.get(id);
320
- }
321
- static removeExecution(id) {
322
- const execution = RunInTerminalTool_1._activeExecutions.get(id);
323
- if (!execution) {
324
- return false;
325
- }
326
- execution.dispose();
327
- RunInTerminalTool_1._activeExecutions.delete(id);
328
- return true;
329
- }
330
- get _enableCommandLineSandboxRewriting() {
331
- return true;
332
- }
333
- constructor(
334
- _chatService,
335
- _configurationService,
336
- _fileService,
337
- _historyService,
338
- _instantiationService,
339
- _labelService,
340
- _languageModelToolsService,
341
- _remoteAgentService,
342
- _storageService,
343
- _terminalChatService,
344
- _logService,
345
- _terminalService,
346
- _terminalSandboxService,
347
- _workspaceContextService,
348
- _chatWidgetService,
349
- _agentSessionsService
350
- ) {
351
- super();
352
- this._chatService = _chatService;
353
- this._configurationService = _configurationService;
354
- this._fileService = _fileService;
355
- this._historyService = _historyService;
356
- this._instantiationService = _instantiationService;
357
- this._labelService = _labelService;
358
- this._languageModelToolsService = _languageModelToolsService;
359
- this._remoteAgentService = _remoteAgentService;
360
- this._storageService = _storageService;
361
- this._terminalChatService = _terminalChatService;
362
- this._logService = _logService;
363
- this._terminalService = _terminalService;
364
- this._terminalSandboxService = _terminalSandboxService;
365
- this._workspaceContextService = _workspaceContextService;
366
- this._chatWidgetService = _chatWidgetService;
367
- this._agentSessionsService = _agentSessionsService;
368
- this._archivedSessionListener = this._register(( new MutableDisposable()));
369
- this._sessionTerminalAssociations = ( new ResourceMap());
370
- this._sessionTerminalInstances = ( new ResourceMap());
371
- this._terminalsBeingDisposedBySessionCleanup = ( new Set());
372
- this._osBackend = this._remoteAgentService.getEnvironment().then(remoteEnv => remoteEnv?.os ?? OS);
373
- this._terminalToolCreator = this._instantiationService.createInstance(ToolTerminalCreator);
374
- this._treeSitterCommandParser = this._register(this._instantiationService.createInstance(TreeSitterCommandParser));
375
- this._telemetry = this._instantiationService.createInstance(RunInTerminalToolTelemetry);
376
- this._commandArtifactCollector = this._instantiationService.createInstance(TerminalCommandArtifactCollector);
377
- this._profileFetcher = this._instantiationService.createInstance(TerminalProfileFetcher);
378
- this._commandLineRewriters = [
379
- this._register(this._instantiationService.createInstance(CommandLineCdPrefixRewriter)),
380
- this._register(
381
- this._instantiationService.createInstance(CommandLinePwshChainOperatorRewriter, this._treeSitterCommandParser)
382
- )
383
- ];
384
- if (this._enableCommandLineSandboxRewriting) {
385
- this._commandLineRewriters.push(
386
- this._register(this._instantiationService.createInstance(CommandLineSandboxRewriter))
387
- );
388
- }
389
- this._commandLineRewriters.push(this._register(
390
- this._instantiationService.createInstance(CommandLinePreventHistoryRewriter)
391
- ));
392
- this._commandLineAnalyzers = [this._register(this._instantiationService.createInstance(
393
- CommandLineFileWriteAnalyzer,
394
- this._treeSitterCommandParser,
395
- (message, args) => this._logService.info(`RunInTerminalTool#CommandLineFileWriteAnalyzer: ${message}`, args)
396
- )), this._register(this._instantiationService.createInstance(
397
- CommandLineAutoApproveAnalyzer,
398
- this._treeSitterCommandParser,
399
- this._telemetry,
400
- (message, args) => this._logService.info(`RunInTerminalTool#CommandLineAutoApproveAnalyzer: ${message}`, args)
401
- ))];
402
- if (this._enableCommandLineSandboxRewriting) {
403
- this._commandLineAnalyzers.push(
404
- this._register(this._instantiationService.createInstance(CommandLineSandboxAnalyzer))
405
- );
406
- }
407
- this._commandLinePresenters = [
408
- this._instantiationService.createInstance(SandboxedCommandLinePresenter),
409
- ( new NodeCommandLinePresenter()),
410
- ( new PythonCommandLinePresenter()),
411
- ( new RubyCommandLinePresenter())
412
- ];
413
- this._outputAnalyzers = [
414
- this._register(this._instantiationService.createInstance(SandboxOutputAnalyzer))
415
- ];
416
- this._register(
417
- Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {
418
- if (!e || e.affectsConfiguration(TerminalChatAgentToolsSettingId.EnableAutoApprove)) {
419
- if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) !== true) {
420
- this._storageService.remove(
421
- TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted,
422
- StorageScope.APPLICATION
423
- );
424
- }
425
- }
426
- })
427
- );
428
- this._restoreTerminalAssociations();
429
- this._register(this._terminalService.onDidDisposeInstance(e => {
430
- this._removeTerminalAssociations(e);
431
- }));
432
- this._register(this._chatService.onDidDisposeSession(e => {
433
- for (const resource of e.sessionResources) {
434
- this._cleanupSessionTerminals(resource);
435
- }
436
- }));
437
- }
438
- async handleToolStream(context, _token) {
439
- const partialInput = context.rawInput;
440
- if (partialInput && typeof partialInput === "object" && partialInput.command) {
441
- const normalizedCommand = normalizeTerminalCommandForDisplay(partialInput.command).replace(/\r\n|\r|\n/g, " ");
442
- const truncatedCommand = normalizedCommand.length > 80 ? normalizedCommand.substring(0, 77) + "..." : normalizedCommand;
443
- const invocationMessage = partialInput.isBackground ? ( new MarkdownString(( localize(13910, "Running `{0}` in background", truncatedCommand)))) : ( new MarkdownString(( localize(13911, "Running `{0}`", truncatedCommand))));
444
- return {
445
- invocationMessage
446
- };
447
- }
448
- return {
449
- invocationMessage: ( localize(13912, "Running command"))
450
- };
451
- }
452
- async prepareToolInvocation(context, token) {
453
- const args = context.parameters;
454
- const chatSessionResource = context.chatSessionResource;
455
- let instance;
456
- if (chatSessionResource) {
457
- const toolTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
458
- if (toolTerminal && !toolTerminal.isBackground) {
459
- instance = toolTerminal.instance;
460
- }
461
- }
462
- const [os, shell, cwd, sandboxPrereqs] = await Promise.all([this._osBackend, this._profileFetcher.getCopilotShell(), (async () => {
463
- let cwd = await instance?.getCwdResource();
464
- if (!cwd) {
465
- const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
466
- const workspaceFolder = activeWorkspaceRootUri ? this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
467
- cwd = workspaceFolder?.uri;
468
- }
469
- return cwd;
470
- })(), this._terminalSandboxService.checkForSandboxingPrereqs()]);
471
- const language = os === OperatingSystem.Windows ? "pwsh" : "sh";
472
- const isTerminalSandboxEnabled = sandboxPrereqs.enabled;
473
- const requiresUnsandboxConfirmation = isTerminalSandboxEnabled && args.requestUnsandboxedExecution === true;
474
- const missingDependencies = sandboxPrereqs.failedCheck === TerminalSandboxPrerequisiteCheck.Dependencies && sandboxPrereqs.missingDependencies?.length ? sandboxPrereqs.missingDependencies : undefined;
475
- const terminalToolSessionId = generateUuid();
476
- const terminalCommandId = `tool-${generateUuid()}`;
477
- let rewrittenCommand = args.command;
478
- let forDisplayCommand = undefined;
479
- let isSandboxWrapped = false;
480
- for (const rewriter of this._commandLineRewriters) {
481
- const rewriteResult = await rewriter.rewrite({
482
- commandLine: rewrittenCommand,
483
- cwd,
484
- shell,
485
- os,
486
- requestUnsandboxedExecution: requiresUnsandboxConfirmation
487
- });
488
- if (rewriteResult) {
489
- rewrittenCommand = rewriteResult.rewritten;
490
- forDisplayCommand = rewriteResult.forDisplay ?? forDisplayCommand;
491
- if (rewriteResult.isSandboxWrapped) {
492
- isSandboxWrapped = true;
493
- }
494
- this._logService.info(
495
- `RunInTerminalTool: Command rewritten by ${rewriter.constructor.name}: ${rewriteResult.reasoning}`
496
- );
497
- }
498
- }
499
- const toolSpecificData = {
500
- kind: "terminal",
501
- terminalToolSessionId,
502
- terminalCommandId,
503
- commandLine: {
504
- original: args.command,
505
- toolEdited: rewrittenCommand === args.command ? undefined : rewrittenCommand,
506
- forDisplay: forDisplayCommand ?? normalizeTerminalCommandForDisplay(rewrittenCommand ?? args.command),
507
- isSandboxWrapped
508
- },
509
- cwd,
510
- language,
511
- isBackground: args.isBackground,
512
- requestUnsandboxedExecution: requiresUnsandboxConfirmation,
513
- requestUnsandboxedExecutionReason: args.requestUnsandboxedExecutionReason,
514
- missingSandboxDependencies: missingDependencies
515
- };
516
- let sandboxConfirmationMessageForMissingDeps = undefined;
517
- if (missingDependencies) {
518
- const depsList = missingDependencies.join(", ");
519
- sandboxConfirmationMessageForMissingDeps = {
520
- title: ( localize(13913, "Missing Sandbox Dependencies")),
521
- message: ( new MarkdownString(( localize(
522
- 13914,
523
- "The following dependencies required for sandboxed execution are not installed: {0}. Would you like to install them?",
524
- depsList
525
- )))),
526
- customButtons: [( localize(13915, "Install")), ( localize(13916, "Cancel"))]
527
- };
528
- }
529
- const alternativeRecommendation = getRecommendedToolsOverRunInTerminal(args.command, this._languageModelToolsService);
530
- if (alternativeRecommendation) {
531
- toolSpecificData.alternativeRecommendation = alternativeRecommendation;
532
- return {
533
- confirmationMessages: undefined,
534
- presentation: ToolInvocationPresentation.Hidden,
535
- toolSpecificData
536
- };
537
- }
538
- const commandLine = rewrittenCommand ?? args.command;
539
- const isEligibleForAutoApproval = () => {
540
- const config = this._configurationService.getValue(ChatConfiguration.EligibleForAutoApproval);
541
- if (config && typeof config === "object") {
542
- if (Object.prototype.hasOwnProperty.call(config, TOOL_REFERENCE_NAME)) {
543
- return config[TOOL_REFERENCE_NAME];
544
- }
545
- for (const legacyName of LEGACY_TOOL_REFERENCE_FULL_NAMES) {
546
- if (Object.prototype.hasOwnProperty.call(config, legacyName)) {
547
- return config[legacyName];
548
- }
549
- }
550
- }
551
- return true;
552
- };
553
- const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;
554
- const isAutoApproveWarningAccepted = this._storageService.getBoolean(
555
- TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted,
556
- StorageScope.APPLICATION,
557
- false
558
- );
559
- const isAutoApproveAllowed = isEligibleForAutoApproval() && isAutoApproveEnabled && isAutoApproveWarningAccepted;
560
- const commandLineAnalyzerOptions = {
561
- commandLine,
562
- cwd,
563
- os,
564
- shell,
565
- treeSitterLanguage: isPowerShell(shell, os) ? TreeSitterCommandParserLanguage.PowerShell : TreeSitterCommandParserLanguage.Bash,
566
- terminalToolSessionId,
567
- chatSessionResource,
568
- requiresUnsandboxConfirmation
569
- };
570
- const isSessionAutoApproved = chatSessionResource && this._isSessionAutoApproveLevel(chatSessionResource);
571
- const commandLineAnalyzers = isSessionAutoApproved ? this._commandLineAnalyzers.filter(e => !(e instanceof CommandLineAutoApproveAnalyzer)) : this._commandLineAnalyzers;
572
- const commandLineAnalyzerResults = await Promise.all(( commandLineAnalyzers.map(e => e.analyze(commandLineAnalyzerOptions))));
573
- const disclaimersRaw = ( commandLineAnalyzerResults.map(e => e.disclaimers)).filter(e => !!e).flatMap(e => e);
574
- let disclaimer;
575
- if (disclaimersRaw.length > 0) {
576
- const disclaimerTexts = ( disclaimersRaw.map(d => typeof d === "string" ? d : d.value));
577
- const hasMarkdownDisclaimer = ( disclaimersRaw.some(d => typeof d !== "string"));
578
- const mdOptions = hasMarkdownDisclaimer ? {
579
- supportThemeIcons: true,
580
- isTrusted: {
581
- enabledCommands: [TerminalChatCommandId.OpenTerminalSettingsLink]
582
- }
583
- } : {
584
- supportThemeIcons: true
585
- };
586
- disclaimer = ( new MarkdownString(`$(${Codicon.info.id}) ` + disclaimerTexts.join(" "), mdOptions));
587
- }
588
- const analyzersIsAutoApproveAllowed = commandLineAnalyzerResults.every(e => e.isAutoApproveAllowed);
589
- const customActions = isEligibleForAutoApproval() && analyzersIsAutoApproveAllowed ? ( commandLineAnalyzerResults.map(e => e.customActions ?? [])).flat() : undefined;
590
- let shellType = basename(shell, ".exe");
591
- if (shellType === "powershell") {
592
- shellType = "pwsh";
593
- }
594
- const wouldBeAutoApproved =
595
- (( commandLineAnalyzerResults.some(e => e.isAutoApproved)) &&
596
- commandLineAnalyzerResults.every(e => e.isAutoApproved !== false) &&
597
- analyzersIsAutoApproveAllowed);
598
- const isFinalAutoApproved =
599
- (isAutoApproveAllowed &&
600
- wouldBeAutoApproved) || ( commandLineAnalyzerResults.some(e => e.forceAutoApproval));
601
- if (isFinalAutoApproved || (isAutoApproveEnabled && ( commandLineAnalyzerResults.some(e => e.autoApproveInfo)))) {
602
- toolSpecificData.autoApproveInfo = commandLineAnalyzerResults.find(e => e.autoApproveInfo)?.autoApproveInfo;
603
- }
604
- const commandToDisplay = (toolSpecificData.commandLine.forDisplay ?? toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original).trimStart();
605
- const extractedCd = extractCdPrefix(commandToDisplay, shell, os);
606
- let confirmationTitle;
607
- if (extractedCd && cwd) {
608
- const isAbsolutePath = os === OperatingSystem.Windows ? win32.isAbsolute(extractedCd.directory) : posix.isAbsolute(extractedCd.directory);
609
- const directoryUri = isAbsolutePath ? ( URI.from({
610
- scheme: cwd.scheme,
611
- authority: cwd.authority,
612
- path: extractedCd.directory
613
- })) : URI.joinPath(cwd, extractedCd.directory);
614
- const directoryLabel = this._labelService.getUriLabel(directoryUri);
615
- const cdPrefix = commandToDisplay.substring(0, commandToDisplay.length - extractedCd.command.length);
616
- toolSpecificData.confirmation = {
617
- commandLine: extractedCd.command,
618
- cwdLabel: directoryLabel,
619
- cdPrefix
620
- };
621
- confirmationTitle = args.isBackground ? ( localize(
622
- 13917,
623
- "Run `{0}` command in background within `{1}`?",
624
- shellType,
625
- directoryLabel
626
- )) : ( localize(13918, "Run `{0}` command within `{1}`?", shellType, directoryLabel));
627
- } else {
628
- toolSpecificData.confirmation = {
629
- commandLine: commandToDisplay
630
- };
631
- confirmationTitle = args.isBackground ? ( localize(13919, "Run `{0}` command in background?", shellType)) : ( localize(13920, "Run `{0}` command?", shellType));
632
- }
633
- const commandForPresenter = extractedCd?.command ?? commandToDisplay;
634
- let presenterInput = commandForPresenter;
635
- for (const presenter of this._commandLinePresenters) {
636
- const presenterResult = await presenter.present({
637
- commandLine: {
638
- original: args.command,
639
- forDisplay: presenterInput
640
- },
641
- shell,
642
- os
643
- });
644
- if (presenterResult) {
645
- toolSpecificData.presentationOverrides = {
646
- commandLine: presenterResult.commandLine,
647
- language: presenterResult.language ?? undefined
648
- };
649
- if (extractedCd && toolSpecificData.confirmation?.cwdLabel) {
650
- if (presenterResult.languageDisplayName) {
651
- confirmationTitle = args.isBackground ? ( localize(
652
- 13921,
653
- "Run `{0}` command in `{1}` in background within `{2}`?",
654
- presenterResult.languageDisplayName,
655
- shellType,
656
- toolSpecificData.confirmation.cwdLabel
657
- )) : ( localize(
658
- 13922,
659
- "Run `{0}` command in `{1}` within `{2}`?",
660
- presenterResult.languageDisplayName,
661
- shellType,
662
- toolSpecificData.confirmation.cwdLabel
663
- ));
664
- } else {
665
- confirmationTitle = args.isBackground ? ( localize(
666
- 13923,
667
- "Run command in `{0}` in background within `{1}`?",
668
- shellType,
669
- toolSpecificData.confirmation.cwdLabel
670
- )) : ( localize(
671
- 13924,
672
- "Run command in `{0}` within `{1}`?",
673
- shellType,
674
- toolSpecificData.confirmation.cwdLabel
675
- ));
676
- }
677
- } else {
678
- if (presenterResult.languageDisplayName) {
679
- confirmationTitle = args.isBackground ? ( localize(
680
- 13925,
681
- "Run `{0}` command in `{1}` in background?",
682
- presenterResult.languageDisplayName,
683
- shellType
684
- )) : ( localize(
685
- 13926,
686
- "Run `{0}` command in `{1}`?",
687
- presenterResult.languageDisplayName,
688
- shellType
689
- ));
690
- } else {
691
- confirmationTitle = args.isBackground ? ( localize(13927, "Run command in `{0}` in background?", shellType)) : ( localize(13928, "Run command in `{0}`?", shellType));
692
- }
693
- }
694
- if (!presenterResult.processOtherPresenters) {
695
- break;
696
- }
697
- presenterInput = presenterResult.commandLine;
698
- }
699
- }
700
- if (requiresUnsandboxConfirmation) {
701
- confirmationTitle = args.isBackground ? ( localize(
702
- 13929,
703
- "Run `{0}` command outside the [sandbox]({1}) in background?",
704
- shellType,
705
- TERMINAL_SANDBOX_DOCUMENTATION_URL
706
- )) : ( localize(
707
- 13930,
708
- "Run `{0}` command outside the [sandbox]({1})?",
709
- shellType,
710
- TERMINAL_SANDBOX_DOCUMENTATION_URL
711
- ));
712
- }
713
- const shouldShowConfirmation = (!isFinalAutoApproved && !isSessionAutoApproved) || context.forceConfirmationReason !== undefined;
714
- const confirmationMessage = requiresUnsandboxConfirmation ? ( new MarkdownString(( localize(
715
- 13931,
716
- "Explanation: {0}\n\nGoal: {1}\n\nReason for leaving the sandbox: {2}",
717
- args.explanation,
718
- args.goal,
719
- args.requestUnsandboxedExecutionReason || ( localize(13932, "The model indicated that this command needs unsandboxed access."))
720
- )))) : ( new MarkdownString(( localize(13933, "Explanation: {0}\n\nGoal: {1}", args.explanation, args.goal))));
721
- const confirmationMessages = shouldShowConfirmation ? {
722
- title: confirmationTitle,
723
- message: confirmationMessage,
724
- disclaimer,
725
- allowAutoConfirm: undefined,
726
- terminalCustomActions: customActions
727
- } : undefined;
728
- const rawDisplayCommand = toolSpecificData.commandLine.forDisplay ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original;
729
- const displayCommand = rawDisplayCommand.length > 80 ? rawDisplayCommand.substring(0, 77) + "..." : rawDisplayCommand;
730
- const invocationMessage = toolSpecificData.commandLine.isSandboxWrapped ? args.isBackground ? ( new MarkdownString(( localize(13934, "Running `{0}` in sandbox in background", displayCommand)))) : ( new MarkdownString(( localize(13935, "Running `{0}` in sandbox", displayCommand)))) : args.isBackground ? ( new MarkdownString(( localize(13936, "Running `{0}` in background", displayCommand)))) : ( new MarkdownString(( localize(13937, "Running `{0}`", displayCommand))));
731
- return {
732
- invocationMessage,
733
- icon: toolSpecificData.commandLine.isSandboxWrapped ? Codicon.terminalSecure : Codicon.terminal,
734
- confirmationMessages: sandboxConfirmationMessageForMissingDeps ?? confirmationMessages,
735
- toolSpecificData
736
- };
737
- }
738
- _isSessionAutoApproveLevel(chatSessionResource) {
739
- const inspected = this._configurationService.inspect(ChatConfiguration.GlobalAutoApprove);
740
- if (inspected.policyValue === false) {
741
- return false;
742
- }
743
- const widget = this._chatWidgetService.getWidgetBySessionResource(chatSessionResource) ?? this._chatWidgetService.lastFocusedWidget;
744
- if (widget && isAutoApproveLevel(widget.input.currentModeInfo.permissionLevel)) {
745
- return true;
746
- }
747
- const model = this._chatService.getSession(chatSessionResource);
748
- const request = model?.getRequests().at(-1);
749
- return isAutoApproveLevel(request?.modeInfo?.permissionLevel);
750
- }
751
- async invoke(invocation, _countTokens, _progress, token) {
752
- const toolSpecificData = invocation.toolSpecificData;
753
- if (!toolSpecificData) {
754
- throw ( new Error("toolSpecificData must be provided for this tool"));
755
- }
756
- if (!invocation.context) {
757
- throw ( new Error("Invocation context must be provided for this tool"));
758
- }
759
- const commandId = toolSpecificData.terminalCommandId;
760
- if (toolSpecificData.alternativeRecommendation) {
761
- return {
762
- content: [{
763
- kind: "text",
764
- value: toolSpecificData.alternativeRecommendation
765
- }]
766
- };
767
- }
768
- if (toolSpecificData.missingSandboxDependencies?.length) {
769
- const installButton = ( localize(13915, "Install"));
770
- if (invocation.selectedCustomButton === installButton) {
771
- const sessionResource = invocation.context.sessionResource;
772
- const {
773
- exitCode
774
- } = await this._terminalSandboxService.installMissingSandboxDependencies(toolSpecificData.missingSandboxDependencies, sessionResource, token, {
775
- createTerminal: async () => this._terminalService.createTerminal({}),
776
- focusTerminal: async terminal => {
777
- this._terminalService.setActiveInstance(terminal);
778
- await this._terminalService.revealTerminal(terminal, true);
779
- terminal.focus();
780
- }
781
- });
782
- if (exitCode !== undefined && exitCode !== 0) {
783
- return {
784
- content: [{
785
- kind: "text",
786
- value: ( localize(
787
- 13938,
788
- "Sandbox dependency installation failed (exit code {0}). The command was not executed.",
789
- exitCode
790
- ))
791
- }]
792
- };
793
- }
794
- if (exitCode === undefined) {
795
- return {
796
- content: [{
797
- kind: "text",
798
- value: ( localize(
799
- 13939,
800
- "Could not determine whether sandbox dependency installation succeeded. The command was not executed."
801
- ))
802
- }]
803
- };
804
- }
805
- this._logService.info(
806
- "RunInTerminalTool: Sandbox dependency installation succeeded, proceeding with command execution"
807
- );
808
- } else {
809
- this._logService.info("RunInTerminalTool: User cancelled sandbox dependency installation");
810
- return {
811
- content: [{
812
- kind: "text",
813
- value: ( localize(13940, "Sandbox dependency installation was cancelled by the user."))
814
- }]
815
- };
816
- }
817
- }
818
- const args = invocation.parameters;
819
- this._logService.debug(`RunInTerminalTool: Invoking with options ${JSON.stringify(args)}`);
820
- let toolResultMessage;
821
- const chatSessionResource = invocation.context.sessionResource;
822
- const command = toolSpecificData.commandLine.userEdited ?? toolSpecificData.commandLine.toolEdited ?? toolSpecificData.commandLine.original;
823
- const didUserEditCommand = (toolSpecificData.commandLine.userEdited !== undefined && toolSpecificData.commandLine.userEdited !== toolSpecificData.commandLine.original);
824
- const didToolEditCommand = (!didUserEditCommand && toolSpecificData.commandLine.toolEdited !== undefined && toolSpecificData.commandLine.toolEdited !== toolSpecificData.commandLine.original &&
825
- normalizeTerminalCommandForDisplay(toolSpecificData.commandLine.toolEdited).trim() !== normalizeTerminalCommandForDisplay(toolSpecificData.commandLine.original).trim());
826
- const didSandboxWrapCommand = toolSpecificData.commandLine.isSandboxWrapped === true;
827
- if (token.isCancellationRequested) {
828
- throw ( new CancellationError());
829
- }
830
- let error;
831
- const isNewSession = !args.isBackground && !( this._sessionTerminalAssociations.has(chatSessionResource));
832
- const timingStart = Date.now();
833
- const termId = generateUuid();
834
- const terminalToolSessionId = toolSpecificData.terminalToolSessionId;
835
- const store = ( new DisposableStore());
836
- this._logService.debug(
837
- `RunInTerminalTool: Creating ${args.isBackground ? "background" : "foreground"} terminal. termId=${termId}, chatSessionResource=${chatSessionResource}`
838
- );
839
- const toolTerminal = await this._initTerminal(
840
- chatSessionResource,
841
- termId,
842
- terminalToolSessionId,
843
- args.isBackground,
844
- token
845
- );
846
- this._handleTerminalVisibility(toolTerminal, chatSessionResource);
847
- const timingConnectMs = Date.now() - timingStart;
848
- const xterm = await toolTerminal.instance.xtermReadyPromise;
849
- if (!xterm) {
850
- throw ( new Error("Instance was disposed before xterm.js was ready"));
851
- }
852
- const commandDetection = toolTerminal.instance.capabilities.get(TerminalCapability.CommandDetection);
853
- let inputUserChars = 0;
854
- let inputUserSigint = false;
855
- store.add(xterm.raw.onData(data => {
856
- if (!telemetryIgnoredSequences.includes(data)) {
857
- inputUserChars += data.length;
858
- }
859
- inputUserSigint ||= data === "\u0003";
860
- }));
861
- let terminalResult = "";
862
- let outputLineCount = -1;
863
- let exitCode;
864
- let altBufferResult;
865
- let didTimeout = false;
866
- let didMoveToBackground = args.isBackground;
867
- let timeoutPromise;
868
- let timeoutRacePromise;
869
- let outputMonitor;
870
- let pollingResult;
871
- const executeCancellation = store.add(( new CancellationTokenSource(token)));
872
- const timeoutValue = args.timeout !== undefined ? clamp(args.timeout, 0, Number.MAX_SAFE_INTEGER) : undefined;
873
- if (!args.isBackground && timeoutValue !== undefined && timeoutValue > 0) {
874
- const shouldEnforceTimeout = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnforceTimeoutFromModel) === true;
875
- if (shouldEnforceTimeout) {
876
- timeoutPromise = timeout(timeoutValue);
877
- timeoutRacePromise = timeoutPromise.then(() => ({
878
- type: "timeout"
879
- })).catch(() => ({
880
- type: "timeout"
881
- }));
882
- }
883
- }
884
- let continueInBackgroundResolve;
885
- const continueInBackgroundPromise = ( new Promise(resolve => {
886
- continueInBackgroundResolve = resolve;
887
- }));
888
- if (terminalToolSessionId) {
889
- store.add(this._terminalChatService.onDidContinueInBackground(sessionId => {
890
- if (sessionId === terminalToolSessionId) {
891
- const execution = RunInTerminalTool_1._activeExecutions.get(termId);
892
- if (execution) {
893
- execution.setBackground();
894
- }
895
- didMoveToBackground = true;
896
- continueInBackgroundResolve?.();
897
- }
898
- }));
899
- }
900
- let executionPromise;
901
- try {
902
- const execution = this._instantiationService.createInstance(
903
- ActiveTerminalExecution,
904
- chatSessionResource,
905
- termId,
906
- toolTerminal,
907
- commandDetection,
908
- args.isBackground
909
- );
910
- if (toolTerminal.shellIntegrationQuality === ShellIntegrationQuality.None) {
911
- toolResultMessage = "$(info) Enable [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration) to improve command detection";
912
- }
913
- this._logService.info(
914
- `RunInTerminalTool: Using \`${execution.strategy.type}\` execute strategy for command \`${command}\``
915
- );
916
- store.add(execution);
917
- RunInTerminalTool_1._activeExecutions.set(termId, execution);
918
- const startMarkerPromise = Event.toPromise(execution.strategy.onDidCreateStartMarker);
919
- store.add(execution.strategy.onDidCreateStartMarker(startMarker => {
920
- if (!outputMonitor) {
921
- outputMonitor = store.add(this._instantiationService.createInstance(OutputMonitor, {
922
- instance: toolTerminal.instance,
923
- sessionResource: chatSessionResource,
924
- getOutput: marker => execution.getOutput(marker ?? startMarker)
925
- }, undefined, invocation.context, token, command));
926
- }
927
- }));
928
- executionPromise = execution.start(command, executeCancellation.token, commandId);
929
- if (args.isBackground) {
930
- this._logService.debug(`RunInTerminalTool: Starting background execution \`${command}\``);
931
- await startMarkerPromise;
932
- if (outputMonitor) {
933
- await Event.toPromise(outputMonitor.onDidFinishCommand);
934
- pollingResult = outputMonitor.pollingResult;
935
- }
936
- await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
937
- if (token.isCancellationRequested) {
938
- throw ( new CancellationError());
939
- }
940
- const state = toolSpecificData.terminalCommandState ?? {};
941
- state.timestamp = state.timestamp ?? timingStart;
942
- toolSpecificData.terminalCommandState = state;
943
- let resultText = (didSandboxWrapCommand ? `Command is now running in terminal with ID=${termId}` : 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}`);
944
- const backgroundOutput = pollingResult?.modelOutputEvalResponse ?? pollingResult?.output;
945
- const outputAnalyzerMessage = backgroundOutput ? await this._getOutputAnalyzerMessage(undefined, backgroundOutput, command, didSandboxWrapCommand) : undefined;
946
- if (pollingResult && pollingResult.modelOutputEvalResponse) {
947
- resultText += `\n\ The command became idle with output:\n`;
948
- if (outputAnalyzerMessage) {
949
- resultText += `${outputAnalyzerMessage}\n`;
950
- }
951
- resultText += pollingResult.modelOutputEvalResponse;
952
- } else if (pollingResult) {
953
- resultText += `\n\ The command is still running, with output:\n`;
954
- if (outputAnalyzerMessage) {
955
- resultText += `${outputAnalyzerMessage}\n`;
956
- }
957
- resultText += pollingResult.output;
958
- }
959
- const endCwd = await toolTerminal.instance.getCwdResource();
960
- return {
961
- toolMetadata: {
962
- exitCode: undefined,
963
- id: termId,
964
- cwd: endCwd?.toString()
965
- },
966
- content: [{
967
- kind: "text",
968
- value: resultText
969
- }]
970
- };
971
- } else {
972
- const raceCandidates = [executionPromise.then(result => ({
973
- type: "completed",
974
- result
975
- })), continueInBackgroundPromise.then(() => ({
976
- type: "background"
977
- }))];
978
- if (timeoutRacePromise) {
979
- raceCandidates.push(timeoutRacePromise);
980
- }
981
- const raceResult = await Promise.race(raceCandidates);
982
- if (raceResult.type === "background") {
983
- this._logService.debug(
984
- `RunInTerminalTool: Continue in background triggered, returning output collected so far`
985
- );
986
- error = "continueInBackground";
987
- const backgroundOutput = execution.getOutput();
988
- outputLineCount = backgroundOutput ? count(backgroundOutput.trim(), "\n") + 1 : 0;
989
- terminalResult = backgroundOutput;
990
- } else if (raceResult.type === "timeout") {
991
- this._logService.debug(`RunInTerminalTool: Timeout reached, returning output collected so far`);
992
- error = "timeout";
993
- didTimeout = true;
994
- didMoveToBackground = true;
995
- toolTerminal.isBackground = true;
996
- this._sessionTerminalAssociations.delete(chatSessionResource);
997
- await this._associateProcessIdWithSession(
998
- toolTerminal.instance,
999
- chatSessionResource,
1000
- termId,
1001
- toolTerminal.shellIntegrationQuality,
1002
- true
1003
- );
1004
- const timeoutOutput = execution.getOutput();
1005
- outputLineCount = timeoutOutput ? count(timeoutOutput.trim(), "\n") + 1 : 0;
1006
- terminalResult = timeoutOutput ?? "";
1007
- } else {
1008
- const executeResult = raceResult.result;
1009
- toolTerminal.receivedUserInput = false;
1010
- if (token.isCancellationRequested) {
1011
- throw ( new CancellationError());
1012
- }
1013
- if (executeResult.didEnterAltBuffer) {
1014
- const state = toolSpecificData.terminalCommandState ?? {};
1015
- state.timestamp = state.timestamp ?? timingStart;
1016
- toolSpecificData.terminalCommandState = state;
1017
- toolResultMessage = altBufferMessage;
1018
- outputLineCount = 0;
1019
- error = executeResult.error ?? "alternateBuffer";
1020
- const altBufferCwd = await toolTerminal.instance.getCwdResource();
1021
- altBufferResult = {
1022
- toolResultMessage,
1023
- toolMetadata: {
1024
- exitCode: undefined,
1025
- id: termId,
1026
- cwd: altBufferCwd?.toString()
1027
- },
1028
- content: [{
1029
- kind: "text",
1030
- value: altBufferMessage
1031
- }]
1032
- };
1033
- } else {
1034
- await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
1035
- {
1036
- const state = toolSpecificData.terminalCommandState ?? {};
1037
- state.timestamp = state.timestamp ?? timingStart;
1038
- if (executeResult.exitCode !== undefined) {
1039
- state.exitCode = executeResult.exitCode;
1040
- if (state.timestamp !== undefined) {
1041
- state.duration = state.duration ?? Math.max(0, Date.now() - state.timestamp);
1042
- }
1043
- }
1044
- toolSpecificData.terminalCommandState = state;
1045
- }
1046
- this._logService.info(
1047
- `RunInTerminalTool: Finished \`${execution.strategy.type}\` execute strategy with exitCode \`${executeResult.exitCode}\`, result.length \`${executeResult.output?.length}\`, error \`${executeResult.error}\``
1048
- );
1049
- outputLineCount = executeResult.output === undefined ? 0 : count(executeResult.output.trim(), "\n") + 1;
1050
- exitCode = executeResult.exitCode;
1051
- error = executeResult.error;
1052
- const resultArr = [];
1053
- if (executeResult.output !== undefined) {
1054
- resultArr.push(executeResult.output);
1055
- }
1056
- if (executeResult.additionalInformation) {
1057
- resultArr.push(executeResult.additionalInformation);
1058
- }
1059
- terminalResult = resultArr.join("\n\n");
1060
- }
1061
- }
1062
- }
1063
- } catch (e) {
1064
- if (didTimeout && e instanceof CancellationError) {
1065
- this._logService.debug(`RunInTerminalTool: Timeout reached, returning output collected so far`);
1066
- error = "timeout";
1067
- didMoveToBackground = true;
1068
- toolTerminal.isBackground = true;
1069
- this._sessionTerminalAssociations.delete(chatSessionResource);
1070
- const timeoutOutput = getOutput(toolTerminal.instance, undefined);
1071
- outputLineCount = timeoutOutput ? count(timeoutOutput.trim(), "\n") + 1 : 0;
1072
- terminalResult = timeoutOutput ?? "";
1073
- } else {
1074
- this._logService.debug(`RunInTerminalTool: Threw exception`);
1075
- if (e instanceof CancellationError) {
1076
- await this._commandArtifactCollector.capture(toolSpecificData, toolTerminal.instance, commandId);
1077
- const state = toolSpecificData.terminalCommandState ?? {};
1078
- if (state.exitCode === undefined) {
1079
- state.exitCode = -1;
1080
- state.timestamp = state.timestamp ?? timingStart;
1081
- state.duration = state.duration ?? Math.max(0, Date.now() - state.timestamp);
1082
- }
1083
- toolSpecificData.terminalCommandState = state;
1084
- }
1085
- RunInTerminalTool_1._activeExecutions.get(termId)?.dispose();
1086
- RunInTerminalTool_1._activeExecutions.delete(termId);
1087
- toolTerminal.instance.dispose();
1088
- error = e instanceof CancellationError ? "canceled" : "unexpectedException";
1089
- throw e;
1090
- }
1091
- } finally {
1092
- timeoutPromise?.cancel();
1093
- if (didMoveToBackground && executionPromise) {
1094
- executionPromise.catch(e => {
1095
- if (!(e instanceof CancellationError)) {
1096
- this._logService.error(`RunInTerminalTool: Background execution error`, e);
1097
- }
1098
- });
1099
- } else {
1100
- RunInTerminalTool_1._activeExecutions.get(termId)?.dispose();
1101
- RunInTerminalTool_1._activeExecutions.delete(termId);
1102
- }
1103
- store.dispose();
1104
- const timingExecuteMs = Date.now() - timingStart;
1105
- this._telemetry.logInvoke(toolTerminal.instance, {
1106
- terminalToolSessionId: toolSpecificData.terminalToolSessionId,
1107
- didUserEditCommand,
1108
- didToolEditCommand,
1109
- isBackground: args.isBackground,
1110
- isSandboxWrapped: toolSpecificData.commandLine.isSandboxWrapped === true,
1111
- shellIntegrationQuality: toolTerminal.shellIntegrationQuality,
1112
- error,
1113
- isNewSession,
1114
- outputLineCount,
1115
- exitCode,
1116
- timingExecuteMs,
1117
- timingConnectMs,
1118
- inputUserChars,
1119
- inputUserSigint,
1120
- terminalExecutionIdleBeforeTimeout: pollingResult?.state === OutputMonitorState.Idle,
1121
- pollDurationMs: pollingResult?.pollDurationMs,
1122
- inputToolManualAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualAcceptCount,
1123
- inputToolManualRejectCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualRejectCount,
1124
- inputToolManualChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualChars,
1125
- inputToolAutoAcceptCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoAcceptCount,
1126
- inputToolAutoChars: outputMonitor?.outputMonitorTelemetryCounters?.inputToolAutoChars,
1127
- inputToolManualShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolManualShownCount,
1128
- inputToolFreeFormInputCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputCount,
1129
- inputToolFreeFormInputShownCount: outputMonitor?.outputMonitorTelemetryCounters?.inputToolFreeFormInputShownCount
1130
- });
1131
- }
1132
- if (altBufferResult) {
1133
- return altBufferResult;
1134
- }
1135
- const resultText = [];
1136
- if (!didSandboxWrapCommand) {
1137
- if (didUserEditCommand) {
1138
- resultText.push(
1139
- `Note: The user manually edited the command to \`${command}\`, and this is the output of running that command instead:\n`
1140
- );
1141
- } else if (didToolEditCommand) {
1142
- resultText.push(
1143
- `Note: The tool simplified the command to \`${command}\`, and this is the output of running that command instead:\n`
1144
- );
1145
- }
1146
- if (didMoveToBackground && !args.isBackground) {
1147
- resultText.push(
1148
- `Note: This terminal execution was moved to the background using the ID ${termId}\n`
1149
- );
1150
- }
1151
- }
1152
- if (didTimeout && timeoutValue !== undefined && timeoutValue > 0) {
1153
- resultText.push(
1154
- `Note: Command timed out after ${timeoutValue}ms and was moved to the background. The command may still be running in terminal ID ${termId}. Use ${TerminalToolId.AwaitTerminal} to wait for it to complete or ${TerminalToolId.GetTerminalOutput} to check its current output. Do NOT use sleep or manual polling to wait.\n\n`
1155
- );
1156
- }
1157
- const outputAnalyzerMessage = await this._getOutputAnalyzerMessage(exitCode, terminalResult, command, didSandboxWrapCommand);
1158
- if (outputAnalyzerMessage) {
1159
- resultText.push(`${outputAnalyzerMessage}\n`);
1160
- }
1161
- resultText.push(terminalResult);
1162
- const isError = exitCode !== undefined && exitCode !== 0;
1163
- const endCwd = await toolTerminal.instance.getCwdResource();
1164
- const imageContent = await this._extractImagesFromOutput(terminalResult, endCwd);
1165
- return {
1166
- toolResultMessage,
1167
- toolMetadata: {
1168
- exitCode: exitCode,
1169
- id: termId,
1170
- cwd: endCwd?.toString(),
1171
- timedOut: didTimeout || undefined,
1172
- timeoutMs: didTimeout ? timeoutValue : undefined
1173
- },
1174
- toolResultDetails: isError ? {
1175
- input: command,
1176
- output: [{
1177
- type: "embed",
1178
- isText: true,
1179
- value: terminalResult
1180
- }],
1181
- isError: true
1182
- } : undefined,
1183
- content: [{
1184
- kind: "text",
1185
- value: resultText.join("")
1186
- }, ...imageContent]
1187
- };
1188
- }
1189
- async _getOutputAnalyzerMessage(exitCode, exitResult, commandLine, isSandboxWrapped) {
1190
- for (const analyzer of this._outputAnalyzers) {
1191
- const message = await analyzer.analyze({
1192
- exitCode,
1193
- exitResult,
1194
- commandLine,
1195
- isSandboxWrapped
1196
- });
1197
- if (message) {
1198
- return message;
1199
- }
1200
- }
1201
- return undefined;
1202
- }
1203
- static {
1204
- this._maxImageFileSize = 5 * 1024 * 1024;
1205
- }
1206
- async _extractImagesFromOutput(output, cwd) {
1207
- const normalizedOutput = output.replace(/\r?\n/g, "");
1208
- const pathPattern = /(?:[^\s]*[\/\\][^\s]*\.(?:png|jpe?g|gif|webp|bmp))/gi;
1209
- const matches = ( new Set());
1210
- for (const match of normalizedOutput.matchAll(pathPattern)) {
1211
- matches.add(match[0]);
1212
- }
1213
- if (matches.size === 0) {
1214
- return [];
1215
- }
1216
- const results = [];
1217
- for (const filePath of matches) {
1218
- try {
1219
- const mimeType = getMediaMime(filePath);
1220
- if (!mimeType || !mimeType.startsWith("image/")) {
1221
- continue;
1222
- }
1223
- let fileUri;
1224
- if (/^\/|^[A-Za-z]:[\\\/]/.test(filePath)) {
1225
- fileUri = URI.file(filePath);
1226
- } else if (cwd) {
1227
- fileUri = URI.joinPath(cwd, filePath);
1228
- } else {
1229
- continue;
1230
- }
1231
- const stat = await this._fileService.stat(fileUri).catch(() => undefined);
1232
- if (!stat || stat.isDirectory || stat.size > RunInTerminalTool_1._maxImageFileSize) {
1233
- continue;
1234
- }
1235
- const fileContent = await this._fileService.readFile(fileUri);
1236
- results.push({
1237
- kind: "data",
1238
- value: {
1239
- mimeType,
1240
- data: fileContent.value
1241
- },
1242
- audience: [LanguageModelPartAudience.User]
1243
- });
1244
- } catch {}
1245
- }
1246
- return results;
1247
- }
1248
- _handleTerminalVisibility(toolTerminal, chatSessionResource) {
1249
- const chatSessionOpenInWidget = !!this._chatWidgetService.getWidgetBySessionResource(chatSessionResource);
1250
- if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.OutputLocation) === "terminal" && chatSessionOpenInWidget) {
1251
- this._terminalService.setActiveInstance(toolTerminal.instance);
1252
- this._terminalService.revealTerminal(toolTerminal.instance, true);
1253
- }
1254
- }
1255
- async _initTerminal(chatSessionResource, termId, terminalToolSessionId, isBackground, token) {
1256
- if (!isBackground) {
1257
- const cachedTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
1258
- if (cachedTerminal && !cachedTerminal.isBackground) {
1259
- this._logService.debug(
1260
- `RunInTerminalTool: Using cached terminal with session resource \`${chatSessionResource}\``
1261
- );
1262
- this._terminalToolCreator.refreshShellIntegrationQuality(cachedTerminal);
1263
- this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, cachedTerminal.instance);
1264
- return cachedTerminal;
1265
- }
1266
- }
1267
- this._logService.debug(
1268
- `RunInTerminalTool: Creating ${isBackground ? "background" : "foreground"} terminal with ID=${termId}`
1269
- );
1270
- const profile = await this._profileFetcher.getCopilotProfile();
1271
- const os = await this._osBackend;
1272
- const toolTerminal = await this._terminalToolCreator.createTerminal(profile, os, token);
1273
- toolTerminal.isBackground = isBackground;
1274
- this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, toolTerminal.instance);
1275
- this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionResource, toolTerminal.instance);
1276
- this._registerInputListener(toolTerminal);
1277
- this._addSessionTerminalAssociation(chatSessionResource, toolTerminal);
1278
- if (token.isCancellationRequested) {
1279
- toolTerminal.instance.dispose();
1280
- throw ( new CancellationError());
1281
- }
1282
- await this._setupProcessIdAssociation(toolTerminal, chatSessionResource, termId, isBackground);
1283
- return toolTerminal;
1284
- }
1285
- _registerInputListener(toolTerminal) {
1286
- const disposable = toolTerminal.instance.onData(data => {
1287
- if (!telemetryIgnoredSequences.includes(data)) {
1288
- toolTerminal.receivedUserInput = data.length > 0;
1289
- }
1290
- });
1291
- this._register(toolTerminal.instance.onDisposed(() => disposable.dispose()));
1292
- }
1293
- _restoreTerminalAssociations() {
1294
- const storedAssociations = this._storageService.get(
1295
- TerminalToolStorageKeysInternal.TerminalSession,
1296
- StorageScope.WORKSPACE,
1297
- "{}"
1298
- );
1299
- try {
1300
- const associations = JSON.parse(storedAssociations);
1301
- for (const instance of this._terminalService.instances) {
1302
- if (instance.processId) {
1303
- const association = associations[instance.processId];
1304
- if (association) {
1305
- const chatSessionResource = LocalChatSessionUri.forSession(association.sessionId);
1306
- this._logService.debug(
1307
- `RunInTerminalTool: Restored terminal association for PID ${instance.processId}, session ${association.sessionId}`
1308
- );
1309
- const toolTerminal = {
1310
- instance,
1311
- shellIntegrationQuality: association.shellIntegrationQuality,
1312
- isBackground: association.isBackground
1313
- };
1314
- this._addSessionTerminalAssociation(chatSessionResource, toolTerminal);
1315
- this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionResource, instance);
1316
- this._register(instance.onDisposed(() => {
1317
- this._removeProcessIdAssociation(instance.processId);
1318
- }));
1319
- }
1320
- }
1321
- }
1322
- } catch (error) {
1323
- this._logService.debug(`RunInTerminalTool: Failed to restore terminal associations: ${error}`);
1324
- }
1325
- }
1326
- async _setupProcessIdAssociation(toolTerminal, chatSessionResource, termId, isBackground) {
1327
- await this._associateProcessIdWithSession(
1328
- toolTerminal.instance,
1329
- chatSessionResource,
1330
- termId,
1331
- toolTerminal.shellIntegrationQuality,
1332
- isBackground
1333
- );
1334
- this._register(toolTerminal.instance.onDisposed(() => {
1335
- if (toolTerminal.instance.processId) {
1336
- this._removeProcessIdAssociation(toolTerminal.instance.processId);
1337
- }
1338
- }));
1339
- }
1340
- async _associateProcessIdWithSession(terminal, chatSessionResource, id, shellIntegrationQuality, isBackground) {
1341
- try {
1342
- const pid = await Promise.race([
1343
- terminal.processReady.then(() => terminal.processId),
1344
- timeout(5000).then(() => {
1345
- throw ( new Error("Timeout"));
1346
- })
1347
- ]);
1348
- if (isNumber(pid)) {
1349
- const storedAssociations = this._storageService.get(
1350
- TerminalToolStorageKeysInternal.TerminalSession,
1351
- StorageScope.WORKSPACE,
1352
- "{}"
1353
- );
1354
- const associations = JSON.parse(storedAssociations);
1355
- const sessionId = chatSessionResourceToId(chatSessionResource);
1356
- const existingAssociation = associations[pid] || {};
1357
- associations[pid] = {
1358
- ...existingAssociation,
1359
- sessionId,
1360
- shellIntegrationQuality,
1361
- id,
1362
- isBackground
1363
- };
1364
- this._storageService.store(
1365
- TerminalToolStorageKeysInternal.TerminalSession,
1366
- JSON.stringify(associations),
1367
- StorageScope.WORKSPACE,
1368
- StorageTarget.USER
1369
- );
1370
- this._logService.debug(
1371
- `RunInTerminalTool: Associated terminal PID ${pid} with session ${sessionId}`
1372
- );
1373
- }
1374
- } catch (error) {
1375
- this._logService.debug(`RunInTerminalTool: Failed to associate terminal with session: ${error}`);
1376
- }
1377
- }
1378
- async _removeProcessIdAssociation(pid) {
1379
- try {
1380
- const storedAssociations = this._storageService.get(
1381
- TerminalToolStorageKeysInternal.TerminalSession,
1382
- StorageScope.WORKSPACE,
1383
- "{}"
1384
- );
1385
- const associations = JSON.parse(storedAssociations);
1386
- if (associations[pid]) {
1387
- delete associations[pid];
1388
- this._storageService.store(
1389
- TerminalToolStorageKeysInternal.TerminalSession,
1390
- JSON.stringify(associations),
1391
- StorageScope.WORKSPACE,
1392
- StorageTarget.USER
1393
- );
1394
- this._logService.debug(`RunInTerminalTool: Removed terminal association for PID ${pid}`);
1395
- }
1396
- } catch (error) {
1397
- this._logService.debug(`RunInTerminalTool: Failed to remove terminal association: ${error}`);
1398
- }
1399
- }
1400
- _cleanupSessionTerminals(chatSessionResource) {
1401
- const sessionTerminals = this._sessionTerminalInstances.get(chatSessionResource);
1402
- const toolTerminal = this._sessionTerminalAssociations.get(chatSessionResource);
1403
- const terminalsToDispose = sessionTerminals ?? (toolTerminal ? ( new Set([toolTerminal.instance])) : undefined);
1404
- if (!terminalsToDispose || terminalsToDispose.size === 0) {
1405
- return;
1406
- }
1407
- this._logService.debug(
1408
- `RunInTerminalTool: Cleaning up ${terminalsToDispose.size} terminal(s) for ended chat session ${chatSessionResource}`
1409
- );
1410
- this._sessionTerminalAssociations.delete(chatSessionResource);
1411
- this._sessionTerminalInstances.delete(chatSessionResource);
1412
- for (const terminal of terminalsToDispose) {
1413
- this._terminalsBeingDisposedBySessionCleanup.add(terminal);
1414
- terminal.dispose();
1415
- }
1416
- const terminalToRemove = [];
1417
- for (const [termId, execution] of RunInTerminalTool_1._activeExecutions.entries()) {
1418
- if (( terminalsToDispose.has(execution.instance))) {
1419
- execution.dispose();
1420
- terminalToRemove.push(termId);
1421
- }
1422
- }
1423
- for (const termId of terminalToRemove) {
1424
- RunInTerminalTool_1._activeExecutions.delete(termId);
1425
- }
1426
- }
1427
- _addSessionTerminalAssociation(chatSessionResource, toolTerminal) {
1428
- this._ensureArchivedSessionListener();
1429
- let sessionTerminals = this._sessionTerminalInstances.get(chatSessionResource);
1430
- if (!sessionTerminals) {
1431
- sessionTerminals = ( new Set());
1432
- this._sessionTerminalInstances.set(chatSessionResource, sessionTerminals);
1433
- }
1434
- sessionTerminals.add(toolTerminal.instance);
1435
- if (!toolTerminal.isBackground) {
1436
- this._sessionTerminalAssociations.set(chatSessionResource, toolTerminal);
1437
- }
1438
- }
1439
- _ensureArchivedSessionListener() {
1440
- if (this._archivedSessionListener.value) {
1441
- return;
1442
- }
1443
- this._archivedSessionListener.value = this._agentSessionsService.onDidChangeSessionArchivedState(session => {
1444
- if (session.isArchived()) {
1445
- this._cleanupSessionTerminals(session.resource);
1446
- }
1447
- });
1448
- }
1449
- _removeTerminalAssociations(terminal) {
1450
- if (this._terminalsBeingDisposedBySessionCleanup.delete(terminal)) {
1451
- return;
1452
- }
1453
- for (const [sessionResource, toolTerminal] of this._sessionTerminalAssociations.entries()) {
1454
- if (terminal === toolTerminal.instance) {
1455
- this._sessionTerminalAssociations.delete(sessionResource);
1456
- }
1457
- }
1458
- for (const [sessionResource, sessionTerminals] of this._sessionTerminalInstances.entries()) {
1459
- if (!sessionTerminals.delete(terminal)) {
1460
- continue;
1461
- }
1462
- if (sessionTerminals.size === 0) {
1463
- this._sessionTerminalInstances.delete(sessionResource);
1464
- }
1465
- }
1466
- }
1467
- };
1468
- RunInTerminalTool = RunInTerminalTool_1 = ( __decorate([( __param(0, IChatService)), ( __param(1, IConfigurationService)), ( __param(2, IFileService)), ( __param(3, IHistoryService)), ( __param(4, IInstantiationService)), ( __param(5, ILabelService)), ( __param(6, ILanguageModelToolsService)), ( __param(7, IRemoteAgentService)), ( __param(8, IStorageService)), ( __param(9, ITerminalChatService)), ( __param(10, ITerminalLogService)), ( __param(11, ITerminalService)), ( __param(12, ITerminalSandboxService)), ( __param(13, IWorkspaceContextService)), ( __param(14, IChatWidgetService)), ( __param(15, IAgentSessionsService))], RunInTerminalTool));
1469
- let ActiveTerminalExecution = class ActiveTerminalExecution extends Disposable {
1470
- get completionPromise() {
1471
- return this._completionDeferred.p;
1472
- }
1473
- get isBackground() {
1474
- return this._isBackground;
1475
- }
1476
- get startMarker() {
1477
- return this._startMarker;
1478
- }
1479
- get instance() {
1480
- return this._toolTerminal.instance;
1481
- }
1482
- constructor(
1483
- sessionResource,
1484
- termId,
1485
- toolTerminal,
1486
- commandDetection,
1487
- isBackground,
1488
- _instantiationService
1489
- ) {
1490
- super();
1491
- this.sessionResource = sessionResource;
1492
- this.termId = termId;
1493
- this._instantiationService = _instantiationService;
1494
- this._toolTerminal = toolTerminal;
1495
- this._isBackground = isBackground;
1496
- this._completionDeferred = ( new DeferredPromise());
1497
- this.strategy = this._register(this._createStrategy(commandDetection));
1498
- this._register(this.strategy.onDidCreateStartMarker(marker => {
1499
- if (marker) {
1500
- this._startMarker = marker;
1501
- }
1502
- }));
1503
- }
1504
- _createStrategy(commandDetection) {
1505
- switch (this._toolTerminal.shellIntegrationQuality) {
1506
- case ShellIntegrationQuality.None:
1507
- return this._instantiationService.createInstance(
1508
- NoneExecuteStrategy,
1509
- this._toolTerminal.instance,
1510
- () => this._toolTerminal.receivedUserInput ?? false
1511
- );
1512
- case ShellIntegrationQuality.Basic:
1513
- return this._instantiationService.createInstance(
1514
- BasicExecuteStrategy,
1515
- this._toolTerminal.instance,
1516
- () => this._toolTerminal.receivedUserInput ?? false,
1517
- commandDetection
1518
- );
1519
- case ShellIntegrationQuality.Rich:
1520
- return this._instantiationService.createInstance(RichExecuteStrategy, this._toolTerminal.instance, commandDetection);
1521
- }
1522
- }
1523
- async start(commandLine, token, commandId) {
1524
- try {
1525
- const result = await this.strategy.execute(commandLine, token, commandId);
1526
- this._completionDeferred.complete(result);
1527
- return result;
1528
- } catch (e) {
1529
- this._completionDeferred.error(e);
1530
- throw e;
1531
- }
1532
- }
1533
- setForeground() {
1534
- this._isBackground = false;
1535
- }
1536
- setBackground() {
1537
- this._isBackground = true;
1538
- }
1539
- getOutput(marker) {
1540
- return getOutput(this.instance, marker ?? this._startMarker);
1541
- }
1542
- };
1543
- ActiveTerminalExecution = ( __decorate([( __param(5, IInstantiationService))], ActiveTerminalExecution));
1544
- let TerminalProfileFetcher = class TerminalProfileFetcher {
1545
- constructor(
1546
- _configurationService,
1547
- _terminalProfileResolverService,
1548
- _remoteAgentService
1549
- ) {
1550
- this._configurationService = _configurationService;
1551
- this._terminalProfileResolverService = _terminalProfileResolverService;
1552
- this._remoteAgentService = _remoteAgentService;
1553
- this.osBackend = this._remoteAgentService.getEnvironment().then(remoteEnv => remoteEnv?.os ?? OS);
1554
- }
1555
- async getCopilotProfile() {
1556
- const os = await this.osBackend;
1557
- const customChatAgentProfile = this._getChatTerminalProfile(os);
1558
- if (customChatAgentProfile) {
1559
- return customChatAgentProfile;
1560
- }
1561
- const defaultProfile = await this._terminalProfileResolverService.getDefaultProfile({
1562
- os,
1563
- remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority
1564
- });
1565
- if (basename(defaultProfile.path) === "cmd.exe") {
1566
- return {
1567
- ...defaultProfile,
1568
- path: "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
1569
- profileName: "PowerShell"
1570
- };
1571
- }
1572
- if (defaultProfile.path === "/bin/sh") {
1573
- return {
1574
- ...defaultProfile,
1575
- path: "/bin/bash",
1576
- profileName: "bash"
1577
- };
1578
- }
1579
- return {
1580
- ...defaultProfile,
1581
- icon: undefined
1582
- };
1583
- }
1584
- async getCopilotShell() {
1585
- return (await this.getCopilotProfile()).path;
1586
- }
1587
- _getChatTerminalProfile(os) {
1588
- let profileSetting;
1589
- switch (os) {
1590
- case OperatingSystem.Windows:
1591
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileWindows;
1592
- break;
1593
- case OperatingSystem.Macintosh:
1594
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileMacOs;
1595
- break;
1596
- case OperatingSystem.Linux:
1597
- default:
1598
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileLinux;
1599
- break;
1600
- }
1601
- const profile = this._configurationService.getValue(profileSetting);
1602
- if (this._isValidChatAgentTerminalProfile(profile)) {
1603
- return profile;
1604
- }
1605
- return undefined;
1606
- }
1607
- _isValidChatAgentTerminalProfile(profile) {
1608
- if (profile === null || profile === undefined || typeof profile !== "object") {
1609
- return false;
1610
- }
1611
- if ("path" in profile && isString(profile.path)) {
1612
- return true;
1613
- }
1614
- return false;
1615
- }
1616
- };
1617
- TerminalProfileFetcher = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, ITerminalProfileResolverService)), ( __param(2, IRemoteAgentService))], TerminalProfileFetcher));
1618
-
1619
- export { RunInTerminalTool, TerminalProfileFetcher, createRunInTerminalToolData };