@codingame/monaco-vscode-chat-service-override 22.1.9 → 23.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 (277) hide show
  1. package/index.js +17 -8
  2. package/package.json +43 -40
  3. package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +1 -1
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityActions.js +6 -6
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +57 -48
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +2 -2
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +19 -19
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +1 -1
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +26 -17
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +51 -5
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -2
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +2 -2
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +7 -7
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatLanguageModelActions.js +13 -13
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +19 -19
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/{chatClearActions.d.ts → chatNewActions.d.ts} +2 -1
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/{chatClearActions.js → chatNewActions.js} +32 -32
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatPromptNavigationActions.js +4 -4
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -9
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.d.ts +9 -9
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.js +101 -98
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.js +35 -24
  24. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.js +43 -25
  25. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +1 -1
  26. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +34 -33
  27. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionViewModel.d.ts +53 -0
  28. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionViewModel.js +154 -0
  29. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.d.ts +7 -0
  30. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessions.js +13 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.d.ts +44 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsView.js +347 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.d.ts +85 -0
  34. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.js +250 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/media/agentsessionsview.css +24 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/agentSessions/media/agentsessionsviewer.css +97 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +290 -231
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +2 -2
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +7 -10
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentResolveService.d.ts +1 -1
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentResolveService.js +6 -6
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +1 -1
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatContextService.d.ts +24 -0
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatContextService.js +113 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCheckpointTimeline.d.ts +31 -0
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCheckpointTimelineImpl.d.ts +102 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCheckpointTimelineImpl.js +646 -0
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +2 -3
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +46 -26
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +17 -4
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +44 -34
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +14 -14
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +25 -6
  54. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +46 -10
  55. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +45 -6
  56. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +30 -10
  57. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +10 -3
  58. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +60 -9
  59. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingOperations.d.ts +117 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingOperations.js +12 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +6 -4
  62. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +60 -55
  63. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +29 -16
  64. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +365 -143
  65. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.d.ts +2 -3
  66. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.js +3 -30
  67. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelChangeService.d.ts +7 -3
  68. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelChangeService.js +58 -22
  69. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +1 -1
  70. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +5 -4
  71. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +3 -3
  72. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +1 -1
  73. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +3 -3
  74. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +5 -5
  75. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +6 -18
  76. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +1 -3
  77. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +7 -11
  78. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.d.ts +1 -1
  79. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.js +13 -1
  80. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.js +38 -33
  81. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +11 -6
  82. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +83 -24
  83. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagement.contribution.d.ts +1 -0
  84. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagement.contribution.js +91 -0
  85. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.d.ts +64 -0
  86. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditor.js +370 -0
  87. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.d.ts +25 -0
  88. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatManagementEditorInput.js +56 -0
  89. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.d.ts +61 -0
  90. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsViewModel.js +349 -0
  91. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.d.ts +43 -0
  92. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatModelsWidget.js +787 -0
  93. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.d.ts +17 -0
  94. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/chatUsageWidget.js +109 -0
  95. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatManagementEditor.css +122 -0
  96. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatModelsWidget.css +211 -0
  97. package/vscode/src/vs/workbench/contrib/chat/browser/chatManagement/media/chatUsageWidget.css +69 -0
  98. package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.d.ts +1 -1
  99. package/vscode/src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.js +21 -20
  100. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +54 -54
  101. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
  102. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +31 -22
  103. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
  104. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +16 -6
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionTracker.d.ts +6 -3
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionTracker.js +29 -21
  107. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/localChatSessionsProvider.d.ts +5 -2
  108. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/localChatSessionsProvider.js +37 -33
  109. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/chatSessionsView.d.ts +15 -12
  110. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/chatSessionsView.js +96 -131
  111. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsTreeRenderer.d.ts +12 -7
  112. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsTreeRenderer.js +66 -34
  113. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.d.ts +5 -3
  114. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/view/sessionsViewPane.js +77 -71
  115. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.d.ts +91 -18
  116. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions.contribution.js +458 -138
  117. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +3 -1
  118. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +212 -150
  119. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +96 -89
  120. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +3 -2
  121. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +5 -5
  122. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +3 -4
  123. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +15 -16
  124. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
  125. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +33 -17
  126. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
  127. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +3 -3
  128. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsConfirmationService.d.ts +27 -0
  129. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsConfirmationService.js +688 -0
  130. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +15 -10
  131. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +126 -135
  132. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +6 -1
  133. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +2 -1
  134. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSessions.css +38 -1
  135. package/vscode/src/vs/workbench/contrib/chat/browser/media/simpleBrowserOverlay.css +14 -14
  136. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.d.ts +1 -1
  137. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/chatModeActions.js +28 -26
  138. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionContribution.js +1 -1
  139. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptCodingAgentActionOverlay.js +3 -3
  140. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptFileActions.js +9 -6
  141. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +24 -13
  142. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptUrlHandler.js +15 -14
  143. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/runPromptAction.js +25 -23
  144. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveAsPromptFileActions.d.ts +21 -0
  145. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveAsPromptFileActions.js +89 -0
  146. package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.js +16 -16
  147. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +30 -29
  148. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +10 -19
  149. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +61 -43
  150. package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.js +7 -4
  151. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +28 -28
  152. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +254 -165
  153. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.d.ts +4 -4
  154. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +2 -2
  155. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +1 -1
  156. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +4 -6
  157. package/vscode/src/vs/workbench/contrib/chat/common/chatTodoListService.d.ts +10 -6
  158. package/vscode/src/vs/workbench/contrib/chat/common/chatTodoListService.js +20 -12
  159. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/chatPromptFilesContribution.js +13 -17
  160. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/PromptHeaderDefinitionProvider.js +9 -8
  161. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptBodyAutocompletion.d.ts +1 -0
  162. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptBodyAutocompletion.js +51 -21
  163. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptCodeActions.d.ts +7 -3
  164. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptCodeActions.js +74 -20
  165. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptDocumentSemanticTokensProvider.js +11 -6
  166. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.d.ts +1 -2
  167. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHeaderAutocompletion.js +83 -53
  168. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHovers.d.ts +2 -1
  169. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptHovers.js +136 -78
  170. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptLinkProvider.js +4 -4
  171. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.d.ts +18 -10
  172. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageProviders/promptValidator.js +357 -157
  173. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/promptFileContributions.js +1 -1
  174. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.d.ts +55 -28
  175. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.js +235 -108
  176. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +12 -2
  177. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +50 -4
  178. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +27 -27
  179. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
  180. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  181. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/aiEditTelemetry/aiEditTelemetryServiceImpl.d.ts +3 -1
  182. package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/aiEditTelemetry/aiEditTelemetryServiceImpl.js +11 -7
  183. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +13 -15
  184. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +1 -1
  185. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +2 -2
  186. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.d.ts +20 -32
  187. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.js +63 -140
  188. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +1 -1
  189. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +17 -16
  190. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
  191. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +1 -1
  192. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +2 -2
  193. package/vscode/src/vs/workbench/contrib/remoteCodingAgents/browser/remoteCodingAgents.contribution.js +7 -7
  194. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminal.chat.contribution.js +3 -0
  195. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatAccessibilityHelp.js +16 -16
  196. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatActions.js +119 -15
  197. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatController.js +6 -4
  198. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.d.ts +47 -0
  199. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatService.js +192 -0
  200. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.d.ts +7 -5
  201. package/vscode/src/vs/workbench/contrib/terminalContrib/chat/browser/terminalChatWidget.js +21 -16
  202. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandLineAutoApprover.js +8 -3
  203. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.d.ts +2 -2
  204. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/basicExecuteStrategy.js +18 -27
  205. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.d.ts +5 -2
  206. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/executeStrategy.js +3 -1
  207. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.d.ts +1 -1
  208. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/noneExecuteStrategy.js +4 -25
  209. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.d.ts +2 -2
  210. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/richExecuteStrategy.js +18 -27
  211. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.d.ts +12 -0
  212. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/executeStrategy/strategyHelpers.js +31 -0
  213. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.d.ts +3 -0
  214. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalHelpers.js +24 -8
  215. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalToolTelemetry.js +8 -0
  216. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/taskHelpers.d.ts +1 -1
  217. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/taskHelpers.js +33 -4
  218. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.js +42 -13
  219. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.js +14 -21
  220. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAnalyzer.d.ts +23 -0
  221. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.d.ts +18 -0
  222. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineAutoApproveAnalyzer.js +227 -0
  223. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.d.ts +17 -0
  224. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineAnalyzer/commandLineFileWriteAnalyzer.js +133 -0
  225. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineCdPrefixRewriter.d.ts +5 -0
  226. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineCdPrefixRewriter.js +36 -0
  227. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePwshChainOperatorRewriter.d.ts +8 -0
  228. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLinePwshChainOperatorRewriter.js +33 -0
  229. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/commandLineRewriter/commandLineRewriter.d.ts +17 -0
  230. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalLastCommandTool.js +4 -4
  231. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalOutputTool.js +3 -3
  232. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/getTerminalSelectionTool.js +3 -3
  233. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.d.ts +5 -1
  234. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.js +75 -37
  235. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/types.d.ts +1 -0
  236. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.d.ts +8 -0
  237. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalConfirmationTool.js +71 -0
  238. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.d.ts +28 -15
  239. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.js +366 -363
  240. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/createAndRunTaskTool.js +18 -18
  241. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/getTaskOutputTool.js +9 -9
  242. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/runTaskTool.js +16 -16
  243. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/task/taskHelpers.js +1 -1
  244. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.d.ts +19 -0
  245. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.js +123 -0
  246. package/vscode/src/vs/base/common/yaml.d.ts +0 -74
  247. package/vscode/src/vs/base/common/yaml.js +0 -597
  248. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +0 -8
  249. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +0 -239
  250. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTimeline.d.ts +0 -102
  251. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTimeline.js +0 -435
  252. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +0 -14
  253. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +0 -67
  254. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -49
  255. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -380
  256. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/common.d.ts +0 -37
  257. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/common.js +0 -137
  258. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +0 -44
  259. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +0 -176
  260. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +0 -4
  261. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +0 -206
  262. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +0 -7
  263. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +0 -79
  264. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +0 -8
  265. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +0 -145
  266. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +0 -65
  267. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +0 -306
  268. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveToPromptAction.d.ts +0 -12
  269. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/saveToPromptAction.js +0 -102
  270. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/newPromptsParser.d.ts +0 -97
  271. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/newPromptsParser.js +0 -247
  272. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts +0 -118
  273. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +0 -10
  274. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandSimplifier.d.ts +0 -10
  275. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/commandSimplifier.js +0 -55
  276. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/subCommands.d.ts +0 -2
  277. package/vscode/src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/subCommands.js +0 -66
