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
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Management Commands
|
|
3
|
-
*
|
|
4
|
-
* This module contains all model-related CLI commands extracted from the monolithic commands.ts.
|
|
5
|
-
* These commands provide functionality for managing AI models including listing supported models,
|
|
6
|
-
* switching between different models, and displaying current model configuration.
|
|
7
|
-
*
|
|
8
|
-
* Commands:
|
|
9
|
-
* - list: List all supported providers and models with capabilities
|
|
10
|
-
* - current: Show current model configuration details
|
|
11
|
-
* - switch: Switch to a different AI model (provider auto-detected)
|
|
12
|
-
* - help: Show detailed help for model commands
|
|
13
|
-
*/
|
|
14
|
-
import chalk from 'chalk';
|
|
15
|
-
import { DextoRuntimeError, DextoValidationError } from '@dexto/core';
|
|
16
|
-
import { CommandOutputHelper } from '../utils/command-output.js';
|
|
17
|
-
/**
|
|
18
|
-
* Model management command definition
|
|
19
|
-
* Note: In interactive CLI, /model shows the interactive selector
|
|
20
|
-
* Subcommands available for debugging/advanced use, but not emphasized
|
|
21
|
-
*/
|
|
22
|
-
export const modelCommands = {
|
|
23
|
-
name: 'model',
|
|
24
|
-
description: 'Switch AI model (interactive selector)',
|
|
25
|
-
usage: '/model',
|
|
26
|
-
category: 'General',
|
|
27
|
-
aliases: ['m'],
|
|
28
|
-
subcommands: [
|
|
29
|
-
{
|
|
30
|
-
name: 'list',
|
|
31
|
-
description: 'List all supported providers and models',
|
|
32
|
-
usage: '/model list',
|
|
33
|
-
handler: async (_args, agent) => {
|
|
34
|
-
try {
|
|
35
|
-
console.log(chalk.bold.blue('\n🤖 Supported Models and Providers:\n'));
|
|
36
|
-
const providers = agent.getSupportedProviders();
|
|
37
|
-
const allModels = agent.getSupportedModels();
|
|
38
|
-
for (const provider of providers) {
|
|
39
|
-
const models = allModels[provider];
|
|
40
|
-
console.log(chalk.bold.yellow(`${provider.toUpperCase()}:`));
|
|
41
|
-
console.log(chalk.cyan(' Models:'));
|
|
42
|
-
for (const model of models) {
|
|
43
|
-
const tokenLimit = ` (${model.maxInputTokens.toLocaleString()} tokens)`;
|
|
44
|
-
const defaultLabel = model.isDefault ? chalk.green(' [DEFAULT]') : '';
|
|
45
|
-
console.log(` ${chalk.cyan(model.name)}${tokenLimit}${defaultLabel}`);
|
|
46
|
-
}
|
|
47
|
-
console.log();
|
|
48
|
-
}
|
|
49
|
-
console.log(chalk.dim('💡 Use /model switch <model> to switch models'));
|
|
50
|
-
console.log(chalk.dim('💡 Default models are marked with [DEFAULT]'));
|
|
51
|
-
console.log(chalk.dim('💡 Token limits show maximum input context size\n'));
|
|
52
|
-
return CommandOutputHelper.noOutput(); // List is displayed above
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return CommandOutputHelper.error(error, 'Failed to list models');
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'current',
|
|
61
|
-
description: 'Show current model configuration',
|
|
62
|
-
usage: '/model current',
|
|
63
|
-
handler: async (args, agent) => {
|
|
64
|
-
try {
|
|
65
|
-
const config = agent.getEffectiveConfig();
|
|
66
|
-
console.log(chalk.blue('\n🤖 Current Model Configuration:\n'));
|
|
67
|
-
console.log(` Provider: ${chalk.cyan(config.llm.provider)}`);
|
|
68
|
-
console.log(` Model: ${chalk.cyan(config.llm.model)}`);
|
|
69
|
-
console.log(` Router: ${chalk.cyan(config.llm.router)}`);
|
|
70
|
-
if (config.llm.maxIterations) {
|
|
71
|
-
console.log(` Max Iterations: ${chalk.cyan(config.llm.maxIterations.toString())}`);
|
|
72
|
-
}
|
|
73
|
-
if (config.llm.maxInputTokens) {
|
|
74
|
-
console.log(` Max Input Tokens: ${chalk.cyan(config.llm.maxInputTokens.toString())}`);
|
|
75
|
-
}
|
|
76
|
-
console.log();
|
|
77
|
-
return CommandOutputHelper.noOutput(); // Config is displayed above
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
return CommandOutputHelper.error(error, 'Failed to get model info');
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'switch',
|
|
86
|
-
description: 'Switch to a different model',
|
|
87
|
-
usage: '/model switch <model>',
|
|
88
|
-
handler: async (args, agent) => {
|
|
89
|
-
const validationError = CommandOutputHelper.validateRequiredArg(args, 0, 'Model name', '/model switch <model>');
|
|
90
|
-
if (validationError)
|
|
91
|
-
return validationError;
|
|
92
|
-
const model = args[0] || '';
|
|
93
|
-
try {
|
|
94
|
-
// Infer provider from model name
|
|
95
|
-
const provider = agent.inferProviderFromModel(model);
|
|
96
|
-
if (!provider) {
|
|
97
|
-
return CommandOutputHelper.error(new Error(`Unknown model: ${model}\n💡 Use /model list to see available models`));
|
|
98
|
-
}
|
|
99
|
-
console.log(chalk.yellow(`🔄 Switching to ${model} (${provider})...`));
|
|
100
|
-
const llmConfig = { model, provider };
|
|
101
|
-
await agent.switchLLM(llmConfig);
|
|
102
|
-
return CommandOutputHelper.success(`✅ Successfully switched to ${model} (${provider})`);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
if (error instanceof DextoRuntimeError) {
|
|
106
|
-
const errorLines = [
|
|
107
|
-
`Failed to switch model:\n ${error.message}\n Code: ${error.code}`,
|
|
108
|
-
];
|
|
109
|
-
if (error.recovery) {
|
|
110
|
-
const recoverySteps = Array.isArray(error.recovery)
|
|
111
|
-
? error.recovery
|
|
112
|
-
: [error.recovery];
|
|
113
|
-
errorLines.push(...recoverySteps.map((step) => `💡 ${step}`));
|
|
114
|
-
}
|
|
115
|
-
console.log(chalk.red(errorLines.join('\n')));
|
|
116
|
-
return CommandOutputHelper.error(new Error(errorLines.join('\n')));
|
|
117
|
-
}
|
|
118
|
-
else if (error instanceof DextoValidationError) {
|
|
119
|
-
const errors = error.errors.map((e) => ` - ${e.message}`).join('\n');
|
|
120
|
-
return CommandOutputHelper.error(new Error(`Validation failed:\n${errors}`));
|
|
121
|
-
}
|
|
122
|
-
return CommandOutputHelper.error(error, 'Failed to switch model');
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: 'help',
|
|
128
|
-
description: 'Show detailed help for model commands',
|
|
129
|
-
usage: '/model help',
|
|
130
|
-
handler: async (_args, _agent) => {
|
|
131
|
-
const helpText = [
|
|
132
|
-
'\n🤖 Model Management Commands:\n',
|
|
133
|
-
'Available subcommands:',
|
|
134
|
-
' /model list - List all supported providers, models, and capabilities',
|
|
135
|
-
' /model current - Display currently active model and configuration',
|
|
136
|
-
' /model switch <model> - Switch to a different AI model (provider auto-detected)',
|
|
137
|
-
' Examples:',
|
|
138
|
-
' /model switch gpt-5',
|
|
139
|
-
' /model switch claude-sonnet-4-5-20250929',
|
|
140
|
-
' /model switch gemini-2.5-pro',
|
|
141
|
-
' /model help - Show this help message',
|
|
142
|
-
'\n💡 Switching models allows you to use different AI capabilities',
|
|
143
|
-
'💡 Model changes apply to the current session immediately',
|
|
144
|
-
'💡 Available providers: openai, anthropic, gemini',
|
|
145
|
-
'💡 You can also press Ctrl+M for interactive model selector\n',
|
|
146
|
-
].join('\n');
|
|
147
|
-
console.log(chalk.bold.blue('\n🤖 Model Management Commands:\n'));
|
|
148
|
-
console.log(chalk.cyan('Available subcommands:'));
|
|
149
|
-
console.log(` ${chalk.yellow('/model list')} - List all supported providers, models, and capabilities`);
|
|
150
|
-
console.log(` ${chalk.yellow('/model current')} - Display currently active model and configuration`);
|
|
151
|
-
console.log(` ${chalk.yellow('/model switch')} ${chalk.blue('<model>')} - Switch to a different AI model (provider auto-detected)`);
|
|
152
|
-
console.log(` Examples:`);
|
|
153
|
-
console.log(` ${chalk.dim('/model switch gpt-5')}`);
|
|
154
|
-
console.log(` ${chalk.dim('/model switch claude-sonnet-4-5-20250929')}`);
|
|
155
|
-
console.log(` ${chalk.dim('/model switch gemini-2.5-pro')}`);
|
|
156
|
-
console.log(` ${chalk.yellow('/model help')} - Show this help message`);
|
|
157
|
-
console.log(chalk.dim('\n💡 Switching models allows you to use different AI capabilities'));
|
|
158
|
-
console.log(chalk.dim('💡 Model changes apply to the current session immediately'));
|
|
159
|
-
console.log(chalk.dim('💡 Available providers: openai, anthropic, gemini'));
|
|
160
|
-
console.log(chalk.dim('💡 You can also press Ctrl+M for interactive model selector\n'));
|
|
161
|
-
return helpText;
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
handler: async (args, agent) => {
|
|
166
|
-
// Default to showing help about interactive selector if no subcommand
|
|
167
|
-
if (args.length === 0) {
|
|
168
|
-
const helpText = [
|
|
169
|
-
'🤖 Model Selection',
|
|
170
|
-
'\nIn interactive mode: Press Ctrl+M or type /model to show the model selector',
|
|
171
|
-
'\nAdvanced subcommands (optional):',
|
|
172
|
-
' /model list - List all available models',
|
|
173
|
-
' /model current - Show current model',
|
|
174
|
-
' /model switch <model> - Switch to specific model\n',
|
|
175
|
-
].join('\n');
|
|
176
|
-
console.log(chalk.blue(helpText));
|
|
177
|
-
return helpText;
|
|
178
|
-
}
|
|
179
|
-
const subcommand = args[0];
|
|
180
|
-
const subArgs = args.slice(1);
|
|
181
|
-
// Find matching subcommand
|
|
182
|
-
const subcmd = modelCommands.subcommands?.find((s) => s.name === subcommand);
|
|
183
|
-
if (subcmd) {
|
|
184
|
-
return subcmd.handler(subArgs, agent);
|
|
185
|
-
}
|
|
186
|
-
const errorMsg = `❌ Unknown model subcommand: ${subcommand}\nUse /model for interactive selector or /model list to see all models`;
|
|
187
|
-
console.log(chalk.red(errorMsg));
|
|
188
|
-
return errorMsg;
|
|
189
|
-
},
|
|
190
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-line text input component
|
|
3
|
-
*
|
|
4
|
-
* Keyboard behavior (standard terminal-like):
|
|
5
|
-
* - Typing: Characters appear at cursor position
|
|
6
|
-
* - Backspace: Delete character before cursor
|
|
7
|
-
* - Left/Right: Move cursor horizontally
|
|
8
|
-
* - Up/Down: Navigate history (single line) or move between lines (multi-line)
|
|
9
|
-
* - Enter: Submit
|
|
10
|
-
* - Shift+Enter: Add newline
|
|
11
|
-
* - Ctrl+A: Move to start of line
|
|
12
|
-
* - Ctrl+E: Move to end of line
|
|
13
|
-
*/
|
|
14
|
-
interface MultiLineTextInputProps {
|
|
15
|
-
value: string;
|
|
16
|
-
onChange: (value: string) => void;
|
|
17
|
-
onSubmit: (value: string) => void;
|
|
18
|
-
placeholder?: string | undefined;
|
|
19
|
-
isDisabled?: boolean | undefined;
|
|
20
|
-
history?: string[] | undefined;
|
|
21
|
-
historyIndex?: number | undefined;
|
|
22
|
-
onHistoryNavigate?: ((direction: 'up' | 'down') => void) | undefined;
|
|
23
|
-
}
|
|
24
|
-
export declare function MultiLineTextInput({ value, onChange, onSubmit, placeholder, isDisabled, history, historyIndex, onHistoryNavigate, }: MultiLineTextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=MultiLineTextInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MultiLineTextInput.d.ts","sourceRoot":"","sources":["../../../../src/cli/ink-cli/components/MultiLineTextInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,UAAU,uBAAuB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEjC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxE;AAED,wBAAgB,kBAAkB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,UAAkB,EAClB,OAAY,EACZ,YAAiB,EACjB,iBAAiB,GACpB,EAAE,uBAAuB,2CA2RzB"}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Multi-line text input component
|
|
4
|
-
*
|
|
5
|
-
* Keyboard behavior (standard terminal-like):
|
|
6
|
-
* - Typing: Characters appear at cursor position
|
|
7
|
-
* - Backspace: Delete character before cursor
|
|
8
|
-
* - Left/Right: Move cursor horizontally
|
|
9
|
-
* - Up/Down: Navigate history (single line) or move between lines (multi-line)
|
|
10
|
-
* - Enter: Submit
|
|
11
|
-
* - Shift+Enter: Add newline
|
|
12
|
-
* - Ctrl+A: Move to start of line
|
|
13
|
-
* - Ctrl+E: Move to end of line
|
|
14
|
-
*/
|
|
15
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
16
|
-
import { Box, Text, useInput, useStdout } from 'ink';
|
|
17
|
-
export function MultiLineTextInput({ value, onChange, onSubmit, placeholder, isDisabled = false, history = [], historyIndex = -1, onHistoryNavigate, }) {
|
|
18
|
-
const [cursorPos, setCursorPos] = useState(value.length);
|
|
19
|
-
const { stdout } = useStdout();
|
|
20
|
-
const terminalWidth = stdout?.columns || 80;
|
|
21
|
-
// Keep cursor valid when value changes externally (e.g., from history navigation)
|
|
22
|
-
// Only adjust if cursor would be past end of value, to avoid jumping during typing
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (cursorPos > value.length) {
|
|
25
|
-
setCursorPos(value.length);
|
|
26
|
-
}
|
|
27
|
-
}, [value, cursorPos]);
|
|
28
|
-
// Calculate line info for cursor positioning
|
|
29
|
-
const getLineInfo = useCallback((pos) => {
|
|
30
|
-
const lines = value.split('\n');
|
|
31
|
-
let charCount = 0;
|
|
32
|
-
let lineIndex = 0;
|
|
33
|
-
let colIndex = 0;
|
|
34
|
-
for (let i = 0; i < lines.length; i++) {
|
|
35
|
-
const lineLength = lines[i].length;
|
|
36
|
-
if (charCount + lineLength >= pos || i === lines.length - 1) {
|
|
37
|
-
lineIndex = i;
|
|
38
|
-
colIndex = pos - charCount;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
charCount += lineLength + 1; // +1 for newline
|
|
42
|
-
}
|
|
43
|
-
return { lines, lineIndex, colIndex, charCount };
|
|
44
|
-
}, [value]);
|
|
45
|
-
// Get position at start of a line
|
|
46
|
-
const getLineStart = useCallback((lineIndex) => {
|
|
47
|
-
const lines = value.split('\n');
|
|
48
|
-
let pos = 0;
|
|
49
|
-
for (let i = 0; i < lineIndex && i < lines.length; i++) {
|
|
50
|
-
pos += lines[i].length + 1;
|
|
51
|
-
}
|
|
52
|
-
return pos;
|
|
53
|
-
}, [value]);
|
|
54
|
-
useInput((input, key) => {
|
|
55
|
-
if (isDisabled)
|
|
56
|
-
return;
|
|
57
|
-
const lines = value.split('\n');
|
|
58
|
-
const isMultiLine = lines.length > 1;
|
|
59
|
-
const { lineIndex, colIndex } = getLineInfo(cursorPos);
|
|
60
|
-
// Newline detection based on actual terminal behavior:
|
|
61
|
-
// - Ctrl+J sends \n (0x0a) with NO ctrl flag (Enter sends \r with key.return)
|
|
62
|
-
// - Shift+Enter sends backslash + \r (0x5c 0x0d) on many terminals
|
|
63
|
-
// - Alt+Enter may set key.meta with key.return
|
|
64
|
-
const isCtrlJ = input === '\n'; // Ctrl+J sends 0x0a, regular Enter sends 0x0d
|
|
65
|
-
const isShiftEnter = input === '\\\r' ||
|
|
66
|
-
(key.return && key.shift) ||
|
|
67
|
-
input === '\x1b[13;2u' ||
|
|
68
|
-
input === '\x1bOM';
|
|
69
|
-
const wantsNewline = isCtrlJ || isShiftEnter || (key.return && key.meta);
|
|
70
|
-
if (wantsNewline) {
|
|
71
|
-
const newValue = value.slice(0, cursorPos) + '\n' + value.slice(cursorPos);
|
|
72
|
-
onChange(newValue);
|
|
73
|
-
setCursorPos(cursorPos + 1);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
// Enter = submit
|
|
77
|
-
if (key.return) {
|
|
78
|
-
if (value.trim()) {
|
|
79
|
-
onSubmit(value);
|
|
80
|
-
}
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Backspace - delete character before cursor
|
|
84
|
-
const isBackspace = key.backspace || input === '\x7f' || input === '\x08';
|
|
85
|
-
if (isBackspace) {
|
|
86
|
-
if (cursorPos > 0) {
|
|
87
|
-
const newValue = value.slice(0, cursorPos - 1) + value.slice(cursorPos);
|
|
88
|
-
onChange(newValue);
|
|
89
|
-
setCursorPos(cursorPos - 1);
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Delete - delete character at cursor (forward delete)
|
|
94
|
-
if (key.delete) {
|
|
95
|
-
if (cursorPos < value.length) {
|
|
96
|
-
const newValue = value.slice(0, cursorPos) + value.slice(cursorPos + 1);
|
|
97
|
-
onChange(newValue);
|
|
98
|
-
}
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
// Left arrow
|
|
102
|
-
if (key.leftArrow) {
|
|
103
|
-
setCursorPos(Math.max(0, cursorPos - 1));
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
// Right arrow
|
|
107
|
-
if (key.rightArrow) {
|
|
108
|
-
setCursorPos(Math.min(value.length, cursorPos + 1));
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
// Up arrow
|
|
112
|
-
if (key.upArrow) {
|
|
113
|
-
if (isMultiLine && lineIndex > 0) {
|
|
114
|
-
const prevLineStart = getLineStart(lineIndex - 1);
|
|
115
|
-
const prevLineLength = lines[lineIndex - 1].length;
|
|
116
|
-
const newCol = Math.min(colIndex, prevLineLength);
|
|
117
|
-
setCursorPos(prevLineStart + newCol);
|
|
118
|
-
}
|
|
119
|
-
else if (onHistoryNavigate && history.length > 0) {
|
|
120
|
-
onHistoryNavigate('up');
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
// Down arrow
|
|
125
|
-
if (key.downArrow) {
|
|
126
|
-
if (isMultiLine && lineIndex < lines.length - 1) {
|
|
127
|
-
const nextLineStart = getLineStart(lineIndex + 1);
|
|
128
|
-
const nextLineLength = lines[lineIndex + 1].length;
|
|
129
|
-
const newCol = Math.min(colIndex, nextLineLength);
|
|
130
|
-
setCursorPos(nextLineStart + newCol);
|
|
131
|
-
}
|
|
132
|
-
else if (onHistoryNavigate && historyIndex >= 0) {
|
|
133
|
-
onHistoryNavigate('down');
|
|
134
|
-
}
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
// Ctrl+A - start of line
|
|
138
|
-
if (key.ctrl && input === 'a') {
|
|
139
|
-
setCursorPos(getLineStart(lineIndex));
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
// Ctrl+E - end of line
|
|
143
|
-
if (key.ctrl && input === 'e') {
|
|
144
|
-
const lineStart = getLineStart(lineIndex);
|
|
145
|
-
setCursorPos(lineStart + lines[lineIndex].length);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
// Ctrl+K - delete to end of line
|
|
149
|
-
if (key.ctrl && input === 'k') {
|
|
150
|
-
const lineStart = getLineStart(lineIndex);
|
|
151
|
-
const lineEnd = lineStart + lines[lineIndex].length;
|
|
152
|
-
if (cursorPos < lineEnd) {
|
|
153
|
-
onChange(value.slice(0, cursorPos) + value.slice(lineEnd));
|
|
154
|
-
}
|
|
155
|
-
else if (cursorPos < value.length) {
|
|
156
|
-
onChange(value.slice(0, cursorPos) + value.slice(cursorPos + 1));
|
|
157
|
-
}
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
// Ctrl+U - delete to start of line
|
|
161
|
-
if (key.ctrl && input === 'u') {
|
|
162
|
-
const lineStart = getLineStart(lineIndex);
|
|
163
|
-
if (cursorPos > lineStart) {
|
|
164
|
-
onChange(value.slice(0, lineStart) + value.slice(cursorPos));
|
|
165
|
-
setCursorPos(lineStart);
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
// Ctrl+W - delete word
|
|
170
|
-
if (key.ctrl && input === 'w') {
|
|
171
|
-
if (cursorPos > 0) {
|
|
172
|
-
let wordStart = cursorPos - 1;
|
|
173
|
-
while (wordStart > 0 && value[wordStart] === ' ')
|
|
174
|
-
wordStart--;
|
|
175
|
-
while (wordStart > 0 &&
|
|
176
|
-
value[wordStart - 1] !== ' ' &&
|
|
177
|
-
value[wordStart - 1] !== '\n')
|
|
178
|
-
wordStart--;
|
|
179
|
-
onChange(value.slice(0, wordStart) + value.slice(cursorPos));
|
|
180
|
-
setCursorPos(wordStart);
|
|
181
|
-
}
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
// Regular character input
|
|
185
|
-
if (input && !key.ctrl && !key.meta) {
|
|
186
|
-
const newValue = value.slice(0, cursorPos) + input + value.slice(cursorPos);
|
|
187
|
-
onChange(newValue);
|
|
188
|
-
setCursorPos(cursorPos + input.length);
|
|
189
|
-
}
|
|
190
|
-
}, { isActive: !isDisabled });
|
|
191
|
-
// Helper to pad line to full terminal width
|
|
192
|
-
const padLine = (content) => {
|
|
193
|
-
const visibleLength = content.length;
|
|
194
|
-
const padding = Math.max(0, terminalWidth - visibleLength);
|
|
195
|
-
return content + ' '.repeat(padding);
|
|
196
|
-
};
|
|
197
|
-
// Empty state
|
|
198
|
-
if (!value) {
|
|
199
|
-
const emptyContent = '❯ ' + (placeholder || '');
|
|
200
|
-
return (_jsx(Box, { width: terminalWidth, children: _jsxs(Text, { backgroundColor: "#222", children: [_jsx(Text, { color: "green", bold: true, children: '❯ ' }), _jsx(Text, { inverse: true, children: " " }), placeholder && _jsx(Text, { dimColor: true, children: placeholder }), _jsx(Text, { children: ' '.repeat(Math.max(0, terminalWidth - 3 - (placeholder?.length || 0))) })] }) }));
|
|
201
|
-
}
|
|
202
|
-
// Render lines
|
|
203
|
-
const lines = value.split('\n');
|
|
204
|
-
const { lineIndex: cursorLine, colIndex: cursorCol } = getLineInfo(cursorPos);
|
|
205
|
-
return (_jsx(Box, { flexDirection: "column", width: terminalWidth, children: lines.map((line, idx) => {
|
|
206
|
-
const prefix = idx === 0 ? '❯ ' : ' ';
|
|
207
|
-
const isCursorLine = idx === cursorLine;
|
|
208
|
-
const contentLength = prefix.length + line.length + 1; // +1 for cursor space
|
|
209
|
-
const padding = ' '.repeat(Math.max(0, terminalWidth - contentLength));
|
|
210
|
-
if (!isCursorLine) {
|
|
211
|
-
return (_jsx(Box, { width: terminalWidth, children: _jsxs(Text, { backgroundColor: "#222", children: [_jsx(Text, { color: "green", bold: idx === 0, children: prefix }), _jsx(Text, { children: line }), _jsx(Text, { children: ' '.repeat(Math.max(0, terminalWidth - prefix.length - line.length)) })] }) }, idx));
|
|
212
|
-
}
|
|
213
|
-
// Cursor line
|
|
214
|
-
const before = line.slice(0, cursorCol);
|
|
215
|
-
const atCursor = line.charAt(cursorCol) || ' ';
|
|
216
|
-
const after = line.slice(cursorCol + 1);
|
|
217
|
-
const cursorContentLength = prefix.length + before.length + 1 + after.length;
|
|
218
|
-
return (_jsx(Box, { width: terminalWidth, children: _jsxs(Text, { backgroundColor: "#222", children: [_jsx(Text, { color: "green", bold: idx === 0, children: prefix }), _jsx(Text, { children: before }), _jsx(Text, { inverse: true, children: atCursor }), _jsx(Text, { children: after }), _jsx(Text, { children: ' '.repeat(Math.max(0, terminalWidth - cursorContentLength)) })] }) }, idx));
|
|
219
|
-
}) }));
|
|
220
|
-
}
|
package/dist/discord/bot.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/discord/bot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAA+B,MAAM,YAAY,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgFzC,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,mBA+IhD"}
|
package/dist/discord/bot.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
|
-
import { Client, GatewayIntentBits, Partials } from 'discord.js';
|
|
3
|
-
import https from 'https';
|
|
4
|
-
import http from 'http'; // ADDED for http support
|
|
5
|
-
// Load environment variables
|
|
6
|
-
dotenv.config();
|
|
7
|
-
const token = process.env.DISCORD_BOT_TOKEN;
|
|
8
|
-
// User-based cooldown system for Discord interactions
|
|
9
|
-
const userCooldowns = new Map();
|
|
10
|
-
const RATE_LIMIT_ENABLED = process.env.DISCORD_RATE_LIMIT_ENABLED?.toLowerCase() !== 'false'; // default-on
|
|
11
|
-
let COOLDOWN_SECONDS = Number(process.env.DISCORD_RATE_LIMIT_SECONDS ?? 5);
|
|
12
|
-
if (Number.isNaN(COOLDOWN_SECONDS) || COOLDOWN_SECONDS < 0) {
|
|
13
|
-
console.error('DISCORD_RATE_LIMIT_SECONDS must be a non-negative number. Defaulting to 5 seconds.');
|
|
14
|
-
COOLDOWN_SECONDS = 5; // Default to a safe value
|
|
15
|
-
}
|
|
16
|
-
// Helper to download a file URL and convert it to base64
|
|
17
|
-
async function downloadFileAsBase64(fileUrl) {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const protocol = fileUrl.startsWith('https:') ? https : http; // Determine protocol
|
|
20
|
-
const MAX_BYTES = 5 * 1024 * 1024; // 5 MB hard cap
|
|
21
|
-
let downloadedBytes = 0;
|
|
22
|
-
const req = protocol.get(fileUrl, (res) => {
|
|
23
|
-
// Store the request object
|
|
24
|
-
if (res.statusCode && res.statusCode >= 400) {
|
|
25
|
-
// Clean up response stream
|
|
26
|
-
res.resume();
|
|
27
|
-
return reject(new Error(`Failed to download file: ${res.statusCode} ${res.statusMessage}`));
|
|
28
|
-
}
|
|
29
|
-
const chunks = [];
|
|
30
|
-
res.on('data', (chunk) => {
|
|
31
|
-
downloadedBytes += chunk.length;
|
|
32
|
-
if (downloadedBytes > MAX_BYTES) {
|
|
33
|
-
// Clean up response stream before destroying request
|
|
34
|
-
res.resume();
|
|
35
|
-
req.destroy(new Error('Attachment exceeds 5 MB limit')); // Destroy the request
|
|
36
|
-
// No explicit reject here, as 'error' on req should handle it or timeout will occur
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
chunks.push(chunk);
|
|
40
|
-
});
|
|
41
|
-
res.on('end', () => {
|
|
42
|
-
if (req.destroyed)
|
|
43
|
-
return; // If request was destroyed due to size limit, do nothing
|
|
44
|
-
const buffer = Buffer.concat(chunks);
|
|
45
|
-
const contentType = res.headers['content-type'] || 'application/octet-stream';
|
|
46
|
-
resolve({ base64: buffer.toString('base64'), mimeType: contentType });
|
|
47
|
-
});
|
|
48
|
-
// Handle errors on the response stream itself (e.g., premature close)
|
|
49
|
-
res.on('error', (err) => {
|
|
50
|
-
if (!req.destroyed) {
|
|
51
|
-
// Avoid double-rejection if req.destroy() already called this
|
|
52
|
-
reject(err);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
// Handle errors on the request object (e.g., socket hang up, DNS resolution error, or from req.destroy())
|
|
57
|
-
req.on('error', (err) => {
|
|
58
|
-
reject(err);
|
|
59
|
-
});
|
|
60
|
-
// Optional: Add a timeout for the request
|
|
61
|
-
req.setTimeout(30000, () => {
|
|
62
|
-
// 30 seconds timeout
|
|
63
|
-
if (!req.destroyed) {
|
|
64
|
-
req.destroy(new Error('File download timed out'));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
// Insert initDiscordBot to wire up a Discord client given pre-initialized services
|
|
70
|
-
export function startDiscordBot(agent) {
|
|
71
|
-
if (!token) {
|
|
72
|
-
throw new Error('DISCORD_BOT_TOKEN is not set');
|
|
73
|
-
}
|
|
74
|
-
const agentEventBus = agent.agentEventBus;
|
|
75
|
-
// Helper to get or create session for a Discord user
|
|
76
|
-
// Each Discord user gets their own persistent session
|
|
77
|
-
function getDiscordSessionId(userId) {
|
|
78
|
-
return `discord-${userId}`;
|
|
79
|
-
}
|
|
80
|
-
// Create Discord client
|
|
81
|
-
const client = new Client({
|
|
82
|
-
intents: [
|
|
83
|
-
GatewayIntentBits.Guilds,
|
|
84
|
-
GatewayIntentBits.GuildMessages,
|
|
85
|
-
GatewayIntentBits.MessageContent,
|
|
86
|
-
GatewayIntentBits.DirectMessages,
|
|
87
|
-
],
|
|
88
|
-
partials: [Partials.Channel],
|
|
89
|
-
});
|
|
90
|
-
client.once('ready', () => {
|
|
91
|
-
console.log(`Discord bot logged in as ${client.user?.tag || 'Unknown'}`);
|
|
92
|
-
});
|
|
93
|
-
client.on('messageCreate', async (message) => {
|
|
94
|
-
// Ignore bots
|
|
95
|
-
if (message.author.bot)
|
|
96
|
-
return;
|
|
97
|
-
if (RATE_LIMIT_ENABLED && COOLDOWN_SECONDS > 0) {
|
|
98
|
-
// Only apply cooldown if enabled and seconds > 0
|
|
99
|
-
const now = Date.now();
|
|
100
|
-
const cooldownEnd = userCooldowns.get(message.author.id) || 0;
|
|
101
|
-
if (now < cooldownEnd) {
|
|
102
|
-
const timeLeft = (cooldownEnd - now) / 1000;
|
|
103
|
-
try {
|
|
104
|
-
await message.reply(`Please wait ${timeLeft.toFixed(1)} more seconds before using this command again.`);
|
|
105
|
-
}
|
|
106
|
-
catch (replyError) {
|
|
107
|
-
console.error('Error sending cooldown message:', replyError);
|
|
108
|
-
}
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
let userText = message.content;
|
|
113
|
-
let imageDataInput;
|
|
114
|
-
// Handle attachments (images)
|
|
115
|
-
if (message.attachments.size > 0) {
|
|
116
|
-
const attachment = message.attachments.first();
|
|
117
|
-
if (attachment && attachment.url) {
|
|
118
|
-
const { base64, mimeType } = await downloadFileAsBase64(attachment.url);
|
|
119
|
-
imageDataInput = { image: base64, mimeType };
|
|
120
|
-
userText = message.content || '';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Only respond to !ask prefix or DMs
|
|
124
|
-
if (!message.guild || (userText && userText.startsWith('!ask '))) {
|
|
125
|
-
if (userText && userText.startsWith('!ask ')) {
|
|
126
|
-
userText = userText.substring(5).trim();
|
|
127
|
-
}
|
|
128
|
-
if (!userText)
|
|
129
|
-
return;
|
|
130
|
-
// Subscribe for toolCall events
|
|
131
|
-
const toolCallHandler = (payload) => {
|
|
132
|
-
message.channel
|
|
133
|
-
.send(`🔧 Calling tool **${payload.toolName}** with args: ${JSON.stringify(payload.args)}`)
|
|
134
|
-
.catch((error) => {
|
|
135
|
-
console.error(`Failed to send tool call notification for ${payload.toolName} to channel ${message.channel.id}:`, error);
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
agentEventBus.on('llm:tool-call', toolCallHandler);
|
|
139
|
-
try {
|
|
140
|
-
const sessionId = getDiscordSessionId(message.author.id);
|
|
141
|
-
await message.channel.sendTyping();
|
|
142
|
-
const responseText = await agent.run(userText, imageDataInput, undefined, sessionId);
|
|
143
|
-
// Handle Discord's 2000 character limit
|
|
144
|
-
const MAX_LENGTH = 1900; // Leave some buffer
|
|
145
|
-
if (responseText && responseText.length <= MAX_LENGTH) {
|
|
146
|
-
await message.reply(responseText);
|
|
147
|
-
}
|
|
148
|
-
else if (responseText) {
|
|
149
|
-
// Split into chunks and send multiple messages
|
|
150
|
-
let remaining = responseText;
|
|
151
|
-
let isFirst = true;
|
|
152
|
-
while (remaining && remaining.length > 0) {
|
|
153
|
-
const chunk = remaining.substring(0, MAX_LENGTH);
|
|
154
|
-
remaining = remaining.substring(MAX_LENGTH);
|
|
155
|
-
if (isFirst) {
|
|
156
|
-
await message.reply(chunk);
|
|
157
|
-
isFirst = false;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// For subsequent chunks, use message.channel.send to avoid a chain of replies
|
|
161
|
-
// and to ensure messages are sent in order.
|
|
162
|
-
// Adding a small delay can also help with ordering and rate limits.
|
|
163
|
-
await new Promise((resolve) => setTimeout(resolve, 250)); // 250ms delay
|
|
164
|
-
await message.channel.send(chunk);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
await message.reply('I received your message but could not generate a response.');
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
console.error('Error handling Discord message', error);
|
|
174
|
-
try {
|
|
175
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
176
|
-
await message.reply(`Error: ${errorMessage}`);
|
|
177
|
-
}
|
|
178
|
-
catch (replyError) {
|
|
179
|
-
console.error('Error sending error reply:', replyError);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
finally {
|
|
183
|
-
agentEventBus.off('llm:tool-call', toolCallHandler);
|
|
184
|
-
// Set cooldown for the user after processing
|
|
185
|
-
if (RATE_LIMIT_ENABLED && COOLDOWN_SECONDS > 0) {
|
|
186
|
-
userCooldowns.set(message.author.id, Date.now() + COOLDOWN_SECONDS * 1000);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
client.login(token);
|
|
192
|
-
return client;
|
|
193
|
-
}
|
package/dist/telegram/bot.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Bot } from 'grammy';
|
|
3
|
-
import { DextoAgent } from '@dexto/core';
|
|
4
|
-
export declare function startTelegramBot(agent: DextoAgent): Bot<import("grammy").Context, import("grammy").Api<import("grammy").RawApi>>;
|
|
5
|
-
//# sourceMappingURL=bot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/telegram/bot.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAkB,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAU,MAAM,aAAa,CAAC;AAyCjD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,gFAyOjD"}
|