centaurus-cli 3.0.1 → 3.1.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 (552) hide show
  1. package/dist/ai/types.js +0 -1
  2. package/dist/ai/types.js.map +1 -1
  3. package/dist/cli-adapter.js +5047 -5158
  4. package/dist/cli-adapter.js.map +1 -1
  5. package/dist/commands/CommandParser.js +372 -315
  6. package/dist/commands/CommandParser.js.map +1 -1
  7. package/dist/config/build-config.js +11 -42
  8. package/dist/config/build-config.js.map +1 -1
  9. package/dist/config/defaultConfig.js +94 -82
  10. package/dist/config/defaultConfig.js.map +1 -1
  11. package/dist/config/manager.js +144 -160
  12. package/dist/config/manager.js.map +1 -1
  13. package/dist/config/mcp-config-manager.js +411 -364
  14. package/dist/config/mcp-config-manager.js.map +1 -1
  15. package/dist/config/models.js +118 -185
  16. package/dist/config/models.js.map +1 -1
  17. package/dist/config/slash-commands.js +186 -184
  18. package/dist/config/slash-commands.js.map +1 -1
  19. package/dist/config/types.js +33 -26
  20. package/dist/config/types.js.map +1 -1
  21. package/dist/context/command-detector.js +63 -67
  22. package/dist/context/command-detector.js.map +1 -1
  23. package/dist/context/context-manager.js +533 -518
  24. package/dist/context/context-manager.js.map +1 -1
  25. package/dist/context/handlers/docker-handler.js +518 -576
  26. package/dist/context/handlers/docker-handler.js.map +1 -1
  27. package/dist/context/handlers/ssh-handler.js +1050 -1109
  28. package/dist/context/handlers/ssh-handler.js.map +1 -1
  29. package/dist/context/handlers/wsl-handler.js +558 -630
  30. package/dist/context/handlers/wsl-handler.js.map +1 -1
  31. package/dist/context/index.js +42 -6
  32. package/dist/context/index.js.map +1 -1
  33. package/dist/context/subshell-handler.js +0 -4
  34. package/dist/context/subshell-handler.js.map +1 -1
  35. package/dist/context/types.js +20 -31
  36. package/dist/context/types.js.map +1 -1
  37. package/dist/hooks/useConnectivity.js +13 -10
  38. package/dist/hooks/useConnectivity.js.map +1 -1
  39. package/dist/hooks/useTerminalDimensions.js +67 -79
  40. package/dist/hooks/useTerminalDimensions.js.map +1 -1
  41. package/dist/index.js +228 -251
  42. package/dist/index.js.map +1 -1
  43. package/dist/mcp/mcp-command-handler.js +297 -260
  44. package/dist/mcp/mcp-command-handler.js.map +1 -1
  45. package/dist/mcp/mcp-server-manager.js +139 -155
  46. package/dist/mcp/mcp-server-manager.js.map +1 -1
  47. package/dist/mcp/mcp-tool-wrapper.js +74 -94
  48. package/dist/mcp/mcp-tool-wrapper.js.map +1 -1
  49. package/dist/services/ai-autocomplete-agent.js +169 -181
  50. package/dist/services/ai-autocomplete-agent.js.map +1 -1
  51. package/dist/services/ai-context-injector.js +180 -93
  52. package/dist/services/ai-context-injector.js.map +1 -1
  53. package/dist/services/ai-service-client.js +513 -456
  54. package/dist/services/ai-service-client.js.map +1 -1
  55. package/dist/services/api-client.js +443 -441
  56. package/dist/services/api-client.js.map +1 -1
  57. package/dist/services/auth-handler.js +162 -198
  58. package/dist/services/auth-handler.js.map +1 -1
  59. package/dist/services/background-task-manager.js +258 -282
  60. package/dist/services/background-task-manager.js.map +1 -1
  61. package/dist/services/checkpoint-manager.js +1526 -1512
  62. package/dist/services/checkpoint-manager.js.map +1 -1
  63. package/dist/services/clipboard-service.js +151 -200
  64. package/dist/services/clipboard-service.js.map +1 -1
  65. package/dist/services/connectivity-manager.js +63 -65
  66. package/dist/services/connectivity-manager.js.map +1 -1
  67. package/dist/services/conversation-manager.js +118 -121
  68. package/dist/services/conversation-manager.js.map +1 -1
  69. package/dist/services/environment-context-injector.js +160 -187
  70. package/dist/services/environment-context-injector.js.map +1 -1
  71. package/dist/services/fast-context-agent.js +203 -243
  72. package/dist/services/fast-context-agent.js.map +1 -1
  73. package/dist/services/input-detection-agent.js +190 -202
  74. package/dist/services/input-detection-agent.js.map +1 -1
  75. package/dist/services/input-requirement-detector.js +155 -189
  76. package/dist/services/input-requirement-detector.js.map +1 -1
  77. package/dist/services/local-chat-storage.js +342 -365
  78. package/dist/services/local-chat-storage.js.map +1 -1
  79. package/dist/services/monitored-shell-manager.js +225 -233
  80. package/dist/services/monitored-shell-manager.js.map +1 -1
  81. package/dist/services/ollama-service.js +293 -310
  82. package/dist/services/ollama-service.js.map +1 -1
  83. package/dist/services/rules-storage.js +142 -0
  84. package/dist/services/rules-storage.js.map +1 -0
  85. package/dist/services/session-quota-manager.js +219 -235
  86. package/dist/services/session-quota-manager.js.map +1 -1
  87. package/dist/services/shell-input-agent.js +299 -334
  88. package/dist/services/shell-input-agent.js.map +1 -1
  89. package/dist/services/sub-agent-manager.js +459 -501
  90. package/dist/services/sub-agent-manager.js.map +1 -1
  91. package/dist/services/warpify-detector.js +133 -183
  92. package/dist/services/warpify-detector.js.map +1 -1
  93. package/dist/services/workflow-storage.js +202 -217
  94. package/dist/services/workflow-storage.js.map +1 -1
  95. package/dist/test-ssh-handler.js +148 -193
  96. package/dist/test-ssh-handler.js.map +1 -1
  97. package/dist/tools/add-mcp.js +161 -0
  98. package/dist/tools/add-mcp.js.map +1 -0
  99. package/dist/tools/background-command.js +240 -273
  100. package/dist/tools/background-command.js.map +1 -1
  101. package/dist/tools/command.js +447 -440
  102. package/dist/tools/command.js.map +1 -1
  103. package/dist/tools/create-image.js +172 -202
  104. package/dist/tools/create-image.js.map +1 -1
  105. package/dist/tools/enter-remote-session.js +169 -215
  106. package/dist/tools/enter-remote-session.js.map +1 -1
  107. package/dist/tools/fast-context.js +60 -67
  108. package/dist/tools/fast-context.js.map +1 -1
  109. package/dist/tools/file-ops.js +601 -572
  110. package/dist/tools/file-ops.js.map +1 -1
  111. package/dist/tools/find-files.js +262 -303
  112. package/dist/tools/find-files.js.map +1 -1
  113. package/dist/tools/get-diff.js +423 -406
  114. package/dist/tools/get-diff.js.map +1 -1
  115. package/dist/tools/grep-search.js +966 -948
  116. package/dist/tools/grep-search.js.map +1 -1
  117. package/dist/tools/inspect-symbol.js +308 -323
  118. package/dist/tools/inspect-symbol.js.map +1 -1
  119. package/dist/tools/plan-mode.js +459 -503
  120. package/dist/tools/plan-mode.js.map +1 -1
  121. package/dist/tools/read-binary-file.js +160 -190
  122. package/dist/tools/read-binary-file.js.map +1 -1
  123. package/dist/tools/registry.js +100 -84
  124. package/dist/tools/registry.js.map +1 -1
  125. package/dist/tools/reproduce_issue.js +170 -151
  126. package/dist/tools/reproduce_issue.js.map +1 -1
  127. package/dist/tools/sub-agent.js +223 -228
  128. package/dist/tools/sub-agent.js.map +1 -1
  129. package/dist/tools/task-complete.js +28 -27
  130. package/dist/tools/task-complete.js.map +1 -1
  131. package/dist/tools/types.js +0 -1
  132. package/dist/tools/types.js.map +1 -1
  133. package/dist/tools/validation.js +96 -118
  134. package/dist/tools/validation.js.map +1 -1
  135. package/dist/tools/web-search.js +194 -194
  136. package/dist/tools/web-search.js.map +1 -1
  137. package/dist/tools/workflow-tool.js +77 -82
  138. package/dist/tools/workflow-tool.js.map +1 -1
  139. package/dist/types/index.js +0 -1
  140. package/dist/types/index.js.map +1 -1
  141. package/dist/types/rule.js +1 -0
  142. package/dist/types/rule.js.map +1 -0
  143. package/dist/types/workflow.js +0 -7
  144. package/dist/types/workflow.js.map +1 -1
  145. package/dist/ui/components/AgentTimer.js +24 -25
  146. package/dist/ui/components/AgentTimer.js.map +1 -1
  147. package/dist/ui/components/App.js +3266 -3263
  148. package/dist/ui/components/App.js.map +1 -1
  149. package/dist/ui/components/AuthScreen.js +22 -34
  150. package/dist/ui/components/AuthScreen.js.map +1 -1
  151. package/dist/ui/components/AuthWelcomeScreen.js +30 -24
  152. package/dist/ui/components/AuthWelcomeScreen.js.map +1 -1
  153. package/dist/ui/components/Breadcrumbs.js +53 -82
  154. package/dist/ui/components/Breadcrumbs.js.map +1 -1
  155. package/dist/ui/components/CircularSelectInput.js +59 -67
  156. package/dist/ui/components/CircularSelectInput.js.map +1 -1
  157. package/dist/ui/components/ClipboardFileAutocomplete.js +78 -39
  158. package/dist/ui/components/ClipboardFileAutocomplete.js.map +1 -1
  159. package/dist/ui/components/CodeBlock.js +24 -42
  160. package/dist/ui/components/CodeBlock.js.map +1 -1
  161. package/dist/ui/components/ConfigViewer.js +18 -25
  162. package/dist/ui/components/ConfigViewer.js.map +1 -1
  163. package/dist/ui/components/ConfirmPrompt.js +49 -71
  164. package/dist/ui/components/ConfirmPrompt.js.map +1 -1
  165. package/dist/ui/components/ConnectionStatusMessage.js +32 -83
  166. package/dist/ui/components/ConnectionStatusMessage.js.map +1 -1
  167. package/dist/ui/components/ContextWindowIndicator.js +34 -49
  168. package/dist/ui/components/ContextWindowIndicator.js.map +1 -1
  169. package/dist/ui/components/DetailedPlanReviewScreen.js +104 -106
  170. package/dist/ui/components/DetailedPlanReviewScreen.js.map +1 -1
  171. package/dist/ui/components/DiffViewer.js +68 -121
  172. package/dist/ui/components/DiffViewer.js.map +1 -1
  173. package/dist/ui/components/ErrorBoundary.js +40 -48
  174. package/dist/ui/components/ErrorBoundary.js.map +1 -1
  175. package/dist/ui/components/FileCreationPreview.js +29 -60
  176. package/dist/ui/components/FileCreationPreview.js.map +1 -1
  177. package/dist/ui/components/FileOperation.js +34 -29
  178. package/dist/ui/components/FileOperation.js.map +1 -1
  179. package/dist/ui/components/FileTagAutocomplete.js +55 -25
  180. package/dist/ui/components/FileTagAutocomplete.js.map +1 -1
  181. package/dist/ui/components/FontRecommendation.js.map +1 -1
  182. package/dist/ui/components/GitDiffBreadcrumb.js +29 -0
  183. package/dist/ui/components/GitDiffBreadcrumb.js.map +1 -0
  184. package/dist/ui/components/InputBox.js +1620 -2150
  185. package/dist/ui/components/InputBox.js.map +1 -1
  186. package/dist/ui/components/InteractiveShell.js +234 -352
  187. package/dist/ui/components/InteractiveShell.js.map +1 -1
  188. package/dist/ui/components/KeyboardHelp.js +34 -35
  189. package/dist/ui/components/KeyboardHelp.js.map +1 -1
  190. package/dist/ui/components/LoadingIndicator.js +22 -25
  191. package/dist/ui/components/LoadingIndicator.js.map +1 -1
  192. package/dist/ui/components/MCPAddScreen.js +40 -51
  193. package/dist/ui/components/MCPAddScreen.js.map +1 -1
  194. package/dist/ui/components/MCPListScreen.js +40 -48
  195. package/dist/ui/components/MCPListScreen.js.map +1 -1
  196. package/dist/ui/components/MCPServerListScreen.js +49 -56
  197. package/dist/ui/components/MCPServerListScreen.js.map +1 -1
  198. package/dist/ui/components/MarkdownRenderer.js +69 -96
  199. package/dist/ui/components/MarkdownRenderer.js.map +1 -1
  200. package/dist/ui/components/MessageBox.js +66 -48
  201. package/dist/ui/components/MessageBox.js.map +1 -1
  202. package/dist/ui/components/MessageDisplay.js +150 -142
  203. package/dist/ui/components/MessageDisplay.js.map +1 -1
  204. package/dist/ui/components/MonitorModeAIPanel.js +46 -65
  205. package/dist/ui/components/MonitorModeAIPanel.js.map +1 -1
  206. package/dist/ui/components/MultiLineInput.js +243 -277
  207. package/dist/ui/components/MultiLineInput.js.map +1 -1
  208. package/dist/ui/components/PasswordPrompt.js +37 -18
  209. package/dist/ui/components/PasswordPrompt.js.map +1 -1
  210. package/dist/ui/components/PlanAcceptedMessage.js +27 -38
  211. package/dist/ui/components/PlanAcceptedMessage.js.map +1 -1
  212. package/dist/ui/components/PlanReviewScreen.js +46 -50
  213. package/dist/ui/components/PlanReviewScreen.js.map +1 -1
  214. package/dist/ui/components/RulesEditorScreen.js +81 -0
  215. package/dist/ui/components/RulesEditorScreen.js.map +1 -0
  216. package/dist/ui/components/SelectPrompt.js +19 -8
  217. package/dist/ui/components/SelectPrompt.js.map +1 -1
  218. package/dist/ui/components/ShimmerText.js +44 -0
  219. package/dist/ui/components/ShimmerText.js.map +1 -0
  220. package/dist/ui/components/SlashCommandAutocomplete.js +49 -22
  221. package/dist/ui/components/SlashCommandAutocomplete.js.map +1 -1
  222. package/dist/ui/components/StatusBar.js +56 -87
  223. package/dist/ui/components/StatusBar.js.map +1 -1
  224. package/dist/ui/components/StreamingMessageDisplay.js +116 -99
  225. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
  226. package/dist/ui/components/TaskCompletedMessage.js +28 -23
  227. package/dist/ui/components/TaskCompletedMessage.js.map +1 -1
  228. package/dist/ui/components/TaskProgressIndicator.js +44 -70
  229. package/dist/ui/components/TaskProgressIndicator.js.map +1 -1
  230. package/dist/ui/components/ThinkingDisplay.js +44 -41
  231. package/dist/ui/components/ThinkingDisplay.js.map +1 -1
  232. package/dist/ui/components/ToolExecutionMessage.js +772 -1326
  233. package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
  234. package/dist/ui/components/ToolExecutionStatus.js +53 -84
  235. package/dist/ui/components/ToolExecutionStatus.js.map +1 -1
  236. package/dist/ui/components/ToolResult.js +22 -15
  237. package/dist/ui/components/ToolResult.js.map +1 -1
  238. package/dist/ui/components/VersionUpdatePrompt.js +88 -120
  239. package/dist/ui/components/VersionUpdatePrompt.js.map +1 -1
  240. package/dist/ui/components/WelcomeBanner.js +176 -26
  241. package/dist/ui/components/WelcomeBanner.js.map +1 -1
  242. package/dist/ui/components/WorkflowCreatorScreen.js +94 -161
  243. package/dist/ui/components/WorkflowCreatorScreen.js.map +1 -1
  244. package/dist/utils/ansi-encoder.js +30 -61
  245. package/dist/utils/ansi-encoder.js.map +1 -1
  246. package/dist/utils/chat-formatter.js +327 -305
  247. package/dist/utils/chat-formatter.js.map +1 -1
  248. package/dist/utils/command-history.js +152 -174
  249. package/dist/utils/command-history.js.map +1 -1
  250. package/dist/utils/context-sanitizer.js +49 -112
  251. package/dist/utils/context-sanitizer.js.map +1 -1
  252. package/dist/utils/conversation-logger.js +292 -324
  253. package/dist/utils/conversation-logger.js.map +1 -1
  254. package/dist/utils/custom-commands-manager.js +126 -131
  255. package/dist/utils/custom-commands-manager.js.map +1 -1
  256. package/dist/utils/editor-utils.js +732 -837
  257. package/dist/utils/editor-utils.js.map +1 -1
  258. package/dist/utils/file.js +174 -213
  259. package/dist/utils/file.js.map +1 -1
  260. package/dist/utils/git-stats.js +169 -0
  261. package/dist/utils/git-stats.js.map +1 -0
  262. package/dist/utils/input-classifier.js +960 -482
  263. package/dist/utils/input-classifier.js.map +1 -1
  264. package/dist/utils/logger.js +48 -73
  265. package/dist/utils/logger.js.map +1 -1
  266. package/dist/utils/markdown-parser.js +277 -310
  267. package/dist/utils/markdown-parser.js.map +1 -1
  268. package/dist/utils/rule-reference-resolver.js +54 -0
  269. package/dist/utils/rule-reference-resolver.js.map +1 -0
  270. package/dist/utils/shell.js +144 -156
  271. package/dist/utils/shell.js.map +1 -1
  272. package/dist/utils/state.js +23 -22
  273. package/dist/utils/state.js.map +1 -1
  274. package/dist/utils/syntax-checker.js +279 -327
  275. package/dist/utils/syntax-checker.js.map +1 -1
  276. package/dist/utils/terminal-output.js +199 -302
  277. package/dist/utils/terminal-output.js.map +1 -1
  278. package/dist/utils/text-clipboard.js +47 -70
  279. package/dist/utils/text-clipboard.js.map +1 -1
  280. package/dist/utils/unicode-sanitizer.js +134 -197
  281. package/dist/utils/unicode-sanitizer.js.map +1 -1
  282. package/dist/utils/version-checker.js +46 -56
  283. package/dist/utils/version-checker.js.map +1 -1
  284. package/package.json +6 -4
  285. package/dist/ai/types.d.ts +0 -20
  286. package/dist/ai/types.d.ts.map +0 -1
  287. package/dist/cli-adapter.d.ts +0 -514
  288. package/dist/cli-adapter.d.ts.map +0 -1
  289. package/dist/commands/CommandParser.d.ts +0 -27
  290. package/dist/commands/CommandParser.d.ts.map +0 -1
  291. package/dist/config/build-config.d.ts +0 -42
  292. package/dist/config/build-config.d.ts.map +0 -1
  293. package/dist/config/defaultConfig.d.ts +0 -79
  294. package/dist/config/defaultConfig.d.ts.map +0 -1
  295. package/dist/config/manager.d.ts +0 -62
  296. package/dist/config/manager.d.ts.map +0 -1
  297. package/dist/config/mcp-config-manager.d.ts +0 -79
  298. package/dist/config/mcp-config-manager.d.ts.map +0 -1
  299. package/dist/config/models.d.ts +0 -83
  300. package/dist/config/models.d.ts.map +0 -1
  301. package/dist/config/slash-commands.d.ts +0 -23
  302. package/dist/config/slash-commands.d.ts.map +0 -1
  303. package/dist/config/types.d.ts +0 -35
  304. package/dist/config/types.d.ts.map +0 -1
  305. package/dist/context/command-detector.d.ts +0 -50
  306. package/dist/context/command-detector.d.ts.map +0 -1
  307. package/dist/context/context-manager.d.ts +0 -157
  308. package/dist/context/context-manager.d.ts.map +0 -1
  309. package/dist/context/handlers/docker-handler.d.ts +0 -130
  310. package/dist/context/handlers/docker-handler.d.ts.map +0 -1
  311. package/dist/context/handlers/ssh-handler.d.ts +0 -201
  312. package/dist/context/handlers/ssh-handler.d.ts.map +0 -1
  313. package/dist/context/handlers/wsl-handler.d.ts +0 -146
  314. package/dist/context/handlers/wsl-handler.d.ts.map +0 -1
  315. package/dist/context/index.d.ts +0 -8
  316. package/dist/context/index.d.ts.map +0 -1
  317. package/dist/context/subshell-handler.d.ts +0 -165
  318. package/dist/context/subshell-handler.d.ts.map +0 -1
  319. package/dist/context/types.d.ts +0 -70
  320. package/dist/context/types.d.ts.map +0 -1
  321. package/dist/hooks/useConnectivity.d.ts +0 -2
  322. package/dist/hooks/useConnectivity.d.ts.map +0 -1
  323. package/dist/hooks/useTerminalDimensions.d.ts +0 -41
  324. package/dist/hooks/useTerminalDimensions.d.ts.map +0 -1
  325. package/dist/index.d.ts +0 -9
  326. package/dist/index.d.ts.map +0 -1
  327. package/dist/mcp/mcp-command-handler.d.ts +0 -47
  328. package/dist/mcp/mcp-command-handler.d.ts.map +0 -1
  329. package/dist/mcp/mcp-server-manager.d.ts +0 -30
  330. package/dist/mcp/mcp-server-manager.d.ts.map +0 -1
  331. package/dist/mcp/mcp-tool-wrapper.d.ts +0 -12
  332. package/dist/mcp/mcp-tool-wrapper.d.ts.map +0 -1
  333. package/dist/services/ai-autocomplete-agent.d.ts +0 -39
  334. package/dist/services/ai-autocomplete-agent.d.ts.map +0 -1
  335. package/dist/services/ai-context-injector.d.ts +0 -41
  336. package/dist/services/ai-context-injector.d.ts.map +0 -1
  337. package/dist/services/ai-service-client.d.ts +0 -128
  338. package/dist/services/ai-service-client.d.ts.map +0 -1
  339. package/dist/services/api-client.d.ts +0 -353
  340. package/dist/services/api-client.d.ts.map +0 -1
  341. package/dist/services/auth-handler.d.ts +0 -30
  342. package/dist/services/auth-handler.d.ts.map +0 -1
  343. package/dist/services/background-task-manager.d.ts +0 -114
  344. package/dist/services/background-task-manager.d.ts.map +0 -1
  345. package/dist/services/checkpoint-manager.d.ts +0 -204
  346. package/dist/services/checkpoint-manager.d.ts.map +0 -1
  347. package/dist/services/clipboard-service.d.ts +0 -37
  348. package/dist/services/clipboard-service.d.ts.map +0 -1
  349. package/dist/services/connectivity-manager.d.ts +0 -18
  350. package/dist/services/connectivity-manager.d.ts.map +0 -1
  351. package/dist/services/conversation-manager.d.ts +0 -73
  352. package/dist/services/conversation-manager.d.ts.map +0 -1
  353. package/dist/services/environment-context-injector.d.ts +0 -69
  354. package/dist/services/environment-context-injector.d.ts.map +0 -1
  355. package/dist/services/fast-context-agent.d.ts +0 -12
  356. package/dist/services/fast-context-agent.d.ts.map +0 -1
  357. package/dist/services/input-detection-agent.d.ts +0 -40
  358. package/dist/services/input-detection-agent.d.ts.map +0 -1
  359. package/dist/services/input-requirement-detector.d.ts +0 -28
  360. package/dist/services/input-requirement-detector.d.ts.map +0 -1
  361. package/dist/services/local-chat-storage.d.ts +0 -182
  362. package/dist/services/local-chat-storage.d.ts.map +0 -1
  363. package/dist/services/monitored-shell-manager.d.ts +0 -120
  364. package/dist/services/monitored-shell-manager.d.ts.map +0 -1
  365. package/dist/services/ollama-service.d.ts +0 -197
  366. package/dist/services/ollama-service.d.ts.map +0 -1
  367. package/dist/services/session-quota-manager.d.ts +0 -101
  368. package/dist/services/session-quota-manager.d.ts.map +0 -1
  369. package/dist/services/shell-input-agent.d.ts +0 -89
  370. package/dist/services/shell-input-agent.d.ts.map +0 -1
  371. package/dist/services/sub-agent-manager.d.ts +0 -140
  372. package/dist/services/sub-agent-manager.d.ts.map +0 -1
  373. package/dist/services/warpify-detector.d.ts +0 -43
  374. package/dist/services/warpify-detector.d.ts.map +0 -1
  375. package/dist/services/workflow-storage.d.ts +0 -72
  376. package/dist/services/workflow-storage.d.ts.map +0 -1
  377. package/dist/test-ssh-handler.d.ts +0 -8
  378. package/dist/test-ssh-handler.d.ts.map +0 -1
  379. package/dist/tools/background-command.d.ts +0 -11
  380. package/dist/tools/background-command.d.ts.map +0 -1
  381. package/dist/tools/command.d.ts +0 -3
  382. package/dist/tools/command.d.ts.map +0 -1
  383. package/dist/tools/create-image.d.ts +0 -10
  384. package/dist/tools/create-image.d.ts.map +0 -1
  385. package/dist/tools/enter-remote-session.d.ts +0 -48
  386. package/dist/tools/enter-remote-session.d.ts.map +0 -1
  387. package/dist/tools/fast-context.d.ts +0 -3
  388. package/dist/tools/fast-context.d.ts.map +0 -1
  389. package/dist/tools/file-ops.d.ts +0 -7
  390. package/dist/tools/file-ops.d.ts.map +0 -1
  391. package/dist/tools/find-files.d.ts +0 -49
  392. package/dist/tools/find-files.d.ts.map +0 -1
  393. package/dist/tools/get-diff.d.ts +0 -14
  394. package/dist/tools/get-diff.d.ts.map +0 -1
  395. package/dist/tools/grep-search.d.ts +0 -155
  396. package/dist/tools/grep-search.d.ts.map +0 -1
  397. package/dist/tools/inspect-symbol.d.ts +0 -32
  398. package/dist/tools/inspect-symbol.d.ts.map +0 -1
  399. package/dist/tools/plan-mode.d.ts +0 -140
  400. package/dist/tools/plan-mode.d.ts.map +0 -1
  401. package/dist/tools/read-binary-file.d.ts +0 -10
  402. package/dist/tools/read-binary-file.d.ts.map +0 -1
  403. package/dist/tools/registry.d.ts +0 -31
  404. package/dist/tools/registry.d.ts.map +0 -1
  405. package/dist/tools/reproduce_issue.d.ts +0 -2
  406. package/dist/tools/reproduce_issue.d.ts.map +0 -1
  407. package/dist/tools/sub-agent.d.ts +0 -9
  408. package/dist/tools/sub-agent.d.ts.map +0 -1
  409. package/dist/tools/task-complete.d.ts +0 -3
  410. package/dist/tools/task-complete.d.ts.map +0 -1
  411. package/dist/tools/types.d.ts +0 -40
  412. package/dist/tools/types.d.ts.map +0 -1
  413. package/dist/tools/validation.d.ts +0 -47
  414. package/dist/tools/validation.d.ts.map +0 -1
  415. package/dist/tools/web-search.d.ts +0 -24
  416. package/dist/tools/web-search.d.ts.map +0 -1
  417. package/dist/tools/workflow-tool.d.ts +0 -11
  418. package/dist/tools/workflow-tool.d.ts.map +0 -1
  419. package/dist/types/index.d.ts +0 -123
  420. package/dist/types/index.d.ts.map +0 -1
  421. package/dist/types/workflow.d.ts +0 -110
  422. package/dist/types/workflow.d.ts.map +0 -1
  423. package/dist/ui/components/AgentTimer.d.ts +0 -7
  424. package/dist/ui/components/AgentTimer.d.ts.map +0 -1
  425. package/dist/ui/components/App.d.ts +0 -197
  426. package/dist/ui/components/App.d.ts.map +0 -1
  427. package/dist/ui/components/AuthScreen.d.ts +0 -8
  428. package/dist/ui/components/AuthScreen.d.ts.map +0 -1
  429. package/dist/ui/components/AuthWelcomeScreen.d.ts +0 -8
  430. package/dist/ui/components/AuthWelcomeScreen.d.ts.map +0 -1
  431. package/dist/ui/components/Breadcrumbs.d.ts +0 -13
  432. package/dist/ui/components/Breadcrumbs.d.ts.map +0 -1
  433. package/dist/ui/components/CircularSelectInput.d.ts +0 -24
  434. package/dist/ui/components/CircularSelectInput.d.ts.map +0 -1
  435. package/dist/ui/components/ClipboardFileAutocomplete.d.ts +0 -10
  436. package/dist/ui/components/ClipboardFileAutocomplete.d.ts.map +0 -1
  437. package/dist/ui/components/CodeBlock.d.ts +0 -9
  438. package/dist/ui/components/CodeBlock.d.ts.map +0 -1
  439. package/dist/ui/components/ConfigViewer.d.ts +0 -11
  440. package/dist/ui/components/ConfigViewer.d.ts.map +0 -1
  441. package/dist/ui/components/ConfirmPrompt.d.ts +0 -13
  442. package/dist/ui/components/ConfirmPrompt.d.ts.map +0 -1
  443. package/dist/ui/components/ConnectionStatusMessage.d.ts +0 -17
  444. package/dist/ui/components/ConnectionStatusMessage.d.ts.map +0 -1
  445. package/dist/ui/components/ContextWindowIndicator.d.ts +0 -8
  446. package/dist/ui/components/ContextWindowIndicator.d.ts.map +0 -1
  447. package/dist/ui/components/DetailedPlanReviewScreen.d.ts +0 -17
  448. package/dist/ui/components/DetailedPlanReviewScreen.d.ts.map +0 -1
  449. package/dist/ui/components/DiffViewer.d.ts +0 -9
  450. package/dist/ui/components/DiffViewer.d.ts.map +0 -1
  451. package/dist/ui/components/ErrorBoundary.d.ts +0 -17
  452. package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
  453. package/dist/ui/components/FileCreationPreview.d.ts +0 -8
  454. package/dist/ui/components/FileCreationPreview.d.ts.map +0 -1
  455. package/dist/ui/components/FileOperation.d.ts +0 -10
  456. package/dist/ui/components/FileOperation.d.ts.map +0 -1
  457. package/dist/ui/components/FileTagAutocomplete.d.ts +0 -11
  458. package/dist/ui/components/FileTagAutocomplete.d.ts.map +0 -1
  459. package/dist/ui/components/FontRecommendation.d.ts +0 -1
  460. package/dist/ui/components/FontRecommendation.d.ts.map +0 -1
  461. package/dist/ui/components/InputBox.d.ts +0 -42
  462. package/dist/ui/components/InputBox.d.ts.map +0 -1
  463. package/dist/ui/components/InteractiveShell.d.ts +0 -30
  464. package/dist/ui/components/InteractiveShell.d.ts.map +0 -1
  465. package/dist/ui/components/KeyboardHelp.d.ts +0 -7
  466. package/dist/ui/components/KeyboardHelp.d.ts.map +0 -1
  467. package/dist/ui/components/LoadingIndicator.d.ts +0 -3
  468. package/dist/ui/components/LoadingIndicator.d.ts.map +0 -1
  469. package/dist/ui/components/MCPAddScreen.d.ts +0 -13
  470. package/dist/ui/components/MCPAddScreen.d.ts.map +0 -1
  471. package/dist/ui/components/MCPListScreen.d.ts +0 -17
  472. package/dist/ui/components/MCPListScreen.d.ts.map +0 -1
  473. package/dist/ui/components/MCPServerListScreen.d.ts +0 -16
  474. package/dist/ui/components/MCPServerListScreen.d.ts.map +0 -1
  475. package/dist/ui/components/MarkdownRenderer.d.ts +0 -8
  476. package/dist/ui/components/MarkdownRenderer.d.ts.map +0 -1
  477. package/dist/ui/components/MessageBox.d.ts +0 -10
  478. package/dist/ui/components/MessageBox.d.ts.map +0 -1
  479. package/dist/ui/components/MessageDisplay.d.ts +0 -14
  480. package/dist/ui/components/MessageDisplay.d.ts.map +0 -1
  481. package/dist/ui/components/MonitorModeAIPanel.d.ts +0 -23
  482. package/dist/ui/components/MonitorModeAIPanel.d.ts.map +0 -1
  483. package/dist/ui/components/MultiLineInput.d.ts +0 -13
  484. package/dist/ui/components/MultiLineInput.d.ts.map +0 -1
  485. package/dist/ui/components/PasswordPrompt.d.ts +0 -9
  486. package/dist/ui/components/PasswordPrompt.d.ts.map +0 -1
  487. package/dist/ui/components/PlanAcceptedMessage.d.ts +0 -20
  488. package/dist/ui/components/PlanAcceptedMessage.d.ts.map +0 -1
  489. package/dist/ui/components/PlanReviewScreen.d.ts +0 -14
  490. package/dist/ui/components/PlanReviewScreen.d.ts.map +0 -1
  491. package/dist/ui/components/SelectPrompt.d.ts +0 -12
  492. package/dist/ui/components/SelectPrompt.d.ts.map +0 -1
  493. package/dist/ui/components/SlashCommandAutocomplete.d.ts +0 -13
  494. package/dist/ui/components/SlashCommandAutocomplete.d.ts.map +0 -1
  495. package/dist/ui/components/StatusBar.d.ts +0 -14
  496. package/dist/ui/components/StatusBar.d.ts.map +0 -1
  497. package/dist/ui/components/StreamingMessageDisplay.d.ts +0 -15
  498. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +0 -1
  499. package/dist/ui/components/TaskCompletedMessage.d.ts +0 -14
  500. package/dist/ui/components/TaskCompletedMessage.d.ts.map +0 -1
  501. package/dist/ui/components/TaskProgressIndicator.d.ts +0 -18
  502. package/dist/ui/components/TaskProgressIndicator.d.ts.map +0 -1
  503. package/dist/ui/components/ThinkingDisplay.d.ts +0 -15
  504. package/dist/ui/components/ThinkingDisplay.d.ts.map +0 -1
  505. package/dist/ui/components/ToolExecutionMessage.d.ts +0 -8
  506. package/dist/ui/components/ToolExecutionMessage.d.ts.map +0 -1
  507. package/dist/ui/components/ToolExecutionStatus.d.ts +0 -10
  508. package/dist/ui/components/ToolExecutionStatus.d.ts.map +0 -1
  509. package/dist/ui/components/ToolResult.d.ts +0 -10
  510. package/dist/ui/components/ToolResult.d.ts.map +0 -1
  511. package/dist/ui/components/VersionUpdatePrompt.d.ts +0 -9
  512. package/dist/ui/components/VersionUpdatePrompt.d.ts.map +0 -1
  513. package/dist/ui/components/WelcomeBanner.d.ts +0 -3
  514. package/dist/ui/components/WelcomeBanner.d.ts.map +0 -1
  515. package/dist/ui/components/WorkflowCreatorScreen.d.ts +0 -25
  516. package/dist/ui/components/WorkflowCreatorScreen.d.ts.map +0 -1
  517. package/dist/utils/ansi-encoder.d.ts +0 -7
  518. package/dist/utils/ansi-encoder.d.ts.map +0 -1
  519. package/dist/utils/chat-formatter.d.ts +0 -12
  520. package/dist/utils/chat-formatter.d.ts.map +0 -1
  521. package/dist/utils/command-history.d.ts +0 -24
  522. package/dist/utils/command-history.d.ts.map +0 -1
  523. package/dist/utils/context-sanitizer.d.ts +0 -50
  524. package/dist/utils/context-sanitizer.d.ts.map +0 -1
  525. package/dist/utils/conversation-logger.d.ts +0 -142
  526. package/dist/utils/conversation-logger.d.ts.map +0 -1
  527. package/dist/utils/custom-commands-manager.d.ts +0 -59
  528. package/dist/utils/custom-commands-manager.d.ts.map +0 -1
  529. package/dist/utils/editor-utils.d.ts +0 -101
  530. package/dist/utils/editor-utils.d.ts.map +0 -1
  531. package/dist/utils/file.d.ts +0 -61
  532. package/dist/utils/file.d.ts.map +0 -1
  533. package/dist/utils/input-classifier.d.ts +0 -25
  534. package/dist/utils/input-classifier.d.ts.map +0 -1
  535. package/dist/utils/logger.d.ts +0 -17
  536. package/dist/utils/logger.d.ts.map +0 -1
  537. package/dist/utils/markdown-parser.d.ts +0 -60
  538. package/dist/utils/markdown-parser.d.ts.map +0 -1
  539. package/dist/utils/shell.d.ts +0 -47
  540. package/dist/utils/shell.d.ts.map +0 -1
  541. package/dist/utils/state.d.ts +0 -13
  542. package/dist/utils/state.d.ts.map +0 -1
  543. package/dist/utils/syntax-checker.d.ts +0 -24
  544. package/dist/utils/syntax-checker.d.ts.map +0 -1
  545. package/dist/utils/terminal-output.d.ts +0 -25
  546. package/dist/utils/terminal-output.d.ts.map +0 -1
  547. package/dist/utils/text-clipboard.d.ts +0 -12
  548. package/dist/utils/text-clipboard.d.ts.map +0 -1
  549. package/dist/utils/unicode-sanitizer.d.ts +0 -44
  550. package/dist/utils/unicode-sanitizer.d.ts.map +0 -1
  551. package/dist/utils/version-checker.d.ts +0 -14
  552. package/dist/utils/version-checker.d.ts.map +0 -1
