centaurus-cli 3.0.0 → 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 -5037
  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 +1513 -973
  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 +605 -537
  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 -400
  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 -3249
  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 -511
  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 -167
  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 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/tools/command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE1F,uEAAuE;AACvE,SAAS,iBAAiB,CAAC,KAAa;IACpC,IAAI,SAAS,GAAG,KAAK;QACjB,mCAAmC;SAClC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,gDAAgD;SACtE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;SACrB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;SACrB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;SACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE/B,2BAA2B;IAC3B,MAAM,MAAM,GAA8B;QACtC,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,IAAI,EAAE,qBAAqB;QACtC,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,QAAQ;QACjB,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,QAA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B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;4BACnC,CAAC;wBACL,CAAC;wBACD,MAAM,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;wBACjE,KAAK,EAAE,IAAI;qBACd,CAAC,CAAC;gBACP,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/tools/command.ts"],"sourcesContent":["import { Tool } from './types.js';\r\nimport * as shellUtils from '../utils/shell.js';\r\nimport * as fs from 'fs';\r\nimport * as path from 'path';\r\nimport { ContextManager } from '../context/context-manager.js';\r\nimport { runWSLCommand, runDockerCommand, runSSHCommand } from '../utils/editor-utils.js';\r\n\r\n// Helper to process shell input with escape sequences and special keys\r\nfunction processShellInput(input: string): string {\r\n let processed = input\r\n // Handle standard escape sequences\r\n .replace(/\\\\n/g, '\\r') // Use \\r for Enter/Newline in interactive shell\r\n .replace(/\\\\r/g, '\\r')\r\n .replace(/\\\\t/g, '\\t')\r\n .replace(/\\\\b/g, '\\b')\r\n .replace(/\\\\x1B/g, '\\x1B');\r\n\r\n // Handle special key codes\r\n const keyMap: { [key: string]: string } = {\r\n '[UP]': '\\u001b[A',\r\n '[DOWN]': '\\u001b[B',\r\n '[RIGHT]': '\\u001b[C',\r\n '[LEFT]': '\\u001b[D',\r\n '[ENTER]': '\\r', // Enter key sends CR\r\n '[TAB]': '\\t',\r\n '[ESC]': '\\u001b',\r\n '[BACKSPACE]': '\\b',\r\n '[CTRL+C]': '\\u0003',\r\n '[CTRL+D]': '\\u0004',\r\n '[CTRL+Z]': '\\u001a'\r\n };\r\n\r\n // Replace special keys\r\n for (const [key, code] of Object.entries(keyMap)) {\r\n processed = processed.split(key).join(code);\r\n }\r\n\r\n return processed;\r\n}\r\n\r\nfunction resolveCommandWorkingDirectory(\r\n currentContext: any,\r\n contextCwd: string,\r\n commandCwd?: string\r\n): string {\r\n if (currentContext.type === 'local') {\r\n return commandCwd ? path.resolve(contextCwd, commandCwd) : contextCwd;\r\n }\r\n\r\n const remoteBase = currentContext.metadata?.workingDirectory || contextCwd || '~';\r\n if (!commandCwd) {\r\n return remoteBase;\r\n }\r\n\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 runCommandTool: Tool = {\r\n schema: {\r\n name: 'execute_command',\r\n description: `PROPOSE a command to run on behalf of the user. Operating System: windows. Shell: pwsh.\r\n**NEVER PROPOSE A cd COMMAND**.\r\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\r\nMake sure to specify CommandLine exactly as it should be run in the shell.\r\nNote that the user will have to approve the command before it is executed. The user may reject it if it is not to their liking.\r\nThe actual command will NOT execute until the user approves it. The user may not approve it immediately.\r\nIf the step is WAITING for user approval, it has NOT started running.\r\nIf the step returns a command id, it means that the command was sent to the background. You should use the command_status tool to monitor the output and status of the command.\r\nCommands will be run with PAGER=cat. You may want to limit the length of output for commands that usually rely on paging and may contain very long output (e.g. git log, use git log -n <N>).`,\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 why you are executing this command and what you expect it to do. This will be shown to the user. Example: \"Running npm install to install the project dependencies\"',\r\n },\r\n CommandLine: {\r\n type: 'string',\r\n description: 'The exact command line string to execute.',\r\n },\r\n Cwd: {\r\n type: 'string',\r\n description: 'The current working directory for the command',\r\n },\r\n SafeToAutoRun: {\r\n type: 'boolean',\r\n description: 'Set to true if you believe that this command is safe to run WITHOUT user approval. A command is unsafe if it may have some destructive side-effects. Example unsafe side-effects include: deleting files, mutating state, installing system dependencies, making external requests, etc. Set to true only if you are extremely confident it is safe. If you feel the command could be unsafe, never set this to true, EVEN if the USER asks you to. It is imperative that you never auto-run a potentially unsafe command.',\r\n },\r\n WaitMsBeforeAsync: {\r\n type: 'integer',\r\n description: 'This specifies the number of milliseconds to wait after starting the command before sending it to the background. If you want the command to complete execution synchronously, set this to a large enough value that you expect the command to complete in that time under ordinary circumstances. If you\\'re starting an interactive or long-running command, set it to a large enough value that it would cause possible failure cases to execute synchronously (e.g. 500ms). Keep the value as small as possible, with a maximum of 10000ms.',\r\n },\r\n shell_input: {\r\n type: 'string',\r\n description: '[INTERNAL - DO NOT USE FROM MAIN AGENT] Input to send to a CURRENTLY RUNNING interactive shell. This parameter is used internally by the shell input sub-agent. When starting a command, do NOT set this parameter - just start the command and the user will provide input through the shell UI or agent control mode.',\r\n },\r\n },\r\n required: ['reason_text', 'CommandLine', 'Cwd', 'SafeToAutoRun', 'WaitMsBeforeAsync'],\r\n },\r\n },\r\n async execute(args, context) {\r\n const { CommandLine, Cwd, shell_input } = args;\r\n\r\n // Handle shell_input action - send input to a running shell\r\n // NOTE: shell_input should only be used by ShellInputAgent, not the main agent\r\n if (shell_input) {\r\n if (context.cliAdapter) {\r\n const interactiveProcess = context.cliAdapter.getCurrentInteractiveProcess();\r\n if (!interactiveProcess) {\r\n // Provide a helpful error message guiding the correct approach\r\n throw new Error(\r\n `Cannot use shell_input when no interactive shell is running. ` +\r\n `To run an interactive command:\\n` +\r\n `1. First, run the command WITHOUT shell_input - just use CommandLine\\n` +\r\n `2. The interactive shell will open and you can provide input there\\n` +\r\n `3. Agent Control mode (if enabled) will automatically handle input prompts\\n\\n` +\r\n `Please retry: run the command first, then input will be handled automatically.`\r\n );\r\n }\r\n // Process input to handle escapes and special keys\r\n const processedInput = processShellInput(shell_input);\r\n\r\n // Send the processed input\r\n interactiveProcess.write(processedInput);\r\n\r\n // Return readable confirmation (showing what was actually sent)\r\n const readableSent = processedInput\r\n .replace(/\\n/g, '\\\\n')\r\n .replace(/\\r/g, '\\\\r')\r\n .replace(/\\x1B/g, '^[')\r\n .replace(/\\u0003/g, '^C');\r\n\r\n return `Sent input to active shell: ${readableSent}`;\r\n } else {\r\n throw new Error('CLI adapter not available for shell input.');\r\n }\r\n }\r\n\r\n const command = CommandLine; // Map to internal variable\r\n const contextManager = context.contextManager as ContextManager;\r\n const currentContext = contextManager.getCurrentContext();\r\n\r\n // Special handling for cd command - change the actual working directory\r\n // Only intercept simple cd commands, not chained ones (cd path && cmd, cd path; cmd)\r\n // Chained commands will be executed by the shell directly\r\n const isChainedCommand = /&&|;/.test(command);\r\n const cdMatch = !isChainedCommand && command.match(/^cd\\s+(.+)$/);\r\n if (cdMatch) {\r\n if (currentContext.type === 'local') {\r\n const targetDir = cdMatch[1].trim();\r\n const newCwd = path.resolve(Cwd || context.cwd, targetDir);\r\n\r\n if (!fs.existsSync(newCwd)) {\r\n throw new Error(`Directory not found: ${targetDir}\\n\\nAction: Use 'list_directory' to verify the directory structure.`);\r\n }\r\n\r\n if (!fs.statSync(newCwd).isDirectory()) {\r\n throw new Error(`Path is not a directory: ${targetDir}\\n\\nAction: Verify the path points to a directory, not a file.`);\r\n }\r\n\r\n contextManager.updateWorkingDirectory(newCwd);\r\n\r\n // Update CLI adapter CWD and notify UI\r\n if (context.cliAdapter) {\r\n context.cliAdapter.cwd = newCwd;\r\n if (context.cliAdapter.onCwdChange) {\r\n context.cliAdapter.onCwdChange(newCwd);\r\n }\r\n }\r\n\r\n return `Changed directory to: ${newCwd}`;\r\n } else {\r\n // Execute cd in subshell and update working directory\r\n const targetDir = cdMatch[1].trim();\r\n const result = await contextManager.executeCommand(`cd ${targetDir}`);\r\n if (result.exitCode === 0) {\r\n // Get the actual new working directory from the handler\r\n if (currentContext.handler) {\r\n const newCwd = await currentContext.handler.getCurrentWorkingDirectory();\r\n if (newCwd) {\r\n contextManager.updateWorkingDirectory(newCwd);\r\n\r\n // Update CLI adapter CWD and notify UI\r\n if (context.cliAdapter) {\r\n context.cliAdapter.cwd = newCwd;\r\n if (context.cliAdapter.onCwdChange) {\r\n context.cliAdapter.onCwdChange(newCwd);\r\n }\r\n }\r\n }\r\n }\r\n return `Changed directory to: ${contextManager.getCurrentContext().metadata.workingDirectory}`;\r\n } else {\r\n throw new Error(`${result.stderr || 'Failed to change directory'}\\n\\nAction: Verify the directory exists in the remote environment.`);\r\n }\r\n }\r\n }\r\n\r\n // Check for long-running commands\r\n const longRunningPatterns = [\r\n /npm\\s+run\\s+dev/,\r\n /npm\\s+run\\s+start/,\r\n /npm\\s+start/,\r\n /yarn\\s+dev/,\r\n /yarn\\s+start/,\r\n /pnpm\\s+dev/,\r\n /pnpm\\s+start/,\r\n /python\\s+-m\\s+http\\.server/,\r\n /python3\\s+-m\\s+http\\.server/,\r\n /php\\s+-S/,\r\n /ruby\\s+-run\\s+-e\\s+httpd/,\r\n /serve\\s+/,\r\n /http-server/,\r\n /webpack\\s+--watch/,\r\n /webpack-dev-server/,\r\n /vite(?:\\s+(?!build)|\\s*$)/,\r\n /next\\s+dev/,\r\n /gatsby\\s+develop/,\r\n /rails\\s+server/,\r\n /rails\\s+s\\b/,\r\n /django\\s+runserver/,\r\n /manage\\.py\\s+runserver/,\r\n /flask\\s+run/,\r\n /nodemon/,\r\n /ng\\s+serve/,\r\n /ember\\s+serve/,\r\n /hugo\\s+server/,\r\n /jekyll\\s+serve/,\r\n /docker\\s+run.*-d/,\r\n /docker-compose\\s+up/,\r\n /tail\\s+-f/,\r\n /watch\\s+/,\r\n /less\\s+/,\r\n /more\\s+/,\r\n /vim\\s+/,\r\n /vi\\s+/,\r\n /nano\\s+/,\r\n /emacs\\s+/,\r\n ];\r\n\r\n const isLongRunning = longRunningPatterns.some((pattern) => pattern.test(command));\r\n\r\n if (isLongRunning) {\r\n throw new Error(\r\n `This command appears to be a long-running process (like a development server or file watcher). ` +\r\n `Long-running commands cannot be executed through execute_command as they would block execution.\\n\\n` +\r\n `USE THE background_command TOOL INSTEAD:\\n` +\r\n `- action: \"start\" to run the command in the background\\n` +\r\n `- action: \"status\" to check the output while it runs\\n` +\r\n `- action: \"kill\" to terminate when done\\n\\n` +\r\n `Command that needs background execution: ${command}`\r\n );\r\n }\r\n\r\n // Check for risky commands\r\n const riskyPatterns = [/rm\\s+-rf/, /del\\s+\\/s/, /format/, /dd\\s+if=/];\r\n const isRisky = riskyPatterns.some((pattern) => pattern.test(command));\r\n\r\n const approved = await context.requireApproval(\r\n `Execute command: ${command}${currentContext.type !== 'local' ? ` (in ${currentContext.type} environment)` : ''}`,\r\n isRisky,\r\n undefined,\r\n 'execute_command',\r\n { command }\r\n );\r\n\r\n // Check for feedback object (user rejected with feedback)\r\n if (typeof approved === 'object' && 'feedback' in approved) {\r\n throw new Error(`USER_FEEDBACK: ${approved.feedback}`);\r\n }\r\n\r\n // Check for boolean false (user rejected)\r\n if (!approved) {\r\n throw new Error('Operation cancelled by user.');\r\n }\r\n\r\n const executionCwd = resolveCommandWorkingDirectory(currentContext, context.cwd, Cwd);\r\n\r\n // Execute command with interactive support (allows user input via stdin)\r\n if (currentContext.type === 'local') {\r\n // Use interactive process for full stdin/stdout/stderr support\r\n return new Promise<string>((resolve, reject) => {\r\n let output = '';\r\n let exitCode: number | undefined;\r\n\r\n // Start interactive process\r\n const interactiveProcess = shellUtils.executeCommandInteractive(\r\n command,\r\n executionCwd,\r\n (data: string) => {\r\n // Accumulate output\r\n output += data;\r\n\r\n // Stream to UI if callback is available\r\n if (context.onStreamingOutput) {\r\n context.onStreamingOutput(data, 'stdout');\r\n }\r\n },\r\n (code: number) => {\r\n // Process exited\r\n exitCode = code;\r\n\r\n // Clear the interactive process reference\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(undefined);\r\n }\r\n\r\n // Resolve or reject based on exit code\r\n if (code === 0) {\r\n resolve(output || 'Command executed successfully');\r\n } else {\r\n const errorOutput = output + `\\nExit Code: ${code}`;\r\n reject(new Error(`${errorOutput || `Command failed with exit code ${code}`}\\n\\nPossible reasons:\\n1. The command is invalid or not installed.\\n2. The arguments are incorrect.\\n3. The command requires user input (interactive mode).`));\r\n }\r\n }\r\n );\r\n\r\n // Store the interactive process reference so user can send input\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(interactiveProcess);\r\n }\r\n });\r\n } else if (currentContext.type === 'wsl') {\r\n // WSL execution with PTY for proper TTY handling (sudo, etc.)\r\n const remoteCwd = executionCwd;\r\n const distribution = currentContext.metadata?.distroName || 'Ubuntu';\r\n\r\n return new Promise<string>((resolve, reject) => {\r\n let output = '';\r\n\r\n // Calculate constrained terminal dimensions for proper escape sequence handling\r\n // Reduce width to account for UI borders/padding (~4 chars for left+right borders/padding)\r\n // Reduce height to account for available display area in InteractiveShell\r\n const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);\r\n const constrainedRows = Math.min(process.stdout.rows || 24, 50);\r\n\r\n const wslPty = runWSLCommand(\r\n distribution,\r\n command,\r\n remoteCwd,\r\n (data: string) => {\r\n // Stream output to UI\r\n output += data;\r\n if (context.onStreamingOutput) {\r\n context.onStreamingOutput(data, 'stdout');\r\n }\r\n },\r\n (exitCode: number) => {\r\n // Clear the interactive process\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(undefined);\r\n }\r\n\r\n if (exitCode !== 0) {\r\n reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\\n\\nPossible reasons:\\n1. The command is invalid or not installed.\\n2. The arguments are incorrect.`));\r\n } else {\r\n resolve(output || 'Command executed successfully');\r\n }\r\n },\r\n constrainedCols,\r\n constrainedRows\r\n );\r\n\r\n // Set up interactive process for stdin\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess({\r\n process: null,\r\n write: (data: string) => wslPty.write(data),\r\n kill: () => wslPty.kill(),\r\n signal: (sig: NodeJS.Signals) => {\r\n if (sig === 'SIGINT') {\r\n wslPty.write('\\x03'); // Ctrl+C\r\n }\r\n },\r\n resize: (cols: number, rows: number) => wslPty.resize(cols, rows),\r\n isPty: true\r\n });\r\n }\r\n });\r\n } else if (currentContext.type === 'docker') {\r\n // Docker execution - check if nested inside SSH\r\n const parentContext = contextManager.getParentContext();\r\n\r\n const remoteCwd = executionCwd;\r\n const containerId = currentContext.metadata?.containerId || '';\r\n\r\n // Calculate constrained terminal dimensions for proper escape sequence handling\r\n const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);\r\n const constrainedRows = Math.min(process.stdout.rows || 24, 50);\r\n\r\n if (parentContext && parentContext.type === 'ssh') {\r\n // Nested Docker inside SSH: route docker exec command through SSH\r\n const sshClient = parentContext.handler?.client;\r\n\r\n if (!sshClient) {\r\n throw new Error('SSH client not available for nested Docker session');\r\n }\r\n\r\n // Build docker exec command to run via SSH\r\n // Escape the command properly for nested shell execution\r\n const escapedCommand = command.replace(/\"/g, '\\\\\"');\r\n const dockerCommand = `docker exec -w \"${remoteCwd}\" ${containerId} sh -c \"${escapedCommand}\"`;\r\n\r\n return new Promise<string>((resolve, reject) => {\r\n let output = '';\r\n\r\n const sshPty = runSSHCommand(\r\n sshClient,\r\n dockerCommand,\r\n parentContext.metadata.workingDirectory || '~',\r\n (data: string) => {\r\n // Stream output to UI\r\n output += data;\r\n if (context.onStreamingOutput) {\r\n context.onStreamingOutput(data, 'stdout');\r\n }\r\n },\r\n (exitCode: number) => {\r\n // Clear the interactive process\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(undefined);\r\n }\r\n\r\n if (exitCode !== 0) {\r\n reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\\n\\nPossible reasons:\\n1. The command is invalid or not installed in the container.\\n2. The arguments are incorrect.\\n3. The Docker container may not be running.`));\r\n } else {\r\n resolve(output || 'Command executed successfully');\r\n }\r\n },\r\n constrainedCols,\r\n constrainedRows\r\n );\r\n\r\n // Set up interactive process for stdin\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess({\r\n process: null,\r\n write: (data: string) => sshPty.write(data),\r\n kill: () => sshPty.kill(),\r\n signal: (sig: NodeJS.Signals) => {\r\n if (sig === 'SIGINT') {\r\n sshPty.write('\\x03'); // Ctrl+C\r\n }\r\n },\r\n resize: (cols: number, rows: number) => sshPty.resize(cols, rows),\r\n isPty: true\r\n });\r\n }\r\n });\r\n } else {\r\n // Local Docker: use standard runDockerCommand\r\n return new Promise<string>((resolve, reject) => {\r\n let output = '';\r\n\r\n const dockerPty = runDockerCommand(\r\n containerId,\r\n command,\r\n remoteCwd,\r\n (data: string) => {\r\n // Stream output to UI\r\n output += data;\r\n if (context.onStreamingOutput) {\r\n context.onStreamingOutput(data, 'stdout');\r\n }\r\n },\r\n (exitCode: number) => {\r\n // Clear the interactive process\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(undefined);\r\n }\r\n\r\n if (exitCode !== 0) {\r\n reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\\n\\nPossible reasons:\\n1. The command is invalid or not installed.\\n2. The arguments are incorrect.`));\r\n } else {\r\n resolve(output || 'Command executed successfully');\r\n }\r\n },\r\n constrainedCols,\r\n constrainedRows\r\n );\r\n\r\n // Set up interactive process for stdin\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess({\r\n process: null,\r\n write: (data: string) => dockerPty.write(data),\r\n kill: () => dockerPty.kill(),\r\n signal: (sig: NodeJS.Signals) => {\r\n if (sig === 'SIGINT') {\r\n dockerPty.write('\\x03'); // Ctrl+C\r\n }\r\n },\r\n resize: (cols: number, rows: number) => dockerPty.resize(cols, rows),\r\n isPty: true\r\n });\r\n }\r\n });\r\n }\r\n } else if (currentContext.type === 'ssh') {\r\n // SSH execution with PTY for proper TTY handling\r\n const remoteCwd = executionCwd;\r\n const sshClient = currentContext.handler?.client;\r\n\r\n if (!sshClient) {\r\n throw new Error('SSH client not available');\r\n }\r\n\r\n return new Promise<string>((resolve, reject) => {\r\n let output = '';\r\n\r\n // Calculate constrained terminal dimensions for proper escape sequence handling\r\n const constrainedCols = Math.max(40, (process.stdout.columns || 80) - 4);\r\n const constrainedRows = Math.min(process.stdout.rows || 24, 50);\r\n\r\n const sshPty = runSSHCommand(\r\n sshClient,\r\n command,\r\n remoteCwd,\r\n (data: string) => {\r\n // Stream output to UI\r\n output += data;\r\n if (context.onStreamingOutput) {\r\n context.onStreamingOutput(data, 'stdout');\r\n }\r\n },\r\n (exitCode: number) => {\r\n // Clear the interactive process\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess(undefined);\r\n }\r\n\r\n if (exitCode !== 0) {\r\n reject(new Error(`${output || `Command failed with exit code ${exitCode}`}\\n\\nPossible reasons:\\n1. The command is invalid or not installed.\\n2. The arguments are incorrect.`));\r\n } else {\r\n resolve(output || 'Command executed successfully');\r\n }\r\n },\r\n constrainedCols,\r\n constrainedRows\r\n );\r\n\r\n // Set up interactive process for stdin\r\n if (context.cliAdapter) {\r\n context.cliAdapter.setCurrentInteractiveProcess({\r\n process: null,\r\n write: (data: string) => sshPty.write(data),\r\n kill: () => sshPty.kill(),\r\n signal: (sig: NodeJS.Signals) => {\r\n if (sig === 'SIGINT') {\r\n sshPty.write('\\x03'); // Ctrl+C\r\n }\r\n },\r\n resize: (cols: number, rows: number) => sshPty.resize(cols, rows),\r\n isPty: true\r\n });\r\n }\r\n });\r\n }\r\n },\r\n};\r\n"],"mappings":"AACA,YAAY,gBAAgB;AAC5B,YAAY,QAAQ;AACpB,YAAY,UAAU;AAEtB,SAAS,eAAe,kBAAkB,qBAAqB;AAG/D,SAAS,kBAAkB,OAAuB;AAC9C,MAAI,YAAY,MAEX,QAAQ,QAAQ,IAAI,EACpB,QAAQ,QAAQ,IAAI,EACpB,QAAQ,QAAQ,GAAI,EACpB,QAAQ,QAAQ,IAAI,EACpB,QAAQ,UAAU,MAAM;AAG7B,QAAM,SAAoC;AAAA,IACtC,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA;AAAA,IACX,SAAS;AAAA,IACT,SAAS;AAAA,IACT,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,Y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AAC;AAAA,QACL;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;","names":[]}
