@google/gemini-cli 0.0.3-preview.4

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 (883) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +310 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/google-gemini-cli-0.3.0-preview.3.tgz +0 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.js +29 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/package.json +85 -0
  9. package/dist/src/commands/extensions/disable.d.ts +14 -0
  10. package/dist/src/commands/extensions/disable.js +42 -0
  11. package/dist/src/commands/extensions/disable.js.map +1 -0
  12. package/dist/src/commands/extensions/enable.d.ts +14 -0
  13. package/dist/src/commands/extensions/enable.js +48 -0
  14. package/dist/src/commands/extensions/enable.js.map +1 -0
  15. package/dist/src/commands/extensions/install.d.ts +13 -0
  16. package/dist/src/commands/extensions/install.js +48 -0
  17. package/dist/src/commands/extensions/install.js.map +1 -0
  18. package/dist/src/commands/extensions/install.test.d.ts +6 -0
  19. package/dist/src/commands/extensions/install.test.js +19 -0
  20. package/dist/src/commands/extensions/install.test.js.map +1 -0
  21. package/dist/src/commands/extensions/list.d.ts +8 -0
  22. package/dist/src/commands/extensions/list.js +32 -0
  23. package/dist/src/commands/extensions/list.js.map +1 -0
  24. package/dist/src/commands/extensions/uninstall.d.ts +12 -0
  25. package/dist/src/commands/extensions/uninstall.js +38 -0
  26. package/dist/src/commands/extensions/uninstall.js.map +1 -0
  27. package/dist/src/commands/extensions/uninstall.test.d.ts +6 -0
  28. package/dist/src/commands/extensions/uninstall.test.js +15 -0
  29. package/dist/src/commands/extensions/uninstall.test.js.map +1 -0
  30. package/dist/src/commands/extensions/update.d.ts +12 -0
  31. package/dist/src/commands/extensions/update.js +38 -0
  32. package/dist/src/commands/extensions/update.js.map +1 -0
  33. package/dist/src/commands/extensions.d.ts +7 -0
  34. package/dist/src/commands/extensions.js +29 -0
  35. package/dist/src/commands/extensions.js.map +1 -0
  36. package/dist/src/commands/mcp/add.d.ts +7 -0
  37. package/dist/src/commands/mcp/add.js +166 -0
  38. package/dist/src/commands/mcp/add.js.map +1 -0
  39. package/dist/src/commands/mcp/list.d.ts +8 -0
  40. package/dist/src/commands/mcp/list.js +110 -0
  41. package/dist/src/commands/mcp/list.js.map +1 -0
  42. package/dist/src/commands/mcp/remove.d.ts +7 -0
  43. package/dist/src/commands/mcp/remove.js +44 -0
  44. package/dist/src/commands/mcp/remove.js.map +1 -0
  45. package/dist/src/commands/mcp.d.ts +7 -0
  46. package/dist/src/commands/mcp.js +23 -0
  47. package/dist/src/commands/mcp.js.map +1 -0
  48. package/dist/src/config/auth.d.ts +6 -0
  49. package/dist/src/config/auth.js +34 -0
  50. package/dist/src/config/auth.js.map +1 -0
  51. package/dist/src/config/auth.test.d.ts +6 -0
  52. package/dist/src/config/auth.test.js +57 -0
  53. package/dist/src/config/auth.test.js.map +1 -0
  54. package/dist/src/config/config.d.ts +42 -0
  55. package/dist/src/config/config.js +446 -0
  56. package/dist/src/config/config.js.map +1 -0
  57. package/dist/src/config/extension.d.ts +59 -0
  58. package/dist/src/config/extension.js +372 -0
  59. package/dist/src/config/extension.js.map +1 -0
  60. package/dist/src/config/extensions/variableSchema.d.ts +28 -0
  61. package/dist/src/config/extensions/variableSchema.js +18 -0
  62. package/dist/src/config/extensions/variableSchema.js.map +1 -0
  63. package/dist/src/config/extensions/variables.d.ts +17 -0
  64. package/dist/src/config/extensions/variables.js +40 -0
  65. package/dist/src/config/extensions/variables.js.map +1 -0
  66. package/dist/src/config/extensions/variables.test.d.ts +6 -0
  67. package/dist/src/config/extensions/variables.test.js +17 -0
  68. package/dist/src/config/extensions/variables.test.js.map +1 -0
  69. package/dist/src/config/keyBindings.d.ts +66 -0
  70. package/dist/src/config/keyBindings.js +141 -0
  71. package/dist/src/config/keyBindings.js.map +1 -0
  72. package/dist/src/config/keyBindings.test.d.ts +6 -0
  73. package/dist/src/config/keyBindings.test.js +51 -0
  74. package/dist/src/config/keyBindings.test.js.map +1 -0
  75. package/dist/src/config/sandboxConfig.d.ts +13 -0
  76. package/dist/src/config/sandboxConfig.js +73 -0
  77. package/dist/src/config/sandboxConfig.js.map +1 -0
  78. package/dist/src/config/settings.d.ts +62 -0
  79. package/dist/src/config/settings.js +656 -0
  80. package/dist/src/config/settings.js.map +1 -0
  81. package/dist/src/config/settingsSchema.d.ts +750 -0
  82. package/dist/src/config/settingsSchema.js +723 -0
  83. package/dist/src/config/settingsSchema.js.map +1 -0
  84. package/dist/src/config/settingsSchema.test.d.ts +6 -0
  85. package/dist/src/config/settingsSchema.test.js +193 -0
  86. package/dist/src/config/settingsSchema.test.js.map +1 -0
  87. package/dist/src/config/trustedFolders.d.ts +37 -0
  88. package/dist/src/config/trustedFolders.js +118 -0
  89. package/dist/src/config/trustedFolders.js.map +1 -0
  90. package/dist/src/config/trustedFolders.test.d.ts +6 -0
  91. package/dist/src/config/trustedFolders.test.js +164 -0
  92. package/dist/src/config/trustedFolders.test.js.map +1 -0
  93. package/dist/src/gemini.d.ts +11 -0
  94. package/dist/src/gemini.js +289 -0
  95. package/dist/src/gemini.js.map +1 -0
  96. package/dist/src/gemini.test.d.ts +6 -0
  97. package/dist/src/gemini.test.js +247 -0
  98. package/dist/src/gemini.test.js.map +1 -0
  99. package/dist/src/generated/git-commit.d.ts +7 -0
  100. package/dist/src/generated/git-commit.js +10 -0
  101. package/dist/src/generated/git-commit.js.map +1 -0
  102. package/dist/src/nonInteractiveCli.d.ts +7 -0
  103. package/dist/src/nonInteractiveCli.js +92 -0
  104. package/dist/src/nonInteractiveCli.js.map +1 -0
  105. package/dist/src/patches/is-in-ci.d.ts +7 -0
  106. package/dist/src/patches/is-in-ci.js +15 -0
  107. package/dist/src/patches/is-in-ci.js.map +1 -0
  108. package/dist/src/services/BuiltinCommandLoader.d.ts +24 -0
  109. package/dist/src/services/BuiltinCommandLoader.js +82 -0
  110. package/dist/src/services/BuiltinCommandLoader.js.map +1 -0
  111. package/dist/src/services/BuiltinCommandLoader.test.d.ts +6 -0
  112. package/dist/src/services/BuiltinCommandLoader.test.js +108 -0
  113. package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -0
  114. package/dist/src/services/CommandService.d.ts +55 -0
  115. package/dist/src/services/CommandService.js +90 -0
  116. package/dist/src/services/CommandService.js.map +1 -0
  117. package/dist/src/services/CommandService.test.d.ts +6 -0
  118. package/dist/src/services/CommandService.test.js +233 -0
  119. package/dist/src/services/CommandService.test.js.map +1 -0
  120. package/dist/src/services/FileCommandLoader.d.ts +49 -0
  121. package/dist/src/services/FileCommandLoader.js +220 -0
  122. package/dist/src/services/FileCommandLoader.js.map +1 -0
  123. package/dist/src/services/McpPromptLoader.d.ts +35 -0
  124. package/dist/src/services/McpPromptLoader.js +218 -0
  125. package/dist/src/services/McpPromptLoader.js.map +1 -0
  126. package/dist/src/services/McpPromptLoader.test.d.ts +6 -0
  127. package/dist/src/services/McpPromptLoader.test.js +114 -0
  128. package/dist/src/services/McpPromptLoader.test.js.map +1 -0
  129. package/dist/src/services/prompt-processors/argumentProcessor.d.ts +16 -0
  130. package/dist/src/services/prompt-processors/argumentProcessor.js +21 -0
  131. package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -0
  132. package/dist/src/services/prompt-processors/atFileProcessor.d.ts +12 -0
  133. package/dist/src/services/prompt-processors/atFileProcessor.js +62 -0
  134. package/dist/src/services/prompt-processors/atFileProcessor.js.map +1 -0
  135. package/dist/src/services/prompt-processors/atFileProcessor.test.d.ts +6 -0
  136. package/dist/src/services/prompt-processors/atFileProcessor.test.js +174 -0
  137. package/dist/src/services/prompt-processors/atFileProcessor.test.js.map +1 -0
  138. package/dist/src/services/prompt-processors/injectionParser.d.ts +29 -0
  139. package/dist/src/services/prompt-processors/injectionParser.js +60 -0
  140. package/dist/src/services/prompt-processors/injectionParser.js.map +1 -0
  141. package/dist/src/services/prompt-processors/injectionParser.test.d.ts +6 -0
  142. package/dist/src/services/prompt-processors/injectionParser.test.js +189 -0
  143. package/dist/src/services/prompt-processors/injectionParser.test.js.map +1 -0
  144. package/dist/src/services/prompt-processors/shellProcessor.d.ts +27 -0
  145. package/dist/src/services/prompt-processors/shellProcessor.js +121 -0
  146. package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
  147. package/dist/src/services/prompt-processors/types.d.ts +45 -0
  148. package/dist/src/services/prompt-processors/types.js +20 -0
  149. package/dist/src/services/prompt-processors/types.js.map +1 -0
  150. package/dist/src/services/types.d.ts +22 -0
  151. package/dist/src/services/types.js +7 -0
  152. package/dist/src/services/types.js.map +1 -0
  153. package/dist/src/test-utils/customMatchers.d.ts +14 -0
  154. package/dist/src/test-utils/customMatchers.js +40 -0
  155. package/dist/src/test-utils/customMatchers.js.map +1 -0
  156. package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
  157. package/dist/src/test-utils/mockCommandContext.js +86 -0
  158. package/dist/src/test-utils/mockCommandContext.js.map +1 -0
  159. package/dist/src/test-utils/mockCommandContext.test.d.ts +6 -0
  160. package/dist/src/test-utils/mockCommandContext.test.js +51 -0
  161. package/dist/src/test-utils/mockCommandContext.test.js.map +1 -0
  162. package/dist/src/test-utils/render.d.ts +8 -0
  163. package/dist/src/test-utils/render.js +10 -0
  164. package/dist/src/test-utils/render.js.map +1 -0
  165. package/dist/src/ui/App.d.ts +15 -0
  166. package/dist/src/ui/App.js +676 -0
  167. package/dist/src/ui/App.js.map +1 -0
  168. package/dist/src/ui/IdeIntegrationNudge.d.ts +16 -0
  169. package/dist/src/ui/IdeIntegrationNudge.js +47 -0
  170. package/dist/src/ui/IdeIntegrationNudge.js.map +1 -0
  171. package/dist/src/ui/colors.d.ts +7 -0
  172. package/dist/src/ui/colors.js +54 -0
  173. package/dist/src/ui/colors.js.map +1 -0
  174. package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
  175. package/dist/src/ui/commands/aboutCommand.js +43 -0
  176. package/dist/src/ui/commands/aboutCommand.js.map +1 -0
  177. package/dist/src/ui/commands/authCommand.d.ts +7 -0
  178. package/dist/src/ui/commands/authCommand.js +16 -0
  179. package/dist/src/ui/commands/authCommand.js.map +1 -0
  180. package/dist/src/ui/commands/bugCommand.d.ts +7 -0
  181. package/dist/src/ui/commands/bugCommand.js +71 -0
  182. package/dist/src/ui/commands/bugCommand.js.map +1 -0
  183. package/dist/src/ui/commands/chatCommand.d.ts +7 -0
  184. package/dist/src/ui/commands/chatCommand.js +235 -0
  185. package/dist/src/ui/commands/chatCommand.js.map +1 -0
  186. package/dist/src/ui/commands/clearCommand.d.ts +7 -0
  187. package/dist/src/ui/commands/clearCommand.js +27 -0
  188. package/dist/src/ui/commands/clearCommand.js.map +1 -0
  189. package/dist/src/ui/commands/compressCommand.d.ts +7 -0
  190. package/dist/src/ui/commands/compressCommand.js +66 -0
  191. package/dist/src/ui/commands/compressCommand.js.map +1 -0
  192. package/dist/src/ui/commands/copyCommand.d.ts +7 -0
  193. package/dist/src/ui/commands/copyCommand.js +59 -0
  194. package/dist/src/ui/commands/copyCommand.js.map +1 -0
  195. package/dist/src/ui/commands/corgiCommand.d.ts +7 -0
  196. package/dist/src/ui/commands/corgiCommand.js +15 -0
  197. package/dist/src/ui/commands/corgiCommand.js.map +1 -0
  198. package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
  199. package/dist/src/ui/commands/directoryCommand.js +135 -0
  200. package/dist/src/ui/commands/directoryCommand.js.map +1 -0
  201. package/dist/src/ui/commands/docsCommand.d.ts +7 -0
  202. package/dist/src/ui/commands/docsCommand.js +31 -0
  203. package/dist/src/ui/commands/docsCommand.js.map +1 -0
  204. package/dist/src/ui/commands/editorCommand.d.ts +7 -0
  205. package/dist/src/ui/commands/editorCommand.js +16 -0
  206. package/dist/src/ui/commands/editorCommand.js.map +1 -0
  207. package/dist/src/ui/commands/extensionsCommand.d.ts +7 -0
  208. package/dist/src/ui/commands/extensionsCommand.js +31 -0
  209. package/dist/src/ui/commands/extensionsCommand.js.map +1 -0
  210. package/dist/src/ui/commands/helpCommand.d.ts +7 -0
  211. package/dist/src/ui/commands/helpCommand.js +21 -0
  212. package/dist/src/ui/commands/helpCommand.js.map +1 -0
  213. package/dist/src/ui/commands/ideCommand.d.ts +8 -0
  214. package/dist/src/ui/commands/ideCommand.js +216 -0
  215. package/dist/src/ui/commands/ideCommand.js.map +1 -0
  216. package/dist/src/ui/commands/initCommand.d.ts +7 -0
  217. package/dist/src/ui/commands/initCommand.js +76 -0
  218. package/dist/src/ui/commands/initCommand.js.map +1 -0
  219. package/dist/src/ui/commands/mcpCommand.d.ts +7 -0
  220. package/dist/src/ui/commands/mcpCommand.js +424 -0
  221. package/dist/src/ui/commands/mcpCommand.js.map +1 -0
  222. package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
  223. package/dist/src/ui/commands/memoryCommand.js +92 -0
  224. package/dist/src/ui/commands/memoryCommand.js.map +1 -0
  225. package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
  226. package/dist/src/ui/commands/privacyCommand.js +16 -0
  227. package/dist/src/ui/commands/privacyCommand.js.map +1 -0
  228. package/dist/src/ui/commands/quitCommand.d.ts +7 -0
  229. package/dist/src/ui/commands/quitCommand.js +34 -0
  230. package/dist/src/ui/commands/quitCommand.js.map +1 -0
  231. package/dist/src/ui/commands/restoreCommand.d.ts +8 -0
  232. package/dist/src/ui/commands/restoreCommand.js +124 -0
  233. package/dist/src/ui/commands/restoreCommand.js.map +1 -0
  234. package/dist/src/ui/commands/settingsCommand.d.ts +7 -0
  235. package/dist/src/ui/commands/settingsCommand.js +16 -0
  236. package/dist/src/ui/commands/settingsCommand.js.map +1 -0
  237. package/dist/src/ui/commands/setupGithubCommand.d.ts +9 -0
  238. package/dist/src/ui/commands/setupGithubCommand.js +154 -0
  239. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
  240. package/dist/src/ui/commands/setupGithubCommand.test.d.ts +6 -0
  241. package/dist/src/ui/commands/setupGithubCommand.test.js +167 -0
  242. package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -0
  243. package/dist/src/ui/commands/statsCommand.d.ts +7 -0
  244. package/dist/src/ui/commands/statsCommand.js +54 -0
  245. package/dist/src/ui/commands/statsCommand.js.map +1 -0
  246. package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
  247. package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
  248. package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
  249. package/dist/src/ui/commands/themeCommand.d.ts +7 -0
  250. package/dist/src/ui/commands/themeCommand.js +16 -0
  251. package/dist/src/ui/commands/themeCommand.js.map +1 -0
  252. package/dist/src/ui/commands/toolsCommand.d.ts +7 -0
  253. package/dist/src/ui/commands/toolsCommand.js +56 -0
  254. package/dist/src/ui/commands/toolsCommand.js.map +1 -0
  255. package/dist/src/ui/commands/types.d.ts +148 -0
  256. package/dist/src/ui/commands/types.js +13 -0
  257. package/dist/src/ui/commands/types.js.map +1 -0
  258. package/dist/src/ui/commands/vimCommand.d.ts +7 -0
  259. package/dist/src/ui/commands/vimCommand.js +23 -0
  260. package/dist/src/ui/commands/vimCommand.js.map +1 -0
  261. package/dist/src/ui/components/AboutBox.d.ts +17 -0
  262. package/dist/src/ui/components/AboutBox.js +6 -0
  263. package/dist/src/ui/components/AboutBox.js.map +1 -0
  264. package/dist/src/ui/components/AsciiArt.d.ts +8 -0
  265. package/dist/src/ui/components/AsciiArt.js +36 -0
  266. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  267. package/dist/src/ui/components/AuthDialog.d.ts +16 -0
  268. package/dist/src/ui/components/AuthDialog.js +92 -0
  269. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  270. package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
  271. package/dist/src/ui/components/AuthDialog.test.js +276 -0
  272. package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
  273. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  274. package/dist/src/ui/components/AuthInProgress.js +23 -0
  275. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  276. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  277. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  278. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  279. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  280. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  281. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  282. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +20 -0
  283. package/dist/src/ui/components/ContextSummaryDisplay.js +66 -0
  284. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  285. package/dist/src/ui/components/ContextUsageDisplay.d.ts +9 -0
  286. package/dist/src/ui/components/ContextUsageDisplay.js +14 -0
  287. package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -0
  288. package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
  289. package/dist/src/ui/components/DebugProfiler.js +27 -0
  290. package/dist/src/ui/components/DebugProfiler.js.map +1 -0
  291. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  292. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  293. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  294. package/dist/src/ui/components/EditorSettingsDialog.d.ts +16 -0
  295. package/dist/src/ui/components/EditorSettingsDialog.js +71 -0
  296. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  297. package/dist/src/ui/components/FolderTrustDialog.d.ts +17 -0
  298. package/dist/src/ui/components/FolderTrustDialog.js +45 -0
  299. package/dist/src/ui/components/FolderTrustDialog.js.map +1 -0
  300. package/dist/src/ui/components/FolderTrustDialog.test.d.ts +6 -0
  301. package/dist/src/ui/components/FolderTrustDialog.test.js +63 -0
  302. package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -0
  303. package/dist/src/ui/components/Footer.d.ts +23 -0
  304. package/dist/src/ui/components/Footer.js +25 -0
  305. package/dist/src/ui/components/Footer.js.map +1 -0
  306. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  307. package/dist/src/ui/components/GeminiRespondingSpinner.js +18 -0
  308. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  309. package/dist/src/ui/components/Header.d.ts +13 -0
  310. package/dist/src/ui/components/Header.js +28 -0
  311. package/dist/src/ui/components/Header.js.map +1 -0
  312. package/dist/src/ui/components/Header.test.d.ts +6 -0
  313. package/dist/src/ui/components/Header.test.js +37 -0
  314. package/dist/src/ui/components/Header.test.js.map +1 -0
  315. package/dist/src/ui/components/Help.d.ts +12 -0
  316. package/dist/src/ui/components/Help.js +10 -0
  317. package/dist/src/ui/components/Help.js.map +1 -0
  318. package/dist/src/ui/components/HistoryItemDisplay.d.ts +20 -0
  319. package/dist/src/ui/components/HistoryItemDisplay.js +18 -0
  320. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  321. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
  322. package/dist/src/ui/components/HistoryItemDisplay.test.js +93 -0
  323. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
  324. package/dist/src/ui/components/InputPrompt.d.ts +28 -0
  325. package/dist/src/ui/components/InputPrompt.js +562 -0
  326. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  327. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  328. package/dist/src/ui/components/LoadingIndicator.js +25 -0
  329. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  330. package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
  331. package/dist/src/ui/components/LoadingIndicator.test.js +190 -0
  332. package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
  333. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  334. package/dist/src/ui/components/MemoryUsageDisplay.js +22 -0
  335. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  336. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  337. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  338. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  339. package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
  340. package/dist/src/ui/components/PrepareLabel.js +16 -0
  341. package/dist/src/ui/components/PrepareLabel.js.map +1 -0
  342. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  343. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  344. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  345. package/dist/src/ui/components/SettingsDialog.d.ts +15 -0
  346. package/dist/src/ui/components/SettingsDialog.js +550 -0
  347. package/dist/src/ui/components/SettingsDialog.js.map +1 -0
  348. package/dist/src/ui/components/SettingsDialog.test.d.ts +6 -0
  349. package/dist/src/ui/components/SettingsDialog.test.js +646 -0
  350. package/dist/src/ui/components/SettingsDialog.test.js.map +1 -0
  351. package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
  352. package/dist/src/ui/components/ShellConfirmationDialog.js +46 -0
  353. package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
  354. package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +6 -0
  355. package/dist/src/ui/components/ShellConfirmationDialog.test.js +40 -0
  356. package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -0
  357. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  358. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  359. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  360. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  361. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  362. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  363. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  364. package/dist/src/ui/components/StatsDisplay.js +43 -0
  365. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  366. package/dist/src/ui/components/SuggestionsDisplay.d.ts +22 -0
  367. package/dist/src/ui/components/SuggestionsDisplay.js +40 -0
  368. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  369. package/dist/src/ui/components/ThemeDialog.d.ts +20 -0
  370. package/dist/src/ui/components/ThemeDialog.js +138 -0
  371. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  372. package/dist/src/ui/components/Tips.d.ts +12 -0
  373. package/dist/src/ui/components/Tips.js +9 -0
  374. package/dist/src/ui/components/Tips.js.map +1 -0
  375. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  376. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  377. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  378. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  379. package/dist/src/ui/components/UpdateNotification.js +10 -0
  380. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  381. package/dist/src/ui/components/WorkspaceMigrationDialog.d.ts +11 -0
  382. package/dist/src/ui/components/WorkspaceMigrationDialog.js +42 -0
  383. package/dist/src/ui/components/WorkspaceMigrationDialog.js.map +1 -0
  384. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  385. package/dist/src/ui/components/messages/CompressionMessage.js +17 -0
  386. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  387. package/dist/src/ui/components/messages/DiffRenderer.d.ts +16 -0
  388. package/dist/src/ui/components/messages/DiffRenderer.js +226 -0
  389. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  390. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
  391. package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
  392. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
  393. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  394. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  395. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  396. package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
  397. package/dist/src/ui/components/messages/GeminiMessage.js +11 -0
  398. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  399. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  400. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  401. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  402. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  403. package/dist/src/ui/components/messages/InfoMessage.js +10 -0
  404. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  405. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  406. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +162 -0
  407. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  408. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
  409. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +122 -0
  410. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
  411. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  412. package/dist/src/ui/components/messages/ToolGroupMessage.js +50 -0
  413. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  414. package/dist/src/ui/components/messages/ToolGroupMessage.test.d.ts +6 -0
  415. package/dist/src/ui/components/messages/ToolGroupMessage.test.js +259 -0
  416. package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -0
  417. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  418. package/dist/src/ui/components/messages/ToolMessage.js +62 -0
  419. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  420. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
  421. package/dist/src/ui/components/messages/ToolMessage.test.js +118 -0
  422. package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
  423. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  424. package/dist/src/ui/components/messages/UserMessage.js +14 -0
  425. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  426. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  427. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  428. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  429. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  430. package/dist/src/ui/components/shared/MaxSizedBox.js +451 -0
  431. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  432. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
  433. package/dist/src/ui/components/shared/MaxSizedBox.test.js +154 -0
  434. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
  435. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +46 -0
  436. package/dist/src/ui/components/shared/RadioButtonSelect.js +116 -0
  437. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  438. package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +6 -0
  439. package/dist/src/ui/components/shared/RadioButtonSelect.test.js +111 -0
  440. package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -0
  441. package/dist/src/ui/components/shared/text-buffer.d.ts +467 -0
  442. package/dist/src/ui/components/shared/text-buffer.js +1489 -0
  443. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  444. package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
  445. package/dist/src/ui/components/shared/vim-buffer-actions.js +552 -0
  446. package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
  447. package/dist/src/ui/constants.d.ts +17 -0
  448. package/dist/src/ui/constants.js +22 -0
  449. package/dist/src/ui/constants.js.map +1 -0
  450. package/dist/src/ui/contexts/KeypressContext.d.ts +31 -0
  451. package/dist/src/ui/contexts/KeypressContext.js +318 -0
  452. package/dist/src/ui/contexts/KeypressContext.js.map +1 -0
  453. package/dist/src/ui/contexts/KeypressContext.test.d.ts +6 -0
  454. package/dist/src/ui/contexts/KeypressContext.test.js +385 -0
  455. package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -0
  456. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  457. package/dist/src/ui/contexts/OverflowContext.js +38 -0
  458. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  459. package/dist/src/ui/contexts/SessionContext.d.ts +39 -0
  460. package/dist/src/ui/contexts/SessionContext.js +55 -0
  461. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  462. package/dist/src/ui/contexts/SettingsContext.d.ts +9 -0
  463. package/dist/src/ui/contexts/SettingsContext.js +15 -0
  464. package/dist/src/ui/contexts/SettingsContext.js.map +1 -0
  465. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  466. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  467. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  468. package/dist/src/ui/contexts/VimModeContext.d.ts +19 -0
  469. package/dist/src/ui/contexts/VimModeContext.js +48 -0
  470. package/dist/src/ui/contexts/VimModeContext.js.map +1 -0
  471. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  472. package/dist/src/ui/editors/editorSettingsManager.js +47 -0
  473. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  474. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  475. package/dist/src/ui/hooks/atCommandProcessor.js +364 -0
  476. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  477. package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +6 -0
  478. package/dist/src/ui/hooks/atCommandProcessor.test.js +832 -0
  479. package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -0
  480. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +17 -0
  481. package/dist/src/ui/hooks/shellCommandProcessor.js +234 -0
  482. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  483. package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +6 -0
  484. package/dist/src/ui/hooks/shellCommandProcessor.test.js +325 -0
  485. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -0
  486. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +29 -0
  487. package/dist/src/ui/hooks/slashCommandProcessor.js +443 -0
  488. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  489. package/dist/src/ui/hooks/useAtCompletion.d.ts +23 -0
  490. package/dist/src/ui/hooks/useAtCompletion.js +179 -0
  491. package/dist/src/ui/hooks/useAtCompletion.js.map +1 -0
  492. package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
  493. package/dist/src/ui/hooks/useAuthCommand.js +66 -0
  494. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  495. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +12 -0
  496. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +46 -0
  497. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  498. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +6 -0
  499. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +311 -0
  500. package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -0
  501. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  502. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  503. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  504. package/dist/src/ui/hooks/useCommandCompletion.d.ts +32 -0
  505. package/dist/src/ui/hooks/useCommandCompletion.js +186 -0
  506. package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -0
  507. package/dist/src/ui/hooks/useCompletion.d.ts +24 -0
  508. package/dist/src/ui/hooks/useCompletion.js +88 -0
  509. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  510. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  511. package/dist/src/ui/hooks/useConsoleMessages.js +76 -0
  512. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  513. package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
  514. package/dist/src/ui/hooks/useEditorSettings.js +43 -0
  515. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  516. package/dist/src/ui/hooks/useEditorSettings.test.d.ts +6 -0
  517. package/dist/src/ui/hooks/useEditorSettings.test.js +164 -0
  518. package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -0
  519. package/dist/src/ui/hooks/useFocus.d.ts +10 -0
  520. package/dist/src/ui/hooks/useFocus.js +41 -0
  521. package/dist/src/ui/hooks/useFocus.js.map +1 -0
  522. package/dist/src/ui/hooks/useFolderTrust.d.ts +13 -0
  523. package/dist/src/ui/hooks/useFolderTrust.js +64 -0
  524. package/dist/src/ui/hooks/useFolderTrust.js.map +1 -0
  525. package/dist/src/ui/hooks/useGeminiStream.d.ts +24 -0
  526. package/dist/src/ui/hooks/useGeminiStream.js +634 -0
  527. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  528. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  529. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  530. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  531. package/dist/src/ui/hooks/useGitBranchName.test.d.ts +6 -0
  532. package/dist/src/ui/hooks/useGitBranchName.test.js +175 -0
  533. package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -0
  534. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  535. package/dist/src/ui/hooks/useHistoryManager.js +72 -0
  536. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  537. package/dist/src/ui/hooks/useHistoryManager.test.d.ts +6 -0
  538. package/dist/src/ui/hooks/useHistoryManager.test.js +171 -0
  539. package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -0
  540. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  541. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  542. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  543. package/dist/src/ui/hooks/useInputHistory.test.d.ts +6 -0
  544. package/dist/src/ui/hooks/useInputHistory.test.js +207 -0
  545. package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -0
  546. package/dist/src/ui/hooks/useKeypress.d.ts +17 -0
  547. package/dist/src/ui/hooks/useKeypress.js +27 -0
  548. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  549. package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
  550. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
  551. package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
  552. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  553. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  554. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  555. package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +6 -0
  556. package/dist/src/ui/hooks/useLoadingIndicator.test.js +91 -0
  557. package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -0
  558. package/dist/src/ui/hooks/useLogger.d.ts +11 -0
  559. package/dist/src/ui/hooks/useLogger.js +29 -0
  560. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  561. package/dist/src/ui/hooks/useMessageQueue.d.ts +22 -0
  562. package/dist/src/ui/hooks/useMessageQueue.js +49 -0
  563. package/dist/src/ui/hooks/useMessageQueue.js.map +1 -0
  564. package/dist/src/ui/hooks/useMessageQueue.test.d.ts +6 -0
  565. package/dist/src/ui/hooks/useMessageQueue.test.js +158 -0
  566. package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -0
  567. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  568. package/dist/src/ui/hooks/usePhraseCycler.js +187 -0
  569. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  570. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  571. package/dist/src/ui/hooks/usePrivacySettings.js +119 -0
  572. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  573. package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +6 -0
  574. package/dist/src/ui/hooks/usePrivacySettings.test.js +154 -0
  575. package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -0
  576. package/dist/src/ui/hooks/usePromptCompletion.d.ts +23 -0
  577. package/dist/src/ui/hooks/usePromptCompletion.js +177 -0
  578. package/dist/src/ui/hooks/usePromptCompletion.js.map +1 -0
  579. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  580. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  581. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  582. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  583. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  584. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  585. package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
  586. package/dist/src/ui/hooks/useReverseSearchCompletion.js +56 -0
  587. package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
  588. package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +6 -0
  589. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +163 -0
  590. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -0
  591. package/dist/src/ui/hooks/useSettingsCommand.d.ts +10 -0
  592. package/dist/src/ui/hooks/useSettingsCommand.js +21 -0
  593. package/dist/src/ui/hooks/useSettingsCommand.js.map +1 -0
  594. package/dist/src/ui/hooks/useShellHistory.d.ts +14 -0
  595. package/dist/src/ui/hooks/useShellHistory.js +111 -0
  596. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  597. package/dist/src/ui/hooks/useShellHistory.test.d.ts +6 -0
  598. package/dist/src/ui/hooks/useShellHistory.test.js +187 -0
  599. package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -0
  600. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  601. package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
  602. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  603. package/dist/src/ui/hooks/useSlashCompletion.d.ts +20 -0
  604. package/dist/src/ui/hooks/useSlashCompletion.js +135 -0
  605. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
  606. package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +6 -0
  607. package/dist/src/ui/hooks/useSlashCompletion.test.js +272 -0
  608. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -0
  609. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  610. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  611. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  612. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  613. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  614. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  615. package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
  616. package/dist/src/ui/hooks/useThemeCommand.js +79 -0
  617. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  618. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  619. package/dist/src/ui/hooks/useTimer.js +58 -0
  620. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  621. package/dist/src/ui/hooks/useTimer.test.d.ts +6 -0
  622. package/dist/src/ui/hooks/useTimer.test.js +90 -0
  623. package/dist/src/ui/hooks/useTimer.test.js.map +1 -0
  624. package/dist/src/ui/hooks/useToolScheduler.test.d.ts +6 -0
  625. package/dist/src/ui/hooks/useToolScheduler.test.js +850 -0
  626. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -0
  627. package/dist/src/ui/hooks/useWorkspaceMigration.d.ts +13 -0
  628. package/dist/src/ui/hooks/useWorkspaceMigration.js +53 -0
  629. package/dist/src/ui/hooks/useWorkspaceMigration.js.map +1 -0
  630. package/dist/src/ui/hooks/vim.d.ts +28 -0
  631. package/dist/src/ui/hooks/vim.js +639 -0
  632. package/dist/src/ui/hooks/vim.js.map +1 -0
  633. package/dist/src/ui/keyMatchers.d.ts +27 -0
  634. package/dist/src/ui/keyMatchers.js +68 -0
  635. package/dist/src/ui/keyMatchers.js.map +1 -0
  636. package/dist/src/ui/keyMatchers.test.d.ts +6 -0
  637. package/dist/src/ui/keyMatchers.test.js +276 -0
  638. package/dist/src/ui/keyMatchers.test.js.map +1 -0
  639. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  640. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +41 -0
  641. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  642. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  643. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +18 -0
  644. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  645. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  646. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +18 -0
  647. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  648. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  649. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  650. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  651. package/dist/src/ui/semantic-colors.d.ts +7 -0
  652. package/dist/src/ui/semantic-colors.js +24 -0
  653. package/dist/src/ui/semantic-colors.js.map +1 -0
  654. package/dist/src/ui/textConstants.d.ts +9 -0
  655. package/dist/src/ui/textConstants.js +10 -0
  656. package/dist/src/ui/textConstants.js.map +1 -0
  657. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  658. package/dist/src/ui/themes/ansi-light.js +142 -0
  659. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  660. package/dist/src/ui/themes/ansi.d.ts +7 -0
  661. package/dist/src/ui/themes/ansi.js +152 -0
  662. package/dist/src/ui/themes/ansi.js.map +1 -0
  663. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  664. package/dist/src/ui/themes/atom-one-dark.js +138 -0
  665. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  666. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  667. package/dist/src/ui/themes/ayu-light.js +130 -0
  668. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  669. package/dist/src/ui/themes/ayu.d.ts +7 -0
  670. package/dist/src/ui/themes/ayu.js +104 -0
  671. package/dist/src/ui/themes/ayu.js.map +1 -0
  672. package/dist/src/ui/themes/color-utils.d.ts +21 -0
  673. package/dist/src/ui/themes/color-utils.js +221 -0
  674. package/dist/src/ui/themes/color-utils.js.map +1 -0
  675. package/dist/src/ui/themes/color-utils.test.d.ts +6 -0
  676. package/dist/src/ui/themes/color-utils.test.js +197 -0
  677. package/dist/src/ui/themes/color-utils.test.js.map +1 -0
  678. package/dist/src/ui/themes/default-light.d.ts +7 -0
  679. package/dist/src/ui/themes/default-light.js +100 -0
  680. package/dist/src/ui/themes/default-light.js.map +1 -0
  681. package/dist/src/ui/themes/default.d.ts +7 -0
  682. package/dist/src/ui/themes/default.js +143 -0
  683. package/dist/src/ui/themes/default.js.map +1 -0
  684. package/dist/src/ui/themes/dracula.d.ts +7 -0
  685. package/dist/src/ui/themes/dracula.js +115 -0
  686. package/dist/src/ui/themes/dracula.js.map +1 -0
  687. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  688. package/dist/src/ui/themes/github-dark.js +138 -0
  689. package/dist/src/ui/themes/github-dark.js.map +1 -0
  690. package/dist/src/ui/themes/github-light.d.ts +7 -0
  691. package/dist/src/ui/themes/github-light.js +140 -0
  692. package/dist/src/ui/themes/github-light.js.map +1 -0
  693. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  694. package/dist/src/ui/themes/googlecode.js +137 -0
  695. package/dist/src/ui/themes/googlecode.js.map +1 -0
  696. package/dist/src/ui/themes/no-color.d.ts +7 -0
  697. package/dist/src/ui/themes/no-color.js +115 -0
  698. package/dist/src/ui/themes/no-color.js.map +1 -0
  699. package/dist/src/ui/themes/semantic-tokens.d.ts +37 -0
  700. package/dist/src/ui/themes/semantic-tokens.js +94 -0
  701. package/dist/src/ui/themes/semantic-tokens.js.map +1 -0
  702. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  703. package/dist/src/ui/themes/shades-of-purple.js +304 -0
  704. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  705. package/dist/src/ui/themes/theme-manager.d.ts +66 -0
  706. package/dist/src/ui/themes/theme-manager.js +262 -0
  707. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  708. package/dist/src/ui/themes/theme-manager.test.d.ts +6 -0
  709. package/dist/src/ui/themes/theme-manager.test.js +142 -0
  710. package/dist/src/ui/themes/theme-manager.test.js.map +1 -0
  711. package/dist/src/ui/themes/theme.d.ts +130 -0
  712. package/dist/src/ui/themes/theme.js +379 -0
  713. package/dist/src/ui/themes/theme.js.map +1 -0
  714. package/dist/src/ui/themes/xcode.d.ts +7 -0
  715. package/dist/src/ui/themes/xcode.js +145 -0
  716. package/dist/src/ui/themes/xcode.js.map +1 -0
  717. package/dist/src/ui/types.d.ts +193 -0
  718. package/dist/src/ui/types.js +44 -0
  719. package/dist/src/ui/types.js.map +1 -0
  720. package/dist/src/ui/utils/CodeColorizer.d.ts +17 -0
  721. package/dist/src/ui/utils/CodeColorizer.js +110 -0
  722. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  723. package/dist/src/ui/utils/ConsolePatcher.d.ts +25 -0
  724. package/dist/src/ui/utils/ConsolePatcher.js +52 -0
  725. package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
  726. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
  727. package/dist/src/ui/utils/InlineMarkdownRenderer.js +111 -0
  728. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
  729. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  730. package/dist/src/ui/utils/MarkdownDisplay.js +208 -0
  731. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  732. package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
  733. package/dist/src/ui/utils/MarkdownDisplay.test.js +152 -0
  734. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
  735. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  736. package/dist/src/ui/utils/TableRenderer.js +84 -0
  737. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  738. package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
  739. package/dist/src/ui/utils/clipboardUtils.js +127 -0
  740. package/dist/src/ui/utils/clipboardUtils.js.map +1 -0
  741. package/dist/src/ui/utils/clipboardUtils.test.d.ts +6 -0
  742. package/dist/src/ui/utils/clipboardUtils.test.js +65 -0
  743. package/dist/src/ui/utils/clipboardUtils.test.js.map +1 -0
  744. package/dist/src/ui/utils/commandUtils.d.ts +24 -0
  745. package/dist/src/ui/utils/commandUtils.js +131 -0
  746. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  747. package/dist/src/ui/utils/commandUtils.test.d.ts +6 -0
  748. package/dist/src/ui/utils/commandUtils.test.js +349 -0
  749. package/dist/src/ui/utils/commandUtils.test.js.map +1 -0
  750. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  751. package/dist/src/ui/utils/computeStats.js +57 -0
  752. package/dist/src/ui/utils/computeStats.js.map +1 -0
  753. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  754. package/dist/src/ui/utils/displayUtils.js +24 -0
  755. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  756. package/dist/src/ui/utils/displayUtils.test.d.ts +6 -0
  757. package/dist/src/ui/utils/displayUtils.test.js +42 -0
  758. package/dist/src/ui/utils/displayUtils.test.js.map +1 -0
  759. package/dist/src/ui/utils/formatters.d.ts +13 -0
  760. package/dist/src/ui/utils/formatters.js +56 -0
  761. package/dist/src/ui/utils/formatters.js.map +1 -0
  762. package/dist/src/ui/utils/formatters.test.d.ts +6 -0
  763. package/dist/src/ui/utils/formatters.test.js +56 -0
  764. package/dist/src/ui/utils/formatters.test.js.map +1 -0
  765. package/dist/src/ui/utils/isNarrowWidth.d.ts +6 -0
  766. package/dist/src/ui/utils/isNarrowWidth.js +9 -0
  767. package/dist/src/ui/utils/isNarrowWidth.js.map +1 -0
  768. package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
  769. package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
  770. package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
  771. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  772. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  773. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  774. package/dist/src/ui/utils/markdownUtilities.test.d.ts +6 -0
  775. package/dist/src/ui/utils/markdownUtilities.test.js +42 -0
  776. package/dist/src/ui/utils/markdownUtilities.test.js.map +1 -0
  777. package/dist/src/ui/utils/platformConstants.d.ts +52 -0
  778. package/dist/src/ui/utils/platformConstants.js +53 -0
  779. package/dist/src/ui/utils/platformConstants.js.map +1 -0
  780. package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
  781. package/dist/src/ui/utils/terminalSetup.js +281 -0
  782. package/dist/src/ui/utils/terminalSetup.js.map +1 -0
  783. package/dist/src/ui/utils/textUtils.d.ts +32 -0
  784. package/dist/src/ui/utils/textUtils.js +80 -0
  785. package/dist/src/ui/utils/textUtils.js.map +1 -0
  786. package/dist/src/ui/utils/updateCheck.d.ts +12 -0
  787. package/dist/src/ui/utils/updateCheck.js +78 -0
  788. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  789. package/dist/src/ui/utils/updateCheck.test.d.ts +6 -0
  790. package/dist/src/ui/utils/updateCheck.test.js +145 -0
  791. package/dist/src/ui/utils/updateCheck.test.js.map +1 -0
  792. package/dist/src/utils/checks.d.ts +19 -0
  793. package/dist/src/utils/checks.js +24 -0
  794. package/dist/src/utils/checks.js.map +1 -0
  795. package/dist/src/utils/cleanup.d.ts +8 -0
  796. package/dist/src/utils/cleanup.js +35 -0
  797. package/dist/src/utils/cleanup.js.map +1 -0
  798. package/dist/src/utils/dialogScopeUtils.d.ts +32 -0
  799. package/dist/src/utils/dialogScopeUtils.js +48 -0
  800. package/dist/src/utils/dialogScopeUtils.js.map +1 -0
  801. package/dist/src/utils/errors.d.ts +6 -0
  802. package/dist/src/utils/errors.js +12 -0
  803. package/dist/src/utils/errors.js.map +1 -0
  804. package/dist/src/utils/events.d.ts +11 -0
  805. package/dist/src/utils/events.js +13 -0
  806. package/dist/src/utils/events.js.map +1 -0
  807. package/dist/src/utils/gitUtils.d.ts +30 -0
  808. package/dist/src/utils/gitUtils.js +89 -0
  809. package/dist/src/utils/gitUtils.js.map +1 -0
  810. package/dist/src/utils/gitUtils.test.d.ts +6 -0
  811. package/dist/src/utils/gitUtils.test.js +113 -0
  812. package/dist/src/utils/gitUtils.test.js.map +1 -0
  813. package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
  814. package/dist/src/utils/handleAutoUpdate.js +102 -0
  815. package/dist/src/utils/handleAutoUpdate.js.map +1 -0
  816. package/dist/src/utils/installationInfo.d.ts +23 -0
  817. package/dist/src/utils/installationInfo.js +154 -0
  818. package/dist/src/utils/installationInfo.js.map +1 -0
  819. package/dist/src/utils/installationInfo.test.d.ts +6 -0
  820. package/dist/src/utils/installationInfo.test.js +242 -0
  821. package/dist/src/utils/installationInfo.test.js.map +1 -0
  822. package/dist/src/utils/package.d.ts +12 -0
  823. package/dist/src/utils/package.js +24 -0
  824. package/dist/src/utils/package.js.map +1 -0
  825. package/dist/src/utils/readStdin.d.ts +6 -0
  826. package/dist/src/utils/readStdin.js +59 -0
  827. package/dist/src/utils/readStdin.js.map +1 -0
  828. package/dist/src/utils/readStdin.test.d.ts +6 -0
  829. package/dist/src/utils/readStdin.test.js +88 -0
  830. package/dist/src/utils/readStdin.test.js.map +1 -0
  831. package/dist/src/utils/resolvePath.d.ts +6 -0
  832. package/dist/src/utils/resolvePath.js +21 -0
  833. package/dist/src/utils/resolvePath.js.map +1 -0
  834. package/dist/src/utils/sandbox-macos-permissive-closed.sb +32 -0
  835. package/dist/src/utils/sandbox-macos-permissive-open.sb +25 -0
  836. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +37 -0
  837. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +93 -0
  838. package/dist/src/utils/sandbox-macos-restrictive-open.sb +96 -0
  839. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +98 -0
  840. package/dist/src/utils/sandbox.d.ts +7 -0
  841. package/dist/src/utils/sandbox.js +724 -0
  842. package/dist/src/utils/sandbox.js.map +1 -0
  843. package/dist/src/utils/settingsUtils.d.ts +134 -0
  844. package/dist/src/utils/settingsUtils.js +330 -0
  845. package/dist/src/utils/settingsUtils.js.map +1 -0
  846. package/dist/src/utils/settingsUtils.test.d.ts +6 -0
  847. package/dist/src/utils/settingsUtils.test.js +511 -0
  848. package/dist/src/utils/settingsUtils.test.js.map +1 -0
  849. package/dist/src/utils/spawnWrapper.d.ts +7 -0
  850. package/dist/src/utils/spawnWrapper.js +8 -0
  851. package/dist/src/utils/spawnWrapper.js.map +1 -0
  852. package/dist/src/utils/startupWarnings.d.ts +6 -0
  853. package/dist/src/utils/startupWarnings.js +40 -0
  854. package/dist/src/utils/startupWarnings.js.map +1 -0
  855. package/dist/src/utils/updateEventEmitter.d.ts +11 -0
  856. package/dist/src/utils/updateEventEmitter.js +12 -0
  857. package/dist/src/utils/updateEventEmitter.js.map +1 -0
  858. package/dist/src/utils/userStartupWarnings.d.ts +6 -0
  859. package/dist/src/utils/userStartupWarnings.js +54 -0
  860. package/dist/src/utils/userStartupWarnings.js.map +1 -0
  861. package/dist/src/utils/userStartupWarnings.test.d.ts +6 -0
  862. package/dist/src/utils/userStartupWarnings.test.js +67 -0
  863. package/dist/src/utils/userStartupWarnings.test.js.map +1 -0
  864. package/dist/src/utils/version.d.ts +6 -0
  865. package/dist/src/utils/version.js +11 -0
  866. package/dist/src/utils/version.js.map +1 -0
  867. package/dist/src/validateNonInterActiveAuth.d.ts +8 -0
  868. package/dist/src/validateNonInterActiveAuth.js +37 -0
  869. package/dist/src/validateNonInterActiveAuth.js.map +1 -0
  870. package/dist/src/zed-integration/acp.d.ts +63 -0
  871. package/dist/src/zed-integration/acp.js +226 -0
  872. package/dist/src/zed-integration/acp.js.map +1 -0
  873. package/dist/src/zed-integration/fileSystemService.d.ts +19 -0
  874. package/dist/src/zed-integration/fileSystemService.js +43 -0
  875. package/dist/src/zed-integration/fileSystemService.js.map +1 -0
  876. package/dist/src/zed-integration/schema.d.ts +11782 -0
  877. package/dist/src/zed-integration/schema.js +311 -0
  878. package/dist/src/zed-integration/schema.js.map +1 -0
  879. package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
  880. package/dist/src/zed-integration/zedIntegration.js +740 -0
  881. package/dist/src/zed-integration/zedIntegration.js.map +1 -0
  882. package/dist/tsconfig.tsbuildinfo +1 -0
  883. package/package.json +85 -0