@@ -1,290 +1,257 @@
1
- /**
2
- * Background Command Tool
3
- *
4
- * Allows the AI to execute commands in the background (non-blocking),
5
- * check their status, and kill/terminate them.
6
- *
7
- * Uses the existing BackgroundTaskManager singleton.
8
- */
9
- import { BackgroundTaskManager } from '../services/background-task-manager.js';
10
- import { runSSHCommand, runLocalPty } from '../utils/editor-utils.js';
11
- export const backgroundCommandTool = {
12
- schema: {
13
- name: 'background_command',
14
- description: `Execute shell commands in the background, check their status, or kill them. This tool is NON-BLOCKING - when you start a command, the tool returns immediately with a task ID while the command continues running in the background.
15
-
16
- USE CASES:
17
- - Running development servers (npm run dev, python -m http.server, etc.)
18
- - Running long-running processes (builds, tests, watchers)
19
- - Running multiple commands concurrently
20
-
21
- ACTIONS:
22
- 1. "start" - Start a new background command. Returns a task_id immediately.
23
- 2. "status" - Check the status and output of a background task. Use this to monitor progress.
24
- 3. "kill" - Terminate a running background task.
25
- 4. "wait" - Pause execution for a specified duration. Use this instead of repeatedly checking status.
26
-
27
- IMPORTANT:
28
- - After starting a task, you can continue with other work while it runs.
29
- - Use "status" periodically to check on long-running tasks.
30
- - Use "wait" to pause before checking status again (e.g., wait 30 seconds for a build to complete).
31
- - Always clean up tasks with "kill" when they're no longer needed.
1
+ import { BackgroundTaskManager } from "../services/background-task-manager.js";
2
+ import { runSSHCommand, runLocalPty } from "../utils/editor-utils.js";
3
+ import * as path from "path";
4
+ function resolveBackgroundCommandCwd(currentContext, contextCwd, commandCwd) {
5
+ if (currentContext.type === "local") {
6
+ return path.resolve(contextCwd, commandCwd);
7
+ }
8
+ const remoteBase = currentContext.metadata?.workingDirectory || contextCwd || "~";
9
+ return path.posix.isAbsolute(commandCwd) ? commandCwd : path.posix.join(remoteBase, commandCwd);
10
+ }
11
+ const backgroundCommandTool = {
12
+ schema: {
13
+ name: "background_command",
14
+ description: `Execute shell commands in the background, check their status, or kill them. This tool is NON-BLOCKING - when you start a command, the tool returns immediately with a task ID while the command continues running in the background.
15
+
16
+ USE CASES:
17
+ - Running development servers (npm run dev, python -m http.server, etc.)
18
+ - Running long-running processes (builds, tests, watchers)
19
+ - Running multiple commands concurrently
20
+
21
+ ACTIONS:
22
+ 1. "start" - Start a new background command. Returns a task_id immediately.
23
+ 2. "status" - Check the status and output of a background task. Use this to monitor progress.
24
+ 3. "kill" - Terminate a running background task.
25
+ 4. "wait" - Pause execution for a specified duration. Use this instead of repeatedly checking status.
26
+
27
+ IMPORTANT:
28
+ - After starting a task, you can continue with other work while it runs.
29
+ - Use "status" periodically to check on long-running tasks.
30
+ - Use "wait" to pause before checking status again (e.g., wait 30 seconds for a build to complete).
31
+ - Always clean up tasks with "kill" when they're no longer needed.
32
32
  - The task_id returned from "start" must be saved to use with "status" or "kill".`,
33
- parameters: {
34
- type: 'object',
35
- properties: {
36
- reason_text: {
37
- type: 'string',
38
- description: 'REQUIRED: A brief explanation of what you are doing with this background command.',
39
- },
40
- action: {
41
- type: 'string',
42
- enum: ['start', 'status', 'kill', 'wait'],
43
- description: 'The action to perform: "start" to run a new command, "status" to check a task, "kill" to terminate a task, "wait" to pause execution.',
44
- },
45
- command: {
46
- type: 'string',
47
- description: 'The shell command to execute. REQUIRED when action is "start".',
48
- },
49
- cwd: {
50
- type: 'string',
51
- description: 'The working directory for the command. REQUIRED when action is "start".',
52
- },
53
- task_id: {
54
- type: 'string',
55
- description: 'The task ID to check or kill. REQUIRED when action is "status" or "kill".',
56
- },
57
- output_lines: {
58
- type: 'integer',
59
- description: 'Number of lines of output to return (from the end). Default: 50. Only used with "status" action.',
60
- },
61
- wait_seconds: {
62
- type: 'integer',
63
- description: 'Number of seconds to wait. REQUIRED when action is "wait". Use this to pause before checking task status again.',
64
- },
65
- },
66
- required: ['reason_text', 'action'],
33
+ parameters: {
34
+ type: "object",
35
+ properties: {
36
+ reason_text: {
37
+ type: "string",
38
+ description: "REQUIRED: A brief explanation of what you are doing with this background command."
39
+ },
40
+ action: {
41
+ type: "string",
42
+ enum: ["start", "status", "kill", "wait"],
43
+ description: 'The action to perform: "start" to run a new command, "status" to check a task, "kill" to terminate a task, "wait" to pause execution.'
44
+ },
45
+ command: {
46
+ type: "string",
47
+ description: 'The shell command to execute. REQUIRED when action is "start".'
48
+ },
49
+ cwd: {
50
+ type: "string",
51
+ description: 'The working directory for the command. REQUIRED when action is "start".'
52
+ },
53
+ task_id: {
54
+ type: "string",
55
+ description: 'The task ID to check or kill. REQUIRED when action is "status" or "kill".'
67
56
  },
68
- },
69
- async execute(args, context) {
70
- const { action, command, cwd, task_id, output_lines = 50, wait_seconds } = args;
71
- switch (action) {
72
- case 'start': {
73
- // Validate required parameters for start
74
- if (!command) {
75
- throw new Error('Missing required parameter "command" for action "start"');
76
- }
77
- if (!cwd) {
78
- throw new Error('Missing required parameter "cwd" for action "start"');
79
- }
80
- // Check for remote context
81
- // The context object passed to execute contains the contextManager
82
- const contextManager = context.contextManager;
83
- // Get the full context stack to handle nested environments
84
- // If getContextStack is not available (older version), fall back to checking current context
85
- let stack = [];
86
- if (typeof contextManager.getContextStack === 'function') {
87
- stack = contextManager.getContextStack();
88
- }
89
- else {
90
- // Fallback for safety
91
- const current = contextManager.getCurrentContext();
92
- if (current)
93
- stack = [current];
94
- }
95
- let currentCommand = command;
96
- // Iterate from the target context (top of stack) down to the root
97
- for (let i = stack.length - 1; i >= 0; i--) {
98
- const ctx = stack[i];
99
- const isTarget = i === stack.length - 1;
100
- // Determine the working directory to use for this execution layer
101
- // If this is the target layer, use the user-provided cwd
102
- // If this is an intermediate layer, use its tracked working directory
103
- const executionCwd = isTarget ? cwd : ctx.metadata.workingDirectory;
104
- // 1. Check if this context has a direct protocol executor (e.g. active SSH client)
105
- if (ctx.type === 'ssh' && ctx.handler?.client) {
106
- const sshClient = ctx.handler.client;
107
- // Start task tracking
108
- const remoteTask = BackgroundTaskManager.startRemoteTask(command, // Original command for display
109
- cwd, // Original CWD for display
110
- ctx.type // Context type
111
- );
112
- // Execute via SSH PTY
113
- const sshPty = runSSHCommand(sshClient, currentCommand, // The accumulated (possibly wrapped) command
114
- executionCwd, remoteTask.onData, remoteTask.onExit);
115
- remoteTask.setRemotePty(sshPty);
116
- return formatStartResponse(remoteTask.id, command, cwd, ctx.type);
117
- }
118
- // 2. Check if this is the local root context
119
- if (ctx.type === 'local') {
120
- // Start task tracking
121
- const remoteTask = BackgroundTaskManager.startRemoteTask(command, cwd, 'local');
122
- // Execute via Local PTY (which might be running a wrapped command like "wsl ..." or "docker ...")
123
- const localPty = runLocalPty(currentCommand, executionCwd, // Use the local CWD
124
- remoteTask.onData, remoteTask.onExit);
125
- remoteTask.setRemotePty(localPty);
126
- return formatStartResponse(remoteTask.id, command, cwd, 'local');
127
- }
128
- // 3. Otherwise, WRAP the command for the next iteration (parent)
129
- if (ctx.type === 'docker') {
130
- const containerId = ctx.metadata.containerId;
131
- if (!containerId)
132
- throw new Error('Docker context missing containerId');
133
- currentCommand = buildDockerCommand(containerId, executionCwd, currentCommand);
134
- }
135
- else if (ctx.type === 'wsl') {
136
- const distro = ctx.metadata.distroName || 'Ubuntu';
137
- currentCommand = buildWSLCommand(distro, executionCwd, currentCommand);
138
- }
139
- else if (ctx.type === 'ssh') {
140
- // Fallback for SSH without accessible client (e.g. wrapped command)
141
- currentCommand = buildSSHCommand(ctx.metadata, executionCwd, currentCommand);
142
- }
143
- else {
144
- // Unknown context type, try to pass through or error?
145
- // For now we error to be safe, or just wrap in sh -c?
146
- throw new Error(`Unsupported context type for wrapping: ${ctx.type}`);
147
- }
148
- }
149
- throw new Error('Failed to execute command: Reached end of context stack without execution.');
150
- }
151
- case 'status': {
152
- // Validate required parameters for status
153
- if (!task_id) {
154
- throw new Error('Missing required parameter "task_id" for action "status"');
155
- }
156
- const task = BackgroundTaskManager.getTask(task_id);
157
- if (!task) {
158
- // List all available tasks to help the AI
159
- const allTasks = BackgroundTaskManager.getAllTasks();
160
- if (allTasks.length === 0) {
161
- throw new Error(`Task "${task_id}" not found. There are no background tasks currently tracked.`);
162
- }
163
- const taskList = allTasks.map(t => `- ${t.id} (${t.isRunning ? 'running' : 'completed'}): ${t.command}`).join('\n');
164
- throw new Error(`Task "${task_id}" not found.\n\nAvailable tasks:\n${taskList}`);
165
- }
166
- // Get the output (last N lines)
167
- const fullOutput = task.output;
168
- const lines = fullOutput.split('\n');
169
- const outputToShow = lines.slice(-output_lines).join('\n');
170
- const truncated = lines.length > output_lines;
171
- const durationMs = Date.now() - task.startTime.getTime();
172
- const durationSec = Math.round(durationMs / 1000);
173
- let statusText = '';
174
- if (task.isRunning) {
175
- statusText = `**Status:** šŸ”„ Running (${durationSec}s)`;
176
- }
177
- else if (task.exitCode === 0) {
178
- statusText = `**Status:** āœ… Completed successfully (exit code: 0)`;
179
- }
180
- else if (task.exitCode !== undefined) {
181
- statusText = `**Status:** āŒ Failed (exit code: ${task.exitCode})`;
182
- }
183
- else if (task.error) {
184
- statusText = `**Status:** āŒ Error: ${task.error}`;
185
- }
186
- else {
187
- statusText = `**Status:** ā¹ļø Stopped`;
188
- }
189
- const remoteLabel = task.remoteContext ? ` [${task.remoteContext}]` : '';
190
- return `Background Task Status${remoteLabel}
191
-
192
- **Task ID:** ${task_id}
193
- **Command:** ${task.command}
194
- **Working Directory:** ${task.cwd}
195
- ${statusText}
196
-
197
- **Output${truncated ? ` (last ${output_lines} lines)` : ''}:**
198
- \`\`\`
199
- ${outputToShow || '(no output yet)'}
57
+ output_lines: {
58
+ type: "integer",
59
+ description: 'Number of lines of output to return (from the end). Default: 50. Only used with "status" action.'
60
+ },
61
+ wait_seconds: {
62
+ type: "integer",
63
+ description: 'Number of seconds to wait. REQUIRED when action is "wait". Use this to pause before checking task status again.'
64
+ }
65
+ },
66
+ required: ["reason_text", "action"]
67
+ }
68
+ },
69
+ async execute(args, context) {
70
+ const { action, command, cwd, task_id, output_lines = 50, wait_seconds } = args;
71
+ switch (action) {
72
+ case "start": {
73
+ if (!command) {
74
+ throw new Error('Missing required parameter "command" for action "start"');
75
+ }
76
+ if (!cwd) {
77
+ throw new Error('Missing required parameter "cwd" for action "start"');
78
+ }
79
+ const contextManager = context.contextManager;
80
+ const activeContext = contextManager.getCurrentContext();
81
+ let stack = [];
82
+ if (typeof contextManager.getContextStack === "function") {
83
+ stack = contextManager.getContextStack();
84
+ } else {
85
+ const current = contextManager.getCurrentContext();
86
+ if (current) stack = [current];
87
+ }
88
+ let currentCommand = command;
89
+ for (let i = stack.length - 1; i >= 0; i--) {
90
+ const ctx = stack[i];
91
+ const isTarget = i === stack.length - 1;
92
+ const executionCwd = isTarget ? cwd : ctx.metadata.workingDirectory;
93
+ if (ctx.type === "ssh" && ctx.handler?.client) {
94
+ const sshClient = ctx.handler.client;
95
+ const remoteTask = BackgroundTaskManager.startRemoteTask(
96
+ command,
97
+ // Original command for display
98
+ cwd,
99
+ // Original CWD for display
100
+ ctx.type
101
+ // Context type
102
+ );
103
+ const sshPty = runSSHCommand(
104
+ sshClient,
105
+ currentCommand,
106
+ // The accumulated (possibly wrapped) command
107
+ executionCwd,
108
+ remoteTask.onData,
109
+ remoteTask.onExit
110
+ );
111
+ remoteTask.setRemotePty(sshPty);
112
+ return formatStartResponse(remoteTask.id, command, cwd, ctx.type);
113
+ }
114
+ if (ctx.type === "local") {
115
+ const remoteTask = BackgroundTaskManager.startRemoteTask(
116
+ command,
117
+ cwd,
118
+ "local"
119
+ );
120
+ const localPty = runLocalPty(
121
+ currentCommand,
122
+ executionCwd,
123
+ // Use the local CWD
124
+ remoteTask.onData,
125
+ remoteTask.onExit
126
+ );
127
+ remoteTask.setRemotePty(localPty);
128
+ return formatStartResponse(remoteTask.id, command, cwd, "local");
129
+ }
130
+ if (ctx.type === "docker") {
131
+ const containerId = ctx.metadata.containerId;
132
+ if (!containerId) throw new Error("Docker context missing containerId");
133
+ currentCommand = buildDockerCommand(containerId, executionCwd, currentCommand);
134
+ } else if (ctx.type === "wsl") {
135
+ const distro = ctx.metadata.distroName || "Ubuntu";
136
+ currentCommand = buildWSLCommand(distro, executionCwd, currentCommand);
137
+ } else if (ctx.type === "ssh") {
138
+ currentCommand = buildSSHCommand(ctx.metadata, executionCwd, currentCommand);
139
+ } else {
140
+ throw new Error(`Unsupported context type for wrapping: ${ctx.type}`);
141
+ }
142
+ }
143
+ throw new Error("Failed to execute command: Reached end of context stack without execution.");
144
+ }
145
+ case "status": {
146
+ if (!task_id) {
147
+ throw new Error('Missing required parameter "task_id" for action "status"');
148
+ }
149
+ const task = BackgroundTaskManager.getTask(task_id);
150
+ if (!task) {
151
+ const allTasks = BackgroundTaskManager.getAllTasks();
152
+ if (allTasks.length === 0) {
153
+ throw new Error(`Task "${task_id}" not found. There are no background tasks currently tracked.`);
154
+ }
155
+ const taskList = allTasks.map((t) => `- ${t.id} (${t.isRunning ? "running" : "completed"}): ${t.command}`).join("\n");
156
+ throw new Error(`Task "${task_id}" not found.
157
+
158
+ Available tasks:
159
+ ${taskList}`);
160
+ }
161
+ const fullOutput = task.output;
162
+ const lines = fullOutput.split("\n");
163
+ const outputToShow = lines.slice(-output_lines).join("\n");
164
+ const truncated = lines.length > output_lines;
165
+ const durationMs = Date.now() - task.startTime.getTime();
166
+ const durationSec = Math.round(durationMs / 1e3);
167
+ let statusText = "";
168
+ if (task.isRunning) {
169
+ statusText = `**Status:** \u{1F504} Running (${durationSec}s)`;
170
+ } else if (task.exitCode === 0) {
171
+ statusText = `**Status:** \u2705 Completed successfully (exit code: 0)`;
172
+ } else if (task.exitCode !== void 0) {
173
+ statusText = `**Status:** \u274C Failed (exit code: ${task.exitCode})`;
174
+ } else if (task.error) {
175
+ statusText = `**Status:** \u274C Error: ${task.error}`;
176
+ } else {
177
+ statusText = `**Status:** \u23F9\uFE0F Stopped`;
178
+ }
179
+ const remoteLabel = task.remoteContext ? ` [${task.remoteContext}]` : "";
180
+ return `Background Task Status${remoteLabel}
181
+
182
+ **Task ID:** ${task_id}
183
+ **Command:** ${task.command}
184
+ **Working Directory:** ${task.cwd}
185
+ ${statusText}
186
+
187
+ **Output${truncated ? ` (last ${output_lines} lines)` : ""}:**
188
+ \`\`\`
189
+ ${outputToShow || "(no output yet)"}
200
190
  \`\`\``;
201
- }
202
- case 'kill': {
203
- // Validate required parameters for kill
204
- if (!task_id) {
205
- throw new Error('Missing required parameter "task_id" for action "kill"');
206
- }
207
- const task = BackgroundTaskManager.getTask(task_id);
208
- if (!task) {
209
- // Try to find if it was recently killed or doesn't exist
210
- throw new Error(`Task "${task_id}" not found.`);
211
- }
212
- if (!task.isRunning) {
213
- return `Task "${task_id}" is not running (already completed or stopped). No action taken.`;
214
- }
215
- // For remote tasks, we might need to do special cleanup,
216
- // but BackgroundTaskManager.cancelTask() handles calling the pty.kill()
217
- const success = BackgroundTaskManager.cancelTask(task_id);
218
- if (success) {
219
- return `Background task "${task_id}" has been terminated.
220
-
221
- **Command:** ${task.command}
222
- **Status:** ā¹ļø Killed by request`;
223
- }
224
- else {
225
- throw new Error(`Failed to kill task "${task_id}". The task may have already completed.`);
226
- }
227
- }
228
- case 'wait': {
229
- // Validate required parameters for wait
230
- if (!wait_seconds) {
231
- throw new Error('Missing required parameter "wait_seconds" for action "wait"');
232
- }
233
- if (wait_seconds < 1 || wait_seconds > 300) {
234
- throw new Error('wait_seconds must be between 1 and 300 (5 minutes)');
235
- }
236
- // Create a promise that resolves after the specified duration
237
- await new Promise(resolve => setTimeout(resolve, wait_seconds * 1000));
238
- return `Waited for ${wait_seconds} second${wait_seconds !== 1 ? 's' : ''}.
239
-
240
- ā±ļø The execution has been paused for the requested duration. You can now continue with the next action.`;
241
- }
242
- default:
243
- throw new Error(`Unknown action "${action}". Valid actions are: "start", "status", "kill", "wait".`);
191
+ }
192
+ case "kill": {
193
+ if (!task_id) {
194
+ throw new Error('Missing required parameter "task_id" for action "kill"');
195
+ }
196
+ const task = BackgroundTaskManager.getTask(task_id);
197
+ if (!task) {
198
+ throw new Error(`Task "${task_id}" not found.`);
244
199
  }
245
- },
200
+ if (!task.isRunning) {
201
+ return `Task "${task_id}" is not running (already completed or stopped). No action taken.`;
202
+ }
203
+ const success = BackgroundTaskManager.cancelTask(task_id);
204
+ if (success) {
205
+ return `Background task "${task_id}" has been terminated.
206
+
207
+ **Command:** ${task.command}
208
+ **Status:** \u23F9\uFE0F Killed by request`;
209
+ } else {
210
+ throw new Error(`Failed to kill task "${task_id}". The task may have already completed.`);
211
+ }
212
+ }
213
+ case "wait": {
214
+ if (!wait_seconds) {
215
+ throw new Error('Missing required parameter "wait_seconds" for action "wait"');
216
+ }
217
+ if (wait_seconds < 1 || wait_seconds > 300) {
218
+ throw new Error("wait_seconds must be between 1 and 300 (5 minutes)");
219
+ }
220
+ await new Promise((resolve) => setTimeout(resolve, wait_seconds * 1e3));
221
+ return `Waited for ${wait_seconds} second${wait_seconds !== 1 ? "s" : ""}.
222
+
223
+ \u23F1\uFE0F The execution has been paused for the requested duration. You can now continue with the next action.`;
224
+ }
225
+ default:
226
+ throw new Error(`Unknown action "${action}". Valid actions are: "start", "status", "kill", "wait".`);
227
+ }
228
+ }
246
229
  };
