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