dexto 1.3.0 → 1.5.0
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/README.md +87 -22
- package/dist/agents/agent-registry.json +9 -0
- package/dist/agents/agent-template.yml +2 -2
- package/dist/agents/coding-agent/coding-agent.yml +27 -16
- package/dist/agents/database-agent/database-agent.yml +2 -2
- package/dist/agents/default-agent.yml +9 -7
- package/dist/agents/github-agent/github-agent.yml +2 -2
- package/dist/agents/product-name-researcher/product-name-researcher.yml +2 -2
- package/dist/agents/talk2pdf-agent/talk2pdf-agent.yml +2 -2
- package/dist/analytics/events.d.ts +13 -6
- package/dist/analytics/events.d.ts.map +1 -1
- package/dist/analytics/index.d.ts +1 -1
- package/dist/analytics/index.d.ts.map +1 -1
- package/dist/analytics/index.js +6 -2
- package/dist/api/server-hono.d.ts.map +1 -1
- package/dist/api/server-hono.js +65 -9
- package/dist/cli/cli-subscriber.d.ts +4 -0
- package/dist/cli/cli-subscriber.d.ts.map +1 -1
- package/dist/cli/cli-subscriber.js +47 -3
- package/dist/cli/commands/create-app.d.ts +16 -14
- package/dist/cli/commands/create-app.d.ts.map +1 -1
- package/dist/cli/commands/create-app.js +626 -102
- package/dist/cli/commands/create-image.d.ts +7 -0
- package/dist/cli/commands/create-image.d.ts.map +1 -0
- package/dist/cli/commands/create-image.js +201 -0
- package/dist/cli/commands/helpers/formatters.d.ts.map +1 -1
- package/dist/cli/commands/helpers/formatters.js +9 -8
- package/dist/cli/commands/index.d.ts +2 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +2 -1
- package/dist/cli/commands/init-app.js +7 -7
- package/dist/cli/commands/install.d.ts +0 -3
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +19 -70
- package/dist/cli/commands/interactive-commands/command-parser.d.ts +17 -14
- package/dist/cli/commands/interactive-commands/command-parser.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/command-parser.js +7 -22
- package/dist/cli/commands/interactive-commands/commands.d.ts +4 -4
- package/dist/cli/commands/interactive-commands/commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/commands.js +34 -42
- package/dist/cli/commands/interactive-commands/documentation-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/documentation-commands.js +4 -7
- package/dist/cli/commands/interactive-commands/general-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/general-commands.js +159 -117
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts +9 -3
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/mcp/index.js +18 -3
- package/dist/cli/commands/interactive-commands/model/index.d.ts +8 -6
- package/dist/cli/commands/interactive-commands/model/index.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/model/index.js +18 -6
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts +3 -2
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.js +77 -60
- package/dist/cli/commands/interactive-commands/session/index.d.ts +7 -12
- package/dist/cli/commands/interactive-commands/session/index.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/session/index.js +7 -14
- package/dist/cli/commands/interactive-commands/session/session-commands.d.ts +10 -24
- package/dist/cli/commands/interactive-commands/session/session-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/session/session-commands.js +16 -371
- package/dist/cli/commands/interactive-commands/system/system-commands.d.ts +1 -0
- package/dist/cli/commands/interactive-commands/system/system-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/system/system-commands.js +106 -77
- package/dist/cli/commands/interactive-commands/tool-commands.d.ts +1 -1
- package/dist/cli/commands/interactive-commands/tool-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/tool-commands.js +5 -62
- package/dist/cli/commands/interactive-commands/utils/command-output.d.ts +13 -17
- package/dist/cli/commands/interactive-commands/utils/command-output.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/utils/command-output.js +18 -37
- package/dist/cli/commands/list-agents.d.ts +2 -2
- package/dist/cli/commands/list-agents.d.ts.map +1 -1
- package/dist/cli/commands/list-agents.js +38 -34
- package/dist/cli/commands/session-commands.js +16 -16
- package/dist/cli/commands/setup.d.ts +13 -5
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +860 -65
- package/dist/cli/commands/uninstall.d.ts.map +1 -1
- package/dist/cli/commands/uninstall.js +4 -6
- package/dist/cli/commands/which.d.ts.map +1 -1
- package/dist/cli/commands/which.js +18 -4
- package/dist/cli/ink-cli/InkCLIRefactored.d.ts +9 -22
- package/dist/cli/ink-cli/InkCLIRefactored.d.ts.map +1 -1
- package/dist/cli/ink-cli/InkCLIRefactored.js +50 -133
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts +26 -3
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/ApprovalPrompt.js +182 -45
- package/dist/cli/ink-cli/components/CustomInput.js +1 -1
- package/dist/cli/ink-cli/components/EditableMultiLineInput.js +4 -4
- package/dist/cli/ink-cli/components/ElicitationForm.d.ts +22 -0
- package/dist/cli/ink-cli/components/ElicitationForm.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/ElicitationForm.js +358 -0
- package/dist/cli/ink-cli/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/ErrorBoundary.js +1 -1
- package/dist/cli/ink-cli/components/Footer.d.ts +16 -0
- package/dist/cli/ink-cli/components/Footer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/Footer.js +27 -0
- package/dist/cli/ink-cli/components/HistorySearchBar.d.ts +17 -0
- package/dist/cli/ink-cli/components/HistorySearchBar.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/HistorySearchBar.js +8 -0
- package/dist/cli/ink-cli/components/MultiLineInput.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/MultiLineInput.js +3 -3
- package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts +15 -2
- package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/ResourceAutocomplete.js +126 -82
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts +15 -2
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.js +228 -122
- package/dist/cli/ink-cli/components/StatusBar.d.ts +15 -2
- package/dist/cli/ink-cli/components/StatusBar.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/StatusBar.js +50 -10
- package/dist/cli/ink-cli/components/TextBufferInput.d.ts +52 -0
- package/dist/cli/ink-cli/components/TextBufferInput.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/TextBufferInput.js +471 -0
- package/dist/cli/ink-cli/components/base/BaseAutocomplete.js +4 -4
- package/dist/cli/ink-cli/components/base/BaseSelector.d.ts +11 -1
- package/dist/cli/ink-cli/components/base/BaseSelector.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/base/BaseSelector.js +90 -49
- package/dist/cli/ink-cli/components/chat/Footer.js +1 -1
- package/dist/cli/ink-cli/components/chat/Header.d.ts +1 -0
- package/dist/cli/ink-cli/components/chat/Header.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/chat/Header.js +6 -3
- package/dist/cli/ink-cli/components/chat/MessageItem.d.ts +3 -0
- package/dist/cli/ink-cli/components/chat/MessageItem.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/chat/MessageItem.js +95 -9
- package/dist/cli/ink-cli/components/chat/MessageList.js +1 -1
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.d.ts +16 -0
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.js +27 -0
- package/dist/cli/ink-cli/components/chat/ToolIcon.d.ts +5 -3
- package/dist/cli/ink-cli/components/chat/ToolIcon.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/chat/ToolIcon.js +21 -7
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.js +6 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.js +15 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.js +9 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.js +37 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.js +9 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.js +6 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.js +29 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.d.ts +45 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.js +38 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.d.ts +10 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.js +6 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.d.ts +13 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.js +12 -0
- package/dist/cli/ink-cli/components/input/InputArea.d.ts +36 -8
- package/dist/cli/ink-cli/components/input/InputArea.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/input/InputArea.js +3 -3
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts +25 -0
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.js +166 -0
- package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts +27 -0
- package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/modes/StaticCLI.js +95 -0
- package/dist/cli/ink-cli/components/modes/index.d.ts +10 -0
- package/dist/cli/ink-cli/components/modes/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/modes/index.js +9 -0
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.d.ts +26 -0
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.js +92 -0
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts +29 -0
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.js +286 -0
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts +22 -0
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.js +59 -0
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.d.ts +22 -0
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.js +59 -0
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.d.ts +26 -0
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.js +73 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.d.ts +21 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.js +51 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.d.ts +29 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.js +215 -0
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts +22 -0
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.js +74 -0
- package/dist/cli/ink-cli/components/overlays/McpSelector.d.ts +21 -0
- package/dist/cli/ink-cli/components/overlays/McpSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpSelector.js +52 -0
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts +28 -0
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpServerActions.js +84 -0
- package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts +29 -0
- package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/McpServerList.js +109 -0
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts +15 -8
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.js +400 -23
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.d.ts +22 -0
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.js +52 -0
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.d.ts +29 -0
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.js +166 -0
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.d.ts +27 -0
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.js +119 -0
- package/dist/cli/ink-cli/components/overlays/PromptList.d.ts +33 -0
- package/dist/cli/ink-cli/components/overlays/PromptList.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PromptList.js +144 -0
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.d.ts +23 -0
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.js +189 -0
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.d.ts +7 -2
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.js +19 -5
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.d.ts +21 -0
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.js +42 -0
- package/dist/cli/ink-cli/components/overlays/StreamSelector.d.ts +20 -0
- package/dist/cli/ink-cli/components/overlays/StreamSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/StreamSelector.js +58 -0
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts +25 -0
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.js +400 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.d.ts +25 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.js +609 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.d.ts +15 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.js +14 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts +33 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.js +419 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts +25 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.js +29 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts +17 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.js +11 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts +20 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.js +10 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts +30 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.js +13 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.d.ts +8 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.js +7 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.d.ts +79 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.js +38 -0
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.d.ts +21 -0
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.js +65 -0
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts +28 -0
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.js +66 -0
- package/dist/cli/ink-cli/components/renderers/FileRenderer.d.ts +19 -0
- package/dist/cli/ink-cli/components/renderers/FileRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/FileRenderer.js +26 -0
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.d.ts +21 -0
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.js +26 -0
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.d.ts +20 -0
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.js +12 -0
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.d.ts +21 -0
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.js +25 -0
- package/dist/cli/ink-cli/components/renderers/diff-shared.d.ts +61 -0
- package/dist/cli/ink-cli/components/renderers/diff-shared.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/diff-shared.js +158 -0
- package/dist/cli/ink-cli/components/renderers/index.d.ts +28 -0
- package/dist/cli/ink-cli/components/renderers/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/renderers/index.js +36 -0
- package/dist/cli/ink-cli/components/shared/MarkdownText.d.ts +38 -0
- package/dist/cli/ink-cli/components/shared/MarkdownText.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/shared/MarkdownText.js +362 -0
- package/dist/cli/ink-cli/components/shared/VirtualizedList.d.ts +44 -0
- package/dist/cli/ink-cli/components/shared/VirtualizedList.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/shared/VirtualizedList.js +300 -0
- package/dist/cli/ink-cli/components/shared/text-buffer.d.ts +185 -0
- package/dist/cli/ink-cli/components/shared/text-buffer.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/shared/text-buffer.js +1338 -0
- package/dist/cli/ink-cli/constants/processingPhrases.d.ts +10 -0
- package/dist/cli/ink-cli/constants/processingPhrases.d.ts.map +1 -0
- package/dist/cli/ink-cli/constants/processingPhrases.js +64 -0
- package/dist/cli/ink-cli/constants/tips.d.ts +15 -0
- package/dist/cli/ink-cli/constants/tips.d.ts.map +1 -0
- package/dist/cli/ink-cli/constants/tips.js +53 -0
- package/dist/cli/ink-cli/containers/InputContainer.d.ts +42 -8
- package/dist/cli/ink-cli/containers/InputContainer.d.ts.map +1 -1
- package/dist/cli/ink-cli/containers/InputContainer.js +513 -85
- package/dist/cli/ink-cli/containers/OverlayContainer.d.ts +23 -5
- package/dist/cli/ink-cli/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/cli/ink-cli/containers/OverlayContainer.js +1214 -132
- package/dist/cli/ink-cli/containers/index.d.ts +1 -1
- package/dist/cli/ink-cli/containers/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/contexts/KeypressContext.d.ts +36 -0
- package/dist/cli/ink-cli/contexts/KeypressContext.d.ts.map +1 -0
- package/dist/cli/ink-cli/contexts/KeypressContext.js +461 -0
- package/dist/cli/ink-cli/contexts/MouseContext.d.ts +27 -0
- package/dist/cli/ink-cli/contexts/MouseContext.d.ts.map +1 -0
- package/dist/cli/ink-cli/contexts/MouseContext.js +102 -0
- package/dist/cli/ink-cli/contexts/ScrollProvider.d.ts +33 -0
- package/dist/cli/ink-cli/contexts/ScrollProvider.d.ts.map +1 -0
- package/dist/cli/ink-cli/contexts/ScrollProvider.js +170 -0
- package/dist/cli/ink-cli/contexts/index.d.ts +7 -0
- package/dist/cli/ink-cli/contexts/index.d.ts.map +1 -0
- package/dist/cli/ink-cli/contexts/index.js +6 -0
- package/dist/cli/ink-cli/hooks/index.d.ts +5 -0
- package/dist/cli/ink-cli/hooks/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/index.js +6 -1
- package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts +26 -9
- package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/useAgentEvents.js +90 -198
- package/dist/cli/ink-cli/hooks/useBatchedScroll.d.ts +14 -0
- package/dist/cli/ink-cli/hooks/useBatchedScroll.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useBatchedScroll.js +25 -0
- package/dist/cli/ink-cli/hooks/useCLIState.d.ts +50 -0
- package/dist/cli/ink-cli/hooks/useCLIState.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useCLIState.js +190 -0
- package/dist/cli/ink-cli/hooks/useElapsedTime.d.ts +24 -0
- package/dist/cli/ink-cli/hooks/useElapsedTime.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useElapsedTime.js +69 -0
- package/dist/cli/ink-cli/hooks/useHistorySearch.d.ts +61 -0
- package/dist/cli/ink-cli/hooks/useHistorySearch.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useHistorySearch.js +210 -0
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts +136 -0
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.js +663 -0
- package/dist/cli/ink-cli/hooks/useKeyboardShortcuts.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/useKeyboardShortcuts.js +7 -26
- package/dist/cli/ink-cli/hooks/useKeypress.d.ts +18 -0
- package/dist/cli/ink-cli/hooks/useKeypress.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useKeypress.js +26 -0
- package/dist/cli/ink-cli/hooks/usePhraseCycler.d.ts +30 -0
- package/dist/cli/ink-cli/hooks/usePhraseCycler.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/usePhraseCycler.js +68 -0
- package/dist/cli/ink-cli/hooks/useStreaming.d.ts +19 -0
- package/dist/cli/ink-cli/hooks/useStreaming.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useStreaming.js +26 -0
- package/dist/cli/ink-cli/hooks/useTerminalSize.d.ts +14 -0
- package/dist/cli/ink-cli/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useTerminalSize.js +31 -0
- package/dist/cli/ink-cli/hooks/useTokenCounter.d.ts +42 -0
- package/dist/cli/ink-cli/hooks/useTokenCounter.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useTokenCounter.js +96 -0
- package/dist/cli/ink-cli/services/CommandService.d.ts +32 -1
- package/dist/cli/ink-cli/services/CommandService.d.ts.map +1 -1
- package/dist/cli/ink-cli/services/CommandService.js +36 -5
- package/dist/cli/ink-cli/services/InputService.d.ts +1 -5
- package/dist/cli/ink-cli/services/InputService.d.ts.map +1 -1
- package/dist/cli/ink-cli/services/InputService.js +1 -8
- package/dist/cli/ink-cli/services/index.d.ts +2 -1
- package/dist/cli/ink-cli/services/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/services/index.js +2 -1
- package/dist/cli/ink-cli/services/processStream.d.ts +69 -0
- package/dist/cli/ink-cli/services/processStream.d.ts.map +1 -0
- package/dist/cli/ink-cli/services/processStream.js +742 -0
- package/dist/cli/ink-cli/state/actions.d.ts +30 -60
- package/dist/cli/ink-cli/state/actions.d.ts.map +1 -1
- package/dist/cli/ink-cli/state/actions.js +3 -0
- package/dist/cli/ink-cli/state/index.d.ts +5 -3
- package/dist/cli/ink-cli/state/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/state/index.js +4 -3
- package/dist/cli/ink-cli/state/initialState.d.ts +4 -3
- package/dist/cli/ink-cli/state/initialState.d.ts.map +1 -1
- package/dist/cli/ink-cli/state/initialState.js +20 -4
- package/dist/cli/ink-cli/state/reducer.d.ts +3 -0
- package/dist/cli/ink-cli/state/reducer.d.ts.map +1 -1
- package/dist/cli/ink-cli/state/reducer.js +62 -168
- package/dist/cli/ink-cli/state/streaming-state.d.ts +27 -0
- package/dist/cli/ink-cli/state/streaming-state.d.ts.map +1 -0
- package/dist/cli/ink-cli/state/streaming-state.js +39 -0
- package/dist/cli/ink-cli/state/types.d.ts +223 -6
- package/dist/cli/ink-cli/state/types.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/bracketedPaste.d.ts +22 -0
- package/dist/cli/ink-cli/utils/bracketedPaste.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/bracketedPaste.js +27 -0
- package/dist/cli/ink-cli/utils/clipboardUtils.d.ts +49 -0
- package/dist/cli/ink-cli/utils/clipboardUtils.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/clipboardUtils.js +356 -0
- package/dist/cli/ink-cli/utils/commandOverlays.d.ts +33 -0
- package/dist/cli/ink-cli/utils/commandOverlays.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/commandOverlays.js +78 -0
- package/dist/cli/ink-cli/utils/debugLog.d.ts +38 -0
- package/dist/cli/ink-cli/utils/debugLog.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/debugLog.js +66 -0
- package/dist/cli/ink-cli/utils/index.d.ts +2 -1
- package/dist/cli/ink-cli/utils/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/index.js +3 -1
- package/dist/cli/ink-cli/utils/input.d.ts +25 -0
- package/dist/cli/ink-cli/utils/input.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/input.js +56 -0
- package/dist/cli/ink-cli/utils/inputParsing.d.ts +0 -9
- package/dist/cli/ink-cli/utils/inputParsing.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/inputParsing.js +0 -27
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts +59 -3
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/messageFormatting.js +348 -20
- package/dist/cli/ink-cli/utils/mouse.d.ts +61 -0
- package/dist/cli/ink-cli/utils/mouse.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/mouse.js +209 -0
- package/dist/cli/ink-cli/utils/streamSplitter.d.ts +44 -0
- package/dist/cli/ink-cli/utils/streamSplitter.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/streamSplitter.js +154 -0
- package/dist/cli/ink-cli/utils/textUtils.d.ts +63 -0
- package/dist/cli/ink-cli/utils/textUtils.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/textUtils.js +248 -0
- package/dist/cli/ink-cli/utils/toolUtils.d.ts +9 -0
- package/dist/cli/ink-cli/utils/toolUtils.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/toolUtils.js +15 -0
- package/dist/cli/utils/api-key-setup.d.ts +54 -4
- package/dist/cli/utils/api-key-setup.d.ts.map +1 -1
- package/dist/cli/utils/api-key-setup.js +433 -107
- package/dist/cli/utils/api-key-verification.d.ts +17 -0
- package/dist/cli/utils/api-key-verification.d.ts.map +1 -0
- package/dist/cli/utils/api-key-verification.js +211 -0
- package/dist/cli/utils/config-validation.d.ts +22 -2
- package/dist/cli/utils/config-validation.d.ts.map +1 -1
- package/dist/cli/utils/config-validation.js +354 -25
- package/dist/cli/utils/local-model-setup.d.ts +46 -0
- package/dist/cli/utils/local-model-setup.d.ts.map +1 -0
- package/dist/cli/utils/local-model-setup.js +662 -0
- package/dist/cli/utils/options.d.ts.map +1 -1
- package/dist/cli/utils/options.js +1 -3
- package/dist/cli/utils/prompt-helpers.d.ts +47 -0
- package/dist/cli/utils/prompt-helpers.d.ts.map +1 -0
- package/dist/cli/utils/prompt-helpers.js +66 -0
- package/dist/cli/utils/provider-setup.d.ts +66 -8
- package/dist/cli/utils/provider-setup.d.ts.map +1 -1
- package/dist/cli/utils/provider-setup.js +324 -84
- package/dist/cli/utils/scaffolding-utils.d.ts +76 -0
- package/dist/cli/utils/scaffolding-utils.d.ts.map +1 -0
- package/dist/cli/utils/scaffolding-utils.js +246 -0
- package/dist/cli/utils/setup-utils.d.ts +16 -0
- package/dist/cli/utils/setup-utils.d.ts.map +1 -1
- package/dist/cli/utils/setup-utils.js +72 -21
- package/dist/cli/utils/template-engine.d.ts +65 -0
- package/dist/cli/utils/template-engine.d.ts.map +1 -0
- package/dist/cli/utils/template-engine.js +1089 -0
- package/dist/config/cli-overrides.d.ts +45 -2
- package/dist/config/cli-overrides.d.ts.map +1 -1
- package/dist/config/cli-overrides.js +107 -10
- package/dist/index.js +379 -99
- package/dist/utils/agent-helpers.d.ts +95 -0
- package/dist/utils/agent-helpers.d.ts.map +1 -0
- package/dist/utils/agent-helpers.js +117 -0
- package/dist/webui/assets/index-8j-KMkX1.js +2054 -0
- package/dist/webui/assets/index-c_AX24V4.css +1 -0
- package/dist/webui/assets/{tanstack-DgxBONJY.js → tanstack-Br79RQ-n.js} +1 -1
- package/dist/webui/index.html +4 -10
- package/dist/webui/logos/aws-color.svg +1 -0
- package/dist/webui/logos/dexto/dexto_logo.svg +1 -1
- package/dist/webui/logos/dexto/dexto_logo_light.svg +6 -6
- package/dist/webui/logos/glama.svg +7 -0
- package/dist/webui/logos/litellm.svg +7 -0
- package/dist/webui/logos/openrouter.svg +1 -0
- package/package.json +18 -15
- package/dist/cli/commands/interactive-commands/index.d.ts +0 -63
- package/dist/cli/commands/interactive-commands/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/index.js +0 -73
- package/dist/cli/commands/interactive-commands/mcp/mcp-add-utils.d.ts +0 -34
- package/dist/cli/commands/interactive-commands/mcp/mcp-add-utils.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/mcp/mcp-add-utils.js +0 -178
- package/dist/cli/commands/interactive-commands/mcp/mcp-commands.d.ts +0 -9
- package/dist/cli/commands/interactive-commands/mcp/mcp-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/mcp/mcp-commands.js +0 -325
- package/dist/cli/commands/interactive-commands/model/model-commands.d.ts +0 -21
- package/dist/cli/commands/interactive-commands/model/model-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/model/model-commands.js +0 -190
- package/dist/cli/ink-cli/components/MultiLineTextInput.d.ts +0 -26
- package/dist/cli/ink-cli/components/MultiLineTextInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/MultiLineTextInput.js +0 -220
- package/dist/discord/bot.d.ts +0 -4
- package/dist/discord/bot.d.ts.map +0 -1
- package/dist/discord/bot.js +0 -193
- package/dist/telegram/bot.d.ts +0 -5
- package/dist/telegram/bot.d.ts.map +0 -1
- package/dist/telegram/bot.js +0 -251
- package/dist/webui/assets/index-DKq5Xng1.js +0 -687
- package/dist/webui/assets/index-D_0_GBu5.css +0 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// packages/cli/src/cli/utils/api-key-verification.ts
|
|
2
|
+
import { logger } from '@dexto/core';
|
|
3
|
+
/**
|
|
4
|
+
* Verify an API key by making a minimal test request to the provider.
|
|
5
|
+
* Uses provider-specific endpoints for efficient validation.
|
|
6
|
+
*
|
|
7
|
+
* @param provider - The LLM provider
|
|
8
|
+
* @param apiKey - The API key to verify
|
|
9
|
+
* @param model - Optional specific model to test with
|
|
10
|
+
* @returns Verification result
|
|
11
|
+
*/
|
|
12
|
+
export async function verifyApiKey(provider, apiKey, _model) {
|
|
13
|
+
try {
|
|
14
|
+
switch (provider) {
|
|
15
|
+
case 'openai':
|
|
16
|
+
return await verifyOpenAI(apiKey);
|
|
17
|
+
case 'anthropic':
|
|
18
|
+
return await verifyAnthropic(apiKey);
|
|
19
|
+
case 'google':
|
|
20
|
+
return await verifyGoogle(apiKey);
|
|
21
|
+
case 'groq':
|
|
22
|
+
return await verifyGroq(apiKey);
|
|
23
|
+
case 'xai':
|
|
24
|
+
return await verifyXAI(apiKey);
|
|
25
|
+
case 'cohere':
|
|
26
|
+
return await verifyCohere(apiKey);
|
|
27
|
+
case 'openrouter':
|
|
28
|
+
return await verifyOpenRouter(apiKey);
|
|
29
|
+
case 'glama':
|
|
30
|
+
return await verifyGlama(apiKey);
|
|
31
|
+
case 'openai-compatible':
|
|
32
|
+
case 'litellm':
|
|
33
|
+
// For custom endpoints, we can't verify without a baseURL
|
|
34
|
+
// Just do basic format check
|
|
35
|
+
return { success: true, modelUsed: 'custom' };
|
|
36
|
+
case 'vertex':
|
|
37
|
+
case 'bedrock':
|
|
38
|
+
// These use cloud credentials, not API keys
|
|
39
|
+
// Skip verification
|
|
40
|
+
return { success: true, modelUsed: 'cloud-auth' };
|
|
41
|
+
default:
|
|
42
|
+
// Unknown provider - skip verification
|
|
43
|
+
return { success: true, modelUsed: 'unknown' };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
48
|
+
logger.debug(`API key verification failed for ${provider}: ${errorMessage}`);
|
|
49
|
+
return { success: false, error: errorMessage };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Verify OpenAI API key using the models endpoint
|
|
54
|
+
*/
|
|
55
|
+
async function verifyOpenAI(apiKey) {
|
|
56
|
+
const response = await fetch('https://api.openai.com/v1/models', {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${apiKey}`,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
if (response.ok) {
|
|
63
|
+
return { success: true, modelUsed: 'models-list' };
|
|
64
|
+
}
|
|
65
|
+
const error = await parseErrorResponse(response);
|
|
66
|
+
return { success: false, error };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Verify Anthropic API key using a minimal messages request
|
|
70
|
+
*/
|
|
71
|
+
async function verifyAnthropic(apiKey) {
|
|
72
|
+
// Anthropic doesn't have a models endpoint, so we make a minimal request
|
|
73
|
+
// that will fail fast if the key is invalid
|
|
74
|
+
const response = await fetch('https://api.anthropic.com/v1/messages', {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
'x-api-key': apiKey,
|
|
79
|
+
'anthropic-version': '2023-06-01',
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify({
|
|
82
|
+
model: 'claude-3-5-haiku-20241022',
|
|
83
|
+
max_tokens: 1,
|
|
84
|
+
messages: [{ role: 'user', content: 'hi' }],
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
// 200 = success, 400 = bad request (but key is valid), 401/403 = invalid key
|
|
88
|
+
if (response.ok || response.status === 400) {
|
|
89
|
+
return { success: true, modelUsed: 'claude-3-5-haiku-20241022' };
|
|
90
|
+
}
|
|
91
|
+
const error = await parseErrorResponse(response);
|
|
92
|
+
return { success: false, error };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Verify Google AI API key using the models endpoint
|
|
96
|
+
*/
|
|
97
|
+
async function verifyGoogle(apiKey) {
|
|
98
|
+
const response = await fetch(`https://generativelanguage.googleapis.com/v1/models?key=${apiKey}`, {
|
|
99
|
+
method: 'GET',
|
|
100
|
+
});
|
|
101
|
+
if (response.ok) {
|
|
102
|
+
return { success: true, modelUsed: 'models-list' };
|
|
103
|
+
}
|
|
104
|
+
const error = await parseErrorResponse(response);
|
|
105
|
+
return { success: false, error };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Verify Groq API key using the models endpoint
|
|
109
|
+
*/
|
|
110
|
+
async function verifyGroq(apiKey) {
|
|
111
|
+
const response = await fetch('https://api.groq.com/openai/v1/models', {
|
|
112
|
+
method: 'GET',
|
|
113
|
+
headers: {
|
|
114
|
+
Authorization: `Bearer ${apiKey}`,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (response.ok) {
|
|
118
|
+
return { success: true, modelUsed: 'models-list' };
|
|
119
|
+
}
|
|
120
|
+
const error = await parseErrorResponse(response);
|
|
121
|
+
return { success: false, error };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Verify xAI API key using the models endpoint
|
|
125
|
+
*/
|
|
126
|
+
async function verifyXAI(apiKey) {
|
|
127
|
+
const response = await fetch('https://api.x.ai/v1/models', {
|
|
128
|
+
method: 'GET',
|
|
129
|
+
headers: {
|
|
130
|
+
Authorization: `Bearer ${apiKey}`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
if (response.ok) {
|
|
134
|
+
return { success: true, modelUsed: 'models-list' };
|
|
135
|
+
}
|
|
136
|
+
const error = await parseErrorResponse(response);
|
|
137
|
+
return { success: false, error };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Verify Cohere API key using a check-api-key endpoint or models list
|
|
141
|
+
*/
|
|
142
|
+
async function verifyCohere(apiKey) {
|
|
143
|
+
const response = await fetch('https://api.cohere.com/v2/models', {
|
|
144
|
+
method: 'GET',
|
|
145
|
+
headers: {
|
|
146
|
+
Authorization: `Bearer ${apiKey}`,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
if (response.ok) {
|
|
150
|
+
return { success: true, modelUsed: 'models-list' };
|
|
151
|
+
}
|
|
152
|
+
const error = await parseErrorResponse(response);
|
|
153
|
+
return { success: false, error };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Verify OpenRouter API key using the auth endpoint
|
|
157
|
+
*/
|
|
158
|
+
async function verifyOpenRouter(apiKey) {
|
|
159
|
+
const response = await fetch('https://openrouter.ai/api/v1/auth/key', {
|
|
160
|
+
method: 'GET',
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: `Bearer ${apiKey}`,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
if (response.ok) {
|
|
166
|
+
return { success: true, modelUsed: 'auth-check' };
|
|
167
|
+
}
|
|
168
|
+
const error = await parseErrorResponse(response);
|
|
169
|
+
return { success: false, error };
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Verify Glama API key using the models endpoint
|
|
173
|
+
*/
|
|
174
|
+
async function verifyGlama(apiKey) {
|
|
175
|
+
const response = await fetch('https://glama.ai/api/gateway/openai/v1/models', {
|
|
176
|
+
method: 'GET',
|
|
177
|
+
headers: {
|
|
178
|
+
Authorization: `Bearer ${apiKey}`,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
if (response.ok) {
|
|
182
|
+
return { success: true, modelUsed: 'models-list' };
|
|
183
|
+
}
|
|
184
|
+
const error = await parseErrorResponse(response);
|
|
185
|
+
return { success: false, error };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Parse error response from provider API
|
|
189
|
+
*/
|
|
190
|
+
async function parseErrorResponse(response) {
|
|
191
|
+
const status = response.status;
|
|
192
|
+
// Common status codes
|
|
193
|
+
if (status === 401) {
|
|
194
|
+
return 'Invalid API key - authentication failed';
|
|
195
|
+
}
|
|
196
|
+
if (status === 403) {
|
|
197
|
+
return 'API key does not have permission to access this resource';
|
|
198
|
+
}
|
|
199
|
+
if (status === 429) {
|
|
200
|
+
return 'Rate limit exceeded - but API key appears valid';
|
|
201
|
+
}
|
|
202
|
+
// Try to parse JSON error
|
|
203
|
+
try {
|
|
204
|
+
const json = await response.json();
|
|
205
|
+
const message = json.error?.message || json.message || json.detail || JSON.stringify(json);
|
|
206
|
+
return `API error (${status}): ${message}`;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return `API error (${status}): ${response.statusText}`;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
import { type AgentConfig, type ValidatedAgentConfig } from '@dexto/core';
|
|
1
|
+
import { type AgentConfig, type ValidatedAgentConfig, type LLMValidationOptions } from '@dexto/core';
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
config?: ValidatedAgentConfig;
|
|
5
|
+
errors?: string[];
|
|
6
|
+
skipped?: boolean;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Validates agent config with optional interactive fixes for user experience.
|
|
4
10
|
* Uses schema parsing to detect API key issues and provides targeted setup.
|
|
5
11
|
* Returns validated config with all defaults applied.
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: This function NEVER exits the process. It always returns a result
|
|
14
|
+
* that allows the caller to decide what to do next.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The agent configuration to validate
|
|
17
|
+
* @param interactive - Whether to allow interactive prompts to fix issues
|
|
18
|
+
* @param validationOptions - Validation strictness options
|
|
19
|
+
* @param validationOptions.strict - When true (default), enforces API key requirements.
|
|
20
|
+
* When false, allows missing credentials for interactive config.
|
|
6
21
|
*/
|
|
7
|
-
export declare function validateAgentConfig(config: AgentConfig, interactive?: boolean): Promise<
|
|
22
|
+
export declare function validateAgentConfig(config: AgentConfig, interactive?: boolean, validationOptions?: LLMValidationOptions): Promise<ValidationResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Legacy function for backwards compatibility
|
|
25
|
+
* @deprecated Use validateAgentConfig with result handling instead
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateAgentConfigOrExit(config: AgentConfig, interactive?: boolean): Promise<ValidatedAgentConfig>;
|
|
8
28
|
//# sourceMappingURL=config-validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/config-validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-validation.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/config-validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAGH,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC5B,MAAM,aAAa,CAAC;AAWrB,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,WAAW,EACnB,WAAW,GAAE,OAAe,EAC5B,iBAAiB,CAAC,EAAE,oBAAoB,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAyC3B;AAwZD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,MAAM,EAAE,WAAW,EACnB,WAAW,GAAE,OAAe,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAgC/B"}
|
|
@@ -1,37 +1,312 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import * as p from '@clack/prompts';
|
|
3
|
+
import { AgentConfigSchema, createAgentConfigSchema, } from '@dexto/core';
|
|
3
4
|
import { interactiveApiKeySetup } from './api-key-setup.js';
|
|
4
5
|
import { LLMErrorCode } from '@dexto/core';
|
|
5
6
|
import { logger } from '@dexto/core';
|
|
7
|
+
import { getGlobalPreferencesPath, loadGlobalPreferences, saveGlobalPreferences, } from '@dexto/agent-management';
|
|
6
8
|
/**
|
|
7
9
|
* Validates agent config with optional interactive fixes for user experience.
|
|
8
10
|
* Uses schema parsing to detect API key issues and provides targeted setup.
|
|
9
11
|
* Returns validated config with all defaults applied.
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: This function NEVER exits the process. It always returns a result
|
|
14
|
+
* that allows the caller to decide what to do next.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The agent configuration to validate
|
|
17
|
+
* @param interactive - Whether to allow interactive prompts to fix issues
|
|
18
|
+
* @param validationOptions - Validation strictness options
|
|
19
|
+
* @param validationOptions.strict - When true (default), enforces API key requirements.
|
|
20
|
+
* When false, allows missing credentials for interactive config.
|
|
10
21
|
*/
|
|
11
|
-
export async function validateAgentConfig(config, interactive = false) {
|
|
22
|
+
export async function validateAgentConfig(config, interactive = false, validationOptions) {
|
|
23
|
+
// Use appropriate schema based on validation options
|
|
24
|
+
// Default to strict validation unless explicitly relaxed
|
|
25
|
+
const schema = validationOptions?.strict === false
|
|
26
|
+
? createAgentConfigSchema({ strict: false })
|
|
27
|
+
: AgentConfigSchema;
|
|
12
28
|
// Parse with schema to detect issues
|
|
13
|
-
const parseResult =
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
const parseResult = schema.safeParse(config);
|
|
30
|
+
if (parseResult.success) {
|
|
31
|
+
return { success: true, config: parseResult.data };
|
|
32
|
+
}
|
|
33
|
+
// Validation failed - handle based on mode
|
|
34
|
+
logger.debug(`Agent config validation error: ${JSON.stringify(parseResult.error)}`);
|
|
35
|
+
const errors = formatZodErrors(parseResult.error);
|
|
36
|
+
if (!interactive) {
|
|
37
|
+
// Non-interactive mode: show errors and next steps, but don't exit
|
|
38
|
+
showValidationErrors(errors);
|
|
39
|
+
showNextSteps();
|
|
40
|
+
return { success: false, errors };
|
|
41
|
+
}
|
|
42
|
+
// Interactive mode: try to help the user fix the issue
|
|
43
|
+
// Check for API key errors first
|
|
44
|
+
const apiKeyError = findApiKeyError(parseResult.error, config);
|
|
45
|
+
if (apiKeyError) {
|
|
46
|
+
return await handleApiKeyError(apiKeyError.provider, config, errors, validationOptions);
|
|
47
|
+
}
|
|
48
|
+
// Check for baseURL errors next
|
|
49
|
+
const baseURLError = findBaseURLError(parseResult.error, config);
|
|
50
|
+
if (baseURLError) {
|
|
51
|
+
return await handleBaseURLError(baseURLError.provider, config, errors, validationOptions);
|
|
52
|
+
}
|
|
53
|
+
// Other validation errors - show options
|
|
54
|
+
return await handleOtherErrors(errors);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Handle API key validation errors interactively
|
|
58
|
+
*/
|
|
59
|
+
async function handleApiKeyError(provider, config, errors, validationOptions) {
|
|
60
|
+
console.log(chalk.rgb(255, 165, 0)(`\n🔑 API key issue detected for ${provider} provider\n`));
|
|
61
|
+
const action = await p.select({
|
|
62
|
+
message: 'How would you like to proceed?',
|
|
63
|
+
options: [
|
|
64
|
+
{
|
|
65
|
+
value: 'setup',
|
|
66
|
+
label: 'Set up API key now',
|
|
67
|
+
hint: 'Configure the API key interactively',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: 'skip',
|
|
71
|
+
label: 'Continue anyway',
|
|
72
|
+
hint: 'Try to start without fixing (may fail)',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
value: 'edit',
|
|
76
|
+
label: 'Edit configuration manually',
|
|
77
|
+
hint: 'Show file path and instructions',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
if (p.isCancel(action)) {
|
|
82
|
+
showNextSteps();
|
|
83
|
+
return { success: false, errors, skipped: true };
|
|
84
|
+
}
|
|
85
|
+
if (action === 'setup') {
|
|
86
|
+
const result = await interactiveApiKeySetup(provider, { exitOnCancel: false });
|
|
87
|
+
if (result.success && !result.skipped) {
|
|
88
|
+
// Retry validation after API key setup
|
|
89
|
+
return validateAgentConfig(config, true, validationOptions);
|
|
27
90
|
}
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
91
|
+
// Setup was skipped or cancelled - let them continue anyway
|
|
92
|
+
return { success: false, errors, skipped: true };
|
|
93
|
+
}
|
|
94
|
+
if (action === 'edit') {
|
|
95
|
+
showManualEditInstructions();
|
|
96
|
+
return { success: false, errors, skipped: true };
|
|
97
|
+
}
|
|
98
|
+
// 'skip' - continue anyway
|
|
99
|
+
p.log.warn('Continuing with validation errors - some features may not work correctly');
|
|
100
|
+
return { success: false, errors, skipped: true };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Handle baseURL validation errors interactively
|
|
104
|
+
*/
|
|
105
|
+
async function handleBaseURLError(provider, config, errors, validationOptions) {
|
|
106
|
+
console.log(chalk.rgb(255, 165, 0)(`\n🌐 Base URL required for ${provider} provider\n`));
|
|
107
|
+
const providerExamples = {
|
|
108
|
+
'openai-compatible': 'http://localhost:11434/v1 (Ollama)',
|
|
109
|
+
litellm: 'http://localhost:4000 (LiteLLM proxy)',
|
|
110
|
+
};
|
|
111
|
+
const example = providerExamples[provider] || 'http://localhost:8080/v1';
|
|
112
|
+
p.note([
|
|
113
|
+
`The ${provider} provider requires a base URL to connect to your`,
|
|
114
|
+
`local or custom LLM endpoint.`,
|
|
115
|
+
``,
|
|
116
|
+
`${chalk.gray('Example:')} ${example}`,
|
|
117
|
+
].join('\n'), 'Base URL Required');
|
|
118
|
+
const action = await p.select({
|
|
119
|
+
message: 'How would you like to proceed?',
|
|
120
|
+
options: [
|
|
121
|
+
{
|
|
122
|
+
value: 'setup',
|
|
123
|
+
label: 'Enter base URL now',
|
|
124
|
+
hint: 'Configure the base URL interactively',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
value: 'skip',
|
|
128
|
+
label: 'Continue anyway',
|
|
129
|
+
hint: 'Try to start without fixing (may fail)',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
value: 'edit',
|
|
133
|
+
label: 'Edit configuration manually',
|
|
134
|
+
hint: 'Show file path and instructions',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
if (p.isCancel(action)) {
|
|
139
|
+
showNextSteps();
|
|
140
|
+
return { success: false, errors, skipped: true };
|
|
141
|
+
}
|
|
142
|
+
if (action === 'setup') {
|
|
143
|
+
const result = await interactiveBaseURLSetup(provider, config.llm?.baseURL);
|
|
144
|
+
if (result.success && !result.skipped && result.baseURL && config.llm) {
|
|
145
|
+
// Update config with the new baseURL for retry validation
|
|
146
|
+
const updatedConfig = {
|
|
147
|
+
...config,
|
|
148
|
+
llm: { ...config.llm, baseURL: result.baseURL },
|
|
149
|
+
};
|
|
150
|
+
// Retry validation after baseURL setup
|
|
151
|
+
return validateAgentConfig(updatedConfig, true, validationOptions);
|
|
152
|
+
}
|
|
153
|
+
// Setup was skipped or cancelled
|
|
154
|
+
return { success: false, errors, skipped: true };
|
|
155
|
+
}
|
|
156
|
+
if (action === 'edit') {
|
|
157
|
+
showManualEditInstructions();
|
|
158
|
+
return { success: false, errors, skipped: true };
|
|
159
|
+
}
|
|
160
|
+
// 'skip' - continue anyway
|
|
161
|
+
p.log.warn('Continuing with validation errors - some features may not work correctly');
|
|
162
|
+
return { success: false, errors, skipped: true };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Interactive baseURL setup
|
|
166
|
+
*/
|
|
167
|
+
async function interactiveBaseURLSetup(provider, existingBaseURL) {
|
|
168
|
+
const providerDefaults = {
|
|
169
|
+
'openai-compatible': 'http://localhost:11434/v1',
|
|
170
|
+
litellm: 'http://localhost:4000',
|
|
171
|
+
};
|
|
172
|
+
// Use existing baseURL if available, otherwise fall back to provider defaults
|
|
173
|
+
const defaultURL = existingBaseURL || providerDefaults[provider] || '';
|
|
174
|
+
const baseURL = await p.text({
|
|
175
|
+
message: `Enter base URL for ${provider}`,
|
|
176
|
+
placeholder: defaultURL,
|
|
177
|
+
initialValue: defaultURL,
|
|
178
|
+
validate: (value) => {
|
|
179
|
+
if (!value.trim()) {
|
|
180
|
+
return 'Base URL is required';
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
new URL(value.trim());
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return 'Please enter a valid URL (e.g., http://localhost:11434/v1)';
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
if (p.isCancel(baseURL)) {
|
|
192
|
+
p.log.warn('Skipping base URL setup. You can configure it later with: dexto setup');
|
|
193
|
+
return { success: false, skipped: true };
|
|
194
|
+
}
|
|
195
|
+
const trimmedURL = baseURL.trim();
|
|
196
|
+
// Save to preferences
|
|
197
|
+
const spinner = p.spinner();
|
|
198
|
+
spinner.start('Saving base URL to preferences...');
|
|
199
|
+
try {
|
|
200
|
+
const preferences = await loadGlobalPreferences();
|
|
201
|
+
// Update the LLM section with baseURL (complete replacement as per schema design)
|
|
202
|
+
const updatedPreferences = {
|
|
203
|
+
...preferences,
|
|
204
|
+
llm: {
|
|
205
|
+
...preferences.llm,
|
|
206
|
+
baseURL: trimmedURL,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
await saveGlobalPreferences(updatedPreferences);
|
|
210
|
+
spinner.stop(chalk.green('✓ Base URL saved to preferences'));
|
|
211
|
+
return { success: true, baseURL: trimmedURL };
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
spinner.stop(chalk.red('✗ Failed to save base URL'));
|
|
215
|
+
logger.error(`Failed to save baseURL: ${error instanceof Error ? error.message : String(error)}`);
|
|
216
|
+
// Show manual instructions
|
|
217
|
+
p.note([
|
|
218
|
+
`Add this to your preferences file:`,
|
|
219
|
+
``,
|
|
220
|
+
` ${chalk.cyan('baseURL:')} ${trimmedURL}`,
|
|
221
|
+
``,
|
|
222
|
+
`File: ${getGlobalPreferencesPath()}`,
|
|
223
|
+
].join('\n'), chalk.rgb(255, 165, 0)('Manual Setup Required'));
|
|
224
|
+
// Still return success with the URL for in-memory use
|
|
225
|
+
return { success: true, baseURL: trimmedURL, skipped: true };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Handle non-API-key validation errors interactively
|
|
230
|
+
*/
|
|
231
|
+
async function handleOtherErrors(errors) {
|
|
232
|
+
console.log(chalk.rgb(255, 165, 0)('\n⚠️ Configuration issues detected:\n'));
|
|
233
|
+
for (const error of errors) {
|
|
234
|
+
console.log(chalk.red(` • ${error}`));
|
|
235
|
+
}
|
|
236
|
+
console.log('');
|
|
237
|
+
const action = await p.select({
|
|
238
|
+
message: 'How would you like to proceed?',
|
|
239
|
+
options: [
|
|
240
|
+
{
|
|
241
|
+
value: 'skip',
|
|
242
|
+
label: 'Continue anyway',
|
|
243
|
+
hint: 'Try to start despite errors (may fail)',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
value: 'edit',
|
|
247
|
+
label: 'Edit configuration manually',
|
|
248
|
+
hint: 'Show file path and instructions',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
value: 'setup',
|
|
252
|
+
label: 'Run setup again',
|
|
253
|
+
hint: 'Reconfigure from scratch',
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
});
|
|
257
|
+
if (p.isCancel(action)) {
|
|
258
|
+
showNextSteps();
|
|
259
|
+
return { success: false, errors, skipped: true };
|
|
260
|
+
}
|
|
261
|
+
if (action === 'edit') {
|
|
262
|
+
showManualEditInstructions();
|
|
263
|
+
return { success: false, errors, skipped: true };
|
|
32
264
|
}
|
|
33
|
-
|
|
34
|
-
|
|
265
|
+
if (action === 'setup') {
|
|
266
|
+
p.log.info('Run: dexto setup --force');
|
|
267
|
+
return { success: false, errors, skipped: true };
|
|
268
|
+
}
|
|
269
|
+
// 'skip' - continue anyway
|
|
270
|
+
p.log.warn('Continuing with validation errors - some features may not work correctly');
|
|
271
|
+
return { success: false, errors, skipped: true };
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Show validation errors in a user-friendly way
|
|
275
|
+
*/
|
|
276
|
+
function showValidationErrors(errors) {
|
|
277
|
+
console.log(chalk.rgb(255, 165, 0)('\n⚠️ Configuration issues detected:\n'));
|
|
278
|
+
for (const error of errors) {
|
|
279
|
+
console.log(chalk.red(` • ${error}`));
|
|
280
|
+
}
|
|
281
|
+
console.log('');
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Show next steps after validation failure
|
|
285
|
+
*/
|
|
286
|
+
function showNextSteps() {
|
|
287
|
+
const prefsPath = getGlobalPreferencesPath();
|
|
288
|
+
console.log(chalk.bold('\nNext steps:'));
|
|
289
|
+
console.log(` • Run ${chalk.cyan('dexto setup')} to reconfigure interactively`);
|
|
290
|
+
console.log(` • Edit ${chalk.cyan(prefsPath)} directly`);
|
|
291
|
+
console.log(` • Check your environment variables\n`);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Show manual edit instructions
|
|
295
|
+
*/
|
|
296
|
+
function showManualEditInstructions() {
|
|
297
|
+
const prefsPath = getGlobalPreferencesPath();
|
|
298
|
+
p.note([
|
|
299
|
+
`Your configuration files:`,
|
|
300
|
+
``,
|
|
301
|
+
` ${chalk.cyan('Global preferences:')} ${prefsPath}`,
|
|
302
|
+
` ${chalk.cyan('Agent configs:')} ~/.dexto/agents/*/`,
|
|
303
|
+
``,
|
|
304
|
+
`Edit the appropriate file and run dexto again.`,
|
|
305
|
+
``,
|
|
306
|
+
chalk.gray('Example commands:'),
|
|
307
|
+
chalk.gray(` code ${prefsPath} # Open in VS Code`),
|
|
308
|
+
chalk.gray(` nano ${prefsPath} # Edit in terminal`),
|
|
309
|
+
].join('\n'), 'Manual Configuration');
|
|
35
310
|
}
|
|
36
311
|
/**
|
|
37
312
|
* Extract API key error details from Zod validation error
|
|
@@ -56,6 +331,28 @@ function findApiKeyError(error, configData) {
|
|
|
56
331
|
}
|
|
57
332
|
return null;
|
|
58
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Extract baseURL error details from Zod validation error
|
|
336
|
+
*/
|
|
337
|
+
function findBaseURLError(error, configData) {
|
|
338
|
+
for (const issue of error.issues) {
|
|
339
|
+
// Check for our custom BASE_URL_MISSING error code in params
|
|
340
|
+
if (issue.code === 'custom' && hasErrorCode(issue.params, LLMErrorCode.BASE_URL_MISSING)) {
|
|
341
|
+
const provider = getProviderFromParams(issue.params) || configData.llm?.provider;
|
|
342
|
+
if (provider) {
|
|
343
|
+
return { provider };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Fallback: check for baseURL path errors
|
|
347
|
+
if (issue.path.includes('baseURL') && issue.message.includes('requires')) {
|
|
348
|
+
const provider = configData.llm?.provider;
|
|
349
|
+
if (provider) {
|
|
350
|
+
return { provider };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
59
356
|
/**
|
|
60
357
|
* Type guard to check if params contains the expected error code
|
|
61
358
|
*/
|
|
@@ -80,9 +377,41 @@ function getProviderFromParams(params) {
|
|
|
80
377
|
/**
|
|
81
378
|
* Format Zod validation errors in a user-friendly way
|
|
82
379
|
*/
|
|
83
|
-
function
|
|
84
|
-
|
|
380
|
+
function formatZodErrors(error) {
|
|
381
|
+
return error.issues.map((issue) => {
|
|
85
382
|
const path = issue.path.length > 0 ? issue.path.join('.') : 'config';
|
|
86
|
-
|
|
383
|
+
return `${path}: ${issue.message}`;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Legacy function for backwards compatibility
|
|
388
|
+
* @deprecated Use validateAgentConfig with result handling instead
|
|
389
|
+
*/
|
|
390
|
+
export async function validateAgentConfigOrExit(config, interactive = false) {
|
|
391
|
+
const result = await validateAgentConfig(config, interactive);
|
|
392
|
+
if (result.success && result.config) {
|
|
393
|
+
return result.config;
|
|
394
|
+
}
|
|
395
|
+
// If validation failed but was skipped, return config as-is with defaults applied
|
|
396
|
+
// This allows the app to launch in a limited capacity (e.g., web UI for configuration)
|
|
397
|
+
// Runtime errors will occur when actually trying to use the LLM
|
|
398
|
+
if (result.skipped) {
|
|
399
|
+
logger.warn('Starting with validation warnings - some features may not work');
|
|
400
|
+
// Apply defaults manually without strict validation
|
|
401
|
+
// This allows launching web UI for interactive configuration
|
|
402
|
+
// Use unknown cast to bypass branded type checking since we're intentionally
|
|
403
|
+
// returning a partially valid config that the user acknowledged
|
|
404
|
+
const configWithDefaults = {
|
|
405
|
+
...config,
|
|
406
|
+
llm: {
|
|
407
|
+
...config.llm,
|
|
408
|
+
maxIterations: config.llm?.maxIterations ?? 50,
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
return configWithDefaults;
|
|
87
412
|
}
|
|
413
|
+
// Last resort: exit with helpful message
|
|
414
|
+
console.log(chalk.rgb(255, 165, 0)('\nUnable to start with current configuration.'));
|
|
415
|
+
showNextSteps();
|
|
416
|
+
process.exit(1);
|
|
88
417
|
}
|