@machina.ai/cell-cli 1.0.13-rc9 → 1.0.21-rc1

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 (579) hide show
  1. package/dist/package.json +11 -7
  2. package/dist/src/commands/mcp/add.d.ts +7 -0
  3. package/dist/src/commands/mcp/add.js +166 -0
  4. package/dist/src/commands/mcp/add.js.map +1 -0
  5. package/dist/src/commands/mcp/list.d.ts +8 -0
  6. package/dist/src/commands/mcp/list.js +110 -0
  7. package/dist/src/commands/mcp/list.js.map +1 -0
  8. package/dist/src/commands/mcp/remove.d.ts +7 -0
  9. package/dist/src/commands/mcp/remove.js +44 -0
  10. package/dist/src/commands/mcp/remove.js.map +1 -0
  11. package/dist/src/commands/mcp.d.ts +7 -0
  12. package/dist/src/commands/mcp.js +23 -0
  13. package/dist/src/commands/mcp.js.map +1 -0
  14. package/dist/src/config/auth.test.d.ts +6 -0
  15. package/dist/src/config/auth.test.js +28 -0
  16. package/dist/src/config/auth.test.js.map +1 -0
  17. package/dist/src/config/config.d.ts +6 -3
  18. package/dist/src/config/config.js +177 -90
  19. package/dist/src/config/config.js.map +1 -1
  20. package/dist/src/config/extension.d.ts +1 -0
  21. package/dist/src/config/extension.js +4 -0
  22. package/dist/src/config/extension.js.map +1 -1
  23. package/dist/src/config/keyBindings.d.ts +66 -0
  24. package/dist/src/config/keyBindings.js +141 -0
  25. package/dist/src/config/keyBindings.js.map +1 -0
  26. package/dist/src/config/keyBindings.test.d.ts +6 -0
  27. package/dist/src/config/keyBindings.test.js +51 -0
  28. package/dist/src/config/keyBindings.test.js.map +1 -0
  29. package/dist/src/config/sandboxConfig.js +3 -3
  30. package/dist/src/config/sandboxConfig.js.map +1 -1
  31. package/dist/src/config/settings.d.ts +6 -41
  32. package/dist/src/config/settings.js +137 -52
  33. package/dist/src/config/settings.js.map +1 -1
  34. package/dist/src/config/settingsSchema.d.ts +533 -0
  35. package/dist/src/config/settingsSchema.js +507 -0
  36. package/dist/src/config/settingsSchema.js.map +1 -0
  37. package/dist/src/config/settingsSchema.test.d.ts +6 -0
  38. package/dist/src/config/settingsSchema.test.js +195 -0
  39. package/dist/src/config/settingsSchema.test.js.map +1 -0
  40. package/dist/src/config/trustedFolders.d.ts +37 -0
  41. package/dist/src/config/trustedFolders.js +118 -0
  42. package/dist/src/config/trustedFolders.js.map +1 -0
  43. package/dist/src/config/trustedFolders.test.d.ts +6 -0
  44. package/dist/src/config/trustedFolders.test.js +160 -0
  45. package/dist/src/config/trustedFolders.test.js.map +1 -0
  46. package/dist/src/gemini.d.ts +3 -0
  47. package/dist/src/gemini.js +106 -68
  48. package/dist/src/gemini.js.map +1 -1
  49. package/dist/src/gemini.test.d.ts +6 -0
  50. package/dist/src/gemini.test.js +193 -0
  51. package/dist/src/gemini.test.js.map +1 -0
  52. package/dist/src/generated/git-commit.d.ts +2 -1
  53. package/dist/src/generated/git-commit.js +3 -2
  54. package/dist/src/generated/git-commit.js.map +1 -1
  55. package/dist/src/nonInteractiveCli.js +35 -55
  56. package/dist/src/nonInteractiveCli.js.map +1 -1
  57. package/dist/src/patches/is-in-ci.d.ts +7 -0
  58. package/dist/src/patches/is-in-ci.js +15 -0
  59. package/dist/src/patches/is-in-ci.js.map +1 -0
  60. package/dist/src/services/BuiltinCommandLoader.js +12 -0
  61. package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
  62. package/dist/src/services/BuiltinCommandLoader.test.d.ts +6 -0
  63. package/dist/src/services/BuiltinCommandLoader.test.js +108 -0
  64. package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -0
  65. package/dist/src/services/CommandService.d.ts +8 -4
  66. package/dist/src/services/CommandService.js +24 -8
  67. package/dist/src/services/CommandService.js.map +1 -1
  68. package/dist/src/services/CommandService.test.d.ts +6 -0
  69. package/dist/src/services/CommandService.test.js +232 -0
  70. package/dist/src/services/CommandService.test.js.map +1 -0
  71. package/dist/src/services/FileCommandLoader.d.ts +15 -3
  72. package/dist/src/services/FileCommandLoader.js +115 -38
  73. package/dist/src/services/FileCommandLoader.js.map +1 -1
  74. package/dist/src/services/McpPromptLoader.d.ts +25 -0
  75. package/dist/src/services/McpPromptLoader.js +192 -0
  76. package/dist/src/services/McpPromptLoader.js.map +1 -0
  77. package/dist/src/services/prompt-processors/argumentProcessor.d.ts +16 -0
  78. package/dist/src/services/prompt-processors/argumentProcessor.js +20 -0
  79. package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -0
  80. package/dist/src/services/prompt-processors/shellProcessor.d.ts +35 -0
  81. package/dist/src/services/prompt-processors/shellProcessor.js +170 -0
  82. package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
  83. package/dist/src/services/prompt-processors/types.d.ts +40 -0
  84. package/dist/src/services/prompt-processors/types.js +16 -0
  85. package/dist/src/services/prompt-processors/types.js.map +1 -0
  86. package/dist/src/test-utils/customMatchers.d.ts +14 -0
  87. package/dist/src/test-utils/customMatchers.js +46 -0
  88. package/dist/src/test-utils/customMatchers.js.map +1 -0
  89. package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
  90. package/dist/src/test-utils/mockCommandContext.js +86 -0
  91. package/dist/src/test-utils/mockCommandContext.js.map +1 -0
  92. package/dist/src/test-utils/mockCommandContext.test.d.ts +6 -0
  93. package/dist/src/test-utils/mockCommandContext.test.js +51 -0
  94. package/dist/src/test-utils/mockCommandContext.test.js.map +1 -0
  95. package/dist/src/test-utils/render.d.ts +8 -0
  96. package/dist/src/test-utils/render.js +10 -0
  97. package/dist/src/test-utils/render.js.map +1 -0
  98. package/dist/src/ui/App.js +229 -67
  99. package/dist/src/ui/App.js.map +1 -1
  100. package/dist/src/ui/IdeIntegrationNudge.d.ts +16 -0
  101. package/dist/src/ui/IdeIntegrationNudge.js +52 -0
  102. package/dist/src/ui/IdeIntegrationNudge.js.map +1 -0
  103. package/dist/src/ui/colors.js +6 -0
  104. package/dist/src/ui/colors.js.map +1 -1
  105. package/dist/src/ui/commands/aboutCommand.js +9 -5
  106. package/dist/src/ui/commands/aboutCommand.js.map +1 -1
  107. package/dist/src/ui/commands/bugCommand.js +13 -5
  108. package/dist/src/ui/commands/bugCommand.js.map +1 -1
  109. package/dist/src/ui/commands/chatCommand.js +66 -6
  110. package/dist/src/ui/commands/chatCommand.js.map +1 -1
  111. package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
  112. package/dist/src/ui/commands/directoryCommand.js +134 -0
  113. package/dist/src/ui/commands/directoryCommand.js.map +1 -0
  114. package/dist/src/ui/commands/docsCommand.js +1 -1
  115. package/dist/src/ui/commands/docsCommand.js.map +1 -1
  116. package/dist/src/ui/commands/helpCommand.js +7 -6
  117. package/dist/src/ui/commands/helpCommand.js.map +1 -1
  118. package/dist/src/ui/commands/ideCommand.js +179 -109
  119. package/dist/src/ui/commands/ideCommand.js.map +1 -1
  120. package/dist/src/ui/commands/initCommand.d.ts +7 -0
  121. package/dist/src/ui/commands/initCommand.js +76 -0
  122. package/dist/src/ui/commands/initCommand.js.map +1 -0
  123. package/dist/src/ui/commands/mcpCommand.js +244 -26
  124. package/dist/src/ui/commands/mcpCommand.js.map +1 -1
  125. package/dist/src/ui/commands/memoryCommand.js +9 -4
  126. package/dist/src/ui/commands/memoryCommand.js.map +1 -1
  127. package/dist/src/ui/commands/settingsCommand.d.ts +7 -0
  128. package/dist/src/ui/commands/settingsCommand.js +16 -0
  129. package/dist/src/ui/commands/settingsCommand.js.map +1 -0
  130. package/dist/src/ui/commands/setupGithubCommand.d.ts +7 -0
  131. package/dist/src/ui/commands/setupGithubCommand.js +115 -0
  132. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
  133. package/dist/src/ui/commands/setupGithubCommand.test.d.ts +6 -0
  134. package/dist/src/ui/commands/setupGithubCommand.test.js +74 -0
  135. package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -0
  136. package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
  137. package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
  138. package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
  139. package/dist/src/ui/commands/types.d.ts +42 -3
  140. package/dist/src/ui/commands/types.js +1 -0
  141. package/dist/src/ui/commands/types.js.map +1 -1
  142. package/dist/src/ui/commands/vimCommand.d.ts +7 -0
  143. package/dist/src/ui/commands/vimCommand.js +23 -0
  144. package/dist/src/ui/commands/vimCommand.js.map +1 -0
  145. package/dist/src/ui/components/AboutBox.d.ts +1 -0
  146. package/dist/src/ui/components/AboutBox.js +1 -1
  147. package/dist/src/ui/components/AboutBox.js.map +1 -1
  148. package/dist/src/ui/components/AsciiArt.d.ts +3 -2
  149. package/dist/src/ui/components/AsciiArt.js +23 -12
  150. package/dist/src/ui/components/AsciiArt.js.map +1 -1
  151. package/dist/src/ui/components/AuthDialog.js +12 -6
  152. package/dist/src/ui/components/AuthDialog.js.map +1 -1
  153. package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
  154. package/dist/src/ui/components/AuthDialog.test.js +114 -0
  155. package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
  156. package/dist/src/ui/components/AuthInProgress.js +5 -4
  157. package/dist/src/ui/components/AuthInProgress.js.map +1 -1
  158. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +2 -2
  159. package/dist/src/ui/components/ContextSummaryDisplay.js +31 -34
  160. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  161. package/dist/src/ui/components/ContextUsageDisplay.d.ts +9 -0
  162. package/dist/src/ui/components/ContextUsageDisplay.js +14 -0
  163. package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -0
  164. package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
  165. package/dist/src/ui/components/DebugProfiler.js +27 -0
  166. package/dist/src/ui/components/DebugProfiler.js.map +1 -0
  167. package/dist/src/ui/components/EditorSettingsDialog.js +6 -5
  168. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
  169. package/dist/src/ui/components/FolderTrustDialog.d.ts +16 -0
  170. package/dist/src/ui/components/FolderTrustDialog.js +39 -0
  171. package/dist/src/ui/components/FolderTrustDialog.js.map +1 -0
  172. package/dist/src/ui/components/FolderTrustDialog.test.d.ts +6 -0
  173. package/dist/src/ui/components/FolderTrustDialog.test.js +26 -0
  174. package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -0
  175. package/dist/src/ui/components/Footer.d.ts +2 -0
  176. package/dist/src/ui/components/Footer.js +18 -7
  177. package/dist/src/ui/components/Footer.js.map +1 -1
  178. package/dist/src/ui/components/Header.d.ts +0 -1
  179. package/dist/src/ui/components/Header.js +13 -5
  180. package/dist/src/ui/components/Header.js.map +1 -1
  181. package/dist/src/ui/components/Header.test.d.ts +6 -0
  182. package/dist/src/ui/components/Header.test.js +44 -0
  183. package/dist/src/ui/components/Header.test.js.map +1 -0
  184. package/dist/src/ui/components/Help.js +2 -2
  185. package/dist/src/ui/components/Help.js.map +1 -1
  186. package/dist/src/ui/components/HistoryItemDisplay.d.ts +2 -0
  187. package/dist/src/ui/components/HistoryItemDisplay.js +2 -1
  188. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
  189. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
  190. package/dist/src/ui/components/HistoryItemDisplay.test.js +91 -0
  191. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
  192. package/dist/src/ui/components/InputPrompt.d.ts +3 -0
  193. package/dist/src/ui/components/InputPrompt.js +179 -126
  194. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  195. package/dist/src/ui/components/LoadingIndicator.js +10 -5
  196. package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
  197. package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
  198. package/dist/src/ui/components/LoadingIndicator.test.js +190 -0
  199. package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
  200. package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
  201. package/dist/src/ui/components/PrepareLabel.js +16 -0
  202. package/dist/src/ui/components/PrepareLabel.js.map +1 -0
  203. package/dist/src/ui/components/SettingsDialog.d.ts +14 -0
  204. package/dist/src/ui/components/SettingsDialog.js +519 -0
  205. package/dist/src/ui/components/SettingsDialog.js.map +1 -0
  206. package/dist/src/ui/components/SettingsDialog.test.d.ts +6 -0
  207. package/dist/src/ui/components/SettingsDialog.test.js +568 -0
  208. package/dist/src/ui/components/SettingsDialog.test.js.map +1 -0
  209. package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
  210. package/dist/src/ui/components/ShellConfirmationDialog.js +46 -0
  211. package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
  212. package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +6 -0
  213. package/dist/src/ui/components/ShellConfirmationDialog.test.js +40 -0
  214. package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -0
  215. package/dist/src/ui/components/StatsDisplay.js +8 -7
  216. package/dist/src/ui/components/StatsDisplay.js.map +1 -1
  217. package/dist/src/ui/components/SuggestionsDisplay.d.ts +1 -0
  218. package/dist/src/ui/components/SuggestionsDisplay.js +3 -3
  219. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
  220. package/dist/src/ui/components/ThemeDialog.js +20 -25
  221. package/dist/src/ui/components/ThemeDialog.js.map +1 -1
  222. package/dist/src/ui/components/Tips.js +1 -1
  223. package/dist/src/ui/components/Tips.js.map +1 -1
  224. package/dist/src/ui/components/messages/DiffRenderer.js +21 -11
  225. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -1
  226. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
  227. package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
  228. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
  229. package/dist/src/ui/components/messages/InfoMessage.js +2 -1
  230. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
  231. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +52 -18
  232. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
  233. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
  234. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
  235. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
  236. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
  237. package/dist/src/ui/components/messages/ToolMessage.test.js +118 -0
  238. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
  239. package/dist/src/ui/components/messages/UserMessage.js +4 -1
  240. package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
  241. package/dist/src/ui/components/shared/MaxSizedBox.js +1 -1
  242. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
  243. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
  244. package/dist/src/ui/components/shared/MaxSizedBox.test.js +154 -0
  245. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
  246. package/dist/src/ui/components/shared/RadioButtonSelect.js +11 -9
  247. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
  248. package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +6 -0
  249. package/dist/src/ui/components/shared/RadioButtonSelect.test.js +111 -0
  250. package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -0
  251. package/dist/src/ui/components/shared/text-buffer.d.ts +286 -3
  252. package/dist/src/ui/components/shared/text-buffer.js +612 -89
  253. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  254. package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
  255. package/dist/src/ui/components/shared/vim-buffer-actions.js +552 -0
  256. package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
  257. package/dist/src/ui/contexts/KeypressContext.d.ts +30 -0
  258. package/dist/src/ui/contexts/KeypressContext.js +309 -0
  259. package/dist/src/ui/contexts/KeypressContext.js.map +1 -0
  260. package/dist/src/ui/contexts/KeypressContext.test.d.ts +6 -0
  261. package/dist/src/ui/contexts/KeypressContext.test.js +219 -0
  262. package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -0
  263. package/dist/src/ui/contexts/SessionContext.d.ts +3 -0
  264. package/dist/src/ui/contexts/SessionContext.js +2 -1
  265. package/dist/src/ui/contexts/SessionContext.js.map +1 -1
  266. package/dist/src/ui/contexts/SettingsContext.d.ts +9 -0
  267. package/dist/src/ui/contexts/SettingsContext.js +15 -0
  268. package/dist/src/ui/contexts/SettingsContext.js.map +1 -0
  269. package/dist/src/ui/contexts/VimModeContext.d.ts +19 -0
  270. package/dist/src/ui/contexts/VimModeContext.js +48 -0
  271. package/dist/src/ui/contexts/VimModeContext.js.map +1 -0
  272. package/dist/src/ui/editors/editorSettingsManager.js +6 -13
  273. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
  274. package/dist/src/ui/hooks/atCommandProcessor.js +82 -62
  275. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
  276. package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +6 -0
  277. package/dist/src/ui/hooks/atCommandProcessor.test.js +809 -0
  278. package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -0
  279. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +1 -0
  280. package/dist/src/ui/hooks/shellCommandProcessor.js +139 -196
  281. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
  282. package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +6 -0
  283. package/dist/src/ui/hooks/shellCommandProcessor.test.js +328 -0
  284. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -0
  285. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +11 -3
  286. package/dist/src/ui/hooks/slashCommandProcessor.js +237 -90
  287. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  288. package/dist/src/ui/hooks/useAtCompletion.d.ts +23 -0
  289. package/dist/src/ui/hooks/useAtCompletion.js +178 -0
  290. package/dist/src/ui/hooks/useAtCompletion.js.map +1 -0
  291. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +5 -5
  292. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
  293. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +6 -0
  294. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +191 -0
  295. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -0
  296. package/dist/src/ui/hooks/useCommandCompletion.d.ts +29 -0
  297. package/dist/src/ui/hooks/useCommandCompletion.js +165 -0
  298. package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -0
  299. package/dist/src/ui/hooks/useCompletion.d.ts +5 -3
  300. package/dist/src/ui/hooks/useCompletion.js +7 -312
  301. package/dist/src/ui/hooks/useCompletion.js.map +1 -1
  302. package/dist/src/ui/hooks/useConsoleMessages.js +53 -37
  303. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -1
  304. package/dist/src/ui/hooks/useEditorSettings.test.d.ts +6 -0
  305. package/dist/src/ui/hooks/useEditorSettings.test.js +164 -0
  306. package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -0
  307. package/dist/src/ui/hooks/useFocus.d.ts +4 -0
  308. package/dist/src/ui/hooks/useFocus.js +4 -4
  309. package/dist/src/ui/hooks/useFocus.js.map +1 -1
  310. package/dist/src/ui/hooks/useFolderTrust.d.ts +12 -0
  311. package/dist/src/ui/hooks/useFolderTrust.js +55 -0
  312. package/dist/src/ui/hooks/useFolderTrust.js.map +1 -0
  313. package/dist/src/ui/hooks/useGeminiStream.d.ts +2 -1
  314. package/dist/src/ui/hooks/useGeminiStream.js +40 -26
  315. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  316. package/dist/src/ui/hooks/useGitBranchName.test.d.ts +6 -0
  317. package/dist/src/ui/hooks/useGitBranchName.test.js +175 -0
  318. package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -0
  319. package/dist/src/ui/hooks/useHistoryManager.test.d.ts +6 -0
  320. package/dist/src/ui/hooks/useHistoryManager.test.js +171 -0
  321. package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -0
  322. package/dist/src/ui/hooks/useInputHistory.d.ts +1 -1
  323. package/dist/src/ui/hooks/useInputHistory.test.d.ts +6 -0
  324. package/dist/src/ui/hooks/useInputHistory.test.js +207 -0
  325. package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -0
  326. package/dist/src/ui/hooks/useKeypress.d.ts +4 -16
  327. package/dist/src/ui/hooks/useKeypress.js +8 -137
  328. package/dist/src/ui/hooks/useKeypress.js.map +1 -1
  329. package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
  330. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
  331. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
  332. package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +6 -0
  333. package/dist/src/ui/hooks/useLoadingIndicator.test.js +91 -0
  334. package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -0
  335. package/dist/src/ui/hooks/useMessageQueue.d.ts +22 -0
  336. package/dist/src/ui/hooks/useMessageQueue.js +49 -0
  337. package/dist/src/ui/hooks/useMessageQueue.js.map +1 -0
  338. package/dist/src/ui/hooks/useMessageQueue.test.d.ts +6 -0
  339. package/dist/src/ui/hooks/useMessageQueue.test.js +158 -0
  340. package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -0
  341. package/dist/src/ui/hooks/usePhraseCycler.js +3 -5
  342. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
  343. package/dist/src/ui/hooks/usePrivacySettings.js +6 -2
  344. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -1
  345. package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +6 -0
  346. package/dist/src/ui/hooks/usePrivacySettings.test.js +154 -0
  347. package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -0
  348. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +1 -1
  349. package/dist/src/ui/hooks/useReactToolScheduler.js +18 -17
  350. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
  351. package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
  352. package/dist/src/ui/hooks/useReverseSearchCompletion.js +56 -0
  353. package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
  354. package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +6 -0
  355. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +163 -0
  356. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -0
  357. package/dist/src/ui/hooks/useSettingsCommand.d.ts +10 -0
  358. package/dist/src/ui/hooks/useSettingsCommand.js +21 -0
  359. package/dist/src/ui/hooks/useSettingsCommand.js.map +1 -0
  360. package/dist/src/ui/hooks/useShellHistory.d.ts +4 -2
  361. package/dist/src/ui/hooks/useShellHistory.js +30 -7
  362. package/dist/src/ui/hooks/useShellHistory.js.map +1 -1
  363. package/dist/src/ui/hooks/useShellHistory.test.d.ts +6 -0
  364. package/dist/src/ui/hooks/useShellHistory.test.js +159 -0
  365. package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -0
  366. package/dist/src/ui/hooks/useSlashCompletion.d.ts +20 -0
  367. package/dist/src/ui/hooks/useSlashCompletion.js +135 -0
  368. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
  369. package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +6 -0
  370. package/dist/src/ui/hooks/useSlashCompletion.test.js +272 -0
  371. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -0
  372. package/dist/src/ui/hooks/useThemeCommand.js +1 -1
  373. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
  374. package/dist/src/ui/hooks/useTimer.test.d.ts +6 -0
  375. package/dist/src/ui/hooks/useTimer.test.js +90 -0
  376. package/dist/src/ui/hooks/useTimer.test.js.map +1 -0
  377. package/dist/src/ui/hooks/useToolScheduler.test.d.ts +6 -0
  378. package/dist/src/ui/hooks/useToolScheduler.test.js +846 -0
  379. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -0
  380. package/dist/src/ui/hooks/vim.d.ts +28 -0
  381. package/dist/src/ui/hooks/vim.js +639 -0
  382. package/dist/src/ui/hooks/vim.js.map +1 -0
  383. package/dist/src/ui/keyMatchers.d.ts +26 -0
  384. package/dist/src/ui/keyMatchers.js +68 -0
  385. package/dist/src/ui/keyMatchers.js.map +1 -0
  386. package/dist/src/ui/keyMatchers.test.d.ts +6 -0
  387. package/dist/src/ui/keyMatchers.test.js +276 -0
  388. package/dist/src/ui/keyMatchers.test.js.map +1 -0
  389. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +5 -4
  390. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
  391. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +5 -4
  392. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -1
  393. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +5 -4
  394. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -1
  395. package/dist/src/ui/semantic-colors.d.ts +7 -0
  396. package/dist/src/ui/semantic-colors.js +24 -0
  397. package/dist/src/ui/semantic-colors.js.map +1 -0
  398. package/dist/src/ui/themes/ansi-light.js +4 -1
  399. package/dist/src/ui/themes/ansi-light.js.map +1 -1
  400. package/dist/src/ui/themes/ansi.js +4 -1
  401. package/dist/src/ui/themes/ansi.js.map +1 -1
  402. package/dist/src/ui/themes/atom-one-dark.js +4 -1
  403. package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
  404. package/dist/src/ui/themes/ayu-light.js +5 -2
  405. package/dist/src/ui/themes/ayu-light.js.map +1 -1
  406. package/dist/src/ui/themes/ayu.js +5 -2
  407. package/dist/src/ui/themes/ayu.js.map +1 -1
  408. package/dist/src/ui/themes/color-utils.test.d.ts +6 -0
  409. package/dist/src/ui/themes/color-utils.test.js +197 -0
  410. package/dist/src/ui/themes/color-utils.test.js.map +1 -0
  411. package/dist/src/ui/themes/default-light.js +2 -1
  412. package/dist/src/ui/themes/default-light.js.map +1 -1
  413. package/dist/src/ui/themes/default.js +2 -1
  414. package/dist/src/ui/themes/default.js.map +1 -1
  415. package/dist/src/ui/themes/dracula.js +4 -1
  416. package/dist/src/ui/themes/dracula.js.map +1 -1
  417. package/dist/src/ui/themes/github-dark.js +4 -1
  418. package/dist/src/ui/themes/github-dark.js.map +1 -1
  419. package/dist/src/ui/themes/github-light.js +4 -1
  420. package/dist/src/ui/themes/github-light.js.map +1 -1
  421. package/dist/src/ui/themes/googlecode.js +4 -1
  422. package/dist/src/ui/themes/googlecode.js.map +1 -1
  423. package/dist/src/ui/themes/no-color.js +32 -1
  424. package/dist/src/ui/themes/no-color.js.map +1 -1
  425. package/dist/src/ui/themes/semantic-tokens.d.ts +37 -0
  426. package/dist/src/ui/themes/semantic-tokens.js +94 -0
  427. package/dist/src/ui/themes/semantic-tokens.js.map +1 -0
  428. package/dist/src/ui/themes/shades-of-purple.js +4 -1
  429. package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
  430. package/dist/src/ui/themes/theme-manager.d.ts +6 -0
  431. package/dist/src/ui/themes/theme-manager.js +18 -2
  432. package/dist/src/ui/themes/theme-manager.js.map +1 -1
  433. package/dist/src/ui/themes/theme-manager.test.d.ts +6 -0
  434. package/dist/src/ui/themes/theme-manager.test.js +83 -0
  435. package/dist/src/ui/themes/theme-manager.test.js.map +1 -0
  436. package/dist/src/ui/themes/theme.d.ts +48 -2
  437. package/dist/src/ui/themes/theme.js +102 -92
  438. package/dist/src/ui/themes/theme.js.map +1 -1
  439. package/dist/src/ui/themes/xcode.js +4 -1
  440. package/dist/src/ui/themes/xcode.js.map +1 -1
  441. package/dist/src/ui/types.d.ts +13 -2
  442. package/dist/src/ui/types.js +1 -0
  443. package/dist/src/ui/types.js.map +1 -1
  444. package/dist/src/ui/utils/CodeColorizer.d.ts +3 -1
  445. package/dist/src/ui/utils/CodeColorizer.js +22 -9
  446. package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
  447. package/dist/src/ui/utils/ConsolePatcher.d.ts +3 -1
  448. package/dist/src/ui/utils/ConsolePatcher.js +18 -8
  449. package/dist/src/ui/utils/ConsolePatcher.js.map +1 -1
  450. package/dist/src/ui/utils/InlineMarkdownRenderer.js +8 -1
  451. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
  452. package/dist/src/ui/utils/MarkdownDisplay.js +4 -2
  453. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
  454. package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
  455. package/dist/src/ui/utils/MarkdownDisplay.test.js +151 -0
  456. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
  457. package/dist/src/ui/utils/clipboardUtils.test.d.ts +6 -0
  458. package/dist/src/ui/utils/clipboardUtils.test.js +65 -0
  459. package/dist/src/ui/utils/clipboardUtils.test.js.map +1 -0
  460. package/dist/src/ui/utils/commandUtils.d.ts +1 -0
  461. package/dist/src/ui/utils/commandUtils.js +22 -1
  462. package/dist/src/ui/utils/commandUtils.js.map +1 -1
  463. package/dist/src/ui/utils/commandUtils.test.d.ts +6 -0
  464. package/dist/src/ui/utils/commandUtils.test.js +294 -0
  465. package/dist/src/ui/utils/commandUtils.test.js.map +1 -0
  466. package/dist/src/ui/utils/computeStats.js +3 -1
  467. package/dist/src/ui/utils/computeStats.js.map +1 -1
  468. package/dist/src/ui/utils/displayUtils.test.d.ts +6 -0
  469. package/dist/src/ui/utils/displayUtils.test.js +42 -0
  470. package/dist/src/ui/utils/displayUtils.test.js.map +1 -0
  471. package/dist/src/ui/utils/formatters.test.d.ts +6 -0
  472. package/dist/src/ui/utils/formatters.test.js +56 -0
  473. package/dist/src/ui/utils/formatters.test.js.map +1 -0
  474. package/dist/src/ui/utils/isNarrowWidth.d.ts +6 -0
  475. package/dist/src/ui/utils/isNarrowWidth.js +9 -0
  476. package/dist/src/ui/utils/isNarrowWidth.js.map +1 -0
  477. package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
  478. package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
  479. package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
  480. package/dist/src/ui/utils/markdownUtilities.test.d.ts +6 -0
  481. package/dist/src/ui/utils/markdownUtilities.test.js +42 -0
  482. package/dist/src/ui/utils/markdownUtilities.test.js.map +1 -0
  483. package/dist/src/ui/utils/platformConstants.d.ts +43 -0
  484. package/dist/src/ui/utils/platformConstants.js +44 -0
  485. package/dist/src/ui/utils/platformConstants.js.map +1 -0
  486. package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
  487. package/dist/src/ui/utils/terminalSetup.js +281 -0
  488. package/dist/src/ui/utils/terminalSetup.js.map +1 -0
  489. package/dist/src/ui/utils/textUtils.d.ts +0 -8
  490. package/dist/src/ui/utils/textUtils.js +0 -22
  491. package/dist/src/ui/utils/textUtils.js.map +1 -1
  492. package/dist/src/ui/utils/updateCheck.d.ts +7 -1
  493. package/dist/src/ui/utils/updateCheck.js +47 -9
  494. package/dist/src/ui/utils/updateCheck.js.map +1 -1
  495. package/dist/src/ui/utils/updateCheck.test.d.ts +6 -0
  496. package/dist/src/ui/utils/updateCheck.test.js +145 -0
  497. package/dist/src/ui/utils/updateCheck.test.js.map +1 -0
  498. package/dist/src/utils/checks.d.ts +19 -0
  499. package/dist/src/utils/checks.js +24 -0
  500. package/dist/src/utils/checks.js.map +1 -0
  501. package/dist/src/utils/cleanup.d.ts +2 -2
  502. package/dist/src/utils/cleanup.js +2 -2
  503. package/dist/src/utils/cleanup.js.map +1 -1
  504. package/dist/src/utils/dialogScopeUtils.d.ts +31 -0
  505. package/dist/src/utils/dialogScopeUtils.js +48 -0
  506. package/dist/src/utils/dialogScopeUtils.js.map +1 -0
  507. package/dist/src/utils/events.d.ts +11 -0
  508. package/dist/src/utils/events.js +13 -0
  509. package/dist/src/utils/events.js.map +1 -0
  510. package/dist/src/utils/gitUtils.d.ts +30 -0
  511. package/dist/src/utils/gitUtils.js +89 -0
  512. package/dist/src/utils/gitUtils.js.map +1 -0
  513. package/dist/src/utils/gitUtils.test.d.ts +6 -0
  514. package/dist/src/utils/gitUtils.test.js +113 -0
  515. package/dist/src/utils/gitUtils.test.js.map +1 -0
  516. package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
  517. package/dist/src/utils/handleAutoUpdate.js +101 -0
  518. package/dist/src/utils/handleAutoUpdate.js.map +1 -0
  519. package/dist/src/utils/installationInfo.d.ts +23 -0
  520. package/dist/src/utils/installationInfo.js +154 -0
  521. package/dist/src/utils/installationInfo.js.map +1 -0
  522. package/dist/src/utils/installationInfo.test.d.ts +6 -0
  523. package/dist/src/utils/installationInfo.test.js +242 -0
  524. package/dist/src/utils/installationInfo.test.js.map +1 -0
  525. package/dist/src/utils/readStdin.js +10 -0
  526. package/dist/src/utils/readStdin.js.map +1 -1
  527. package/dist/src/utils/resolvePath.d.ts +6 -0
  528. package/dist/src/utils/resolvePath.js +21 -0
  529. package/dist/src/utils/resolvePath.js.map +1 -0
  530. package/dist/src/utils/sandbox-macos-permissive-closed.sb +6 -0
  531. package/dist/src/utils/sandbox-macos-permissive-open.sb +6 -0
  532. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +6 -0
  533. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +6 -0
  534. package/dist/src/utils/sandbox-macos-restrictive-open.sb +6 -0
  535. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +6 -0
  536. package/dist/src/utils/sandbox.d.ts +2 -2
  537. package/dist/src/utils/sandbox.js +448 -397
  538. package/dist/src/utils/sandbox.js.map +1 -1
  539. package/dist/src/utils/settingsUtils.d.ts +134 -0
  540. package/dist/src/utils/settingsUtils.js +336 -0
  541. package/dist/src/utils/settingsUtils.js.map +1 -0
  542. package/dist/src/utils/settingsUtils.test.d.ts +6 -0
  543. package/dist/src/utils/settingsUtils.test.js +514 -0
  544. package/dist/src/utils/settingsUtils.test.js.map +1 -0
  545. package/dist/src/utils/spawnWrapper.d.ts +7 -0
  546. package/dist/src/utils/spawnWrapper.js +8 -0
  547. package/dist/src/utils/spawnWrapper.js.map +1 -0
  548. package/dist/src/utils/updateEventEmitter.d.ts +11 -0
  549. package/dist/src/utils/updateEventEmitter.js +12 -0
  550. package/dist/src/utils/updateEventEmitter.js.map +1 -0
  551. package/dist/src/utils/userStartupWarnings.test.d.ts +6 -0
  552. package/dist/src/utils/userStartupWarnings.test.js +67 -0
  553. package/dist/src/utils/userStartupWarnings.test.js.map +1 -0
  554. package/dist/src/utils/version.js +1 -1
  555. package/dist/src/utils/version.js.map +1 -1
  556. package/dist/src/validateNonInterActiveAuth.d.ts +7 -0
  557. package/dist/src/validateNonInterActiveAuth.js +37 -0
  558. package/dist/src/validateNonInterActiveAuth.js.map +1 -0
  559. package/dist/src/zed-integration/acp.d.ts +63 -0
  560. package/dist/src/{acp → zed-integration}/acp.js +76 -44
  561. package/dist/src/zed-integration/acp.js.map +1 -0
  562. package/dist/src/zed-integration/fileSystemService.d.ts +19 -0
  563. package/dist/src/zed-integration/fileSystemService.js +43 -0
  564. package/dist/src/zed-integration/fileSystemService.js.map +1 -0
  565. package/dist/src/zed-integration/schema.d.ts +11679 -0
  566. package/dist/src/zed-integration/schema.js +305 -0
  567. package/dist/src/zed-integration/schema.js.map +1 -0
  568. package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
  569. package/dist/src/{acp/acpPeer.js → zed-integration/zedIntegration.js} +336 -169
  570. package/dist/src/zed-integration/zedIntegration.js.map +1 -0
  571. package/dist/tsconfig.tsbuildinfo +1 -1
  572. package/package.json +13 -8
  573. package/dist/src/acp/acp.d.ts +0 -208
  574. package/dist/src/acp/acp.js.map +0 -1
  575. package/dist/src/acp/acpPeer.d.ts +0 -8
  576. package/dist/src/acp/acpPeer.js.map +0 -1
  577. package/dist/src/ui/utils/errorParsing.d.ts +0 -7
  578. package/dist/src/ui/utils/errorParsing.js +0 -90
  579. package/dist/src/ui/utils/errorParsing.js.map +0 -1