247
- /**
248
- * Format the successful start response
249
- */
250
230
  function formatStartResponse(taskId, command, cwd, contextType) {
251
- return `Background task started successfully in ${contextType}.
252
-
253
- **Task ID:** ${taskId}
254
- **Command:** ${command}
255
- **Working Directory:** ${cwd}
256
- **Context:** ${contextType}
257
-
231
+ return `Background task started successfully in ${contextType}.
232
+
233
+ **Task ID:** ${taskId}
234
+ **Command:** ${command}
235
+ **Working Directory:** ${cwd}
236
+ **Context:** ${contextType}
237
+
258
238
  The command is now running in the background. Use action="status" with task_id="${taskId}" to check progress, or action="kill" to terminate it.`;
259
239
  }
260
- /**
261
- * Helper to escape a command for use in "sh -c" or similar
262
- */
263
240
  function escapeCmd(cmd) {
264
- // Escape backslashes first, then quotes
265
- return cmd.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
241
+ return cmd.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
266
242
  }
267
- /**
268
- * Build a Docker execution command
269
- */
270
243
  function buildDockerCommand(containerId, cwd, command) {
271
- // docker exec -w <cwd> <id> sh -c "<cmd>"
272
- return `docker exec -w "${cwd}" ${containerId} sh -c "${escapeCmd(command)}"`;
244
+ return `docker exec -w "${cwd}" ${containerId} sh -c "${escapeCmd(command)}"`;
273
245
  }
274
- /**
275
- * Build a WSL execution command
276
- */
277
246
  function buildWSLCommand(distro, cwd, command) {
278
- // wsl -d <distro> -- bash -c "cd <cwd> && <cmd>"
279
- return `wsl -d ${distro} -- bash -c "cd \\"${cwd}\\" && ${escapeCmd(command)}"`;
247
+ return `wsl -d ${distro} -- bash -c "cd \\"${cwd}\\" && ${escapeCmd(command)}"`;
280
248
  }
281
- /**
282
- * Build an SSH execution command (for wrapping)
283
- */
284
249
  function buildSSHCommand(metadata, cwd, command) {
285
- const portFlag = metadata.port ? `-p ${metadata.port}` : '';
286
- const userHost = `${metadata.username}@${metadata.hostname}`;
287
- // ssh -p <port> user@host "cd <cwd> && <cmd>"
288
- return `ssh ${portFlag} ${userHost} "cd \\"${cwd}\\" && ${escapeCmd(command)}"`;
250
+ const portFlag = metadata.port ? `-p ${metadata.port}` : "";
251
+ const userHost = `${metadata.username}@${metadata.hostname}`;
252
+ return `ssh ${portFlag} ${userHost} "cd \\"${cwd}\\" && ${escapeCmd(command)}"`;
289
253
  }
254
+ export {
255
+ backgroundCommandTool
256
+ };
290
257
  //# sourceMappingURL=background-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"background-command.js","sourceRoot":"","sources":["../../src/tools/background-command.ts"],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EAAE,OAAe;IACjE,iDAAiD;IACjD,OAAO,UAAU,MAAM,sBAAsB,GAAG,UAAU,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,QAAa,EAAE,GAAW,EAAE,OAAe;IAChE,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,MAAM,QAAQ,GAAG,GAAG,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7D,8CAA8C;IAC9C,OAAO,OAAO,QAAQ,IAAI,QAAQ,WAAW,GAAG,UAAU,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;AACpF,CAAC"}
1
+ {"version":3,"sources":["../../src/tools/background-command.ts"],"sourcesContent":["/**\r\n * Background Command Tool\r\n * \r\n * Allows the AI to execute commands in the background (non-blocking),\r\n * check their status, and kill/terminate them.\r\n * \r\n * Uses the existing BackgroundTaskManager singleton.\r\n */\r\n\r\nimport { Tool } from './types.js';\r\nimport { BackgroundTaskManager } from '../services/background-task-manager.js';\r\nimport { runSSHCommand, runLocalPty } from '../utils/editor-utils.js';\r\nimport { ContextManager } from '../context/context-manager.js';\r\nimport * as path from 'path';\r\n\r\nfunction resolveBackgroundCommandCwd(currentContext: any, contextCwd: string, commandCwd: string): string {\r\n if (currentContext.type === 'local') {\r\n return path.resolve(contextCwd, commandCwd);\r\n }\r\n\r\n const remoteBase = currentContext.metadata?.workingDirectory || contextCwd || '~';\r\n return path.posix.isAbsolute(commandCwd)\r\n ? commandCwd\r\n : path.posix.join(remoteBase, commandCwd);\r\n}\r\n\r\n\r\nexport const backgroundCommandTool: Tool = {\r\n schema: {\r\n name: 'background_command',\r\n description: `Execute shell commands in the background, check their status, or kill them. This tool is NON-BLOCKING - when you start a command, the tool returns immediately with a task ID while the command continues running in the background.\r\n\r\nUSE CASES:\r\n- Running development servers (npm run dev, python -m http.server, etc.)\r\n- Running long-running processes (builds, tests, watchers)\r\n- Running multiple commands concurrently\r\n\r\nACTIONS:\r\n1. \"start\" - Start a new background command. Returns a task_id immediately.\r\n2. \"status\" - Check the status and output of a background task. Use this to monitor progress.\r\n3. \"kill\" - Terminate a running background task.\r\n4. \"wait\" - Pause execution for a specified duration. Use this instead of repeatedly checking status.\r\n\r\nIMPORTANT:\r\n- After starting a task, you can continue with other work while it runs.\r\n- Use \"status\" periodically to check on long-running tasks.\r\n- Use \"wait\" to pause before checking status again (e.g., wait 30 seconds for a build to complete).\r\n- Always clean up tasks with \"kill\" when they're no longer needed.\r\n- The task_id returned from \"start\" must be saved to use with \"status\" or \"kill\".`,\r\n parameters: {\r\n type: 'object',\r\n properties: {\r\n reason_text: {\r\n type: 'string',\r\n description: 'REQUIRED: A brief explanation of what you are doing with this background command.',\r\n },\r\n action: {\r\n type: 'string',\r\n enum: ['start', 'status', 'kill', 'wait'],\r\n description: 'The action to perform: \"start\" to run a new command, \"status\" to check a task, \"kill\" to terminate a task, \"wait\" to pause execution.',\r\n },\r\n command: {\r\n type: 'string',\r\n description: 'The shell command to execute. REQUIRED when action is \"start\".',\r\n },\r\n cwd: {\r\n type: 'string',\r\n description: 'The working directory for the command. REQUIRED when action is \"start\".',\r\n },\r\n task_id: {\r\n type: 'string',\r\n description: 'The task ID to check or kill. REQUIRED when action is \"status\" or \"kill\".',\r\n },\r\n output_lines: {\r\n type: 'integer',\r\n description: 'Number of lines of output to return (from the end). Default: 50. Only used with \"status\" action.',\r\n },\r\n wait_seconds: {\r\n type: 'integer',\r\n description: 'Number of seconds to wait. REQUIRED when action is \"wait\". Use this to pause before checking task status again.',\r\n },\r\n },\r\n required: ['reason_text', 'action'],\r\n },\r\n },\r\n async execute(args, context) {\r\n const { action, command, cwd, task_id, output_lines = 50, wait_seconds } = args;\r\n\r\n switch (action) {\r\n case 'start': {\r\n // Validate required parameters for start\r\n if (!command) {\r\n throw new Error('Missing required parameter \"command\" for action \"start\"');\r\n }\r\n if (!cwd) {\r\n throw new Error('Missing required parameter \"cwd\" for action \"start\"');\r\n }\r\n\r\n // Check for remote context\r\n const contextManager = context.contextManager as ContextManager;\r\n const activeContext = contextManager.getCurrentContext();\r\n\r\n // Get the full context stack to handle nested environments\r\n // If getContextStack is not available (older version), fall back to checking current context\r\n let stack: any[] = [];\r\n if (typeof contextManager.getContextStack === 'function') {\r\n stack = contextManager.getContextStack();\r\n } else {\r\n // Fallback for safety\r\n const current = contextManager.getCurrentContext();\r\n if (current) stack = [current];\r\n }\r\n\r\n let currentCommand = command;\r\n\r\n // Iterate from the target context (top of stack) down to the root\r\n for (let i = stack.length - 1; i >= 0; i--) {\r\n const ctx = stack[i];\r\n const isTarget = i === stack.length - 1;\r\n\r\n // Determine the working directory to use for this execution layer\r\n // If this is the target layer, use the user-provided cwd\r\n // If this is an intermediate layer, use its tracked working directory\r\n const executionCwd = isTarget ? cwd : ctx.metadata.workingDirectory;\r\n\r\n // 1. Check if this context has a direct protocol executor (e.g. active SSH client)\r\n if (ctx.type === 'ssh' && ctx.handler?.client) {\r\n const sshClient = ctx.handler.client;\r\n\r\n // Start task tracking\r\n const remoteTask = BackgroundTaskManager.startRemoteTask(\r\n command, // Original command for display\r\n cwd, // Original CWD for display\r\n ctx.type // Context type\r\n );\r\n\r\n // Execute via SSH PTY\r\n const sshPty = runSSHCommand(\r\n sshClient,\r\n currentCommand, // The accumulated (possibly wrapped) command\r\n executionCwd,\r\n remoteTask.onData,\r\n remoteTask.onExit\r\n );\r\n remoteTask.setRemotePty(sshPty);\r\n\r\n return formatStartResponse(remoteTask.id, command, cwd, ctx.type);\r\n }\r\n\r\n // 2. Check if this is the local root context\r\n if (ctx.type === 'local') {\r\n // Start task tracking\r\n const remoteTask = BackgroundTaskManager.startRemoteTask(\r\n command,\r\n cwd,\r\n 'local'\r\n );\r\n\r\n // Execute via Local PTY (which might be running a wrapped command like \"wsl ...\" or \"docker ...\")\r\n const localPty = runLocalPty(\r\n currentCommand,\r\n executionCwd, // Use the local CWD\r\n remoteTask.onData,\r\n remoteTask.onExit\r\n );\r\n remoteTask.setRemotePty(localPty);\r\n\r\n return formatStartResponse(remoteTask.id, command, cwd, 'local');\r\n }\r\n\r\n // 3. Otherwise, WRAP the command for the next iteration (parent)\r\n if (ctx.type === 'docker') {\r\n const containerId = ctx.metadata.containerId;\r\n if (!containerId) throw new Error('Docker context missing containerId');\r\n currentCommand = buildDockerCommand(containerId, executionCwd, currentCommand);\r\n } else if (ctx.type === 'wsl') {\r\n const distro = ctx.metadata.distroName || 'Ubuntu';\r\n currentCommand = buildWSLCommand(distro, executionCwd, currentCommand);\r\n } else if (ctx.type === 'ssh') {\r\n // Fallback for SSH without accessible client (e.g. wrapped command)\r\n currentCommand = buildSSHCommand(ctx.metadata, executionCwd, currentCommand);\r\n } else {\r\n // Unknown context type, try to pass through or error?\r\n // For now we error to be safe, or just wrap in sh -c?\r\n throw new Error(`Unsupported context type for wrapping: ${ctx.type}`);\r\n }\r\n }\r\n\r\n throw new Error('Failed to execute command: Reached end of context stack without execution.');\r\n }\r\n\r\n case 'status': {\r\n // Validate required parameters for status\r\n if (!task_id) {\r\n throw new Error('Missing required parameter \"task_id\" for action \"status\"');\r\n }\r\n\r\n const task = BackgroundTaskManager.getTask(task_id);\r\n if (!task) {\r\n // List all available tasks to help the AI\r\n const allTasks = BackgroundTaskManager.getAllTasks();\r\n if (allTasks.length === 0) {\r\n throw new Error(`Task \"${task_id}\" not found. There are no background tasks currently tracked.`);\r\n }\r\n const taskList = allTasks.map(t => `- ${t.id} (${t.isRunning ? 'running' : 'completed'}): ${t.command}`).join('\\n');\r\n throw new Error(`Task \"${task_id}\" not found.\\n\\nAvailable tasks:\\n${taskList}`);\r\n }\r\n\r\n // Get the output (last N lines)\r\n const fullOutput = task.output;\r\n const lines = fullOutput.split('\\n');\r\n const outputToShow = lines.slice(-output_lines).join('\\n');\r\n const truncated = lines.length > output_lines;\r\n\r\n const durationMs = Date.now() - task.startTime.getTime();\r\n const durationSec = Math.round(durationMs / 1000);\r\n\r\n let statusText = '';\r\n if (task.isRunning) {\r\n statusText = `**Status:** šŸ”„ Running (${durationSec}s)`;\r\n } else if (task.exitCode === 0) {\r\n statusText = `**Status:** āœ… Completed successfully (exit code: 0)`;\r\n } else if (task.exitCode !== undefined) {\r\n statusText = `**Status:** āŒ Failed (exit code: ${task.exitCode})`;\r\n } else if (task.error) {\r\n statusText = `**Status:** āŒ Error: ${task.error}`;\r\n } else {\r\n statusText = `**Status:** ā¹ļø Stopped`;\r\n }\r\n\r\n const remoteLabel = task.remoteContext ? ` [${task.remoteContext}]` : '';\r\n\r\n return `Background Task Status${remoteLabel}\r\n\r\n**Task ID:** ${task_id}\r\n**Command:** ${task.command}\r\n**Working Directory:** ${task.cwd}\r\n${statusText}\r\n\r\n**Output${truncated ? ` (last ${output_lines} lines)` : ''}:**\r\n\\`\\`\\`\r\n${outputToShow || '(no output yet)'}\r\n\\`\\`\\``;\r\n }\r\n\r\n case 'kill': {\r\n // Validate required parameters for kill\r\n if (!task_id) {\r\n throw new Error('Missing required parameter \"task_id\" for action \"kill\"');\r\n }\r\n\r\n const task = BackgroundTaskManager.getTask(task_id);\r\n if (!task) {\r\n // Try to find if it was recently killed or doesn't exist\r\n throw new Error(`Task \"${task_id}\" not found.`);\r\n }\r\n\r\n if (!task.isRunning) {\r\n return `Task \"${task_id}\" is not running (already completed or stopped). No action taken.`;\r\n }\r\n\r\n // For remote tasks, we might need to do special cleanup, \r\n // but BackgroundTaskManager.cancelTask() handles calling the pty.kill()\r\n const success = BackgroundTaskManager.cancelTask(task_id);\r\n if (success) {\r\n return `Background task \"${task_id}\" has been terminated.\r\n\r\n**Command:** ${task.command}\r\n**Status:** ā¹ļø Killed by request`;\r\n } else {\r\n throw new Error(`Failed to kill task \"${task_id}\". The task may have already completed.`);\r\n }\r\n }\r\n\r\n case 'wait': {\r\n // Validate required parameters for wait\r\n if (!wait_seconds) {\r\n throw new Error('Missing required parameter \"wait_seconds\" for action \"wait\"');\r\n }\r\n\r\n if (wait_seconds < 1 || wait_seconds > 300) {\r\n throw new Error('wait_seconds must be between 1 and 300 (5 minutes)');\r\n }\r\n\r\n // Create a promise that resolves after the specified duration\r\n await new Promise(resolve => setTimeout(resolve, wait_seconds * 1000));\r\n\r\n return `Waited for ${wait_seconds} second${wait_seconds !== 1 ? 's' : ''}.\r\n\r\nā±ļø The execution has been paused for the requested duration. You can now continue with the next action.`;\r\n }\r\n\r\n default:\r\n throw new Error(`Unknown action \"${action}\". Valid actions are: \"start\", \"status\", \"kill\", \"wait\".`);\r\n }\r\n },\r\n};\r\n\r\n/**\r\n * Format the successful start response\r\n */\r\nfunction formatStartResponse(taskId: string, command: string, cwd: string, contextType: string): string {\r\n return `Background task started successfully in ${contextType}.\r\n\r\n**Task ID:** ${taskId}\r\n**Command:** ${command}\r\n**Working Directory:** ${cwd}\r\n**Context:** ${contextType}\r\n\r\nThe command is now running in the background. Use action=\"status\" with task_id=\"${taskId}\" to check progress, or action=\"kill\" to terminate it.`;\r\n}\r\n\r\n/**\r\n * Helper to escape a command for use in \"sh -c\" or similar\r\n */\r\nfunction escapeCmd(cmd: string): string {\r\n // Escape backslashes first, then quotes\r\n return cmd.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\r\n}\r\n\r\n/**\r\n * Build a Docker execution command\r\n */\r\nfunction buildDockerCommand(containerId: string, cwd: string, command: string): string {\r\n // docker exec -w <cwd> <id> sh -c \"<cmd>\"\r\n return `docker exec -w \"${cwd}\" ${containerId} sh -c \"${escapeCmd(command)}\"`;\r\n}\r\n\r\n/**\r\n * Build a WSL execution command\r\n */\r\nfunction buildWSLCommand(distro: string, cwd: string, command: string): string {\r\n // wsl -d <distro> -- bash -c \"cd <cwd> && <cmd>\"\r\n return `wsl -d ${distro} -- bash -c \"cd \\\\\"${cwd}\\\\\" && ${escapeCmd(command)}\"`;\r\n}\r\n\r\n/**\r\n * Build an SSH execution command (for wrapping)\r\n */\r\nfunction buildSSHCommand(metadata: any, cwd: string, command: string): string {\r\n const portFlag = metadata.port ? `-p ${metadata.port}` : '';\r\n const userHost = `${metadata.username}@${metadata.hostname}`;\r\n // ssh -p <port> user@host \"cd <cwd> && <cmd>\"\r\n return `ssh ${portFlag} ${userHost} \"cd \\\\\"${cwd}\\\\\" && ${escapeCmd(command)}\"`;\r\n}\r\n"],"mappings":"AAUA,SAAS,6BAA6B;AACtC,SAAS,eAAe,mBAAmB;AAE3C,YAAY,UAAU;AAEtB,SAAS,4BAA4B,gBAAqB,YAAoB,YAA4B;AACtG,MAAI,eAAe,SAAS,SAAS;AACjC,WAAO,KAAK,QAAQ,YAAY,UAAU;AAAA,EAC9C;AAEA,QAAM,aAAa,eAAe,UAAU,oBAAoB,cAAc;AAC9E,SAAO,KAAK,MAAM,WAAW,UAAU,IACjC,aACA,KAAK,MAAM,KAAK,YAAY,UAAU;AAChD;AAGO,MAAM,wBAA8B;AAAA,EACvC,QAAQ;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBb,YAAY;AAAA,MACR,MAAM;AAAA,MACN,YAAY;AAAA,QACR,aAAa;AAAA,UACT,MAAM;AAAA,UACN,aAAa;AAAA,QACjB;AAAA,QACA,QAAQ;AAAA,UACJ,MAAM;AAAA,UACN,MAAM,CAAC,SAAS,UAAU,QAAQ,MAAM;AAAA,UACxC,aAAa;AAAA,QACjB;AAAA,QACA,SAAS;AAAA,UACL,MAAM;AAAA,UACN,aAAa;AAAA,QACjB;AAAA,QACA,KAAK;AAAA,UACD,MAAM;AAAA,UACN,aAAa;AAAA,QACjB;AAAA,QACA,SAAS;AAAA,UACL,MAAM;AAAA,UACN,aAAa;AAAA,QACjB;AAAA,QACA,cAAc;AAAA,UACV,MAA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