@umsai/ums-code 0.0.11-post6 → 0.0.14-v1
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 +5 -5
- package/dist/src/acp/acp.d.ts +208 -0
- package/dist/src/{zed-integration → acp}/acp.js +44 -76
- package/dist/src/acp/acp.js.map +1 -0
- package/dist/src/acp/acpPeer.d.ts +8 -0
- package/dist/src/acp/acpPeer.js +537 -0
- package/dist/src/acp/acpPeer.js.map +1 -0
- package/dist/src/config/auth.js +11 -12
- package/dist/src/config/auth.js.map +1 -1
- package/dist/src/config/config.d.ts +3 -3
- package/dist/src/config/config.js +86 -164
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/extension.d.ts +1 -2
- package/dist/src/config/extension.js +4 -9
- package/dist/src/config/extension.js.map +1 -1
- package/dist/src/config/sandboxConfig.js +3 -3
- package/dist/src/config/sandboxConfig.js.map +1 -1
- package/dist/src/config/settings.d.ts +64 -3
- package/dist/src/config/settings.js +38 -58
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/gemini.js +41 -37
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -2
- package/dist/src/generated/git-commit.js +1 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/nonInteractiveCli.js +8 -3
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.d.ts +1 -0
- package/dist/src/services/BuiltinCommandLoader.js +4 -11
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/FileCommandLoader.js +8 -10
- 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 +7 -2
- package/dist/src/services/prompt-processors/argumentProcessor.js +10 -2
- package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -1
- package/dist/src/services/prompt-processors/shellProcessor.d.ts +13 -16
- package/dist/src/services/prompt-processors/shellProcessor.js +40 -125
- package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -1
- package/dist/src/services/prompt-processors/types.d.ts +0 -2
- package/dist/src/services/prompt-processors/types.js +0 -2
- package/dist/src/services/prompt-processors/types.js.map +1 -1
- package/dist/src/ui/App.js +46 -224
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/aboutCommand.js +5 -9
- package/dist/src/ui/commands/aboutCommand.js.map +1 -1
- package/dist/src/ui/commands/bugCommand.js +5 -13
- package/dist/src/ui/commands/bugCommand.js.map +1 -1
- package/dist/src/ui/commands/chatCommand.js +6 -23
- package/dist/src/ui/commands/chatCommand.js.map +1 -1
- package/dist/src/ui/commands/clearCommand.js +1 -0
- package/dist/src/ui/commands/clearCommand.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +21 -18
- 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 +18 -90
- package/dist/src/ui/commands/ideCommand.js.map +1 -1
- package/dist/src/ui/commands/initCommand.d.ts +1 -1
- package/dist/src/ui/commands/initCommand.js +7 -17
- package/dist/src/ui/commands/initCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +7 -11
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +6 -139
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/quitCommand.d.ts +0 -1
- package/dist/src/ui/commands/quitCommand.js +0 -25
- package/dist/src/ui/commands/quitCommand.js.map +1 -1
- package/dist/src/ui/commands/setupGithubCommand.d.ts +0 -2
- package/dist/src/ui/commands/setupGithubCommand.js +26 -132
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -1
- package/dist/src/ui/commands/toolsCommand.js +2 -2
- package/dist/src/ui/commands/toolsCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +3 -19
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/commands/ums/umsInitCommand.js +21 -55
- package/dist/src/ui/commands/ums/umsInitCommand.js.map +1 -1
- package/dist/src/ui/components/AboutBox.d.ts +0 -1
- 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 +0 -1
- package/dist/src/ui/components/AsciiArt.js +0 -8
- package/dist/src/ui/components/AsciiArt.js.map +1 -1
- package/dist/src/ui/components/AuthDialog.d.ts +1 -1
- package/dist/src/ui/components/AuthDialog.js +15 -17
- package/dist/src/ui/components/AuthDialog.js.map +1 -1
- package/dist/src/ui/components/AuthInProgress.js +5 -6
- package/dist/src/ui/components/AuthInProgress.js.map +1 -1
- package/dist/src/ui/components/ContextSummaryDisplay.js +25 -22
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/DebugProfiler.js +4 -5
- package/dist/src/ui/components/DebugProfiler.js.map +1 -1
- package/dist/src/ui/components/EditorSettingsDialog.js +5 -6
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -1
- package/dist/src/ui/components/Footer.d.ts +0 -1
- package/dist/src/ui/components/Footer.js +6 -16
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Header.d.ts +1 -0
- package/dist/src/ui/components/Header.js +5 -13
- package/dist/src/ui/components/Header.js.map +1 -1
- package/dist/src/ui/components/Help.js +1 -1
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +1 -2
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/IDEContextDetailDisplay.d.ts +12 -0
- package/dist/src/ui/components/IDEContextDetailDisplay.js +12 -0
- package/dist/src/ui/components/IDEContextDetailDisplay.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.d.ts +0 -1
- package/dist/src/ui/components/InputPrompt.js +35 -98
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/LoadingIndicator.js +5 -10
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -1
- package/dist/src/ui/components/ShellConfirmationDialog.js +5 -7
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.js +7 -8
- 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 +20 -10
- package/dist/src/ui/components/ThemeDialog.js.map +1 -1
- package/dist/src/ui/components/messages/DiffRenderer.js +1 -10
- package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -1
- package/dist/src/ui/components/messages/InfoMessage.js +1 -6
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +14 -36
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js +1 -1
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessage.js +10 -75
- package/dist/src/ui/components/messages/ToolMessage.js.map +1 -1
- 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/RadioButtonSelect.js +9 -11
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.d.ts +4 -17
- package/dist/src/ui/components/shared/text-buffer.js +80 -262
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.js +152 -139
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -1
- package/dist/src/ui/components/ums/UMSKeyPrompt.js +3 -3
- package/dist/src/ui/components/ums/UMSKeyPrompt.js.map +1 -1
- package/dist/src/ui/contexts/SessionContext.d.ts +1 -3
- package/dist/src/ui/contexts/SessionContext.js +11 -3
- package/dist/src/ui/contexts/SessionContext.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +16 -17
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.js +13 -8
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +2 -9
- package/dist/src/ui/hooks/slashCommandProcessor.js +62 -234
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAtCompletion.js +3 -4
- package/dist/src/ui/hooks/useAtCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useAuthCommand.js +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +6 -6
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.d.ts +0 -4
- package/dist/src/ui/hooks/useFocus.js +4 -4
- package/dist/src/ui/hooks/useFocus.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.d.ts +3 -4
- package/dist/src/ui/hooks/useGeminiStream.js +33 -50
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.d.ts +16 -4
- package/dist/src/ui/hooks/useKeypress.js +140 -8
- package/dist/src/ui/hooks/useKeypress.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js +2 -2
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.js +2 -6
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +15 -15
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useThemeCommand.js +1 -1
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -1
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +4 -5
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +4 -5
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -1
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +4 -5
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -1
- package/dist/src/ui/themes/ansi-light.js +1 -2
- package/dist/src/ui/themes/ansi-light.js.map +1 -1
- package/dist/src/ui/themes/ansi.js +1 -2
- package/dist/src/ui/themes/ansi.js.map +1 -1
- package/dist/src/ui/themes/atom-one-dark.js +1 -2
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -1
- package/dist/src/ui/themes/ayu-light.js +1 -2
- package/dist/src/ui/themes/ayu-light.js.map +1 -1
- package/dist/src/ui/themes/ayu.js +1 -2
- package/dist/src/ui/themes/ayu.js.map +1 -1
- package/dist/src/ui/themes/default-light.js +1 -2
- package/dist/src/ui/themes/default-light.js.map +1 -1
- package/dist/src/ui/themes/default.js +1 -2
- package/dist/src/ui/themes/default.js.map +1 -1
- package/dist/src/ui/themes/dracula.js +1 -2
- package/dist/src/ui/themes/dracula.js.map +1 -1
- package/dist/src/ui/themes/github-dark.js +1 -2
- package/dist/src/ui/themes/github-dark.js.map +1 -1
- package/dist/src/ui/themes/github-light.js +1 -2
- package/dist/src/ui/themes/github-light.js.map +1 -1
- package/dist/src/ui/themes/googlecode.js +1 -2
- package/dist/src/ui/themes/googlecode.js.map +1 -1
- package/dist/src/ui/themes/no-color.js +1 -30
- package/dist/src/ui/themes/no-color.js.map +1 -1
- package/dist/src/ui/themes/qwen-dark.js +1 -2
- package/dist/src/ui/themes/qwen-dark.js.map +1 -1
- package/dist/src/ui/themes/qwen-light.js +1 -2
- package/dist/src/ui/themes/qwen-light.js.map +1 -1
- package/dist/src/ui/themes/shades-of-purple.js +1 -2
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -1
- package/dist/src/ui/themes/theme-manager.d.ts +0 -6
- package/dist/src/ui/themes/theme-manager.js +1 -8
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/themes/theme.d.ts +2 -45
- package/dist/src/ui/themes/theme.js +107 -92
- package/dist/src/ui/themes/theme.js.map +1 -1
- package/dist/src/ui/themes/xcode.js +1 -2
- package/dist/src/ui/themes/xcode.js.map +1 -1
- package/dist/src/ui/types.d.ts +4 -30
- package/dist/src/ui/types.js +0 -2
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/CodeColorizer.d.ts +1 -2
- package/dist/src/ui/utils/CodeColorizer.js +4 -5
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -1
- package/dist/src/ui/utils/ConsolePatcher.d.ts +0 -1
- package/dist/src/ui/utils/ConsolePatcher.js +0 -3
- package/dist/src/ui/utils/ConsolePatcher.js.map +1 -1
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +1 -8
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
- package/dist/src/ui/utils/MarkdownDisplay.js +2 -4
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
- package/dist/src/ui/utils/commandUtils.d.ts +0 -1
- package/dist/src/ui/utils/commandUtils.js +1 -22
- package/dist/src/ui/utils/commandUtils.js.map +1 -1
- package/dist/src/ui/utils/computeStats.js +1 -3
- package/dist/src/ui/utils/computeStats.js.map +1 -1
- package/dist/src/ui/utils/errorParsing.d.ts +7 -0
- package/dist/src/ui/utils/errorParsing.js +90 -0
- package/dist/src/ui/utils/errorParsing.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +1 -1
- package/dist/src/ui/utils/updateCheck.js +10 -4
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- 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/gitUtils.d.ts +1 -21
- package/dist/src/utils/gitUtils.js +3 -68
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/installationInfo.js +5 -5
- package/dist/src/utils/installationInfo.js.map +1 -1
- package/dist/src/utils/readStdin.js +0 -10
- package/dist/src/utils/readStdin.js.map +1 -1
- package/dist/src/utils/sandbox.js +434 -457
- package/dist/src/utils/sandbox.js.map +1 -1
- package/dist/src/utils/version.js +1 -1
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/validateNonInterActiveAuth.js +7 -4
- package/dist/src/validateNonInterActiveAuth.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/dist/src/commands/mcp/add.d.ts +0 -7
- package/dist/src/commands/mcp/add.js +0 -166
- package/dist/src/commands/mcp/add.js.map +0 -1
- package/dist/src/commands/mcp/list.d.ts +0 -8
- package/dist/src/commands/mcp/list.js +0 -110
- package/dist/src/commands/mcp/list.js.map +0 -1
- package/dist/src/commands/mcp/remove.d.ts +0 -7
- package/dist/src/commands/mcp/remove.js +0 -44
- package/dist/src/commands/mcp/remove.js.map +0 -1
- package/dist/src/commands/mcp.d.ts +0 -7
- package/dist/src/commands/mcp.js +0 -23
- package/dist/src/commands/mcp.js.map +0 -1
- package/dist/src/config/auth.test.d.ts +0 -6
- package/dist/src/config/auth.test.js +0 -57
- package/dist/src/config/auth.test.js.map +0 -1
- package/dist/src/config/keyBindings.d.ts +0 -66
- package/dist/src/config/keyBindings.js +0 -141
- package/dist/src/config/keyBindings.js.map +0 -1
- package/dist/src/config/keyBindings.test.d.ts +0 -6
- package/dist/src/config/keyBindings.test.js +0 -51
- package/dist/src/config/keyBindings.test.js.map +0 -1
- package/dist/src/config/settingsSchema.d.ts +0 -613
- package/dist/src/config/settingsSchema.js +0 -586
- package/dist/src/config/settingsSchema.js.map +0 -1
- package/dist/src/config/settingsSchema.test.d.ts +0 -6
- package/dist/src/config/settingsSchema.test.js +0 -196
- package/dist/src/config/settingsSchema.test.js.map +0 -1
- package/dist/src/config/trustedFolders.d.ts +0 -37
- package/dist/src/config/trustedFolders.js +0 -118
- package/dist/src/config/trustedFolders.js.map +0 -1
- package/dist/src/config/trustedFolders.test.d.ts +0 -6
- package/dist/src/config/trustedFolders.test.js +0 -160
- package/dist/src/config/trustedFolders.test.js.map +0 -1
- package/dist/src/gemini.test.d.ts +0 -6
- package/dist/src/gemini.test.js +0 -193
- package/dist/src/gemini.test.js.map +0 -1
- package/dist/src/services/BuiltinCommandLoader.test.d.ts +0 -6
- package/dist/src/services/BuiltinCommandLoader.test.js +0 -111
- package/dist/src/services/BuiltinCommandLoader.test.js.map +0 -1
- package/dist/src/services/CommandService.test.d.ts +0 -6
- package/dist/src/services/CommandService.test.js +0 -232
- package/dist/src/services/CommandService.test.js.map +0 -1
- package/dist/src/test-utils/customMatchers.d.ts +0 -14
- package/dist/src/test-utils/customMatchers.js +0 -46
- package/dist/src/test-utils/customMatchers.js.map +0 -1
- package/dist/src/test-utils/mockCommandContext.d.ts +0 -18
- package/dist/src/test-utils/mockCommandContext.js +0 -87
- package/dist/src/test-utils/mockCommandContext.js.map +0 -1
- package/dist/src/test-utils/mockCommandContext.test.d.ts +0 -6
- package/dist/src/test-utils/mockCommandContext.test.js +0 -51
- package/dist/src/test-utils/mockCommandContext.test.js.map +0 -1
- package/dist/src/test-utils/render.d.ts +0 -8
- package/dist/src/test-utils/render.js +0 -10
- package/dist/src/test-utils/render.js.map +0 -1
- package/dist/src/ui/IdeIntegrationNudge.d.ts +0 -16
- package/dist/src/ui/IdeIntegrationNudge.js +0 -52
- package/dist/src/ui/IdeIntegrationNudge.js.map +0 -1
- package/dist/src/ui/commands/agentsCommand.d.ts +0 -7
- package/dist/src/ui/commands/agentsCommand.js +0 -32
- package/dist/src/ui/commands/agentsCommand.js.map +0 -1
- package/dist/src/ui/commands/settingsCommand.d.ts +0 -7
- package/dist/src/ui/commands/settingsCommand.js +0 -16
- package/dist/src/ui/commands/settingsCommand.js.map +0 -1
- package/dist/src/ui/commands/setupGithubCommand.test.d.ts +0 -6
- package/dist/src/ui/commands/setupGithubCommand.test.js +0 -167
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +0 -1
- package/dist/src/ui/commands/summaryCommand.d.ts +0 -7
- package/dist/src/ui/commands/summaryCommand.js +0 -149
- package/dist/src/ui/commands/summaryCommand.js.map +0 -1
- package/dist/src/ui/commands/terminalSetupCommand.d.ts +0 -13
- package/dist/src/ui/commands/terminalSetupCommand.js +0 -41
- package/dist/src/ui/commands/terminalSetupCommand.js.map +0 -1
- package/dist/src/ui/components/AuthDialog.test.d.ts +0 -6
- package/dist/src/ui/components/AuthDialog.test.js +0 -220
- package/dist/src/ui/components/AuthDialog.test.js.map +0 -1
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +0 -9
- package/dist/src/ui/components/ContextUsageDisplay.js +0 -14
- package/dist/src/ui/components/ContextUsageDisplay.js.map +0 -1
- package/dist/src/ui/components/FolderTrustDialog.d.ts +0 -16
- package/dist/src/ui/components/FolderTrustDialog.js +0 -39
- package/dist/src/ui/components/FolderTrustDialog.js.map +0 -1
- package/dist/src/ui/components/FolderTrustDialog.test.d.ts +0 -6
- package/dist/src/ui/components/FolderTrustDialog.test.js +0 -26
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +0 -1
- package/dist/src/ui/components/Header.test.d.ts +0 -6
- package/dist/src/ui/components/Header.test.js +0 -37
- package/dist/src/ui/components/Header.test.js.map +0 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +0 -6
- package/dist/src/ui/components/HistoryItemDisplay.test.js +0 -91
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +0 -1
- package/dist/src/ui/components/LoadingIndicator.test.d.ts +0 -6
- package/dist/src/ui/components/LoadingIndicator.test.js +0 -190
- package/dist/src/ui/components/LoadingIndicator.test.js.map +0 -1
- package/dist/src/ui/components/OpenAIKeyPrompt.test.d.ts +0 -6
- package/dist/src/ui/components/OpenAIKeyPrompt.test.js +0 -44
- package/dist/src/ui/components/OpenAIKeyPrompt.test.js.map +0 -1
- package/dist/src/ui/components/QuitConfirmationDialog.d.ts +0 -17
- package/dist/src/ui/components/QuitConfirmationDialog.js +0 -44
- package/dist/src/ui/components/QuitConfirmationDialog.js.map +0 -1
- package/dist/src/ui/components/QwenOAuthProgress.test.d.ts +0 -6
- package/dist/src/ui/components/QwenOAuthProgress.test.js +0 -292
- package/dist/src/ui/components/QwenOAuthProgress.test.js.map +0 -1
- package/dist/src/ui/components/SettingsDialog.d.ts +0 -14
- package/dist/src/ui/components/SettingsDialog.js +0 -519
- package/dist/src/ui/components/SettingsDialog.js.map +0 -1
- package/dist/src/ui/components/SettingsDialog.test.d.ts +0 -6
- package/dist/src/ui/components/SettingsDialog.test.js +0 -568
- package/dist/src/ui/components/SettingsDialog.test.js.map +0 -1
- package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +0 -6
- package/dist/src/ui/components/ShellConfirmationDialog.test.js +0 -40
- package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +0 -1
- package/dist/src/ui/components/TodoDisplay.d.ts +0 -16
- package/dist/src/ui/components/TodoDisplay.js +0 -27
- package/dist/src/ui/components/TodoDisplay.js.map +0 -1
- package/dist/src/ui/components/TodoDisplay.test.d.ts +0 -6
- package/dist/src/ui/components/TodoDisplay.test.js +0 -77
- package/dist/src/ui/components/TodoDisplay.test.js.map +0 -1
- package/dist/src/ui/components/WelcomeBackDialog.d.ts +0 -13
- package/dist/src/ui/components/WelcomeBackDialog.js +0 -31
- package/dist/src/ui/components/WelcomeBackDialog.js.map +0 -1
- package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +0 -6
- package/dist/src/ui/components/messages/DiffRenderer.test.js +0 -239
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +0 -1
- package/dist/src/ui/components/messages/SummaryMessage.d.ts +0 -11
- package/dist/src/ui/components/messages/SummaryMessage.js +0 -35
- package/dist/src/ui/components/messages/SummaryMessage.js.map +0 -1
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +0 -6
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +0 -37
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +0 -1
- package/dist/src/ui/components/messages/ToolMessage.test.d.ts +0 -6
- package/dist/src/ui/components/messages/ToolMessage.test.js +0 -146
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +0 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +0 -6
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +0 -154
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +0 -1
- package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +0 -6
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js +0 -111
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +0 -1
- package/dist/src/ui/components/shared/TextInput.d.ts +0 -16
- package/dist/src/ui/components/shared/TextInput.js +0 -127
- package/dist/src/ui/components/shared/TextInput.js.map +0 -1
- package/dist/src/ui/components/subagents/constants.d.ts +0 -23
- package/dist/src/ui/components/subagents/constants.js +0 -67
- package/dist/src/ui/components/subagents/constants.js.map +0 -1
- package/dist/src/ui/components/subagents/create/AgentCreationWizard.d.ts +0 -15
- package/dist/src/ui/components/subagents/create/AgentCreationWizard.js +0 -171
- package/dist/src/ui/components/subagents/create/AgentCreationWizard.js.map +0 -1
- package/dist/src/ui/components/subagents/create/ColorSelector.d.ts +0 -15
- package/dist/src/ui/components/subagents/create/ColorSelector.js +0 -41
- package/dist/src/ui/components/subagents/create/ColorSelector.js.map +0 -1
- package/dist/src/ui/components/subagents/create/CreationSummary.d.ts +0 -10
- package/dist/src/ui/components/subagents/create/CreationSummary.js +0 -163
- package/dist/src/ui/components/subagents/create/CreationSummary.js.map +0 -1
- package/dist/src/ui/components/subagents/create/DescriptionInput.d.ts +0 -10
- package/dist/src/ui/components/subagents/create/DescriptionInput.js +0 -105
- package/dist/src/ui/components/subagents/create/DescriptionInput.js.map +0 -1
- package/dist/src/ui/components/subagents/create/GenerationMethodSelector.d.ts +0 -10
- package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js +0 -33
- package/dist/src/ui/components/subagents/create/GenerationMethodSelector.js.map +0 -1
- package/dist/src/ui/components/subagents/create/LocationSelector.d.ts +0 -10
- package/dist/src/ui/components/subagents/create/LocationSelector.js +0 -33
- package/dist/src/ui/components/subagents/create/LocationSelector.js.map +0 -1
- package/dist/src/ui/components/subagents/create/TextEntryStep.d.ts +0 -26
- package/dist/src/ui/components/subagents/create/TextEntryStep.js +0 -28
- package/dist/src/ui/components/subagents/create/TextEntryStep.js.map +0 -1
- package/dist/src/ui/components/subagents/create/ToolSelector.d.ts +0 -16
- package/dist/src/ui/components/subagents/create/ToolSelector.js +0 -143
- package/dist/src/ui/components/subagents/create/ToolSelector.js.map +0 -1
- package/dist/src/ui/components/subagents/index.d.ts +0 -8
- package/dist/src/ui/components/subagents/index.js +0 -12
- package/dist/src/ui/components/subagents/index.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/ActionSelectionStep.d.ts +0 -13
- package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js +0 -45
- package/dist/src/ui/components/subagents/manage/ActionSelectionStep.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/AgentDeleteStep.d.ts +0 -13
- package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js +0 -32
- package/dist/src/ui/components/subagents/manage/AgentDeleteStep.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/AgentEditStep.d.ts +0 -15
- package/dist/src/ui/components/subagents/manage/AgentEditStep.js +0 -62
- package/dist/src/ui/components/subagents/manage/AgentEditStep.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/AgentSelectionStep.d.ts +0 -12
- package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js +0 -224
- package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/AgentViewerStep.d.ts +0 -11
- package/dist/src/ui/components/subagents/manage/AgentViewerStep.js +0 -18
- package/dist/src/ui/components/subagents/manage/AgentViewerStep.js.map +0 -1
- package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.d.ts +0 -15
- package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js +0 -220
- package/dist/src/ui/components/subagents/manage/AgentsManagerDialog.js.map +0 -1
- package/dist/src/ui/components/subagents/reducers.d.ts +0 -14
- package/dist/src/ui/components/subagents/reducers.js +0 -161
- package/dist/src/ui/components/subagents/reducers.js.map +0 -1
- package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.d.ts +0 -19
- package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.js +0 -184
- package/dist/src/ui/components/subagents/runtime/AgentExecutionDisplay.js.map +0 -1
- package/dist/src/ui/components/subagents/types.d.ts +0 -137
- package/dist/src/ui/components/subagents/types.js +0 -15
- package/dist/src/ui/components/subagents/types.js.map +0 -1
- package/dist/src/ui/components/subagents/utils.d.ts +0 -15
- package/dist/src/ui/components/subagents/utils.js +0 -79
- package/dist/src/ui/components/subagents/utils.js.map +0 -1
- package/dist/src/ui/contexts/KeypressContext.d.ts +0 -31
- package/dist/src/ui/contexts/KeypressContext.js +0 -388
- package/dist/src/ui/contexts/KeypressContext.js.map +0 -1
- package/dist/src/ui/contexts/KeypressContext.test.d.ts +0 -6
- package/dist/src/ui/contexts/KeypressContext.test.js +0 -754
- package/dist/src/ui/contexts/KeypressContext.test.js.map +0 -1
- package/dist/src/ui/contexts/SettingsContext.d.ts +0 -9
- package/dist/src/ui/contexts/SettingsContext.js +0 -15
- package/dist/src/ui/contexts/SettingsContext.js.map +0 -1
- package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +0 -6
- package/dist/src/ui/hooks/atCommandProcessor.test.js +0 -824
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +0 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +0 -6
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +0 -328
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +0 -1
- package/dist/src/ui/hooks/useAgentsManagerDialog.d.ts +0 -11
- package/dist/src/ui/hooks/useAgentsManagerDialog.js +0 -21
- package/dist/src/ui/hooks/useAgentsManagerDialog.js.map +0 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +0 -6
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +0 -191
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +0 -1
- package/dist/src/ui/hooks/useDialogClose.d.ts +0 -34
- package/dist/src/ui/hooks/useDialogClose.js +0 -62
- package/dist/src/ui/hooks/useDialogClose.js.map +0 -1
- package/dist/src/ui/hooks/useEditorSettings.test.d.ts +0 -6
- package/dist/src/ui/hooks/useEditorSettings.test.js +0 -164
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +0 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +0 -12
- package/dist/src/ui/hooks/useFolderTrust.js +0 -55
- package/dist/src/ui/hooks/useFolderTrust.js.map +0 -1
- package/dist/src/ui/hooks/useGitBranchName.test.d.ts +0 -6
- package/dist/src/ui/hooks/useGitBranchName.test.js +0 -239
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +0 -1
- package/dist/src/ui/hooks/useHistoryManager.test.d.ts +0 -6
- package/dist/src/ui/hooks/useHistoryManager.test.js +0 -171
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +0 -1
- package/dist/src/ui/hooks/useInputHistory.test.d.ts +0 -6
- package/dist/src/ui/hooks/useInputHistory.test.js +0 -207
- package/dist/src/ui/hooks/useInputHistory.test.js.map +0 -1
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +0 -15
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +0 -20
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +0 -1
- package/dist/src/ui/hooks/useLaunchEditor.d.ts +0 -10
- package/dist/src/ui/hooks/useLaunchEditor.js +0 -70
- package/dist/src/ui/hooks/useLaunchEditor.js.map +0 -1
- package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +0 -6
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +0 -91
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +0 -1
- package/dist/src/ui/hooks/useMessageQueue.d.ts +0 -22
- package/dist/src/ui/hooks/useMessageQueue.js +0 -49
- package/dist/src/ui/hooks/useMessageQueue.js.map +0 -1
- package/dist/src/ui/hooks/useMessageQueue.test.d.ts +0 -6
- package/dist/src/ui/hooks/useMessageQueue.test.js +0 -158
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +0 -1
- package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +0 -6
- package/dist/src/ui/hooks/usePrivacySettings.test.js +0 -154
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +0 -1
- package/dist/src/ui/hooks/useQuitConfirmation.d.ts +0 -14
- package/dist/src/ui/hooks/useQuitConfirmation.js +0 -36
- package/dist/src/ui/hooks/useQuitConfirmation.js.map +0 -1
- package/dist/src/ui/hooks/useQwenAuth.test.d.ts +0 -6
- package/dist/src/ui/hooks/useQwenAuth.test.js +0 -288
- package/dist/src/ui/hooks/useQwenAuth.test.js.map +0 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +0 -6
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +0 -163
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +0 -1
- package/dist/src/ui/hooks/useSettingsCommand.d.ts +0 -10
- package/dist/src/ui/hooks/useSettingsCommand.js +0 -21
- package/dist/src/ui/hooks/useSettingsCommand.js.map +0 -1
- package/dist/src/ui/hooks/useShellHistory.test.d.ts +0 -6
- package/dist/src/ui/hooks/useShellHistory.test.js +0 -162
- package/dist/src/ui/hooks/useShellHistory.test.js.map +0 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +0 -6
- package/dist/src/ui/hooks/useSlashCompletion.test.js +0 -272
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +0 -1
- package/dist/src/ui/hooks/useSubagentCreateDialog.d.ts +0 -10
- package/dist/src/ui/hooks/useSubagentCreateDialog.js +0 -21
- package/dist/src/ui/hooks/useSubagentCreateDialog.js.map +0 -1
- package/dist/src/ui/hooks/useTimer.test.d.ts +0 -6
- package/dist/src/ui/hooks/useTimer.test.js +0 -90
- package/dist/src/ui/hooks/useTimer.test.js.map +0 -1
- package/dist/src/ui/hooks/useToolScheduler.test.d.ts +0 -6
- package/dist/src/ui/hooks/useToolScheduler.test.js +0 -846
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +0 -1
- package/dist/src/ui/hooks/useWelcomeBack.d.ts +0 -23
- package/dist/src/ui/hooks/useWelcomeBack.js +0 -78
- package/dist/src/ui/hooks/useWelcomeBack.js.map +0 -1
- package/dist/src/ui/keyMatchers.d.ts +0 -26
- package/dist/src/ui/keyMatchers.js +0 -68
- package/dist/src/ui/keyMatchers.js.map +0 -1
- package/dist/src/ui/keyMatchers.test.d.ts +0 -6
- package/dist/src/ui/keyMatchers.test.js +0 -276
- package/dist/src/ui/keyMatchers.test.js.map +0 -1
- package/dist/src/ui/semantic-colors.d.ts +0 -7
- package/dist/src/ui/semantic-colors.js +0 -24
- package/dist/src/ui/semantic-colors.js.map +0 -1
- package/dist/src/ui/themes/color-utils.test.d.ts +0 -6
- package/dist/src/ui/themes/color-utils.test.js +0 -197
- package/dist/src/ui/themes/color-utils.test.js.map +0 -1
- package/dist/src/ui/themes/semantic-tokens.d.ts +0 -37
- package/dist/src/ui/themes/semantic-tokens.js +0 -94
- package/dist/src/ui/themes/semantic-tokens.js.map +0 -1
- package/dist/src/ui/themes/theme-manager.test.d.ts +0 -6
- package/dist/src/ui/themes/theme-manager.test.js +0 -83
- package/dist/src/ui/themes/theme-manager.test.js.map +0 -1
- package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +0 -6
- package/dist/src/ui/utils/MarkdownDisplay.test.js +0 -151
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +0 -1
- package/dist/src/ui/utils/clipboardUtils.test.d.ts +0 -6
- package/dist/src/ui/utils/clipboardUtils.test.js +0 -65
- package/dist/src/ui/utils/clipboardUtils.test.js.map +0 -1
- package/dist/src/ui/utils/commandUtils.test.d.ts +0 -6
- package/dist/src/ui/utils/commandUtils.test.js +0 -294
- package/dist/src/ui/utils/commandUtils.test.js.map +0 -1
- package/dist/src/ui/utils/displayUtils.test.d.ts +0 -6
- package/dist/src/ui/utils/displayUtils.test.js +0 -42
- package/dist/src/ui/utils/displayUtils.test.js.map +0 -1
- package/dist/src/ui/utils/formatters.test.d.ts +0 -6
- package/dist/src/ui/utils/formatters.test.js +0 -56
- package/dist/src/ui/utils/formatters.test.js.map +0 -1
- package/dist/src/ui/utils/isNarrowWidth.d.ts +0 -6
- package/dist/src/ui/utils/isNarrowWidth.js +0 -9
- package/dist/src/ui/utils/isNarrowWidth.js.map +0 -1
- package/dist/src/ui/utils/kittyProtocolDetector.d.ts +0 -13
- package/dist/src/ui/utils/kittyProtocolDetector.js +0 -88
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +0 -1
- package/dist/src/ui/utils/markdownUtilities.test.d.ts +0 -6
- package/dist/src/ui/utils/markdownUtilities.test.js +0 -42
- package/dist/src/ui/utils/markdownUtilities.test.js.map +0 -1
- package/dist/src/ui/utils/platformConstants.d.ts +0 -45
- package/dist/src/ui/utils/platformConstants.js +0 -46
- package/dist/src/ui/utils/platformConstants.js.map +0 -1
- package/dist/src/ui/utils/terminalSetup.d.ts +0 -30
- package/dist/src/ui/utils/terminalSetup.js +0 -281
- package/dist/src/ui/utils/terminalSetup.js.map +0 -1
- package/dist/src/ui/utils/updateCheck.test.d.ts +0 -6
- package/dist/src/ui/utils/updateCheck.test.js +0 -145
- package/dist/src/ui/utils/updateCheck.test.js.map +0 -1
- package/dist/src/utils/checks.d.ts +0 -19
- package/dist/src/utils/checks.js +0 -24
- package/dist/src/utils/checks.js.map +0 -1
- package/dist/src/utils/dialogScopeUtils.d.ts +0 -31
- package/dist/src/utils/dialogScopeUtils.js +0 -48
- package/dist/src/utils/dialogScopeUtils.js.map +0 -1
- package/dist/src/utils/gitUtils.test.d.ts +0 -6
- package/dist/src/utils/gitUtils.test.js +0 -113
- package/dist/src/utils/gitUtils.test.js.map +0 -1
- package/dist/src/utils/installationInfo.test.d.ts +0 -6
- package/dist/src/utils/installationInfo.test.js +0 -242
- package/dist/src/utils/installationInfo.test.js.map +0 -1
- package/dist/src/utils/settingsUtils.d.ts +0 -134
- package/dist/src/utils/settingsUtils.js +0 -336
- package/dist/src/utils/settingsUtils.js.map +0 -1
- package/dist/src/utils/settingsUtils.test.d.ts +0 -6
- package/dist/src/utils/settingsUtils.test.js +0 -514
- package/dist/src/utils/settingsUtils.test.js.map +0 -1
- package/dist/src/utils/userStartupWarnings.test.d.ts +0 -6
- package/dist/src/utils/userStartupWarnings.test.js +0 -67
- package/dist/src/utils/userStartupWarnings.test.js.map +0 -1
- package/dist/src/zed-integration/acp.d.ts +0 -63
- package/dist/src/zed-integration/acp.js.map +0 -1
- package/dist/src/zed-integration/fileSystemService.d.ts +0 -19
- package/dist/src/zed-integration/fileSystemService.js +0 -43
- package/dist/src/zed-integration/fileSystemService.js.map +0 -1
- package/dist/src/zed-integration/schema.d.ts +0 -11782
- package/dist/src/zed-integration/schema.js +0 -311
- package/dist/src/zed-integration/schema.js.map +0 -1
- package/dist/src/zed-integration/zedIntegration.d.ts +0 -10
- package/dist/src/zed-integration/zedIntegration.js +0 -765
- package/dist/src/zed-integration/zedIntegration.js.map +0 -1
|
@@ -11,7 +11,6 @@ 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';
|
|
15
14
|
const execAsync = promisify(exec);
|
|
16
15
|
function getContainerPath(hostPath) {
|
|
17
16
|
if (os.platform() !== 'win32') {
|
|
@@ -54,7 +53,7 @@ const BUILTIN_SEATBELT_PROFILES = [
|
|
|
54
53
|
* @returns {Promise<boolean>} A promise that resolves to true if the current user's UID/GID should be used, false otherwise.
|
|
55
54
|
*/
|
|
56
55
|
async function shouldUseCurrentUserInSandbox() {
|
|
57
|
-
const envVar = process.env
|
|
56
|
+
const envVar = process.env.SANDBOX_SET_UID_GID?.toLowerCase().trim();
|
|
58
57
|
if (envVar === '1' || envVar === 'true') {
|
|
59
58
|
return true;
|
|
60
59
|
}
|
|
@@ -91,7 +90,7 @@ function parseImageName(image) {
|
|
|
91
90
|
return tag ? `${name}-${tag}` : name;
|
|
92
91
|
}
|
|
93
92
|
function ports() {
|
|
94
|
-
return (process.env
|
|
93
|
+
return (process.env.SANDBOX_PORTS ?? '')
|
|
95
94
|
.split(',')
|
|
96
95
|
.filter((p) => p.trim())
|
|
97
96
|
.map((p) => p.trim());
|
|
@@ -102,8 +101,8 @@ function entrypoint(workdir) {
|
|
|
102
101
|
const shellCmds = [];
|
|
103
102
|
const pathSeparator = isWindows ? ';' : ':';
|
|
104
103
|
let pathSuffix = '';
|
|
105
|
-
if (process.env
|
|
106
|
-
const paths = process.env
|
|
104
|
+
if (process.env.PATH) {
|
|
105
|
+
const paths = process.env.PATH.split(pathSeparator);
|
|
107
106
|
for (const p of paths) {
|
|
108
107
|
const containerPath = getContainerPath(p);
|
|
109
108
|
if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
|
|
@@ -115,8 +114,8 @@ function entrypoint(workdir) {
|
|
|
115
114
|
shellCmds.push(`export PATH="$PATH${pathSuffix}";`);
|
|
116
115
|
}
|
|
117
116
|
let pythonPathSuffix = '';
|
|
118
|
-
if (process.env
|
|
119
|
-
const paths = process.env
|
|
117
|
+
if (process.env.PYTHONPATH) {
|
|
118
|
+
const paths = process.env.PYTHONPATH.split(pathSeparator);
|
|
120
119
|
for (const p of paths) {
|
|
121
120
|
const containerPath = getContainerPath(p);
|
|
122
121
|
if (containerPath.toLowerCase().startsWith(containerWorkdir.toLowerCase())) {
|
|
@@ -133,465 +132,110 @@ function entrypoint(workdir) {
|
|
|
133
132
|
}
|
|
134
133
|
ports().forEach((p) => shellCmds.push(`socat TCP4-LISTEN:${p},bind=$(hostname -i),fork,reuseaddr TCP4:127.0.0.1:${p} 2> /dev/null &`));
|
|
135
134
|
const cliArgs = process.argv.slice(2).map((arg) => quote([arg]));
|
|
136
|
-
const cliCmd = process.env
|
|
137
|
-
? process.env
|
|
135
|
+
const cliCmd = process.env.NODE_ENV === 'development'
|
|
136
|
+
? process.env.DEBUG
|
|
138
137
|
? 'npm run debug --'
|
|
139
138
|
: 'npm rebuild && npm run start --'
|
|
140
|
-
: process.env
|
|
141
|
-
? `node --inspect-brk=0.0.0.0:${process.env
|
|
139
|
+
: process.env.DEBUG
|
|
140
|
+
? `node --inspect-brk=0.0.0.0:${process.env.DEBUG_PORT || '9229'} $(which qwen)`
|
|
142
141
|
: 'qwen';
|
|
143
142
|
const args = [...shellCmds, cliCmd, ...cliArgs];
|
|
144
143
|
return ['bash', '-c', args.join(' ')];
|
|
145
144
|
}
|
|
146
145
|
export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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;
|
|
273
|
-
}
|
|
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
|
-
}
|
|
309
|
-
}
|
|
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}`);
|
|
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');
|
|
316
150
|
process.exit(1);
|
|
317
151
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
if (
|
|
323
|
-
|
|
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`);
|
|
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`);
|
|
349
158
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
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}`);
|
|
159
|
+
if (!fs.existsSync(profileFile)) {
|
|
160
|
+
console.error(`ERROR: missing macos seatbelt profile file '${profileFile}'`);
|
|
161
|
+
process.exit(1);
|
|
388
162
|
}
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
//
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
execSync(`${config.command} network inspect ${SANDBOX_PROXY_NAME} || ${config.command} network create ${SANDBOX_PROXY_NAME}`);
|
|
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
|
+
];
|
|
180
|
+
// Add included directories from the workspace context
|
|
181
|
+
// Always add 5 INCLUDE_DIR parameters to ensure .sb files can reference them
|
|
182
|
+
const MAX_INCLUDE_DIRS = 5;
|
|
183
|
+
const targetDir = fs.realpathSync(cliConfig?.getTargetDir() || '');
|
|
184
|
+
const includedDirs = [];
|
|
185
|
+
if (cliConfig) {
|
|
186
|
+
const workspaceContext = cliConfig.getWorkspaceContext();
|
|
187
|
+
const directories = workspaceContext.getDirectories();
|
|
188
|
+
// Filter out TARGET_DIR
|
|
189
|
+
for (const dir of directories) {
|
|
190
|
+
const realDir = fs.realpathSync(dir);
|
|
191
|
+
if (realDir !== targetDir) {
|
|
192
|
+
includedDirs.push(realDir);
|
|
420
193
|
}
|
|
421
194
|
}
|
|
422
195
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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 OPENAI_API_KEY and related env vars for Qwen
|
|
442
|
-
if (process.env['OPENAI_API_KEY']) {
|
|
443
|
-
args.push('--env', `OPENAI_API_KEY=${process.env['OPENAI_API_KEY']}`);
|
|
444
|
-
}
|
|
445
|
-
// copy TAVILY_API_KEY for web search tool
|
|
446
|
-
if (process.env['TAVILY_API_KEY']) {
|
|
447
|
-
args.push('--env', `TAVILY_API_KEY=${process.env['TAVILY_API_KEY']}`);
|
|
448
|
-
}
|
|
449
|
-
if (process.env['OPENAI_BASE_URL']) {
|
|
450
|
-
args.push('--env', `OPENAI_BASE_URL=${process.env['OPENAI_BASE_URL']}`);
|
|
451
|
-
}
|
|
452
|
-
if (process.env['OPENAI_MODEL']) {
|
|
453
|
-
args.push('--env', `OPENAI_MODEL=${process.env['OPENAI_MODEL']}`);
|
|
454
|
-
}
|
|
455
|
-
// copy GOOGLE_GENAI_USE_VERTEXAI
|
|
456
|
-
if (process.env['GOOGLE_GENAI_USE_VERTEXAI']) {
|
|
457
|
-
args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env['GOOGLE_GENAI_USE_VERTEXAI']}`);
|
|
458
|
-
}
|
|
459
|
-
// copy GOOGLE_GENAI_USE_GCA
|
|
460
|
-
if (process.env['GOOGLE_GENAI_USE_GCA']) {
|
|
461
|
-
args.push('--env', `GOOGLE_GENAI_USE_GCA=${process.env['GOOGLE_GENAI_USE_GCA']}`);
|
|
462
|
-
}
|
|
463
|
-
// copy GOOGLE_CLOUD_PROJECT
|
|
464
|
-
if (process.env['GOOGLE_CLOUD_PROJECT']) {
|
|
465
|
-
args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env['GOOGLE_CLOUD_PROJECT']}`);
|
|
466
|
-
}
|
|
467
|
-
// copy GOOGLE_CLOUD_LOCATION
|
|
468
|
-
if (process.env['GOOGLE_CLOUD_LOCATION']) {
|
|
469
|
-
args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env['GOOGLE_CLOUD_LOCATION']}`);
|
|
470
|
-
}
|
|
471
|
-
// copy GEMINI_MODEL
|
|
472
|
-
if (process.env['GEMINI_MODEL']) {
|
|
473
|
-
args.push('--env', `GEMINI_MODEL=${process.env['GEMINI_MODEL']}`);
|
|
474
|
-
}
|
|
475
|
-
// copy TERM and COLORTERM to try to maintain terminal setup
|
|
476
|
-
if (process.env['TERM']) {
|
|
477
|
-
args.push('--env', `TERM=${process.env['TERM']}`);
|
|
478
|
-
}
|
|
479
|
-
if (process.env['COLORTERM']) {
|
|
480
|
-
args.push('--env', `COLORTERM=${process.env['COLORTERM']}`);
|
|
481
|
-
}
|
|
482
|
-
// Pass through IDE mode environment variables
|
|
483
|
-
for (const envVar of [
|
|
484
|
-
'QWEN_CODE_IDE_SERVER_PORT',
|
|
485
|
-
'QWEN_CODE_IDE_WORKSPACE_PATH',
|
|
486
|
-
'TERM_PROGRAM',
|
|
487
|
-
]) {
|
|
488
|
-
if (process.env[envVar]) {
|
|
489
|
-
args.push('--env', `${envVar}=${process.env[envVar]}`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
// copy VIRTUAL_ENV if under working directory
|
|
493
|
-
// also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
|
|
494
|
-
// sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
|
|
495
|
-
// directory will be empty if not set up, which is still preferable to having host binaries
|
|
496
|
-
if (process.env['VIRTUAL_ENV']
|
|
497
|
-
?.toLowerCase()
|
|
498
|
-
.startsWith(workdir.toLowerCase())) {
|
|
499
|
-
const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
|
|
500
|
-
if (!fs.existsSync(sandboxVenvPath)) {
|
|
501
|
-
fs.mkdirSync(sandboxVenvPath, { recursive: true });
|
|
196
|
+
for (let i = 0; i < MAX_INCLUDE_DIRS; i++) {
|
|
197
|
+
let dirPath = '/dev/null'; // Default to a safe path that won't cause issues
|
|
198
|
+
if (i < includedDirs.length) {
|
|
199
|
+
dirPath = includedDirs[i];
|
|
502
200
|
}
|
|
503
|
-
args.push('
|
|
504
|
-
args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env['VIRTUAL_ENV'])}`);
|
|
201
|
+
args.push('-D', `INCLUDE_DIR_${i}=${dirPath}`);
|
|
505
202
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
console.error(`SANDBOX_ENV: ${env}`);
|
|
512
|
-
args.push('--env', env);
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
console.error('ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs');
|
|
516
|
-
process.exit(1);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
// copy NODE_OPTIONS
|
|
522
|
-
const existingNodeOptions = process.env['NODE_OPTIONS'] || '';
|
|
523
|
-
const allNodeOptions = [
|
|
524
|
-
...(existingNodeOptions ? [existingNodeOptions] : []),
|
|
525
|
-
...nodeArgs,
|
|
526
|
-
].join(' ');
|
|
527
|
-
if (allNodeOptions.length > 0) {
|
|
528
|
-
args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
|
|
529
|
-
}
|
|
530
|
-
// set SANDBOX as container name
|
|
531
|
-
args.push('--env', `SANDBOX=${containerName}`);
|
|
532
|
-
// for podman only, use empty --authfile to skip unnecessary auth refresh overhead
|
|
533
|
-
if (config.command === 'podman') {
|
|
534
|
-
const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
|
|
535
|
-
fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
|
|
536
|
-
args.push('--authfile', emptyAuthFilePath);
|
|
537
|
-
}
|
|
538
|
-
// Determine if the current user's UID/GID should be passed to the sandbox.
|
|
539
|
-
// See shouldUseCurrentUserInSandbox for more details.
|
|
540
|
-
let userFlag = '';
|
|
541
|
-
const finalEntrypoint = entrypoint(workdir);
|
|
542
|
-
if (process.env['GEMINI_CLI_INTEGRATION_TEST'] === 'true') {
|
|
543
|
-
args.push('--user', 'root');
|
|
544
|
-
userFlag = '--user root';
|
|
545
|
-
}
|
|
546
|
-
else if (await shouldUseCurrentUserInSandbox()) {
|
|
547
|
-
// For the user-creation logic to work, the container must start as root.
|
|
548
|
-
// The entrypoint script then handles dropping privileges to the correct user.
|
|
549
|
-
args.push('--user', 'root');
|
|
550
|
-
const uid = execSync('id -u').toString().trim();
|
|
551
|
-
const gid = execSync('id -g').toString().trim();
|
|
552
|
-
// Instead of passing --user to the main sandbox container, we let it
|
|
553
|
-
// start as root, then create a user with the host's UID/GID, and
|
|
554
|
-
// finally switch to that user to run the gemini process. This is
|
|
555
|
-
// necessary on Linux to ensure the user exists within the
|
|
556
|
-
// container's /etc/passwd file, which is required by os.userInfo().
|
|
557
|
-
const username = 'gemini';
|
|
558
|
-
const homeDir = getContainerPath(os.homedir());
|
|
559
|
-
const setupUserCommands = [
|
|
560
|
-
// Use -f with groupadd to avoid errors if the group already exists.
|
|
561
|
-
`groupadd -f -g ${gid} ${username}`,
|
|
562
|
-
// Create user only if it doesn't exist. Use -o for non-unique UID.
|
|
563
|
-
`id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
|
|
564
|
-
].join(' && ');
|
|
565
|
-
const originalCommand = finalEntrypoint[2];
|
|
566
|
-
const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
|
|
567
|
-
// Use `su -p` to preserve the environment.
|
|
568
|
-
const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
|
|
569
|
-
// The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
|
|
570
|
-
finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
|
|
571
|
-
// We still need userFlag for the simpler proxy container, which does not have this issue.
|
|
572
|
-
userFlag = `--user ${uid}:${gid}`;
|
|
573
|
-
// When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
|
|
574
|
-
args.push('--env', `HOME=${os.homedir()}`);
|
|
575
|
-
}
|
|
576
|
-
// push container image name
|
|
577
|
-
args.push(image);
|
|
578
|
-
// push container entrypoint (including args)
|
|
579
|
-
args.push(...finalEntrypoint);
|
|
203
|
+
args.push('-f', profileFile, 'sh', '-c', [
|
|
204
|
+
`SANDBOX=sandbox-exec`,
|
|
205
|
+
`NODE_OPTIONS="${nodeOptions}"`,
|
|
206
|
+
...process.argv.map((arg) => quote([arg])),
|
|
207
|
+
].join(' '));
|
|
580
208
|
// start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
|
|
209
|
+
const proxyCommand = process.env.GEMINI_SANDBOX_PROXY_COMMAND;
|
|
581
210
|
let proxyProcess = undefined;
|
|
582
211
|
let sandboxProcess = undefined;
|
|
212
|
+
const sandboxEnv = { ...process.env };
|
|
583
213
|
if (proxyCommand) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
214
|
+
const proxy = process.env.HTTPS_PROXY ||
|
|
215
|
+
process.env.https_proxy ||
|
|
216
|
+
process.env.HTTP_PROXY ||
|
|
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, {
|
|
587
229
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
588
230
|
shell: true,
|
|
589
231
|
detached: true,
|
|
590
232
|
});
|
|
591
233
|
// install handlers to stop proxy on exit/signal
|
|
592
234
|
const stopProxy = () => {
|
|
593
|
-
console.log('stopping proxy
|
|
594
|
-
|
|
235
|
+
console.log('stopping proxy ...');
|
|
236
|
+
if (proxyProcess?.pid) {
|
|
237
|
+
process.kill(-proxyProcess.pid, 'SIGTERM');
|
|
238
|
+
}
|
|
595
239
|
};
|
|
596
240
|
process.on('exit', stopProxy);
|
|
597
241
|
process.on('SIGINT', stopProxy);
|
|
@@ -601,10 +245,10 @@ export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
|
601
245
|
// console.info(data.toString());
|
|
602
246
|
// });
|
|
603
247
|
proxyProcess.stderr?.on('data', (data) => {
|
|
604
|
-
console.error(data.toString()
|
|
248
|
+
console.error(data.toString());
|
|
605
249
|
});
|
|
606
250
|
proxyProcess.on('close', (code, signal) => {
|
|
607
|
-
console.error(`ERROR: proxy
|
|
251
|
+
console.error(`ERROR: proxy command '${proxyCommand}' exited with code ${code}, signal ${signal}`);
|
|
608
252
|
if (sandboxProcess?.pid) {
|
|
609
253
|
process.kill(-sandboxProcess.pid, 'SIGTERM');
|
|
610
254
|
}
|
|
@@ -612,29 +256,362 @@ export async function start_sandbox(config, nodeArgs = [], cliConfig) {
|
|
|
612
256
|
});
|
|
613
257
|
console.log('waiting for proxy to start ...');
|
|
614
258
|
await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
|
|
615
|
-
// connect proxy container to sandbox network
|
|
616
|
-
// (workaround for older versions of docker that don't support multiple --network args)
|
|
617
|
-
await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
|
|
618
259
|
}
|
|
619
260
|
// spawn child and let it inherit stdio
|
|
620
261
|
sandboxProcess = spawn(config.command, args, {
|
|
621
262
|
stdio: 'inherit',
|
|
622
263
|
});
|
|
623
|
-
sandboxProcess
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
264
|
+
await new Promise((resolve) => sandboxProcess?.on('close', resolve));
|
|
265
|
+
return;
|
|
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
|
+
},
|
|
632
300
|
});
|
|
633
|
-
}
|
|
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}`);
|
|
634
433
|
}
|
|
635
|
-
|
|
636
|
-
|
|
434
|
+
// copy OPENAI_API_KEY and related env vars for Qwen
|
|
435
|
+
if (process.env.OPENAI_API_KEY) {
|
|
436
|
+
args.push('--env', `OPENAI_API_KEY=${process.env.OPENAI_API_KEY}`);
|
|
637
437
|
}
|
|
438
|
+
// copy TAVILY_API_KEY for web search tool
|
|
439
|
+
if (process.env.TAVILY_API_KEY) {
|
|
440
|
+
args.push('--env', `TAVILY_API_KEY=${process.env.TAVILY_API_KEY}`);
|
|
441
|
+
}
|
|
442
|
+
if (process.env.OPENAI_BASE_URL) {
|
|
443
|
+
args.push('--env', `OPENAI_BASE_URL=${process.env.OPENAI_BASE_URL}`);
|
|
444
|
+
}
|
|
445
|
+
if (process.env.OPENAI_MODEL) {
|
|
446
|
+
args.push('--env', `OPENAI_MODEL=${process.env.OPENAI_MODEL}`);
|
|
447
|
+
}
|
|
448
|
+
// copy GOOGLE_GENAI_USE_VERTEXAI
|
|
449
|
+
if (process.env.GOOGLE_GENAI_USE_VERTEXAI) {
|
|
450
|
+
args.push('--env', `GOOGLE_GENAI_USE_VERTEXAI=${process.env.GOOGLE_GENAI_USE_VERTEXAI}`);
|
|
451
|
+
}
|
|
452
|
+
// copy GOOGLE_GENAI_USE_GCA
|
|
453
|
+
if (process.env.GOOGLE_GENAI_USE_GCA) {
|
|
454
|
+
args.push('--env', `GOOGLE_GENAI_USE_GCA=${process.env.GOOGLE_GENAI_USE_GCA}`);
|
|
455
|
+
}
|
|
456
|
+
// copy GOOGLE_CLOUD_PROJECT
|
|
457
|
+
if (process.env.GOOGLE_CLOUD_PROJECT) {
|
|
458
|
+
args.push('--env', `GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT}`);
|
|
459
|
+
}
|
|
460
|
+
// copy GOOGLE_CLOUD_LOCATION
|
|
461
|
+
if (process.env.GOOGLE_CLOUD_LOCATION) {
|
|
462
|
+
args.push('--env', `GOOGLE_CLOUD_LOCATION=${process.env.GOOGLE_CLOUD_LOCATION}`);
|
|
463
|
+
}
|
|
464
|
+
// copy GEMINI_MODEL
|
|
465
|
+
if (process.env.GEMINI_MODEL) {
|
|
466
|
+
args.push('--env', `GEMINI_MODEL=${process.env.GEMINI_MODEL}`);
|
|
467
|
+
}
|
|
468
|
+
// copy TERM and COLORTERM to try to maintain terminal setup
|
|
469
|
+
if (process.env.TERM) {
|
|
470
|
+
args.push('--env', `TERM=${process.env.TERM}`);
|
|
471
|
+
}
|
|
472
|
+
if (process.env.COLORTERM) {
|
|
473
|
+
args.push('--env', `COLORTERM=${process.env.COLORTERM}`);
|
|
474
|
+
}
|
|
475
|
+
// copy VIRTUAL_ENV if under working directory
|
|
476
|
+
// also mount-replace VIRTUAL_ENV directory with <project_settings>/sandbox.venv
|
|
477
|
+
// sandbox can then set up this new VIRTUAL_ENV directory using sandbox.bashrc (see below)
|
|
478
|
+
// directory will be empty if not set up, which is still preferable to having host binaries
|
|
479
|
+
if (process.env.VIRTUAL_ENV?.toLowerCase().startsWith(workdir.toLowerCase())) {
|
|
480
|
+
const sandboxVenvPath = path.resolve(SETTINGS_DIRECTORY_NAME, 'sandbox.venv');
|
|
481
|
+
if (!fs.existsSync(sandboxVenvPath)) {
|
|
482
|
+
fs.mkdirSync(sandboxVenvPath, { recursive: true });
|
|
483
|
+
}
|
|
484
|
+
args.push('--volume', `${sandboxVenvPath}:${getContainerPath(process.env.VIRTUAL_ENV)}`);
|
|
485
|
+
args.push('--env', `VIRTUAL_ENV=${getContainerPath(process.env.VIRTUAL_ENV)}`);
|
|
486
|
+
}
|
|
487
|
+
// copy additional environment variables from SANDBOX_ENV
|
|
488
|
+
if (process.env.SANDBOX_ENV) {
|
|
489
|
+
for (let env of process.env.SANDBOX_ENV.split(',')) {
|
|
490
|
+
if ((env = env.trim())) {
|
|
491
|
+
if (env.includes('=')) {
|
|
492
|
+
console.error(`SANDBOX_ENV: ${env}`);
|
|
493
|
+
args.push('--env', env);
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
console.error('ERROR: SANDBOX_ENV must be a comma-separated list of key=value pairs');
|
|
497
|
+
process.exit(1);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
// copy NODE_OPTIONS
|
|
503
|
+
const existingNodeOptions = process.env.NODE_OPTIONS || '';
|
|
504
|
+
const allNodeOptions = [
|
|
505
|
+
...(existingNodeOptions ? [existingNodeOptions] : []),
|
|
506
|
+
...nodeArgs,
|
|
507
|
+
].join(' ');
|
|
508
|
+
if (allNodeOptions.length > 0) {
|
|
509
|
+
args.push('--env', `NODE_OPTIONS="${allNodeOptions}"`);
|
|
510
|
+
}
|
|
511
|
+
// set SANDBOX as container name
|
|
512
|
+
args.push('--env', `SANDBOX=${containerName}`);
|
|
513
|
+
// for podman only, use empty --authfile to skip unnecessary auth refresh overhead
|
|
514
|
+
if (config.command === 'podman') {
|
|
515
|
+
const emptyAuthFilePath = path.join(os.tmpdir(), 'empty_auth.json');
|
|
516
|
+
fs.writeFileSync(emptyAuthFilePath, '{}', 'utf-8');
|
|
517
|
+
args.push('--authfile', emptyAuthFilePath);
|
|
518
|
+
}
|
|
519
|
+
// Determine if the current user's UID/GID should be passed to the sandbox.
|
|
520
|
+
// See shouldUseCurrentUserInSandbox for more details.
|
|
521
|
+
let userFlag = '';
|
|
522
|
+
const finalEntrypoint = entrypoint(workdir);
|
|
523
|
+
if (process.env.GEMINI_CLI_INTEGRATION_TEST === 'true') {
|
|
524
|
+
args.push('--user', 'root');
|
|
525
|
+
userFlag = '--user root';
|
|
526
|
+
}
|
|
527
|
+
else if (await shouldUseCurrentUserInSandbox()) {
|
|
528
|
+
// For the user-creation logic to work, the container must start as root.
|
|
529
|
+
// The entrypoint script then handles dropping privileges to the correct user.
|
|
530
|
+
args.push('--user', 'root');
|
|
531
|
+
const uid = execSync('id -u').toString().trim();
|
|
532
|
+
const gid = execSync('id -g').toString().trim();
|
|
533
|
+
// Instead of passing --user to the main sandbox container, we let it
|
|
534
|
+
// start as root, then create a user with the host's UID/GID, and
|
|
535
|
+
// finally switch to that user to run the gemini process. This is
|
|
536
|
+
// necessary on Linux to ensure the user exists within the
|
|
537
|
+
// container's /etc/passwd file, which is required by os.userInfo().
|
|
538
|
+
const username = 'gemini';
|
|
539
|
+
const homeDir = getContainerPath(os.homedir());
|
|
540
|
+
const setupUserCommands = [
|
|
541
|
+
// Use -f with groupadd to avoid errors if the group already exists.
|
|
542
|
+
`groupadd -f -g ${gid} ${username}`,
|
|
543
|
+
// Create user only if it doesn't exist. Use -o for non-unique UID.
|
|
544
|
+
`id -u ${username} &>/dev/null || useradd -o -u ${uid} -g ${gid} -d ${homeDir} -s /bin/bash ${username}`,
|
|
545
|
+
].join(' && ');
|
|
546
|
+
const originalCommand = finalEntrypoint[2];
|
|
547
|
+
const escapedOriginalCommand = originalCommand.replace(/'/g, "'\\''");
|
|
548
|
+
// Use `su -p` to preserve the environment.
|
|
549
|
+
const suCommand = `su -p ${username} -c '${escapedOriginalCommand}'`;
|
|
550
|
+
// The entrypoint is always `['bash', '-c', '<command>']`, so we modify the command part.
|
|
551
|
+
finalEntrypoint[2] = `${setupUserCommands} && ${suCommand}`;
|
|
552
|
+
// We still need userFlag for the simpler proxy container, which does not have this issue.
|
|
553
|
+
userFlag = `--user ${uid}:${gid}`;
|
|
554
|
+
// When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
|
|
555
|
+
args.push('--env', `HOME=${os.homedir()}`);
|
|
556
|
+
}
|
|
557
|
+
// push container image name
|
|
558
|
+
args.push(image);
|
|
559
|
+
// push container entrypoint (including args)
|
|
560
|
+
args.push(...finalEntrypoint);
|
|
561
|
+
// start and set up proxy if GEMINI_SANDBOX_PROXY_COMMAND is set
|
|
562
|
+
let proxyProcess = undefined;
|
|
563
|
+
let sandboxProcess = undefined;
|
|
564
|
+
if (proxyCommand) {
|
|
565
|
+
// run proxyCommand in its own container
|
|
566
|
+
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}`;
|
|
567
|
+
proxyProcess = spawn(proxyContainerCommand, {
|
|
568
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
569
|
+
shell: true,
|
|
570
|
+
detached: true,
|
|
571
|
+
});
|
|
572
|
+
// install handlers to stop proxy on exit/signal
|
|
573
|
+
const stopProxy = () => {
|
|
574
|
+
console.log('stopping proxy container ...');
|
|
575
|
+
execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
|
|
576
|
+
};
|
|
577
|
+
process.on('exit', stopProxy);
|
|
578
|
+
process.on('SIGINT', stopProxy);
|
|
579
|
+
process.on('SIGTERM', stopProxy);
|
|
580
|
+
// commented out as it disrupts ink rendering
|
|
581
|
+
// proxyProcess.stdout?.on('data', (data) => {
|
|
582
|
+
// console.info(data.toString());
|
|
583
|
+
// });
|
|
584
|
+
proxyProcess.stderr?.on('data', (data) => {
|
|
585
|
+
console.error(data.toString().trim());
|
|
586
|
+
});
|
|
587
|
+
proxyProcess.on('close', (code, signal) => {
|
|
588
|
+
console.error(`ERROR: proxy container command '${proxyContainerCommand}' exited with code ${code}, signal ${signal}`);
|
|
589
|
+
if (sandboxProcess?.pid) {
|
|
590
|
+
process.kill(-sandboxProcess.pid, 'SIGTERM');
|
|
591
|
+
}
|
|
592
|
+
process.exit(1);
|
|
593
|
+
});
|
|
594
|
+
console.log('waiting for proxy to start ...');
|
|
595
|
+
await execAsync(`until timeout 0.25 curl -s http://localhost:8877; do sleep 0.25; done`);
|
|
596
|
+
// connect proxy container to sandbox network
|
|
597
|
+
// (workaround for older versions of docker that don't support multiple --network args)
|
|
598
|
+
await execAsync(`${config.command} network connect ${SANDBOX_NETWORK_NAME} ${SANDBOX_PROXY_NAME}`);
|
|
599
|
+
}
|
|
600
|
+
// spawn child and let it inherit stdio
|
|
601
|
+
sandboxProcess = spawn(config.command, args, {
|
|
602
|
+
stdio: 'inherit',
|
|
603
|
+
});
|
|
604
|
+
sandboxProcess.on('error', (err) => {
|
|
605
|
+
console.error('Sandbox process error:', err);
|
|
606
|
+
});
|
|
607
|
+
await new Promise((resolve) => {
|
|
608
|
+
sandboxProcess?.on('close', (code, signal) => {
|
|
609
|
+
if (code !== 0) {
|
|
610
|
+
console.log(`Sandbox process exited with code: ${code}, signal: ${signal}`);
|
|
611
|
+
}
|
|
612
|
+
resolve();
|
|
613
|
+
});
|
|
614
|
+
});
|
|
638
615
|
}
|
|
639
616
|
// Helper functions to ensure sandbox image is present
|
|
640
617
|
async function imageExists(sandbox, image) {
|