@vybestack/llxprt-code 0.1.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 (575) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +256 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +21 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/package.json +95 -0
  8. package/dist/src/config/auth.d.ts +6 -0
  9. package/dist/src/config/auth.js +42 -0
  10. package/dist/src/config/auth.js.map +1 -0
  11. package/dist/src/config/config.d.ts +41 -0
  12. package/dist/src/config/config.js +345 -0
  13. package/dist/src/config/config.js.map +1 -0
  14. package/dist/src/config/extension.d.ts +21 -0
  15. package/dist/src/config/extension.js +109 -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 +88 -0
  21. package/dist/src/config/settings.js +263 -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 +420 -0
  25. package/dist/src/gemini.js.map +1 -0
  26. package/dist/src/generated/git-commit.d.ts +6 -0
  27. package/dist/src/generated/git-commit.js +9 -0
  28. package/dist/src/generated/git-commit.js.map +1 -0
  29. package/dist/src/nonInteractiveCli.d.ts +7 -0
  30. package/dist/src/nonInteractiveCli.js +131 -0
  31. package/dist/src/nonInteractiveCli.js.map +1 -0
  32. package/dist/src/providers/IMessage.d.ts +38 -0
  33. package/dist/src/providers/IMessage.js +17 -0
  34. package/dist/src/providers/IMessage.js.map +1 -0
  35. package/dist/src/providers/IModel.d.ts +23 -0
  36. package/dist/src/providers/IModel.js +17 -0
  37. package/dist/src/providers/IModel.js.map +1 -0
  38. package/dist/src/providers/IProvider.d.ts +32 -0
  39. package/dist/src/providers/IProvider.js +17 -0
  40. package/dist/src/providers/IProvider.js.map +1 -0
  41. package/dist/src/providers/ITool.d.ts +23 -0
  42. package/dist/src/providers/ITool.js +17 -0
  43. package/dist/src/providers/ITool.js.map +1 -0
  44. package/dist/src/providers/ProviderAwareContentGenerator.d.ts +6 -0
  45. package/dist/src/providers/ProviderAwareContentGenerator.js +9 -0
  46. package/dist/src/providers/ProviderAwareContentGenerator.js.map +1 -0
  47. package/dist/src/providers/ProviderManager.d.ts +19 -0
  48. package/dist/src/providers/ProviderManager.js +63 -0
  49. package/dist/src/providers/ProviderManager.js.map +1 -0
  50. package/dist/src/providers/ProviderManagerAdapter.d.ts +17 -0
  51. package/dist/src/providers/ProviderManagerAdapter.js +113 -0
  52. package/dist/src/providers/ProviderManagerAdapter.js.map +1 -0
  53. package/dist/src/providers/README-qwen3.md +60 -0
  54. package/dist/src/providers/README.md +203 -0
  55. package/dist/src/providers/adapters/IStreamAdapter.d.ts +18 -0
  56. package/dist/src/providers/adapters/IStreamAdapter.js +7 -0
  57. package/dist/src/providers/adapters/IStreamAdapter.js.map +1 -0
  58. package/dist/src/providers/anthropic/AnthropicProvider.d.ts +46 -0
  59. package/dist/src/providers/anthropic/AnthropicProvider.js +478 -0
  60. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -0
  61. package/dist/src/providers/contentGeneratorProvider.d.ts +13 -0
  62. package/dist/src/providers/contentGeneratorProvider.js +17 -0
  63. package/dist/src/providers/contentGeneratorProvider.js.map +1 -0
  64. package/dist/src/providers/enhanceConfigWithProviders.d.ts +12 -0
  65. package/dist/src/providers/enhanceConfigWithProviders.js +16 -0
  66. package/dist/src/providers/enhanceConfigWithProviders.js.map +1 -0
  67. package/dist/src/providers/gemini/GeminiProvider.d.ts +72 -0
  68. package/dist/src/providers/gemini/GeminiProvider.js +454 -0
  69. package/dist/src/providers/gemini/GeminiProvider.js.map +1 -0
  70. package/dist/src/providers/index.d.ts +13 -0
  71. package/dist/src/providers/index.js +18 -0
  72. package/dist/src/providers/index.js.map +1 -0
  73. package/dist/src/providers/integration/TEST_INSTRUCTIONS.md +197 -0
  74. package/dist/src/providers/openai/ConversationCache.d.ts +20 -0
  75. package/dist/src/providers/openai/ConversationCache.js +109 -0
  76. package/dist/src/providers/openai/ConversationCache.js.map +1 -0
  77. package/dist/src/providers/openai/IChatGenerateParams.d.ts +11 -0
  78. package/dist/src/providers/openai/IChatGenerateParams.js +2 -0
  79. package/dist/src/providers/openai/IChatGenerateParams.js.map +1 -0
  80. package/dist/src/providers/openai/OpenAIProvider.d.ts +71 -0
  81. package/dist/src/providers/openai/OpenAIProvider.js +486 -0
  82. package/dist/src/providers/openai/OpenAIProvider.js.map +1 -0
  83. package/dist/src/providers/openai/Qwen3FireworksProvider.d.ts +39 -0
  84. package/dist/src/providers/openai/Qwen3FireworksProvider.js +209 -0
  85. package/dist/src/providers/openai/Qwen3FireworksProvider.js.map +1 -0
  86. package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +2 -0
  87. package/dist/src/providers/openai/RESPONSES_API_MODELS.js +14 -0
  88. package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +1 -0
  89. package/dist/src/providers/openai/buildResponsesRequest.d.ts +67 -0
  90. package/dist/src/providers/openai/buildResponsesRequest.js +144 -0
  91. package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -0
  92. package/dist/src/providers/openai/docs/accessing-provider-info.md +172 -0
  93. package/dist/src/providers/openai/docs/params-mapping.md +91 -0
  94. package/dist/src/providers/openai/docs/qwen3-fireworks.md +47 -0
  95. package/dist/src/providers/openai/docs/responses-api-tool-calls.md +96 -0
  96. package/dist/src/providers/openai/estimateRemoteTokens.d.ts +26 -0
  97. package/dist/src/providers/openai/estimateRemoteTokens.js +75 -0
  98. package/dist/src/providers/openai/estimateRemoteTokens.js.map +1 -0
  99. package/dist/src/providers/openai/getOpenAIProviderInfo.d.ts +46 -0
  100. package/dist/src/providers/openai/getOpenAIProviderInfo.js +74 -0
  101. package/dist/src/providers/openai/getOpenAIProviderInfo.js.map +1 -0
  102. package/dist/src/providers/openai/parseResponsesStream.d.ts +3 -0
  103. package/dist/src/providers/openai/parseResponsesStream.js +444 -0
  104. package/dist/src/providers/openai/parseResponsesStream.js.map +1 -0
  105. package/dist/src/providers/parsers/TextToolCallParser.d.ts +35 -0
  106. package/dist/src/providers/parsers/TextToolCallParser.js +248 -0
  107. package/dist/src/providers/parsers/TextToolCallParser.js.map +1 -0
  108. package/dist/src/providers/providerConfigUtils.d.ts +26 -0
  109. package/dist/src/providers/providerConfigUtils.js +173 -0
  110. package/dist/src/providers/providerConfigUtils.js.map +1 -0
  111. package/dist/src/providers/providerManagerInstance.d.ts +9 -0
  112. package/dist/src/providers/providerManagerInstance.js +109 -0
  113. package/dist/src/providers/providerManagerInstance.js.map +1 -0
  114. package/dist/src/providers/tokenizers/AnthropicTokenizer.d.ts +19 -0
  115. package/dist/src/providers/tokenizers/AnthropicTokenizer.js +37 -0
  116. package/dist/src/providers/tokenizers/AnthropicTokenizer.js.map +1 -0
  117. package/dist/src/providers/tokenizers/ITokenizer.d.ts +18 -0
  118. package/dist/src/providers/tokenizers/ITokenizer.js +17 -0
  119. package/dist/src/providers/tokenizers/ITokenizer.js.map +1 -0
  120. package/dist/src/providers/tokenizers/OpenAITokenizer.d.ts +24 -0
  121. package/dist/src/providers/tokenizers/OpenAITokenizer.js +56 -0
  122. package/dist/src/providers/tokenizers/OpenAITokenizer.js.map +1 -0
  123. package/dist/src/providers/types.d.ts +14 -0
  124. package/dist/src/providers/types.js +16 -0
  125. package/dist/src/providers/types.js.map +1 -0
  126. package/dist/src/services/CommandService.d.ts +13 -0
  127. package/dist/src/services/CommandService.js +38 -0
  128. package/dist/src/services/CommandService.js.map +1 -0
  129. package/dist/src/tools/IToolFormatter.d.ts +40 -0
  130. package/dist/src/tools/IToolFormatter.js +17 -0
  131. package/dist/src/tools/IToolFormatter.js.map +1 -0
  132. package/dist/src/tools/ToolFormatter.d.ts +45 -0
  133. package/dist/src/tools/ToolFormatter.js +216 -0
  134. package/dist/src/tools/ToolFormatter.js.map +1 -0
  135. package/dist/src/ui/App.d.ts +15 -0
  136. package/dist/src/ui/App.js +468 -0
  137. package/dist/src/ui/App.js.map +1 -0
  138. package/dist/src/ui/colors.d.ts +25 -0
  139. package/dist/src/ui/colors.js +126 -0
  140. package/dist/src/ui/colors.js.map +1 -0
  141. package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
  142. package/dist/src/ui/commands/aboutCommand.js +61 -0
  143. package/dist/src/ui/commands/aboutCommand.js.map +1 -0
  144. package/dist/src/ui/commands/authCommand.d.ts +7 -0
  145. package/dist/src/ui/commands/authCommand.js +14 -0
  146. package/dist/src/ui/commands/authCommand.js.map +1 -0
  147. package/dist/src/ui/commands/clearCommand.d.ts +7 -0
  148. package/dist/src/ui/commands/clearCommand.js +15 -0
  149. package/dist/src/ui/commands/clearCommand.js.map +1 -0
  150. package/dist/src/ui/commands/helpCommand.d.ts +7 -0
  151. package/dist/src/ui/commands/helpCommand.js +18 -0
  152. package/dist/src/ui/commands/helpCommand.js.map +1 -0
  153. package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
  154. package/dist/src/ui/commands/memoryCommand.js +81 -0
  155. package/dist/src/ui/commands/memoryCommand.js.map +1 -0
  156. package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
  157. package/dist/src/ui/commands/privacyCommand.js +14 -0
  158. package/dist/src/ui/commands/privacyCommand.js.map +1 -0
  159. package/dist/src/ui/commands/themeCommand.d.ts +7 -0
  160. package/dist/src/ui/commands/themeCommand.js +14 -0
  161. package/dist/src/ui/commands/themeCommand.js.map +1 -0
  162. package/dist/src/ui/commands/types.d.ts +63 -0
  163. package/dist/src/ui/commands/types.js +7 -0
  164. package/dist/src/ui/commands/types.js.map +1 -0
  165. package/dist/src/ui/components/AboutBox.d.ts +16 -0
  166. package/dist/src/ui/components/AboutBox.js +6 -0
  167. package/dist/src/ui/components/AboutBox.js.map +1 -0
  168. package/dist/src/ui/components/AsciiArt.d.ts +7 -0
  169. package/dist/src/ui/components/AsciiArt.js +24 -0
  170. package/dist/src/ui/components/AsciiArt.js.map +1 -0
  171. package/dist/src/ui/components/AuthDialog.d.ts +15 -0
  172. package/dist/src/ui/components/AuthDialog.js +102 -0
  173. package/dist/src/ui/components/AuthDialog.js.map +1 -0
  174. package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
  175. package/dist/src/ui/components/AuthInProgress.js +27 -0
  176. package/dist/src/ui/components/AuthInProgress.js.map +1 -0
  177. package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
  178. package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
  179. package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
  180. package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
  181. package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
  182. package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
  183. package/dist/src/ui/components/ContextSummaryDisplay.d.ts +15 -0
  184. package/dist/src/ui/components/ContextSummaryDisplay.js +41 -0
  185. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
  186. package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
  187. package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
  188. package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
  189. package/dist/src/ui/components/EditorSettingsDialog.d.ts +15 -0
  190. package/dist/src/ui/components/EditorSettingsDialog.js +73 -0
  191. package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
  192. package/dist/src/ui/components/ErrorBoundary.d.ts +46 -0
  193. package/dist/src/ui/components/ErrorBoundary.js +115 -0
  194. package/dist/src/ui/components/ErrorBoundary.js.map +1 -0
  195. package/dist/src/ui/components/Footer.d.ts +22 -0
  196. package/dist/src/ui/components/Footer.js +32 -0
  197. package/dist/src/ui/components/Footer.js.map +1 -0
  198. package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
  199. package/dist/src/ui/components/GeminiRespondingSpinner.js +16 -0
  200. package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
  201. package/dist/src/ui/components/Header.d.ts +14 -0
  202. package/dist/src/ui/components/Header.js +20 -0
  203. package/dist/src/ui/components/Header.js.map +1 -0
  204. package/dist/src/ui/components/Help.d.ts +12 -0
  205. package/dist/src/ui/components/Help.js +10 -0
  206. package/dist/src/ui/components/Help.js.map +1 -0
  207. package/dist/src/ui/components/HistoryItemDisplay.d.ts +18 -0
  208. package/dist/src/ui/components/HistoryItemDisplay.js +17 -0
  209. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
  210. package/dist/src/ui/components/InputPrompt.d.ts +25 -0
  211. package/dist/src/ui/components/InputPrompt.js +350 -0
  212. package/dist/src/ui/components/InputPrompt.js.map +1 -0
  213. package/dist/src/ui/components/LayoutManager.d.ts +24 -0
  214. package/dist/src/ui/components/LayoutManager.js +58 -0
  215. package/dist/src/ui/components/LayoutManager.js.map +1 -0
  216. package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
  217. package/dist/src/ui/components/LoadingIndicator.js +20 -0
  218. package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
  219. package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
  220. package/dist/src/ui/components/MemoryUsageDisplay.js +27 -0
  221. package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
  222. package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
  223. package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
  224. package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
  225. package/dist/src/ui/components/ProviderDialog.d.ts +9 -0
  226. package/dist/src/ui/components/ProviderDialog.js +54 -0
  227. package/dist/src/ui/components/ProviderDialog.js.map +1 -0
  228. package/dist/src/ui/components/ProviderModelDialog.d.ts +15 -0
  229. package/dist/src/ui/components/ProviderModelDialog.js +54 -0
  230. package/dist/src/ui/components/ProviderModelDialog.js.map +1 -0
  231. package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
  232. package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
  233. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
  234. package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
  235. package/dist/src/ui/components/ShellModeIndicator.js +5 -0
  236. package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
  237. package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
  238. package/dist/src/ui/components/ShowMoreLines.js +24 -0
  239. package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
  240. package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
  241. package/dist/src/ui/components/StatsDisplay.js +42 -0
  242. package/dist/src/ui/components/StatsDisplay.js.map +1 -0
  243. package/dist/src/ui/components/SuggestionsDisplay.d.ts +21 -0
  244. package/dist/src/ui/components/SuggestionsDisplay.js +32 -0
  245. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
  246. package/dist/src/ui/components/ThemeDialog.d.ts +19 -0
  247. package/dist/src/ui/components/ThemeDialog.js +127 -0
  248. package/dist/src/ui/components/ThemeDialog.js.map +1 -0
  249. package/dist/src/ui/components/Tips.d.ts +12 -0
  250. package/dist/src/ui/components/Tips.js +8 -0
  251. package/dist/src/ui/components/Tips.js.map +1 -0
  252. package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
  253. package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
  254. package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
  255. package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
  256. package/dist/src/ui/components/UpdateNotification.js +10 -0
  257. package/dist/src/ui/components/UpdateNotification.js.map +1 -0
  258. package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
  259. package/dist/src/ui/components/messages/CompressionMessage.js +16 -0
  260. package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
  261. package/dist/src/ui/components/messages/DiffRenderer.d.ts +15 -0
  262. package/dist/src/ui/components/messages/DiffRenderer.js +212 -0
  263. package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
  264. package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
  265. package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
  266. package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
  267. package/dist/src/ui/components/messages/GeminiMessage.d.ts +15 -0
  268. package/dist/src/ui/components/messages/GeminiMessage.js +10 -0
  269. package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
  270. package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
  271. package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
  272. package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
  273. package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
  274. package/dist/src/ui/components/messages/InfoMessage.js +9 -0
  275. package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
  276. package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
  277. package/dist/src/ui/components/messages/ToolConfirmationMessage.js +117 -0
  278. package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
  279. package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
  280. package/dist/src/ui/components/messages/ToolGroupMessage.js +53 -0
  281. package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
  282. package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
  283. package/dist/src/ui/components/messages/ToolMessage.js +61 -0
  284. package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
  285. package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
  286. package/dist/src/ui/components/messages/UserMessage.js +9 -0
  287. package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
  288. package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
  289. package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
  290. package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
  291. package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
  292. package/dist/src/ui/components/shared/MaxSizedBox.js +384 -0
  293. package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
  294. package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +44 -0
  295. package/dist/src/ui/components/shared/RadioButtonSelect.js +77 -0
  296. package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
  297. package/dist/src/ui/components/shared/text-buffer.d.ts +184 -0
  298. package/dist/src/ui/components/shared/text-buffer.js +1021 -0
  299. package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
  300. package/dist/src/ui/constants.d.ts +8 -0
  301. package/dist/src/ui/constants.js +12 -0
  302. package/dist/src/ui/constants.js.map +1 -0
  303. package/dist/src/ui/containers/SessionController.d.ts +26 -0
  304. package/dist/src/ui/containers/SessionController.js +314 -0
  305. package/dist/src/ui/containers/SessionController.js.map +1 -0
  306. package/dist/src/ui/containers/UIStateShell.d.ts +6 -0
  307. package/dist/src/ui/containers/UIStateShell.js +4 -0
  308. package/dist/src/ui/containers/UIStateShell.js.map +1 -0
  309. package/dist/src/ui/contexts/AppDispatchContext.d.ts +12 -0
  310. package/dist/src/ui/contexts/AppDispatchContext.js +17 -0
  311. package/dist/src/ui/contexts/AppDispatchContext.js.map +1 -0
  312. package/dist/src/ui/contexts/OpenAIProviderContext.d.ts +29 -0
  313. package/dist/src/ui/contexts/OpenAIProviderContext.js +63 -0
  314. package/dist/src/ui/contexts/OpenAIProviderContext.js.map +1 -0
  315. package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
  316. package/dist/src/ui/contexts/OverflowContext.js +43 -0
  317. package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
  318. package/dist/src/ui/contexts/SessionContext.d.ts +36 -0
  319. package/dist/src/ui/contexts/SessionContext.js +66 -0
  320. package/dist/src/ui/contexts/SessionContext.js.map +1 -0
  321. package/dist/src/ui/contexts/SessionStateContext.d.ts +15 -0
  322. package/dist/src/ui/contexts/SessionStateContext.js +26 -0
  323. package/dist/src/ui/contexts/SessionStateContext.js.map +1 -0
  324. package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
  325. package/dist/src/ui/contexts/StreamingContext.js +15 -0
  326. package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
  327. package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
  328. package/dist/src/ui/editors/editorSettingsManager.js +54 -0
  329. package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
  330. package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
  331. package/dist/src/ui/hooks/atCommandProcessor.js +310 -0
  332. package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
  333. package/dist/src/ui/hooks/index.d.ts +2 -0
  334. package/dist/src/ui/hooks/index.js +3 -0
  335. package/dist/src/ui/hooks/index.js.map +1 -0
  336. package/dist/src/ui/hooks/shellCommandProcessor.d.ts +16 -0
  337. package/dist/src/ui/hooks/shellCommandProcessor.js +263 -0
  338. package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
  339. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +27 -0
  340. package/dist/src/ui/hooks/slashCommandProcessor.js +1413 -0
  341. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
  342. package/dist/src/ui/hooks/useAuthCommand.d.ts +15 -0
  343. package/dist/src/ui/hooks/useAuthCommand.js +76 -0
  344. package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
  345. package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +10 -0
  346. package/dist/src/ui/hooks/useAutoAcceptIndicator.js +37 -0
  347. package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
  348. package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
  349. package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
  350. package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
  351. package/dist/src/ui/hooks/useCompletion.d.ts +21 -0
  352. package/dist/src/ui/hooks/useCompletion.js +375 -0
  353. package/dist/src/ui/hooks/useCompletion.js.map +1 -0
  354. package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
  355. package/dist/src/ui/hooks/useConsoleMessages.js +60 -0
  356. package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
  357. package/dist/src/ui/hooks/useEditorSettings.d.ts +17 -0
  358. package/dist/src/ui/hooks/useEditorSettings.js +48 -0
  359. package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
  360. package/dist/src/ui/hooks/useGeminiStream.d.ts +23 -0
  361. package/dist/src/ui/hooks/useGeminiStream.js +607 -0
  362. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
  363. package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
  364. package/dist/src/ui/hooks/useGitBranchName.js +61 -0
  365. package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
  366. package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
  367. package/dist/src/ui/hooks/useHistoryManager.js +74 -0
  368. package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
  369. package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
  370. package/dist/src/ui/hooks/useInputHistory.js +84 -0
  371. package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
  372. package/dist/src/ui/hooks/useKeypress.d.ts +29 -0
  373. package/dist/src/ui/hooks/useKeypress.js +162 -0
  374. package/dist/src/ui/hooks/useKeypress.js.map +1 -0
  375. package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
  376. package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
  377. package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
  378. package/dist/src/ui/hooks/useLogger.d.ts +10 -0
  379. package/dist/src/ui/hooks/useLogger.js +29 -0
  380. package/dist/src/ui/hooks/useLogger.js.map +1 -0
  381. package/dist/src/ui/hooks/useOpenAIProviderInfo.d.ts +17 -0
  382. package/dist/src/ui/hooks/useOpenAIProviderInfo.js +43 -0
  383. package/dist/src/ui/hooks/useOpenAIProviderInfo.js.map +1 -0
  384. package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
  385. package/dist/src/ui/hooks/usePhraseCycler.js +197 -0
  386. package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
  387. package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
  388. package/dist/src/ui/hooks/usePrivacySettings.js +115 -0
  389. package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
  390. package/dist/src/ui/hooks/useProviderDialog.d.ts +25 -0
  391. package/dist/src/ui/hooks/useProviderDialog.js +61 -0
  392. package/dist/src/ui/hooks/useProviderDialog.js.map +1 -0
  393. package/dist/src/ui/hooks/useProviderModelDialog.d.ts +26 -0
  394. package/dist/src/ui/hooks/useProviderModelDialog.js +62 -0
  395. package/dist/src/ui/hooks/useProviderModelDialog.js.map +1 -0
  396. package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
  397. package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
  398. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
  399. package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
  400. package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
  401. package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
  402. package/dist/src/ui/hooks/useSession.d.ts +11 -0
  403. package/dist/src/ui/hooks/useSession.js +19 -0
  404. package/dist/src/ui/hooks/useSession.js.map +1 -0
  405. package/dist/src/ui/hooks/useShellHistory.d.ts +11 -0
  406. package/dist/src/ui/hooks/useShellHistory.js +89 -0
  407. package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
  408. package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
  409. package/dist/src/ui/hooks/useShowMemoryCommand.js +50 -0
  410. package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
  411. package/dist/src/ui/hooks/useStableCallback.d.ts +40 -0
  412. package/dist/src/ui/hooks/useStableCallback.js +58 -0
  413. package/dist/src/ui/hooks/useStableCallback.js.map +1 -0
  414. package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
  415. package/dist/src/ui/hooks/useStateAndRef.js +26 -0
  416. package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
  417. package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
  418. package/dist/src/ui/hooks/useTerminalSize.js +27 -0
  419. package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
  420. package/dist/src/ui/hooks/useThemeCommand.d.ts +16 -0
  421. package/dist/src/ui/hooks/useThemeCommand.js +94 -0
  422. package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
  423. package/dist/src/ui/hooks/useTimer.d.ts +12 -0
  424. package/dist/src/ui/hooks/useTimer.js +58 -0
  425. package/dist/src/ui/hooks/useTimer.js.map +1 -0
  426. package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
  427. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +42 -0
  428. package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
  429. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
  430. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +17 -0
  431. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
  432. package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
  433. package/dist/src/ui/privacy/GeminiPrivacyNotice.js +17 -0
  434. package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
  435. package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
  436. package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
  437. package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
  438. package/dist/src/ui/reducers/appReducer.d.ts +59 -0
  439. package/dist/src/ui/reducers/appReducer.js +91 -0
  440. package/dist/src/ui/reducers/appReducer.js.map +1 -0
  441. package/dist/src/ui/reducers/sessionReducer.d.ts +36 -0
  442. package/dist/src/ui/reducers/sessionReducer.js +30 -0
  443. package/dist/src/ui/reducers/sessionReducer.js.map +1 -0
  444. package/dist/src/ui/themes/ansi-light.d.ts +7 -0
  445. package/dist/src/ui/themes/ansi-light.js +139 -0
  446. package/dist/src/ui/themes/ansi-light.js.map +1 -0
  447. package/dist/src/ui/themes/ansi.d.ts +7 -0
  448. package/dist/src/ui/themes/ansi.js +149 -0
  449. package/dist/src/ui/themes/ansi.js.map +1 -0
  450. package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
  451. package/dist/src/ui/themes/atom-one-dark.js +136 -0
  452. package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
  453. package/dist/src/ui/themes/ayu-light.d.ts +7 -0
  454. package/dist/src/ui/themes/ayu-light.js +128 -0
  455. package/dist/src/ui/themes/ayu-light.js.map +1 -0
  456. package/dist/src/ui/themes/ayu.d.ts +7 -0
  457. package/dist/src/ui/themes/ayu.js +102 -0
  458. package/dist/src/ui/themes/ayu.js.map +1 -0
  459. package/dist/src/ui/themes/default-light.d.ts +7 -0
  460. package/dist/src/ui/themes/default-light.js +100 -0
  461. package/dist/src/ui/themes/default-light.js.map +1 -0
  462. package/dist/src/ui/themes/default.d.ts +7 -0
  463. package/dist/src/ui/themes/default.js +143 -0
  464. package/dist/src/ui/themes/default.js.map +1 -0
  465. package/dist/src/ui/themes/dracula.d.ts +7 -0
  466. package/dist/src/ui/themes/dracula.js +113 -0
  467. package/dist/src/ui/themes/dracula.js.map +1 -0
  468. package/dist/src/ui/themes/github-dark.d.ts +7 -0
  469. package/dist/src/ui/themes/github-dark.js +136 -0
  470. package/dist/src/ui/themes/github-dark.js.map +1 -0
  471. package/dist/src/ui/themes/github-light.d.ts +7 -0
  472. package/dist/src/ui/themes/github-light.js +138 -0
  473. package/dist/src/ui/themes/github-light.js.map +1 -0
  474. package/dist/src/ui/themes/googlecode.d.ts +7 -0
  475. package/dist/src/ui/themes/googlecode.js +135 -0
  476. package/dist/src/ui/themes/googlecode.js.map +1 -0
  477. package/dist/src/ui/themes/green-screen.d.ts +7 -0
  478. package/dist/src/ui/themes/green-screen.js +113 -0
  479. package/dist/src/ui/themes/green-screen.js.map +1 -0
  480. package/dist/src/ui/themes/no-color.d.ts +7 -0
  481. package/dist/src/ui/themes/no-color.js +84 -0
  482. package/dist/src/ui/themes/no-color.js.map +1 -0
  483. package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
  484. package/dist/src/ui/themes/shades-of-purple.js +302 -0
  485. package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
  486. package/dist/src/ui/themes/theme-manager.d.ts +33 -0
  487. package/dist/src/ui/themes/theme-manager.js +111 -0
  488. package/dist/src/ui/themes/theme-manager.js.map +1 -0
  489. package/dist/src/ui/themes/theme.d.ts +83 -0
  490. package/dist/src/ui/themes/theme.js +304 -0
  491. package/dist/src/ui/themes/theme.js.map +1 -0
  492. package/dist/src/ui/themes/xcode.d.ts +7 -0
  493. package/dist/src/ui/themes/xcode.js +143 -0
  494. package/dist/src/ui/themes/xcode.js.map +1 -0
  495. package/dist/src/ui/types.d.ts +174 -0
  496. package/dist/src/ui/types.js +43 -0
  497. package/dist/src/ui/types.js.map +1 -0
  498. package/dist/src/ui/utils/CodeColorizer.d.ts +14 -0
  499. package/dist/src/ui/utils/CodeColorizer.js +97 -0
  500. package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
  501. package/dist/src/ui/utils/ConsolePatcher.d.ts +23 -0
  502. package/dist/src/ui/utils/ConsolePatcher.js +42 -0
  503. package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
  504. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
  505. package/dist/src/ui/utils/InlineMarkdownRenderer.js +104 -0
  506. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
  507. package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
  508. package/dist/src/ui/utils/MarkdownDisplay.js +205 -0
  509. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
  510. package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
  511. package/dist/src/ui/utils/TableRenderer.js +84 -0
  512. package/dist/src/ui/utils/TableRenderer.js.map +1 -0
  513. package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
  514. package/dist/src/ui/utils/clipboardUtils.js +127 -0
  515. package/dist/src/ui/utils/clipboardUtils.js.map +1 -0
  516. package/dist/src/ui/utils/commandUtils.d.ts +22 -0
  517. package/dist/src/ui/utils/commandUtils.js +25 -0
  518. package/dist/src/ui/utils/commandUtils.js.map +1 -0
  519. package/dist/src/ui/utils/computeStats.d.ts +10 -0
  520. package/dist/src/ui/utils/computeStats.js +55 -0
  521. package/dist/src/ui/utils/computeStats.js.map +1 -0
  522. package/dist/src/ui/utils/displayUtils.d.ts +17 -0
  523. package/dist/src/ui/utils/displayUtils.js +24 -0
  524. package/dist/src/ui/utils/displayUtils.js.map +1 -0
  525. package/dist/src/ui/utils/errorParsing.d.ts +7 -0
  526. package/dist/src/ui/utils/errorParsing.js +106 -0
  527. package/dist/src/ui/utils/errorParsing.js.map +1 -0
  528. package/dist/src/ui/utils/formatters.d.ts +13 -0
  529. package/dist/src/ui/utils/formatters.js +56 -0
  530. package/dist/src/ui/utils/formatters.js.map +1 -0
  531. package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
  532. package/dist/src/ui/utils/markdownUtilities.js +110 -0
  533. package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
  534. package/dist/src/ui/utils/renderLoopDetector.d.ts +52 -0
  535. package/dist/src/ui/utils/renderLoopDetector.js +146 -0
  536. package/dist/src/ui/utils/renderLoopDetector.js.map +1 -0
  537. package/dist/src/ui/utils/textUtils.d.ts +22 -0
  538. package/dist/src/ui/utils/textUtils.js +58 -0
  539. package/dist/src/ui/utils/textUtils.js.map +1 -0
  540. package/dist/src/ui/utils/updateCheck.d.ts +6 -0
  541. package/dist/src/ui/utils/updateCheck.js +50 -0
  542. package/dist/src/ui/utils/updateCheck.js.map +1 -0
  543. package/dist/src/utils/ConversationContext.d.ts +55 -0
  544. package/dist/src/utils/ConversationContext.js +85 -0
  545. package/dist/src/utils/ConversationContext.js.map +1 -0
  546. package/dist/src/utils/cleanup.d.ts +8 -0
  547. package/dist/src/utils/cleanup.js +34 -0
  548. package/dist/src/utils/cleanup.js.map +1 -0
  549. package/dist/src/utils/package.d.ts +12 -0
  550. package/dist/src/utils/package.js +24 -0
  551. package/dist/src/utils/package.js.map +1 -0
  552. package/dist/src/utils/readStdin.d.ts +6 -0
  553. package/dist/src/utils/readStdin.js +34 -0
  554. package/dist/src/utils/readStdin.js.map +1 -0
  555. package/dist/src/utils/sandbox-macos-permissive-closed.sb +26 -0
  556. package/dist/src/utils/sandbox-macos-permissive-open.sb +19 -0
  557. package/dist/src/utils/sandbox-macos-permissive-proxied.sb +31 -0
  558. package/dist/src/utils/sandbox-macos-restrictive-closed.sb +87 -0
  559. package/dist/src/utils/sandbox-macos-restrictive-open.sb +90 -0
  560. package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +92 -0
  561. package/dist/src/utils/sandbox.d.ts +7 -0
  562. package/dist/src/utils/sandbox.js +680 -0
  563. package/dist/src/utils/sandbox.js.map +1 -0
  564. package/dist/src/utils/startupWarnings.d.ts +6 -0
  565. package/dist/src/utils/startupWarnings.js +40 -0
  566. package/dist/src/utils/startupWarnings.js.map +1 -0
  567. package/dist/src/utils/userStartupWarnings.d.ts +6 -0
  568. package/dist/src/utils/userStartupWarnings.js +48 -0
  569. package/dist/src/utils/userStartupWarnings.js.map +1 -0
  570. package/dist/src/utils/version.d.ts +6 -0
  571. package/dist/src/utils/version.js +11 -0
  572. package/dist/src/utils/version.js.map +1 -0
  573. package/dist/tsconfig.tsbuildinfo +1 -0
  574. package/dist/vybestack-llxprt-code-0.1.12.tgz +0 -0
  575. package/package.json +95 -0
