@machina.ai/cell-cli 1.0.17-rc1 → 1.0.21-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +11 -8
- package/dist/src/commands/mcp/add.d.ts +7 -0
- package/dist/src/commands/mcp/add.js +166 -0
- package/dist/src/commands/mcp/add.js.map +1 -0
- package/dist/src/commands/mcp/list.d.ts +8 -0
- package/dist/src/commands/mcp/list.js +110 -0
- package/dist/src/commands/mcp/list.js.map +1 -0
- package/dist/src/commands/mcp/remove.d.ts +7 -0
- package/dist/src/commands/mcp/remove.js +44 -0
- package/dist/src/commands/mcp/remove.js.map +1 -0
- package/dist/src/commands/mcp.d.ts +7 -0
- package/dist/src/commands/mcp.js +23 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/config/auth.test.d.ts +6 -0
- package/dist/src/config/auth.test.js +28 -0
- package/dist/src/config/auth.test.js.map +1 -0
- package/dist/src/config/config.d.ts +3 -3
- package/dist/src/config/config.js +138 -69
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/keyBindings.d.ts +66 -0
- package/dist/src/config/keyBindings.js +141 -0
- package/dist/src/config/keyBindings.js.map +1 -0
- package/dist/src/config/keyBindings.test.d.ts +6 -0
- package/dist/src/config/keyBindings.test.js +51 -0
- package/dist/src/config/keyBindings.test.js.map +1 -0
- package/dist/src/config/sandboxConfig.js +3 -3
- package/dist/src/config/sandboxConfig.js.map +1 -1
- package/dist/src/config/settings.d.ts +3 -54
- package/dist/src/config/settings.js +58 -38
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +533 -0
- package/dist/src/config/settingsSchema.js +507 -0
- package/dist/src/config/settingsSchema.js.map +1 -0
- package/dist/src/config/settingsSchema.test.d.ts +6 -0
- package/dist/src/config/settingsSchema.test.js +195 -0
- package/dist/src/config/settingsSchema.test.js.map +1 -0
- package/dist/src/config/trustedFolders.d.ts +37 -0
- package/dist/src/config/trustedFolders.js +118 -0
- package/dist/src/config/trustedFolders.js.map +1 -0
- package/dist/src/config/trustedFolders.test.d.ts +6 -0
- package/dist/src/config/trustedFolders.test.js +160 -0
- package/dist/src/config/trustedFolders.test.js.map +1 -0
- package/dist/src/gemini.js +54 -37
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.d.ts +6 -0
- package/dist/src/gemini.test.js +193 -0
- package/dist/src/gemini.test.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +2 -1
- package/dist/src/generated/git-commit.js +2 -1
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/nonInteractiveCli.js +22 -17
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +5 -2
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.d.ts +6 -0
- package/dist/src/services/BuiltinCommandLoader.test.js +108 -0
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -0
- package/dist/src/services/CommandService.test.d.ts +6 -0
- package/dist/src/services/CommandService.test.js +232 -0
- package/dist/src/services/CommandService.test.js.map +1 -0
- package/dist/src/services/FileCommandLoader.js +10 -8
- package/dist/src/services/FileCommandLoader.js.map +1 -1
- package/dist/src/services/McpPromptLoader.js +3 -3
- package/dist/src/services/McpPromptLoader.js.map +1 -1
- package/dist/src/services/prompt-processors/argumentProcessor.d.ts +2 -7
- package/dist/src/services/prompt-processors/argumentProcessor.js +2 -10
- package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -1
- package/dist/src/services/prompt-processors/shellProcessor.d.ts +16 -13
- package/dist/src/services/prompt-processors/shellProcessor.js +133 -40
- package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -1
- package/dist/src/services/prompt-processors/types.d.ts +2 -0
- package/dist/src/services/prompt-processors/types.js +2 -0
- package/dist/src/services/prompt-processors/types.js.map +1 -1
- package/dist/src/test-utils/customMatchers.d.ts +14 -0
- package/dist/src/test-utils/customMatchers.js +46 -0
- package/dist/src/test-utils/customMatchers.js.map +1 -0
- package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
- package/dist/src/test-utils/mockCommandContext.js +86 -0
- package/dist/src/test-utils/mockCommandContext.js.map +1 -0
- package/dist/src/test-utils/mockCommandContext.test.d.ts +6 -0
- package/dist/src/test-utils/mockCommandContext.test.js +51 -0
- package/dist/src/test-utils/mockCommandContext.test.js.map +1 -0
- package/dist/src/test-utils/render.d.ts +8 -0
- package/dist/src/test-utils/render.js +10 -0
- package/dist/src/test-utils/render.js.map +1 -0
- package/dist/src/ui/App.js +146 -37
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/IdeIntegrationNudge.d.ts +16 -0
- package/dist/src/ui/IdeIntegrationNudge.js +52 -0
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -0
- package/dist/src/ui/commands/aboutCommand.js +9 -5
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/bugCommand.js +13 -5
- package/dist/src/ui/commands/bugCommand.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.js +23 -6
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +2 -4
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/docsCommand.js +1 -1
- package/dist/src/ui/commands/docsCommand.js.map +1 -1
- package/dist/src/ui/commands/ideCommand.js +110 -42
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +7 -3
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/settingsCommand.d.ts +7 -0
- package/dist/src/ui/commands/settingsCommand.js +16 -0
- package/dist/src/ui/commands/settingsCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.js +86 -19
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -1
- package/dist/src/ui/commands/setupGithubCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/setupGithubCommand.test.js +74 -0
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -0
- package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
- package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
- package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +14 -2
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/AboutBox.d.ts +1 -0
- package/dist/src/ui/components/AboutBox.js +1 -1
- package/dist/src/ui/components/AboutBox.js.map +1 -1
- package/dist/src/ui/components/AsciiArt.d.ts +2 -1
- package/dist/src/ui/components/AsciiArt.js +22 -11
- package/dist/src/ui/components/AsciiArt.js.map +1 -1
- package/dist/src/ui/components/AuthDialog.js +12 -6
- package/dist/src/ui/components/AuthDialog.js.map +1 -1
- package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
- package/dist/src/ui/components/AuthDialog.test.js +114 -0
- package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
- package/dist/src/ui/components/AuthInProgress.js +5 -4
- package/dist/src/ui/components/AuthInProgress.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +22 -25
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +9 -0
- package/dist/src/ui/components/ContextUsageDisplay.js +14 -0
- package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -0
- package/dist/src/ui/components/DebugProfiler.js +5 -4
- package/dist/src/ui/components/DebugProfiler.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +6 -5
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.d.ts +16 -0
- package/dist/src/ui/components/FolderTrustDialog.js +39 -0
- package/dist/src/ui/components/FolderTrustDialog.js.map +1 -0
- package/dist/src/ui/components/FolderTrustDialog.test.d.ts +6 -0
- package/dist/src/ui/components/FolderTrustDialog.test.js +26 -0
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +1 -0
- package/dist/src/ui/components/Footer.js +16 -6
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Header.d.ts +0 -1
- package/dist/src/ui/components/Header.js +13 -5
- package/dist/src/ui/components/Header.js.map +1 -1
- package/dist/src/ui/components/Header.test.d.ts +6 -0
- package/dist/src/ui/components/Header.test.js +44 -0
- package/dist/src/ui/components/Header.test.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js +91 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.d.ts +1 -0
- package/dist/src/ui/components/InputPrompt.js +98 -35
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.js +10 -5
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/components/LoadingIndicator.test.js +190 -0
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.d.ts +14 -0
- package/dist/src/ui/components/SettingsDialog.js +519 -0
- package/dist/src/ui/components/SettingsDialog.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.test.d.ts +6 -0
- package/dist/src/ui/components/SettingsDialog.test.js +568 -0
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js +7 -5
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +6 -0
- package/dist/src/ui/components/ShellConfirmationDialog.test.js +40 -0
- package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -0
- package/dist/src/ui/components/StatsDisplay.js +8 -7
- package/dist/src/ui/components/StatsDisplay.js.map +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.js +1 -1
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.js +10 -20
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.js +10 -1
- package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
- package/dist/src/ui/components/messages/InfoMessage.js +2 -1
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +36 -14
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +37 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js +118 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.js +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +154 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js +11 -9
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +6 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js +111 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +17 -4
- package/dist/src/ui/components/shared/text-buffer.js +262 -80
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.js +139 -152
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.d.ts +30 -0
- package/dist/src/ui/contexts/KeypressContext.js +309 -0
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -0
- package/dist/src/ui/contexts/KeypressContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/KeypressContext.test.js +219 -0
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.d.ts +3 -0
- package/dist/src/ui/contexts/SessionContext.js +2 -1
- package/dist/src/ui/contexts/SessionContext.js.map +1 -1
- package/dist/src/ui/contexts/SettingsContext.d.ts +9 -0
- package/dist/src/ui/contexts/SettingsContext.js +15 -0
- package/dist/src/ui/contexts/SettingsContext.js.map +1 -0
- package/dist/src/ui/hooks/atCommandProcessor.js +16 -13
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +6 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js +809 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +6 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +328 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +6 -2
- package/dist/src/ui/hooks/slashCommandProcessor.js +121 -57
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAtCompletion.d.ts +23 -0
- package/dist/src/ui/hooks/useAtCompletion.js +178 -0
- package/dist/src/ui/hooks/useAtCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +5 -5
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +6 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +191 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -0
- package/dist/src/ui/hooks/useCommandCompletion.d.ts +6 -1
- package/dist/src/ui/hooks/useCommandCompletion.js +95 -383
- package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useEditorSettings.test.d.ts +6 -0
- package/dist/src/ui/hooks/useEditorSettings.test.js +164 -0
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -0
- package/dist/src/ui/hooks/useFocus.d.ts +4 -0
- package/dist/src/ui/hooks/useFocus.js +4 -4
- package/dist/src/ui/hooks/useFocus.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +12 -0
- package/dist/src/ui/hooks/useFolderTrust.js +55 -0
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.d.ts +2 -1
- package/dist/src/ui/hooks/useGeminiStream.js +35 -22
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.d.ts +6 -0
- package/dist/src/ui/hooks/useGitBranchName.test.js +175 -0
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -0
- package/dist/src/ui/hooks/useHistoryManager.test.d.ts +6 -0
- package/dist/src/ui/hooks/useHistoryManager.test.js +171 -0
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -0
- package/dist/src/ui/hooks/useInputHistory.test.d.ts +6 -0
- package/dist/src/ui/hooks/useInputHistory.test.js +207 -0
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -0
- package/dist/src/ui/hooks/useKeypress.d.ts +4 -16
- package/dist/src/ui/hooks/useKeypress.js +8 -140
- package/dist/src/ui/hooks/useKeypress.js.map +1 -1
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +91 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/hooks/useMessageQueue.d.ts +22 -0
- package/dist/src/ui/hooks/useMessageQueue.js +49 -0
- package/dist/src/ui/hooks/useMessageQueue.js.map +1 -0
- package/dist/src/ui/hooks/useMessageQueue.test.d.ts +6 -0
- package/dist/src/ui/hooks/useMessageQueue.test.js +158 -0
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +2 -5
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.js +6 -2
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +6 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.js +154 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +18 -16
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.js +4 -2
- package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +163 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useSettingsCommand.d.ts +10 -0
- package/dist/src/ui/hooks/useSettingsCommand.js +21 -0
- package/dist/src/ui/hooks/useSettingsCommand.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.test.d.ts +6 -0
- package/dist/src/ui/hooks/useShellHistory.test.js +159 -0
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -0
- package/dist/src/ui/hooks/useSlashCompletion.d.ts +20 -0
- package/dist/src/ui/hooks/useSlashCompletion.js +135 -0
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.js +272 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useThemeCommand.js +1 -1
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
- package/dist/src/ui/hooks/useTimer.test.d.ts +6 -0
- package/dist/src/ui/hooks/useTimer.test.js +90 -0
- package/dist/src/ui/hooks/useTimer.test.js.map +1 -0
- package/dist/src/ui/hooks/useToolScheduler.test.d.ts +6 -0
- package/dist/src/ui/hooks/useToolScheduler.test.js +846 -0
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -0
- package/dist/src/ui/hooks/vim.js +13 -4
- package/dist/src/ui/hooks/vim.js.map +1 -1
- package/dist/src/ui/keyMatchers.d.ts +26 -0
- package/dist/src/ui/keyMatchers.js +68 -0
- package/dist/src/ui/keyMatchers.js.map +1 -0
- package/dist/src/ui/keyMatchers.test.d.ts +6 -0
- package/dist/src/ui/keyMatchers.test.js +276 -0
- package/dist/src/ui/keyMatchers.test.js.map +1 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +5 -4
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -1
- package/dist/src/ui/semantic-colors.d.ts +7 -0
- package/dist/src/ui/semantic-colors.js +24 -0
- package/dist/src/ui/semantic-colors.js.map +1 -0
- package/dist/src/ui/themes/ansi-light.js +2 -1
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/ansi.js +2 -1
- package/dist/src/ui/themes/ansi.js.map +1 -1
- package/dist/src/ui/themes/atom-one-dark.js +2 -1
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
- package/dist/src/ui/themes/ayu-light.js +2 -1
- package/dist/src/ui/themes/ayu-light.js.map +1 -1
- package/dist/src/ui/themes/ayu.js +2 -1
- package/dist/src/ui/themes/ayu.js.map +1 -1
- package/dist/src/ui/themes/color-utils.test.d.ts +6 -0
- package/dist/src/ui/themes/color-utils.test.js +197 -0
- package/dist/src/ui/themes/color-utils.test.js.map +1 -0
- package/dist/src/ui/themes/default-light.js +2 -1
- package/dist/src/ui/themes/default-light.js.map +1 -1
- package/dist/src/ui/themes/default.js +2 -1
- package/dist/src/ui/themes/default.js.map +1 -1
- package/dist/src/ui/themes/dracula.js +2 -1
- package/dist/src/ui/themes/dracula.js.map +1 -1
- package/dist/src/ui/themes/github-dark.js +2 -1
- package/dist/src/ui/themes/github-dark.js.map +1 -1
- package/dist/src/ui/themes/github-light.js +2 -1
- package/dist/src/ui/themes/github-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +2 -1
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/no-color.js +30 -1
- package/dist/src/ui/themes/no-color.js.map +1 -1
- package/dist/src/ui/themes/semantic-tokens.d.ts +37 -0
- package/dist/src/ui/themes/semantic-tokens.js +94 -0
- package/dist/src/ui/themes/semantic-tokens.js.map +1 -0
- package/dist/src/ui/themes/shades-of-purple.js +2 -1
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.d.ts +6 -0
- package/dist/src/ui/themes/theme-manager.js +8 -1
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.test.d.ts +6 -0
- package/dist/src/ui/themes/theme-manager.test.js +83 -0
- package/dist/src/ui/themes/theme-manager.test.js.map +1 -0
- package/dist/src/ui/themes/theme.d.ts +45 -2
- package/dist/src/ui/themes/theme.js +92 -107
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/themes/xcode.js +2 -1
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/types.d.ts +3 -1
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/CodeColorizer.d.ts +2 -1
- package/dist/src/ui/utils/CodeColorizer.js +5 -4
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
- package/dist/src/ui/utils/ConsolePatcher.d.ts +3 -1
- package/dist/src/ui/utils/ConsolePatcher.js +18 -8
- package/dist/src/ui/utils/ConsolePatcher.js.map +1 -1
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +8 -1
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.js +4 -2
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js +151 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
- package/dist/src/ui/utils/clipboardUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/clipboardUtils.test.js +65 -0
- package/dist/src/ui/utils/clipboardUtils.test.js.map +1 -0
- package/dist/src/ui/utils/commandUtils.d.ts +1 -0
- package/dist/src/ui/utils/commandUtils.js +22 -1
- package/dist/src/ui/utils/commandUtils.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/commandUtils.test.js +294 -0
- package/dist/src/ui/utils/commandUtils.test.js.map +1 -0
- package/dist/src/ui/utils/computeStats.js +3 -1
- package/dist/src/ui/utils/computeStats.js.map +1 -1
- package/dist/src/ui/utils/displayUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/displayUtils.test.js +42 -0
- package/dist/src/ui/utils/displayUtils.test.js.map +1 -0
- package/dist/src/ui/utils/formatters.test.d.ts +6 -0
- package/dist/src/ui/utils/formatters.test.js +56 -0
- package/dist/src/ui/utils/formatters.test.js.map +1 -0
- package/dist/src/ui/utils/isNarrowWidth.d.ts +6 -0
- package/dist/src/ui/utils/isNarrowWidth.js +9 -0
- package/dist/src/ui/utils/isNarrowWidth.js.map +1 -0
- package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
- package/dist/src/ui/utils/markdownUtilities.test.d.ts +6 -0
- package/dist/src/ui/utils/markdownUtilities.test.js +42 -0
- package/dist/src/ui/utils/markdownUtilities.test.js.map +1 -0
- package/dist/src/ui/utils/platformConstants.d.ts +43 -0
- package/dist/src/ui/utils/platformConstants.js +44 -0
- package/dist/src/ui/utils/platformConstants.js.map +1 -0
- package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
- package/dist/src/ui/utils/terminalSetup.js +281 -0
- package/dist/src/ui/utils/terminalSetup.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.js +1 -1
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.test.d.ts +6 -0
- package/dist/src/ui/utils/updateCheck.test.js +145 -0
- package/dist/src/ui/utils/updateCheck.test.js.map +1 -0
- package/dist/src/utils/checks.d.ts +19 -0
- package/dist/src/utils/checks.js +24 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/utils/cleanup.d.ts +2 -2
- package/dist/src/utils/cleanup.js +2 -2
- package/dist/src/utils/cleanup.js.map +1 -1
- package/dist/src/utils/dialogScopeUtils.d.ts +31 -0
- package/dist/src/utils/dialogScopeUtils.js +48 -0
- package/dist/src/utils/dialogScopeUtils.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +21 -1
- package/dist/src/utils/gitUtils.js +68 -3
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/gitUtils.test.d.ts +6 -0
- package/dist/src/utils/gitUtils.test.js +113 -0
- package/dist/src/utils/gitUtils.test.js.map +1 -0
- package/dist/src/utils/installationInfo.test.d.ts +6 -0
- package/dist/src/utils/installationInfo.test.js +242 -0
- package/dist/src/utils/installationInfo.test.js.map +1 -0
- package/dist/src/utils/readStdin.js +10 -0
- package/dist/src/utils/readStdin.js.map +1 -1
- package/dist/src/utils/sandbox.js +443 -420
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/settingsUtils.d.ts +134 -0
- package/dist/src/utils/settingsUtils.js +336 -0
- package/dist/src/utils/settingsUtils.js.map +1 -0
- package/dist/src/utils/settingsUtils.test.d.ts +6 -0
- package/dist/src/utils/settingsUtils.test.js +514 -0
- package/dist/src/utils/settingsUtils.test.js.map +1 -0
- package/dist/src/utils/userStartupWarnings.test.d.ts +6 -0
- package/dist/src/utils/userStartupWarnings.test.js +67 -0
- package/dist/src/utils/userStartupWarnings.test.js.map +1 -0
- package/dist/src/utils/version.js +1 -1
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +3 -3
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/src/zed-integration/acp.d.ts +63 -0
- package/dist/src/{acp → zed-integration}/acp.js +76 -44
- package/dist/src/zed-integration/acp.js.map +1 -0
- package/dist/src/zed-integration/fileSystemService.d.ts +19 -0
- package/dist/src/zed-integration/fileSystemService.js +43 -0
- package/dist/src/zed-integration/fileSystemService.js.map +1 -0
- package/dist/src/zed-integration/schema.d.ts +11679 -0
- package/dist/src/zed-integration/schema.js +305 -0
- package/dist/src/zed-integration/schema.js.map +1 -0
- package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
- package/dist/src/{acp/acpPeer.js → zed-integration/zedIntegration.js} +336 -169
- package/dist/src/zed-integration/zedIntegration.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -9
- package/dist/src/acp/acp.d.ts +0 -208
- package/dist/src/acp/acp.js.map +0 -1
- package/dist/src/acp/acpPeer.d.ts +0 -8
- package/dist/src/acp/acpPeer.js.map +0 -1
- package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +0 -12
- package/dist/src/ui/components/IDEContextDetailDisplay.js +0 -12
- package/dist/src/ui/components/IDEContextDetailDisplay.js.map +0 -1
- package/dist/src/ui/utils/errorParsing.d.ts +0 -7
- package/dist/src/ui/utils/errorParsing.js +0 -90
- package/dist/src/ui/utils/errorParsing.js.map +0 -1
|
@@ -11,6 +11,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
11
11
|
import { quote, parse } from 'shell-quote';
|
|
12
12
|
import { USER_SETTINGS_DIR, SETTINGS_DIRECTORY_NAME, } from '../config/settings.js';
|
|
13
13
|
import { promisify } from 'util';
|
|
14
|
+
import { ConsolePatcher } from '../ui/utils/ConsolePatcher.js';
|
|
14
15
|
const execAsync = promisify(exec);
|
|
15
16
|
function getContainerPath(hostPath) {
|
|
16
17
|
if (os.platform() !== 'win32') {
|
|
@@ -53,7 +54,7 @@ const BUILTIN_SEATBELT_PROFILES = [
|
|
|
53
54
|
* @returns {Promise<boolean>} A promise that resolves to true if the current user's UID/GID should be used, false otherwise.
|
|
54
55
|
*/
|
|
55
56
|
async function shouldUseCurrentUserInSandbox() {
|
|
56
|
-
const envVar = process.env
|
|
57
|
+
const envVar = process.env['SANDBOX_SET_UID_GID']?.toLowerCase().trim();
|
|
57
58
|
if (envVar === '1' || envVar === 'true') {
|
|
58
59
|
return true;
|
|
59
60
|
}
|
|
@@ -90,7 +91,7 @@ function parseImageName(image) {
|
|
|
90
91
|
return tag ? `${name}-${tag}` : name;
|
|
91
92
|
}
|
|
92
93
|
function ports() {
|
|
93
|
-
return (process.env
|
|
94
|
+
return (process.env['SANDBOX_PORTS'] ?? '')
|
|
94
95
|
.split(',')
|
|
95
96
|
.filter((p) => p.trim())
|
|
96
97
|
.map((p) => p.trim());
|
|
@@ -101,8 +102,8 @@ function entrypoint(workdir) {
|
|
|
101
102
|
const shellCmds = [];
|
|
102
103
|
const pathSeparator = isWindows ? ';' : ':';
|
|
103
104
|
let pathSuffix = '';
|
|
104
|
-
if (process.env
|
|
105
|
-
const paths = process.env
|
|
105
|
+
if (process.env['PATH']) {
|
|
106
|
+
const paths = process.env['PATH'].split(pathSeparator);
|
|
106
107
|
for (const p of paths) {
|
|
107
108
|
const containerPath = getContainerPath(p);
|
|
108
109
|
if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
|
|
@@ -114,8 +115,8 @@ function entrypoint(workdir) {
|
|
|
114
115
|
shellCmds.push(`export PATH="$PATH${pathSuffix}";`);
|
|
115
116
|
}
|
|
116
117
|
let pythonPathSuffix = '';
|
|
117
|
-
if (process.env
|
|
118
|
-
const paths = process.env
|
|
118
|
+
if (process.env['PYTHONPATH']) {
|
|
119
|
+
const paths = process.env['PYTHONPATH'].split(pathSeparator);
|
|
119
120
|
for (const p of paths) {
|
|
120
121
|
const containerPath = getContainerPath(p);
|
|
121
122
|
if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
|
|
@@ -132,110 +133,451 @@ function entrypoint(workdir) {
|
|
|
132
133
|
}
|
|
133
134
|
ports().forEach((p) => shellCmds.push(`socat TCP4-LISTEN:${p},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${p} 2> /dev/null &`));
|
|
134
135
|
const cliArgs = process.argv.slice(2).map((arg) => quote([arg]));
|
|
135
|
-
const cliCmd = process.env
|
|
136
|
-
? process.env
|
|
136
|
+
const cliCmd = process.env['NODE_ENV'] === 'development'
|
|
137
|
+
? process.env['DEBUG']
|
|
137
138
|
? 'npm run debug --'
|
|
138
139
|
: 'npm rebuild && npm run start --'
|
|
139
|
-
: process.env
|
|
140
|
-
? `node --inspect-brk=0.0.0.0:${process.env
|
|
140
|
+
: process.env['DEBUG']
|
|
141
|
+
? `node --inspect-brk=0.0.0.0:${process.env['DEBUG_PORT'] || '9229'} $(which gemini)`
|
|
141
142
|
: 'gemini';
|
|
142
143
|
const args = [...shellCmds, cliCmd, ...cliArgs];
|
|
143
144
|
return ['bash', '-c', args.join(' ')];
|
|
144
145
|
}
|
|
145
146
|
export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
const patcher = new ConsolePatcher({
|
|
148
|
+
debugMode: cliConfig?.getDebugMode() || !!process.env['DEBUG'],
|
|
149
|
+
stderr: true,
|
|
150
|
+
});
|
|
151
|
+
patcher.patch();
|
|
152
|
+
try {
|
|
153
|
+
if (config.command === 'sandbox-exec') {
|
|
154
|
+
// disallow BUILD_SANDBOX
|
|
155
|
+
if (process.env['BUILD_SANDBOX']) {
|
|
156
|
+
console.error('ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt');
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
const profile = (process.env['SEATBELT_PROFILE'] ??= 'permissive-open');
|
|
160
|
+
let profileFile = new URL(`sandbox-macos-${profile}.sb`, import.meta.url)
|
|
161
|
+
.pathname;
|
|
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
|
+
console.error(`ERROR: missing macos seatbelt profile file '${profileFile}'`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
// Log on STDERR so it doesn't clutter the output on STDOUT
|
|
171
|
+
console.error(`using macos seatbelt (profile: ${profile}) ...`);
|
|
172
|
+
// if DEBUG is set, convert to --inspect-brk in NODE_OPTIONS
|
|
173
|
+
const nodeOptions = [
|
|
174
|
+
...(process.env['DEBUG'] ? ['--inspect-brk'] : []),
|
|
175
|
+
...nodeArgs,
|
|
176
|
+
].join(' ');
|
|
177
|
+
const args = [
|
|
178
|
+
'-D',
|
|
179
|
+
`TARGET_DIR=${fs.realpathSync(process.cwd())}`,
|
|
180
|
+
'-D',
|
|
181
|
+
`TMP_DIR=${fs.realpathSync(os.tmpdir())}`,
|
|
182
|
+
'-D',
|
|
183
|
+
`HOME_DIR=${fs.realpathSync(os.homedir())}`,
|
|
184
|
+
'-D',
|
|
185
|
+
`CACHE_DIR=${fs.realpathSync(execSync(`getconf DARWIN_USER_CACHE_DIR`).toString().trim())}`,
|
|
186
|
+
];
|
|
187
|
+
// Add included directories from the workspace context
|
|
188
|
+
// Always add 5 INCLUDE_DIR parameters to ensure .sb files can reference them
|
|
189
|
+
const MAX_INCLUDE_DIRS = 5;
|
|
190
|
+
const targetDir = fs.realpathSync(cliConfig?.getTargetDir() || '');
|
|
191
|
+
const includedDirs = [];
|
|
192
|
+
if (cliConfig) {
|
|
193
|
+
const workspaceContext = cliConfig.getWorkspaceContext();
|
|
194
|
+
const directories = workspaceContext.getDirectories();
|
|
195
|
+
// Filter out TARGET_DIR
|
|
196
|
+
for (const dir of directories) {
|
|
197
|
+
const realDir = fs.realpathSync(dir);
|
|
198
|
+
if (realDir !== targetDir) {
|
|
199
|
+
includedDirs.push(realDir);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
for (let i = 0; i < MAX_INCLUDE_DIRS; i++) {
|
|
204
|
+
let dirPath = '/dev/null'; // Default to a safe path that won't cause issues
|
|
205
|
+
if (i < includedDirs.length) {
|
|
206
|
+
dirPath = includedDirs[i];
|
|
207
|
+
}
|
|
208
|
+
args.push('-D', `INCLUDE_DIR_${i}=${dirPath}`);
|
|
209
|
+
}
|
|
210
|
+
args.push('-f', profileFile, 'sh', '-c', [
|
|
211
|
+
`SANDBOX=sandbox-exec`,
|
|
212
|
+
`NODE_OPTIONS="${nodeOptions}"`,
|
|
213
|
+
...process.argv.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
|
+
console.error(`ERROR: proxy command '${proxyCommand}' exited with code ${code}, signal ${signal}`);
|
|
259
|
+
if (sandboxProcess?.pid) {
|
|
260
|
+
process.kill(-sandboxProcess.pid, 'SIGTERM');
|
|
261
|
+
}
|
|
262
|
+
process.exit(1);
|
|
263
|
+
});
|
|
264
|
+
console.log('waiting for proxy to start ...');
|
|
265
|
+
await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
|
|
266
|
+
}
|
|
267
|
+
// spawn child and let it inherit stdio
|
|
268
|
+
sandboxProcess = spawn(config.command, args, {
|
|
269
|
+
stdio: 'inherit',
|
|
270
|
+
});
|
|
271
|
+
await new Promise((resolve) => sandboxProcess?.on('close', resolve));
|
|
272
|
+
return;
|
|
151
273
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
274
|
+
console.error(`hopping into sandbox (command: ${config.command}) ...`);
|
|
275
|
+
// determine full path for gemini-cli to distinguish linked vs installed setting
|
|
276
|
+
const gcPath = fs.realpathSync(process.argv[1]);
|
|
277
|
+
const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
|
|
278
|
+
const isCustomProjectSandbox = fs.existsSync(projectSandboxDockerfile);
|
|
279
|
+
const image = config.image;
|
|
280
|
+
const workdir = path.resolve(process.cwd());
|
|
281
|
+
const containerWorkdir = getContainerPath(workdir);
|
|
282
|
+
// if BUILD_SANDBOX is set, then call scripts/build_sandbox.js under gemini-cli repo
|
|
283
|
+
//
|
|
284
|
+
// note this can only be done with binary linked from gemini-cli repo
|
|
285
|
+
if (process.env['BUILD_SANDBOX']) {
|
|
286
|
+
if (!gcPath.includes('gemini-cli/packages/')) {
|
|
287
|
+
console.error('ERROR: cannot build sandbox using installed gemini binary; ' +
|
|
288
|
+
'run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.');
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
console.error('building sandbox ...');
|
|
293
|
+
const gcRoot = gcPath.split('/packages/')[0];
|
|
294
|
+
// if project folder has sandbox.Dockerfile under project settings folder, use that
|
|
295
|
+
let buildArgs = '';
|
|
296
|
+
const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
|
|
297
|
+
if (isCustomProjectSandbox) {
|
|
298
|
+
console.error(`using ${projectSandboxDockerfile} for sandbox`);
|
|
299
|
+
buildArgs += `-f ${path.resolve(projectSandboxDockerfile)} -i ${image}`;
|
|
300
|
+
}
|
|
301
|
+
execSync(`cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`, {
|
|
302
|
+
stdio: 'inherit',
|
|
303
|
+
env: {
|
|
304
|
+
...process.env,
|
|
305
|
+
GEMINI_SANDBOX: config.command, // in case sandbox is enabled via flags (see config.ts under cli package)
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
}
|
|
158
309
|
}
|
|
159
|
-
if
|
|
160
|
-
|
|
310
|
+
// stop if image is missing
|
|
311
|
+
if (!(await ensureSandboxImageIsPresent(config.command, image))) {
|
|
312
|
+
const remedy = image === LOCAL_DEV_SANDBOX_IMAGE_NAME
|
|
313
|
+
? '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.'
|
|
314
|
+
: 'Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists.';
|
|
315
|
+
console.error(`ERROR: Sandbox image '${image}' is missing or could not be pulled. ${remedy}`);
|
|
161
316
|
process.exit(1);
|
|
162
317
|
}
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
'-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
318
|
+
// use interactive mode and auto-remove container on exit
|
|
319
|
+
// run init binary inside container to forward signals & reap zombies
|
|
320
|
+
const args = ['run', '-i', '--rm', '--init', '--workdir', containerWorkdir];
|
|
321
|
+
// add custom flags from SANDBOX_FLAGS
|
|
322
|
+
if (process.env['SANDBOX_FLAGS']) {
|
|
323
|
+
const flags = parse(process.env['SANDBOX_FLAGS'], process.env).filter((f) => typeof f === 'string');
|
|
324
|
+
args.push(...flags);
|
|
325
|
+
}
|
|
326
|
+
// add TTY only if stdin is TTY as well, i.e. for piped input don't init TTY in container
|
|
327
|
+
if (process.stdin.isTTY) {
|
|
328
|
+
args.push('-t');
|
|
329
|
+
}
|
|
330
|
+
// mount current directory as working directory in sandbox (set via --workdir)
|
|
331
|
+
args.push('--volume', `${workdir}:${containerWorkdir}`);
|
|
332
|
+
// mount user settings directory inside container, after creating if missing
|
|
333
|
+
// note user/home changes inside sandbox and we mount at BOTH paths for consistency
|
|
334
|
+
const userSettingsDirOnHost = USER_SETTINGS_DIR;
|
|
335
|
+
const userSettingsDirInSandbox = getContainerPath(`/home/node/${SETTINGS_DIRECTORY_NAME}`);
|
|
336
|
+
if (!fs.existsSync(userSettingsDirOnHost)) {
|
|
337
|
+
fs.mkdirSync(userSettingsDirOnHost);
|
|
338
|
+
}
|
|
339
|
+
args.push('--volume', `${userSettingsDirOnHost}:${userSettingsDirInSandbox}`);
|
|
340
|
+
if (userSettingsDirInSandbox !== userSettingsDirOnHost) {
|
|
341
|
+
args.push('--volume', `${userSettingsDirOnHost}:${getContainerPath(userSettingsDirOnHost)}`);
|
|
342
|
+
}
|
|
343
|
+
// mount os.tmpdir() as os.tmpdir() inside container
|
|
344
|
+
args.push('--volume', `${os.tmpdir()}:${getContainerPath(os.tmpdir())}`);
|
|
345
|
+
// mount gcloud config directory if it exists
|
|
346
|
+
const gcloudConfigDir = path.join(os.homedir(), '.config', 'gcloud');
|
|
347
|
+
if (fs.existsSync(gcloudConfigDir)) {
|
|
348
|
+
args.push('--volume', `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`);
|
|
349
|
+
}
|
|
350
|
+
// mount ADC file if GOOGLE_APPLICATION_CREDENTIALS is set
|
|
351
|
+
if (process.env['GOOGLE_APPLICATION_CREDENTIALS']) {
|
|
352
|
+
const adcFile = process.env['GOOGLE_APPLICATION_CREDENTIALS'];
|
|
353
|
+
if (fs.existsSync(adcFile)) {
|
|
354
|
+
args.push('--volume', `${adcFile}:${getContainerPath(adcFile)}:ro`);
|
|
355
|
+
args.push('--env', `GOOGLE_APPLICATION_CREDENTIALS=${getContainerPath(adcFile)}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// mount paths listed in SANDBOX_MOUNTS
|
|
359
|
+
if (process.env['SANDBOX_MOUNTS']) {
|
|
360
|
+
for (let mount of process.env['SANDBOX_MOUNTS'].split(',')) {
|
|
361
|
+
if (mount.trim()) {
|
|
362
|
+
// parse mount as from:to:opts
|
|
363
|
+
let [from, to, opts] = mount.trim().split(':');
|
|
364
|
+
to = to || from; // default to mount at same path inside container
|
|
365
|
+
opts = opts || 'ro'; // default to read-only
|
|
366
|
+
mount = `${from}:${to}:${opts}`;
|
|
367
|
+
// check that from path is absolute
|
|
368
|
+
if (!path.isAbsolute(from)) {
|
|
369
|
+
console.error(`ERROR: path '${from}' listed in SANDBOX_MOUNTS must be absolute`);
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
// check that from path exists on host
|
|
373
|
+
if (!fs.existsSync(from)) {
|
|
374
|
+
console.error(`ERROR: missing mount path '${from}' listed in SANDBOX_MOUNTS`);
|
|
375
|
+
process.exit(1);
|
|
376
|
+
}
|
|
377
|
+
console.error(`SANDBOX_MOUNTS: ${from} -> ${to} (${opts})`);
|
|
378
|
+
args.push('--volume', mount);
|
|
193
379
|
}
|
|
194
380
|
}
|
|
195
381
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
382
|
+
// expose env-specified ports on the sandbox
|
|
383
|
+
ports().forEach((p) => args.push('--publish', `${p}:${p}`));
|
|
384
|
+
// if DEBUG is set, expose debugging port
|
|
385
|
+
if (process.env['DEBUG']) {
|
|
386
|
+
const debugPort = process.env['DEBUG_PORT'] || '9229';
|
|
387
|
+
args.push(`--publish`, `${debugPort}:${debugPort}`);
|
|
388
|
+
}
|
|
389
|
+
// copy proxy environment variables, replacing localhost with SANDBOX_PROXY_NAME
|
|
390
|
+
// copy as both upper-case and lower-case as is required by some utilities
|
|
391
|
+
// GEMINI_SANDBOX_PROXY_COMMAND implies HTTPS_PROXY unless HTTP_PROXY is set
|
|
392
|
+
const proxyCommand = process.env['GEMINI_SANDBOX_PROXY_COMMAND'];
|
|
393
|
+
if (proxyCommand) {
|
|
394
|
+
let proxy = process.env['HTTPS_PROXY'] ||
|
|
395
|
+
process.env['https_proxy'] ||
|
|
396
|
+
process.env['HTTP_PROXY'] ||
|
|
397
|
+
process.env['http_proxy'] ||
|
|
398
|
+
'http://localhost:8877';
|
|
399
|
+
proxy = proxy.replace('localhost', SANDBOX_PROXY_NAME);
|
|
400
|
+
if (proxy) {
|
|
401
|
+
args.push('--env', `HTTPS_PROXY=${proxy}`);
|
|
402
|
+
args.push('--env', `https_proxy=${proxy}`); // lower-case can be required, e.g. for curl
|
|
403
|
+
args.push('--env', `HTTP_PROXY=${proxy}`);
|
|
404
|
+
args.push('--env', `http_proxy=${proxy}`);
|
|
405
|
+
}
|
|
406
|
+
const noProxy = process.env['NO_PROXY'] || process.env['no_proxy'];
|
|
407
|
+
if (noProxy) {
|
|
408
|
+
args.push('--env', `NO_PROXY=${noProxy}`);
|
|
409
|
+
args.push('--env', `no_proxy=${noProxy}`);
|
|
410
|
+
}
|
|
411
|
+
// if using proxy, switch to internal networking through proxy
|
|
412
|
+
if (proxy) {
|
|
413
|
+
execSync(`${config.command} network inspect ${SANDBOX_NETWORK_NAME} || ${config.command} network create --internal ${SANDBOX_NETWORK_NAME}`);
|
|
414
|
+
args.push('--network', SANDBOX_NETWORK_NAME);
|
|
415
|
+
// if proxy command is set, create a separate network w/ host access (i.e. non-internal)
|
|
416
|
+
// we will run proxy in its own container connected to both host network and internal network
|
|
417
|
+
// this allows proxy to work even on rootless podman on macos with host<->vm<->container isolation
|
|
418
|
+
if (proxyCommand) {
|
|
419
|
+
execSync(`${config.command} network inspect ${SANDBOX_PROXY_NAME} || ${config.command} network create ${SANDBOX_PROXY_NAME}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
// name container after image, plus numeric suffix to avoid conflicts
|
|
424
|
+
const imageName = parseImageName(image);
|
|
425
|
+
let index = 0;
|
|
426
|
+
const containerNameCheck = execSync(`${config.command} ps -a --format "{{.Names}}"`)
|
|
427
|
+
.toString()
|
|
428
|
+
.trim();
|
|
429
|
+
while (containerNameCheck.includes(`${imageName}-${index}`)) {
|
|
430
|
+
index++;
|
|
431
|
+
}
|
|
432
|
+
const containerName = `${imageName}-${index}`;
|
|
433
|
+
args.push('--name', containerName, '--hostname', containerName);
|
|
434
|
+
// copy GEMINI_API_KEY(s)
|
|
435
|
+
if (process.env['GEMINI_API_KEY']) {
|
|
436
|
+
args.push('--env', `GEMINI_API_KEY=${process.env['GEMINI_API_KEY']}`);
|
|
437
|
+
}
|
|
438
|
+
if (process.env['GOOGLE_API_KEY']) {
|
|
439
|
+
args.push('--env', `GOOGLE_API_KEY=${process.env['GOOGLE_API_KEY']}`);
|
|
440
|
+
}
|
|
441
|
+
// copy GOOGLE_GENAI_USE_VERTEXAI
|
|
442
|
+
if (process.env['GOOGLE_GENAI_USE_VERTEXAI']) {
|
|
443
|
+
args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env['GOOGLE_GENAI_USE_VERTEXAI']}`);
|
|
444
|
+
}
|
|
445
|
+
// copy GOOGLE_GENAI_USE_GCA
|
|
446
|
+
if (process.env['GOOGLE_GENAI_USE_GCA']) {
|
|
447
|
+
args.push('--env', `GOOGLE_GENAI_USE_GCA=${process.env['GOOGLE_GENAI_USE_GCA']}`);
|
|
448
|
+
}
|
|
449
|
+
// copy GOOGLE_CLOUD_PROJECT
|
|
450
|
+
if (process.env['GOOGLE_CLOUD_PROJECT']) {
|
|
451
|
+
args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env['GOOGLE_CLOUD_PROJECT']}`);
|
|
452
|
+
}
|
|
453
|
+
// copy GOOGLE_CLOUD_LOCATION
|
|
454
|
+
if (process.env['GOOGLE_CLOUD_LOCATION']) {
|
|
455
|
+
args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env['GOOGLE_CLOUD_LOCATION']}`);
|
|
456
|
+
}
|
|
457
|
+
// copy GEMINI_MODEL
|
|
458
|
+
if (process.env['GEMINI_MODEL']) {
|
|
459
|
+
args.push('--env', `GEMINI_MODEL=${process.env['GEMINI_MODEL']}`);
|
|
460
|
+
}
|
|
461
|
+
// copy TERM and COLORTERM to try to maintain terminal setup
|
|
462
|
+
if (process.env['TERM']) {
|
|
463
|
+
args.push('--env', `TERM=${process.env['TERM']}`);
|
|
464
|
+
}
|
|
465
|
+
if (process.env['COLORTERM']) {
|
|
466
|
+
args.push('--env', `COLORTERM=${process.env['COLORTERM']}`);
|
|
467
|
+
}
|
|
468
|
+
// Pass through IDE mode environment variables
|
|
469
|
+
for (const envVar of [
|
|
470
|
+
'CELL_CLI_IDE_SERVER_PORT',
|
|
471
|
+
'CELL_CLI_IDE_WORKSPACE_PATH',
|
|
472
|
+
'TERM_PROGRAM',
|
|
473
|
+
]) {
|
|
474
|
+
if (process.env[envVar]) {
|
|
475
|
+
args.push('--env', `${envVar}=${process.env[envVar]}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
// copy VIRTUAL_ENV if under working directory
|
|
479
|
+
// also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
|
|
480
|
+
// sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
|
|
481
|
+
// directory will be empty if not set up, which is still preferable to having host binaries
|
|
482
|
+
if (process.env['VIRTUAL_ENV']
|
|
483
|
+
?.toLowerCase()
|
|
484
|
+
.startsWith(workdir.toLowerCase())) {
|
|
485
|
+
const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
|
|
486
|
+
if (!fs.existsSync(sandboxVenvPath)) {
|
|
487
|
+
fs.mkdirSync(sandboxVenvPath, { recursive: true });
|
|
488
|
+
}
|
|
489
|
+
args.push('--volume', `${sandboxVenvPath}:${getContainerPath(process.env['VIRTUAL_ENV'])}`);
|
|
490
|
+
args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env['VIRTUAL_ENV'])}`);
|
|
491
|
+
}
|
|
492
|
+
// copy additional environment variables from SANDBOX_ENV
|
|
493
|
+
if (process.env['SANDBOX_ENV']) {
|
|
494
|
+
for (let env of process.env['SANDBOX_ENV'].split(',')) {
|
|
495
|
+
if ((env = env.trim())) {
|
|
496
|
+
if (env.includes('=')) {
|
|
497
|
+
console.error(`SANDBOX_ENV: ${env}`);
|
|
498
|
+
args.push('--env', env);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
console.error('ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs');
|
|
502
|
+
process.exit(1);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
200
505
|
}
|
|
201
|
-
args.push('-D', `INCLUDE_DIR_${i}=${dirPath}`);
|
|
202
506
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
...
|
|
207
|
-
|
|
507
|
+
// copy NODE_OPTIONS
|
|
508
|
+
const existingNodeOptions = process.env['NODE_OPTIONS'] || '';
|
|
509
|
+
const allNodeOptions = [
|
|
510
|
+
...(existingNodeOptions ? [existingNodeOptions] : []),
|
|
511
|
+
...nodeArgs,
|
|
512
|
+
].join(' ');
|
|
513
|
+
if (allNodeOptions.length > 0) {
|
|
514
|
+
args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
|
|
515
|
+
}
|
|
516
|
+
// set SANDBOX as container name
|
|
517
|
+
args.push('--env', `SANDBOX=${containerName}`);
|
|
518
|
+
// for podman only, use empty --authfile to skip unnecessary auth refresh overhead
|
|
519
|
+
if (config.command === 'podman') {
|
|
520
|
+
const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
|
|
521
|
+
fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
|
|
522
|
+
args.push('--authfile', emptyAuthFilePath);
|
|
523
|
+
}
|
|
524
|
+
// Determine if the current user's UID/GID should be passed to the sandbox.
|
|
525
|
+
// See shouldUseCurrentUserInSandbox for more details.
|
|
526
|
+
let userFlag = '';
|
|
527
|
+
const finalEntrypoint = entrypoint(workdir);
|
|
528
|
+
if (process.env['GEMINI_CLI_INTEGRATION_TEST'] === 'true') {
|
|
529
|
+
args.push('--user', 'root');
|
|
530
|
+
userFlag = '--user root';
|
|
531
|
+
}
|
|
532
|
+
else if (await shouldUseCurrentUserInSandbox()) {
|
|
533
|
+
// For the user-creation logic to work, the container must start as root.
|
|
534
|
+
// The entrypoint script then handles dropping privileges to the correct user.
|
|
535
|
+
args.push('--user', 'root');
|
|
536
|
+
const uid = execSync('id -u').toString().trim();
|
|
537
|
+
const gid = execSync('id -g').toString().trim();
|
|
538
|
+
// Instead of passing --user to the main sandbox container, we let it
|
|
539
|
+
// start as root, then create a user with the host's UID/GID, and
|
|
540
|
+
// finally switch to that user to run the gemini process. This is
|
|
541
|
+
// necessary on Linux to ensure the user exists within the
|
|
542
|
+
// container's /etc/passwd file, which is required by os.userInfo().
|
|
543
|
+
const username = 'gemini';
|
|
544
|
+
const homeDir = getContainerPath(os.homedir());
|
|
545
|
+
const setupUserCommands = [
|
|
546
|
+
// Use -f with groupadd to avoid errors if the group already exists.
|
|
547
|
+
`groupadd -f -g ${gid} ${username}`,
|
|
548
|
+
// Create user only if it doesn't exist. Use -o for non-unique UID.
|
|
549
|
+
`id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
|
|
550
|
+
].join(' && ');
|
|
551
|
+
const originalCommand = finalEntrypoint[2];
|
|
552
|
+
const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
|
|
553
|
+
// Use `su -p` to preserve the environment.
|
|
554
|
+
const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
|
|
555
|
+
// The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
|
|
556
|
+
finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
|
|
557
|
+
// We still need userFlag for the simpler proxy container, which does not have this issue.
|
|
558
|
+
userFlag = `--user ${uid}:${gid}`;
|
|
559
|
+
// When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
|
|
560
|
+
args.push('--env', `HOME=${os.homedir()}`);
|
|
561
|
+
}
|
|
562
|
+
// push container image name
|
|
563
|
+
args.push(image);
|
|
564
|
+
// push container entrypoint (including args)
|
|
565
|
+
args.push(...finalEntrypoint);
|
|
208
566
|
// start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
|
|
209
|
-
const proxyCommand = process.env.GEMINI_SANDBOX_PROXY_COMMAND;
|
|
210
567
|
let proxyProcess = undefined;
|
|
211
568
|
let sandboxProcess = undefined;
|
|
212
|
-
const sandboxEnv = { ...process.env };
|
|
213
569
|
if (proxyCommand) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
process.env.http_proxy ||
|
|
218
|
-
'http://localhost:8877';
|
|
219
|
-
sandboxEnv['HTTPS_PROXY'] = proxy;
|
|
220
|
-
sandboxEnv['https_proxy'] = proxy; // lower-case can be required, e.g. for curl
|
|
221
|
-
sandboxEnv['HTTP_PROXY'] = proxy;
|
|
222
|
-
sandboxEnv['http_proxy'] = proxy;
|
|
223
|
-
const noProxy = process.env.NO_PROXY || process.env.no_proxy;
|
|
224
|
-
if (noProxy) {
|
|
225
|
-
sandboxEnv['NO_PROXY'] = noProxy;
|
|
226
|
-
sandboxEnv['no_proxy'] = noProxy;
|
|
227
|
-
}
|
|
228
|
-
proxyProcess = spawn(proxyCommand, {
|
|
570
|
+
// run proxyCommand in its own container
|
|
571
|
+
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}`;
|
|
572
|
+
proxyProcess = spawn(proxyContainerCommand, {
|
|
229
573
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
230
574
|
shell: true,
|
|
231
575
|
detached: true,
|
|
232
576
|
});
|
|
233
577
|
// install handlers to stop proxy on exit/signal
|
|
234
578
|
const stopProxy = () => {
|
|
235
|
-
console.log('stopping proxy ...');
|
|
236
|
-
|
|
237
|
-
process.kill(-proxyProcess.pid, 'SIGTERM');
|
|
238
|
-
}
|
|
579
|
+
console.log('stopping proxy container ...');
|
|
580
|
+
execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
|
|
239
581
|
};
|
|
240
582
|
process.on('exit', stopProxy);
|
|
241
583
|
process.on('SIGINT', stopProxy);
|
|
@@ -245,10 +587,10 @@ export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
|
245
587
|
// console.info(data.toString());
|
|
246
588
|
// });
|
|
247
589
|
proxyProcess.stderr?.on('data', (data) => {
|
|
248
|
-
console.error(data.toString());
|
|
590
|
+
console.error(data.toString().trim());
|
|
249
591
|
});
|
|
250
592
|
proxyProcess.on('close', (code, signal) => {
|
|
251
|
-
console.error(`ERROR: proxy command '${
|
|
593
|
+
console.error(`ERROR: proxy container command '${proxyContainerCommand}' exited with code ${code}, signal ${signal}`);
|
|
252
594
|
if (sandboxProcess?.pid) {
|
|
253
595
|
process.kill(-sandboxProcess.pid, 'SIGTERM');
|
|
254
596
|
}
|
|
@@ -256,348 +598,29 @@ export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
|
256
598
|
});
|
|
257
599
|
console.log('waiting for proxy to start ...');
|
|
258
600
|
await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
|
|
601
|
+
// connect proxy container to sandbox network
|
|
602
|
+
// (workaround for older versions of docker that don't support multiple --network args)
|
|
603
|
+
await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
|
|
259
604
|
}
|
|
260
605
|
// spawn child and let it inherit stdio
|
|
261
606
|
sandboxProcess = spawn(config.command, args, {
|
|
262
607
|
stdio: 'inherit',
|
|
263
608
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
console.error(`hopping into sandbox (command: ${config.command}) ...`);
|
|
268
|
-
// determine full path for gemini-cli to distinguish linked vs installed setting
|
|
269
|
-
const gcPath = fs.realpathSync(process.argv[1]);
|
|
270
|
-
const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
|
|
271
|
-
const isCustomProjectSandbox = fs.existsSync(projectSandboxDockerfile);
|
|
272
|
-
const image = config.image;
|
|
273
|
-
const workdir = path.resolve(process.cwd());
|
|
274
|
-
const containerWorkdir = getContainerPath(workdir);
|
|
275
|
-
// if BUILD_SANDBOX is set, then call scripts/build_sandbox.js under gemini-cli repo
|
|
276
|
-
//
|
|
277
|
-
// note this can only be done with binary linked from gemini-cli repo
|
|
278
|
-
if (process.env.BUILD_SANDBOX) {
|
|
279
|
-
if (!gcPath.includes('gemini-cli/packages/')) {
|
|
280
|
-
console.error('ERROR: cannot build sandbox using installed gemini binary; ' +
|
|
281
|
-
'run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.');
|
|
282
|
-
process.exit(1);
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
console.error('building sandbox ...');
|
|
286
|
-
const gcRoot = gcPath.split('/packages/')[0];
|
|
287
|
-
// if project folder has sandbox.Dockerfile under project settings folder, use that
|
|
288
|
-
let buildArgs = '';
|
|
289
|
-
const projectSandboxDockerfile = path.join(SETTINGS_DIRECTORY_NAME, 'sandbox.Dockerfile');
|
|
290
|
-
if (isCustomProjectSandbox) {
|
|
291
|
-
console.error(`using ${projectSandboxDockerfile} for sandbox`);
|
|
292
|
-
buildArgs += `-f ${path.resolve(projectSandboxDockerfile)} -i ${image}`;
|
|
293
|
-
}
|
|
294
|
-
execSync(`cd ${gcRoot} && node scripts/build_sandbox.js -s ${buildArgs}`, {
|
|
295
|
-
stdio: 'inherit',
|
|
296
|
-
env: {
|
|
297
|
-
...process.env,
|
|
298
|
-
GEMINI_SANDBOX: config.command, // in case sandbox is enabled via flags (see config.ts under cli package)
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
// stop if image is missing
|
|
304
|
-
if (!(await ensureSandboxImageIsPresent(config.command, image))) {
|
|
305
|
-
const remedy = image === LOCAL_DEV_SANDBOX_IMAGE_NAME
|
|
306
|
-
? '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.'
|
|
307
|
-
: 'Please check the image name, your network connection, or notify gemini-cli-dev@google.com if the issue persists.';
|
|
308
|
-
console.error(`ERROR: Sandbox image '${image}' is missing or could not be pulled. ${remedy}`);
|
|
309
|
-
process.exit(1);
|
|
310
|
-
}
|
|
311
|
-
// use interactive mode and auto-remove container on exit
|
|
312
|
-
// run init binary inside container to forward signals & reap zombies
|
|
313
|
-
const args = ['run', '-i', '--rm', '--init', '--workdir', containerWorkdir];
|
|
314
|
-
// add custom flags from SANDBOX_FLAGS
|
|
315
|
-
if (process.env.SANDBOX_FLAGS) {
|
|
316
|
-
const flags = parse(process.env.SANDBOX_FLAGS, process.env).filter((f) => typeof f === 'string');
|
|
317
|
-
args.push(...flags);
|
|
318
|
-
}
|
|
319
|
-
// add TTY only if stdin is TTY as well, i.e. for piped input don't init TTY in container
|
|
320
|
-
if (process.stdin.isTTY) {
|
|
321
|
-
args.push('-t');
|
|
322
|
-
}
|
|
323
|
-
// mount current directory as working directory in sandbox (set via --workdir)
|
|
324
|
-
args.push('--volume', `${workdir}:${containerWorkdir}`);
|
|
325
|
-
// mount user settings directory inside container, after creating if missing
|
|
326
|
-
// note user/home changes inside sandbox and we mount at BOTH paths for consistency
|
|
327
|
-
const userSettingsDirOnHost = USER_SETTINGS_DIR;
|
|
328
|
-
const userSettingsDirInSandbox = getContainerPath(`/home/node/${SETTINGS_DIRECTORY_NAME}`);
|
|
329
|
-
if (!fs.existsSync(userSettingsDirOnHost)) {
|
|
330
|
-
fs.mkdirSync(userSettingsDirOnHost);
|
|
331
|
-
}
|
|
332
|
-
args.push('--volume', `${userSettingsDirOnHost}:${userSettingsDirInSandbox}`);
|
|
333
|
-
if (userSettingsDirInSandbox !== userSettingsDirOnHost) {
|
|
334
|
-
args.push('--volume', `${userSettingsDirOnHost}:${getContainerPath(userSettingsDirOnHost)}`);
|
|
335
|
-
}
|
|
336
|
-
// mount os.tmpdir() as os.tmpdir() inside container
|
|
337
|
-
args.push('--volume', `${os.tmpdir()}:${getContainerPath(os.tmpdir())}`);
|
|
338
|
-
// mount gcloud config directory if it exists
|
|
339
|
-
const gcloudConfigDir = path.join(os.homedir(), '.config', 'gcloud');
|
|
340
|
-
if (fs.existsSync(gcloudConfigDir)) {
|
|
341
|
-
args.push('--volume', `${gcloudConfigDir}:${getContainerPath(gcloudConfigDir)}:ro`);
|
|
342
|
-
}
|
|
343
|
-
// mount ADC file if GOOGLE_APPLICATION_CREDENTIALS is set
|
|
344
|
-
if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
345
|
-
const adcFile = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
346
|
-
if (fs.existsSync(adcFile)) {
|
|
347
|
-
args.push('--volume', `${adcFile}:${getContainerPath(adcFile)}:ro`);
|
|
348
|
-
args.push('--env', `GOOGLE_APPLICATION_CREDENTIALS=${getContainerPath(adcFile)}`);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
// mount paths listed in SANDBOX_MOUNTS
|
|
352
|
-
if (process.env.SANDBOX_MOUNTS) {
|
|
353
|
-
for (let mount of process.env.SANDBOX_MOUNTS.split(',')) {
|
|
354
|
-
if (mount.trim()) {
|
|
355
|
-
// parse mount as from:to:opts
|
|
356
|
-
let [from, to, opts] = mount.trim().split(':');
|
|
357
|
-
to = to || from; // default to mount at same path inside container
|
|
358
|
-
opts = opts || 'ro'; // default to read-only
|
|
359
|
-
mount = `${from}:${to}:${opts}`;
|
|
360
|
-
// check that from path is absolute
|
|
361
|
-
if (!path.isAbsolute(from)) {
|
|
362
|
-
console.error(`ERROR: path '${from}' listed in SANDBOX_MOUNTS must be absolute`);
|
|
363
|
-
process.exit(1);
|
|
364
|
-
}
|
|
365
|
-
// check that from path exists on host
|
|
366
|
-
if (!fs.existsSync(from)) {
|
|
367
|
-
console.error(`ERROR: missing mount path '${from}' listed in SANDBOX_MOUNTS`);
|
|
368
|
-
process.exit(1);
|
|
369
|
-
}
|
|
370
|
-
console.error(`SANDBOX_MOUNTS: ${from} -> ${to} (${opts})`);
|
|
371
|
-
args.push('--volume', mount);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// expose env-specified ports on the sandbox
|
|
376
|
-
ports().forEach((p) => args.push('--publish', `${p}:${p}`));
|
|
377
|
-
// if DEBUG is set, expose debugging port
|
|
378
|
-
if (process.env.DEBUG) {
|
|
379
|
-
const debugPort = process.env.DEBUG_PORT || '9229';
|
|
380
|
-
args.push(`--publish`, `${debugPort}:${debugPort}`);
|
|
381
|
-
}
|
|
382
|
-
// copy proxy environment variables, replacing localhost with SANDBOX_PROXY_NAME
|
|
383
|
-
// copy as both upper-case and lower-case as is required by some utilities
|
|
384
|
-
// GEMINI_SANDBOX_PROXY_COMMAND implies HTTPS_PROXY unless HTTP_PROXY is set
|
|
385
|
-
const proxyCommand = process.env.GEMINI_SANDBOX_PROXY_COMMAND;
|
|
386
|
-
if (proxyCommand) {
|
|
387
|
-
let proxy = process.env.HTTPS_PROXY ||
|
|
388
|
-
process.env.https_proxy ||
|
|
389
|
-
process.env.HTTP_PROXY ||
|
|
390
|
-
process.env.http_proxy ||
|
|
391
|
-
'http://localhost:8877';
|
|
392
|
-
proxy = proxy.replace('localhost', SANDBOX_PROXY_NAME);
|
|
393
|
-
if (proxy) {
|
|
394
|
-
args.push('--env', `HTTPS_PROXY=${proxy}`);
|
|
395
|
-
args.push('--env', `https_proxy=${proxy}`); // lower-case can be required, e.g. for curl
|
|
396
|
-
args.push('--env', `HTTP_PROXY=${proxy}`);
|
|
397
|
-
args.push('--env', `http_proxy=${proxy}`);
|
|
398
|
-
}
|
|
399
|
-
const noProxy = process.env.NO_PROXY || process.env.no_proxy;
|
|
400
|
-
if (noProxy) {
|
|
401
|
-
args.push('--env', `NO_PROXY=${noProxy}`);
|
|
402
|
-
args.push('--env', `no_proxy=${noProxy}`);
|
|
403
|
-
}
|
|
404
|
-
// if using proxy, switch to internal networking through proxy
|
|
405
|
-
if (proxy) {
|
|
406
|
-
execSync(`${config.command} network inspect ${SANDBOX_NETWORK_NAME} || ${config.command} network create --internal ${SANDBOX_NETWORK_NAME}`);
|
|
407
|
-
args.push('--network', SANDBOX_NETWORK_NAME);
|
|
408
|
-
// if proxy command is set, create a separate network w/ host access (i.e. non-internal)
|
|
409
|
-
// we will run proxy in its own container connected to both host network and internal network
|
|
410
|
-
// this allows proxy to work even on rootless podman on macos with host<->vm<->container isolation
|
|
411
|
-
if (proxyCommand) {
|
|
412
|
-
execSync(`${config.command} network inspect ${SANDBOX_PROXY_NAME} || ${config.command} network create ${SANDBOX_PROXY_NAME}`);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
// name container after image, plus numeric suffix to avoid conflicts
|
|
417
|
-
const imageName = parseImageName(image);
|
|
418
|
-
let index = 0;
|
|
419
|
-
const containerNameCheck = execSync(`${config.command} ps -a --format "{{.Names}}"`)
|
|
420
|
-
.toString()
|
|
421
|
-
.trim();
|
|
422
|
-
while (containerNameCheck.includes(`${imageName}-${index}`)) {
|
|
423
|
-
index++;
|
|
424
|
-
}
|
|
425
|
-
const containerName = `${imageName}-${index}`;
|
|
426
|
-
args.push('--name', containerName, '--hostname', containerName);
|
|
427
|
-
// copy GEMINI_API_KEY(s)
|
|
428
|
-
if (process.env.GEMINI_API_KEY) {
|
|
429
|
-
args.push('--env', `GEMINI_API_KEY=${process.env.GEMINI_API_KEY}`);
|
|
430
|
-
}
|
|
431
|
-
if (process.env.GOOGLE_API_KEY) {
|
|
432
|
-
args.push('--env', `GOOGLE_API_KEY=${process.env.GOOGLE_API_KEY}`);
|
|
433
|
-
}
|
|
434
|
-
// copy GOOGLE_GENAI_USE_VERTEXAI
|
|
435
|
-
if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
|
|
436
|
-
args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env.GOOGLE_GENAI_USE_VERTEXAI}`);
|
|
437
|
-
}
|
|
438
|
-
// copy GOOGLE_GENAI_USE_GCA
|
|
439
|
-
if (process.env.GOOGLE_GENAI_USE_GCA) {
|
|
440
|
-
args.push('--env', `GOOGLE_GENAI_USE_GCA=${process.env.GOOGLE_GENAI_USE_GCA}`);
|
|
441
|
-
}
|
|
442
|
-
// copy GOOGLE_CLOUD_PROJECT
|
|
443
|
-
if (process.env.GOOGLE_CLOUD_PROJECT) {
|
|
444
|
-
args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT}`);
|
|
445
|
-
}
|
|
446
|
-
// copy GOOGLE_CLOUD_LOCATION
|
|
447
|
-
if (process.env.GOOGLE_CLOUD_LOCATION) {
|
|
448
|
-
args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env.GOOGLE_CLOUD_LOCATION}`);
|
|
449
|
-
}
|
|
450
|
-
// copy GEMINI_MODEL
|
|
451
|
-
if (process.env.GEMINI_MODEL) {
|
|
452
|
-
args.push('--env', `GEMINI_MODEL=${process.env.GEMINI_MODEL}`);
|
|
453
|
-
}
|
|
454
|
-
// copy TERM and COLORTERM to try to maintain terminal setup
|
|
455
|
-
if (process.env.TERM) {
|
|
456
|
-
args.push('--env', `TERM=${process.env.TERM}`);
|
|
457
|
-
}
|
|
458
|
-
if (process.env.COLORTERM) {
|
|
459
|
-
args.push('--env', `COLORTERM=${process.env.COLORTERM}`);
|
|
460
|
-
}
|
|
461
|
-
// copy VIRTUAL_ENV if under working directory
|
|
462
|
-
// also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
|
|
463
|
-
// sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
|
|
464
|
-
// directory will be empty if not set up, which is still preferable to having host binaries
|
|
465
|
-
if (process.env.VIRTUAL_ENV?.toLowerCase().startsWith(workdir.toLowerCase())) {
|
|
466
|
-
const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
|
|
467
|
-
if (!fs.existsSync(sandboxVenvPath)) {
|
|
468
|
-
fs.mkdirSync(sandboxVenvPath, { recursive: true });
|
|
469
|
-
}
|
|
470
|
-
args.push('--volume', `${sandboxVenvPath}:${getContainerPath(process.env.VIRTUAL_ENV)}`);
|
|
471
|
-
args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env.VIRTUAL_ENV)}`);
|
|
472
|
-
}
|
|
473
|
-
// copy additional environment variables from SANDBOX_ENV
|
|
474
|
-
if (process.env.SANDBOX_ENV) {
|
|
475
|
-
for (let env of process.env.SANDBOX_ENV.split(',')) {
|
|
476
|
-
if ((env = env.trim())) {
|
|
477
|
-
if (env.includes('=')) {
|
|
478
|
-
console.error(`SANDBOX_ENV: ${env}`);
|
|
479
|
-
args.push('--env', env);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
console.error('ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs');
|
|
483
|
-
process.exit(1);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
// copy NODE_OPTIONS
|
|
489
|
-
const existingNodeOptions = process.env.NODE_OPTIONS || '';
|
|
490
|
-
const allNodeOptions = [
|
|
491
|
-
...(existingNodeOptions ? [existingNodeOptions] : []),
|
|
492
|
-
...nodeArgs,
|
|
493
|
-
].join(' ');
|
|
494
|
-
if (allNodeOptions.length > 0) {
|
|
495
|
-
args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
|
|
496
|
-
}
|
|
497
|
-
// set SANDBOX as container name
|
|
498
|
-
args.push('--env', `SANDBOX=${containerName}`);
|
|
499
|
-
// for podman only, use empty --authfile to skip unnecessary auth refresh overhead
|
|
500
|
-
if (config.command === 'podman') {
|
|
501
|
-
const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
|
|
502
|
-
fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
|
|
503
|
-
args.push('--authfile', emptyAuthFilePath);
|
|
504
|
-
}
|
|
505
|
-
// Determine if the current user's UID/GID should be passed to the sandbox.
|
|
506
|
-
// See shouldUseCurrentUserInSandbox for more details.
|
|
507
|
-
let userFlag = '';
|
|
508
|
-
const finalEntrypoint = entrypoint(workdir);
|
|
509
|
-
if (process.env.GEMINI_CLI_INTEGRATION_TEST === 'true') {
|
|
510
|
-
args.push('--user', 'root');
|
|
511
|
-
userFlag = '--user root';
|
|
512
|
-
}
|
|
513
|
-
else if (await shouldUseCurrentUserInSandbox()) {
|
|
514
|
-
// For the user-creation logic to work, the container must start as root.
|
|
515
|
-
// The entrypoint script then handles dropping privileges to the correct user.
|
|
516
|
-
args.push('--user', 'root');
|
|
517
|
-
const uid = execSync('id -u').toString().trim();
|
|
518
|
-
const gid = execSync('id -g').toString().trim();
|
|
519
|
-
// Instead of passing --user to the main sandbox container, we let it
|
|
520
|
-
// start as root, then create a user with the host's UID/GID, and
|
|
521
|
-
// finally switch to that user to run the gemini process. This is
|
|
522
|
-
// necessary on Linux to ensure the user exists within the
|
|
523
|
-
// container's /etc/passwd file, which is required by os.userInfo().
|
|
524
|
-
const username = 'gemini';
|
|
525
|
-
const homeDir = getContainerPath(os.homedir());
|
|
526
|
-
const setupUserCommands = [
|
|
527
|
-
// Use -f with groupadd to avoid errors if the group already exists.
|
|
528
|
-
`groupadd -f -g ${gid} ${username}`,
|
|
529
|
-
// Create user only if it doesn't exist. Use -o for non-unique UID.
|
|
530
|
-
`id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
|
|
531
|
-
].join(' && ');
|
|
532
|
-
const originalCommand = finalEntrypoint[2];
|
|
533
|
-
const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
|
|
534
|
-
// Use `su -p` to preserve the environment.
|
|
535
|
-
const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
|
|
536
|
-
// The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
|
|
537
|
-
finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
|
|
538
|
-
// We still need userFlag for the simpler proxy container, which does not have this issue.
|
|
539
|
-
userFlag = `--user ${uid}:${gid}`;
|
|
540
|
-
// When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
|
|
541
|
-
args.push('--env', `HOME=${os.homedir()}`);
|
|
542
|
-
}
|
|
543
|
-
// push container image name
|
|
544
|
-
args.push(image);
|
|
545
|
-
// push container entrypoint (including args)
|
|
546
|
-
args.push(...finalEntrypoint);
|
|
547
|
-
// start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
|
|
548
|
-
let proxyProcess = undefined;
|
|
549
|
-
let sandboxProcess = undefined;
|
|
550
|
-
if (proxyCommand) {
|
|
551
|
-
// run proxyCommand in its own container
|
|
552
|
-
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}`;
|
|
553
|
-
proxyProcess = spawn(proxyContainerCommand, {
|
|
554
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
555
|
-
shell: true,
|
|
556
|
-
detached: true,
|
|
557
|
-
});
|
|
558
|
-
// install handlers to stop proxy on exit/signal
|
|
559
|
-
const stopProxy = () => {
|
|
560
|
-
console.log('stopping proxy container ...');
|
|
561
|
-
execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
|
|
562
|
-
};
|
|
563
|
-
process.on('exit', stopProxy);
|
|
564
|
-
process.on('SIGINT', stopProxy);
|
|
565
|
-
process.on('SIGTERM', stopProxy);
|
|
566
|
-
// commented out as it disrupts ink rendering
|
|
567
|
-
// proxyProcess.stdout?.on('data', (data) => {
|
|
568
|
-
// console.info(data.toString());
|
|
569
|
-
// });
|
|
570
|
-
proxyProcess.stderr?.on('data', (data) => {
|
|
571
|
-
console.error(data.toString().trim());
|
|
609
|
+
sandboxProcess.on('error', (err) => {
|
|
610
|
+
console.error('Sandbox process error:', err);
|
|
572
611
|
});
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
612
|
+
await new Promise((resolve) => {
|
|
613
|
+
sandboxProcess?.on('close', (code, signal) => {
|
|
614
|
+
if (code !== 0) {
|
|
615
|
+
console.log(`Sandbox process exited with code: ${code}, signal: ${signal}`);
|
|
616
|
+
}
|
|
617
|
+
resolve();
|
|
618
|
+
});
|
|
579
619
|
});
|
|
580
|
-
console.log('waiting for proxy to start ...');
|
|
581
|
-
await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
|
|
582
|
-
// connect proxy container to sandbox network
|
|
583
|
-
// (workaround for older versions of docker that don't support multiple --network args)
|
|
584
|
-
await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
|
|
585
620
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
});
|
|
590
|
-
sandboxProcess.on('error', (err) => {
|
|
591
|
-
console.error('Sandbox process error:', err);
|
|
592
|
-
});
|
|
593
|
-
await new Promise((resolve) => {
|
|
594
|
-
sandboxProcess?.on('close', (code, signal) => {
|
|
595
|
-
if (code !== 0) {
|
|
596
|
-
console.log(`Sandbox process exited with code: ${code}, signal: ${signal}`);
|
|
597
|
-
}
|
|
598
|
-
resolve();
|
|
599
|
-
});
|
|
600
|
-
});
|
|
621
|
+
finally {
|
|
622
|
+
patcher.cleanup();
|
|
623
|
+
}
|
|
601
624
|
}
|
|
602
625
|
// Helper functions to ensure sandbox image is present
|
|
603
626
|
async function imageExists(sandbox, image) {
|