@@ -1,214 +1,184 @@
1
- /**
2
- * Create Image Tool
3
- *
4
- * Generates images using Gemini 2.0 Flash image generation via backend API.
5
- * The generated image is saved to the specified file path.
6
- */
7
- import * as fs from 'fs';
8
- import * as path from 'path';
9
- /**
10
- * Generate an image via backend API
11
- */
12
- async function generateImageViaBackend(prompt, aspectRatio = '1:1') {
13
- // Import axios and apiClient dynamically to avoid circular dependencies
14
- const axios = (await import('axios')).default;
15
- const { apiClient } = await import('../services/api-client.js');
16
- // Check if authenticated
17
- if (!apiClient.isAuthenticated()) {
18
- throw new Error('Authentication required. Please sign in to use image generation.\n' +
19
- 'Image generation is a backend feature that requires authentication.');
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ async function generateImageViaBackend(prompt, aspectRatio = "1:1") {
4
+ const axios = (await import("axios")).default;
5
+ const { apiClient } = await import("../services/api-client.js");
6
+ if (!apiClient.isAuthenticated()) {
7
+ throw new Error(
8
+ "Authentication required. Please sign in to use image generation.\nImage generation is a backend feature that requires authentication."
9
+ );
10
+ }
11
+ try {
12
+ const { IS_DEV_BUILD, DEV_BACKEND_URL, PRODUCTION_BACKEND_URL } = await import("../config/build-config.js");
13
+ const baseURL = IS_DEV_BUILD ? DEV_BACKEND_URL : PRODUCTION_BACKEND_URL;
14
+ const response = await axios.post(
15
+ `${baseURL}/images/generations`,
16
+ {
17
+ prompt,
18
+ aspect_ratio: aspectRatio
19
+ },
20
+ {
21
+ headers: {
22
+ "Content-Type": "application/json",
23
+ "Authorization": `Bearer ${apiClient.sessionToken}`
24
+ },
25
+ timeout: 12e4
26
+ // 2 minute timeout for image generation
27
+ }
28
+ );
29
+ if (!response.data || !response.data.success) {
30
+ throw new Error(response.data?.error?.message || "Image generation failed");
20
31
  }
21
- try {
22
- // Import build config - values frozen at compile time for security
23
- const { IS_DEV_BUILD, DEV_BACKEND_URL, PRODUCTION_BACKEND_URL } = await import('../config/build-config.js');
24
- const baseURL = IS_DEV_BUILD ? DEV_BACKEND_URL : PRODUCTION_BACKEND_URL;
25
- const response = await axios.post(`${baseURL}/image/generate`, {
26
- prompt,
27
- aspect_ratio: aspectRatio,
28
- }, {
29
- headers: {
30
- 'Content-Type': 'application/json',
31
- 'Authorization': `Bearer ${apiClient.sessionToken}`,
32
- },
33
- timeout: 120000, // 2 minute timeout for image generation
34
- });
35
- if (!response.data || !response.data.success) {
36
- throw new Error(response.data?.error?.message || 'Image generation failed');
37
- }
38
- return response.data.data;
32
+ return response.data.data;
33
+ } catch (error) {
34
+ if (error.response?.status === 401) {
35
+ throw new Error(
36
+ "Authentication required. Please sign in to use image generation.\nImage generation is a backend feature that requires authentication."
37
+ );
39
38
  }
40
- catch (error) {
41
- if (error.response?.status === 401) {
42
- throw new Error('Authentication required. Please sign in to use image generation.\n' +
43
- 'Image generation is a backend feature that requires authentication.');
44
- }
45
- if (error.response?.status === 429) {
46
- throw new Error('Image generation rate limit exceeded. Please try again later.');
47
- }
48
- throw new Error(error.response?.data?.error?.message ||
49
- error.message ||
50
- 'Image generation request failed');
39
+ if (error.response?.status === 429) {
40
+ throw new Error("Image generation rate limit exceeded. Please try again later.");
51
41
  }
42
+ throw new Error(
43
+ error.response?.data?.error?.message || error.message || "Image generation request failed"
44
+ );
45
+ }
52
46
  }
53
- /**
54
- * Get file extension from MIME type
55
- */
56
47
  function getExtensionFromMimeType(mimeType) {
57
- const mimeToExt = {
58
- 'image/png': '.png',
59
- 'image/jpeg': '.jpg',
60
- 'image/jpg': '.jpg',
61
- 'image/webp': '.webp',
62
- 'image/gif': '.gif',
63
- };
64
- return mimeToExt[mimeType] || '.png';
48
+ const mimeToExt = {
49
+ "image/png": ".png",
50
+ "image/jpeg": ".jpg",
51
+ "image/jpg": ".jpg",
52
+ "image/webp": ".webp",
53
+ "image/gif": ".gif"
54
+ };
55
+ return mimeToExt[mimeType] || ".png";
65
56
  }
66
- export const createImageTool = {
67
- schema: {
68
- name: 'create_image',
69
- description: `Generate an AI image using Gemini 2.0 Flash and save it to a file.
70
-
71
- Use this tool when you need to create visual content such as:
72
- - UI mockups, wireframes, or app screenshots
73
- - Icons, logos, or brand assets
74
- - Diagrams, flowcharts, or illustrations
75
- - Product images or concept art
76
- - Backgrounds, textures, or patterns
77
-
78
- IMPORTANT: Provide detailed, specific prompts for best results:
79
- - Describe the subject clearly (what is in the image)
80
- - Specify the style (photorealistic, cartoon, sketch, 3D render, watercolor, etc.)
81
- - Include colors, lighting, and mood (bright, dark, warm, cool)
82
- - Mention perspective and composition (close-up, wide shot, centered)
83
- - Add context about the background and environment
84
-
85
- Example prompts:
86
- - "A modern minimalist app login screen with gradient purple background, centered white login form with email and password fields, clean sans-serif typography"
87
- - "A friendly robot mascot character, cartoon style, blue and silver colors, smiling face, waving hand, white background"
88
- - "An isometric 3D illustration of a smart home, pastel colors, showing connected devices like lights, thermostat, and speakers"
89
-
90
- ASPECT RATIOS:
91
- - 1:1 - Square (default, good for icons, avatars)
92
- - 16:9 - Widescreen landscape (good for banners, headers)
93
- - 9:16 - Portrait/vertical (good for mobile, stories)
94
- - 4:3 - Standard landscape
95
- - 3:4 - Standard portrait
96
-
57
+ const createImageTool = {
58
+ schema: {
59
+ name: "create_image",
60
+ description: `Generate an AI image using Gemini 2.0 Flash and save it to a file.
61
+
62
+ Use this tool when you need to create visual content such as:
63
+ - UI mockups, wireframes, or app screenshots
64
+ - Icons, logos, or brand assets
65
+ - Diagrams, flowcharts, or illustrations
66
+ - Product images or concept art
67
+ - Backgrounds, textures, or patterns
68
+
69
+ IMPORTANT: Provide detailed, specific prompts for best results:
70
+ - Describe the subject clearly (what is in the image)
71
+ - Specify the style (photorealistic, cartoon, sketch, 3D render, watercolor, etc.)
72
+ - Include colors, lighting, and mood (bright, dark, warm, cool)
73
+ - Mention perspective and composition (close-up, wide shot, centered)
74
+ - Add context about the background and environment
75
+
76
+ Example prompts:
77
+ - "A modern minimalist app login screen with gradient purple background, centered white login form with email and password fields, clean sans-serif typography"
78
+ - "A friendly robot mascot character, cartoon style, blue and silver colors, smiling face, waving hand, white background"
79
+ - "An isometric 3D illustration of a smart home, pastel colors, showing connected devices like lights, thermostat, and speakers"
80
+
81
+ ASPECT RATIOS:
82
+ - 1:1 - Square (default, good for icons, avatars)
83
+ - 16:9 - Widescreen landscape (good for banners, headers)
84
+ - 9:16 - Portrait/vertical (good for mobile, stories)
85
+ - 4:3 - Standard landscape
86
+ - 3:4 - Standard portrait
87
+
97
88
  Requires authentication to use.`,
98
- parameters: {
99
- type: 'object',
100
- properties: {
101
- reason_text: {
102
- type: 'string',
103
- description: 'REQUIRED: A brief explanation of why you are generating this image. This will be shown to the user. Example: "Creating a logo for the new dashboard feature"'
104
- },
105
- image_prompt: {
106
- type: 'string',
107
- description: 'Detailed description of the image to generate. Be specific about subject, style, colors, composition, and mood for best results.'
108
- },
109
- output_path: {
110
- type: 'string',
111
- description: 'Absolute file path where the image should be saved. The directory must exist. Example: /path/to/project/assets/logo.png'
112
- },
113
- aspect_ratio: {
114
- type: 'string',
115
- enum: ['1:1', '16:9', '9:16', '4:3', '3:4'],
116
- description: 'Aspect ratio for the generated image. Default: 1:1 (square)'
117
- }
118
- },
119
- required: ['reason_text', 'image_prompt', 'output_path']
120
- }
121
- },
122
- async execute(args, context) {
123
- const { image_prompt, output_path, aspect_ratio } = args;
124
- // Validate image_prompt
125
- if (!image_prompt || typeof image_prompt !== 'string') {
126
- throw new Error('image_prompt is required and must be a string');
127
- }
128
- if (image_prompt.length < 3) {
129
- throw new Error('image_prompt must be at least 3 characters');
130
- }
131
- if (image_prompt.length > 5000) {
132
- throw new Error('image_prompt must not exceed 5000 characters');
133
- }
134
- // Validate output_path
135
- if (!output_path || typeof output_path !== 'string') {
136
- throw new Error('output_path is required and must be a string');
137
- }
138
- // Check for active context
139
- const contextManager = context.contextManager;
140
- const currentContext = contextManager?.getCurrentContext();
141
- const isRemote = currentContext && currentContext.type !== 'local';
142
- let finalPath = output_path;
143
- // Path validation and resolution
144
- if (!isRemote) {
145
- // Local execution: Resolve path against local CWD
146
- const resolvedPath = path.isAbsolute(output_path)
147
- ? output_path
148
- : path.resolve(context.cwd, output_path);
149
- // Check if directory exists
150
- const directory = path.dirname(resolvedPath);
151
- if (!fs.existsSync(directory)) {
152
- throw new Error(`Directory does not exist: ${directory}. Please create the directory first.`);
153
- }
154
- finalPath = resolvedPath;
155
- }
156
- else {
157
- // Remote execution: Validate directory existence via handler if possible?
158
- // For now, we'll assume the path is valid relative to remote CWD or absolute
159
- // The handler's writeFile will handle resolution relative to its tracked CWD
160
- }
161
- // Validate aspect ratio
162
- const validAspectRatios = ['1:1', '16:9', '9:16', '4:3', '3:4'];
163
- const selectedAspectRatio = aspect_ratio || '1:1';
164
- if (!validAspectRatios.includes(selectedAspectRatio)) {
165
- throw new Error(`Invalid aspect_ratio. Must be one of: ${validAspectRatios.join(', ')}`);
89
+ parameters: {
90
+ type: "object",
91
+ properties: {
92
+ reason_text: {
93
+ type: "string",
94
+ description: 'REQUIRED: A brief explanation of why you are generating this image. This will be shown to the user. Example: "Creating a logo for the new dashboard feature"'
95
+ },
96
+ image_prompt: {
97
+ type: "string",
98
+ description: "Detailed description of the image to generate. Be specific about subject, style, colors, composition, and mood for best results."
99
+ },
100
+ output_path: {
101
+ type: "string",
102
+ description: "Absolute file path where the image should be saved. The directory must exist. Example: /path/to/project/assets/logo.png"
103
+ },
104
+ aspect_ratio: {
105
+ type: "string",
106
+ enum: ["1:1", "16:9", "9:16", "4:3", "3:4"],
107
+ description: "Aspect ratio for the generated image. Default: 1:1 (square)"
166
108
  }
167
- try {
168
- // Generate the image via backend
169
- const result = await generateImageViaBackend(image_prompt, selectedAspectRatio);
170
- // Ensure the file has the correct extension based on MIME type
171
- const expectedExt = getExtensionFromMimeType(result.mimeType);
172
- const currentExt = path.extname(finalPath).toLowerCase();
173
- if (!currentExt) {
174
- // No extension provided, add one
175
- finalPath = finalPath + expectedExt;
176
- }
177
- else if (currentExt !== expectedExt && currentExt !== '.png' && currentExt !== '.jpg' && currentExt !== '.jpeg') {
178
- // Unusual extension, warn but proceed
179
- }
180
- // Decode base64
181
- const imageBuffer = Buffer.from(result.imageData, 'base64');
182
- let savedPath = finalPath;
183
- let fileSizeKB = 0;
184
- if (isRemote && currentContext.handler) {
185
- // Remote Write: Use the handler
186
- // Handler's writeFile resolves relative paths against its tracked CWD
187
- await currentContext.handler.writeFile(finalPath, imageBuffer);
188
- fileSizeKB = Math.round(imageBuffer.length / 1024);
189
- // For display, hint that it's remote
190
- savedPath = `${finalPath} (on ${currentContext.type})`;
191
- }
192
- else {
193
- // Local Write: Use fs
194
- fs.writeFileSync(finalPath, imageBuffer);
195
- const stats = fs.statSync(finalPath);
196
- fileSizeKB = Math.round(stats.size / 1024);
197
- savedPath = finalPath;
198
- }
199
- return `Image generated successfully!
200
-
201
- **File:** ${savedPath}
202
- **Size:** ${fileSizeKB} KB
203
- **Format:** ${result.mimeType}
204
- **Aspect Ratio:** ${selectedAspectRatio}
205
-
109
+ },
110
+ required: ["reason_text", "image_prompt", "output_path"]
111
+ }
112
+ },
113
+ async execute(args, context) {
114
+ const { image_prompt, output_path, aspect_ratio } = args;
115
+ if (!image_prompt || typeof image_prompt !== "string") {
116
+ throw new Error("image_prompt is required and must be a string");
117
+ }
118
+ if (image_prompt.length < 3) {
119
+ throw new Error("image_prompt must be at least 3 characters");
120
+ }
121
+ if (image_prompt.length > 5e3) {
122
+ throw new Error("image_prompt must not exceed 5000 characters");
123
+ }
124
+ if (!output_path || typeof output_path !== "string") {
125
+ throw new Error("output_path is required and must be a string");
126
+ }
127
+ const contextManager = context.contextManager;
128
+ const currentContext = contextManager?.getCurrentContext();
129
+ const isRemote = currentContext && currentContext.type !== "local";
130
+ let finalPath = output_path;
131
+ if (!isRemote) {
132
+ const resolvedPath = path.isAbsolute(output_path) ? output_path : path.resolve(context.cwd, output_path);
133
+ const directory = path.dirname(resolvedPath);
134
+ if (!fs.existsSync(directory)) {
135
+ throw new Error(`Directory does not exist: ${directory}. Please create the directory first.`);
136
+ }
137
+ finalPath = resolvedPath;
138
+ } else {
139
+ }
140
+ const validAspectRatios = ["1:1", "16:9", "9:16", "4:3", "3:4"];
141
+ const selectedAspectRatio = aspect_ratio || "1:1";
142
+ if (!validAspectRatios.includes(selectedAspectRatio)) {
143
+ throw new Error(`Invalid aspect_ratio. Must be one of: ${validAspectRatios.join(", ")}`);
144
+ }
145
+ try {
146
+ const result = await generateImageViaBackend(image_prompt, selectedAspectRatio);
147
+ const expectedExt = getExtensionFromMimeType(result.mimeType);
148
+ const currentExt = path.extname(finalPath).toLowerCase();
149
+ if (!currentExt) {
150
+ finalPath = finalPath + expectedExt;
151
+ } else if (currentExt !== expectedExt && currentExt !== ".png" && currentExt !== ".jpg" && currentExt !== ".jpeg") {
152
+ }
153
+ const imageBuffer = Buffer.from(result.imageData, "base64");
154
+ let savedPath = finalPath;
155
+ let fileSizeKB = 0;
156
+ if (isRemote && currentContext.handler) {
157
+ await currentContext.handler.writeFile(finalPath, imageBuffer);
158
+ fileSizeKB = Math.round(imageBuffer.length / 1024);
159
+ savedPath = `${finalPath} (on ${currentContext.type})`;
160
+ } else {
161
+ fs.writeFileSync(finalPath, imageBuffer);
162
+ const stats = fs.statSync(finalPath);
163
+ fileSizeKB = Math.round(stats.size / 1024);
164
+ savedPath = finalPath;
165
+ }
166
+ return `Image generated successfully!
167
+
168
+ **File:** ${savedPath}
169
+ **Size:** ${fileSizeKB} KB
170
+ **Format:** ${result.mimeType}
171
+ **Aspect Ratio:** ${selectedAspectRatio}
172
+
206
173
  The image has been saved and is ready to use.`;
207
- }
208
- catch (error) {
209
- throw new Error(`Image generation failed: ${error.message}`);
210
- }
174
+ } catch (error) {
175
+ throw new Error(`Image generation failed: ${error.message}`);
211
176
  }
177
+ }
178
+ };
179
+ var create_image_default = createImageTool;
180
+ export {
181
+ createImageTool,
182
+ create_image_default as default
212
183
  };
213
- export default createImageTool;
214
184
  //# sourceMappingURL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e,eAAe,CAAC"}
1
+ {"version":3,"sources":["../../src/tools/create-image.ts"],"sourcesContent":["/**\r\n * Create Image Tool\r\n * \r\n * Generates images using Gemini 2.0 Flash image generation via backend API.\r\n * The generated image is saved to the specified file path.\r\n */\r\n\r\nimport { Tool, ToolExecutionContext } from './types.js';\r\nimport * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\n/**\r\n * Generate an image via backend API\r\n */\r\nasync function generateImageViaBackend(\r\n prompt: string,\r\n aspectRatio: string = '1:1'\r\n): Promise<{ imageData: string; mimeType: string }> {\r\n // Import axios and apiClient dynamically to avoid circular dependencies\r\n const axios = (await import('axios')).default;\r\n const { apiClient } = await import('../services/api-client.js');\r\n\r\n // Check if authenticated\r\n if (!apiClient.isAuthenticated()) {\r\n throw new Error(\r\n 'Authentication required. Please sign in to use image generation.\\n' +\r\n 'Image generation is a backend feature that requires authentication.'\r\n );\r\n }\r\n\r\n try {\r\n // Import build config - values frozen at compile time for security\r\n const { IS_DEV_BUILD, DEV_BACKEND_URL, PRODUCTION_BACKEND_URL } = await import('../config/build-config.js');\r\n const baseURL = IS_DEV_BUILD ? DEV_BACKEND_URL : PRODUCTION_BACKEND_URL;\r\n\r\n const response = await axios.post(\r\n `${baseURL}/images/generations`,\r\n {\r\n prompt,\r\n aspect_ratio: aspectRatio,\r\n },\r\n {\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Authorization': `Bearer ${(apiClient as any).sessionToken}`,\r\n },\r\n timeout: 120000, // 2 minute timeout for image generation\r\n }\r\n );\r\n\r\n if (!response.data || !response.data.success) {\r\n throw new Error(response.data?.error?.message || 'Image generation failed');\r\n }\r\n\r\n return response.data.data;\r\n } catch (error: any) {\r\n if (error.response?.status === 401) {\r\n throw new Error(\r\n 'Authentication required. Please sign in to use image generation.\\n' +\r\n 'Image generation is a backend feature that requires authentication.'\r\n );\r\n }\r\n if (error.response?.status === 429) {\r\n throw new Error('Image generation rate limit exceeded. Please try again later.');\r\n }\r\n throw new Error(\r\n error.response?.data?.error?.message ||\r\n error.message ||\r\n 'Image generation request failed'\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Get file extension from MIME type\r\n */\r\nfunction getExtensionFromMimeType(mimeType: string): string {\r\n const mimeToExt: Record<string, string> = {\r\n 'image/png': '.png',\r\n 'image/jpeg': '.jpg',\r\n 'image/jpg': '.jpg',\r\n 'image/webp': '.webp',\r\n 'image/gif': '.gif',\r\n };\r\n return mimeToExt[mimeType] || '.png';\r\n}\r\n\r\nexport const createImageTool: Tool = {\r\n schema: {\r\n name: 'create_image',\r\n description: `Generate an AI image using Gemini 2.0 Flash and save it to a file.\r\n\r\nUse this tool when you need to create visual content such as:\r\n- UI mockups, wireframes, or app screenshots\r\n- Icons, logos, or brand assets\r\n- Diagrams, flowcharts, or illustrations\r\n- Product images or concept art\r\n- Backgrounds, textures, or patterns\r\n\r\nIMPORTANT: Provide detailed, specific prompts for best results:\r\n- Describe the subject clearly (what is in the image)\r\n- Specify the style (photorealistic, cartoon, sketch, 3D render, watercolor, etc.)\r\n- Include colors, lighting, and mood (bright, dark, warm, cool)\r\n- Mention perspective and composition (close-up, wide shot, centered)\r\n- Add context about the background and environment\r\n\r\nExample prompts:\r\n- \"A modern minimalist app login screen with gradient purple background, centered white login form with email and password fields, clean sans-serif typography\"\r\n- \"A friendly robot mascot character, cartoon style, blue and silver colors, smiling face, waving hand, white background\"\r\n- \"An isometric 3D illustration of a smart home, pastel colors, showing connected devices like lights, thermostat, and speakers\"\r\n\r\nASPECT RATIOS:\r\n- 1:1 - Square (default, good for icons, avatars)\r\n- 16:9 - Widescreen landscape (good for banners, headers)\r\n- 9:16 - Portrait/vertical (good for mobile, stories)\r\n- 4:3 - Standard landscape\r\n- 3:4 - Standard portrait\r\n\r\nRequires authentication to use.`,\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 why you are generating this image. This will be shown to the user. Example: \"Creating a logo for the new dashboard feature\"'\r\n },\r\n image_prompt: {\r\n type: 'string',\r\n description: 'Detailed description of the image to generate. Be specific about subject, style, colors, composition, and mood for best results.'\r\n },\r\n output_path: {\r\n type: 'string',\r\n description: 'Absolute file path where the image should be saved. The directory must exist. Example: /path/to/project/assets/logo.png'\r\n },\r\n aspect_ratio: {\r\n type: 'string',\r\n enum: ['1:1', '16:9', '9:16', '4:3', '3:4'],\r\n description: 'Aspect ratio for the generated image. Default: 1:1 (square)'\r\n }\r\n },\r\n required: ['reason_text', 'image_prompt', 'output_path']\r\n }\r\n },\r\n\r\n async execute(args: Record<string, any>, context: ToolExecutionContext): Promise<string> {\r\n const { image_prompt, output_path, aspect_ratio } = args;\r\n\r\n // Validate image_prompt\r\n if (!image_prompt || typeof image_prompt !== 'string') {\r\n throw new Error('image_prompt is required and must be a string');\r\n }\r\n\r\n if (image_prompt.length < 3) {\r\n throw new Error('image_prompt must be at least 3 characters');\r\n }\r\n\r\n if (image_prompt.length > 5000) {\r\n throw new Error('image_prompt must not exceed 5000 characters');\r\n }\r\n\r\n // Validate output_path\r\n if (!output_path || typeof output_path !== 'string') {\r\n throw new Error('output_path is required and must be a string');\r\n }\r\n\r\n // Check for active context\r\n const contextManager = context.contextManager;\r\n const currentContext = contextManager?.getCurrentContext();\r\n const isRemote = currentContext && currentContext.type !== 'local';\r\n\r\n let finalPath = output_path;\r\n\r\n // Path validation and resolution\r\n if (!isRemote) {\r\n // Local execution: Resolve path against local CWD\r\n const resolvedPath = path.isAbsolute(output_path)\r\n ? output_path\r\n : path.resolve(context.cwd, output_path);\r\n\r\n // Check if directory exists\r\n const directory = path.dirname(resolvedPath);\r\n if (!fs.existsSync(directory)) {\r\n throw new Error(`Directory does not exist: ${directory}. Please create the directory first.`);\r\n }\r\n finalPath = resolvedPath;\r\n } else {\r\n // Remote execution: Validate directory existence via handler if possible?\r\n // For now, we'll assume the path is valid relative to remote CWD or absolute\r\n // The handler's writeFile will handle resolution relative to its tracked CWD\r\n }\r\n\r\n // Validate aspect ratio\r\n const validAspectRatios = ['1:1', '16:9', '9:16', '4:3', '3:4'];\r\n const selectedAspectRatio = aspect_ratio || '1:1';\r\n if (!validAspectRatios.includes(selectedAspectRatio)) {\r\n throw new Error(`Invalid aspect_ratio. Must be one of: ${validAspectRatios.join(', ')}`);\r\n }\r\n\r\n try {\r\n // Generate the image via backend\r\n const result = await generateImageViaBackend(image_prompt, selectedAspectRatio);\r\n\r\n // Ensure the file has the correct extension based on MIME type\r\n const expectedExt = getExtensionFromMimeType(result.mimeType);\r\n const currentExt = path.extname(finalPath).toLowerCase();\r\n\r\n if (!currentExt) {\r\n // No extension provided, add one\r\n finalPath = finalPath + expectedExt;\r\n } else if (currentExt !== expectedExt && currentExt !== '.png' && currentExt !== '.jpg' && currentExt !== '.jpeg') {\r\n // Unusual extension, warn but proceed\r\n }\r\n\r\n // Decode base64\r\n const imageBuffer = Buffer.from(result.imageData, 'base64');\r\n\r\n let savedPath = finalPath;\r\n let fileSizeKB = 0;\r\n\r\n if (isRemote && currentContext.handler) {\r\n // Remote Write: Use the handler\r\n // Handler's writeFile resolves relative paths against its tracked CWD\r\n await currentContext.handler.writeFile(finalPath, imageBuffer);\r\n fileSizeKB = Math.round(imageBuffer.length / 1024);\r\n\r\n // For display, hint that it's remote\r\n savedPath = `${finalPath} (on ${currentContext.type})`;\r\n } else {\r\n // Local Write: Use fs\r\n fs.writeFileSync(finalPath, imageBuffer);\r\n const stats = fs.statSync(finalPath);\r\n fileSizeKB = Math.round(stats.size / 1024);\r\n savedPath = finalPath;\r\n }\r\n\r\n return `Image generated successfully!\r\n\r\n**File:** ${savedPath}\r\n**Size:** ${fileSizeKB} KB\r\n**Format:** ${result.mimeType}\r\n**Aspect Ratio:** ${selectedAspectRatio}\r\n\r\nThe image has been saved and is ready to use.`;\r\n\r\n } catch (error: any) {\r\n throw new Error(`Image generation failed: ${error.message}`);\r\n }\r\n }\r\n};\r\n\r\nexport default createImageTool;\r\n"],"mappings":"AAQA,YAAY,QAAQ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