@@ -0,0 +1,680 @@
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 { quote } from 'shell-quote';
12
+ import { USER_SETTINGS_DIR, SETTINGS_DIRECTORY_NAME, } from '../config/settings.js';
13
+ import { promisify } from 'util';
14
+ const execAsync = promisify(exec);
15
+ function getContainerPath(hostPath) {
16
+ if (os.platform() !== 'win32') {
17
+ return hostPath;
18
+ }
19
+ const withForwardSlashes = hostPath.replace(/\\/g, '/');
20
+ const match = withForwardSlashes.match(/^([A-Z]):\/(.*)/i);
21
+ if (match) {
22
+ return `/${match[1].toLowerCase()}/${match[2]}`;
23
+ }
24
+ return hostPath;
25
+ }
26
+ const LOCAL_DEV_SANDBOX_IMAGE_NAME = 'gemini-cli-sandbox';
27
+ const SANDBOX_NETWORK_NAME = 'gemini-cli-sandbox';
28
+ const SANDBOX_PROXY_NAME = 'gemini-cli-sandbox-proxy';
29
+ const BUILTIN_SEATBELT_PROFILES = [
30
+ 'permissive-open',
31
+ 'permissive-closed',
32
+ 'permissive-proxied',
33
+ 'restrictive-open',
34
+ 'restrictive-closed',
35
+ 'restrictive-proxied',
36
+ ];
37
+ /**
38
+ * Determines whether the sandbox container should be run with the current user's UID and GID.
39
+ * This is often necessary on Linux systems (especially Debian/Ubuntu based) when using
40
+ * rootful Docker without userns-remap configured, to avoid permission issues with
41
+ * mounted volumes.
42
+ *
43
+ * The behavior is controlled by the `SANDBOX_SET_UID_GID` environment variable:
44
+ * - If `SANDBOX_SET_UID_GID` is "1" or "true", this function returns `true`.
45
+ * - If `SANDBOX_SET_UID_GID` is "0" or "false", this function returns `false`.
46
+ * - If `SANDBOX_SET_UID_GID` is not set:
47
+ * - On Debian/Ubuntu Linux, it defaults to `true`.
48
+ * - On other OSes, or if OS detection fails, it defaults to `false`.
49
+ *
50
+ * For more context on running Docker containers as non-root, see:
51
+ * https://medium.com/redbubble/running-a-docker-container-as-a-non-root-user-7d2e00f8ee15
52
+ *
53
+ * @returns {Promise<boolean>} A promise that resolves to true if the current user's UID/GID should be used, false otherwise.
54
+ */
55
+ async function shouldUseCurrentUserInSandbox() {
56
+ const envVar = process.env.SANDBOX_SET_UID_GID?.toLowerCase().trim();
57
+ if (envVar === '1' || envVar === 'true') {
58
+ return true;
59
+ }
60
+ if (envVar === '0' || envVar === 'false') {
61
+ return false;
62
+ }
63
+ // If environment variable is not explicitly set, check for Debian/Ubuntu Linux
64
+ if (os.platform() === 'linux') {
65
+ try {
66
+ const osReleaseContent = await readFile('/etc/os-release', 'utf8');
67
+ if (osReleaseContent.includes('ID=debian') ||
68
+ osReleaseContent.includes('ID=ubuntu') ||
69
+ osReleaseContent.match(/^ID_LIKE=.*debian.*/m) || // Covers derivatives
70
+ osReleaseContent.match(/^ID_LIKE=.*ubuntu.*/m) // Covers derivatives
71
+ ) {
72
+ // note here and below we use console.error for informational messages on stderr
73
+ console.error('INFO: Defaulting to use current user UID/GID for Debian/Ubuntu-based Linux.');
74
+ return true;
75
+ }
76
+ }
77
+ catch (_err) {
78
+ // Silently ignore if /etc/os-release is not found or unreadable.
79
+ // The default (false) will be applied in this case.
80
+ console.warn('Warning: Could not read /etc/os-release to auto-detect Debian/Ubuntu for UID/GID default.');
81
+ }
82
+ }
83
+ return false; // Default to false if no other condition is met
84
+ }
85
+ // docker does not allow container names to contain ':' or '/', so we
86
+ // parse those out and make the name a little shorter
87
+ function parseImageName(image) {
88
+ const [fullName, tag] = image.split(':');
89
+ const name = fullName.split('/').at(-1) ?? 'unknown-image';
90
+ return tag ? `${name}-${tag}` : name;
91
+ }
92
+ function ports() {
93
+ return (process.env.SANDBOX_PORTS ?? '')
94
+ .split(',')
95
+ .filter((p) => p.trim())
96
+ .map((p) => p.trim());
97
+ }
98
+ function entrypoint(workdir) {
99
+ const isWindows = os.platform() === 'win32';
100
+ const containerWorkdir = getContainerPath(workdir);
101
+ const shellCmds = [];
102
+ const pathSeparator = isWindows ? ';' : ':';
103
+ let pathSuffix = '';
104
+ if (process.env.PATH) {
105
+ const paths = process.env.PATH.split(pathSeparator);
106
+ for (const p of paths) {
107
+ const containerPath = getContainerPath(p);
108
+ if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
109
+ pathSuffix += `:${containerPath}`;
110
+ }
111
+ }
112
+ }
113
+ if (pathSuffix) {
114
+ shellCmds.push(`export PATH="$PATH${pathSuffix}";`);
115
+ }
116
+ let pythonPathSuffix = '';
117
+ if (process.env.PYTHONPATH) {
118
+ const paths = process.env.PYTHONPATH.split(pathSeparator);
119
+ for (const p of paths) {
120
+ const containerPath = getContainerPath(p);
121
+ if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
122
+ pythonPathSuffix += `:${containerPath}`;
123
+ }
124
+ }
125
+ }
126
+ if (pythonPathSuffix) {
127
+ shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`);
128
+ }
129
+ const projectSandboxBashrc = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.bashrc');
130
+ if (fs.existsSync(projectSandboxBashrc)) {
131
+ shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`);
132
+ }
133
+ ports().forEach((p) => shellCmds.push(`socat TCP4-LISTEN:${p},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${p} 2> /dev/null &`));
134
+ const cliArgs = process.argv.slice(2).map((arg) => quote([arg]));
135
+ const cliCmd = process.env.NODE_ENV === 'development'
136
+ ? process.env.DEBUG
137
+ ? 'npm run debug --'
138
+ : 'npm rebuild && npm run start --'
139
+ : process.env.DEBUG
140
+ ? `node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT || '9229'} $(which llxprt)`
141
+ : 'llxprt';
142
+ const args = [...shellCmds, cliCmd, ...cliArgs];
143
+ return ['bash', '-c', args.join(' ')];
144
+ }
145
+ export async function start_sandbox(config, nodeArgs = []) {
146
+ if (config.command === 'sandbox-exec') {
147
+ // disallow BUILD_SANDBOX
148
+ if (process.env.BUILD_SANDBOX) {
149
+ console.error('ERROR: cannot BUILD_SANDBOX when using MacOS Seatbelt');
150
+ process.exit(1);
151
+ }
152
+ const profile = (process.env.SEATBELT_PROFILE ??= 'permissive-open');
153
+ let profileFile = new URL(`sandbox-macos-${profile}.sb`, import.meta.url)
154
+ .pathname;
155
+ // if profile name is not recognized, then look for file under project settings directory
156
+ if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
157
+ profileFile = path.join(SETTINGS_DIRECTORY_NAME, `sandbox-macos-${profile}.sb`);
158
+ }
159
+ if (!fs.existsSync(profileFile)) {
160
+ console.error(`ERROR: missing macos seatbelt profile file '${profileFile}'`);
161
+ process.exit(1);
162
+ }
163
+ // Log on STDERR so it doesn't clutter the output on STDOUT
164
+ console.error(`using macos seatbelt (profile: ${profile}) ...`);
165
+ // if DEBUG is set, convert to --inspect-brk in NODE_OPTIONS
166
+ const nodeOptions = [
167
+ ...(process.env.DEBUG ? ['--inspect-brk'] : []),
168
+ ...nodeArgs,
169
+ ].join(' ');
170
+ const args = [
171
+ '-D',
172
+ `TARGET_DIR=${fs.realpathSync(process.cwd())}`,
173
+ '-D',
174
+ `TMP_DIR=${fs.realpathSync(os.tmpdir())}`,
175
+ '-D',
176
+ `HOME_DIR=${fs.realpathSync(os.homedir())}`,
177
+ '-D',
178
+ `CACHE_DIR=${fs.realpathSync(execSync(`getconf DARWIN_USER_CACHE_DIR`).toString().trim())}`,
179
+ '-f',
180
+ profileFile,
181
+ 'sh',
182
+ '-c',
183
+ [
184
+ `SANDBOX=sandbox-exec`,
185
+ `NODE_OPTIONS="${nodeOptions}"`,
186
+ ...process.argv.map((arg) => quote([arg])),
187
+ ].join(' '),
188
+ ];
189
+ // start and set up proxy if LLXPRT_SANDBOX_PROXY_COMMAND is set
190
+ const proxyCommand = process.env.LLXPRT_SANDBOX_PROXY_COMMAND;
191
+ let proxyProcess = undefined;
192
+ let sandboxProcess = undefined;
193
+ const sandboxEnv = { ...process.env };
194
+ if (proxyCommand) {
195
+ const proxy = process.env.HTTPS_PROXY ||
196
+ process.env.https_proxy ||
197
+ process.env.HTTP_PROXY ||
198
+ process.env.http_proxy ||
199
+ 'http://localhost:8877';
200
+ sandboxEnv['HTTPS_PROXY'] = proxy;
201
+ sandboxEnv['https_proxy'] = proxy; // lower-case can be required, e.g. for curl
202
+ sandboxEnv['HTTP_PROXY'] = proxy;
203
+ sandboxEnv['http_proxy'] = proxy;
204
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy;
205
+ if (noProxy) {
206
+ sandboxEnv['NO_PROXY'] = noProxy;
207
+ sandboxEnv['no_proxy'] = noProxy;
208
+ }
209
+ proxyProcess = spawn(proxyCommand, {
210
+ stdio: ['ignore', 'pipe', 'pipe'],
211
+ shell: true,
212
+ detached: true,
213
+ });
214
+ // install handlers to stop proxy on exit/signal
215
+ const stopProxy = () => {
216
+ console.log('stopping proxy ...');
217
+ if (proxyProcess?.pid) {
218
+ process.kill(-proxyProcess.pid, 'SIGTERM');
219
+ }
220
+ };
221
+ process.on('exit', stopProxy);
222
+ process.on('SIGINT', stopProxy);
223
+ process.on('SIGTERM', stopProxy);
224
+ // commented out as it disrupts ink rendering
225
+ // proxyProcess.stdout?.on('data', (data) => {
226
+ // console.info(data.toString());
227
+ // });
228
+ proxyProcess.stderr?.on('data', (data) => {
229
+ console.error(data.toString());
230
+ });
231
+ proxyProcess.on('close', (code, signal) => {
232
+ console.error(`ERROR: proxy command '${proxyCommand}' exited with code ${code}, signal ${signal}`);
233
+ if (sandboxProcess?.pid) {
234
+ process.kill(-sandboxProcess.pid, 'SIGTERM');
235
+ }
236
+ process.exit(1);
237
+ });
238
+ console.log('waiting for proxy to start ...');
239
+ await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
240
+ }
241
+ // spawn child and let it inherit stdio
242
+ sandboxProcess = spawn(config.command, args, {
243
+ stdio: 'inherit',
244
+ });
245
+ await new Promise((resolve) => sandboxProcess?.on('close', resolve));
246
+ return;
247
+ }
248
+ console.error(`hopping into sandbox (command: ${config.command}) ...`);
249
+ // determine full path for gemini-cli to distinguish linked vs installed setting
250
+ const gcPath = fs.realpathSync(process.argv[1]);
251
+ const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
252
+ const isCustomProjectSandbox = fs.existsSync(projectSandboxDockerfile);
253
+ const image = config.image;
254
+ const workdir = path.resolve(process.cwd());
255
+ const containerWorkdir = getContainerPath(workdir);
256
+ // if BUILD_SANDBOX is set, then call scripts/build_sandbox.js under gemini-cli repo
257
+ //
258
+ // note this can only be done with binary linked from gemini-cli repo
259
+ if (process.env.BUILD_SANDBOX) {
260
+ if (!gcPath.includes('gemini-cli/packages/')) {
261
+ console.error('ERROR: cannot build sandbox using installed gemini binary; ' +
262
+ 'run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.');
263
+ process.exit(1);
264
+ }
265
+ else {
266
+ console.error('building sandbox ...');
267
+ const gcRoot = gcPath.split('/packages/')[0];
268
+ // if project folder has sandbox.Dockerfile under project settings folder, use that
269
+ let buildArgs = '';
270
+ const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
271
+ if (isCustomProjectSandbox) {
272
+ console.error(`using ${projectSandboxDockerfile} for sandbox`);
273
+ buildArgs += `-f ${path.resolve(projectSandboxDockerfile)} -i ${image}`;
274
+ }
275
+ execSync(`cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`, {
276
+ stdio: 'inherit',
277
+ env: {
278
+ ...process.env,
279
+ LLXPRT_SANDBOX: config.command, // in case sandbox is enabled via flags (see config.ts under cli package)
280
+ },
281
+ });
282
+ }
283
+ }
284
+ // stop if image is missing
285
+ if (!(await ensureSandboxImageIsPresent(config.command, image))) {
286
+ const remedy = image === LOCAL_DEV_SANDBOX_IMAGE_NAME
287
+ ? '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.'
288
+ : 'Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists.';
289
+ console.error(`ERROR: Sandbox image '${image}' is missing or could not be pulled. ${remedy}`);
290
+ process.exit(1);
291
+ }
292
+ // use interactive mode and auto-remove container on exit
293
+ // run init binary inside container to forward signals & reap zombies
294
+ const args = ['run', '-i', '--rm', '--init', '--workdir', containerWorkdir];
295
+ // add TTY only if stdin is TTY as well, i.e. for piped input don't init TTY in container
296
+ if (process.stdin.isTTY) {
297
+ args.push('-t');
298
+ }
299
+ // mount current directory as working directory in sandbox (set via --workdir)
300
+ args.push('--volume', `${workdir}:${containerWorkdir}`);
301
+ // mount user settings directory inside container, after creating if missing
302
+ // note user/home changes inside sandbox and we mount at BOTH paths for consistency
303
+ const userSettingsDirOnHost = USER_SETTINGS_DIR;
304
+ const userSettingsDirInSandbox = getContainerPath(`/home/node/${SETTINGS_DIRECTORY_NAME}`);
305
+ if (!fs.existsSync(userSettingsDirOnHost)) {
306
+ fs.mkdirSync(userSettingsDirOnHost);
307
+ }
308
+ args.push('--volume', `${userSettingsDirOnHost}:${userSettingsDirInSandbox}`);
309
+ if (userSettingsDirInSandbox !== userSettingsDirOnHost) {
310
+ args.push('--volume', `${userSettingsDirOnHost}:${getContainerPath(userSettingsDirOnHost)}`);
311
+ }
312
+ // mount os.tmpdir() as os.tmpdir() inside container
313
+ args.push('--volume', `${os.tmpdir()}:${getContainerPath(os.tmpdir())}`);
314
+ // mount gcloud config directory if it exists
315
+ const gcloudConfigDir = path.join(os.homedir(), '.config', 'gcloud');
316
+ if (fs.existsSync(gcloudConfigDir)) {
317
+ args.push('--volume', `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`);
318
+ }
319
+ // mount ADC file if GOOGLE_APPLICATION_CREDENTIALS is set
320
+ if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
321
+ const adcFile = process.env.GOOGLE_APPLICATION_CREDENTIALS;
322
+ if (fs.existsSync(adcFile)) {
323
+ args.push('--volume', `${adcFile}:${getContainerPath(adcFile)}:ro`);
324
+ args.push('--env', `GOOGLE_APPLICATION_CREDENTIALS=${getContainerPath(adcFile)}`);
325
+ }
326
+ }
327
+ // mount paths listed in SANDBOX_MOUNTS
328
+ if (process.env.SANDBOX_MOUNTS) {
329
+ for (let mount of process.env.SANDBOX_MOUNTS.split(',')) {
330
+ if (mount.trim()) {
331
+ // parse mount as from:to:opts
332
+ let [from, to, opts] = mount.trim().split(':');
333
+ to = to || from; // default to mount at same path inside container
334
+ opts = opts || 'ro'; // default to read-only
335
+ mount = `${from}:${to}:${opts}`;
336
+ // check that from path is absolute
337
+ if (!path.isAbsolute(from)) {
338
+ console.error(`ERROR: path '${from}' listed in SANDBOX_MOUNTS must be absolute`);
339
+ process.exit(1);
340
+ }
341
+ // check that from path exists on host
342
+ if (!fs.existsSync(from)) {
343
+ console.error(`ERROR: missing mount path '${from}' listed in SANDBOX_MOUNTS`);
344
+ process.exit(1);
345
+ }
346
+ console.error(`SANDBOX_MOUNTS: ${from} -> ${to} (${opts})`);
347
+ args.push('--volume', mount);
348
+ }
349
+ }
350
+ }
351
+ // expose env-specified ports on the sandbox
352
+ ports().forEach((p) => args.push('--publish', `${p}:${p}`));
353
+ // if DEBUG is set, expose debugging port
354
+ if (process.env.DEBUG) {
355
+ const debugPort = process.env.DEBUG_PORT || '9229';
356
+ args.push(`--publish`, `${debugPort}:${debugPort}`);
357
+ }
358
+ // copy proxy environment variables, replacing localhost with SANDBOX_PROXY_NAME
359
+ // copy as both upper-case and lower-case as is required by some utilities
360
+ // LLXPRT_SANDBOX_PROXY_COMMAND implies HTTPS_PROXY unless HTTP_PROXY is set
361
+ const proxyCommand = process.env.LLXPRT_SANDBOX_PROXY_COMMAND;
362
+ if (proxyCommand) {
363
+ let proxy = process.env.HTTPS_PROXY ||
364
+ process.env.https_proxy ||
365
+ process.env.HTTP_PROXY ||
366
+ process.env.http_proxy ||
367
+ 'http://localhost:8877';
368
+ proxy = proxy.replace('localhost', SANDBOX_PROXY_NAME);
369
+ if (proxy) {
370
+ args.push('--env', `HTTPS_PROXY=${proxy}`);
371
+ args.push('--env', `https_proxy=${proxy}`); // lower-case can be required, e.g. for curl
372
+ args.push('--env', `HTTP_PROXY=${proxy}`);
373
+ args.push('--env', `http_proxy=${proxy}`);
374
+ }
375
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy;
376
+ if (noProxy) {
377
+ args.push('--env', `NO_PROXY=${noProxy}`);
378
+ args.push('--env', `no_proxy=${noProxy}`);
379
+ }
380
+ // if using proxy, switch to internal networking through proxy
381
+ if (proxy) {
382
+ execSync(`${config.command} network inspect ${SANDBOX_NETWORK_NAME} || ${config.command} network create --internal ${SANDBOX_NETWORK_NAME}`);
383
+ args.push('--network', SANDBOX_NETWORK_NAME);
384
+ // if proxy command is set, create a separate network w/ host access (i.e. non-internal)
385
+ // we will run proxy in its own container connected to both host network and internal network
386
+ // this allows proxy to work even on rootless podman on macos with host<->vm<->container isolation
387
+ if (proxyCommand) {
388
+ execSync(`${config.command} network inspect ${SANDBOX_PROXY_NAME} || ${config.command} network create ${SANDBOX_PROXY_NAME}`);
389
+ }
390
+ }
391
+ }
392
+ // name container after image, plus numeric suffix to avoid conflicts
393
+ const imageName = parseImageName(image);
394
+ let index = 0;
395
+ const containerNameCheck = execSync(`${config.command} ps -a --format "{{.Names}}"`)
396
+ .toString()
397
+ .trim();
398
+ while (containerNameCheck.includes(`${imageName}-${index}`)) {
399
+ index++;
400
+ }
401
+ const containerName = `${imageName}-${index}`;
402
+ args.push('--name', containerName, '--hostname', containerName);
403
+ // copy GEMINI_API_KEY(s)
404
+ if (process.env.GEMINI_API_KEY) {
405
+ args.push('--env', `GEMINI_API_KEY=${process.env.GEMINI_API_KEY}`);
406
+ }
407
+ if (process.env.GOOGLE_API_KEY) {
408
+ args.push('--env', `GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`);
409
+ }
410
+ // copy GOOGLE_GENAI_USE_VERTEXAI
411
+ if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
412
+ args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env.GOOGLE_GENAI_USE_VERTEXAI}`);
413
+ }
414
+ // copy GOOGLE_CLOUD_PROJECT
415
+ if (process.env.GOOGLE_CLOUD_PROJECT) {
416
+ args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT}`);
417
+ }
418
+ // copy GOOGLE_CLOUD_LOCATION
419
+ if (process.env.GOOGLE_CLOUD_LOCATION) {
420
+ args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env.GOOGLE_CLOUD_LOCATION}`);
421
+ }
422
+ // copy GEMINI_MODEL
423
+ if (process.env.GEMINI_MODEL) {
424
+ args.push('--env', `GEMINI_MODEL=${process.env.GEMINI_MODEL}`);
425
+ }
426
+ // copy TERM and COLORTERM to try to maintain terminal setup
427
+ if (process.env.TERM) {
428
+ args.push('--env', `TERM=${process.env.TERM}`);
429
+ }
430
+ if (process.env.COLORTERM) {
431
+ args.push('--env', `COLORTERM=${process.env.COLORTERM}`);
432
+ }
433
+ // copy VIRTUAL_ENV if under working directory
434
+ // also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
435
+ // sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
436
+ // directory will be empty if not set up, which is still preferable to having host binaries
437
+ if (process.env.VIRTUAL_ENV?.toLowerCase().startsWith(workdir.toLowerCase())) {
438
+ const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
439
+ if (!fs.existsSync(sandboxVenvPath)) {
440
+ fs.mkdirSync(sandboxVenvPath, { recursive: true });
441
+ }
442
+ args.push('--volume', `${sandboxVenvPath}:${getContainerPath(process.env.VIRTUAL_ENV)}`);
443
+ args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env.VIRTUAL_ENV)}`);
444
+ }
445
+ // copy additional environment variables from SANDBOX_ENV
446
+ if (process.env.SANDBOX_ENV) {
447
+ for (let env of process.env.SANDBOX_ENV.split(',')) {
448
+ if ((env = env.trim())) {
449
+ if (env.includes('=')) {
450
+ console.error(`SANDBOX_ENV: ${env}`);
451
+ args.push('--env', env);
452
+ }
453
+ else {
454
+ console.error('ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs');
455
+ process.exit(1);
456
+ }
457
+ }
458
+ }
459
+ }
460
+ // copy NODE_OPTIONS
461
+ const existingNodeOptions = process.env.NODE_OPTIONS || '';
462
+ const allNodeOptions = [
463
+ ...(existingNodeOptions ? [existingNodeOptions] : []),
464
+ ...nodeArgs,
465
+ ].join(' ');
466
+ if (allNodeOptions.length > 0) {
467
+ args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
468
+ }
469
+ // set SANDBOX as container name
470
+ args.push('--env', `SANDBOX=${containerName}`);
471
+ // for podman only, use empty --authfile to skip unnecessary auth refresh overhead
472
+ if (config.command === 'podman') {
473
+ const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
474
+ fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
475
+ args.push('--authfile', emptyAuthFilePath);
476
+ }
477
+ // Determine if the current user's UID/GID should be passed to the sandbox.
478
+ // See shouldUseCurrentUserInSandbox for more details.
479
+ let userFlag = '';
480
+ const finalEntrypoint = entrypoint(workdir);
481
+ if (process.env.GEMINI_CLI_INTEGRATION_TEST === 'true') {
482
+ args.push('--user', 'root');
483
+ userFlag = '--user root';
484
+ }
485
+ else if (await shouldUseCurrentUserInSandbox()) {
486
+ // For the user-creation logic to work, the container must start as root.
487
+ // The entrypoint script then handles dropping privileges to the correct user.
488
+ args.push('--user', 'root');
489
+ const uid = execSync('id -u').toString().trim();
490
+ const gid = execSync('id -g').toString().trim();
491
+ // Instead of passing --user to the main sandbox container, we let it
492
+ // start as root, then create a user with the host's UID/GID, and
493
+ // finally switch to that user to run the gemini process. This is
494
+ // necessary on Linux to ensure the user exists within the
495
+ // container's /etc/passwd file, which is required by os.userInfo().
496
+ const username = 'gemini';
497
+ const homeDir = getContainerPath(os.homedir());
498
+ const setupUserCommands = [
499
+ // Use -f with groupadd to avoid errors if the group already exists.
500
+ `groupadd -f -g ${gid} ${username}`,
501
+ // Create user only if it doesn't exist. Use -o for non-unique UID.
502
+ `id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
503
+ ].join(' && ');
504
+ const originalCommand = finalEntrypoint[2];
505
+ const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
506
+ // Use `su -p` to preserve the environment.
507
+ const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
508
+ // The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
509
+ finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
510
+ // We still need userFlag for the simpler proxy container, which does not have this issue.
511
+ userFlag = `--user ${uid}:${gid}`;
512
+ // When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
513
+ args.push('--env', `HOME=${os.homedir()}`);
514
+ }
515
+ // push container image name
516
+ args.push(image);
517
+ // push container entrypoint (including args)
518
+ args.push(...finalEntrypoint);
519
+ // start and set up proxy if LLXPRT_SANDBOX_PROXY_COMMAND is set
520
+ let proxyProcess = undefined;
521
+ let sandboxProcess = undefined;
522
+ if (proxyCommand) {
523
+ // run proxyCommand in its own container
524
+ 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}`;
525
+ proxyProcess = spawn(proxyContainerCommand, {
526
+ stdio: ['ignore', 'pipe', 'pipe'],
527
+ shell: true,
528
+ detached: true,
529
+ });
530
+ // install handlers to stop proxy on exit/signal
531
+ const stopProxy = () => {
532
+ console.log('stopping proxy container ...');
533
+ execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
534
+ };
535
+ process.on('exit', stopProxy);
536
+ process.on('SIGINT', stopProxy);
537
+ process.on('SIGTERM', stopProxy);
538
+ // commented out as it disrupts ink rendering
539
+ // proxyProcess.stdout?.on('data', (data) => {
540
+ // console.info(data.toString());
541
+ // });
542
+ proxyProcess.stderr?.on('data', (data) => {
543
+ console.error(data.toString().trim());
544
+ });
545
+ proxyProcess.on('close', (code, signal) => {
546
+ console.error(`ERROR: proxy container command '${proxyContainerCommand}' exited with code ${code}, signal ${signal}`);
547
+ if (sandboxProcess?.pid) {
548
+ process.kill(-sandboxProcess.pid, 'SIGTERM');
549
+ }
550
+ process.exit(1);
551
+ });
552
+ console.log('waiting for proxy to start ...');
553
+ await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
554
+ // connect proxy container to sandbox network
555
+ // (workaround for older versions of docker that don't support multiple --network args)
556
+ await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
557
+ }
558
+ // spawn child and let it inherit stdio
559
+ sandboxProcess = spawn(config.command, args, {
560
+ stdio: 'inherit',
561
+ });
562
+ sandboxProcess.on('error', (err) => {
563
+ console.error('Sandbox process error:', err);
564
+ });
565
+ await new Promise((resolve) => {
566
+ sandboxProcess?.on('close', (code, signal) => {
567
+ if (code !== 0) {
568
+ console.log(`Sandbox process exited with code: ${code}, signal: ${signal}`);
569
+ }
570
+ resolve();
571
+ });
572
+ });
573
+ }
574
+ // Helper functions to ensure sandbox image is present
575
+ async function imageExists(sandbox, image) {
576
+ return new Promise((resolve) => {
577
+ const args = ['images', '-q', image];
578
+ const checkProcess = spawn(sandbox, args);
579
+ let stdoutData = '';
580
+ if (checkProcess.stdout) {
581
+ checkProcess.stdout.on('data', (data) => {
582
+ stdoutData += data.toString();
583
+ });
584
+ }
585
+ checkProcess.on('error', (err) => {
586
+ console.warn(`Failed to start '${sandbox}' command for image check: ${err.message}`);
587
+ resolve(false);
588
+ });
589
+ checkProcess.on('close', (code) => {
590
+ // Non-zero code might indicate docker daemon not running, etc.
591
+ // The primary success indicator is non-empty stdoutData.
592
+ if (code !== 0) {
593
+ // console.warn(`'${sandbox} images -q ${image}' exited with code ${code}.`);
594
+ }
595
+ resolve(stdoutData.trim() !== '');
596
+ });
597
+ });
598
+ }
599
+ async function pullImage(sandbox, image) {
600
+ console.info(`Attempting to pull image ${image} using ${sandbox}...`);
601
+ return new Promise((resolve) => {
602
+ const args = ['pull', image];
603
+ const pullProcess = spawn(sandbox, args, { stdio: 'pipe' });
604
+ let stderrData = '';
605
+ const onStdoutData = (data) => {
606
+ console.info(data.toString().trim()); // Show pull progress
607
+ };
608
+ const onStderrData = (data) => {
609
+ stderrData += data.toString();
610
+ console.error(data.toString().trim()); // Show pull errors/info from the command itself
611
+ };
612
+ const onError = (err) => {
613
+ console.warn(`Failed to start '${sandbox} pull ${image}' command: ${err.message}`);
614
+ cleanup();
615
+ resolve(false);
616
+ };
617
+ const onClose = (code) => {
618
+ if (code === 0) {
619
+ console.info(`Successfully pulled image ${image}.`);
620
+ cleanup();
621
+ resolve(true);
622
+ }
623
+ else {
624
+ console.warn(`Failed to pull image ${image}. '${sandbox} pull ${image}' exited with code ${code}.`);
625
+ if (stderrData.trim()) {
626
+ // Details already printed by the stderr listener above
627
+ }
628
+ cleanup();
629
+ resolve(false);
630
+ }
631
+ };
632
+ const cleanup = () => {
633
+ if (pullProcess.stdout) {
634
+ pullProcess.stdout.removeListener('data', onStdoutData);
635
+ }
636
+ if (pullProcess.stderr) {
637
+ pullProcess.stderr.removeListener('data', onStderrData);
638
+ }
639
+ pullProcess.removeListener('error', onError);
640
+ pullProcess.removeListener('close', onClose);
641
+ if (pullProcess.connected) {
642
+ pullProcess.disconnect();
643
+ }
644
+ };
645
+ if (pullProcess.stdout) {
646
+ pullProcess.stdout.on('data', onStdoutData);
647
+ }
648
+ if (pullProcess.stderr) {
649
+ pullProcess.stderr.on('data', onStderrData);
650
+ }
651
+ pullProcess.on('error', onError);
652
+ pullProcess.on('close', onClose);
653
+ });
654
+ }
655
+ async function ensureSandboxImageIsPresent(sandbox, image) {
656
+ console.info(`Checking for sandbox image: ${image}`);
657
+ if (await imageExists(sandbox, image)) {
658
+ console.info(`Sandbox image ${image} found locally.`);
659
+ return true;
660
+ }
661
+ console.info(`Sandbox image ${image} not found locally.`);
662
+ if (image === LOCAL_DEV_SANDBOX_IMAGE_NAME) {
663
+ // user needs to build the image themself
664
+ return false;
665
+ }
666
+ if (await pullImage(sandbox, image)) {
667
+ // After attempting to pull, check again to be certain
668
+ if (await imageExists(sandbox, image)) {
669
+ console.info(`Sandbox image ${image} is now available after pulling.`);
670
+ return true;
671
+ }
672
+ else {
673
+ 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.`);
674
+ return false;
675
+ }
676
+ }
677
+ console.error(`Failed to obtain sandbox image ${image} after check and pull attempt.`);
678
+ return false; // Pull command failed or image still not present
679
+ }
680
+ //# sourceMappingURL=sandbox.js.map