@machina.ai/cell-cli 1.18.4-rc1 → 1.19.4-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 (370) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +6 -6
  5. package/dist/src/commands/extensions.test.d.ts +6 -0
  6. package/dist/src/commands/extensions.test.js +67 -0
  7. package/dist/src/commands/extensions.test.js.map +1 -0
  8. package/dist/src/commands/utils.test.d.ts +6 -0
  9. package/dist/src/commands/utils.test.js +35 -0
  10. package/dist/src/commands/utils.test.js.map +1 -0
  11. package/dist/src/config/auth.js +4 -0
  12. package/dist/src/config/auth.js.map +1 -1
  13. package/dist/src/config/auth.test.js +1 -2
  14. package/dist/src/config/auth.test.js.map +1 -1
  15. package/dist/src/config/config.integration.test.js +81 -198
  16. package/dist/src/config/config.integration.test.js.map +1 -1
  17. package/dist/src/config/config.js +3 -9
  18. package/dist/src/config/config.js.map +1 -1
  19. package/dist/src/config/config.test.js +200 -316
  20. package/dist/src/config/config.test.js.map +1 -1
  21. package/dist/src/config/extension.test.js +109 -133
  22. package/dist/src/config/extension.test.js.map +1 -1
  23. package/dist/src/config/extensions/consent.test.d.ts +6 -0
  24. package/dist/src/config/extensions/consent.test.js +152 -0
  25. package/dist/src/config/extensions/consent.test.js.map +1 -0
  26. package/dist/src/config/extensions/extensionEnablement.test.js +82 -15
  27. package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -1
  28. package/dist/src/config/extensions/extensionSettings.test.js +105 -1
  29. package/dist/src/config/extensions/extensionSettings.test.js.map +1 -1
  30. package/dist/src/config/extensions/github.d.ts +1 -0
  31. package/dist/src/config/extensions/github.js +21 -5
  32. package/dist/src/config/extensions/github.js.map +1 -1
  33. package/dist/src/config/extensions/github.test.js +201 -318
  34. package/dist/src/config/extensions/github.test.js.map +1 -1
  35. package/dist/src/config/extensions/storage.test.d.ts +6 -0
  36. package/dist/src/config/extensions/storage.test.js +64 -0
  37. package/dist/src/config/extensions/storage.test.js.map +1 -0
  38. package/dist/src/config/extensions/update.test.js +154 -263
  39. package/dist/src/config/extensions/update.test.js.map +1 -1
  40. package/dist/src/config/extensions/variables.test.js +87 -1
  41. package/dist/src/config/extensions/variables.test.js.map +1 -1
  42. package/dist/src/config/sandboxConfig.d.ts +1 -1
  43. package/dist/src/config/sandboxConfig.js.map +1 -1
  44. package/dist/src/config/sandboxConfig.test.d.ts +6 -0
  45. package/dist/src/config/sandboxConfig.test.js +178 -0
  46. package/dist/src/config/sandboxConfig.test.js.map +1 -0
  47. package/dist/src/config/settingPaths.test.d.ts +6 -0
  48. package/dist/src/config/settingPaths.test.js +22 -0
  49. package/dist/src/config/settingPaths.test.js.map +1 -0
  50. package/dist/src/config/settings.js +12 -1
  51. package/dist/src/config/settings.js.map +1 -1
  52. package/dist/src/config/settings.test.js +228 -227
  53. package/dist/src/config/settings.test.js.map +1 -1
  54. package/dist/src/config/settingsSchema.d.ts +13 -4
  55. package/dist/src/config/settingsSchema.js +13 -4
  56. package/dist/src/config/settingsSchema.js.map +1 -1
  57. package/dist/src/config/settingsSchema.test.js +10 -5
  58. package/dist/src/config/settingsSchema.test.js.map +1 -1
  59. package/dist/src/core/auth.test.d.ts +6 -0
  60. package/dist/src/core/auth.test.js +43 -0
  61. package/dist/src/core/auth.test.js.map +1 -0
  62. package/dist/src/core/initializer.test.d.ts +6 -0
  63. package/dist/src/core/initializer.test.js +101 -0
  64. package/dist/src/core/initializer.test.js.map +1 -0
  65. package/dist/src/core/theme.test.d.ts +6 -0
  66. package/dist/src/core/theme.test.js +46 -0
  67. package/dist/src/core/theme.test.js.map +1 -0
  68. package/dist/src/gemini.d.ts +1 -0
  69. package/dist/src/gemini.js +7 -2
  70. package/dist/src/gemini.js.map +1 -1
  71. package/dist/src/gemini.test.js +625 -1
  72. package/dist/src/gemini.test.js.map +1 -1
  73. package/dist/src/gemini_cleanup.test.d.ts +6 -0
  74. package/dist/src/gemini_cleanup.test.js +201 -0
  75. package/dist/src/gemini_cleanup.test.js.map +1 -0
  76. package/dist/src/generated/git-commit.d.ts +2 -2
  77. package/dist/src/generated/git-commit.js +2 -2
  78. package/dist/src/nonInteractiveCli.test.js +336 -0
  79. package/dist/src/nonInteractiveCli.test.js.map +1 -1
  80. package/dist/src/services/BuiltinCommandLoader.js +3 -1
  81. package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
  82. package/dist/src/services/BuiltinCommandLoader.test.js +1 -22
  83. package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
  84. package/dist/src/test-utils/mockCommandContext.js +1 -1
  85. package/dist/src/test-utils/render.js +4 -0
  86. package/dist/src/test-utils/render.js.map +1 -1
  87. package/dist/src/ui/App.test.js +28 -14
  88. package/dist/src/ui/App.test.js.map +1 -1
  89. package/dist/src/ui/AppContainer.js +30 -6
  90. package/dist/src/ui/AppContainer.js.map +1 -1
  91. package/dist/src/ui/IdeIntegrationNudge.test.d.ts +6 -0
  92. package/dist/src/ui/IdeIntegrationNudge.test.js +147 -0
  93. package/dist/src/ui/IdeIntegrationNudge.test.js.map +1 -0
  94. package/dist/src/ui/auth/ApiAuthDialog.test.js +12 -17
  95. package/dist/src/ui/auth/ApiAuthDialog.test.js.map +1 -1
  96. package/dist/src/ui/auth/AuthDialog.test.js +48 -17
  97. package/dist/src/ui/auth/AuthDialog.test.js.map +1 -1
  98. package/dist/src/ui/auth/AuthInProgress.test.d.ts +6 -0
  99. package/dist/src/ui/auth/AuthInProgress.test.js +71 -0
  100. package/dist/src/ui/auth/AuthInProgress.test.js.map +1 -0
  101. package/dist/src/ui/auth/useAuth.d.ts +2 -0
  102. package/dist/src/ui/auth/useAuth.js +6 -1
  103. package/dist/src/ui/auth/useAuth.js.map +1 -1
  104. package/dist/src/ui/auth/useAuth.test.d.ts +6 -0
  105. package/dist/src/ui/auth/useAuth.test.js +178 -0
  106. package/dist/src/ui/auth/useAuth.test.js.map +1 -0
  107. package/dist/src/ui/commands/extensionsCommand.js +28 -6
  108. package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
  109. package/dist/src/ui/commands/extensionsCommand.test.js +32 -0
  110. package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -1
  111. package/dist/src/ui/commands/resumeCommand.d.ts +7 -0
  112. package/dist/src/ui/commands/resumeCommand.js +16 -0
  113. package/dist/src/ui/commands/resumeCommand.js.map +1 -0
  114. package/dist/src/ui/commands/statsCommand.js +27 -16
  115. package/dist/src/ui/commands/statsCommand.js.map +1 -1
  116. package/dist/src/ui/commands/types.d.ts +1 -1
  117. package/dist/src/ui/commands/types.js.map +1 -1
  118. package/dist/src/ui/components/AboutBox.test.d.ts +6 -0
  119. package/dist/src/ui/components/AboutBox.test.js +53 -0
  120. package/dist/src/ui/components/AboutBox.test.js.map +1 -0
  121. package/dist/src/ui/components/AlternateBufferQuittingDisplay.test.js +62 -11
  122. package/dist/src/ui/components/AlternateBufferQuittingDisplay.test.js.map +1 -1
  123. package/dist/src/ui/components/AnsiOutput.test.js +18 -23
  124. package/dist/src/ui/components/AnsiOutput.test.js.map +1 -1
  125. package/dist/src/ui/components/AsciiArt.d.ts +6 -6
  126. package/dist/src/ui/components/AsciiArt.js +6 -6
  127. package/dist/src/ui/components/AutoAcceptIndicator.test.d.ts +6 -0
  128. package/dist/src/ui/components/AutoAcceptIndicator.test.js +31 -0
  129. package/dist/src/ui/components/AutoAcceptIndicator.test.js.map +1 -0
  130. package/dist/src/ui/components/Banner.test.d.ts +6 -0
  131. package/dist/src/ui/components/Banner.test.js +24 -0
  132. package/dist/src/ui/components/Banner.test.js.map +1 -0
  133. package/dist/src/ui/components/ConfigInitDisplay.test.d.ts +6 -0
  134. package/dist/src/ui/components/ConfigInitDisplay.test.js +103 -0
  135. package/dist/src/ui/components/ConfigInitDisplay.test.js.map +1 -0
  136. package/dist/src/ui/components/ConsoleSummaryDisplay.test.d.ts +6 -0
  137. package/dist/src/ui/components/ConsoleSummaryDisplay.test.js +26 -0
  138. package/dist/src/ui/components/ConsoleSummaryDisplay.test.js.map +1 -0
  139. package/dist/src/ui/components/ContextUsageDisplay.test.d.ts +6 -0
  140. package/dist/src/ui/components/ContextUsageDisplay.test.js +39 -0
  141. package/dist/src/ui/components/ContextUsageDisplay.test.js.map +1 -0
  142. package/dist/src/ui/components/CopyModeWarning.test.d.ts +6 -0
  143. package/dist/src/ui/components/CopyModeWarning.test.js +33 -0
  144. package/dist/src/ui/components/CopyModeWarning.test.js.map +1 -0
  145. package/dist/src/ui/components/DebugProfiler.js +1 -1
  146. package/dist/src/ui/components/DebugProfiler.js.map +1 -1
  147. package/dist/src/ui/components/DebugProfiler.test.js +46 -1
  148. package/dist/src/ui/components/DebugProfiler.test.js.map +1 -1
  149. package/dist/src/ui/components/DetailedMessagesDisplay.test.d.ts +6 -0
  150. package/dist/src/ui/components/DetailedMessagesDisplay.test.js +49 -0
  151. package/dist/src/ui/components/DetailedMessagesDisplay.test.js.map +1 -0
  152. package/dist/src/ui/components/DialogManager.js +4 -0
  153. package/dist/src/ui/components/DialogManager.js.map +1 -1
  154. package/dist/src/ui/components/DialogManager.test.d.ts +6 -0
  155. package/dist/src/ui/components/DialogManager.test.js +167 -0
  156. package/dist/src/ui/components/DialogManager.test.js.map +1 -0
  157. package/dist/src/ui/components/EditorSettingsDialog.test.d.ts +6 -0
  158. package/dist/src/ui/components/EditorSettingsDialog.test.js +111 -0
  159. package/dist/src/ui/components/EditorSettingsDialog.test.js.map +1 -0
  160. package/dist/src/ui/components/ExitWarning.test.d.ts +6 -0
  161. package/dist/src/ui/components/ExitWarning.test.js +54 -0
  162. package/dist/src/ui/components/ExitWarning.test.js.map +1 -0
  163. package/dist/src/ui/components/GeminiRespondingSpinner.test.d.ts +6 -0
  164. package/dist/src/ui/components/GeminiRespondingSpinner.test.js +58 -0
  165. package/dist/src/ui/components/GeminiRespondingSpinner.test.js.map +1 -0
  166. package/dist/src/ui/components/InputPrompt.js +1 -1
  167. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  168. package/dist/src/ui/components/InputPrompt.test.js +6 -0
  169. package/dist/src/ui/components/InputPrompt.test.js.map +1 -1
  170. package/dist/src/ui/components/MainContent.test.d.ts +6 -0
  171. package/dist/src/ui/components/MainContent.test.js +73 -0
  172. package/dist/src/ui/components/MainContent.test.js.map +1 -0
  173. package/dist/src/ui/components/MemoryUsageDisplay.test.d.ts +6 -0
  174. package/dist/src/ui/components/MemoryUsageDisplay.test.js +49 -0
  175. package/dist/src/ui/components/MemoryUsageDisplay.test.js.map +1 -0
  176. package/dist/src/ui/components/ModelDialog.test.js +1 -1
  177. package/dist/src/ui/components/ModelDialog.test.js.map +1 -1
  178. package/dist/src/ui/components/Notifications.js +5 -3
  179. package/dist/src/ui/components/Notifications.js.map +1 -1
  180. package/dist/src/ui/components/Notifications.test.d.ts +6 -0
  181. package/dist/src/ui/components/Notifications.test.js +153 -0
  182. package/dist/src/ui/components/Notifications.test.js.map +1 -0
  183. package/dist/src/ui/components/QuittingDisplay.test.d.ts +6 -0
  184. package/dist/src/ui/components/QuittingDisplay.test.js +49 -0
  185. package/dist/src/ui/components/QuittingDisplay.test.js.map +1 -0
  186. package/dist/src/ui/components/RawMarkdownIndicator.test.d.ts +6 -0
  187. package/dist/src/ui/components/RawMarkdownIndicator.test.js +34 -0
  188. package/dist/src/ui/components/RawMarkdownIndicator.test.js.map +1 -0
  189. package/dist/src/ui/components/SessionBrowser.d.ts +98 -0
  190. package/dist/src/ui/components/SessionBrowser.js +457 -0
  191. package/dist/src/ui/components/SessionBrowser.js.map +1 -0
  192. package/dist/src/ui/components/SessionBrowser.test.d.ts +6 -0
  193. package/dist/src/ui/components/SessionBrowser.test.js +250 -0
  194. package/dist/src/ui/components/SessionBrowser.test.js.map +1 -0
  195. package/dist/src/ui/components/ShellInputPrompt.test.d.ts +6 -0
  196. package/dist/src/ui/components/ShellInputPrompt.test.js +82 -0
  197. package/dist/src/ui/components/ShellInputPrompt.test.js.map +1 -0
  198. package/dist/src/ui/components/ShellModeIndicator.test.d.ts +6 -0
  199. package/dist/src/ui/components/ShellModeIndicator.test.js +17 -0
  200. package/dist/src/ui/components/ShellModeIndicator.test.js.map +1 -0
  201. package/dist/src/ui/components/ShowMoreLines.test.d.ts +6 -0
  202. package/dist/src/ui/components/ShowMoreLines.test.js +40 -0
  203. package/dist/src/ui/components/ShowMoreLines.test.js.map +1 -0
  204. package/dist/src/ui/components/SuggestionsDisplay.test.d.ts +6 -0
  205. package/dist/src/ui/components/SuggestionsDisplay.test.js +56 -0
  206. package/dist/src/ui/components/SuggestionsDisplay.test.js.map +1 -0
  207. package/dist/src/ui/components/ThemeDialog.js +6 -2
  208. package/dist/src/ui/components/ThemeDialog.js.map +1 -1
  209. package/dist/src/ui/components/ThemeDialog.test.js +20 -6
  210. package/dist/src/ui/components/ThemeDialog.test.js.map +1 -1
  211. package/dist/src/ui/components/ThemedGradient.test.d.ts +6 -0
  212. package/dist/src/ui/components/ThemedGradient.test.js +30 -0
  213. package/dist/src/ui/components/ThemedGradient.test.js.map +1 -0
  214. package/dist/src/ui/components/Tips.test.d.ts +6 -0
  215. package/dist/src/ui/components/Tips.test.js +23 -0
  216. package/dist/src/ui/components/Tips.test.js.map +1 -0
  217. package/dist/src/ui/components/UpdateNotification.test.d.ts +6 -0
  218. package/dist/src/ui/components/UpdateNotification.test.js +16 -0
  219. package/dist/src/ui/components/UpdateNotification.test.js.map +1 -0
  220. package/dist/src/ui/components/messages/ErrorMessage.test.d.ts +6 -0
  221. package/dist/src/ui/components/messages/ErrorMessage.test.js +23 -0
  222. package/dist/src/ui/components/messages/ErrorMessage.test.js.map +1 -0
  223. package/dist/src/ui/components/messages/InfoMessage.test.d.ts +6 -0
  224. package/dist/src/ui/components/messages/InfoMessage.test.js +28 -0
  225. package/dist/src/ui/components/messages/InfoMessage.test.js.map +1 -0
  226. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +5 -6
  227. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -1
  228. package/dist/src/ui/components/messages/ToolMessage.test.js +13 -21
  229. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -1
  230. package/dist/src/ui/components/messages/ToolResultDisplay.js +1 -1
  231. package/dist/src/ui/components/messages/ToolResultDisplay.js.map +1 -1
  232. package/dist/src/ui/components/messages/ToolResultDisplay.test.d.ts +6 -0
  233. package/dist/src/ui/components/messages/ToolResultDisplay.test.js +96 -0
  234. package/dist/src/ui/components/messages/ToolResultDisplay.test.js.map +1 -0
  235. package/dist/src/ui/components/messages/UserMessage.test.d.ts +6 -0
  236. package/dist/src/ui/components/messages/UserMessage.test.js +32 -0
  237. package/dist/src/ui/components/messages/UserMessage.test.js.map +1 -0
  238. package/dist/src/ui/components/messages/WarningMessage.test.d.ts +6 -0
  239. package/dist/src/ui/components/messages/WarningMessage.test.js +23 -0
  240. package/dist/src/ui/components/messages/WarningMessage.test.js.map +1 -0
  241. package/dist/src/ui/components/shared/text-buffer.js +20 -4
  242. package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
  243. package/dist/src/ui/components/shared/text-buffer.test.js +20 -0
  244. package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -1
  245. package/dist/src/ui/contexts/UIActionsContext.d.ts +5 -0
  246. package/dist/src/ui/contexts/UIActionsContext.js.map +1 -1
  247. package/dist/src/ui/contexts/UIStateContext.d.ts +1 -0
  248. package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
  249. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +1 -0
  250. package/dist/src/ui/hooks/slashCommandProcessor.js +3 -0
  251. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  252. package/dist/src/ui/hooks/slashCommandProcessor.test.js +1 -0
  253. package/dist/src/ui/hooks/slashCommandProcessor.test.js.map +1 -1
  254. package/dist/src/ui/hooks/useBracketedPaste.js +3 -5
  255. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -1
  256. package/dist/src/ui/hooks/useGeminiStream.test.js +1 -1
  257. package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
  258. package/dist/src/ui/hooks/useSessionBrowser.d.ts +18 -1
  259. package/dist/src/ui/hooks/useSessionBrowser.js +63 -0
  260. package/dist/src/ui/hooks/useSessionBrowser.js.map +1 -1
  261. package/dist/src/ui/hooks/useSessionBrowser.test.js +154 -526
  262. package/dist/src/ui/hooks/useSessionBrowser.test.js.map +1 -1
  263. package/dist/src/ui/hooks/useSlashCompletion.test.js +5 -5
  264. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
  265. package/dist/src/ui/hooks/useToolScheduler.test.js +6 -2
  266. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
  267. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.d.ts +6 -0
  268. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.js +121 -0
  269. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.js.map +1 -0
  270. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.d.ts +6 -0
  271. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.js +34 -0
  272. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.js.map +1 -0
  273. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.d.ts +6 -0
  274. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.js +34 -0
  275. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.js.map +1 -0
  276. package/dist/src/ui/privacy/PrivacyNotice.test.d.ts +6 -0
  277. package/dist/src/ui/privacy/PrivacyNotice.test.js +62 -0
  278. package/dist/src/ui/privacy/PrivacyNotice.test.js.map +1 -0
  279. package/dist/src/ui/state/extensions.test.js +208 -51
  280. package/dist/src/ui/state/extensions.test.js.map +1 -1
  281. package/dist/src/ui/themes/holiday.d.ts +7 -0
  282. package/dist/src/ui/themes/holiday.js +162 -0
  283. package/dist/src/ui/themes/holiday.js.map +1 -0
  284. package/dist/src/ui/themes/theme-manager.js +2 -0
  285. package/dist/src/ui/themes/theme-manager.js.map +1 -1
  286. package/dist/src/ui/types.js +1 -1
  287. package/dist/src/ui/utils/bracketedPaste.d.ts +7 -0
  288. package/dist/src/ui/utils/bracketedPaste.js +15 -0
  289. package/dist/src/ui/utils/bracketedPaste.js.map +1 -0
  290. package/dist/src/ui/utils/kittyProtocolDetector.test.d.ts +6 -0
  291. package/dist/src/ui/utils/kittyProtocolDetector.test.js +113 -0
  292. package/dist/src/ui/utils/kittyProtocolDetector.test.js.map +1 -0
  293. package/dist/src/ui/utils/terminalSetup.js +39 -38
  294. package/dist/src/ui/utils/terminalSetup.js.map +1 -1
  295. package/dist/src/ui/utils/terminalSetup.test.d.ts +6 -0
  296. package/dist/src/ui/utils/terminalSetup.test.js +132 -0
  297. package/dist/src/ui/utils/terminalSetup.test.js.map +1 -0
  298. package/dist/src/ui/utils/ui-sizing.test.d.ts +6 -0
  299. package/dist/src/ui/utils/ui-sizing.test.js +56 -0
  300. package/dist/src/ui/utils/ui-sizing.test.js.map +1 -0
  301. package/dist/src/utils/checks.test.d.ts +6 -0
  302. package/dist/src/utils/checks.test.js +29 -0
  303. package/dist/src/utils/checks.test.js.map +1 -0
  304. package/dist/src/utils/cleanup.test.js +69 -16
  305. package/dist/src/utils/cleanup.test.js.map +1 -1
  306. package/dist/src/utils/dialogScopeUtils.test.d.ts +6 -0
  307. package/dist/src/utils/dialogScopeUtils.test.js +81 -0
  308. package/dist/src/utils/dialogScopeUtils.test.js.map +1 -0
  309. package/dist/src/utils/errors.test.js +62 -0
  310. package/dist/src/utils/errors.test.js.map +1 -1
  311. package/dist/src/utils/events.test.d.ts +6 -0
  312. package/dist/src/utils/events.test.js +24 -0
  313. package/dist/src/utils/events.test.js.map +1 -0
  314. package/dist/src/utils/handleAutoUpdate.test.js +103 -24
  315. package/dist/src/utils/handleAutoUpdate.test.js.map +1 -1
  316. package/dist/src/utils/math.test.d.ts +6 -0
  317. package/dist/src/utils/math.test.js +23 -0
  318. package/dist/src/utils/math.test.js.map +1 -0
  319. package/dist/src/utils/persistentState.test.d.ts +6 -0
  320. package/dist/src/utils/persistentState.test.js +68 -0
  321. package/dist/src/utils/persistentState.test.js.map +1 -0
  322. package/dist/src/utils/readStdin.js +1 -0
  323. package/dist/src/utils/readStdin.js.map +1 -1
  324. package/dist/src/utils/readStdin.test.js +25 -0
  325. package/dist/src/utils/readStdin.test.js.map +1 -1
  326. package/dist/src/utils/resolvePath.test.d.ts +6 -0
  327. package/dist/src/utils/resolvePath.test.js +31 -0
  328. package/dist/src/utils/resolvePath.test.js.map +1 -0
  329. package/dist/src/utils/sandbox.js +6 -137
  330. package/dist/src/utils/sandbox.js.map +1 -1
  331. package/dist/src/utils/sandbox.test.d.ts +6 -0
  332. package/dist/src/utils/sandbox.test.js +302 -0
  333. package/dist/src/utils/sandbox.test.js.map +1 -0
  334. package/dist/src/utils/sandboxUtils.d.ts +14 -0
  335. package/dist/src/utils/sandboxUtils.js +120 -0
  336. package/dist/src/utils/sandboxUtils.js.map +1 -0
  337. package/dist/src/utils/sandboxUtils.test.d.ts +6 -0
  338. package/dist/src/utils/sandboxUtils.test.js +119 -0
  339. package/dist/src/utils/sandboxUtils.test.js.map +1 -0
  340. package/dist/src/utils/sessionCleanup.test.js +38 -0
  341. package/dist/src/utils/sessionCleanup.test.js.map +1 -1
  342. package/dist/src/utils/sessionUtils.d.ts +49 -4
  343. package/dist/src/utils/sessionUtils.js +100 -25
  344. package/dist/src/utils/sessionUtils.js.map +1 -1
  345. package/dist/src/utils/sessionUtils.test.js +46 -3
  346. package/dist/src/utils/sessionUtils.test.js.map +1 -1
  347. package/dist/src/utils/sessions.js +4 -1
  348. package/dist/src/utils/sessions.js.map +1 -1
  349. package/dist/src/utils/sessions.test.js +42 -0
  350. package/dist/src/utils/sessions.test.js.map +1 -1
  351. package/dist/src/utils/updateEventEmitter.test.d.ts +6 -0
  352. package/dist/src/utils/updateEventEmitter.test.js +18 -0
  353. package/dist/src/utils/updateEventEmitter.test.js.map +1 -0
  354. package/dist/src/utils/version.test.d.ts +6 -0
  355. package/dist/src/utils/version.test.js +39 -0
  356. package/dist/src/utils/version.test.js.map +1 -0
  357. package/dist/src/zed-integration/connection.test.d.ts +6 -0
  358. package/dist/src/zed-integration/connection.test.js +175 -0
  359. package/dist/src/zed-integration/connection.test.js.map +1 -0
  360. package/dist/src/zed-integration/fileSystemService.test.d.ts +6 -0
  361. package/dist/src/zed-integration/fileSystemService.test.js +98 -0
  362. package/dist/src/zed-integration/fileSystemService.test.js.map +1 -0
  363. package/dist/src/zed-integration/zedIntegration.d.ts +31 -1
  364. package/dist/src/zed-integration/zedIntegration.js +5 -2
  365. package/dist/src/zed-integration/zedIntegration.js.map +1 -1
  366. package/dist/src/zed-integration/zedIntegration.test.d.ts +6 -0
  367. package/dist/src/zed-integration/zedIntegration.test.js +619 -0
  368. package/dist/src/zed-integration/zedIntegration.test.js.map +1 -0
  369. package/dist/tsconfig.tsbuildinfo +1 -1
  370. package/package.json +6 -6
