@google/gemini-cli 0.1.10-dev.0 → 0.1.10-dev.12

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 (429) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +142 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +20 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/package.json +80 -0
  8. package/dist/src/config/auth.d.ts +6 -0
  9. package/dist/src/config/auth.js +32 -0
  10. package/dist/src/config/auth.js.map +1 -0
  11. package/dist/src/config/config.d.ts +14 -0
  12. package/dist/src/config/config.js +235 -0
  13. package/dist/src/config/config.js.map +1 -0
  14. package/dist/src/config/extension.d.ts +20 -0
  15. package/dist/src/config/extension.js +81 -0
  16. package/dist/src/config/extension.js.map +1 -0
  17. package/dist/src/config/sandboxConfig.d.ts +13 -0
  18. package/dist/src/config/sandboxConfig.js +75 -0
  19. package/dist/src/config/sandboxConfig.js.map +1 -0
  20. package/dist/src/config/settings.d.ts +70 -0
  21. package/dist/src/config/settings.js +165 -0
  22. package/dist/src/config/settings.js.map +1 -0
  23. package/dist/src/gemini.d.ts +6 -0
  24. package/dist/src/gemini.js +217 -0
  25. package/dist/src/gemini.js.map +1 -0
  26. package/dist/src/gemini.test.d.ts +6 -0
  27. package/dist/src/gemini.test.js +122 -0
  28. package/dist/src/gemini.test.js.map +1 -0
  29. package/dist/src/generated/git-commit.d.ts +6 -0
  30. package/dist/src/generated/git-commit.js +9 -0
  31. package/dist/src/generated/git-commit.js.map +1 -0
  32. package/dist/src/nonInteractiveCli.d.ts +7 -0
  33. package/dist/src/nonInteractiveCli.js +115 -0
  34. package/dist/src/nonInteractiveCli.js.map +1 -0
  35. package/dist/src/ui/App.d.ts +14 -0
  36. package/dist/src/ui/App.js +387 -0
  37. package/dist/src/ui/App.js.map +1 -0
  38. package/dist/src/ui/App.test.d.ts +6 -0
  39. package/dist/src/ui/App.test.js +299 -0
  40. package/dist/src/ui/App.test.js.map +1 -0
  41. package/dist/src/ui/colors.d.ts +7 -0
  42. package/dist/src/ui/colors.js +48 -0
  43. package/dist/src/ui/colors.js.map +1 -0
  44. package/dist/src/ui/components/AboutBox.d.ts +16 -0
  45. package/dist/src/ui/components/AboutBox.js +6 -0
  46. package/dist/src/ui/components/AboutBox.js.map +1 -0
  47. package/dist/src/ui/components/AsciiArt.d.ts +7 -0
  48. package/dist/src/ui/components/AsciiArt.js +26 -0
  49. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  50. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  51. package/dist/src/ui/components/AuthDialog.js +47 -0
  52. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  53. package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
  54. package/dist/src/ui/components/AuthDialog.test.js +69 -0
  55. package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
  56. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  57. package/dist/src/ui/components/AuthInProgress.js +27 -0
  58. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  59. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  60. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  61. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  62. package/dist/src/ui/components/ConsolePatcher.d.ts +12 -0
  63. package/dist/src/ui/components/ConsolePatcher.js +40 -0
  64. package/dist/src/ui/components/ConsolePatcher.js.map +1 -0
  65. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  66. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  67. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  68. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
  69. package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
  70. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  71. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  72. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  73. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  74. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  75. package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
  76. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  77. package/dist/src/ui/components/Footer.d.ts +20 -0
  78. package/dist/src/ui/components/Footer.js +13 -0
  79. package/dist/src/ui/components/Footer.js.map +1 -0
  80. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  81. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  82. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  83. package/dist/src/ui/components/Header.d.ts +12 -0
  84. package/dist/src/ui/components/Header.js +20 -0
  85. package/dist/src/ui/components/Header.js.map +1 -0
  86. package/dist/src/ui/components/Help.d.ts +12 -0
  87. package/dist/src/ui/components/Help.js +9 -0
  88. package/dist/src/ui/components/Help.js.map +1 -0
  89. package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
  90. package/dist/src/ui/components/HistoryItemDisplay.js +17 -0
  91. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  92. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
  93. package/dist/src/ui/components/HistoryItemDisplay.test.js +81 -0
  94. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
  95. package/dist/src/ui/components/InputPrompt.d.ts +24 -0
  96. package/dist/src/ui/components/InputPrompt.js +331 -0
  97. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  98. package/dist/src/ui/components/InputPrompt.test.d.ts +6 -0
  99. package/dist/src/ui/components/InputPrompt.test.js +154 -0
  100. package/dist/src/ui/components/InputPrompt.test.js.map +1 -0
  101. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  102. package/dist/src/ui/components/LoadingIndicator.js +19 -0
  103. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  104. package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
  105. package/dist/src/ui/components/LoadingIndicator.test.js +141 -0
  106. package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
  107. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  108. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  109. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  110. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  111. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  112. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  113. package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +6 -0
  114. package/dist/src/ui/components/ModelStatsDisplay.test.js +217 -0
  115. package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -0
  116. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  117. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  118. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  119. package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +6 -0
  120. package/dist/src/ui/components/SessionSummaryDisplay.test.js +60 -0
  121. package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -0
  122. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  123. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  124. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  125. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  126. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  127. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  128. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  129. package/dist/src/ui/components/StatsDisplay.js +42 -0
  130. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  131. package/dist/src/ui/components/StatsDisplay.test.d.ts +6 -0
  132. package/dist/src/ui/components/StatsDisplay.test.js +275 -0
  133. package/dist/src/ui/components/StatsDisplay.test.js.map +1 -0
  134. package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
  135. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  136. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  137. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  138. package/dist/src/ui/components/ThemeDialog.js +126 -0
  139. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  140. package/dist/src/ui/components/Tips.d.ts +12 -0
  141. package/dist/src/ui/components/Tips.js +8 -0
  142. package/dist/src/ui/components/Tips.js.map +1 -0
  143. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  144. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  145. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  146. package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +6 -0
  147. package/dist/src/ui/components/ToolStatsDisplay.test.js +160 -0
  148. package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -0
  149. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  150. package/dist/src/ui/components/UpdateNotification.js +10 -0
  151. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  152. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  153. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  154. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  155. package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
  156. package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
  157. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  158. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
  159. package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
  160. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
  161. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  162. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  163. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  164. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  165. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  166. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  167. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  168. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  169. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  170. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  171. package/dist/src/ui/components/messages/InfoMessage.js +9 -0
  172. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  173. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  174. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +111 -0
  175. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  176. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
  177. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
  178. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
  179. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  180. package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
  181. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  182. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  183. package/dist/src/ui/components/messages/ToolMessage.js +61 -0
  184. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  185. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
  186. package/dist/src/ui/components/messages/ToolMessage.test.js +116 -0
  187. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
  188. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  189. package/dist/src/ui/components/messages/UserMessage.js +9 -0
  190. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  191. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  192. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  193. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  194. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  195. package/dist/src/ui/components/shared/MaxSizedBox.js +384 -0
  196. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  197. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
  198. package/dist/src/ui/components/shared/MaxSizedBox.test.js +134 -0
  199. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
  200. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +41 -0
  201. package/dist/src/ui/components/shared/RadioButtonSelect.js +52 -0
  202. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  203. package/dist/src/ui/components/shared/text-buffer.d.ts +128 -0
  204. package/dist/src/ui/components/shared/text-buffer.js +1122 -0
  205. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  206. package/dist/src/ui/constants.d.ts +8 -0
  207. package/dist/src/ui/constants.js +12 -0
  208. package/dist/src/ui/constants.js.map +1 -0
  209. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  210. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  211. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  212. package/dist/src/ui/contexts/SessionContext.d.ts +33 -0
  213. package/dist/src/ui/contexts/SessionContext.js +49 -0
  214. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  215. package/dist/src/ui/contexts/SessionContext.test.d.ts +6 -0
  216. package/dist/src/ui/contexts/SessionContext.test.js +96 -0
  217. package/dist/src/ui/contexts/SessionContext.test.js.map +1 -0
  218. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  219. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  220. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  221. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  222. package/dist/src/ui/editors/editorSettingsManager.js +54 -0
  223. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  224. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  225. package/dist/src/ui/hooks/atCommandProcessor.js +312 -0
  226. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  227. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
  228. package/dist/src/ui/hooks/shellCommandProcessor.js +261 -0
  229. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  230. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +31 -0
  231. package/dist/src/ui/hooks/slashCommandProcessor.js +981 -0
  232. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  233. package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
  234. package/dist/src/ui/hooks/useAuthCommand.js +54 -0
  235. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  236. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  237. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  238. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  239. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  240. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  241. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  242. package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
  243. package/dist/src/ui/hooks/useCompletion.js +322 -0
  244. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  245. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  246. package/dist/src/ui/hooks/useConsoleMessages.js +60 -0
  247. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  248. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  249. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  250. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  251. package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
  252. package/dist/src/ui/hooks/useGeminiStream.js +524 -0
  253. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  254. package/dist/src/ui/hooks/useGeminiStream.test.d.ts +6 -0
  255. package/dist/src/ui/hooks/useGeminiStream.test.js +775 -0
  256. package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -0
  257. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  258. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  259. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  260. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  261. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  262. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  263. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  264. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  265. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  266. package/dist/src/ui/hooks/useKeypress.d.ts +29 -0
  267. package/dist/src/ui/hooks/useKeypress.js +86 -0
  268. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  269. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  270. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  271. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  272. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  273. package/dist/src/ui/hooks/useLogger.js +29 -0
  274. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  275. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  276. package/dist/src/ui/hooks/usePhraseCycler.js +189 -0
  277. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  278. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  279. package/dist/src/ui/hooks/usePrivacySettings.js +115 -0
  280. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  281. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  282. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  283. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  284. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  285. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  286. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  287. package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
  288. package/dist/src/ui/hooks/useShellHistory.js +89 -0
  289. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  290. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  291. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  292. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  293. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  294. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  295. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  296. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  297. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  298. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  299. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  300. package/dist/src/ui/hooks/useThemeCommand.js +78 -0
  301. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  302. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  303. package/dist/src/ui/hooks/useTimer.js +58 -0
  304. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  305. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  306. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +40 -0
  307. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  308. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  309. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +17 -0
  310. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  311. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  312. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +17 -0
  313. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  314. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  315. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  316. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  317. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  318. package/dist/src/ui/themes/ansi-light.js +139 -0
  319. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  320. package/dist/src/ui/themes/ansi.d.ts +7 -0
  321. package/dist/src/ui/themes/ansi.js +149 -0
  322. package/dist/src/ui/themes/ansi.js.map +1 -0
  323. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  324. package/dist/src/ui/themes/atom-one-dark.js +136 -0
  325. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  326. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  327. package/dist/src/ui/themes/ayu-light.js +128 -0
  328. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  329. package/dist/src/ui/themes/ayu.d.ts +7 -0
  330. package/dist/src/ui/themes/ayu.js +102 -0
  331. package/dist/src/ui/themes/ayu.js.map +1 -0
  332. package/dist/src/ui/themes/default-light.d.ts +7 -0
  333. package/dist/src/ui/themes/default-light.js +100 -0
  334. package/dist/src/ui/themes/default-light.js.map +1 -0
  335. package/dist/src/ui/themes/default.d.ts +7 -0
  336. package/dist/src/ui/themes/default.js +143 -0
  337. package/dist/src/ui/themes/default.js.map +1 -0
  338. package/dist/src/ui/themes/dracula.d.ts +7 -0
  339. package/dist/src/ui/themes/dracula.js +113 -0
  340. package/dist/src/ui/themes/dracula.js.map +1 -0
  341. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  342. package/dist/src/ui/themes/github-dark.js +136 -0
  343. package/dist/src/ui/themes/github-dark.js.map +1 -0
  344. package/dist/src/ui/themes/github-light.d.ts +7 -0
  345. package/dist/src/ui/themes/github-light.js +138 -0
  346. package/dist/src/ui/themes/github-light.js.map +1 -0
  347. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  348. package/dist/src/ui/themes/googlecode.js +135 -0
  349. package/dist/src/ui/themes/googlecode.js.map +1 -0
  350. package/dist/src/ui/themes/no-color.d.ts +7 -0
  351. package/dist/src/ui/themes/no-color.js +84 -0
  352. package/dist/src/ui/themes/no-color.js.map +1 -0
  353. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  354. package/dist/src/ui/themes/shades-of-purple.js +302 -0
  355. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  356. package/dist/src/ui/themes/theme-manager.d.ts +33 -0
  357. package/dist/src/ui/themes/theme-manager.js +109 -0
  358. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  359. package/dist/src/ui/themes/theme.d.ts +67 -0
  360. package/dist/src/ui/themes/theme.js +304 -0
  361. package/dist/src/ui/themes/theme.js.map +1 -0
  362. package/dist/src/ui/themes/xcode.d.ts +7 -0
  363. package/dist/src/ui/themes/xcode.js +143 -0
  364. package/dist/src/ui/themes/xcode.js.map +1 -0
  365. package/dist/src/ui/types.d.ts +162 -0
  366. package/dist/src/ui/types.js +43 -0
  367. package/dist/src/ui/types.js.map +1 -0
  368. package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
  369. package/dist/src/ui/utils/CodeColorizer.js +97 -0
  370. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  371. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  372. package/dist/src/ui/utils/MarkdownDisplay.js +276 -0
  373. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  374. package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
  375. package/dist/src/ui/utils/MarkdownDisplay.test.js +176 -0
  376. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
  377. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  378. package/dist/src/ui/utils/TableRenderer.js +66 -0
  379. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  380. package/dist/src/ui/utils/commandUtils.d.ts +22 -0
  381. package/dist/src/ui/utils/commandUtils.js +25 -0
  382. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  383. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  384. package/dist/src/ui/utils/computeStats.js +55 -0
  385. package/dist/src/ui/utils/computeStats.js.map +1 -0
  386. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  387. package/dist/src/ui/utils/displayUtils.js +24 -0
  388. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  389. package/dist/src/ui/utils/errorParsing.d.ts +15 -0
  390. package/dist/src/ui/utils/errorParsing.js +79 -0
  391. package/dist/src/ui/utils/errorParsing.js.map +1 -0
  392. package/dist/src/ui/utils/formatters.d.ts +13 -0
  393. package/dist/src/ui/utils/formatters.js +56 -0
  394. package/dist/src/ui/utils/formatters.js.map +1 -0
  395. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  396. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  397. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  398. package/dist/src/ui/utils/textUtils.d.ts +22 -0
  399. package/dist/src/ui/utils/textUtils.js +58 -0
  400. package/dist/src/ui/utils/textUtils.js.map +1 -0
  401. package/dist/src/ui/utils/updateCheck.d.ts +6 -0
  402. package/dist/src/ui/utils/updateCheck.js +36 -0
  403. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  404. package/dist/src/utils/cleanup.d.ts +6 -0
  405. package/dist/src/utils/cleanup.js +19 -0
  406. package/dist/src/utils/cleanup.js.map +1 -0
  407. package/dist/src/utils/package.d.ts +12 -0
  408. package/dist/src/utils/package.js +24 -0
  409. package/dist/src/utils/package.js.map +1 -0
  410. package/dist/src/utils/readStdin.d.ts +6 -0
  411. package/dist/src/utils/readStdin.js +34 -0
  412. package/dist/src/utils/readStdin.js.map +1 -0
  413. package/dist/src/utils/sandbox-macos-permissive-closed.sb +26 -0
  414. package/dist/src/utils/sandbox-macos-permissive-open.sb +19 -0
  415. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +31 -0
  416. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +87 -0
  417. package/dist/src/utils/sandbox-macos-restrictive-open.sb +90 -0
  418. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +92 -0
  419. package/dist/src/utils/sandbox.d.ts +7 -0
  420. package/dist/src/utils/sandbox.js +680 -0
  421. package/dist/src/utils/sandbox.js.map +1 -0
  422. package/dist/src/utils/startupWarnings.d.ts +6 -0
  423. package/dist/src/utils/startupWarnings.js +40 -0
  424. package/dist/src/utils/startupWarnings.js.map +1 -0
  425. package/dist/src/utils/version.d.ts +6 -0
  426. package/dist/src/utils/version.js +11 -0
  427. package/dist/src/utils/version.js.map +1 -0
  428. package/dist/tsconfig.tsbuildinfo +1 -0
  429. package/package.json +6 -3
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import React from 'react';
7
+ interface TableRendererProps {
8
+ headers: string[];
9
+ rows: string[][];
10
+ terminalWidth: number;
11
+ }
12
+ /**
13
+ * Custom table renderer for markdown tables
14
+ * We implement our own instead of using ink-table due to module compatibility issues
15
+ */
16
+ export declare const TableRenderer: React.FC<TableRendererProps>;
17
+ export {};
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @license
4
+ * Copyright 2025 Google LLC
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ import React from 'react';
8
+ import { Text, Box } from 'ink';
9
+ import { Colors } from '../colors.js';
10
+ /**
11
+ * Custom table renderer for markdown tables
12
+ * We implement our own instead of using ink-table due to module compatibility issues
13
+ */
14
+ export const TableRenderer = ({ headers, rows, terminalWidth, }) => {
15
+ // Calculate column widths
16
+ const columnWidths = headers.map((header, index) => {
17
+ const headerWidth = header.length;
18
+ const maxRowWidth = Math.max(...rows.map((row) => (row[index] || '').length));
19
+ return Math.max(headerWidth, maxRowWidth) + 2; // Add padding
20
+ });
21
+ // Ensure table fits within terminal width
22
+ const totalWidth = columnWidths.reduce((sum, width) => sum + width + 1, 1);
23
+ const scaleFactor = totalWidth > terminalWidth ? terminalWidth / totalWidth : 1;
24
+ const adjustedWidths = columnWidths.map((width) => Math.floor(width * scaleFactor));
25
+ const renderCell = (content, width, isHeader = false) => {
26
+ // The actual space for content inside the padding
27
+ const contentWidth = Math.max(0, width - 2);
28
+ let cellContent = content;
29
+ if (content.length > contentWidth) {
30
+ if (contentWidth <= 3) {
31
+ // Not enough space for '...'
32
+ cellContent = content.substring(0, contentWidth);
33
+ }
34
+ else {
35
+ cellContent = content.substring(0, contentWidth - 3) + '...';
36
+ }
37
+ }
38
+ // Pad the content to fill the cell
39
+ const padded = cellContent.padEnd(contentWidth, ' ');
40
+ if (isHeader) {
41
+ return (_jsx(Text, { bold: true, color: Colors.AccentCyan, children: padded }));
42
+ }
43
+ return _jsx(Text, { children: padded });
44
+ };
45
+ const renderRow = (cells, isHeader = false) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { children: "\u2502 " }), cells.map((cell, index) => (_jsxs(React.Fragment, { children: [renderCell(cell, adjustedWidths[index] || 0, isHeader), _jsx(Text, { children: " \u2502 " })] }, index)))] }));
46
+ const renderSeparator = () => {
47
+ const separator = adjustedWidths
48
+ .map((width) => '─'.repeat(Math.max(0, (width || 0) - 2)))
49
+ .join('─┼─');
50
+ return _jsxs(Text, { children: ["\u251C\u2500", separator, "\u2500\u2524"] });
51
+ };
52
+ const renderTopBorder = () => {
53
+ const border = adjustedWidths
54
+ .map((width) => '─'.repeat(Math.max(0, (width || 0) - 2)))
55
+ .join('─┬─');
56
+ return _jsxs(Text, { children: ["\u250C\u2500", border, "\u2500\u2510"] });
57
+ };
58
+ const renderBottomBorder = () => {
59
+ const border = adjustedWidths
60
+ .map((width) => '─'.repeat(Math.max(0, (width || 0) - 2)))
61
+ .join('─┴─');
62
+ return _jsxs(Text, { children: ["\u2514\u2500", border, "\u2500\u2518"] });
63
+ };
64
+ return (_jsxs(Box, { flexDirection: "column", marginY: 1, children: [renderTopBorder(), renderRow(headers, true), renderSeparator(), rows.map((row, index) => (_jsx(React.Fragment, { children: renderRow(row) }, index))), renderBottomBorder()] }));
65
+ };
66
+ //# sourceMappingURL=TableRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableRenderer.js","sourceRoot":"","sources":["../../../../src/ui/utils/TableRenderer.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,OAAO,EACP,IAAI,EACJ,aAAa,GACd,EAAE,EAAE;IACH,0BAA0B;IAC1B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACjD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;QAClC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAC1B,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAChD,CAAC;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc;IAC/D,CAAC,CAAC,CAAC;IAEH,0CAA0C;IAC1C,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAA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AC,GAAG,CAAC,CAAC,CAAC,CAAC;aACzD,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,MAAC,IAAI,+BAAI,MAAM,oBAAU,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACnC,eAAe,EAAE,EACjB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,EACxB,eAAe,EAAE,EACjB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CACxB,KAAC,KAAK,CAAC,QAAQ,cAAc,SAAS,CAAC,GAAG,CAAC,IAAtB,KAAK,CAAmC,CAC9D,CAAC,EACD,kBAAkB,EAAE,IACjB,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Checks if a query string potentially represents an '@' command.
8
+ * It triggers if the query starts with '@' or contains '@' preceded by whitespace
9
+ * and followed by a non-whitespace character.
10
+ *
11
+ * @param query The input query string.
12
+ * @returns True if the query looks like an '@' command, false otherwise.
13
+ */
14
+ export declare const isAtCommand: (query: string) => boolean;
15
+ /**
16
+ * Checks if a query string potentially represents an '/' command.
17
+ * It triggers if the query starts with '/'
18
+ *
19
+ * @param query The input query string.
20
+ * @returns True if the query looks like an '/' command, false otherwise.
21
+ */
22
+ export declare const isSlashCommand: (query: string) => boolean;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Checks if a query string potentially represents an '@' command.
8
+ * It triggers if the query starts with '@' or contains '@' preceded by whitespace
9
+ * and followed by a non-whitespace character.
10
+ *
11
+ * @param query The input query string.
12
+ * @returns True if the query looks like an '@' command, false otherwise.
13
+ */
14
+ export const isAtCommand = (query) =>
15
+ // Check if starts with @ OR has a space, then @
16
+ query.startsWith('@') || /\s@/.test(query);
17
+ /**
18
+ * Checks if a query string potentially represents an '/' command.
19
+ * It triggers if the query starts with '/'
20
+ *
21
+ * @param query The input query string.
22
+ * @returns True if the query looks like an '/' command, false otherwise.
23
+ */
24
+ export const isSlashCommand = (query) => query.startsWith('/');
25
+ //# sourceMappingURL=commandUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandUtils.js","sourceRoot":"","sources":["../../../../src/ui/utils/commandUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAW,EAAE;AACpD,gDAAgD;AAChD,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { SessionMetrics, ComputedSessionStats, ModelMetrics } from '../contexts/SessionContext.js';
7
+ export declare function calculateErrorRate(metrics: ModelMetrics): number;
8
+ export declare function calculateAverageLatency(metrics: ModelMetrics): number;
9
+ export declare function calculateCacheHitRate(metrics: ModelMetrics): number;
10
+ export declare const computeSessionStats: (metrics: SessionMetrics) => ComputedSessionStats;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export function calculateErrorRate(metrics) {
7
+ if (metrics.api.totalRequests === 0) {
8
+ return 0;
9
+ }
10
+ return (metrics.api.totalErrors / metrics.api.totalRequests) * 100;
11
+ }
12
+ export function calculateAverageLatency(metrics) {
13
+ if (metrics.api.totalRequests === 0) {
14
+ return 0;
15
+ }
16
+ return metrics.api.totalLatencyMs / metrics.api.totalRequests;
17
+ }
18
+ export function calculateCacheHitRate(metrics) {
19
+ if (metrics.tokens.prompt === 0) {
20
+ return 0;
21
+ }
22
+ return (metrics.tokens.cached / metrics.tokens.prompt) * 100;
23
+ }
24
+ export const computeSessionStats = (metrics) => {
25
+ const { models, tools } = metrics;
26
+ const totalApiTime = Object.values(models).reduce((acc, model) => acc + model.api.totalLatencyMs, 0);
27
+ const totalToolTime = tools.totalDurationMs;
28
+ const agentActiveTime = totalApiTime + totalToolTime;
29
+ const apiTimePercent = agentActiveTime > 0 ? (totalApiTime / agentActiveTime) * 100 : 0;
30
+ const toolTimePercent = agentActiveTime > 0 ? (totalToolTime / agentActiveTime) * 100 : 0;
31
+ const totalCachedTokens = Object.values(models).reduce((acc, model) => acc + model.tokens.cached, 0);
32
+ const totalPromptTokens = Object.values(models).reduce((acc, model) => acc + model.tokens.prompt, 0);
33
+ const cacheEfficiency = totalPromptTokens > 0 ? (totalCachedTokens / totalPromptTokens) * 100 : 0;
34
+ const totalDecisions = tools.totalDecisions.accept +
35
+ tools.totalDecisions.reject +
36
+ tools.totalDecisions.modify;
37
+ const successRate = tools.totalCalls > 0 ? (tools.totalSuccess / tools.totalCalls) * 100 : 0;
38
+ const agreementRate = totalDecisions > 0
39
+ ? (tools.totalDecisions.accept / totalDecisions) * 100
40
+ : 0;
41
+ return {
42
+ totalApiTime,
43
+ totalToolTime,
44
+ agentActiveTime,
45
+ apiTimePercent,
46
+ toolTimePercent,
47
+ cacheEfficiency,
48
+ totalDecisions,
49
+ successRate,
50
+ agreementRate,
51
+ totalCachedTokens,
52
+ totalPromptTokens,
53
+ };
54
+ };
55
+ //# sourceMappingURL=computeStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeStats.js","sourceRoot":"","sources":["../../../../src/ui/utils/computeStats.ts"],"names":[],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AAe;QACf,cAAc;QACd,eAAe;QACf,eAAe;QACf,cAAc;QACd,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare const TOOL_SUCCESS_RATE_HIGH = 95;
7
+ export declare const TOOL_SUCCESS_RATE_MEDIUM = 85;
8
+ export declare const USER_AGREEMENT_RATE_HIGH = 75;
9
+ export declare const USER_AGREEMENT_RATE_MEDIUM = 45;
10
+ export declare const CACHE_EFFICIENCY_HIGH = 40;
11
+ export declare const CACHE_EFFICIENCY_MEDIUM = 15;
12
+ export declare const getStatusColor: (value: number, thresholds: {
13
+ green: number;
14
+ yellow: number;
15
+ }, options?: {
16
+ defaultColor?: string;
17
+ }) => string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Colors } from '../colors.js';
7
+ // --- Thresholds ---
8
+ export const TOOL_SUCCESS_RATE_HIGH = 95;
9
+ export const TOOL_SUCCESS_RATE_MEDIUM = 85;
10
+ export const USER_AGREEMENT_RATE_HIGH = 75;
11
+ export const USER_AGREEMENT_RATE_MEDIUM = 45;
12
+ export const CACHE_EFFICIENCY_HIGH = 40;
13
+ export const CACHE_EFFICIENCY_MEDIUM = 15;
14
+ // --- Color Logic ---
15
+ export const getStatusColor = (value, thresholds, options = {}) => {
16
+ if (value >= thresholds.green) {
17
+ return Colors.AccentGreen;
18
+ }
19
+ if (value >= thresholds.yellow) {
20
+ return Colors.AccentYellow;
21
+ }
22
+ return options.defaultColor || Colors.AccentRed;
23
+ };
24
+ //# sourceMappingURL=displayUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"displayUtils.js","sourceRoot":"","sources":["../../../../src/ui/utils/displayUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAqB;AACrB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,sBAAsB;AACtB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAa,EACb,UAA6C,EAC7C,UAAqC,EAAE,EACvC,EAAE;IACF,IAAI,KAAK,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,IAAI,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,SAAS,CAAC;AAClD,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AuthType } from '@google/gemini-cli-core';
7
+ export interface ApiError {
8
+ error: {
9
+ code: number;
10
+ message: string;
11
+ status: string;
12
+ details: unknown[];
13
+ };
14
+ }
15
+ export declare function parseAndFormatApiError(error: unknown, authType?: AuthType): string;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AuthType } from '@google/gemini-cli-core';
7
+ const RATE_LIMIT_ERROR_MESSAGE_GOOGLE = '\nPlease wait and try again later. To increase your limits, upgrade to a plan with higher limits, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey';
8
+ const RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI = '\nPlease wait and try again later. To increase your limits, request a quota increase through AI Studio, or switch to another /auth method';
9
+ const RATE_LIMIT_ERROR_MESSAGE_VERTEX = '\nPlease wait and try again later. To increase your limits, request a quota increase through Vertex, or switch to another /auth method';
10
+ const RATE_LIMIT_ERROR_MESSAGE_DEFAULT = 'Your request has been rate limited. Please wait and try again later.';
11
+ function isApiError(error) {
12
+ return (typeof error === 'object' &&
13
+ error !== null &&
14
+ 'error' in error &&
15
+ typeof error.error === 'object' &&
16
+ 'message' in error.error);
17
+ }
18
+ function isStructuredError(error) {
19
+ return (typeof error === 'object' &&
20
+ error !== null &&
21
+ 'message' in error &&
22
+ typeof error.message === 'string');
23
+ }
24
+ function getRateLimitMessage(authType) {
25
+ switch (authType) {
26
+ case AuthType.LOGIN_WITH_GOOGLE:
27
+ return RATE_LIMIT_ERROR_MESSAGE_GOOGLE;
28
+ case AuthType.USE_GEMINI:
29
+ return RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI;
30
+ case AuthType.USE_VERTEX_AI:
31
+ return RATE_LIMIT_ERROR_MESSAGE_VERTEX;
32
+ default:
33
+ return RATE_LIMIT_ERROR_MESSAGE_DEFAULT;
34
+ }
35
+ }
36
+ export function parseAndFormatApiError(error, authType) {
37
+ if (isStructuredError(error)) {
38
+ let text = `[API Error: ${error.message}]`;
39
+ if (error.status === 429) {
40
+ text += getRateLimitMessage(authType);
41
+ }
42
+ return text;
43
+ }
44
+ // The error message might be a string containing a JSON object.
45
+ if (typeof error === 'string') {
46
+ const jsonStart = error.indexOf('{');
47
+ if (jsonStart === -1) {
48
+ return `[API Error: ${error}]`; // Not a JSON error, return as is.
49
+ }
50
+ const jsonString = error.substring(jsonStart);
51
+ try {
52
+ const parsedError = JSON.parse(jsonString);
53
+ if (isApiError(parsedError)) {
54
+ let finalMessage = parsedError.error.message;
55
+ try {
56
+ // See if the message is a stringified JSON with another error
57
+ const nestedError = JSON.parse(finalMessage);
58
+ if (isApiError(nestedError)) {
59
+ finalMessage = nestedError.error.message;
60
+ }
61
+ }
62
+ catch (_e) {
63
+ // It's not a nested JSON error, so we just use the message as is.
64
+ }
65
+ let text = `[API Error: ${finalMessage} (Status: ${parsedError.error.status})]`;
66
+ if (parsedError.error.code === 429) {
67
+ text += getRateLimitMessage(authType);
68
+ }
69
+ return text;
70
+ }
71
+ }
72
+ catch (_e) {
73
+ // Not a valid JSON, fall through and return the original message.
74
+ }
75
+ return `[API Error: ${error}]`;
76
+ }
77
+ return '[API Error: An unknown error occurred.]';
78
+ }
79
+ //# sourceMappingURL=errorParsing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorParsing.js","sourceRoot":"","sources":["../../../../src/ui/utils/errorParsing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAmB,MAAM,yBAAyB,CAAC;AAEpE,MAAM,+BAA+B,GACnC,uMAAuM,CAAC;AAC1M,MAAM,mCAAmC,GACvC,2IAA2I,CAAC;AAC9I,MAAM,+BAA+B,GACnC,wIAAwI,CAAC;AAC3I,MAAM,gCAAgC,GACpC,sEAAsE,CAAC;AAWzE,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAO,IAAI,KAAK;QAChB,OAAQ,KAAkB,CAAC,KAAK,KAAK,QAAQ;QAC7C,SAAS,IAAK,KAAkB,CAAC,KAAK,CACvC,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAQ,KAAyB,CAAC,OAAO,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AAED,S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CAAC,WAAW,CAAC,EAAE,CAAC;wBAC5B,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC;oBAC3C,CAAC;gBACH,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACZ,kEAAkE;gBACpE,CAAC;gBACD,IAAI,IAAI,GAAG,eAAe,YAAY,aAAa,WAAW,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC;gBAChF,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;oBACnC,IAAI,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,kEAAkE;QACpE,CAAC;QACD,OAAO,eAAe,KAAK,GAAG,CAAC;IACjC,CAAC;IAED,OAAO,yCAAyC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare const formatMemoryUsage: (bytes: number) => string;
7
+ /**
8
+ * Formats a duration in milliseconds into a concise, human-readable string (e.g., "1h 5s").
9
+ * It omits any time units that are zero.
10
+ * @param milliseconds The duration in milliseconds.
11
+ * @returns A formatted string representing the duration.
12
+ */
13
+ export declare const formatDuration: (milliseconds: number) => string;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export const formatMemoryUsage = (bytes) => {
7
+ const gb = bytes / (1024 * 1024 * 1024);
8
+ if (bytes < 1024 * 1024) {
9
+ return `${(bytes / 1024).toFixed(1)} KB`;
10
+ }
11
+ if (bytes < 1024 * 1024 * 1024) {
12
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
13
+ }
14
+ return `${gb.toFixed(2)} GB`;
15
+ };
16
+ /**
17
+ * Formats a duration in milliseconds into a concise, human-readable string (e.g., "1h 5s").
18
+ * It omits any time units that are zero.
19
+ * @param milliseconds The duration in milliseconds.
20
+ * @returns A formatted string representing the duration.
21
+ */
22
+ export const formatDuration = (milliseconds) => {
23
+ if (milliseconds <= 0) {
24
+ return '0s';
25
+ }
26
+ if (milliseconds < 1000) {
27
+ return `${Math.round(milliseconds)}ms`;
28
+ }
29
+ const totalSeconds = milliseconds / 1000;
30
+ if (totalSeconds < 60) {
31
+ return `${totalSeconds.toFixed(1)}s`;
32
+ }
33
+ const hours = Math.floor(totalSeconds / 3600);
34
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
35
+ const seconds = Math.floor(totalSeconds % 60);
36
+ const parts = [];
37
+ if (hours > 0) {
38
+ parts.push(`${hours}h`);
39
+ }
40
+ if (minutes > 0) {
41
+ parts.push(`${minutes}m`);
42
+ }
43
+ if (seconds > 0) {
44
+ parts.push(`${seconds}s`);
45
+ }
46
+ // If all parts are zero (e.g., exactly 1 hour), return the largest unit.
47
+ if (parts.length === 0) {
48
+ if (hours > 0)
49
+ return `${hours}h`;
50
+ if (minutes > 0)
51
+ return `${minutes}m`;
52
+ return `${seconds}s`;
53
+ }
54
+ return parts.join(' ');
55
+ };
56
+ //# sourceMappingURL=formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../../src/ui/utils/formatters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE;IACzD,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACxC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,GA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AAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,yEAAyE;IACzE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,GAAG,KAAK,GAAG,CAAC;QAClC,IAAI,OAAO,GAAG,CAAC;YAAE,OAAO,GAAG,OAAO,GAAG,CAAC;QACtC,OAAO,GAAG,OAAO,GAAG,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare const findLastSafeSplitPoint: (content: string) => number;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /*
7
+ **Background & Purpose:**
8
+
9
+ The `findSafeSplitPoint` function is designed to address the challenge of displaying or processing large, potentially streaming, pieces of Markdown text. When content (e.g., from an LLM like Gemini) arrives in chunks or grows too large for a single display unit (like a message bubble), it needs to be split. A naive split (e.g., just at a character limit) can break Markdown formatting, especially critical for multi-line elements like code blocks, lists, or blockquotes, leading to incorrect rendering.
10
+
11
+ This function aims to find an *intelligent* or "safe" index within the provided `content` string at which to make such a split, prioritizing the preservation of Markdown integrity.
12
+
13
+ **Key Expectations & Behavior (Prioritized):**
14
+
15
+ 1. **No Split if Short Enough:**
16
+ * If `content.length` is less than or equal to `idealMaxLength`, the function should return `content.length` (indicating no split is necessary for length reasons).
17
+
18
+ 2. **Code Block Integrity (Highest Priority for Safety):**
19
+ * The function must try to avoid splitting *inside* a fenced code block (i.e., between ` ``` ` and ` ``` `).
20
+ * If `idealMaxLength` falls within a code block:
21
+ * The function will attempt to return an index that splits the content *before* the start of that code block.
22
+ * If a code block starts at the very beginning of the `content` and `idealMaxLength` falls within it (meaning the block itself is too long for the first chunk), the function might return `0`. This effectively makes the first chunk empty, pushing the entire oversized code block to the second part of the split.
23
+ * When considering splits near code blocks, the function prefers to keep the entire code block intact in one of the resulting chunks.
24
+
25
+ 3. **Markdown-Aware Newline Splitting (If Not Governed by Code Block Logic):**
26
+ * If `idealMaxLength` does not fall within a code block (or after code block considerations have been made), the function will look for natural break points by scanning backwards from `idealMaxLength`:
27
+ * **Paragraph Breaks:** It prioritizes splitting after a double newline (`\n\n`), as this typically signifies the end of a paragraph or a block-level element.
28
+ * **Single Line Breaks:** If no double newline is found in a suitable range, it will look for a single newline (`\n`).
29
+ * Any newline chosen as a split point must also not be inside a code block.
30
+
31
+ 4. **Fallback to `idealMaxLength`:**
32
+ * If no "safer" split point (respecting code blocks or finding suitable newlines) is identified before or at `idealMaxLength`, and `idealMaxLength` itself is not determined to be an unsafe split point (e.g., inside a code block), the function may return a length larger than `idealMaxLength`, again it CANNOT break markdown formatting. This could happen with very long lines of text without Markdown block structures or newlines.
33
+
34
+ **In essence, `findSafeSplitPoint` tries to be a good Markdown citizen when forced to divide content, preferring structural boundaries over arbitrary character limits, with a strong emphasis on not corrupting code blocks.**
35
+ */
36
+ /**
37
+ * Checks if a given character index within a string is inside a fenced (```) code block.
38
+ * @param content The full string content.
39
+ * @param indexToTest The character index to test.
40
+ * @returns True if the index is inside a code block's content, false otherwise.
41
+ */
42
+ const isIndexInsideCodeBlock = (content, indexToTest) => {
43
+ let fenceCount = 0;
44
+ let searchPos = 0;
45
+ while (searchPos < content.length) {
46
+ const nextFence = content.indexOf('```', searchPos);
47
+ if (nextFence === -1 || nextFence >= indexToTest) {
48
+ break;
49
+ }
50
+ fenceCount++;
51
+ searchPos = nextFence + 3;
52
+ }
53
+ return fenceCount % 2 === 1;
54
+ };
55
+ /**
56
+ * Finds the starting index of the code block that encloses the given index.
57
+ * Returns -1 if the index is not inside a code block.
58
+ * @param content The markdown content.
59
+ * @param index The index to check.
60
+ * @returns Start index of the enclosing code block or -1.
61
+ */
62
+ const findEnclosingCodeBlockStart = (content, index) => {
63
+ if (!isIndexInsideCodeBlock(content, index)) {
64
+ return -1;
65
+ }
66
+ let currentSearchPos = 0;
67
+ while (currentSearchPos < index) {
68
+ const blockStartIndex = content.indexOf('```', currentSearchPos);
69
+ if (blockStartIndex === -1 || blockStartIndex >= index) {
70
+ break;
71
+ }
72
+ const blockEndIndex = content.indexOf('```', blockStartIndex + 3);
73
+ if (blockStartIndex < index) {
74
+ if (blockEndIndex === -1 || index < blockEndIndex + 3) {
75
+ return blockStartIndex;
76
+ }
77
+ }
78
+ if (blockEndIndex === -1)
79
+ break;
80
+ currentSearchPos = blockEndIndex + 3;
81
+ }
82
+ return -1;
83
+ };
84
+ export const findLastSafeSplitPoint = (content) => {
85
+ const enclosingBlockStart = findEnclosingCodeBlockStart(content, content.length);
86
+ if (enclosingBlockStart !== -1) {
87
+ // The end of the content is contained in a code block. Split right before.
88
+ return enclosingBlockStart;
89
+ }
90
+ // Search for the last double newline (\n\n) not in a code block.
91
+ let searchStartIndex = content.length;
92
+ while (searchStartIndex >= 0) {
93
+ const dnlIndex = content.lastIndexOf('\n\n', searchStartIndex);
94
+ if (dnlIndex === -1) {
95
+ // No more double newlines found.
96
+ break;
97
+ }
98
+ const potentialSplitPoint = dnlIndex + 2;
99
+ if (!isIndexInsideCodeBlock(content, potentialSplitPoint)) {
100
+ return potentialSplitPoint;
101
+ }
102
+ // If potentialSplitPoint was inside a code block,
103
+ // the next search should start *before* the \n\n we just found to ensure progress.
104
+ searchStartIndex = dnlIndex - 1;
105
+ }
106
+ // If no safe double newline is found, return content.length
107
+ // to keep the entire content as one piece.
108
+ return content.length;
109
+ };
110
+ //# sourceMappingURL=markdownUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownUtilities.js","sourceRoot":"","sources":["../../../../src/ui/utils/markdownUtilities.ts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Aa,GAAG,CAAC,EAAE,CAAC;gBACtD,OAAO,eAAe,CAAC;YACzB,CAAC;QACH,CAAC;QACD,IAAI,aAAa,KAAK,CAAC,CAAC;YAAE,MAAM;QAChC,gBAAgB,GAAG,aAAa,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAE,EAAE;IACxD,MAAM,mBAAmB,GAAG,2BAA2B,CACrD,OAAO,EACP,OAAO,CAAC,MAAM,CACf,CAAC;IACF,IAAI,mBAAmB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,2EAA2E;QAC3E,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,iEAAiE;IACjE,IAAI,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IACtC,OAAO,gBAAgB,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAC/D,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YACpB,iCAAiC;YACjC,MAAM;QACR,CAAC;QAED,MAAM,mBAAmB,GAAG,QAAQ,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,CAAC;YAC1D,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QAED,kDAAkD;QAClD,mFAAmF;QACnF,gBAAgB,GAAG,QAAQ,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,4DAA4D;IAC5D,2CAA2C;IAC3C,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Calculates the maximum width of a multi-line ASCII art string.
8
+ * @param asciiArt The ASCII art string.
9
+ * @returns The length of the longest line in the ASCII art.
10
+ */
11
+ export declare const getAsciiArtWidth: (asciiArt: string) => number;
12
+ /**
13
+ * Checks if a Buffer is likely binary by testing for the presence of a NULL byte.
14
+ * The presence of a NULL byte is a strong indicator that the data is not plain text.
15
+ * @param data The Buffer to check.
16
+ * @param sampleSize The number of bytes from the start of the buffer to test.
17
+ * @returns True if a NULL byte is found, false otherwise.
18
+ */
19
+ export declare function isBinary(data: Buffer | null | undefined, sampleSize?: number): boolean;
20
+ export declare function toCodePoints(str: string): string[];
21
+ export declare function cpLen(str: string): number;
22
+ export declare function cpSlice(str: string, start: number, end?: number): string;