@@ -0,0 +1,724 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { exec, execSync, spawn } from 'node:child_process';
7
+ import os from 'node:os';
8
+ import path from 'node:path';
9
+ import fs from 'node:fs';
10
+ import { readFile } from 'node:fs/promises';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { quote, parse } from 'shell-quote';
13
+ import { USER_SETTINGS_DIR, SETTINGS_DIRECTORY_NAME, } from '../config/settings.js';
14
+ import { promisify } from 'node:util';
15
+ import { FatalSandboxError } from '@google/gemini-cli-core';
16
+ import { ConsolePatcher } from '../ui/utils/ConsolePatcher.js';
17
+ const execAsync = promisify(exec);
18
+ function getContainerPath(hostPath) {
19
+ if (os.platform() !== 'win32') {
20
+ return hostPath;
21
+ }
22
+ const withForwardSlashes = hostPath.replace(/\\/g, '/');
23
+ const match = withForwardSlashes.match(/^([A-Z]):\/(.*)/i);
24
+ if (match) {
25
+ return `/${match[1].toLowerCase()}/${match[2]}`;
26
+ }
27
+ return hostPath;
28
+ }
29
+ const LOCAL_DEV_SANDBOX_IMAGE_NAME = 'gemini-cli-sandbox';
30
+ const SANDBOX_NETWORK_NAME = 'gemini-cli-sandbox';
31
+ const SANDBOX_PROXY_NAME = 'gemini-cli-sandbox-proxy';
32
+ const BUILTIN_SEATBELT_PROFILES = [
33
+ 'permissive-open',
34
+ 'permissive-closed',
35
+ 'permissive-proxied',
36
+ 'restrictive-open',
37
+ 'restrictive-closed',
38
+ 'restrictive-proxied',
39
+ ];
40
+ /**
41
+ * Determines whether the sandbox container should be run with the current user's UID and GID.
42
+ * This is often necessary on Linux systems (especially Debian/Ubuntu based) when using
43
+ * rootful Docker without userns-remap configured, to avoid permission issues with
44
+ * mounted volumes.
45
+ *
46
+ * The behavior is controlled by the `SANDBOX_SET_UID_GID` environment variable:
47
+ * - If `SANDBOX_SET_UID_GID` is "1" or "true", this function returns `true`.
48
+ * - If `SANDBOX_SET_UID_GID` is "0" or "false", this function returns `false`.
49
+ * - If `SANDBOX_SET_UID_GID` is not set:
50
+ * - On Debian/Ubuntu Linux, it defaults to `true`.
51
+ * - On other OSes, or if OS detection fails, it defaults to `false`.
52
+ *
53
+ * For more context on running Docker containers as non-root, see:
54
+ * https://medium.com/redbubble/running-a-docker-container-as-a-non-root-user-7d2e00f8ee15
55
+ *
56
+ * @returns {Promise<boolean>} A promise that resolves to true if the current user's UID/GID should be used, false otherwise.
57
+ */
58
+ async function shouldUseCurrentUserInSandbox() {
59
+ const envVar = process.env['SANDBOX_SET_UID_GID']?.toLowerCase().trim();
60
+ if (envVar === '1' || envVar === 'true') {
61
+ return true;
62
+ }
63
+ if (envVar === '0' || envVar === 'false') {
64
+ return false;
65
+ }
66
+ // If environment variable is not explicitly set, check for Debian/Ubuntu Linux
67
+ if (os.platform() === 'linux') {
68
+ try {
69
+ const osReleaseContent = await readFile('/etc/os-release', 'utf8');
70
+ if (osReleaseContent.includes('ID=debian') ||
71
+ osReleaseContent.includes('ID=ubuntu') ||
72
+ osReleaseContent.match(/^ID_LIKE=.*debian.*/m) || // Covers derivatives
73
+ osReleaseContent.match(/^ID_LIKE=.*ubuntu.*/m) // Covers derivatives
74
+ ) {
75
+ // note here and below we use console.error for informational messages on stderr
76
+ console.error('INFO: Defaulting to use current user UID/GID for Debian/Ubuntu-based Linux.');
77
+ return true;
78
+ }
79
+ }
80
+ catch (_err) {
81
+ // Silently ignore if /etc/os-release is not found or unreadable.
82
+ // The default (false) will be applied in this case.
83
+ console.warn('Warning: Could not read /etc/os-release to auto-detect Debian/Ubuntu for UID/GID default.');
84
+ }
85
+ }
86
+ return false; // Default to false if no other condition is met
87
+ }
88
+ // docker does not allow container names to contain ':' or '/', so we
89
+ // parse those out to shorten the name
90
+ function parseImageName(image) {
91
+ const [fullName, tag] = image.split(':');
92
+ const name = fullName.split('/').at(-1) ?? 'unknown-image';
93
+ return tag ? `${name}-${tag}` : name;
94
+ }
95
+ function ports() {
96
+ return (process.env['SANDBOX_PORTS'] ?? '')
97
+ .split(',')
98
+ .filter((p) => p.trim())
99
+ .map((p) => p.trim());
100
+ }
101
+ function entrypoint(workdir, cliArgs) {
102
+ const isWindows = os.platform() === 'win32';
103
+ const containerWorkdir = getContainerPath(workdir);
104
+ const shellCmds = [];
105
+ const pathSeparator = isWindows ? ';' : ':';
106
+ let pathSuffix = '';
107
+ if (process.env['PATH']) {
108
+ const paths = process.env['PATH'].split(pathSeparator);
109
+ for (const p of paths) {
110
+ const containerPath = getContainerPath(p);
111
+ if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
112
+ pathSuffix += `:${containerPath}`;
113
+ }
114
+ }
115
+ }
116
+ if (pathSuffix) {
117
+ shellCmds.push(`export PATH="$PATH${pathSuffix}";`);
118
+ }
119
+ let pythonPathSuffix = '';
120
+ if (process.env['PYTHONPATH']) {
121
+ const paths = process.env['PYTHONPATH'].split(pathSeparator);
122
+ for (const p of paths) {
123
+ const containerPath = getContainerPath(p);
124
+ if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
125
+ pythonPathSuffix += `:${containerPath}`;
126
+ }
127
+ }
128
+ }
129
+ if (pythonPathSuffix) {
130
+ shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`);
131
+ }
132
+ const projectSandboxBashrc = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.bashrc');
133
+ if (fs.existsSync(projectSandboxBashrc)) {
134
+ shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`);
135
+ }
136
+ ports().forEach((p) => shellCmds.push(`socat TCP4-LISTEN:${p},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${p} 2> /dev/null &`));
137
+ const quotedCliArgs = cliArgs.slice(2).map((arg) => quote([arg]));
138
+ const cliCmd = process.env['NODE_ENV'] === 'development'
139
+ ? process.env['DEBUG']
140
+ ? 'npm run debug --'
141
+ : 'npm rebuild && npm run start --'
142
+ : process.env['DEBUG']
143
+ ? `node --inspect-brk=0.0.0.0:${process.env['DEBUG_PORT'] || '9229'} $(which gemini)`
144
+ : 'gemini';
145
+ const args = [...shellCmds, cliCmd, ...quotedCliArgs];
146
+ return ['bash', '-c', args.join(' ')];
147
+ }
148
+ export async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
149
+ const patcher = new ConsolePatcher({
150
+ debugMode: cliConfig?.getDebugMode() || !!process.env['DEBUG'],
151
+ stderr: true,
152
+ });
153
+ patcher.patch();
154
+ try {
155
+ if (config.command === 'sandbox-exec') {
156
+ // disallow BUILD_SANDBOX
157
+ if (process.env['BUILD_SANDBOX']) {
158
+ throw new FatalSandboxError('Cannot BUILD_SANDBOX when using macOS Seatbelt');
159
+ }
160
+ const profile = (process.env['SEATBELT_PROFILE'] ??= 'permissive-open');
161
+ let profileFile = fileURLToPath(new URL(`sandbox-macos-${profile}.sb`, import.meta.url));
162
+ // if profile name is not recognized, then look for file under project settings directory
163
+ if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
164
+ profileFile = path.join(SETTINGS_DIRECTORY_NAME, `sandbox-macos-${profile}.sb`);
165
+ }
166
+ if (!fs.existsSync(profileFile)) {
167
+ throw new FatalSandboxError(`Missing macos seatbelt profile file '${profileFile}'`);
168
+ }
169
+ // Log on STDERR so it doesn't clutter the output on STDOUT
170
+ console.error(`using macos seatbelt (profile: ${profile}) ...`);
171
+ // if DEBUG is set, convert to --inspect-brk in NODE_OPTIONS
172
+ const nodeOptions = [
173
+ ...(process.env['DEBUG'] ? ['--inspect-brk'] : []),
174
+ ...nodeArgs,
175
+ ].join(' ');
176
+ const args = [
177
+ '-D',
178
+ `TARGET_DIR=${fs.realpathSync(process.cwd())}`,
179
+ '-D',
180
+ `TMP_DIR=${fs.realpathSync(os.tmpdir())}`,
181
+ '-D',
182
+ `HOME_DIR=${fs.realpathSync(os.homedir())}`,
183
+ '-D',
184
+ `CACHE_DIR=${fs.realpathSync(execSync(`getconf DARWIN_USER_CACHE_DIR`).toString().trim())}`,
185
+ ];
186
+ // Add included directories from the workspace context
187
+ // Always add 5 INCLUDE_DIR parameters to ensure .sb files can reference them
188
+ const MAX_INCLUDE_DIRS = 5;
189
+ const targetDir = fs.realpathSync(cliConfig?.getTargetDir() || '');
190
+ const includedDirs = [];
191
+ if (cliConfig) {
192
+ const workspaceContext = cliConfig.getWorkspaceContext();
193
+ const directories = workspaceContext.getDirectories();
194
+ // Filter out TARGET_DIR
195
+ for (const dir of directories) {
196
+ const realDir = fs.realpathSync(dir);
197
+ if (realDir !== targetDir) {
198
+ includedDirs.push(realDir);
199
+ }
200
+ }
201
+ }
202
+ for (let i = 0; i < MAX_INCLUDE_DIRS; i++) {
203
+ let dirPath = '/dev/null'; // Default to a safe path that won't cause issues
204
+ if (i < includedDirs.length) {
205
+ dirPath = includedDirs[i];
206
+ }
207
+ args.push('-D', `INCLUDE_DIR_${i}=${dirPath}`);
208
+ }
209
+ const finalArgv = cliArgs;
210
+ args.push('-f', profileFile, 'sh', '-c', [
211
+ `SANDBOX=sandbox-exec`,
212
+ `NODE_OPTIONS="${nodeOptions}"`,
213
+ ...finalArgv.map((arg) => quote([arg])),
214
+ ].join(' '));
215
+ // start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
216
+ const proxyCommand = process.env['GEMINI_SANDBOX_PROXY_COMMAND'];
217
+ let proxyProcess = undefined;
218
+ let sandboxProcess = undefined;
219
+ const sandboxEnv = { ...process.env };
220
+ if (proxyCommand) {
221
+ const proxy = process.env['HTTPS_PROXY'] ||
222
+ process.env['https_proxy'] ||
223
+ process.env['HTTP_PROXY'] ||
224
+ process.env['http_proxy'] ||
225
+ 'http://localhost:8877';
226
+ sandboxEnv['HTTPS_PROXY'] = proxy;
227
+ sandboxEnv['https_proxy'] = proxy; // lower-case can be required, e.g. for curl
228
+ sandboxEnv['HTTP_PROXY'] = proxy;
229
+ sandboxEnv['http_proxy'] = proxy;
230
+ const noProxy = process.env['NO_PROXY'] || process.env['no_proxy'];
231
+ if (noProxy) {
232
+ sandboxEnv['NO_PROXY'] = noProxy;
233
+ sandboxEnv['no_proxy'] = noProxy;
234
+ }
235
+ proxyProcess = spawn(proxyCommand, {
236
+ stdio: ['ignore', 'pipe', 'pipe'],
237
+ shell: true,
238
+ detached: true,
239
+ });
240
+ // install handlers to stop proxy on exit/signal
241
+ const stopProxy = () => {
242
+ console.log('stopping proxy ...');
243
+ if (proxyProcess?.pid) {
244
+ process.kill(-proxyProcess.pid, 'SIGTERM');
245
+ }
246
+ };
247
+ process.on('exit', stopProxy);
248
+ process.on('SIGINT', stopProxy);
249
+ process.on('SIGTERM', stopProxy);
250
+ // commented out as it disrupts ink rendering
251
+ // proxyProcess.stdout?.on('data', (data) => {
252
+ // console.info(data.toString());
253
+ // });
254
+ proxyProcess.stderr?.on('data', (data) => {
255
+ console.error(data.toString());
256
+ });
257
+ proxyProcess.on('close', (code, signal) => {
258
+ if (sandboxProcess?.pid) {
259
+ process.kill(-sandboxProcess.pid, 'SIGTERM');
260
+ }
261
+ throw new FatalSandboxError(`Proxy command '${proxyCommand}' exited with code ${code}, signal ${signal}`);
262
+ });
263
+ console.log('waiting for proxy to start ...');
264
+ await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
265
+ }
266
+ // spawn child and let it inherit stdio
267
+ sandboxProcess = spawn(config.command, args, {
268
+ stdio: 'inherit',
269
+ });
270
+ await new Promise((resolve) => sandboxProcess?.on('close', resolve));
271
+ return;
272
+ }
273
+ console.error(`hopping into sandbox (command: ${config.command}) ...`);
274
+ // determine full path for gemini-cli to distinguish linked vs installed setting
275
+ const gcPath = fs.realpathSync(process.argv[1]);
276
+ const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
277
+ const isCustomProjectSandbox = fs.existsSync(projectSandboxDockerfile);
278
+ const image = config.image;
279
+ const workdir = path.resolve(process.cwd());
280
+ const containerWorkdir = getContainerPath(workdir);
281
+ // if BUILD_SANDBOX is set, then call scripts/build_sandbox.js under gemini-cli repo
282
+ //
283
+ // note this can only be done with binary linked from gemini-cli repo
284
+ if (process.env['BUILD_SANDBOX']) {
285
+ if (!gcPath.includes('gemini-cli/packages/')) {
286
+ throw new FatalSandboxError('Cannot build sandbox using installed gemini binary; ' +
287
+ 'run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.');
288
+ }
289
+ else {
290
+ console.error('building sandbox ...');
291
+ const gcRoot = gcPath.split('/packages/')[0];
292
+ // if project folder has sandbox.Dockerfile under project settings folder, use that
293
+ let buildArgs = '';
294
+ const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
295
+ if (isCustomProjectSandbox) {
296
+ console.error(`using ${projectSandboxDockerfile} for sandbox`);
297
+ buildArgs += `-f ${path.resolve(projectSandboxDockerfile)} -i ${image}`;
298
+ }
299
+ execSync(`cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`, {
300
+ stdio: 'inherit',
301
+ env: {
302
+ ...process.env,
303
+ GEMINI_SANDBOX: config.command, // in case sandbox is enabled via flags (see config.ts under cli package)
304
+ },
305
+ });
306
+ }
307
+ }
308
+ // stop if image is missing
309
+ if (!(await ensureSandboxImageIsPresent(config.command, image))) {
310
+ const remedy = image === LOCAL_DEV_SANDBOX_IMAGE_NAME
311
+ ? 'Try running `npm run build:all` or `npm run build:sandbox` under the gemini-cli repo to build it locally, or check the image name and your network connection.'
312
+ : 'Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists.';
313
+ throw new FatalSandboxError(`Sandbox image '${image}' is missing or could not be pulled. ${remedy}`);
314
+ }
315
+ // use interactive mode and auto-remove container on exit
316
+ // run init binary inside container to forward signals & reap zombies
317
+ const args = ['run', '-i', '--rm', '--init', '--workdir', containerWorkdir];
318
+ // add custom flags from SANDBOX_FLAGS
319
+ if (process.env['SANDBOX_FLAGS']) {
320
+ const flags = parse(process.env['SANDBOX_FLAGS'], process.env).filter((f) => typeof f === 'string');
321
+ args.push(...flags);
322
+ }
323
+ // add TTY only if stdin is TTY as well, i.e. for piped input don't init TTY in container
324
+ if (process.stdin.isTTY) {
325
+ args.push('-t');
326
+ }
327
+ // mount current directory as working directory in sandbox (set via --workdir)
328
+ args.push('--volume', `${workdir}:${containerWorkdir}`);
329
+ // mount user settings directory inside container, after creating if missing
330
+ // note user/home changes inside sandbox and we mount at BOTH paths for consistency
331
+ const userSettingsDirOnHost = USER_SETTINGS_DIR;
332
+ const userSettingsDirInSandbox = getContainerPath(`/home/node/${SETTINGS_DIRECTORY_NAME}`);
333
+ if (!fs.existsSync(userSettingsDirOnHost)) {
334
+ fs.mkdirSync(userSettingsDirOnHost);
335
+ }
336
+ args.push('--volume', `${userSettingsDirOnHost}:${userSettingsDirInSandbox}`);
337
+ if (userSettingsDirInSandbox !== userSettingsDirOnHost) {
338
+ args.push('--volume', `${userSettingsDirOnHost}:${getContainerPath(userSettingsDirOnHost)}`);
339
+ }
340
+ // mount os.tmpdir() as os.tmpdir() inside container
341
+ args.push('--volume', `${os.tmpdir()}:${getContainerPath(os.tmpdir())}`);
342
+ // mount gcloud config directory if it exists
343
+ const gcloudConfigDir = path.join(os.homedir(), '.config', 'gcloud');
344
+ if (fs.existsSync(gcloudConfigDir)) {
345
+ args.push('--volume', `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`);
346
+ }
347
+ // mount ADC file if GOOGLE_APPLICATION_CREDENTIALS is set
348
+ if (process.env['GOOGLE_APPLICATION_CREDENTIALS']) {
349
+ const adcFile = process.env['GOOGLE_APPLICATION_CREDENTIALS'];
350
+ if (fs.existsSync(adcFile)) {
351
+ args.push('--volume', `${adcFile}:${getContainerPath(adcFile)}:ro`);
352
+ args.push('--env', `GOOGLE_APPLICATION_CREDENTIALS=${getContainerPath(adcFile)}`);
353
+ }
354
+ }
355
+ // mount paths listed in SANDBOX_MOUNTS
356
+ if (process.env['SANDBOX_MOUNTS']) {
357
+ for (let mount of process.env['SANDBOX_MOUNTS'].split(',')) {
358
+ if (mount.trim()) {
359
+ // parse mount as from:to:opts
360
+ let [from, to, opts] = mount.trim().split(':');
361
+ to = to || from; // default to mount at same path inside container
362
+ opts = opts || 'ro'; // default to read-only
363
+ mount = `${from}:${to}:${opts}`;
364
+ // check that from path is absolute
365
+ if (!path.isAbsolute(from)) {
366
+ throw new FatalSandboxError(`Path '${from}' listed in SANDBOX_MOUNTS must be absolute`);
367
+ }
368
+ // check that from path exists on host
369
+ if (!fs.existsSync(from)) {
370
+ throw new FatalSandboxError(`Missing mount path '${from}' listed in SANDBOX_MOUNTS`);
371
+ }
372
+ console.error(`SANDBOX_MOUNTS: ${from} -> ${to} (${opts})`);
373
+ args.push('--volume', mount);
374
+ }
375
+ }
376
+ }
377
+ // expose env-specified ports on the sandbox
378
+ ports().forEach((p) => args.push('--publish', `${p}:${p}`));
379
+ // if DEBUG is set, expose debugging port
380
+ if (process.env['DEBUG']) {
381
+ const debugPort = process.env['DEBUG_PORT'] || '9229';
382
+ args.push(`--publish`, `${debugPort}:${debugPort}`);
383
+ }
384
+ // copy proxy environment variables, replacing localhost with SANDBOX_PROXY_NAME
385
+ // copy as both upper-case and lower-case as is required by some utilities
386
+ // GEMINI_SANDBOX_PROXY_COMMAND implies HTTPS_PROXY unless HTTP_PROXY is set
387
+ const proxyCommand = process.env['GEMINI_SANDBOX_PROXY_COMMAND'];
388
+ if (proxyCommand) {
389
+ let proxy = process.env['HTTPS_PROXY'] ||
390
+ process.env['https_proxy'] ||
391
+ process.env['HTTP_PROXY'] ||
392
+ process.env['http_proxy'] ||
393
+ 'http://localhost:8877';
394
+ proxy = proxy.replace('localhost', SANDBOX_PROXY_NAME);
395
+ if (proxy) {
396
+ args.push('--env', `HTTPS_PROXY=${proxy}`);
397
+ args.push('--env', `https_proxy=${proxy}`); // lower-case can be required, e.g. for curl
398
+ args.push('--env', `HTTP_PROXY=${proxy}`);
399
+ args.push('--env', `http_proxy=${proxy}`);
400
+ }
401
+ const noProxy = process.env['NO_PROXY'] || process.env['no_proxy'];
402
+ if (noProxy) {
403
+ args.push('--env', `NO_PROXY=${noProxy}`);
404
+ args.push('--env', `no_proxy=${noProxy}`);
405
+ }
406
+ // if using proxy, switch to internal networking through proxy
407
+ if (proxy) {
408
+ execSync(`${config.command} network inspect ${SANDBOX_NETWORK_NAME} || ${config.command} network create --internal ${SANDBOX_NETWORK_NAME}`);
409
+ args.push('--network', SANDBOX_NETWORK_NAME);
410
+ // if proxy command is set, create a separate network w/ host access (i.e. non-internal)
411
+ // we will run proxy in its own container connected to both host network and internal network
412
+ // this allows proxy to work even on rootless podman on macos with host<->vm<->container isolation
413
+ if (proxyCommand) {
414
+ execSync(`${config.command} network inspect ${SANDBOX_PROXY_NAME} || ${config.command} network create ${SANDBOX_PROXY_NAME}`);
415
+ }
416
+ }
417
+ }
418
+ // name container after image, plus numeric suffix to avoid conflicts
419
+ const imageName = parseImageName(image);
420
+ let index = 0;
421
+ const containerNameCheck = execSync(`${config.command} ps -a --format "{{.Names}}"`)
422
+ .toString()
423
+ .trim();
424
+ while (containerNameCheck.includes(`${imageName}-${index}`)) {
425
+ index++;
426
+ }
427
+ const containerName = `${imageName}-${index}`;
428
+ args.push('--name', containerName, '--hostname', containerName);
429
+ // copy GEMINI_API_KEY(s)
430
+ if (process.env['GEMINI_API_KEY']) {
431
+ args.push('--env', `GEMINI_API_KEY=${process.env['GEMINI_API_KEY']}`);
432
+ }
433
+ if (process.env['GOOGLE_API_KEY']) {
434
+ args.push('--env', `GOOGLE_API_KEY=${process.env['GOOGLE_API_KEY']}`);
435
+ }
436
+ // copy GOOGLE_GENAI_USE_VERTEXAI
437
+ if (process.env['GOOGLE_GENAI_USE_VERTEXAI']) {
438
+ args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env['GOOGLE_GENAI_USE_VERTEXAI']}`);
439
+ }
440
+ // copy GOOGLE_GENAI_USE_GCA
441
+ if (process.env['GOOGLE_GENAI_USE_GCA']) {
442
+ args.push('--env', `GOOGLE_GENAI_USE_GCA=${process.env['GOOGLE_GENAI_USE_GCA']}`);
443
+ }
444
+ // copy GOOGLE_CLOUD_PROJECT
445
+ if (process.env['GOOGLE_CLOUD_PROJECT']) {
446
+ args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env['GOOGLE_CLOUD_PROJECT']}`);
447
+ }
448
+ // copy GOOGLE_CLOUD_LOCATION
449
+ if (process.env['GOOGLE_CLOUD_LOCATION']) {
450
+ args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env['GOOGLE_CLOUD_LOCATION']}`);
451
+ }
452
+ // copy GEMINI_MODEL
453
+ if (process.env['GEMINI_MODEL']) {
454
+ args.push('--env', `GEMINI_MODEL=${process.env['GEMINI_MODEL']}`);
455
+ }
456
+ // copy TERM and COLORTERM to try to maintain terminal setup
457
+ if (process.env['TERM']) {
458
+ args.push('--env', `TERM=${process.env['TERM']}`);
459
+ }
460
+ if (process.env['COLORTERM']) {
461
+ args.push('--env', `COLORTERM=${process.env['COLORTERM']}`);
462
+ }
463
+ // Pass through IDE mode environment variables
464
+ for (const envVar of [
465
+ 'GEMINI_CLI_IDE_SERVER_PORT',
466
+ 'GEMINI_CLI_IDE_WORKSPACE_PATH',
467
+ 'TERM_PROGRAM',
468
+ ]) {
469
+ if (process.env[envVar]) {
470
+ args.push('--env', `${envVar}=${process.env[envVar]}`);
471
+ }
472
+ }
473
+ // copy VIRTUAL_ENV if under working directory
474
+ // also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
475
+ // sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
476
+ // directory will be empty if not set up, which is still preferable to having host binaries
477
+ if (process.env['VIRTUAL_ENV']
478
+ ?.toLowerCase()
479
+ .startsWith(workdir.toLowerCase())) {
480
+ const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
481
+ if (!fs.existsSync(sandboxVenvPath)) {
482
+ fs.mkdirSync(sandboxVenvPath, { recursive: true });
483
+ }
484
+ args.push('--volume', `${sandboxVenvPath}:${getContainerPath(process.env['VIRTUAL_ENV'])}`);
485
+ args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env['VIRTUAL_ENV'])}`);
486
+ }
487
+ // copy additional environment variables from SANDBOX_ENV
488
+ if (process.env['SANDBOX_ENV']) {
489
+ for (let env of process.env['SANDBOX_ENV'].split(',')) {
490
+ if ((env = env.trim())) {
491
+ if (env.includes('=')) {
492
+ console.error(`SANDBOX_ENV: ${env}`);
493
+ args.push('--env', env);
494
+ }
495
+ else {
496
+ throw new FatalSandboxError('SANDBOX_ENV must be a comma-separated list of key=value pairs');
497
+ }
498
+ }
499
+ }
500
+ }
501
+ // copy NODE_OPTIONS
502
+ const existingNodeOptions = process.env['NODE_OPTIONS'] || '';
503
+ const allNodeOptions = [
504
+ ...(existingNodeOptions ? [existingNodeOptions] : []),
505
+ ...nodeArgs,
506
+ ].join(' ');
507
+ if (allNodeOptions.length > 0) {
508
+ args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
509
+ }
510
+ // set SANDBOX as container name
511
+ args.push('--env', `SANDBOX=${containerName}`);
512
+ // for podman only, use empty --authfile to skip unnecessary auth refresh overhead
513
+ if (config.command === 'podman') {
514
+ const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
515
+ fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
516
+ args.push('--authfile', emptyAuthFilePath);
517
+ }
518
+ // Determine if the current user's UID/GID should be passed to the sandbox.
519
+ // See shouldUseCurrentUserInSandbox for more details.
520
+ let userFlag = '';
521
+ const finalEntrypoint = entrypoint(workdir, cliArgs);
522
+ if (process.env['GEMINI_CLI_INTEGRATION_TEST'] === 'true') {
523
+ args.push('--user', 'root');
524
+ userFlag = '--user root';
525
+ }
526
+ else if (await shouldUseCurrentUserInSandbox()) {
527
+ // For the user-creation logic to work, the container must start as root.
528
+ // The entrypoint script then handles dropping privileges to the correct user.
529
+ args.push('--user', 'root');
530
+ const uid = execSync('id -u').toString().trim();
531
+ const gid = execSync('id -g').toString().trim();
532
+ // Instead of passing --user to the main sandbox container, we let it
533
+ // start as root, then create a user with the host's UID/GID, and
534
+ // finally switch to that user to run the gemini process. This is
535
+ // necessary on Linux to ensure the user exists within the
536
+ // container's /etc/passwd file, which is required by os.userInfo().
537
+ const username = 'gemini';
538
+ const homeDir = getContainerPath(os.homedir());
539
+ const setupUserCommands = [
540
+ // Use -f with groupadd to avoid errors if the group already exists.
541
+ `groupadd -f -g ${gid} ${username}`,
542
+ // Create user only if it doesn't exist. Use -o for non-unique UID.
543
+ `id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
544
+ ].join(' && ');
545
+ const originalCommand = finalEntrypoint[2];
546
+ const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
547
+ // Use `su -p` to preserve the environment.
548
+ const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
549
+ // The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
550
+ finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
551
+ // We still need userFlag for the simpler proxy container, which does not have this issue.
552
+ userFlag = `--user ${uid}:${gid}`;
553
+ // When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
554
+ args.push('--env', `HOME=${os.homedir()}`);
555
+ }
556
+ // push container image name
557
+ args.push(image);
558
+ // push container entrypoint (including args)
559
+ args.push(...finalEntrypoint);
560
+ // start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
561
+ let proxyProcess = undefined;
562
+ let sandboxProcess = undefined;
563
+ if (proxyCommand) {
564
+ // run proxyCommand in its own container
565
+ const proxyContainerCommand = `${config.command} run --rm --init ${userFlag} --name ${SANDBOX_PROXY_NAME} --network ${SANDBOX_PROXY_NAME} -p 8877:8877 -v ${process.cwd()}:${workdir} --workdir ${workdir} ${image} ${proxyCommand}`;
566
+ proxyProcess = spawn(proxyContainerCommand, {
567
+ stdio: ['ignore', 'pipe', 'pipe'],
568
+ shell: true,
569
+ detached: true,
570
+ });
571
+ // install handlers to stop proxy on exit/signal
572
+ const stopProxy = () => {
573
+ console.log('stopping proxy container ...');
574
+ execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
575
+ };
576
+ process.on('exit', stopProxy);
577
+ process.on('SIGINT', stopProxy);
578
+ process.on('SIGTERM', stopProxy);
579
+ // commented out as it disrupts ink rendering
580
+ // proxyProcess.stdout?.on('data', (data) => {
581
+ // console.info(data.toString());
582
+ // });
583
+ proxyProcess.stderr?.on('data', (data) => {
584
+ console.error(data.toString().trim());
585
+ });
586
+ proxyProcess.on('close', (code, signal) => {
587
+ if (sandboxProcess?.pid) {
588
+ process.kill(-sandboxProcess.pid, 'SIGTERM');
589
+ }
590
+ throw new FatalSandboxError(`Proxy container command '${proxyContainerCommand}' exited with code ${code}, signal ${signal}`);
591
+ });
592
+ console.log('waiting for proxy to start ...');
593
+ await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
594
+ // connect proxy container to sandbox network
595
+ // (workaround for older versions of docker that don't support multiple --network args)
596
+ await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
597
+ }
598
+ // spawn child and let it inherit stdio
599
+ sandboxProcess = spawn(config.command, args, {
600
+ stdio: 'inherit',
601
+ });
602
+ sandboxProcess.on('error', (err) => {
603
+ console.error('Sandbox process error:', err);
604
+ });
605
+ await new Promise((resolve) => {
606
+ sandboxProcess?.on('close', (code, signal) => {
607
+ if (code !== 0) {
608
+ console.log(`Sandbox process exited with code: ${code}, signal: ${signal}`);
609
+ }
610
+ resolve();
611
+ });
612
+ });
613
+ }
614
+ finally {
615
+ patcher.cleanup();
616
+ }
617
+ }
618
+ // Helper functions to ensure sandbox image is present
619
+ async function imageExists(sandbox, image) {
620
+ return new Promise((resolve) => {
621
+ const args = ['images', '-q', image];
622
+ const checkProcess = spawn(sandbox, args);
623
+ let stdoutData = '';
624
+ if (checkProcess.stdout) {
625
+ checkProcess.stdout.on('data', (data) => {
626
+ stdoutData += data.toString();
627
+ });
628
+ }
629
+ checkProcess.on('error', (err) => {
630
+ console.warn(`Failed to start '${sandbox}' command for image check: ${err.message}`);
631
+ resolve(false);
632
+ });
633
+ checkProcess.on('close', (code) => {
634
+ // Non-zero code might indicate docker daemon not running, etc.
635
+ // The primary success indicator is non-empty stdoutData.
636
+ if (code !== 0) {
637
+ // console.warn(`'${sandbox} images -q ${image}' exited with code ${code}.`);
638
+ }
639
+ resolve(stdoutData.trim() !== '');
640
+ });
641
+ });
642
+ }
643
+ async function pullImage(sandbox, image) {
644
+ console.info(`Attempting to pull image ${image} using ${sandbox}...`);
645
+ return new Promise((resolve) => {
646
+ const args = ['pull', image];
647
+ const pullProcess = spawn(sandbox, args, { stdio: 'pipe' });
648
+ let stderrData = '';
649
+ const onStdoutData = (data) => {
650
+ console.info(data.toString().trim()); // Show pull progress
651
+ };
652
+ const onStderrData = (data) => {
653
+ stderrData += data.toString();
654
+ console.error(data.toString().trim()); // Show pull errors/info from the command itself
655
+ };
656
+ const onError = (err) => {
657
+ console.warn(`Failed to start '${sandbox} pull ${image}' command: ${err.message}`);
658
+ cleanup();
659
+ resolve(false);
660
+ };
661
+ const onClose = (code) => {
662
+ if (code === 0) {
663
+ console.info(`Successfully pulled image ${image}.`);
664
+ cleanup();
665
+ resolve(true);
666
+ }
667
+ else {
668
+ console.warn(`Failed to pull image ${image}. '${sandbox} pull ${image}' exited with code ${code}.`);
669
+ if (stderrData.trim()) {
670
+ // Details already printed by the stderr listener above
671
+ }
672
+ cleanup();
673
+ resolve(false);
674
+ }
675
+ };
676
+ const cleanup = () => {
677
+ if (pullProcess.stdout) {
678
+ pullProcess.stdout.removeListener('data', onStdoutData);
679
+ }
680
+ if (pullProcess.stderr) {
681
+ pullProcess.stderr.removeListener('data', onStderrData);
682
+ }
683
+ pullProcess.removeListener('error', onError);
684
+ pullProcess.removeListener('close', onClose);
685
+ if (pullProcess.connected) {
686
+ pullProcess.disconnect();
687
+ }
688
+ };
689
+ if (pullProcess.stdout) {
690
+ pullProcess.stdout.on('data', onStdoutData);
691
+ }
692
+ if (pullProcess.stderr) {
693
+ pullProcess.stderr.on('data', onStderrData);
694
+ }
695
+ pullProcess.on('error', onError);
696
+ pullProcess.on('close', onClose);
697
+ });
698
+ }
699
+ async function ensureSandboxImageIsPresent(sandbox, image) {
700
+ console.info(`Checking for sandbox image: ${image}`);
701
+ if (await imageExists(sandbox, image)) {
702
+ console.info(`Sandbox image ${image} found locally.`);
703
+ return true;
704
+ }
705
+ console.info(`Sandbox image ${image} not found locally.`);
706
+ if (image === LOCAL_DEV_SANDBOX_IMAGE_NAME) {
707
+ // user needs to build the image themselves
708
+ return false;
709
+ }
710
+ if (await pullImage(sandbox, image)) {
711
+ // After attempting to pull, check again to be certain
712
+ if (await imageExists(sandbox, image)) {
713
+ console.info(`Sandbox image ${image} is now available after pulling.`);
714
+ return true;
715
+ }
716
+ else {
717
+ console.warn(`Sandbox image ${image} still not found after a pull attempt. This might indicate an issue with the image name or registry, or the pull command reported success but failed to make the image available.`);
718
+ return false;
719
+ }
720
+ }
721
+ console.error(`Failed to obtain sandbox image ${image} after check and pull attempt.`);
722
+ return false; // Pull command failed or image still not present
723
+ }
724
+ //# sourceMappingURL=sandbox.js.map