@@ -0,0 +1,846 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /* eslint-disable @typescript-eslint/no-explicit-any */
7
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
8
+ import { renderHook, act } from '@testing-library/react';
9
+ import { useReactToolScheduler, mapToDisplay, } from './useReactToolScheduler.js';
10
+ import { ToolConfirmationOutcome, ApprovalMode, Kind, BaseDeclarativeTool, BaseToolInvocation, } from '@machina.ai/cell-cli-core';
11
+ import { ToolCallStatus, } from '../types.js';
12
+ // Mocks
13
+ vi.mock('@machina.ai/cell-cli-core', async () => {
14
+ const actual = await vi.importActual('@machina.ai/cell-cli-core');
15
+ return {
16
+ ...actual,
17
+ ToolRegistry: vi.fn(),
18
+ Config: vi.fn(),
19
+ };
20
+ });
21
+ const mockToolRegistry = {
22
+ getTool: vi.fn(),
23
+ };
24
+ const mockConfig = {
25
+ getToolRegistry: vi.fn(() => mockToolRegistry),
26
+ getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
27
+ getUsageStatisticsEnabled: () => true,
28
+ getDebugMode: () => false,
29
+ getSessionId: () => 'test-session-id',
30
+ getContentGeneratorConfig: () => ({
31
+ model: 'test-model',
32
+ authType: 'oauth-personal',
33
+ }),
34
+ };
35
+ class MockToolInvocation extends BaseToolInvocation {
36
+ tool;
37
+ constructor(tool, params) {
38
+ super(params);
39
+ this.tool = tool;
40
+ }
41
+ getDescription() {
42
+ return JSON.stringify(this.params);
43
+ }
44
+ shouldConfirmExecute(abortSignal) {
45
+ return this.tool.shouldConfirmExecute(this.params, abortSignal);
46
+ }
47
+ execute(signal, updateOutput, terminalColumns, terminalRows) {
48
+ return this.tool.execute(this.params, signal, updateOutput, terminalColumns, terminalRows);
49
+ }
50
+ }
51
+ class MockTool extends BaseDeclarativeTool {
52
+ constructor(name, displayName, canUpdateOutput = false, shouldConfirm = false, isOutputMarkdown = false) {
53
+ super(name, displayName, 'A mock tool for testing', Kind.Other, {}, isOutputMarkdown, canUpdateOutput);
54
+ if (shouldConfirm) {
55
+ this.shouldConfirmExecute.mockImplementation(async () => ({
56
+ type: 'edit',
57
+ title: 'Mock Tool Requires Confirmation',
58
+ onConfirm: mockOnUserConfirmForToolConfirmation,
59
+ filePath: 'mock',
60
+ fileName: 'mockToolRequiresConfirmation.ts',
61
+ fileDiff: 'Mock tool requires confirmation',
62
+ originalContent: 'Original content',
63
+ newContent: 'New content',
64
+ }));
65
+ }
66
+ }
67
+ execute = vi.fn();
68
+ shouldConfirmExecute = vi.fn();
69
+ createInvocation(params) {
70
+ return new MockToolInvocation(this, params);
71
+ }
72
+ }
73
+ const mockTool = new MockTool('mockTool', 'Mock Tool');
74
+ const mockToolWithLiveOutput = new MockTool('mockToolWithLiveOutput', 'Mock Tool With Live Output', true);
75
+ let mockOnUserConfirmForToolConfirmation;
76
+ const mockToolRequiresConfirmation = new MockTool('mockToolRequiresConfirmation', 'Mock Tool Requires Confirmation', false, true);
77
+ describe('useReactToolScheduler in YOLO Mode', () => {
78
+ let onComplete;
79
+ let setPendingHistoryItem;
80
+ beforeEach(() => {
81
+ onComplete = vi.fn();
82
+ setPendingHistoryItem = vi.fn();
83
+ mockToolRegistry.getTool.mockClear();
84
+ mockToolRequiresConfirmation.execute.mockClear();
85
+ mockToolRequiresConfirmation.shouldConfirmExecute.mockClear();
86
+ // IMPORTANT: Enable YOLO mode for this test suite
87
+ mockConfig.getApprovalMode.mockReturnValue(ApprovalMode.YOLO);
88
+ vi.useFakeTimers();
89
+ });
90
+ afterEach(() => {
91
+ vi.clearAllTimers();
92
+ vi.useRealTimers();
93
+ // IMPORTANT: Disable YOLO mode after this test suite
94
+ mockConfig.getApprovalMode.mockReturnValue(ApprovalMode.DEFAULT);
95
+ });
96
+ const renderSchedulerInYoloMode = () => renderHook(() => useReactToolScheduler(onComplete, mockConfig, setPendingHistoryItem, () => undefined, () => { }));
97
+ it('should skip confirmation and execute tool directly when yoloMode is true', async () => {
98
+ mockToolRegistry.getTool.mockReturnValue(mockToolRequiresConfirmation);
99
+ const expectedOutput = 'YOLO Confirmed output';
100
+ mockToolRequiresConfirmation.execute.mockResolvedValue({
101
+ llmContent: expectedOutput,
102
+ returnDisplay: 'YOLO Formatted tool output',
103
+ summary: 'YOLO summary',
104
+ });
105
+ const { result } = renderSchedulerInYoloMode();
106
+ const schedule = result.current[1];
107
+ const request = {
108
+ callId: 'yoloCall',
109
+ name: 'mockToolRequiresConfirmation',
110
+ args: { data: 'any data' },
111
+ };
112
+ act(() => {
113
+ schedule(request, new AbortController().signal);
114
+ });
115
+ await act(async () => {
116
+ await vi.runAllTimersAsync(); // Process validation
117
+ });
118
+ await act(async () => {
119
+ await vi.runAllTimersAsync(); // Process scheduling
120
+ });
121
+ await act(async () => {
122
+ await vi.runAllTimersAsync(); // Process execution
123
+ });
124
+ // Check that shouldConfirmExecute was NOT called
125
+ expect(mockToolRequiresConfirmation.shouldConfirmExecute).not.toHaveBeenCalled();
126
+ // Check that execute WAS called
127
+ expect(mockToolRequiresConfirmation.execute).toHaveBeenCalledWith(request.args, expect.any(AbortSignal), undefined, undefined, undefined);
128
+ // Check that onComplete was called with success
129
+ expect(onComplete).toHaveBeenCalledWith([
130
+ expect.objectContaining({
131
+ status: 'success',
132
+ request,
133
+ response: expect.objectContaining({
134
+ resultDisplay: 'YOLO Formatted tool output',
135
+ responseParts: {
136
+ functionResponse: {
137
+ id: 'yoloCall',
138
+ name: 'mockToolRequiresConfirmation',
139
+ response: { output: expectedOutput },
140
+ },
141
+ },
142
+ }),
143
+ }),
144
+ ]);
145
+ // Ensure no confirmation UI was triggered (setPendingHistoryItem should not have been called with confirmation details)
146
+ const setPendingHistoryItemCalls = setPendingHistoryItem.mock.calls;
147
+ const confirmationCall = setPendingHistoryItemCalls.find((call) => {
148
+ const item = typeof call[0] === 'function' ? call[0]({}) : call[0];
149
+ return item?.tools?.[0]?.confirmationDetails;
150
+ });
151
+ expect(confirmationCall).toBeUndefined();
152
+ });
153
+ });
154
+ describe('useReactToolScheduler', () => {
155
+ // TODO(ntaylormullen): The following tests are skipped due to difficulties in
156
+ // reliably testing the asynchronous state updates and interactions with timers.
157
+ // These tests involve complex sequences of events, including confirmations,
158
+ // live output updates, and cancellations, which are challenging to assert
159
+ // correctly with the current testing setup. Further investigation is needed
160
+ // to find a robust way to test these scenarios.
161
+ let onComplete;
162
+ let setPendingHistoryItem;
163
+ let capturedOnConfirmForTest;
164
+ beforeEach(() => {
165
+ onComplete = vi.fn();
166
+ capturedOnConfirmForTest = undefined;
167
+ setPendingHistoryItem = vi.fn((updaterOrValue) => {
168
+ let pendingItem = null;
169
+ if (typeof updaterOrValue === 'function') {
170
+ // Loosen the type for prevState to allow for more flexible updates in tests
171
+ const prevState = {
172
+ type: 'tool_group', // Still default to tool_group for most cases
173
+ tools: [],
174
+ };
175
+ pendingItem = updaterOrValue(prevState); // Allow any for more flexibility
176
+ }
177
+ else {
178
+ pendingItem = updaterOrValue;
179
+ }
180
+ // Capture onConfirm if it exists, regardless of the exact type of pendingItem
181
+ // This is a common pattern in these tests.
182
+ if (pendingItem?.tools?.[0]?.confirmationDetails
183
+ ?.onConfirm) {
184
+ capturedOnConfirmForTest = pendingItem
185
+ .tools[0].confirmationDetails?.onConfirm;
186
+ }
187
+ });
188
+ mockToolRegistry.getTool.mockClear();
189
+ mockTool.execute.mockClear();
190
+ mockTool.shouldConfirmExecute.mockClear();
191
+ mockToolWithLiveOutput.execute.mockClear();
192
+ mockToolWithLiveOutput.shouldConfirmExecute.mockClear();
193
+ mockToolRequiresConfirmation.execute.mockClear();
194
+ mockToolRequiresConfirmation.shouldConfirmExecute.mockClear();
195
+ mockOnUserConfirmForToolConfirmation = vi.fn();
196
+ mockToolRequiresConfirmation.shouldConfirmExecute.mockImplementation(async () => ({
197
+ onConfirm: mockOnUserConfirmForToolConfirmation,
198
+ fileName: 'mockToolRequiresConfirmation.ts',
199
+ fileDiff: 'Mock tool requires confirmation',
200
+ type: 'edit',
201
+ title: 'Mock Tool Requires Confirmation',
202
+ }));
203
+ vi.useFakeTimers();
204
+ });
205
+ afterEach(() => {
206
+ vi.clearAllTimers();
207
+ vi.useRealTimers();
208
+ });
209
+ const renderScheduler = () => renderHook(() => useReactToolScheduler(onComplete, mockConfig, setPendingHistoryItem, () => undefined, () => { }));
210
+ it('initial state should be empty', () => {
211
+ const { result } = renderScheduler();
212
+ expect(result.current[0]).toEqual([]);
213
+ });
214
+ it('should schedule and execute a tool call successfully', async () => {
215
+ mockToolRegistry.getTool.mockReturnValue(mockTool);
216
+ mockTool.execute.mockResolvedValue({
217
+ llmContent: 'Tool output',
218
+ returnDisplay: 'Formatted tool output',
219
+ summary: 'Formatted summary',
220
+ });
221
+ mockTool.shouldConfirmExecute.mockResolvedValue(null);
222
+ const { result } = renderScheduler();
223
+ const schedule = result.current[1];
224
+ const request = {
225
+ callId: 'call1',
226
+ name: 'mockTool',
227
+ args: { param: 'value' },
228
+ };
229
+ act(() => {
230
+ schedule(request, new AbortController().signal);
231
+ });
232
+ await act(async () => {
233
+ await vi.runAllTimersAsync();
234
+ });
235
+ await act(async () => {
236
+ await vi.runAllTimersAsync();
237
+ });
238
+ await act(async () => {
239
+ await vi.runAllTimersAsync();
240
+ });
241
+ expect(mockTool.execute).toHaveBeenCalledWith(request.args, expect.any(AbortSignal), undefined, undefined, undefined);
242
+ expect(onComplete).toHaveBeenCalledWith([
243
+ expect.objectContaining({
244
+ status: 'success',
245
+ request,
246
+ response: expect.objectContaining({
247
+ resultDisplay: 'Formatted tool output',
248
+ responseParts: {
249
+ functionResponse: {
250
+ id: 'call1',
251
+ name: 'mockTool',
252
+ response: { output: 'Tool output' },
253
+ },
254
+ },
255
+ }),
256
+ }),
257
+ ]);
258
+ expect(result.current[0]).toEqual([]);
259
+ });
260
+ it('should handle tool not found', async () => {
261
+ mockToolRegistry.getTool.mockReturnValue(undefined);
262
+ const { result } = renderScheduler();
263
+ const schedule = result.current[1];
264
+ const request = {
265
+ callId: 'call1',
266
+ name: 'nonexistentTool',
267
+ args: {},
268
+ };
269
+ act(() => {
270
+ schedule(request, new AbortController().signal);
271
+ });
272
+ await act(async () => {
273
+ await vi.runAllTimersAsync();
274
+ });
275
+ await act(async () => {
276
+ await vi.runAllTimersAsync();
277
+ });
278
+ expect(onComplete).toHaveBeenCalledWith([
279
+ expect.objectContaining({
280
+ status: 'error',
281
+ request,
282
+ response: expect.objectContaining({
283
+ error: expect.objectContaining({
284
+ message: 'Tool "nonexistentTool" not found in registry.',
285
+ }),
286
+ }),
287
+ }),
288
+ ]);
289
+ expect(result.current[0]).toEqual([]);
290
+ });
291
+ it('should handle error during shouldConfirmExecute', async () => {
292
+ mockToolRegistry.getTool.mockReturnValue(mockTool);
293
+ const confirmError = new Error('Confirmation check failed');
294
+ mockTool.shouldConfirmExecute.mockRejectedValue(confirmError);
295
+ const { result } = renderScheduler();
296
+ const schedule = result.current[1];
297
+ const request = {
298
+ callId: 'call1',
299
+ name: 'mockTool',
300
+ args: {},
301
+ };
302
+ act(() => {
303
+ schedule(request, new AbortController().signal);
304
+ });
305
+ await act(async () => {
306
+ await vi.runAllTimersAsync();
307
+ });
308
+ await act(async () => {
309
+ await vi.runAllTimersAsync();
310
+ });
311
+ expect(onComplete).toHaveBeenCalledWith([
312
+ expect.objectContaining({
313
+ status: 'error',
314
+ request,
315
+ response: expect.objectContaining({
316
+ error: confirmError,
317
+ }),
318
+ }),
319
+ ]);
320
+ expect(result.current[0]).toEqual([]);
321
+ });
322
+ it('should handle error during execute', async () => {
323
+ mockToolRegistry.getTool.mockReturnValue(mockTool);
324
+ mockTool.shouldConfirmExecute.mockResolvedValue(null);
325
+ const execError = new Error('Execution failed');
326
+ mockTool.execute.mockRejectedValue(execError);
327
+ const { result } = renderScheduler();
328
+ const schedule = result.current[1];
329
+ const request = {
330
+ callId: 'call1',
331
+ name: 'mockTool',
332
+ args: {},
333
+ };
334
+ act(() => {
335
+ schedule(request, new AbortController().signal);
336
+ });
337
+ await act(async () => {
338
+ await vi.runAllTimersAsync();
339
+ });
340
+ await act(async () => {
341
+ await vi.runAllTimersAsync();
342
+ });
343
+ await act(async () => {
344
+ await vi.runAllTimersAsync();
345
+ });
346
+ expect(onComplete).toHaveBeenCalledWith([
347
+ expect.objectContaining({
348
+ status: 'error',
349
+ request,
350
+ response: expect.objectContaining({
351
+ error: execError,
352
+ }),
353
+ }),
354
+ ]);
355
+ expect(result.current[0]).toEqual([]);
356
+ });
357
+ it.skip('should handle tool requiring confirmation - approved', async () => {
358
+ mockToolRegistry.getTool.mockReturnValue(mockToolRequiresConfirmation);
359
+ const expectedOutput = 'Confirmed output';
360
+ mockToolRequiresConfirmation.execute.mockResolvedValue({
361
+ llmContent: expectedOutput,
362
+ returnDisplay: 'Confirmed display',
363
+ summary: 'Confirmed summary',
364
+ });
365
+ const { result } = renderScheduler();
366
+ const schedule = result.current[1];
367
+ const request = {
368
+ callId: 'callConfirm',
369
+ name: 'mockToolRequiresConfirmation',
370
+ args: { data: 'sensitive' },
371
+ };
372
+ act(() => {
373
+ schedule(request, new AbortController().signal);
374
+ });
375
+ await act(async () => {
376
+ await vi.runAllTimersAsync();
377
+ });
378
+ expect(setPendingHistoryItem).toHaveBeenCalled();
379
+ expect(capturedOnConfirmForTest).toBeDefined();
380
+ await act(async () => {
381
+ await capturedOnConfirmForTest?.(ToolConfirmationOutcome.ProceedOnce);
382
+ });
383
+ await act(async () => {
384
+ await vi.runAllTimersAsync();
385
+ });
386
+ await act(async () => {
387
+ await vi.runAllTimersAsync();
388
+ });
389
+ await act(async () => {
390
+ await vi.runAllTimersAsync();
391
+ });
392
+ expect(mockOnUserConfirmForToolConfirmation).toHaveBeenCalledWith(ToolConfirmationOutcome.ProceedOnce);
393
+ expect(mockToolRequiresConfirmation.execute).toHaveBeenCalled();
394
+ expect(onComplete).toHaveBeenCalledWith([
395
+ expect.objectContaining({
396
+ status: 'success',
397
+ request,
398
+ response: expect.objectContaining({
399
+ resultDisplay: 'Confirmed display',
400
+ responseParts: expect.arrayContaining([
401
+ expect.objectContaining({
402
+ functionResponse: expect.objectContaining({
403
+ response: { output: expectedOutput },
404
+ }),
405
+ }),
406
+ ]),
407
+ }),
408
+ }),
409
+ ]);
410
+ });
411
+ it.skip('should handle tool requiring confirmation - cancelled by user', async () => {
412
+ mockToolRegistry.getTool.mockReturnValue(mockToolRequiresConfirmation);
413
+ const { result } = renderScheduler();
414
+ const schedule = result.current[1];
415
+ const request = {
416
+ callId: 'callConfirmCancel',
417
+ name: 'mockToolRequiresConfirmation',
418
+ args: {},
419
+ };
420
+ act(() => {
421
+ schedule(request, new AbortController().signal);
422
+ });
423
+ await act(async () => {
424
+ await vi.runAllTimersAsync();
425
+ });
426
+ expect(setPendingHistoryItem).toHaveBeenCalled();
427
+ expect(capturedOnConfirmForTest).toBeDefined();
428
+ await act(async () => {
429
+ await capturedOnConfirmForTest?.(ToolConfirmationOutcome.Cancel);
430
+ });
431
+ await act(async () => {
432
+ await vi.runAllTimersAsync();
433
+ });
434
+ await act(async () => {
435
+ await vi.runAllTimersAsync();
436
+ });
437
+ expect(mockOnUserConfirmForToolConfirmation).toHaveBeenCalledWith(ToolConfirmationOutcome.Cancel);
438
+ expect(onComplete).toHaveBeenCalledWith([
439
+ expect.objectContaining({
440
+ status: 'cancelled',
441
+ request,
442
+ response: expect.objectContaining({
443
+ responseParts: expect.arrayContaining([
444
+ expect.objectContaining({
445
+ functionResponse: expect.objectContaining({
446
+ response: expect.objectContaining({
447
+ error: `User did not allow tool call ${request.name}. Reason: User cancelled.`,
448
+ }),
449
+ }),
450
+ }),
451
+ ]),
452
+ }),
453
+ }),
454
+ ]);
455
+ });
456
+ it.skip('should handle live output updates', async () => {
457
+ mockToolRegistry.getTool.mockReturnValue(mockToolWithLiveOutput);
458
+ let liveUpdateFn;
459
+ let resolveExecutePromise;
460
+ const executePromise = new Promise((resolve) => {
461
+ resolveExecutePromise = resolve;
462
+ });
463
+ mockToolWithLiveOutput.execute.mockImplementation(async (_args, _signal, updateFn) => {
464
+ liveUpdateFn = updateFn;
465
+ return executePromise;
466
+ });
467
+ mockToolWithLiveOutput.shouldConfirmExecute.mockResolvedValue(null);
468
+ const { result } = renderScheduler();
469
+ const schedule = result.current[1];
470
+ const request = {
471
+ callId: 'liveCall',
472
+ name: 'mockToolWithLiveOutput',
473
+ args: {},
474
+ };
475
+ act(() => {
476
+ schedule(request, new AbortController().signal);
477
+ });
478
+ await act(async () => {
479
+ await vi.runAllTimersAsync();
480
+ });
481
+ expect(liveUpdateFn).toBeDefined();
482
+ expect(setPendingHistoryItem).toHaveBeenCalled();
483
+ await act(async () => {
484
+ liveUpdateFn?.('Live output 1');
485
+ });
486
+ await act(async () => {
487
+ await vi.runAllTimersAsync();
488
+ });
489
+ await act(async () => {
490
+ liveUpdateFn?.('Live output 2');
491
+ });
492
+ await act(async () => {
493
+ await vi.runAllTimersAsync();
494
+ });
495
+ act(() => {
496
+ resolveExecutePromise({
497
+ llmContent: 'Final output',
498
+ returnDisplay: 'Final display',
499
+ summary: 'Final summary',
500
+ });
501
+ });
502
+ await act(async () => {
503
+ await vi.runAllTimersAsync();
504
+ });
505
+ await act(async () => {
506
+ await vi.runAllTimersAsync();
507
+ });
508
+ expect(onComplete).toHaveBeenCalledWith([
509
+ expect.objectContaining({
510
+ status: 'success',
511
+ request,
512
+ response: expect.objectContaining({
513
+ resultDisplay: 'Final display',
514
+ responseParts: expect.arrayContaining([
515
+ expect.objectContaining({
516
+ functionResponse: expect.objectContaining({
517
+ response: { output: 'Final output' },
518
+ }),
519
+ }),
520
+ ]),
521
+ }),
522
+ }),
523
+ ]);
524
+ expect(result.current[0]).toEqual([]);
525
+ });
526
+ it('should schedule and execute multiple tool calls', async () => {
527
+ const tool1 = new MockTool('tool1', 'Tool 1');
528
+ tool1.execute.mockResolvedValue({
529
+ llmContent: 'Output 1',
530
+ returnDisplay: 'Display 1',
531
+ summary: 'Summary 1',
532
+ });
533
+ tool1.shouldConfirmExecute.mockResolvedValue(null);
534
+ const tool2 = new MockTool('tool2', 'Tool 2');
535
+ tool2.execute.mockResolvedValue({
536
+ llmContent: 'Output 2',
537
+ returnDisplay: 'Display 2',
538
+ summary: 'Summary 2',
539
+ });
540
+ tool2.shouldConfirmExecute.mockResolvedValue(null);
541
+ mockToolRegistry.getTool.mockImplementation((name) => {
542
+ if (name === 'tool1')
543
+ return tool1;
544
+ if (name === 'tool2')
545
+ return tool2;
546
+ return undefined;
547
+ });
548
+ const { result } = renderScheduler();
549
+ const schedule = result.current[1];
550
+ const requests = [
551
+ { callId: 'multi1', name: 'tool1', args: { p: 1 } },
552
+ { callId: 'multi2', name: 'tool2', args: { p: 2 } },
553
+ ];
554
+ act(() => {
555
+ schedule(requests, new AbortController().signal);
556
+ });
557
+ await act(async () => {
558
+ await vi.runAllTimersAsync();
559
+ });
560
+ await act(async () => {
561
+ await vi.runAllTimersAsync();
562
+ });
563
+ await act(async () => {
564
+ await vi.runAllTimersAsync();
565
+ });
566
+ await act(async () => {
567
+ await vi.runAllTimersAsync();
568
+ });
569
+ expect(onComplete).toHaveBeenCalledTimes(1);
570
+ const completedCalls = onComplete.mock.calls[0][0];
571
+ expect(completedCalls.length).toBe(2);
572
+ const call1Result = completedCalls.find((c) => c.request.callId === 'multi1');
573
+ const call2Result = completedCalls.find((c) => c.request.callId === 'multi2');
574
+ expect(call1Result).toMatchObject({
575
+ status: 'success',
576
+ request: requests[0],
577
+ response: expect.objectContaining({
578
+ resultDisplay: 'Display 1',
579
+ responseParts: {
580
+ functionResponse: {
581
+ id: 'multi1',
582
+ name: 'tool1',
583
+ response: { output: 'Output 1' },
584
+ },
585
+ },
586
+ }),
587
+ });
588
+ expect(call2Result).toMatchObject({
589
+ status: 'success',
590
+ request: requests[1],
591
+ response: expect.objectContaining({
592
+ resultDisplay: 'Display 2',
593
+ responseParts: {
594
+ functionResponse: {
595
+ id: 'multi2',
596
+ name: 'tool2',
597
+ response: { output: 'Output 2' },
598
+ },
599
+ },
600
+ }),
601
+ });
602
+ expect(result.current[0]).toEqual([]);
603
+ });
604
+ it.skip('should throw error if scheduling while already running', async () => {
605
+ mockToolRegistry.getTool.mockReturnValue(mockTool);
606
+ const longExecutePromise = new Promise((resolve) => setTimeout(() => resolve({
607
+ llmContent: 'done',
608
+ returnDisplay: 'done display',
609
+ summary: 'done summary',
610
+ }), 50));
611
+ mockTool.execute.mockReturnValue(longExecutePromise);
612
+ mockTool.shouldConfirmExecute.mockResolvedValue(null);
613
+ const { result } = renderScheduler();
614
+ const schedule = result.current[1];
615
+ const request1 = {
616
+ callId: 'run1',
617
+ name: 'mockTool',
618
+ args: {},
619
+ };
620
+ const request2 = {
621
+ callId: 'run2',
622
+ name: 'mockTool',
623
+ args: {},
624
+ };
625
+ act(() => {
626
+ schedule(request1, new AbortController().signal);
627
+ });
628
+ await act(async () => {
629
+ await vi.runAllTimersAsync();
630
+ });
631
+ expect(() => schedule(request2, new AbortController().signal)).toThrow('Cannot schedule tool calls while other tool calls are running');
632
+ await act(async () => {
633
+ await vi.advanceTimersByTimeAsync(50);
634
+ await vi.runAllTimersAsync();
635
+ await act(async () => {
636
+ await vi.runAllTimersAsync();
637
+ });
638
+ });
639
+ expect(onComplete).toHaveBeenCalledWith([
640
+ expect.objectContaining({
641
+ status: 'success',
642
+ request: request1,
643
+ response: expect.objectContaining({ resultDisplay: 'done display' }),
644
+ }),
645
+ ]);
646
+ expect(result.current[0]).toEqual([]);
647
+ });
648
+ });
649
+ describe('mapToDisplay', () => {
650
+ const baseRequest = {
651
+ callId: 'testCallId',
652
+ name: 'testTool',
653
+ args: { foo: 'bar' },
654
+ };
655
+ const baseTool = new MockTool('testTool', 'Test Tool Display');
656
+ const baseResponse = {
657
+ callId: 'testCallId',
658
+ responseParts: [
659
+ {
660
+ functionResponse: {
661
+ name: 'testTool',
662
+ id: 'testCallId',
663
+ response: { output: 'Test output' },
664
+ },
665
+ },
666
+ ],
667
+ resultDisplay: 'Test display output',
668
+ error: undefined,
669
+ };
670
+ const baseInvocation = baseTool.build(baseRequest.args);
671
+ const testCases = [
672
+ {
673
+ name: 'validating',
674
+ status: 'validating',
675
+ extraProps: { tool: baseTool, invocation: baseInvocation },
676
+ expectedStatus: ToolCallStatus.Executing,
677
+ expectedName: baseTool.displayName,
678
+ expectedDescription: baseInvocation.getDescription(),
679
+ },
680
+ {
681
+ name: 'awaiting_approval',
682
+ status: 'awaiting_approval',
683
+ extraProps: {
684
+ tool: baseTool,
685
+ invocation: baseInvocation,
686
+ confirmationDetails: {
687
+ onConfirm: vi.fn(),
688
+ type: 'edit',
689
+ title: 'Test Tool Display',
690
+ serverName: 'testTool',
691
+ toolName: 'testTool',
692
+ toolDisplayName: 'Test Tool Display',
693
+ filePath: 'mock',
694
+ fileName: 'test.ts',
695
+ fileDiff: 'Test diff',
696
+ originalContent: 'Original content',
697
+ newContent: 'New content',
698
+ },
699
+ },
700
+ expectedStatus: ToolCallStatus.Confirming,
701
+ expectedName: baseTool.displayName,
702
+ expectedDescription: baseInvocation.getDescription(),
703
+ },
704
+ {
705
+ name: 'scheduled',
706
+ status: 'scheduled',
707
+ extraProps: { tool: baseTool, invocation: baseInvocation },
708
+ expectedStatus: ToolCallStatus.Pending,
709
+ expectedName: baseTool.displayName,
710
+ expectedDescription: baseInvocation.getDescription(),
711
+ },
712
+ {
713
+ name: 'executing no live output',
714
+ status: 'executing',
715
+ extraProps: { tool: baseTool, invocation: baseInvocation },
716
+ expectedStatus: ToolCallStatus.Executing,
717
+ expectedName: baseTool.displayName,
718
+ expectedDescription: baseInvocation.getDescription(),
719
+ },
720
+ {
721
+ name: 'executing with live output',
722
+ status: 'executing',
723
+ extraProps: {
724
+ tool: baseTool,
725
+ invocation: baseInvocation,
726
+ liveOutput: 'Live test output',
727
+ },
728
+ expectedStatus: ToolCallStatus.Executing,
729
+ expectedResultDisplay: 'Live test output',
730
+ expectedName: baseTool.displayName,
731
+ expectedDescription: baseInvocation.getDescription(),
732
+ },
733
+ {
734
+ name: 'success',
735
+ status: 'success',
736
+ extraProps: {
737
+ tool: baseTool,
738
+ invocation: baseInvocation,
739
+ response: baseResponse,
740
+ },
741
+ expectedStatus: ToolCallStatus.Success,
742
+ expectedResultDisplay: baseResponse.resultDisplay,
743
+ expectedName: baseTool.displayName,
744
+ expectedDescription: baseInvocation.getDescription(),
745
+ },
746
+ {
747
+ name: 'error tool not found',
748
+ status: 'error',
749
+ extraProps: {
750
+ response: {
751
+ ...baseResponse,
752
+ error: new Error('Test error tool not found'),
753
+ resultDisplay: 'Error display tool not found',
754
+ },
755
+ },
756
+ expectedStatus: ToolCallStatus.Error,
757
+ expectedResultDisplay: 'Error display tool not found',
758
+ expectedName: baseRequest.name,
759
+ expectedDescription: JSON.stringify(baseRequest.args),
760
+ },
761
+ {
762
+ name: 'error tool execution failed',
763
+ status: 'error',
764
+ extraProps: {
765
+ tool: baseTool,
766
+ response: {
767
+ ...baseResponse,
768
+ error: new Error('Tool execution failed'),
769
+ resultDisplay: 'Execution failed display',
770
+ },
771
+ },
772
+ expectedStatus: ToolCallStatus.Error,
773
+ expectedResultDisplay: 'Execution failed display',
774
+ expectedName: baseTool.displayName, // Changed from baseTool.name
775
+ expectedDescription: baseInvocation.getDescription(),
776
+ },
777
+ {
778
+ name: 'cancelled',
779
+ status: 'cancelled',
780
+ extraProps: {
781
+ tool: baseTool,
782
+ invocation: baseInvocation,
783
+ response: {
784
+ ...baseResponse,
785
+ resultDisplay: 'Cancelled display',
786
+ },
787
+ },
788
+ expectedStatus: ToolCallStatus.Canceled,
789
+ expectedResultDisplay: 'Cancelled display',
790
+ expectedName: baseTool.displayName,
791
+ expectedDescription: baseInvocation.getDescription(),
792
+ },
793
+ ];
794
+ testCases.forEach(({ name: testName, status, extraProps, expectedStatus, expectedResultDisplay, expectedName, expectedDescription, }) => {
795
+ it(`should map ToolCall with status '${status}' (${testName}) correctly`, () => {
796
+ const toolCall = {
797
+ request: baseRequest,
798
+ status,
799
+ ...(extraProps || {}),
800
+ };
801
+ const display = mapToDisplay(toolCall);
802
+ expect(display.type).toBe('tool_group');
803
+ expect(display.tools.length).toBe(1);
804
+ const toolDisplay = display.tools[0];
805
+ expect(toolDisplay.callId).toBe(baseRequest.callId);
806
+ expect(toolDisplay.status).toBe(expectedStatus);
807
+ expect(toolDisplay.resultDisplay).toBe(expectedResultDisplay);
808
+ expect(toolDisplay.name).toBe(expectedName);
809
+ expect(toolDisplay.description).toBe(expectedDescription);
810
+ expect(toolDisplay.renderOutputAsMarkdown).toBe(extraProps?.tool?.isOutputMarkdown ?? false);
811
+ if (status === 'awaiting_approval') {
812
+ expect(toolDisplay.confirmationDetails).toBe(extraProps.confirmationDetails);
813
+ }
814
+ else {
815
+ expect(toolDisplay.confirmationDetails).toBeUndefined();
816
+ }
817
+ });
818
+ });
819
+ it('should map an array of ToolCalls correctly', () => {
820
+ const toolCall1 = {
821
+ request: { ...baseRequest, callId: 'call1' },
822
+ status: 'success',
823
+ tool: baseTool,
824
+ invocation: baseTool.build(baseRequest.args),
825
+ response: { ...baseResponse, callId: 'call1' },
826
+ };
827
+ const toolForCall2 = new MockTool(baseTool.name, baseTool.displayName, false, false, true);
828
+ const toolCall2 = {
829
+ request: { ...baseRequest, callId: 'call2' },
830
+ status: 'executing',
831
+ tool: toolForCall2,
832
+ invocation: toolForCall2.build(baseRequest.args),
833
+ liveOutput: 'markdown output',
834
+ };
835
+ const display = mapToDisplay([toolCall1, toolCall2]);
836
+ expect(display.tools.length).toBe(2);
837
+ expect(display.tools[0].callId).toBe('call1');
838
+ expect(display.tools[0].status).toBe(ToolCallStatus.Success);
839
+ expect(display.tools[0].renderOutputAsMarkdown).toBe(false);
840
+ expect(display.tools[1].callId).toBe('call2');
841
+ expect(display.tools[1].status).toBe(ToolCallStatus.Executing);
842
+ expect(display.tools[1].resultDisplay).toBe('markdown output');
843
+ expect(display.tools[1].renderOutputAsMarkdown).toBe(true);
844
+ });
845
+ });
846
+ //# sourceMappingURL=useToolScheduler.test.js.map