@@ -1,11 +1,10 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { asArray } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
4
3
  import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
5
4
  import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
6
5
  import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
6
  import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
8
- import { MarkdownString, createCommandUri } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
7
+ import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
9
8
  import { Disposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
10
9
  import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
11
10
  import { OS, OperatingSystem } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
@@ -16,108 +15,199 @@ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/pl
16
15
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
17
16
  import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
18
17
  import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
19
- import { TerminalCapability } from '@codingame/monaco-vscode-a9da9abe-278d-5ce6-9418-99c7c07c5c37-common/vscode/vs/platform/terminal/common/capabilities/capabilities';
18
+ import { TerminalCapability } from '@codingame/monaco-vscode-10af0e5d-64cb-56de-b584-29ab4a355d15-common/vscode/vs/platform/terminal/common/capabilities/capabilities';
20
19
  import { ITerminalLogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal.service';
21
20
  import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
22
- import { TerminalToolConfirmationStorageKeys } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart';
23
- import { openTerminalSettingsLinkCommandId } from '@codingame/monaco-vscode-e28ac690-06d5-5ee9-92d1-02df70296354-common/vscode/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart';
21
+ import { TerminalToolConfirmationStorageKeys } from '@codingame/monaco-vscode-a793b3ee-7ba9-5176-a019-30ec806fdd95-common/vscode/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart';
24
22
  import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
25
- import { ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
26
23
  import { ToolDataSource, ToolInvocationPresentation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService';
27
24
  import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
28
- import { ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
25
+ import { ITerminalChatService, ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
29
26
  import { ITerminalProfileResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service';
30
- import { TerminalChatAgentToolsSettingId } from '@codingame/monaco-vscode-a175bd1a-4858-5944-9ae5-fb73305dcb13-common/vscode/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration';
27
+ import { TerminalChatAgentToolsSettingId } from '@codingame/monaco-vscode-de235d7f-e72a-5adb-9256-acf6c64eb6f2-common/vscode/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration';
31
28
  import { getRecommendedToolsOverRunInTerminal } from '../alternativeRecommendation.js';
32
- import { CommandLineAutoApprover } from '../commandLineAutoApprover.js';
33
- import { CommandSimplifier } from '../commandSimplifier.js';
34
29
  import { BasicExecuteStrategy } from '../executeStrategy/basicExecuteStrategy.js';
35
30
  import { NoneExecuteStrategy } from '../executeStrategy/noneExecuteStrategy.js';
36
31
  import { RichExecuteStrategy } from '../executeStrategy/richExecuteStrategy.js';
37
32
  import { getOutput } from '../outputHelpers.js';
38
- import { isPowerShell, generateAutoApproveActions, dedupeRules } from '../runInTerminalHelpers.js';
33
+ import { isWindowsPowerShell, isPowerShell, isZsh, isFish } from '../runInTerminalHelpers.js';
39
34
  import { RunInTerminalToolTelemetry } from '../runInTerminalToolTelemetry.js';
40
- import { splitCommandLineIntoSubCommands } from '../subCommands.js';
41
35
  import { ToolTerminalCreator, ShellIntegrationQuality } from '../toolTerminalCreator.js';
36
+ import { TreeSitterCommandParser, TreeSitterCommandParserLanguage } from '../treeSitterCommandParser.js';
37
+ import { CommandLineAutoApproveAnalyzer } from './commandLineAnalyzer/commandLineAutoApproveAnalyzer.js';
38
+ import { CommandLineFileWriteAnalyzer } from './commandLineAnalyzer/commandLineFileWriteAnalyzer.js';
42
39
  import { OutputMonitor } from './monitoring/outputMonitor.js';
43
40
  import { OutputMonitorState } from './monitoring/types.js';
41
+ import { LocalChatSessionUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatUri';
42
+ import { CommandLineCdPrefixRewriter } from './commandLineRewriter/commandLineCdPrefixRewriter.js';
43
+ import { CommandLinePwshChainOperatorRewriter } from './commandLineRewriter/commandLinePwshChainOperatorRewriter.js';
44
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
45
+ import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
44
46
 
45
47
  var RunInTerminalTool_1;
46
- var TerminalToolStorageKeysInternal;
47
- (function (TerminalToolStorageKeysInternal) {
48
- TerminalToolStorageKeysInternal["TerminalSession"] = "chat.terminalSessions";
49
- })(TerminalToolStorageKeysInternal || (TerminalToolStorageKeysInternal = {}));
50
- const RunInTerminalToolData = {
51
- id: 'run_in_terminal',
52
- toolReferenceName: 'runInTerminal',
53
- displayName: ( localize(11585, 'Run in Terminal')),
54
- modelDescription: [
55
- 'This tool allows you to execute shell commands in a persistent terminal session, preserving environment variables, working directory, and other context across multiple commands.',
48
+ function createPowerShellModelDescription(shell) {
49
+ const isWinPwsh = isWindowsPowerShell(shell);
50
+ return [
51
+ `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.`,
56
52
  '',
57
53
  'Command Execution:',
58
- '- Does NOT support multi-line commands',
54
+ '- Use semicolons ; to chain commands on one line, NEVER use && even when asked explicitly',
55
+ '- Prefer pipelines | for object-based data flow',
56
+ '- Never create a sub-shell (eg. powershell -c "command") unless explicitly asked',
59
57
  '',
60
58
  'Directory Management:',
61
- '- Must use absolute paths to avoid navigation issues.',
59
+ '- Must use absolute paths to avoid navigation issues',
60
+ '- Use $PWD or Get-Location for current directory',
61
+ '- Use Push-Location/Pop-Location for directory stack',
62
62
  '',
63
63
  'Program Execution:',
64
- '- Supports Python, Node.js, and other executables.',
65
- '- Install dependencies via pip, npm, etc.',
64
+ '- Supports .NET, Python, Node.js, and other executables',
65
+ '- Install modules via Install-Module, Install-Package',
66
+ '- Use Get-Command to verify cmdlet/function availability',
66
67
  '',
67
68
  'Background Processes:',
68
- '- For long-running tasks (e.g., servers), set isBackground=true.',
69
- '- Returns a terminal ID for checking status and runtime later.',
69
+ '- For long-running tasks (e.g., servers), set isBackground=true',
70
+ '- Returns a terminal ID for checking status and runtime later',
71
+ '- Use Start-Job for background PowerShell jobs',
70
72
  '',
71
73
  'Output Management:',
72
74
  '- Output is automatically truncated if longer than 60KB to prevent context overflow',
73
- '- Use filters like \'head\', \'tail\', \'grep\' to limit output size',
74
- '- For pager commands, disable paging: use \'git --no-pager\' or add \'| cat\'',
75
+ '- Use Select-Object, Where-Object, Format-Table to filter output',
76
+ '- Use -First/-Last parameters to limit results',
77
+ '- For pager commands, add | Out-String or | Format-List',
75
78
  '',
76
79
  'Best Practices:',
77
- '- Be specific with commands to avoid excessive output',
78
- '- Use targeted queries instead of broad scans',
79
- '- Consider using \'wc -l\' to count before listing many items'
80
- ].join('\n'),
81
- userDescription: ( localize(11586, 'Tool for running commands in the terminal')),
82
- source: ToolDataSource.Internal,
83
- icon: Codicon.terminal,
84
- inputSchema: {
85
- type: 'object',
86
- properties: {
87
- command: {
88
- type: 'string',
89
- description: 'The command to run in the terminal.'
90
- },
91
- explanation: {
92
- type: 'string',
93
- description: 'A one-sentence description of what the command does. This will be shown to the user before the command is run.'
94
- },
95
- isBackground: {
96
- type: 'boolean',
97
- 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.'
98
- },
99
- },
100
- required: [
101
- 'command',
102
- 'explanation',
103
- 'isBackground',
104
- ]
80
+ '- Use proper cmdlet names instead of aliases in scripts',
81
+ '- Quote paths with spaces: "C:\\Path With Spaces"',
82
+ '- Prefer PowerShell cmdlets over external commands when available',
83
+ '- Prefer idiomatic PowerShell like Get-ChildItem instead of dir or ls for file listings',
84
+ '- Use Test-Path to check file/directory existence',
85
+ '- Be specific with Select-Object properties to avoid excessive output'
86
+ ].join('\n');
87
+ }
88
+ const genericDescription = `
89
+ Command Execution:
90
+ - Use && to chain simple commands on one line
91
+ - Prefer pipelines | over temporary files for data flow
92
+ - Never create a sub-shell (eg. bash -c "command") unless explicitly asked
93
+
94
+ Directory Management:
95
+ - Must use absolute paths to avoid navigation issues
96
+ - Use $PWD for current directory references
97
+ - Consider using pushd/popd for directory stack management
98
+ - Supports directory shortcuts like ~ and -
99
+
100
+ Program Execution:
101
+ - Supports Python, Node.js, and other executables
102
+ - Install packages via package managers (brew, apt, etc.)
103
+ - Use which or command -v to verify command availability
104
+
105
+ Background Processes:
106
+ - For long-running tasks (e.g., servers), set isBackground=true
107
+ - Returns a terminal ID for checking status and runtime later
108
+
109
+ Output Management:
110
+ - Output is automatically truncated if longer than 60KB to prevent context overflow
111
+ - Use head, tail, grep, awk to filter and limit output size
112
+ - For pager commands, disable paging: git --no-pager or add | cat
113
+ - Use wc -l to count lines before displaying large outputs
114
+
115
+ Best Practices:
116
+ - Quote variables: "$var" instead of $var to handle spaces
117
+ - Use find with -exec or xargs for file operations
118
+ - Be specific with commands to avoid excessive output`;
119
+ function createBashModelDescription() {
120
+ return [
121
+ '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.',
122
+ genericDescription,
123
+ '- Use [[ ]] for conditional tests instead of [ ]',
124
+ '- Prefer $() over backticks for command substitution',
125
+ '- Use set -e at start of complex commands to exit on errors'
126
+ ].join('\n');
127
+ }
128
+ function createZshModelDescription() {
129
+ return [
130
+ '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.',
131
+ genericDescription,
132
+ '- Use type to check command type (builtin, function, alias)',
133
+ '- Use jobs, fg, bg for job control',
134
+ '- Use [[ ]] for conditional tests instead of [ ]',
135
+ '- Prefer $() over backticks for command substitution',
136
+ '- Use setopt errexit for strict error handling',
137
+ '- Take advantage of zsh globbing features (**, extended globs)'
138
+ ].join('\n');
139
+ }
140
+ function createFishModelDescription() {
141
+ return [
142
+ '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.',
143
+ genericDescription,
144
+ '- Use type to check command type (builtin, function, alias)',
145
+ '- Use jobs, fg, bg for job control',
146
+ '- Use test expressions for conditionals (no [[ ]] syntax)',
147
+ '- Prefer command substitution with () syntax',
148
+ '- Variables are arrays by default, use $var[1] for first element',
149
+ '- Use set -e for strict error handling',
150
+ '- Take advantage of fish\'s autosuggestions and completions'
151
+ ].join('\n');
152
+ }
153
+ async function createRunInTerminalToolData(accessor) {
154
+ const instantiationService = accessor.get(IInstantiationService);
155
+ const profileFetcher = instantiationService.createInstance(TerminalProfileFetcher);
156
+ const shell = await profileFetcher.getCopilotShell();
157
+ const os = await profileFetcher.osBackend;
158
+ let modelDescription;
159
+ if (shell && os && isPowerShell(shell, os)) {
160
+ modelDescription = createPowerShellModelDescription(shell);
105
161
  }
106
- };
162
+ else if (shell && os && isZsh(shell, os)) {
163
+ modelDescription = createZshModelDescription();
164
+ }
165
+ else if (shell && os && isFish(shell, os)) {
166
+ modelDescription = createFishModelDescription();
167
+ }
168
+ else {
169
+ modelDescription = createBashModelDescription();
170
+ }
171
+ return {
172
+ id: 'run_in_terminal',
173
+ toolReferenceName: 'runInTerminal',
174
+ displayName: ( localize(11867, 'Run in Terminal')),
175
+ modelDescription,
176
+ userDescription: ( localize(11868, 'Tool for running commands in the terminal')),
177
+ source: ToolDataSource.Internal,
178
+ icon: Codicon.terminal,
179
+ inputSchema: {
180
+ type: 'object',
181
+ properties: {
182
+ command: {
183
+ type: 'string',
184
+ description: 'The command to run in the terminal.'
185
+ },
186
+ explanation: {
187
+ type: 'string',
188
+ description: 'A one-sentence description of what the command does. This will be shown to the user before the command is run.'
189
+ },
190
+ isBackground: {
191
+ type: 'boolean',
192
+ 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.'
193
+ },
194
+ },
195
+ required: [
196
+ 'command',
197
+ 'explanation',
198
+ 'isBackground',
199
+ ]
200
+ }
201
+ };
202
+ }
203
+ var TerminalToolStorageKeysInternal;
204
+ (function (TerminalToolStorageKeysInternal) {
205
+ TerminalToolStorageKeysInternal["TerminalSession"] = "chat.terminalSessions";
206
+ })(TerminalToolStorageKeysInternal || (TerminalToolStorageKeysInternal = {}));
107
207
  const telemetryIgnoredSequences = [
108
208
  '\x1b[I',
109
209
  '\x1b[O',
110
210
  ];
111
- const promptInjectionWarningCommandsLower = [
112
- 'curl',
113
- 'wget',
114
- ];
115
- const promptInjectionWarningCommandsLowerPwshOnly = [
116
- 'invoke-restmethod',
117
- 'invoke-webrequest',
118
- 'irm',
119
- 'iwr',
120
- ];
121
211
  let RunInTerminalTool = class RunInTerminalTool extends Disposable {
122
212
  static { RunInTerminalTool_1 = this; }
123
213
  static { this._backgroundExecutions = ( new Map()); }
@@ -128,23 +218,33 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
128
218
  }
129
219
  return backgroundExecution.getOutput();
130
220
  }
131
- constructor(_instantiationService, _configurationService, _languageModelToolsService, _storageService, _logService, _terminalProfileResolverService, _terminalService, _remoteAgentService, _chatService) {
221
+ constructor(_chatService, _configurationService, _historyService, _instantiationService, _languageModelToolsService, _remoteAgentService, _storageService, _terminalChatService, _logService, _terminalService, _workspaceContextService) {
132
222
  super();
133
- this._instantiationService = _instantiationService;
223
+ this._chatService = _chatService;
134
224
  this._configurationService = _configurationService;
225
+ this._historyService = _historyService;
226
+ this._instantiationService = _instantiationService;
135
227
  this._languageModelToolsService = _languageModelToolsService;
228
+ this._remoteAgentService = _remoteAgentService;
136
229
  this._storageService = _storageService;
230
+ this._terminalChatService = _terminalChatService;
137
231
  this._logService = _logService;
138
- this._terminalProfileResolverService = _terminalProfileResolverService;
139
232
  this._terminalService = _terminalService;
140
- this._remoteAgentService = _remoteAgentService;
141
- this._chatService = _chatService;
233
+ this._workspaceContextService = _workspaceContextService;
142
234
  this._sessionTerminalAssociations = ( new Map());
143
235
  this._osBackend = this._remoteAgentService.getEnvironment().then(remoteEnv => remoteEnv?.os ?? OS);
144
- this._terminalToolCreator = _instantiationService.createInstance(ToolTerminalCreator);
145
- this._commandSimplifier = _instantiationService.createInstance(CommandSimplifier, this._osBackend);
146
- this._telemetry = _instantiationService.createInstance(RunInTerminalToolTelemetry);
147
- this._commandLineAutoApprover = this._register(_instantiationService.createInstance(CommandLineAutoApprover));
236
+ this._terminalToolCreator = this._instantiationService.createInstance(ToolTerminalCreator);
237
+ this._treeSitterCommandParser = this._register(this._instantiationService.createInstance(TreeSitterCommandParser));
238
+ this._telemetry = this._instantiationService.createInstance(RunInTerminalToolTelemetry);
239
+ this._profileFetcher = this._instantiationService.createInstance(TerminalProfileFetcher);
240
+ this._commandLineRewriters = [
241
+ this._register(this._instantiationService.createInstance(CommandLineCdPrefixRewriter)),
242
+ this._register(this._instantiationService.createInstance(CommandLinePwshChainOperatorRewriter, this._treeSitterCommandParser)),
243
+ ];
244
+ this._commandLineAnalyzers = [
245
+ this._register(this._instantiationService.createInstance(CommandLineFileWriteAnalyzer, this._treeSitterCommandParser, (message, args) => this._logService.info(`RunInTerminalTool#CommandLineFileWriteAnalyzer: ${message}`, args))),
246
+ this._register(this._instantiationService.createInstance(CommandLineAutoApproveAnalyzer, this._treeSitterCommandParser, this._telemetry, (message, args) => this._logService.info(`RunInTerminalTool#CommandLineAutoApproveAnalyzer: ${message}`, args))),
247
+ ];
148
248
  this._register(Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {
149
249
  if (!e || e.affectsConfiguration(TerminalChatAgentToolsSettingId.EnableAutoApprove)) {
150
250
  if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) !== true) {
@@ -161,133 +261,102 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
161
261
  }
162
262
  }));
163
263
  this._register(this._chatService.onDidDisposeSession(e => {
164
- this._cleanupSessionTerminals(e.sessionId);
264
+ const localSessionId = LocalChatSessionUri.parseLocalSessionId(e.sessionResource);
265
+ if (localSessionId) {
266
+ this._cleanupSessionTerminals(localSessionId);
267
+ }
165
268
  }));
166
269
  }
167
270
  async prepareToolInvocation(context, token) {
168
271
  const args = context.parameters;
169
- const alternativeRecommendation = getRecommendedToolsOverRunInTerminal(args.command, this._languageModelToolsService);
170
- const presentation = alternativeRecommendation ? ToolInvocationPresentation.Hidden : undefined;
171
- const os = await this._osBackend;
172
- const shell = await this._getCopilotShell();
173
- const language = os === OperatingSystem.Windows ? 'pwsh' : 'sh';
174
272
  const instance = context.chatSessionId ? this._sessionTerminalAssociations.get(context.chatSessionId)?.instance : undefined;
175
- const terminalToolSessionId = generateUuid();
176
- let toolEditedCommand = await this._commandSimplifier.rewriteIfNeeded(args, instance, shell);
177
- if (toolEditedCommand === args.command) {
178
- toolEditedCommand = undefined;
179
- }
180
- let autoApproveInfo;
181
- let confirmationMessages;
182
- if (alternativeRecommendation) {
183
- confirmationMessages = undefined;
184
- }
185
- else {
186
- const actualCommand = toolEditedCommand ?? args.command;
187
- const subCommands = splitCommandLineIntoSubCommands(actualCommand, shell, os);
188
- const subCommandResults = ( subCommands.map(e => this._commandLineAutoApprover.isCommandAutoApproved(e, shell, os)));
189
- const commandLineResult = this._commandLineAutoApprover.isCommandLineAutoApproved(actualCommand);
190
- const autoApproveReasons = [
191
- ...( subCommandResults.map(e => e.reason)),
192
- commandLineResult.reason,
193
- ];
194
- let isAutoApproved = false;
195
- let isDenied = false;
196
- let autoApproveReason;
197
- let autoApproveDefault;
198
- const deniedSubCommandResult = subCommandResults.find(e => e.result === 'denied');
199
- if (deniedSubCommandResult) {
200
- this._logService.info('autoApprove: Sub-command DENIED auto approval');
201
- isDenied = true;
202
- autoApproveDefault = deniedSubCommandResult.rule?.isDefaultRule;
203
- autoApproveReason = 'subCommand';
204
- }
205
- else if (commandLineResult.result === 'denied') {
206
- this._logService.info('autoApprove: Command line DENIED auto approval');
207
- isDenied = true;
208
- autoApproveDefault = commandLineResult.rule?.isDefaultRule;
209
- autoApproveReason = 'commandLine';
210
- }
211
- else {
212
- if (subCommandResults.every(e => e.result === 'approved')) {
213
- this._logService.info('autoApprove: All sub-commands auto-approved');
214
- autoApproveReason = 'subCommand';
215
- isAutoApproved = true;
216
- autoApproveDefault = subCommandResults.every(e => e.rule?.isDefaultRule);
217
- }
218
- else {
219
- this._logService.info('autoApprove: All sub-commands NOT auto-approved');
220
- if (commandLineResult.result === 'approved') {
221
- this._logService.info('autoApprove: Command line auto-approved');
222
- autoApproveReason = 'commandLine';
223
- isAutoApproved = true;
224
- autoApproveDefault = commandLineResult.rule?.isDefaultRule;
225
- }
226
- else {
227
- this._logService.info('autoApprove: Command line NOT auto-approved');
228
- }
273
+ const [os, shell, cwd] = await Promise.all([
274
+ this._osBackend,
275
+ this._profileFetcher.getCopilotShell(),
276
+ (async () => {
277
+ let cwd = await instance?.getCwdResource();
278
+ if (!cwd) {
279
+ const activeWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot();
280
+ const workspaceFolder = activeWorkspaceRootUri ? this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
281
+ cwd = workspaceFolder?.uri;
229
282
  }
230
- }
231
- for (const reason of autoApproveReasons) {
232
- this._logService.info(`- ${reason}`);
233
- }
234
- const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;
235
- const isAutoApproveWarningAccepted = this._storageService.getBoolean(TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted, StorageScope.APPLICATION, false);
236
- const isAutoApproveAllowed = isAutoApproveEnabled && isAutoApproveWarningAccepted;
237
- if (isAutoApproveEnabled) {
238
- autoApproveInfo = this._createAutoApproveInfo(isAutoApproved, isDenied, autoApproveReason, subCommandResults, commandLineResult);
239
- }
240
- else {
241
- isAutoApproved = false;
242
- }
243
- this._telemetry.logPrepare({
244
- terminalToolSessionId,
245
- subCommands,
246
- autoApproveAllowed: !isAutoApproveEnabled ? 'off' : isAutoApproveWarningAccepted ? 'allowed' : 'needsOptIn',
247
- autoApproveResult: isAutoApproved ? 'approved' : isDenied ? 'denied' : 'manual',
248
- autoApproveReason,
249
- autoApproveDefault
283
+ return cwd;
284
+ })()
285
+ ]);
286
+ const language = os === OperatingSystem.Windows ? 'pwsh' : 'sh';
287
+ const terminalToolSessionId = generateUuid();
288
+ const terminalCommandId = `tool-${generateUuid()}`;
289
+ let rewrittenCommand = args.command;
290
+ for (const rewriter of this._commandLineRewriters) {
291
+ const rewriteResult = await rewriter.rewrite({
292
+ commandLine: rewrittenCommand,
293
+ cwd,
294
+ shell,
295
+ os
250
296
  });
251
- let disclaimer;
252
- const subCommandsLowerFirstWordOnly = ( subCommands.map(command => command.split(' ')[0].toLowerCase()));
253
- if (!isAutoApproved && (( subCommandsLowerFirstWordOnly.some(command => promptInjectionWarningCommandsLower.includes(command))) ||
254
- (isPowerShell(shell, os) && ( subCommandsLowerFirstWordOnly.some(command => promptInjectionWarningCommandsLowerPwshOnly.includes(command)))))) {
255
- disclaimer = ( new MarkdownString(`$(${Codicon.info.id}) ` + ( localize(
256
- 11587,
257
- 'Web content may contain malicious code or attempt prompt injection attacks.'
258
- )), { supportThemeIcons: true }));
259
- }
260
- let customActions;
261
- if (!isAutoApproved && isAutoApproveEnabled) {
262
- customActions = generateAutoApproveActions(actualCommand, subCommands, { subCommandResults, commandLineResult });
263
- }
264
- let shellType = basename(shell, '.exe');
265
- if (shellType === 'powershell') {
266
- shellType = 'pwsh';
297
+ if (rewriteResult) {
298
+ rewrittenCommand = rewriteResult.rewritten;
299
+ this._logService.info(`RunInTerminalTool: Command rewritten by ${rewriter.constructor.name}: ${rewriteResult.reasoning}`);
267
300
  }
268
- confirmationMessages = (isAutoApproved && isAutoApproveAllowed) ? undefined : {
269
- title: args.isBackground
270
- ? ( localize(11588, "Run `{0}` command? (background terminal)", shellType))
271
- : ( localize(11589, "Run `{0}` command?", shellType)),
272
- message: ( new MarkdownString(args.explanation)),
273
- disclaimer,
274
- terminalCustomActions: customActions,
301
+ }
302
+ const toolSpecificData = {
303
+ kind: 'terminal',
304
+ terminalToolSessionId,
305
+ terminalCommandId,
306
+ commandLine: {
307
+ original: args.command,
308
+ toolEdited: rewrittenCommand === args.command ? undefined : rewrittenCommand
309
+ },
310
+ language,
311
+ };
312
+ const alternativeRecommendation = getRecommendedToolsOverRunInTerminal(args.command, this._languageModelToolsService);
313
+ if (alternativeRecommendation) {
314
+ toolSpecificData.alternativeRecommendation = alternativeRecommendation;
315
+ return {
316
+ confirmationMessages: undefined,
317
+ presentation: ToolInvocationPresentation.Hidden,
318
+ toolSpecificData,
275
319
  };
276
320
  }
321
+ const commandLine = rewrittenCommand ?? args.command;
322
+ const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;
323
+ const isAutoApproveWarningAccepted = this._storageService.getBoolean(TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted, StorageScope.APPLICATION, false);
324
+ const isAutoApproveAllowed = isAutoApproveEnabled && isAutoApproveWarningAccepted;
325
+ const commandLineAnalyzerOptions = {
326
+ commandLine,
327
+ cwd,
328
+ os,
329
+ shell,
330
+ treeSitterLanguage: isPowerShell(shell, os) ? TreeSitterCommandParserLanguage.PowerShell : TreeSitterCommandParserLanguage.Bash,
331
+ terminalToolSessionId,
332
+ };
333
+ const commandLineAnalyzerResults = await Promise.all(( this._commandLineAnalyzers.map(e => e.analyze(commandLineAnalyzerOptions))));
334
+ const disclaimersRaw = commandLineAnalyzerResults.filter(e => e.disclaimers).flatMap(e => e.disclaimers);
335
+ let disclaimer;
336
+ if (disclaimersRaw.length > 0) {
337
+ disclaimer = ( new MarkdownString(
338
+ `$(${Codicon.info.id}) ` + disclaimersRaw.join(' '),
339
+ { supportThemeIcons: true }
340
+ ));
341
+ }
342
+ const customActions = ( commandLineAnalyzerResults.map(e => e.customActions ?? [])).flat();
343
+ toolSpecificData.autoApproveInfo = commandLineAnalyzerResults.find(e => e.autoApproveInfo)?.autoApproveInfo;
344
+ let shellType = basename(shell, '.exe');
345
+ if (shellType === 'powershell') {
346
+ shellType = 'pwsh';
347
+ }
348
+ const isFinalAutoApproved = isAutoApproveAllowed && commandLineAnalyzerResults.every(e => e.isAutoApproveAllowed);
349
+ const confirmationMessages = isFinalAutoApproved ? undefined : {
350
+ title: args.isBackground
351
+ ? ( localize(11869, "Run `{0}` command? (background terminal)", shellType))
352
+ : ( localize(11870, "Run `{0}` command?", shellType)),
353
+ message: ( new MarkdownString(args.explanation)),
354
+ disclaimer,
355
+ terminalCustomActions: customActions,
356
+ };
277
357
  return {
278
358
  confirmationMessages,
279
- presentation,
280
- toolSpecificData: {
281
- kind: 'terminal',
282
- terminalToolSessionId,
283
- commandLine: {
284
- original: args.command,
285
- toolEdited: toolEditedCommand
286
- },
287
- language,
288
- alternativeRecommendation,
289
- autoApproveInfo,
290
- }
359
+ toolSpecificData,
291
360
  };
292
361
  }
293
362
  async invoke(invocation, _countTokens, _progress, token) {
@@ -320,18 +389,19 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
320
389
  const isNewSession = !args.isBackground && !( this._sessionTerminalAssociations.has(chatSessionId));
321
390
  const timingStart = Date.now();
322
391
  const termId = generateUuid();
392
+ const terminalToolSessionId = toolSpecificData.terminalToolSessionId;
323
393
  const store = ( new DisposableStore());
324
394
  this._logService.debug(`RunInTerminalTool: Creating ${args.isBackground ? 'background' : 'foreground'} terminal. termId=${termId}, chatSessionId=${chatSessionId}`);
325
395
  const toolTerminal = await (args.isBackground
326
- ? this._initBackgroundTerminal(chatSessionId, termId, token)
327
- : this._initForegroundTerminal(chatSessionId, termId, token));
328
- this._terminalService.setActiveInstance(toolTerminal.instance);
329
- this._terminalService.revealTerminal(toolTerminal.instance, true);
396
+ ? this._initBackgroundTerminal(chatSessionId, termId, terminalToolSessionId, token)
397
+ : this._initForegroundTerminal(chatSessionId, termId, terminalToolSessionId, token));
398
+ this._handleTerminalVisibility(toolTerminal);
330
399
  const timingConnectMs = Date.now() - timingStart;
331
400
  const xterm = await toolTerminal.instance.xtermReadyPromise;
332
401
  if (!xterm) {
333
402
  throw ( new Error('Instance was disposed before xterm.js was ready'));
334
403
  }
404
+ const commandDetection = toolTerminal.instance.capabilities.get(TerminalCapability.CommandDetection);
335
405
  let inputUserChars = 0;
336
406
  let inputUserSigint = false;
337
407
  store.add(xterm.raw.onData(data => {
@@ -345,7 +415,8 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
345
415
  let pollingResult;
346
416
  try {
347
417
  this._logService.debug(`RunInTerminalTool: Starting background execution \`${command}\``);
348
- const execution = ( new BackgroundTerminalExecution(toolTerminal.instance, xterm, command, chatSessionId));
418
+ const commandId = toolSpecificData.terminalCommandId;
419
+ const execution = ( new BackgroundTerminalExecution(toolTerminal.instance, xterm, command, chatSessionId, commandId));
349
420
  RunInTerminalTool_1._backgroundExecutions.set(termId, execution);
350
421
  outputMonitor = store.add(this._instantiationService.createInstance(OutputMonitor, execution, undefined, invocation.context, token, command));
351
422
  await Event.toPromise(outputMonitor.onDidFinishCommand);
@@ -364,16 +435,14 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
364
435
  else if (pollingResult) {
365
436
  resultText += `\n\ The command is still running, with output:\n${pollingResult.output}`;
366
437
  }
367
- const toolResultMessage = toolSpecificData.autoApproveInfo;
368
438
  return {
369
- toolResultMessage: toolResultMessage,
370
439
  toolMetadata: {
371
440
  exitCode: undefined
372
441
  },
373
442
  content: [{
374
443
  kind: 'text',
375
444
  value: resultText,
376
- }]
445
+ }],
377
446
  };
378
447
  }
379
448
  catch (e) {
@@ -421,7 +490,6 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
421
490
  let exitCode;
422
491
  try {
423
492
  let strategy;
424
- const commandDetection = toolTerminal.instance.capabilities.get(TerminalCapability.CommandDetection);
425
493
  switch (toolTerminal.shellIntegrationQuality) {
426
494
  case ShellIntegrationQuality.None: {
427
495
  strategy = this._instantiationService.createInstance(NoneExecuteStrategy, toolTerminal.instance, () => toolTerminal.receivedUserInput ?? false);
@@ -443,7 +511,8 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
443
511
  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));
444
512
  }
445
513
  }));
446
- const executeResult = await strategy.execute(command, token);
514
+ const commandId = toolSpecificData.terminalCommandId;
515
+ const executeResult = await strategy.execute(command, token, commandId);
447
516
  toolTerminal.receivedUserInput = false;
448
517
  if (token.isCancellationRequested) {
449
518
  throw ( new CancellationError());
@@ -504,20 +573,8 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
504
573
  resultText.push(`Note: The tool simplified the command to \`${command}\`, and this is the output of running that command instead:\n`);
505
574
  }
506
575
  resultText.push(terminalResult);
507
- let resolvedToolResultMessage;
508
- if (toolSpecificData.autoApproveInfo) {
509
- if (toolResultMessage) {
510
- resolvedToolResultMessage = ( new MarkdownString(
511
- `${toolSpecificData.autoApproveInfo.value}\n\n${toolResultMessage}`,
512
- toolSpecificData.autoApproveInfo
513
- ));
514
- }
515
- else {
516
- resolvedToolResultMessage = toolSpecificData.autoApproveInfo;
517
- }
518
- }
519
576
  return {
520
- toolResultMessage: resolvedToolResultMessage,
577
+ toolResultMessage,
521
578
  toolMetadata: {
522
579
  exitCode: exitCode
523
580
  },
@@ -528,61 +585,18 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
528
585
  };
529
586
  }
530
587
  }
531
- async _getCopilotShellOrProfile() {
532
- const os = await this._osBackend;
533
- const customChatAgentProfile = this._getChatTerminalProfile(os);
534
- if (customChatAgentProfile) {
535
- return customChatAgentProfile;
536
- }
537
- const defaultShell = await this._terminalProfileResolverService.getDefaultShell({
538
- os,
539
- remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority
540
- });
541
- if (basename(defaultShell) === 'cmd.exe') {
542
- return 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe';
543
- }
544
- return defaultShell;
545
- }
546
- async _getCopilotShell() {
547
- const shellOrProfile = await this._getCopilotShellOrProfile();
548
- if (typeof shellOrProfile === 'string') {
549
- return shellOrProfile;
550
- }
551
- return shellOrProfile.path;
552
- }
553
- _getChatTerminalProfile(os) {
554
- let profileSetting;
555
- switch (os) {
556
- case OperatingSystem.Windows:
557
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileWindows;
558
- break;
559
- case OperatingSystem.Macintosh:
560
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileMacOs;
561
- break;
562
- case OperatingSystem.Linux:
563
- default:
564
- profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileLinux;
565
- break;
566
- }
567
- const profile = this._configurationService.getValue(profileSetting);
568
- if (this._isValidChatAgentTerminalProfile(profile)) {
569
- return profile;
570
- }
571
- return undefined;
572
- }
573
- _isValidChatAgentTerminalProfile(profile) {
574
- if (profile === null || profile === undefined || typeof profile !== 'object') {
575
- return false;
576
- }
577
- if ('path' in profile && typeof profile.path === 'string') {
578
- return true;
588
+ _handleTerminalVisibility(toolTerminal) {
589
+ if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.OutputLocation) === 'terminal') {
590
+ this._terminalService.setActiveInstance(toolTerminal.instance);
591
+ this._terminalService.revealTerminal(toolTerminal.instance, true);
579
592
  }
580
- return false;
581
593
  }
582
- async _initBackgroundTerminal(chatSessionId, termId, token) {
594
+ async _initBackgroundTerminal(chatSessionId, termId, terminalToolSessionId, token) {
583
595
  this._logService.debug(`RunInTerminalTool: Creating background terminal with ID=${termId}`);
584
- const shellOrProfile = await this._getCopilotShellOrProfile();
585
- const toolTerminal = await this._terminalToolCreator.createTerminal(shellOrProfile, token);
596
+ const profile = await this._profileFetcher.getCopilotProfile();
597
+ const toolTerminal = await this._terminalToolCreator.createTerminal(profile, token);
598
+ this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, toolTerminal.instance);
599
+ this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionId, toolTerminal.instance);
586
600
  this._registerInputListener(toolTerminal);
587
601
  this._sessionTerminalAssociations.set(chatSessionId, toolTerminal);
588
602
  if (token.isCancellationRequested) {
@@ -592,15 +606,18 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
592
606
  await this._setupProcessIdAssociation(toolTerminal, chatSessionId, termId, true);
593
607
  return toolTerminal;
594
608
  }
595
- async _initForegroundTerminal(chatSessionId, termId, token) {
609
+ async _initForegroundTerminal(chatSessionId, termId, terminalToolSessionId, token) {
596
610
  const cachedTerminal = this._sessionTerminalAssociations.get(chatSessionId);
597
611
  if (cachedTerminal) {
598
612
  this._logService.debug(`RunInTerminalTool: Using cached foreground terminal with session ID \`${chatSessionId}\``);
599
613
  this._terminalToolCreator.refreshShellIntegrationQuality(cachedTerminal);
614
+ this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, cachedTerminal.instance);
600
615
  return cachedTerminal;
601
616
  }
602
- const shellOrProfile = await this._getCopilotShellOrProfile();
603
- const toolTerminal = await this._terminalToolCreator.createTerminal(shellOrProfile, token);
617
+ const profile = await this._profileFetcher.getCopilotProfile();
618
+ const toolTerminal = await this._terminalToolCreator.createTerminal(profile, token);
619
+ this._terminalChatService.registerTerminalInstanceWithToolSession(terminalToolSessionId, toolTerminal.instance);
620
+ this._terminalChatService.registerTerminalInstanceWithChatSession(chatSessionId, toolTerminal.instance);
604
621
  this._registerInputListener(toolTerminal);
605
622
  this._sessionTerminalAssociations.set(chatSessionId, toolTerminal);
606
623
  if (token.isCancellationRequested) {
@@ -632,6 +649,7 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
632
649
  shellIntegrationQuality: association.shellIntegrationQuality
633
650
  };
634
651
  this._sessionTerminalAssociations.set(association.sessionId, toolTerminal);
652
+ this._terminalChatService.registerTerminalInstanceWithChatSession(association.sessionId, instance);
635
653
  this._register(instance.onDisposed(() => {
636
654
  this._removeProcessIdAssociation(instance.processId);
637
655
  }));
@@ -708,112 +726,97 @@ let RunInTerminalTool = class RunInTerminalTool extends Disposable {
708
726
  }
709
727
  }
710
728
  }
711
- _createAutoApproveInfo(isAutoApproved, isDenied, autoApproveReason, subCommandResults, commandLineResult) {
712
- const formatRuleLinks = (result) => {
713
- return ( asArray(result).map(e => {
714
- const settingsUri = createCommandUri(openTerminalSettingsLinkCommandId, e.rule.sourceTarget);
715
- return `[\`${e.rule.sourceText}\`](${( settingsUri.toString())} "${( localize(11590, 'View rule in settings'))}")`;
716
- })).join(', ');
717
- };
718
- const mdTrustSettings = {
719
- isTrusted: {
720
- enabledCommands: [openTerminalSettingsLinkCommandId]
721
- }
722
- };
723
- const config = this._configurationService.inspect(ChatConfiguration.GlobalAutoApprove);
724
- const isGlobalAutoApproved = config?.value ?? config.defaultValue;
725
- if (isGlobalAutoApproved) {
726
- const settingsUri = createCommandUri(openTerminalSettingsLinkCommandId, 'global');
727
- return (new MarkdownString(`_${( localize(
728
- 11591,
729
- 'Auto approved by setting {0}',
730
- `[\`${ChatConfiguration.GlobalAutoApprove}\`](${( settingsUri.toString())} "${( localize(11592, 'View settings'))}")`
731
- ))}_`, mdTrustSettings));
732
- }
733
- if (isAutoApproved) {
734
- switch (autoApproveReason) {
735
- case 'commandLine': {
736
- if (commandLineResult.rule) {
737
- return (new MarkdownString(
738
- `_${( localize(11593, 'Auto approved by rule {0}', formatRuleLinks(commandLineResult)))}_`,
739
- mdTrustSettings
740
- ));
741
- }
742
- break;
743
- }
744
- case 'subCommand': {
745
- const uniqueRules = dedupeRules(subCommandResults);
746
- if (uniqueRules.length === 1) {
747
- return (new MarkdownString(
748
- `_${( localize(11593, 'Auto approved by rule {0}', formatRuleLinks(uniqueRules)))}_`,
749
- mdTrustSettings
750
- ));
751
- }
752
- else if (uniqueRules.length > 1) {
753
- return (new MarkdownString(
754
- `_${( localize(11594, 'Auto approved by rules {0}', formatRuleLinks(uniqueRules)))}_`,
755
- mdTrustSettings
756
- ));
757
- }
758
- break;
759
- }
760
- }
761
- }
762
- else if (isDenied) {
763
- switch (autoApproveReason) {
764
- case 'commandLine': {
765
- if (commandLineResult.rule) {
766
- return (new MarkdownString(`_${( localize(
767
- 11595,
768
- 'Auto approval denied by rule {0}',
769
- formatRuleLinks(commandLineResult)
770
- ))}_`, mdTrustSettings));
771
- }
772
- break;
773
- }
774
- case 'subCommand': {
775
- const uniqueRules = dedupeRules(subCommandResults.filter(e => e.result === 'denied'));
776
- if (uniqueRules.length === 1) {
777
- return (new MarkdownString(
778
- `_${( localize(11595, 'Auto approval denied by rule {0}', formatRuleLinks(uniqueRules)))}_`
779
- ));
780
- }
781
- else if (uniqueRules.length > 1) {
782
- return (new MarkdownString(
783
- `_${( localize(11596, 'Auto approval denied by rules {0}', formatRuleLinks(uniqueRules)))}_`
784
- ));
785
- }
786
- break;
787
- }
788
- }
789
- }
790
- return undefined;
791
- }
792
729
  };
793
730
  RunInTerminalTool = RunInTerminalTool_1 = ( __decorate([
794
- ( __param(0, IInstantiationService)),
731
+ ( __param(0, IChatService)),
795
732
  ( __param(1, IConfigurationService)),
796
- ( __param(2, ILanguageModelToolsService)),
797
- ( __param(3, IStorageService)),
798
- ( __param(4, ITerminalLogService)),
799
- ( __param(5, ITerminalProfileResolverService)),
800
- ( __param(6, ITerminalService)),
801
- ( __param(7, IRemoteAgentService)),
802
- ( __param(8, IChatService))
733
+ ( __param(2, IHistoryService)),
734
+ ( __param(3, IInstantiationService)),
735
+ ( __param(4, ILanguageModelToolsService)),
736
+ ( __param(5, IRemoteAgentService)),
737
+ ( __param(6, IStorageService)),
738
+ ( __param(7, ITerminalChatService)),
739
+ ( __param(8, ITerminalLogService)),
740
+ ( __param(9, ITerminalService)),
741
+ ( __param(10, IWorkspaceContextService))
803
742
  ], RunInTerminalTool));
804
743
  class BackgroundTerminalExecution extends Disposable {
805
- constructor(instance, _xterm, _commandLine, sessionId) {
744
+ constructor(instance, _xterm, _commandLine, sessionId, commandId) {
806
745
  super();
807
746
  this.instance = instance;
808
747
  this._xterm = _xterm;
809
748
  this._commandLine = _commandLine;
810
749
  this.sessionId = sessionId;
811
750
  this._startMarker = this._register(this._xterm.raw.registerMarker());
812
- this.instance.runCommand(this._commandLine, true);
751
+ this.instance.runCommand(this._commandLine, true, commandId);
813
752
  }
814
753
  getOutput(marker) {
815
754
  return getOutput(this.instance, marker ?? this._startMarker);
816
755
  }
817
756
  }
757
+ let TerminalProfileFetcher = class TerminalProfileFetcher {
758
+ constructor(_configurationService, _terminalProfileResolverService, _remoteAgentService) {
759
+ this._configurationService = _configurationService;
760
+ this._terminalProfileResolverService = _terminalProfileResolverService;
761
+ this._remoteAgentService = _remoteAgentService;
762
+ this.osBackend = this._remoteAgentService.getEnvironment().then(remoteEnv => remoteEnv?.os ?? OS);
763
+ }
764
+ async getCopilotProfile() {
765
+ const os = await this.osBackend;
766
+ const customChatAgentProfile = this._getChatTerminalProfile(os);
767
+ if (customChatAgentProfile) {
768
+ return customChatAgentProfile;
769
+ }
770
+ const defaultProfile = await this._terminalProfileResolverService.getDefaultProfile({
771
+ os,
772
+ remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority
773
+ });
774
+ if (basename(defaultProfile.path) === 'cmd.exe') {
775
+ return {
776
+ ...defaultProfile,
777
+ path: 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
778
+ profileName: 'PowerShell'
779
+ };
780
+ }
781
+ return { ...defaultProfile, icon: undefined };
782
+ }
783
+ async getCopilotShell() {
784
+ return (await this.getCopilotProfile()).path;
785
+ }
786
+ _getChatTerminalProfile(os) {
787
+ let profileSetting;
788
+ switch (os) {
789
+ case OperatingSystem.Windows:
790
+ profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileWindows;
791
+ break;
792
+ case OperatingSystem.Macintosh:
793
+ profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileMacOs;
794
+ break;
795
+ case OperatingSystem.Linux:
796
+ default:
797
+ profileSetting = TerminalChatAgentToolsSettingId.TerminalProfileLinux;
798
+ break;
799
+ }
800
+ const profile = this._configurationService.getValue(profileSetting);
801
+ if (this._isValidChatAgentTerminalProfile(profile)) {
802
+ return profile;
803
+ }
804
+ return undefined;
805
+ }
806
+ _isValidChatAgentTerminalProfile(profile) {
807
+ if (profile === null || profile === undefined || typeof profile !== 'object') {
808
+ return false;
809
+ }
810
+ if ('path' in profile && typeof profile.path === 'string') {
811
+ return true;
812
+ }
813
+ return false;
814
+ }
815
+ };
816
+ TerminalProfileFetcher = ( __decorate([
817
+ ( __param(0, IConfigurationService)),
818
+ ( __param(1, ITerminalProfileResolverService)),
819
+ ( __param(2, IRemoteAgentService))
820
+ ], TerminalProfileFetcher));
818
821
 
819
- export { RunInTerminalTool, RunInTerminalToolData };
822
+ export { RunInTerminalTool, TerminalProfileFetcher, createRunInTerminalToolData };