@@ -3,38 +3,120 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { convertSessionToHistoryFormats } from './useSessionBrowser.js';
7
- import { MessageType, ToolCallStatus } from '../types.js';
6
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
7
+ import { renderHook } from '../../test-utils/render.js';
8
+ import { act } from 'react';
9
+ import { useSessionBrowser, convertSessionToHistoryFormats, } from './useSessionBrowser.js';
10
+ import * as fs from 'node:fs/promises';
11
+ import path from 'node:path';
12
+ import { getSessionFiles } from '../../utils/sessionUtils.js';
13
+ // Mock modules
14
+ vi.mock('fs/promises');
15
+ vi.mock('path');
16
+ vi.mock('../../utils/sessionUtils.js');
17
+ const MOCKED_PROJECT_TEMP_DIR = '/test/project/temp';
18
+ const MOCKED_CHATS_DIR = '/test/project/temp/chats';
19
+ const MOCKED_SESSION_ID = 'test-session-123';
20
+ const MOCKED_CURRENT_SESSION_ID = 'current-session-id';
21
+ describe('useSessionBrowser', () => {
22
+ const mockedFs = vi.mocked(fs);
23
+ const mockedPath = vi.mocked(path);
24
+ const mockedGetSessionFiles = vi.mocked(getSessionFiles);
25
+ const mockConfig = {
26
+ storage: {
27
+ getProjectTempDir: vi.fn(),
28
+ },
29
+ setSessionId: vi.fn(),
30
+ getSessionId: vi.fn(),
31
+ getGeminiClient: vi.fn().mockReturnValue({
32
+ getChatRecordingService: vi.fn().mockReturnValue({
33
+ deleteSession: vi.fn(),
34
+ }),
35
+ }),
36
+ };
37
+ const mockOnLoadHistory = vi.fn();
38
+ beforeEach(() => {
39
+ vi.resetAllMocks();
40
+ mockedPath.join.mockImplementation((...args) => args.join('/'));
41
+ vi.mocked(mockConfig.storage.getProjectTempDir).mockReturnValue(MOCKED_PROJECT_TEMP_DIR);
42
+ vi.mocked(mockConfig.getSessionId).mockReturnValue(MOCKED_CURRENT_SESSION_ID);
43
+ });
44
+ it('should successfully resume a session', async () => {
45
+ const MOCKED_FILENAME = 'session-2025-01-01-test-session-123.json';
46
+ const mockConversation = {
47
+ sessionId: 'existing-session-456',
48
+ messages: [{ type: 'user', content: 'Hello' }],
49
+ };
50
+ const mockSession = {
51
+ id: MOCKED_SESSION_ID,
52
+ fileName: MOCKED_FILENAME,
53
+ };
54
+ mockedGetSessionFiles.mockResolvedValue([mockSession]);
55
+ mockedFs.readFile.mockResolvedValue(JSON.stringify(mockConversation));
56
+ const { result } = renderHook(() => useSessionBrowser(mockConfig, mockOnLoadHistory));
57
+ await act(async () => {
58
+ await result.current.handleResumeSession(mockSession);
59
+ });
60
+ expect(mockedFs.readFile).toHaveBeenCalledWith(`${MOCKED_CHATS_DIR}/${MOCKED_FILENAME}`, 'utf8');
61
+ expect(mockConfig.setSessionId).toHaveBeenCalledWith('existing-session-456');
62
+ expect(result.current.isSessionBrowserOpen).toBe(false);
63
+ expect(mockOnLoadHistory).toHaveBeenCalled();
64
+ });
65
+ it('should handle file read error', async () => {
66
+ const MOCKED_FILENAME = 'session-2025-01-01-test-session-123.json';
67
+ const mockSession = {
68
+ id: MOCKED_SESSION_ID,
69
+ fileName: MOCKED_FILENAME,
70
+ };
71
+ mockedFs.readFile.mockRejectedValue(new Error('File not found'));
72
+ const consoleErrorSpy = vi
73
+ .spyOn(console, 'error')
74
+ .mockImplementation(() => { });
75
+ const { result } = renderHook(() => useSessionBrowser(mockConfig, mockOnLoadHistory));
76
+ await act(async () => {
77
+ await result.current.handleResumeSession(mockSession);
78
+ });
79
+ expect(consoleErrorSpy).toHaveBeenCalled();
80
+ expect(result.current.isSessionBrowserOpen).toBe(false);
81
+ consoleErrorSpy.mockRestore();
82
+ });
83
+ it('should handle JSON parse error', async () => {
84
+ const MOCKED_FILENAME = 'invalid.json';
85
+ const mockSession = {
86
+ id: MOCKED_SESSION_ID,
87
+ fileName: MOCKED_FILENAME,
88
+ };
89
+ mockedFs.readFile.mockResolvedValue('invalid json');
90
+ const consoleErrorSpy = vi
91
+ .spyOn(console, 'error')
92
+ .mockImplementation(() => { });
93
+ const { result } = renderHook(() => useSessionBrowser(mockConfig, mockOnLoadHistory));
94
+ await act(async () => {
95
+ await result.current.handleResumeSession(mockSession);
96
+ });
97
+ expect(consoleErrorSpy).toHaveBeenCalled();
98
+ expect(result.current.isSessionBrowserOpen).toBe(false);
99
+ consoleErrorSpy.mockRestore();
100
+ });
101
+ });
102
+ // The convertSessionToHistoryFormats tests are self-contained and do not need changes.
8
103
  describe('convertSessionToHistoryFormats', () => {
9
104
  it('should convert empty messages array', () => {
10
105
  const result = convertSessionToHistoryFormats([]);
11
106
  expect(result.uiHistory).toEqual([]);
12
107
  expect(result.clientHistory).toEqual([]);
13
108
  });
14
- it('should convert basic user and gemini messages', () => {
109
+ it('should convert basic user and model messages', () => {
15
110
  const messages = [
16
- {
17
- id: 'msg-1',
18
- timestamp: '2025-01-01T00:01:00Z',
19
- content: 'Hello',
20
- type: 'user',
21
- },
22
- {
23
- id: 'msg-2',
24
- timestamp: '2025-01-01T00:02:00Z',
25
- content: 'Hi there!',
26
- type: 'gemini',
27
- },
111
+ { type: 'user', content: 'Hello' },
112
+ { type: 'gemini', content: 'Hi there' },
28
113
  ];
29
114
  const result = convertSessionToHistoryFormats(messages);
30
115
  expect(result.uiHistory).toHaveLength(2);
31
- expect(result.uiHistory[0]).toEqual({
32
- type: MessageType.USER,
33
- text: 'Hello',
34
- });
35
- expect(result.uiHistory[1]).toEqual({
36
- type: MessageType.GEMINI,
37
- text: 'Hi there!',
116
+ expect(result.uiHistory[0]).toMatchObject({ type: 'user', text: 'Hello' });
117
+ expect(result.uiHistory[1]).toMatchObject({
118
+ type: 'gemini',
119
+ text: 'Hi there',
38
120
  });
39
121
  expect(result.clientHistory).toHaveLength(2);
40
122
  expect(result.clientHistory[0]).toEqual({
@@ -43,538 +125,84 @@ describe('convertSessionToHistoryFormats', () => {
43
125
  });
44
126
  expect(result.clientHistory[1]).toEqual({
45
127
  role: 'model',
46
- parts: [{ text: 'Hi there!' }],
128
+ parts: [{ text: 'Hi there' }],
47
129
  });
48
130
  });
49
- it('should convert system, warning, and error messages to appropriate types', () => {
131
+ it('should filter out slash commands from client history but keep in UI', () => {
50
132
  const messages = [
51
- {
52
- id: 'msg-1',
53
- timestamp: '2025-01-01T00:01:00Z',
54
- content: 'System message',
55
- type: 'info',
56
- },
57
- {
58
- id: 'msg-2',
59
- timestamp: '2025-01-01T00:02:00Z',
60
- content: 'Warning message',
61
- type: 'warning',
62
- },
63
- {
64
- id: 'msg-3',
65
- timestamp: '2025-01-01T00:03:00Z',
66
- content: 'Error occurred',
67
- type: 'error',
68
- },
133
+ { type: 'user', content: '/help' },
134
+ { type: 'info', content: 'Help text' },
69
135
  ];
70
136
  const result = convertSessionToHistoryFormats(messages);
71
- expect(result.uiHistory[0]).toEqual({
72
- type: MessageType.INFO,
73
- text: 'System message',
74
- });
75
- expect(result.uiHistory[1]).toEqual({
76
- type: MessageType.WARNING,
77
- text: 'Warning message',
78
- });
79
- expect(result.uiHistory[2]).toEqual({
80
- type: MessageType.ERROR,
81
- text: 'Error occurred',
82
- });
83
- // System, warning, and error messages should not be included in client history
84
- expect(result.clientHistory).toEqual([]);
85
- });
86
- it('should filter out slash commands from client history', () => {
87
- const messages = [
88
- {
89
- id: 'msg-1',
90
- timestamp: '2025-01-01T00:01:00Z',
91
- content: '/help',
92
- type: 'user',
93
- },
94
- {
95
- id: 'msg-2',
96
- timestamp: '2025-01-01T00:02:00Z',
97
- content: '?quit',
98
- type: 'user',
99
- },
100
- {
101
- id: 'msg-3',
102
- timestamp: '2025-01-01T00:03:00Z',
103
- content: 'Regular message',
104
- type: 'user',
105
- },
106
- ];
107
- const result = convertSessionToHistoryFormats(messages);
108
- // All messages should appear in UI history
109
- expect(result.uiHistory).toHaveLength(3);
110
- // Only non-slash commands should appear in client history
111
- expect(result.clientHistory).toHaveLength(1);
112
- expect(result.clientHistory[0]).toEqual({
113
- role: 'user',
114
- parts: [{ text: 'Regular message' }],
115
- });
116
- });
117
- it('should handle tool calls correctly', () => {
118
- const messages = [
119
- {
120
- id: 'msg-1',
121
- timestamp: '2025-01-01T00:01:00Z',
122
- content: "I'll help you with that.",
123
- type: 'gemini',
124
- toolCalls: [
125
- {
126
- id: 'tool-1',
127
- name: 'bash',
128
- displayName: 'Execute Command',
129
- description: 'Run bash command',
130
- args: { command: 'ls -la' },
131
- status: 'success',
132
- timestamp: '2025-01-01T00:01:30Z',
133
- resultDisplay: 'total 4\ndrwxr-xr-x 2 user user 4096 Jan 1 00:00 .',
134
- renderOutputAsMarkdown: false,
135
- },
136
- {
137
- id: 'tool-2',
138
- name: 'read',
139
- displayName: 'Read File',
140
- description: 'Read file contents',
141
- args: { path: '/etc/hosts' },
142
- status: 'error',
143
- timestamp: '2025-01-01T00:01:45Z',
144
- resultDisplay: 'Permission denied',
145
- },
146
- ],
147
- },
148
- ];
149
- const result = convertSessionToHistoryFormats(messages);
150
- expect(result.uiHistory).toHaveLength(2); // text message + tool group
151
- expect(result.uiHistory[0]).toEqual({
152
- type: MessageType.GEMINI,
153
- text: "I'll help you with that.",
154
- });
155
- expect(result.uiHistory[1].type).toBe('tool_group');
156
- // This if-statement is only necessary because TypeScript can't tell that the toBe() assertion
157
- // protects the .tools access below.
158
- if (result.uiHistory[1].type === 'tool_group') {
159
- expect(result.uiHistory[1].tools).toHaveLength(2);
160
- expect(result.uiHistory[1].tools[0]).toEqual({
161
- callId: 'tool-1',
162
- name: 'Execute Command',
163
- description: 'Run bash command',
164
- renderOutputAsMarkdown: false,
165
- status: ToolCallStatus.Success,
166
- resultDisplay: 'total 4\ndrwxr-xr-x 2 user user 4096 Jan 1 00:00 .',
167
- confirmationDetails: undefined,
168
- });
169
- expect(result.uiHistory[1].tools[1]).toEqual({
170
- callId: 'tool-2',
171
- name: 'Read File',
172
- description: 'Read file contents',
173
- renderOutputAsMarkdown: true, // default value
174
- status: ToolCallStatus.Error,
175
- resultDisplay: 'Permission denied',
176
- confirmationDetails: undefined,
177
- });
178
- }
179
- });
180
- it('should skip empty tool calls arrays', () => {
181
- const messages = [
182
- {
183
- id: 'msg-1',
184
- timestamp: '2025-01-01T00:01:00Z',
185
- content: 'Message with empty tools',
186
- type: 'gemini',
187
- toolCalls: [],
188
- },
189
- ];
190
- const result = convertSessionToHistoryFormats(messages);
191
- expect(result.uiHistory).toHaveLength(1); // Only text message
192
- expect(result.uiHistory[0]).toEqual({
193
- type: MessageType.GEMINI,
194
- text: 'Message with empty tools',
195
- });
196
- });
197
- it('should not add tool calls for user messages', () => {
198
- const messages = [
199
- {
200
- id: 'msg-1',
201
- timestamp: '2025-01-01T00:01:00Z',
202
- content: 'User message',
203
- type: 'user',
204
- // This would be invalid in real usage, but testing robustness
205
- toolCalls: [
206
- {
207
- id: 'tool-1',
208
- name: 'invalid',
209
- args: {},
210
- status: 'success',
211
- timestamp: '2025-01-01T00:01:30Z',
212
- },
213
- ],
214
- },
215
- ];
216
- const result = convertSessionToHistoryFormats(messages);
217
- expect(result.uiHistory).toHaveLength(1); // Only user message, no tool group
218
- expect(result.uiHistory[0]).toEqual({
219
- type: MessageType.USER,
220
- text: 'User message',
137
+ expect(result.uiHistory).toHaveLength(2);
138
+ expect(result.uiHistory[0]).toMatchObject({ type: 'user', text: '/help' });
139
+ expect(result.uiHistory[1]).toMatchObject({
140
+ type: 'info',
141
+ text: 'Help text',
221
142
  });
143
+ expect(result.clientHistory).toHaveLength(0);
222
144
  });
223
- it('should handle missing tool call fields gracefully', () => {
145
+ it('should handle tool calls and responses', () => {
224
146
  const messages = [
147
+ { type: 'user', content: 'What time is it?' },
225
148
  {
226
- id: 'msg-1',
227
- timestamp: '2025-01-01T00:01:00Z',
228
- content: 'Message with minimal tool',
229
149
  type: 'gemini',
150
+ content: '',
230
151
  toolCalls: [
231
152
  {
232
- id: 'tool-1',
233
- name: 'minimal_tool',
153
+ id: 'call_1',
154
+ name: 'get_time',
234
155
  args: {},
235
156
  status: 'success',
236
- timestamp: '2025-01-01T00:01:30Z',
237
- // Missing optional fields
157
+ result: '12:00',
238
158
  },
239
159
  ],
240
160
  },
241
161
  ];
242
162
  const result = convertSessionToHistoryFormats(messages);
243
163
  expect(result.uiHistory).toHaveLength(2);
244
- expect(result.uiHistory[1].type).toBe('tool_group');
245
- if (result.uiHistory[1].type === 'tool_group') {
246
- expect(result.uiHistory[1].tools[0]).toEqual({
247
- callId: 'tool-1',
248
- name: 'minimal_tool', // Falls back to name when displayName missing
249
- description: '', // Default empty string
250
- renderOutputAsMarkdown: true, // Default value
251
- status: ToolCallStatus.Success,
252
- resultDisplay: undefined,
253
- confirmationDetails: undefined,
254
- });
255
- }
256
- else {
257
- throw new Error('unreachable');
258
- }
259
- });
260
- describe('tool calls in client history', () => {
261
- it('should convert tool calls to correct Gemini client history format', () => {
262
- const messages = [
263
- {
264
- id: 'msg-1',
265
- timestamp: '2025-01-01T00:01:00Z',
266
- content: 'List files',
267
- type: 'user',
268
- },
269
- {
270
- id: 'msg-2',
271
- timestamp: '2025-01-01T00:02:00Z',
272
- content: "I'll list the files for you.",
273
- type: 'gemini',
274
- toolCalls: [
275
- {
276
- id: 'tool-1',
277
- name: 'list_directory',
278
- args: { path: '/home/user' },
279
- result: {
280
- functionResponse: {
281
- id: 'list_directory-1753650620141-f3b8b9e73919d',
282
- name: 'list_directory',
283
- response: {
284
- output: 'file1.txt\nfile2.txt',
285
- },
286
- },
287
- },
288
- status: 'success',
289
- timestamp: '2025-01-01T00:02:30Z',
290
- },
291
- ],
292
- },
293
- ];
294
- const result = convertSessionToHistoryFormats(messages);
295
- // Should have: user message, model with function call, user with function response
296
- expect(result.clientHistory).toHaveLength(3);
297
- // User message
298
- expect(result.clientHistory[0]).toEqual({
299
- role: 'user',
300
- parts: [{ text: 'List files' }],
301
- });
302
- // Model message with function call
303
- expect(result.clientHistory[1]).toEqual({
304
- role: 'model',
305
- parts: [
306
- { text: "I'll list the files for you." },
307
- {
308
- functionCall: {
309
- name: 'list_directory',
310
- args: { path: '/home/user' },
311
- id: 'tool-1',
312
- },
313
- },
314
- ],
315
- });
316
- // Function response
317
- expect(result.clientHistory[2]).toEqual({
318
- role: 'user',
319
- parts: [
320
- {
321
- functionResponse: {
322
- id: 'list_directory-1753650620141-f3b8b9e73919d',
323
- name: 'list_directory',
324
- response: { output: 'file1.txt\nfile2.txt' },
325
- },
326
- },
327
- ],
328
- });
164
+ expect(result.uiHistory[0]).toMatchObject({
165
+ type: 'user',
166
+ text: 'What time is it?',
167
+ });
168
+ expect(result.uiHistory[1]).toMatchObject({
169
+ type: 'tool_group',
170
+ tools: [
171
+ expect.objectContaining({
172
+ callId: 'call_1',
173
+ name: 'get_time',
174
+ status: 'Success',
175
+ }),
176
+ ],
177
+ });
178
+ expect(result.clientHistory).toHaveLength(3); // User, Model (call), User (response)
179
+ expect(result.clientHistory[0]).toEqual({
180
+ role: 'user',
181
+ parts: [{ text: 'What time is it?' }],
329
182
  });
330
- it('should handle tool calls without text content', () => {
331
- const messages = [
183
+ expect(result.clientHistory[1]).toEqual({
184
+ role: 'model',
185
+ parts: [
332
186
  {
333
- id: 'msg-1',
334
- timestamp: '2025-01-01T00:01:00Z',
335
- content: '',
336
- type: 'gemini',
337
- toolCalls: [
338
- {
339
- id: 'tool-1',
340
- name: 'bash',
341
- args: { command: 'ls' },
342
- result: 'file1.txt\nfile2.txt',
343
- status: 'success',
344
- timestamp: '2025-01-01T00:01:30Z',
345
- },
346
- ],
347
- },
348
- ];
349
- const result = convertSessionToHistoryFormats(messages);
350
- expect(result.clientHistory).toHaveLength(2);
351
- // Model message with only function call (no text)
352
- expect(result.clientHistory[0]).toEqual({
353
- role: 'model',
354
- parts: [
355
- {
356
- functionCall: {
357
- name: 'bash',
358
- args: { command: 'ls' },
359
- id: 'tool-1',
360
- },
361
- },
362
- ],
363
- });
364
- // Function response
365
- expect(result.clientHistory[1]).toEqual({
366
- role: 'user',
367
- parts: [
368
- {
369
- functionResponse: {
370
- id: 'tool-1',
371
- name: 'bash',
372
- response: {
373
- output: 'file1.txt\nfile2.txt',
374
- },
375
- },
187
+ functionCall: {
188
+ name: 'get_time',
189
+ args: {},
190
+ id: 'call_1',
376
191
  },
377
- ],
378
- });
379
- });
380
- it('should handle multiple tool calls in one message', () => {
381
- const messages = [
382
- {
383
- id: 'msg-1',
384
- timestamp: '2025-01-01T00:01:00Z',
385
- content: 'Running multiple commands',
386
- type: 'gemini',
387
- toolCalls: [
388
- {
389
- id: 'tool-1',
390
- name: 'bash',
391
- args: { command: 'pwd' },
392
- result: '/home/user',
393
- status: 'success',
394
- timestamp: '2025-01-01T00:01:30Z',
395
- },
396
- {
397
- id: 'tool-2',
398
- name: 'bash',
399
- args: { command: 'ls' },
400
- result: [
401
- {
402
- functionResponse: {
403
- id: 'tool-2',
404
- name: 'bash',
405
- response: {
406
- output: 'file1.txt',
407
- },
408
- },
409
- },
410
- {
411
- functionResponse: {
412
- id: 'tool-2',
413
- name: 'bash',
414
- response: {
415
- output: 'file2.txt',
416
- },
417
- },
418
- },
419
- ],
420
- status: 'success',
421
- timestamp: '2025-01-01T00:01:35Z',
422
- },
423
- ],
424
192
  },
425
- ];
426
- const result = convertSessionToHistoryFormats(messages);
427
- // Should have: model with both function calls, then one response
428
- expect(result.clientHistory).toHaveLength(2);
429
- // Model message with both function calls
430
- expect(result.clientHistory[0]).toEqual({
431
- role: 'model',
432
- parts: [
433
- { text: 'Running multiple commands' },
434
- {
435
- functionCall: {
436
- name: 'bash',
437
- args: { command: 'pwd' },
438
- id: 'tool-1',
439
- },
440
- },
441
- {
442
- functionCall: {
443
- name: 'bash',
444
- args: { command: 'ls' },
445
- id: 'tool-2',
446
- },
447
- },
448
- ],
449
- });
450
- // First function response
451
- expect(result.clientHistory[1]).toEqual({
452
- role: 'user',
453
- parts: [
454
- {
455
- functionResponse: {
456
- id: 'tool-1',
457
- name: 'bash',
458
- response: { output: '/home/user' },
459
- },
460
- },
461
- {
462
- functionResponse: {
463
- id: 'tool-2',
464
- name: 'bash',
465
- response: { output: 'file1.txt' },
466
- },
467
- },
468
- {
469
- functionResponse: {
470
- id: 'tool-2',
471
- name: 'bash',
472
- response: { output: 'file2.txt' },
473
- },
474
- },
475
- ],
476
- });
193
+ ],
477
194
  });
478
- it('should handle Part array results from tools', () => {
479
- const messages = [
195
+ expect(result.clientHistory[2]).toEqual({
196
+ role: 'user',
197
+ parts: [
480
198
  {
481
- id: 'msg-1',
482
- timestamp: '2025-01-01T00:01:00Z',
483
- content: 'Reading file',
484
- type: 'gemini',
485
- toolCalls: [
486
- {
487
- id: 'tool-1',
488
- name: 'read_file',
489
- args: { path: 'test.txt' },
490
- result: [
491
- {
492
- functionResponse: {
493
- id: 'tool-1',
494
- name: 'read_file',
495
- response: {
496
- output: 'Hello',
497
- },
498
- },
499
- },
500
- {
501
- functionResponse: {
502
- id: 'tool-1',
503
- name: 'read_file',
504
- response: {
505
- output: ' World',
506
- },
507
- },
508
- },
509
- ],
510
- status: 'success',
511
- timestamp: '2025-01-01T00:01:30Z',
512
- },
513
- ],
514
- },
515
- ];
516
- const result = convertSessionToHistoryFormats(messages);
517
- expect(result.clientHistory).toHaveLength(2);
518
- // Function response should extract both function responses
519
- expect(result.clientHistory[1]).toEqual({
520
- role: 'user',
521
- parts: [
522
- {
523
- functionResponse: {
524
- id: 'tool-1',
525
- name: 'read_file',
526
- response: {
527
- output: 'Hello',
528
- },
529
- },
530
- },
531
- {
532
- functionResponse: {
533
- id: 'tool-1',
534
- name: 'read_file',
535
- response: {
536
- output: ' World',
537
- },
538
- },
199
+ functionResponse: {
200
+ id: 'call_1',
201
+ name: 'get_time',
202
+ response: { output: '12:00' },
539
203
  },
540
- ],
541
- });
542
- });
543
- it('should skip tool calls without results', () => {
544
- const messages = [
545
- {
546
- id: 'msg-1',
547
- timestamp: '2025-01-01T00:01:00Z',
548
- content: 'Testing tool',
549
- type: 'gemini',
550
- toolCalls: [
551
- {
552
- id: 'tool-1',
553
- name: 'test_tool',
554
- args: { arg: 'value' },
555
- // No result field
556
- status: 'error',
557
- timestamp: '2025-01-01T00:01:30Z',
558
- },
559
- ],
560
204
  },
561
- ];
562
- const result = convertSessionToHistoryFormats(messages);
563
- // Should only have the model message with function call, no function response
564
- expect(result.clientHistory).toHaveLength(1);
565
- expect(result.clientHistory[0]).toEqual({
566
- role: 'model',
567
- parts: [
568
- { text: 'Testing tool' },
569
- {
570
- functionCall: {
571
- name: 'test_tool',
572
- args: { arg: 'value' },
573
- id: 'tool-1',
574
- },
575
- },
576
- ],
577
- });
205
+ ],
578
206
  });
579
207
  });
580
208
  });