@codingame/monaco-vscode-chat-service-override 25.1.2 → 26.0.0

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