@dexto/tui 1.14.6 → 1.15.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/InkCLIRefactored.cjs +30 -24
- package/dist/InkCLIRefactored.d.ts.map +1 -1
- package/dist/InkCLIRefactored.js +30 -24
- package/dist/components/ApprovalPrompt.cjs +128 -40
- package/dist/components/ApprovalPrompt.d.ts +2 -0
- package/dist/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/ApprovalPrompt.js +128 -41
- package/dist/components/CustomInput.cjs +4 -3
- package/dist/components/CustomInput.d.ts.map +1 -1
- package/dist/components/CustomInput.js +4 -3
- package/dist/components/DeckArea.cjs +43 -0
- package/dist/components/DeckArea.d.ts +14 -0
- package/dist/components/DeckArea.d.ts.map +1 -0
- package/dist/components/DeckArea.js +19 -0
- package/dist/components/EditableMultiLineInput.cjs +9 -8
- package/dist/components/EditableMultiLineInput.d.ts.map +1 -1
- package/dist/components/EditableMultiLineInput.js +9 -8
- package/dist/components/ElicitationForm.cjs +78 -18
- package/dist/components/ElicitationForm.d.ts.map +1 -1
- package/dist/components/ElicitationForm.js +78 -18
- package/dist/components/ErrorBoundary.cjs +15 -5
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +15 -5
- package/dist/components/Footer.cjs +41 -86
- package/dist/components/Footer.d.ts +2 -2
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/Footer.js +44 -92
- package/dist/components/Footer.test.cjs +44 -0
- package/dist/components/Footer.test.js +44 -0
- package/dist/components/HistorySearchBar.cjs +6 -5
- package/dist/components/HistorySearchBar.d.ts.map +1 -1
- package/dist/components/HistorySearchBar.js +6 -5
- package/dist/components/MultiLineInput.cjs +6 -5
- package/dist/components/MultiLineInput.d.ts.map +1 -1
- package/dist/components/MultiLineInput.js +6 -5
- package/dist/components/ResourceAutocomplete.cjs +5 -4
- package/dist/components/ResourceAutocomplete.d.ts.map +1 -1
- package/dist/components/ResourceAutocomplete.js +5 -4
- package/dist/components/SignalGates.test.cjs +215 -0
- package/dist/components/SignalGates.test.d.ts +2 -0
- package/dist/components/SignalGates.test.d.ts.map +1 -0
- package/dist/components/SignalGates.test.js +217 -0
- package/dist/components/SlashCommandAutocomplete.cjs +4 -3
- package/dist/components/SlashCommandAutocomplete.d.ts.map +1 -1
- package/dist/components/SlashCommandAutocomplete.js +4 -3
- package/dist/components/StatusBar.cjs +13 -30
- package/dist/components/StatusBar.d.ts +1 -3
- package/dist/components/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar.js +13 -30
- package/dist/components/TextBufferInput.cjs +13 -12
- package/dist/components/TextBufferInput.d.ts.map +1 -1
- package/dist/components/TextBufferInput.js +13 -12
- package/dist/components/TodoPanel.cjs +23 -16
- package/dist/components/TodoPanel.d.ts.map +1 -1
- package/dist/components/TodoPanel.js +23 -16
- package/dist/components/base/BaseAutocomplete.cjs +7 -6
- package/dist/components/base/BaseAutocomplete.d.ts.map +1 -1
- package/dist/components/base/BaseAutocomplete.js +7 -6
- package/dist/components/base/BaseSelector.cjs +5 -4
- package/dist/components/base/BaseSelector.d.ts.map +1 -1
- package/dist/components/base/BaseSelector.js +5 -4
- package/dist/components/chat/Footer.cjs +2 -1
- package/dist/components/chat/Footer.d.ts.map +1 -1
- package/dist/components/chat/Footer.js +2 -1
- package/dist/components/chat/Header.cjs +20 -16
- package/dist/components/chat/Header.d.ts.map +1 -1
- package/dist/components/chat/Header.js +20 -16
- package/dist/components/chat/MessageItem.cjs +47 -30
- package/dist/components/chat/MessageItem.d.ts.map +1 -1
- package/dist/components/chat/MessageItem.js +52 -29
- package/dist/components/chat/MessageList.cjs +3 -2
- package/dist/components/chat/MessageList.d.ts.map +1 -1
- package/dist/components/chat/MessageList.js +3 -2
- package/dist/components/chat/QueuedMessagesDisplay.cjs +17 -5
- package/dist/components/chat/QueuedMessagesDisplay.d.ts.map +1 -1
- package/dist/components/chat/QueuedMessagesDisplay.js +18 -6
- package/dist/components/chat/SignalMessage.cjs +116 -0
- package/dist/components/chat/SignalMessage.d.ts +18 -0
- package/dist/components/chat/SignalMessage.d.ts.map +1 -0
- package/dist/components/chat/SignalMessage.js +96 -0
- package/dist/components/chat/SignalMessage.test.cjs +112 -0
- package/dist/components/chat/SignalMessage.test.d.ts +2 -0
- package/dist/components/chat/SignalMessage.test.d.ts.map +1 -0
- package/dist/components/chat/SignalMessage.test.js +116 -0
- package/dist/components/chat/ToolIcon.cjs +6 -5
- package/dist/components/chat/ToolIcon.d.ts.map +1 -1
- package/dist/components/chat/ToolIcon.js +6 -5
- package/dist/components/chat/styled-boxes/ConfigBox.cjs +8 -7
- package/dist/components/chat/styled-boxes/ConfigBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/ConfigBox.js +8 -7
- package/dist/components/chat/styled-boxes/HelpBox.cjs +4 -3
- package/dist/components/chat/styled-boxes/HelpBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/HelpBox.js +4 -3
- package/dist/components/chat/styled-boxes/LogConfigBox.cjs +11 -3
- package/dist/components/chat/styled-boxes/LogConfigBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/LogConfigBox.js +11 -3
- package/dist/components/chat/styled-boxes/SessionHistoryBox.cjs +8 -7
- package/dist/components/chat/styled-boxes/SessionHistoryBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/SessionHistoryBox.js +8 -7
- package/dist/components/chat/styled-boxes/SessionListBox.cjs +19 -11
- package/dist/components/chat/styled-boxes/SessionListBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/SessionListBox.js +19 -11
- package/dist/components/chat/styled-boxes/ShortcutsBox.cjs +4 -3
- package/dist/components/chat/styled-boxes/ShortcutsBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/ShortcutsBox.js +4 -3
- package/dist/components/chat/styled-boxes/StatsBox.cjs +13 -5
- package/dist/components/chat/styled-boxes/StatsBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/StatsBox.js +13 -5
- package/dist/components/chat/styled-boxes/StyledBox.cjs +7 -6
- package/dist/components/chat/styled-boxes/StyledBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/StyledBox.js +7 -6
- package/dist/components/chat/styled-boxes/SyspromptBox.cjs +2 -1
- package/dist/components/chat/styled-boxes/SyspromptBox.d.ts.map +1 -1
- package/dist/components/chat/styled-boxes/SyspromptBox.js +2 -1
- package/dist/components/modes/AlternateBufferCLI.cjs +53 -43
- package/dist/components/modes/AlternateBufferCLI.d.ts.map +1 -1
- package/dist/components/modes/AlternateBufferCLI.js +53 -43
- package/dist/components/modes/StaticCLI.cjs +53 -42
- package/dist/components/modes/StaticCLI.d.ts.map +1 -1
- package/dist/components/modes/StaticCLI.js +53 -42
- package/dist/components/overlays/ApiKeyInput.cjs +12 -11
- package/dist/components/overlays/ApiKeyInput.d.ts.map +1 -1
- package/dist/components/overlays/ApiKeyInput.js +12 -11
- package/dist/components/overlays/ChatGPTUsageCapOverlay.cjs +7 -6
- package/dist/components/overlays/ChatGPTUsageCapOverlay.d.ts.map +1 -1
- package/dist/components/overlays/ChatGPTUsageCapOverlay.js +7 -6
- package/dist/components/overlays/CommandOutputOverlay.cjs +2 -1
- package/dist/components/overlays/CommandOutputOverlay.d.ts.map +1 -1
- package/dist/components/overlays/CommandOutputOverlay.js +2 -1
- package/dist/components/overlays/ConnectOverlay.cjs +10 -9
- package/dist/components/overlays/ConnectOverlay.d.ts.map +1 -1
- package/dist/components/overlays/ConnectOverlay.js +10 -9
- package/dist/components/overlays/ContextStatsOverlay.cjs +48 -37
- package/dist/components/overlays/ContextStatsOverlay.d.ts.map +1 -1
- package/dist/components/overlays/ContextStatsOverlay.js +48 -37
- package/dist/components/overlays/CustomModelWizard.cjs +5 -4
- package/dist/components/overlays/CustomModelWizard.d.ts.map +1 -1
- package/dist/components/overlays/CustomModelWizard.js +5 -4
- package/dist/components/overlays/ExportWizard.cjs +28 -27
- package/dist/components/overlays/ExportWizard.d.ts.map +1 -1
- package/dist/components/overlays/ExportWizard.js +28 -27
- package/dist/components/overlays/InsufficientCreditsOverlay.cjs +25 -9
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts +2 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts.map +1 -1
- package/dist/components/overlays/InsufficientCreditsOverlay.js +25 -9
- package/dist/components/overlays/LogLevelSelector.cjs +6 -5
- package/dist/components/overlays/LogLevelSelector.d.ts.map +1 -1
- package/dist/components/overlays/LogLevelSelector.js +6 -5
- package/dist/components/overlays/LoginOverlay.cjs +31 -66
- package/dist/components/overlays/LoginOverlay.d.ts +1 -3
- package/dist/components/overlays/LoginOverlay.d.ts.map +1 -1
- package/dist/components/overlays/LoginOverlay.js +32 -71
- package/dist/components/overlays/LogoutOverlay.cjs +16 -24
- package/dist/components/overlays/LogoutOverlay.d.ts +1 -0
- package/dist/components/overlays/LogoutOverlay.d.ts.map +1 -1
- package/dist/components/overlays/LogoutOverlay.js +18 -38
- package/dist/components/overlays/MarketplaceAddPrompt.cjs +12 -11
- package/dist/components/overlays/MarketplaceAddPrompt.d.ts.map +1 -1
- package/dist/components/overlays/MarketplaceAddPrompt.js +12 -11
- package/dist/components/overlays/MarketplaceBrowser.cjs +27 -26
- package/dist/components/overlays/MarketplaceBrowser.d.ts.map +1 -1
- package/dist/components/overlays/MarketplaceBrowser.js +27 -26
- package/dist/components/overlays/McpAddChoice.cjs +4 -3
- package/dist/components/overlays/McpAddChoice.d.ts.map +1 -1
- package/dist/components/overlays/McpAddChoice.js +4 -3
- package/dist/components/overlays/McpAddSelector.cjs +4 -3
- package/dist/components/overlays/McpAddSelector.d.ts.map +1 -1
- package/dist/components/overlays/McpAddSelector.js +4 -3
- package/dist/components/overlays/McpCustomTypeSelector.cjs +4 -3
- package/dist/components/overlays/McpCustomTypeSelector.d.ts.map +1 -1
- package/dist/components/overlays/McpCustomTypeSelector.js +4 -3
- package/dist/components/overlays/McpCustomWizard.cjs +9 -8
- package/dist/components/overlays/McpCustomWizard.d.ts.map +1 -1
- package/dist/components/overlays/McpCustomWizard.js +9 -8
- package/dist/components/overlays/McpRemoveSelector.cjs +5 -4
- package/dist/components/overlays/McpRemoveSelector.d.ts.map +1 -1
- package/dist/components/overlays/McpRemoveSelector.js +5 -4
- package/dist/components/overlays/McpSelector.cjs +4 -3
- package/dist/components/overlays/McpSelector.d.ts.map +1 -1
- package/dist/components/overlays/McpSelector.js +4 -3
- package/dist/components/overlays/McpServerActions.cjs +7 -6
- package/dist/components/overlays/McpServerActions.d.ts.map +1 -1
- package/dist/components/overlays/McpServerActions.js +7 -6
- package/dist/components/overlays/McpServerList.cjs +6 -5
- package/dist/components/overlays/McpServerList.d.ts.map +1 -1
- package/dist/components/overlays/McpServerList.js +6 -5
- package/dist/components/overlays/ModelSelectorRefactored.cjs +32 -17
- package/dist/components/overlays/ModelSelectorRefactored.d.ts.map +1 -1
- package/dist/components/overlays/ModelSelectorRefactored.js +32 -17
- package/dist/components/overlays/PermissionsSelector.cjs +6 -5
- package/dist/components/overlays/PermissionsSelector.d.ts.map +1 -1
- package/dist/components/overlays/PermissionsSelector.js +6 -5
- package/dist/components/overlays/PluginActions.cjs +7 -6
- package/dist/components/overlays/PluginActions.d.ts.map +1 -1
- package/dist/components/overlays/PluginActions.js +7 -6
- package/dist/components/overlays/PluginList.cjs +12 -11
- package/dist/components/overlays/PluginList.d.ts.map +1 -1
- package/dist/components/overlays/PluginList.js +12 -11
- package/dist/components/overlays/PluginManager.cjs +13 -5
- package/dist/components/overlays/PluginManager.d.ts.map +1 -1
- package/dist/components/overlays/PluginManager.js +13 -5
- package/dist/components/overlays/PromptAddChoice.cjs +5 -4
- package/dist/components/overlays/PromptAddChoice.d.ts.map +1 -1
- package/dist/components/overlays/PromptAddChoice.js +5 -4
- package/dist/components/overlays/PromptAddWizard.cjs +10 -9
- package/dist/components/overlays/PromptAddWizard.d.ts.map +1 -1
- package/dist/components/overlays/PromptAddWizard.js +10 -9
- package/dist/components/overlays/PromptDeleteSelector.cjs +6 -5
- package/dist/components/overlays/PromptDeleteSelector.d.ts.map +1 -1
- package/dist/components/overlays/PromptDeleteSelector.js +6 -5
- package/dist/components/overlays/PromptList.cjs +10 -9
- package/dist/components/overlays/PromptList.d.ts.map +1 -1
- package/dist/components/overlays/PromptList.js +10 -9
- package/dist/components/overlays/ReasoningOverlay.cjs +30 -23
- package/dist/components/overlays/ReasoningOverlay.d.ts.map +1 -1
- package/dist/components/overlays/ReasoningOverlay.js +30 -23
- package/dist/components/overlays/SearchOverlay.cjs +15 -14
- package/dist/components/overlays/SearchOverlay.d.ts.map +1 -1
- package/dist/components/overlays/SearchOverlay.js +15 -14
- package/dist/components/overlays/SessionRenameOverlay.cjs +9 -8
- package/dist/components/overlays/SessionRenameOverlay.d.ts.map +1 -1
- package/dist/components/overlays/SessionRenameOverlay.js +9 -8
- package/dist/components/overlays/SessionSelectorRefactored.cjs +4 -3
- package/dist/components/overlays/SessionSelectorRefactored.d.ts.map +1 -1
- package/dist/components/overlays/SessionSelectorRefactored.js +4 -3
- package/dist/components/overlays/SessionSubcommandSelector.cjs +4 -3
- package/dist/components/overlays/SessionSubcommandSelector.d.ts.map +1 -1
- package/dist/components/overlays/SessionSubcommandSelector.js +4 -3
- package/dist/components/overlays/SoundsSelector.cjs +15 -7
- package/dist/components/overlays/SoundsSelector.d.ts.map +1 -1
- package/dist/components/overlays/SoundsSelector.js +15 -7
- package/dist/components/overlays/StreamSelector.cjs +5 -4
- package/dist/components/overlays/StreamSelector.d.ts.map +1 -1
- package/dist/components/overlays/StreamSelector.js +5 -4
- package/dist/components/overlays/ToolBrowser.cjs +73 -56
- package/dist/components/overlays/ToolBrowser.d.ts.map +1 -1
- package/dist/components/overlays/ToolBrowser.js +73 -56
- package/dist/components/overlays/custom-model-wizard/LocalModelWizard.cjs +103 -69
- package/dist/components/overlays/custom-model-wizard/LocalModelWizard.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/LocalModelWizard.js +103 -69
- package/dist/components/overlays/custom-model-wizard/provider-config.cjs +4 -4
- package/dist/components/overlays/custom-model-wizard/provider-config.js +4 -4
- package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.cjs +3 -2
- package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/shared/ApiKeyStep.js +3 -2
- package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.cjs +5 -4
- package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/shared/ProviderSelector.js +5 -4
- package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.cjs +4 -3
- package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/shared/SetupInfoBanner.js +4 -3
- package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.cjs +7 -6
- package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/shared/WizardStepInput.js +7 -6
- package/dist/components/renderers/DiffRenderer.cjs +5 -4
- package/dist/components/renderers/DiffRenderer.d.ts.map +1 -1
- package/dist/components/renderers/DiffRenderer.js +5 -4
- package/dist/components/renderers/FilePreviewRenderer.cjs +23 -13
- package/dist/components/renderers/FilePreviewRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FilePreviewRenderer.js +23 -13
- package/dist/components/renderers/FileRenderer.cjs +9 -8
- package/dist/components/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FileRenderer.js +9 -8
- package/dist/components/renderers/GenericRenderer.cjs +5 -4
- package/dist/components/renderers/GenericRenderer.d.ts.map +1 -1
- package/dist/components/renderers/GenericRenderer.js +5 -4
- package/dist/components/renderers/SearchRenderer.cjs +4 -3
- package/dist/components/renderers/SearchRenderer.d.ts.map +1 -1
- package/dist/components/renderers/SearchRenderer.js +4 -3
- package/dist/components/renderers/ShellRenderer.cjs +6 -5
- package/dist/components/renderers/ShellRenderer.d.ts.map +1 -1
- package/dist/components/renderers/ShellRenderer.js +6 -5
- package/dist/components/renderers/SignalDiff.cjs +139 -0
- package/dist/components/renderers/SignalDiff.d.ts +21 -0
- package/dist/components/renderers/SignalDiff.d.ts.map +1 -0
- package/dist/components/renderers/SignalDiff.js +106 -0
- package/dist/components/renderers/SignalDiff.test.cjs +78 -0
- package/dist/components/renderers/SignalDiff.test.d.ts +2 -0
- package/dist/components/renderers/SignalDiff.test.d.ts.map +1 -0
- package/dist/components/renderers/SignalDiff.test.js +77 -0
- package/dist/components/renderers/diff-shared.cjs +13 -7
- package/dist/components/renderers/diff-shared.d.ts +5 -0
- package/dist/components/renderers/diff-shared.d.ts.map +1 -1
- package/dist/components/renderers/diff-shared.js +12 -7
- package/dist/components/shared/FocusOverlayFrame.cjs +3 -2
- package/dist/components/shared/FocusOverlayFrame.d.ts.map +1 -1
- package/dist/components/shared/FocusOverlayFrame.js +3 -2
- package/dist/components/shared/HintBar.cjs +2 -1
- package/dist/components/shared/HintBar.d.ts.map +1 -1
- package/dist/components/shared/HintBar.js +2 -1
- package/dist/components/shared/MarkdownText.cjs +36 -53
- package/dist/components/shared/MarkdownText.d.ts +2 -0
- package/dist/components/shared/MarkdownText.d.ts.map +1 -1
- package/dist/components/shared/MarkdownText.js +36 -54
- package/dist/components/shared/VirtualizedList.cjs +2 -1
- package/dist/components/shared/VirtualizedList.d.ts.map +1 -1
- package/dist/components/shared/VirtualizedList.js +2 -1
- package/dist/containers/OverlayContainer.cjs +32 -44
- package/dist/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/containers/OverlayContainer.js +32 -44
- package/dist/contexts/KeypressContext.cjs +7 -1
- package/dist/contexts/KeypressContext.d.ts.map +1 -1
- package/dist/contexts/KeypressContext.js +7 -1
- package/dist/contexts/KeypressContext.test.cjs +82 -0
- package/dist/contexts/KeypressContext.test.d.ts +2 -0
- package/dist/contexts/KeypressContext.test.d.ts.map +1 -0
- package/dist/contexts/KeypressContext.test.js +81 -0
- package/dist/hooks/useAgentEvents.cjs +1 -74
- package/dist/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/hooks/useAgentEvents.js +1 -74
- package/dist/hooks/useCLIState.cjs +0 -3
- package/dist/hooks/useCLIState.d.ts.map +1 -1
- package/dist/hooks/useCLIState.js +0 -3
- package/dist/hooks/useContextStats.cjs +91 -0
- package/dist/hooks/useContextStats.d.ts +13 -0
- package/dist/hooks/useContextStats.d.ts.map +1 -0
- package/dist/hooks/useContextStats.js +67 -0
- package/dist/hooks/useDeckState.cjs +140 -0
- package/dist/hooks/useDeckState.d.ts +20 -0
- package/dist/hooks/useDeckState.d.ts.map +1 -0
- package/dist/hooks/useDeckState.js +123 -0
- package/dist/hooks/useDextoCredits.cjs +81 -0
- package/dist/hooks/useDextoCredits.d.ts +14 -0
- package/dist/hooks/useDextoCredits.d.ts.map +1 -0
- package/dist/hooks/useDextoCredits.js +56 -0
- package/dist/hooks/useDextoCredits.test.cjs +73 -0
- package/dist/hooks/useDextoCredits.test.d.ts +2 -0
- package/dist/hooks/useDextoCredits.test.d.ts.map +1 -0
- package/dist/hooks/useDextoCredits.test.js +72 -0
- package/dist/hooks/useElapsedTime.cjs +13 -24
- package/dist/hooks/useElapsedTime.d.ts +3 -1
- package/dist/hooks/useElapsedTime.d.ts.map +1 -1
- package/dist/hooks/useElapsedTime.js +13 -24
- package/dist/hooks/useElapsedTime.test.cjs +35 -0
- package/dist/hooks/useElapsedTime.test.d.ts +2 -0
- package/dist/hooks/useElapsedTime.test.d.ts.map +1 -0
- package/dist/hooks/useElapsedTime.test.js +34 -0
- package/dist/hooks/useGitDirtyFiles.cjs +59 -0
- package/dist/hooks/useGitDirtyFiles.d.ts +5 -0
- package/dist/hooks/useGitDirtyFiles.d.ts.map +1 -0
- package/dist/hooks/useGitDirtyFiles.js +34 -0
- package/dist/hooks/useGitDirtyFiles.test.cjs +9 -0
- package/dist/hooks/useGitDirtyFiles.test.d.ts +2 -0
- package/dist/hooks/useGitDirtyFiles.test.d.ts.map +1 -0
- package/dist/hooks/useGitDirtyFiles.test.js +8 -0
- package/dist/hooks/useHeldValue.cjs +33 -0
- package/dist/hooks/useHeldValue.d.ts +3 -0
- package/dist/hooks/useHeldValue.d.ts.map +1 -0
- package/dist/hooks/useHeldValue.js +9 -0
- package/dist/hooks/useHeldValue.test.cjs +31 -0
- package/dist/hooks/useHeldValue.test.d.ts +2 -0
- package/dist/hooks/useHeldValue.test.d.ts.map +1 -0
- package/dist/hooks/useHeldValue.test.js +30 -0
- package/dist/hooks/useInputOrchestrator.cjs +22 -30
- package/dist/hooks/useInputOrchestrator.d.ts +2 -0
- package/dist/hooks/useInputOrchestrator.d.ts.map +1 -1
- package/dist/hooks/useInputOrchestrator.js +21 -30
- package/dist/hooks/useInputOrchestrator.test.cjs +24 -0
- package/dist/hooks/useInputOrchestrator.test.d.ts +2 -0
- package/dist/hooks/useInputOrchestrator.test.d.ts.map +1 -0
- package/dist/hooks/useInputOrchestrator.test.js +23 -0
- package/dist/host/index.cjs +22 -49
- package/dist/host/index.d.ts +18 -72
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +18 -42
- package/dist/host/index.test.cjs +21 -35
- package/dist/host/index.test.js +22 -40
- package/dist/index.d.cts +13 -52
- package/dist/interactive-commands/command-parser.cjs +13 -21
- package/dist/interactive-commands/command-parser.d.ts.map +1 -1
- package/dist/interactive-commands/command-parser.js +13 -11
- package/dist/interactive-commands/general-commands.cjs +8 -7
- package/dist/interactive-commands/general-commands.d.ts.map +1 -1
- package/dist/interactive-commands/general-commands.js +8 -7
- package/dist/services/processStream.cjs +33 -21
- package/dist/services/processStream.d.ts.map +1 -1
- package/dist/services/processStream.js +34 -22
- package/dist/services/processStream.test.cjs +52 -4
- package/dist/services/processStream.test.js +52 -4
- package/dist/signal/background.cjs +154 -0
- package/dist/signal/background.d.ts +43 -0
- package/dist/signal/background.d.ts.map +1 -0
- package/dist/signal/background.js +124 -0
- package/dist/signal/background.test.cjs +186 -0
- package/dist/signal/background.test.d.ts +2 -0
- package/dist/signal/background.test.d.ts.map +1 -0
- package/dist/signal/background.test.js +192 -0
- package/dist/signal/caps.cjs +100 -0
- package/dist/signal/caps.d.ts +23 -0
- package/dist/signal/caps.d.ts.map +1 -0
- package/dist/signal/caps.js +73 -0
- package/dist/signal/caps.test.cjs +56 -0
- package/dist/signal/caps.test.d.ts +2 -0
- package/dist/signal/caps.test.d.ts.map +1 -0
- package/dist/signal/caps.test.js +55 -0
- package/dist/signal/components.cjs +257 -0
- package/dist/signal/components.d.ts +120 -0
- package/dist/signal/components.d.ts.map +1 -0
- package/dist/signal/components.js +226 -0
- package/dist/signal/components.test.cjs +156 -0
- package/dist/signal/components.test.d.ts +2 -0
- package/dist/signal/components.test.d.ts.map +1 -0
- package/dist/signal/components.test.js +133 -0
- package/dist/signal/cut.cjs +103 -0
- package/dist/signal/cut.d.ts +11 -0
- package/dist/signal/cut.d.ts.map +1 -0
- package/dist/signal/cut.js +77 -0
- package/dist/signal/cut.test.cjs +20 -0
- package/dist/signal/cut.test.d.ts +2 -0
- package/dist/signal/cut.test.d.ts.map +1 -0
- package/dist/signal/cut.test.js +19 -0
- package/dist/signal/deck-layout.cjs +57 -0
- package/dist/signal/deck-layout.d.ts +29 -0
- package/dist/signal/deck-layout.d.ts.map +1 -0
- package/dist/signal/deck-layout.js +30 -0
- package/dist/signal/deck-parts.cjs +243 -0
- package/dist/signal/deck-parts.d.ts +55 -0
- package/dist/signal/deck-parts.d.ts.map +1 -0
- package/dist/signal/deck-parts.js +205 -0
- package/dist/signal/deck.test.cjs +311 -0
- package/dist/signal/deck.test.d.ts +2 -0
- package/dist/signal/deck.test.d.ts.map +1 -0
- package/dist/signal/deck.test.js +288 -0
- package/dist/signal/glyphs.cjs +195 -0
- package/dist/signal/glyphs.d.ts +8 -0
- package/dist/signal/glyphs.d.ts.map +1 -0
- package/dist/signal/glyphs.js +171 -0
- package/dist/signal/glyphs.test.cjs +17 -0
- package/dist/signal/glyphs.test.d.ts +2 -0
- package/dist/signal/glyphs.test.d.ts.map +1 -0
- package/dist/signal/glyphs.test.js +16 -0
- package/dist/signal/harness.cjs +103 -0
- package/dist/signal/harness.d.ts +70 -0
- package/dist/signal/harness.d.ts.map +1 -0
- package/dist/signal/harness.js +67 -0
- package/dist/signal/harness.test.cjs +84 -0
- package/dist/signal/harness.test.d.ts +2 -0
- package/dist/signal/harness.test.d.ts.map +1 -0
- package/dist/signal/harness.test.js +61 -0
- package/dist/signal/index.cjs +76 -0
- package/dist/signal/index.d.ts +8 -0
- package/dist/signal/index.d.ts.map +1 -0
- package/dist/signal/index.js +45 -0
- package/dist/signal/kit.snapshot.test.cjs +56 -0
- package/dist/signal/kit.snapshot.test.d.ts +2 -0
- package/dist/signal/kit.snapshot.test.d.ts.map +1 -0
- package/dist/signal/kit.snapshot.test.js +55 -0
- package/dist/signal/no-raw-colours.test.cjs +32 -0
- package/dist/signal/no-raw-colours.test.d.ts +2 -0
- package/dist/signal/no-raw-colours.test.d.ts.map +1 -0
- package/dist/signal/no-raw-colours.test.js +30 -0
- package/dist/signal/paint.cjs +76 -0
- package/dist/signal/paint.d.ts +15 -0
- package/dist/signal/paint.d.ts.map +1 -0
- package/dist/signal/paint.js +41 -0
- package/dist/signal/paint.test.cjs +98 -0
- package/dist/signal/paint.test.d.ts +2 -0
- package/dist/signal/paint.test.d.ts.map +1 -0
- package/dist/signal/paint.test.js +75 -0
- package/dist/signal/tone.cjs +109 -0
- package/dist/signal/tone.d.ts +17 -0
- package/dist/signal/tone.d.ts.map +1 -0
- package/dist/signal/tone.js +83 -0
- package/dist/signal/tone.test.cjs +70 -0
- package/dist/signal/tone.test.d.ts +2 -0
- package/dist/signal/tone.test.d.ts.map +1 -0
- package/dist/signal/tone.test.js +69 -0
- package/dist/signal/trace.cjs +142 -0
- package/dist/signal/trace.d.ts +41 -0
- package/dist/signal/trace.d.ts.map +1 -0
- package/dist/signal/trace.js +113 -0
- package/dist/signal/trace.test.cjs +50 -0
- package/dist/signal/trace.test.d.ts +2 -0
- package/dist/signal/trace.test.d.ts.map +1 -0
- package/dist/signal/trace.test.js +49 -0
- package/dist/signal/use-trace.cjs +73 -0
- package/dist/signal/use-trace.d.ts +5 -0
- package/dist/signal/use-trace.d.ts.map +1 -0
- package/dist/signal/use-trace.js +48 -0
- package/dist/signal/wordmark-art.generated.cjs +375 -0
- package/dist/signal/wordmark-art.generated.d.ts +3 -0
- package/dist/signal/wordmark-art.generated.d.ts.map +1 -0
- package/dist/signal/wordmark-art.generated.js +351 -0
- package/dist/signal/wordmark.cjs +60 -0
- package/dist/signal/wordmark.d.ts +23 -0
- package/dist/signal/wordmark.d.ts.map +1 -0
- package/dist/signal/wordmark.js +34 -0
- package/dist/signal/wordmark.test.cjs +71 -0
- package/dist/signal/wordmark.test.d.ts +2 -0
- package/dist/signal/wordmark.test.d.ts.map +1 -0
- package/dist/signal/wordmark.test.js +70 -0
- package/dist/state/initialState.cjs +0 -3
- package/dist/state/initialState.d.ts.map +1 -1
- package/dist/state/initialState.js +0 -3
- package/dist/state/types.d.ts +13 -7
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/approval-response.cjs +45 -0
- package/dist/utils/approval-response.d.ts +14 -0
- package/dist/utils/approval-response.d.ts.map +1 -0
- package/dist/utils/approval-response.js +21 -0
- package/dist/utils/approval-response.test.cjs +49 -0
- package/dist/utils/approval-response.test.d.ts +2 -0
- package/dist/utils/approval-response.test.d.ts.map +1 -0
- package/dist/utils/approval-response.test.js +55 -0
- package/dist/utils/approvalScope.cjs +12 -0
- package/dist/utils/approvalScope.d.ts.map +1 -1
- package/dist/utils/approvalScope.js +12 -0
- package/dist/utils/approvalScope.test.cjs +23 -0
- package/dist/utils/approvalScope.test.d.ts +2 -0
- package/dist/utils/approvalScope.test.d.ts.map +1 -0
- package/dist/utils/approvalScope.test.js +22 -0
- package/dist/utils/background-failure.cjs +51 -0
- package/dist/utils/background-failure.d.ts +12 -0
- package/dist/utils/background-failure.d.ts.map +1 -0
- package/dist/utils/background-failure.js +26 -0
- package/dist/utils/chatgpt-rate-limit.cjs +10 -0
- package/dist/utils/chatgpt-rate-limit.d.ts +9 -0
- package/dist/utils/chatgpt-rate-limit.d.ts.map +1 -1
- package/dist/utils/chatgpt-rate-limit.js +9 -0
- package/dist/utils/chatgpt-rate-limit.test.cjs +10 -0
- package/dist/utils/chatgpt-rate-limit.test.js +11 -0
- package/dist/utils/deck-state.cjs +107 -0
- package/dist/utils/deck-state.d.ts +79 -0
- package/dist/utils/deck-state.d.ts.map +1 -0
- package/dist/utils/deck-state.js +76 -0
- package/dist/utils/deck-state.test.cjs +208 -0
- package/dist/utils/deck-state.test.d.ts +2 -0
- package/dist/utils/deck-state.test.d.ts.map +1 -0
- package/dist/utils/deck-state.test.js +216 -0
- package/dist/utils/fault-block.cjs +37 -0
- package/dist/utils/fault-block.d.ts +13 -0
- package/dist/utils/fault-block.d.ts.map +1 -0
- package/dist/utils/fault-block.js +13 -0
- package/dist/utils/fault-block.test.cjs +23 -0
- package/dist/utils/fault-block.test.d.ts +2 -0
- package/dist/utils/fault-block.test.d.ts.map +1 -0
- package/dist/utils/fault-block.test.js +22 -0
- package/dist/utils/llm-provider-display.cjs +1 -1
- package/dist/utils/llm-provider-display.js +1 -1
- package/dist/utils/messageFormatting.cjs +26 -23
- package/dist/utils/messageFormatting.d.ts +5 -2
- package/dist/utils/messageFormatting.d.ts.map +1 -1
- package/dist/utils/messageFormatting.js +25 -21
- package/dist/utils/messageFormatting.test.cjs +34 -0
- package/dist/utils/messageFormatting.test.js +35 -1
- package/dist/utils/reasoning-variant.cjs +35 -0
- package/dist/utils/reasoning-variant.d.ts +13 -0
- package/dist/utils/reasoning-variant.d.ts.map +1 -0
- package/dist/utils/reasoning-variant.js +11 -0
- package/dist/utils/resize-reflow.cjs +119 -0
- package/dist/utils/resize-reflow.d.ts +18 -0
- package/dist/utils/resize-reflow.d.ts.map +1 -0
- package/dist/utils/resize-reflow.js +83 -0
- package/dist/utils/resize-reflow.test.cjs +100 -0
- package/dist/utils/resize-reflow.test.d.ts +2 -0
- package/dist/utils/resize-reflow.test.d.ts.map +1 -0
- package/dist/utils/resize-reflow.test.js +99 -0
- package/dist/utils/tool-step.cjs +183 -0
- package/dist/utils/tool-step.d.ts +28 -0
- package/dist/utils/tool-step.d.ts.map +1 -0
- package/dist/utils/tool-step.js +156 -0
- package/dist/utils/tool-step.test.cjs +263 -0
- package/dist/utils/tool-step.test.d.ts +2 -0
- package/dist/utils/tool-step.test.d.ts.map +1 -0
- package/dist/utils/tool-step.test.js +262 -0
- package/package.json +9 -5
- package/dist/components/BackgroundTasksPanel.cjs +0 -117
- package/dist/components/BackgroundTasksPanel.d.ts +0 -18
- package/dist/components/BackgroundTasksPanel.d.ts.map +0 -1
- package/dist/components/BackgroundTasksPanel.js +0 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStream.d.ts","sourceRoot":"","sources":["../../src/services/processStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAGvE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAc,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"processStream.d.ts","sourceRoot":"","sources":["../../src/services/processStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAGvE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAc,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AA2EvE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,2DAA2D;IAC3D,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC7D,oFAAoF;IACpF,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACpE,iFAAiF;IACjF,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACnE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,kEAAkE;IAClE,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3F,4CAA4C;IAC5C,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IAC9F,2CAA2C;IAC3C,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IAC/F,4DAA4D;IAC5D,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1E,uDAAuD;IACvD,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,2FAA2F;IAC3F,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2FAA2F;IAC3F,mBAAmB,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAC1C,wFAAwF;IACxF,oBAAoB,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C,yDAAyD;IACzD,QAAQ,EAAE,IAAI,CAAC,OAAO,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAC5D,8DAA8D;IAC9D,YAAY,CAAC,EAAE,OAAO,+BAA+B,EAAE,wBAAwB,CAAC;IAChF,kEAAkE;IAClE,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,mBAAmB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;CAC3F;AAgDD;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAC/B,QAAQ,EAAE,qBAAqB,CAAC,cAAc,CAAC,EAC/C,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,oBAAoB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAmwCf"}
|
|
@@ -2,7 +2,8 @@ import { createDebugLogger } from "../utils/debugLog.js";
|
|
|
2
2
|
import { ApprovalType as ApprovalTypeEnum, ApprovalStatus, LLMErrorCode } from "@dexto/core";
|
|
3
3
|
import { generateMessageId } from "../utils/idGenerator.js";
|
|
4
4
|
import { checkForSplit } from "../utils/streamSplitter.js";
|
|
5
|
-
import {
|
|
5
|
+
import { backgroundFailure } from "../utils/tool-step.js";
|
|
6
|
+
import { formatToolHeader } from "../utils/messageFormatting.js";
|
|
6
7
|
import { isAutoApprovableInEditMode } from "../utils/toolUtils.js";
|
|
7
8
|
import { captureAnalytics } from "../host/index.js";
|
|
8
9
|
import chalk from "chalk";
|
|
@@ -15,6 +16,11 @@ function buildErrorContent(error, prefix) {
|
|
|
15
16
|
}
|
|
16
17
|
return errorContent;
|
|
17
18
|
}
|
|
19
|
+
function isReportedError(error, reported) {
|
|
20
|
+
if (reported.has(error)) return true;
|
|
21
|
+
if (!(error instanceof Error)) return false;
|
|
22
|
+
return [...reported].some((each) => each instanceof Error && each.message === error.message);
|
|
23
|
+
}
|
|
18
24
|
function getErrorCode(error) {
|
|
19
25
|
if (typeof error !== "object" || error === null) {
|
|
20
26
|
return null;
|
|
@@ -48,9 +54,9 @@ function extractInsufficientCreditsBalance(error) {
|
|
|
48
54
|
}
|
|
49
55
|
function buildInsufficientCreditsContent(balance) {
|
|
50
56
|
if (balance === null) {
|
|
51
|
-
return "Out of Dexto
|
|
57
|
+
return "Out of Dexto credits.\nUse the billing prompt to top up and retry your request.";
|
|
52
58
|
}
|
|
53
|
-
return `Out of Dexto
|
|
59
|
+
return `Out of Dexto credits. Current balance: $${balance.toFixed(2)}.
|
|
54
60
|
Use the billing prompt to top up and retry your request.`;
|
|
55
61
|
}
|
|
56
62
|
function hasMeaningfulTokenUsageForAnalytics(tokenUsage, estimatedCost) {
|
|
@@ -73,6 +79,7 @@ async function processStream(iterator, setters, options) {
|
|
|
73
79
|
} = setters;
|
|
74
80
|
const useStreaming = options?.useStreaming ?? true;
|
|
75
81
|
const approvalIdToToolCallId = /* @__PURE__ */ new Map();
|
|
82
|
+
const reportedErrors = /* @__PURE__ */ new Set();
|
|
76
83
|
const state = {
|
|
77
84
|
messageId: null,
|
|
78
85
|
content: "",
|
|
@@ -444,9 +451,6 @@ async function processStream(iterator, setters, options) {
|
|
|
444
451
|
break;
|
|
445
452
|
}
|
|
446
453
|
case "llm:tool-call": {
|
|
447
|
-
if (shouldHideTool(event.toolName)) {
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
454
|
debug.log("TOOL-CALL: state check", {
|
|
451
455
|
toolName: event.toolName,
|
|
452
456
|
hasMessageId: !!state.messageId,
|
|
@@ -526,7 +530,7 @@ async function processStream(iterator, setters, options) {
|
|
|
526
530
|
}
|
|
527
531
|
}
|
|
528
532
|
const toolMessageId = event.callId ? `tool-${event.callId}` : generateMessageId("tool");
|
|
529
|
-
const { header: toolContent } = formatToolHeader({
|
|
533
|
+
const { header: toolContent, argsFormatted: toolArgs } = formatToolHeader({
|
|
530
534
|
toolName: event.toolName,
|
|
531
535
|
args: event.args || {},
|
|
532
536
|
...event.presentationSnapshot !== void 0 && {
|
|
@@ -544,6 +548,8 @@ ${chalk.dim(runningDescription)}`;
|
|
|
544
548
|
role: "tool",
|
|
545
549
|
content: finalToolContent,
|
|
546
550
|
timestamp: /* @__PURE__ */ new Date(),
|
|
551
|
+
toolName: event.toolName,
|
|
552
|
+
toolArgs,
|
|
547
553
|
toolStatus: "pending"
|
|
548
554
|
});
|
|
549
555
|
captureAnalytics("dexto_tool_called", {
|
|
@@ -554,9 +560,6 @@ ${chalk.dim(runningDescription)}`;
|
|
|
554
560
|
break;
|
|
555
561
|
}
|
|
556
562
|
case "llm:tool-result": {
|
|
557
|
-
if (shouldHideTool(event.toolName)) {
|
|
558
|
-
break;
|
|
559
|
-
}
|
|
560
563
|
const sanitized = event.sanitized;
|
|
561
564
|
const toolDisplayData = sanitized?.meta?.display;
|
|
562
565
|
const toolContent = sanitized?.content;
|
|
@@ -595,6 +598,8 @@ ${chalk.dim(runningDescription)}`;
|
|
|
595
598
|
toolResult: resultPreview,
|
|
596
599
|
toolStatus: "finished",
|
|
597
600
|
isError: !event.success,
|
|
601
|
+
...backgroundFailure(event.toolName, event.rawResult),
|
|
602
|
+
...!event.success && event.error !== void 0 && { toolFailureText: event.error },
|
|
598
603
|
...toolDisplayData && { toolDisplayData },
|
|
599
604
|
...toolContent && { toolContent }
|
|
600
605
|
});
|
|
@@ -621,6 +626,7 @@ ${chalk.dim(runningDescription)}`;
|
|
|
621
626
|
break;
|
|
622
627
|
}
|
|
623
628
|
case "llm:error": {
|
|
629
|
+
reportedErrors.add(event.error);
|
|
624
630
|
const insufficientCredits = getErrorCode(event.error) === LLMErrorCode.INSUFFICIENT_CREDITS;
|
|
625
631
|
const insufficientCreditsBalance = insufficientCredits ? extractInsufficientCreditsBalance(event.error) : null;
|
|
626
632
|
const errorContent = insufficientCredits ? buildInsufficientCreditsContent(insufficientCreditsBalance) : buildErrorContent(event.error, "Error: ");
|
|
@@ -630,7 +636,8 @@ ${chalk.dim(runningDescription)}`;
|
|
|
630
636
|
id: generateMessageId("error"),
|
|
631
637
|
role: "system",
|
|
632
638
|
content: errorContent,
|
|
633
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
639
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
640
|
+
systemKind: "fault"
|
|
634
641
|
}
|
|
635
642
|
]);
|
|
636
643
|
if (event.recoverable !== true) {
|
|
@@ -820,7 +827,8 @@ ${chalk.dim(runningDescription)}`;
|
|
|
820
827
|
finalizeMessage(`tool-${toolCallId}`, {
|
|
821
828
|
toolStatus: "finished",
|
|
822
829
|
toolResult: "Cancelled",
|
|
823
|
-
isError: true
|
|
830
|
+
isError: true,
|
|
831
|
+
toolOutcome: event.status === ApprovalStatus.DENIED ? "denied" : "cancelled"
|
|
824
832
|
});
|
|
825
833
|
}
|
|
826
834
|
}
|
|
@@ -912,6 +920,7 @@ ${chalk.dim(runningDescription)}`;
|
|
|
912
920
|
break;
|
|
913
921
|
}
|
|
914
922
|
}
|
|
923
|
+
setUi((prev) => prev.isCancelling ? { ...prev, isCancelling: false } : prev);
|
|
915
924
|
} catch (error) {
|
|
916
925
|
if (error instanceof Error && error.name === "AbortError") {
|
|
917
926
|
clearPending();
|
|
@@ -923,16 +932,19 @@ ${chalk.dim(runningDescription)}`;
|
|
|
923
932
|
}));
|
|
924
933
|
} else {
|
|
925
934
|
clearPending();
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
935
|
+
if (!isReportedError(error, reportedErrors)) {
|
|
936
|
+
const errorContent = buildErrorContent(error, "Stream error: ");
|
|
937
|
+
setMessages((prev) => [
|
|
938
|
+
...prev,
|
|
939
|
+
{
|
|
940
|
+
id: generateMessageId("error"),
|
|
941
|
+
role: "system",
|
|
942
|
+
content: errorContent,
|
|
943
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
944
|
+
systemKind: "fault"
|
|
945
|
+
}
|
|
946
|
+
]);
|
|
947
|
+
}
|
|
936
948
|
setUi((prev) => ({
|
|
937
949
|
...prev,
|
|
938
950
|
isProcessing: false,
|
|
@@ -73,9 +73,6 @@ function createSetters({
|
|
|
73
73
|
promptAddWizard: null,
|
|
74
74
|
autoApproveEdits: false,
|
|
75
75
|
todoExpanded: true,
|
|
76
|
-
backgroundTasksRunning: 0,
|
|
77
|
-
backgroundTasksExpanded: false,
|
|
78
|
-
backgroundTasks: [],
|
|
79
76
|
chatgptRateLimitStatus: null,
|
|
80
77
|
insufficientCredits: null,
|
|
81
78
|
planModeActive: false,
|
|
@@ -477,6 +474,40 @@ function createSetters({
|
|
|
477
474
|
(0, import_vitest.expect)(assistantMessages[1]?.content).toBe("Final");
|
|
478
475
|
(0, import_vitest.expect)(assistantMessages[1]?.reasoning).toBeUndefined();
|
|
479
476
|
});
|
|
477
|
+
(0, import_vitest.it)("reports a fatal error once when the stream rethrows it", async () => {
|
|
478
|
+
const { getMessages, setters } = createSetters();
|
|
479
|
+
const error = new Error("Provider error 500");
|
|
480
|
+
async function* failing() {
|
|
481
|
+
yield { name: "llm:error", sessionId: "test-session", error };
|
|
482
|
+
throw new Error("Provider error 500");
|
|
483
|
+
}
|
|
484
|
+
await (0, import_processStream.processStream)(failing(), setters, {
|
|
485
|
+
useStreaming: true,
|
|
486
|
+
autoApproveEditsRef: { current: false },
|
|
487
|
+
bypassPermissionsRef: { current: false },
|
|
488
|
+
eventBus: { emit: import_vitest.vi.fn() }
|
|
489
|
+
});
|
|
490
|
+
const faults = getMessages().filter((each) => each.content.includes("Provider error 500"));
|
|
491
|
+
(0, import_vitest.expect)(faults).toHaveLength(1);
|
|
492
|
+
(0, import_vitest.expect)(faults[0]?.systemKind).toBe("fault");
|
|
493
|
+
});
|
|
494
|
+
(0, import_vitest.it)("still reports a stream failure nothing has reported", async () => {
|
|
495
|
+
const { getMessages, setters } = createSetters();
|
|
496
|
+
async function* failing() {
|
|
497
|
+
yield* [];
|
|
498
|
+
throw new Error("socket closed");
|
|
499
|
+
}
|
|
500
|
+
await (0, import_processStream.processStream)(failing(), setters, {
|
|
501
|
+
useStreaming: true,
|
|
502
|
+
autoApproveEditsRef: { current: false },
|
|
503
|
+
bypassPermissionsRef: { current: false },
|
|
504
|
+
eventBus: { emit: import_vitest.vi.fn() }
|
|
505
|
+
});
|
|
506
|
+
(0, import_vitest.expect)(getMessages().at(-1)).toMatchObject({
|
|
507
|
+
content: "Stream error: socket closed",
|
|
508
|
+
systemKind: "fault"
|
|
509
|
+
});
|
|
510
|
+
});
|
|
480
511
|
(0, import_vitest.it)("shows the billing recovery overlay for insufficient credits", async () => {
|
|
481
512
|
const { getMessages, getUi, setters } = createSetters();
|
|
482
513
|
const error = Object.assign(new Error("Insufficient Dexto credits. Balance: $0.00"), {
|
|
@@ -504,7 +535,7 @@ function createSetters({
|
|
|
504
535
|
(0, import_vitest.expect)(ui.insufficientCredits).toEqual({ balanceUsd: 0 });
|
|
505
536
|
(0, import_vitest.expect)(ui.isProcessing).toBe(false);
|
|
506
537
|
const latestMessage = getMessages().at(-1);
|
|
507
|
-
(0, import_vitest.expect)(latestMessage?.content).toContain("Out of Dexto
|
|
538
|
+
(0, import_vitest.expect)(latestMessage?.content).toContain("Out of Dexto credits");
|
|
508
539
|
(0, import_vitest.expect)(latestMessage?.content).not.toContain("Error:");
|
|
509
540
|
});
|
|
510
541
|
(0, import_vitest.it)("captures analytics cost fields for priced llm responses", async () => {
|
|
@@ -559,3 +590,20 @@ function createSetters({
|
|
|
559
590
|
);
|
|
560
591
|
});
|
|
561
592
|
});
|
|
593
|
+
(0, import_vitest.describe)("processStream (stop)", () => {
|
|
594
|
+
(0, import_vitest.it)("clears the stop state when a cancelled run ends its stream", async () => {
|
|
595
|
+
const { setters, getUi } = createSetters();
|
|
596
|
+
setters.setUi((prev) => ({ ...prev, isProcessing: false, isCancelling: true }));
|
|
597
|
+
await (0, import_processStream.processStream)(
|
|
598
|
+
eventStream([{ name: "llm:thinking", sessionId: "test-session" }]),
|
|
599
|
+
setters,
|
|
600
|
+
{
|
|
601
|
+
useStreaming: true,
|
|
602
|
+
autoApproveEditsRef: { current: false },
|
|
603
|
+
bypassPermissionsRef: { current: false },
|
|
604
|
+
eventBus: { emit: import_vitest.vi.fn() }
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
(0, import_vitest.expect)(getUi().isCancelling).toBe(false);
|
|
608
|
+
});
|
|
609
|
+
});
|
|
@@ -72,9 +72,6 @@ function createSetters({
|
|
|
72
72
|
promptAddWizard: null,
|
|
73
73
|
autoApproveEdits: false,
|
|
74
74
|
todoExpanded: true,
|
|
75
|
-
backgroundTasksRunning: 0,
|
|
76
|
-
backgroundTasksExpanded: false,
|
|
77
|
-
backgroundTasks: [],
|
|
78
75
|
chatgptRateLimitStatus: null,
|
|
79
76
|
insufficientCredits: null,
|
|
80
77
|
planModeActive: false,
|
|
@@ -476,6 +473,40 @@ describe("processStream (reasoning)", () => {
|
|
|
476
473
|
expect(assistantMessages[1]?.content).toBe("Final");
|
|
477
474
|
expect(assistantMessages[1]?.reasoning).toBeUndefined();
|
|
478
475
|
});
|
|
476
|
+
it("reports a fatal error once when the stream rethrows it", async () => {
|
|
477
|
+
const { getMessages, setters } = createSetters();
|
|
478
|
+
const error = new Error("Provider error 500");
|
|
479
|
+
async function* failing() {
|
|
480
|
+
yield { name: "llm:error", sessionId: "test-session", error };
|
|
481
|
+
throw new Error("Provider error 500");
|
|
482
|
+
}
|
|
483
|
+
await processStream(failing(), setters, {
|
|
484
|
+
useStreaming: true,
|
|
485
|
+
autoApproveEditsRef: { current: false },
|
|
486
|
+
bypassPermissionsRef: { current: false },
|
|
487
|
+
eventBus: { emit: vi.fn() }
|
|
488
|
+
});
|
|
489
|
+
const faults = getMessages().filter((each) => each.content.includes("Provider error 500"));
|
|
490
|
+
expect(faults).toHaveLength(1);
|
|
491
|
+
expect(faults[0]?.systemKind).toBe("fault");
|
|
492
|
+
});
|
|
493
|
+
it("still reports a stream failure nothing has reported", async () => {
|
|
494
|
+
const { getMessages, setters } = createSetters();
|
|
495
|
+
async function* failing() {
|
|
496
|
+
yield* [];
|
|
497
|
+
throw new Error("socket closed");
|
|
498
|
+
}
|
|
499
|
+
await processStream(failing(), setters, {
|
|
500
|
+
useStreaming: true,
|
|
501
|
+
autoApproveEditsRef: { current: false },
|
|
502
|
+
bypassPermissionsRef: { current: false },
|
|
503
|
+
eventBus: { emit: vi.fn() }
|
|
504
|
+
});
|
|
505
|
+
expect(getMessages().at(-1)).toMatchObject({
|
|
506
|
+
content: "Stream error: socket closed",
|
|
507
|
+
systemKind: "fault"
|
|
508
|
+
});
|
|
509
|
+
});
|
|
479
510
|
it("shows the billing recovery overlay for insufficient credits", async () => {
|
|
480
511
|
const { getMessages, getUi, setters } = createSetters();
|
|
481
512
|
const error = Object.assign(new Error("Insufficient Dexto credits. Balance: $0.00"), {
|
|
@@ -503,7 +534,7 @@ describe("processStream (reasoning)", () => {
|
|
|
503
534
|
expect(ui.insufficientCredits).toEqual({ balanceUsd: 0 });
|
|
504
535
|
expect(ui.isProcessing).toBe(false);
|
|
505
536
|
const latestMessage = getMessages().at(-1);
|
|
506
|
-
expect(latestMessage?.content).toContain("Out of Dexto
|
|
537
|
+
expect(latestMessage?.content).toContain("Out of Dexto credits");
|
|
507
538
|
expect(latestMessage?.content).not.toContain("Error:");
|
|
508
539
|
});
|
|
509
540
|
it("captures analytics cost fields for priced llm responses", async () => {
|
|
@@ -558,3 +589,20 @@ describe("processStream (reasoning)", () => {
|
|
|
558
589
|
);
|
|
559
590
|
});
|
|
560
591
|
});
|
|
592
|
+
describe("processStream (stop)", () => {
|
|
593
|
+
it("clears the stop state when a cancelled run ends its stream", async () => {
|
|
594
|
+
const { setters, getUi } = createSetters();
|
|
595
|
+
setters.setUi((prev) => ({ ...prev, isProcessing: false, isCancelling: true }));
|
|
596
|
+
await processStream(
|
|
597
|
+
eventStream([{ name: "llm:thinking", sessionId: "test-session" }]),
|
|
598
|
+
setters,
|
|
599
|
+
{
|
|
600
|
+
useStreaming: true,
|
|
601
|
+
autoApproveEditsRef: { current: false },
|
|
602
|
+
bypassPermissionsRef: { current: false },
|
|
603
|
+
eventBus: { emit: vi.fn() }
|
|
604
|
+
}
|
|
605
|
+
);
|
|
606
|
+
expect(getUi().isCancelling).toBe(false);
|
|
607
|
+
});
|
|
608
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var background_exports = {};
|
|
20
|
+
__export(background_exports, {
|
|
21
|
+
BACKGROUND_QUERY: () => BACKGROUND_QUERY,
|
|
22
|
+
BACKGROUND_TIMEOUT_MS: () => BACKGROUND_TIMEOUT_MS,
|
|
23
|
+
createTerminalReplyFilter: () => createTerminalReplyFilter,
|
|
24
|
+
detectBackgroundTheme: () => detectBackgroundTheme,
|
|
25
|
+
parseBackgroundReply: () => parseBackgroundReply,
|
|
26
|
+
queryBackgroundTheme: () => queryBackgroundTheme,
|
|
27
|
+
shouldQueryBackground: () => shouldQueryBackground
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(background_exports);
|
|
30
|
+
var import_caps = require("./caps.js");
|
|
31
|
+
const BACKGROUND_QUERY = "\x1B]11;?\x07\x1B[c";
|
|
32
|
+
const BACKGROUND_TIMEOUT_MS = 250;
|
|
33
|
+
const OSC11_REPLY = /\x1b\]11;rgba?:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})/i;
|
|
34
|
+
const DA1_REPLY = /\x1b\[\?[\d;]*c/;
|
|
35
|
+
function channel(hex) {
|
|
36
|
+
return parseInt(hex, 16) / (16 ** hex.length - 1);
|
|
37
|
+
}
|
|
38
|
+
function parseBackgroundReply(data) {
|
|
39
|
+
const match = OSC11_REPLY.exec(data);
|
|
40
|
+
if (match === null) return null;
|
|
41
|
+
const [r, g, b] = [match[1], match[2], match[3]].map((hex) => channel(hex ?? ""));
|
|
42
|
+
if (r === void 0 || g === void 0 || b === void 0) return null;
|
|
43
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b >= 0.5 ? "light" : "dark";
|
|
44
|
+
}
|
|
45
|
+
function shouldQueryBackground(caps, stdinIsTTY) {
|
|
46
|
+
return caps.palette === "signal" && caps.color !== "none" && caps.tty && stdinIsTTY;
|
|
47
|
+
}
|
|
48
|
+
function queryBackgroundTheme(io, timeoutMs) {
|
|
49
|
+
const { stdin, stdout } = io;
|
|
50
|
+
const wasRaw = stdin.isRaw === true;
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
let received = "";
|
|
53
|
+
const finish = () => {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
stdin.removeListener("data", onData);
|
|
56
|
+
stdin.setRawMode?.(wasRaw);
|
|
57
|
+
stdin.pause();
|
|
58
|
+
const { keys, held } = stripReplies(received);
|
|
59
|
+
const rest = keys + held;
|
|
60
|
+
if (rest !== "") stdin.unshift(Buffer.from(rest, "latin1"));
|
|
61
|
+
resolve(parseBackgroundReply(received));
|
|
62
|
+
};
|
|
63
|
+
const onData = (chunk) => {
|
|
64
|
+
received += (typeof chunk === "string" ? Buffer.from(chunk) : chunk).toString("latin1");
|
|
65
|
+
if (DA1_REPLY.test(received)) finish();
|
|
66
|
+
};
|
|
67
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
68
|
+
stdin.setRawMode?.(true);
|
|
69
|
+
stdin.on("data", onData);
|
|
70
|
+
stdin.resume();
|
|
71
|
+
stdout.write(BACKGROUND_QUERY);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const MAX_REPLY_LENGTH = 64;
|
|
75
|
+
function scanOscReply(s, at) {
|
|
76
|
+
if (s.length < at + 3) return "none";
|
|
77
|
+
for (let k = 2; k < 5; k++) {
|
|
78
|
+
const ch = s[at + k];
|
|
79
|
+
if (ch === void 0) return "partial";
|
|
80
|
+
const ok = k === 2 ? ch === "1" : k === 3 ? ch === "0" || ch === "1" : ch === ";";
|
|
81
|
+
if (!ok) return "none";
|
|
82
|
+
}
|
|
83
|
+
for (let i = at + 5; i < s.length && i - at <= MAX_REPLY_LENGTH; i++) {
|
|
84
|
+
const ch = s[i] ?? "";
|
|
85
|
+
if (ch === "\x07") return i + 1;
|
|
86
|
+
if (ch === "\x1B") {
|
|
87
|
+
const next = s[i + 1];
|
|
88
|
+
if (next === void 0) return "partial";
|
|
89
|
+
return next === "\\" ? i + 2 : "none";
|
|
90
|
+
}
|
|
91
|
+
if (!/[0-9a-z:/]/i.test(ch)) return "none";
|
|
92
|
+
}
|
|
93
|
+
return s.length - at > MAX_REPLY_LENGTH ? "none" : "partial";
|
|
94
|
+
}
|
|
95
|
+
function scanDa1Reply(s, at) {
|
|
96
|
+
if (s[at + 2] !== "?") return "none";
|
|
97
|
+
for (let i = at + 3; i < s.length && i - at <= MAX_REPLY_LENGTH; i++) {
|
|
98
|
+
const ch = s[i] ?? "";
|
|
99
|
+
if (ch === "c") return i + 1;
|
|
100
|
+
if (!/[\d;]/.test(ch)) return "none";
|
|
101
|
+
}
|
|
102
|
+
return s.length - at > MAX_REPLY_LENGTH ? "none" : "partial";
|
|
103
|
+
}
|
|
104
|
+
function scanReply(s, at) {
|
|
105
|
+
const kind = s[at + 1];
|
|
106
|
+
if (kind === "]") return scanOscReply(s, at);
|
|
107
|
+
if (kind === "[") return scanDa1Reply(s, at);
|
|
108
|
+
return "none";
|
|
109
|
+
}
|
|
110
|
+
function stripReplies(input) {
|
|
111
|
+
let keys = "";
|
|
112
|
+
let i = 0;
|
|
113
|
+
while (i < input.length) {
|
|
114
|
+
const esc = input.indexOf("\x1B", i);
|
|
115
|
+
if (esc === -1) {
|
|
116
|
+
keys += input.slice(i);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
keys += input.slice(i, esc);
|
|
120
|
+
const end = scanReply(input, esc);
|
|
121
|
+
if (end === "partial") return { keys, held: input.slice(esc) };
|
|
122
|
+
if (end === "none") {
|
|
123
|
+
keys += "\x1B";
|
|
124
|
+
i = esc + 1;
|
|
125
|
+
} else {
|
|
126
|
+
i = end;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { keys, held: "" };
|
|
130
|
+
}
|
|
131
|
+
function createTerminalReplyFilter() {
|
|
132
|
+
let held = "";
|
|
133
|
+
return (data) => {
|
|
134
|
+
const result = stripReplies(held + data);
|
|
135
|
+
held = result.held;
|
|
136
|
+
return result.keys;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async function detectBackgroundTheme(io) {
|
|
140
|
+
const caps = (0, import_caps.getCaps)();
|
|
141
|
+
if (!shouldQueryBackground(caps, io.stdin.isTTY === true)) return;
|
|
142
|
+
const theme = await queryBackgroundTheme(io, BACKGROUND_TIMEOUT_MS);
|
|
143
|
+
if (theme !== null && theme !== caps.theme) (0, import_caps.setCaps)({ ...(0, import_caps.getCaps)(), theme });
|
|
144
|
+
}
|
|
145
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
146
|
+
0 && (module.exports = {
|
|
147
|
+
BACKGROUND_QUERY,
|
|
148
|
+
BACKGROUND_TIMEOUT_MS,
|
|
149
|
+
createTerminalReplyFilter,
|
|
150
|
+
detectBackgroundTheme,
|
|
151
|
+
parseBackgroundReply,
|
|
152
|
+
queryBackgroundTheme,
|
|
153
|
+
shouldQueryBackground
|
|
154
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asks the terminal for its background colour (OSC 11) so the Signal palette picks its dark or
|
|
3
|
+
* light set from what is actually on screen, not from COLORFGBG alone.
|
|
4
|
+
*
|
|
5
|
+
* The query is followed by DA1 (primary device attributes), which every terminal answers. That
|
|
6
|
+
* reply marks the end: a terminal that ignores OSC 11 costs one round trip, not the timeout.
|
|
7
|
+
* Runs once at start-up, before Ink takes stdin.
|
|
8
|
+
*/
|
|
9
|
+
import { type Caps, type ThemeName } from './caps.js';
|
|
10
|
+
export declare const BACKGROUND_QUERY = "\u001B]11;?\u0007\u001B[c";
|
|
11
|
+
/** How long to wait for a terminal that answers neither query (a pipe dressed as a TTY). */
|
|
12
|
+
export declare const BACKGROUND_TIMEOUT_MS = 250;
|
|
13
|
+
/** The theme for an OSC 11 reply found anywhere in `data`, or null when there is none. */
|
|
14
|
+
export declare function parseBackgroundReply(data: string): ThemeName | null;
|
|
15
|
+
/** Only the Signal palette reads the theme, and only a colour TTY can answer. */
|
|
16
|
+
export declare function shouldQueryBackground(caps: Caps, stdinIsTTY: boolean): boolean;
|
|
17
|
+
export interface TerminalIO {
|
|
18
|
+
stdin: NodeJS.ReadableStream & {
|
|
19
|
+
isTTY?: boolean;
|
|
20
|
+
isRaw?: boolean;
|
|
21
|
+
setRawMode?: (mode: boolean) => unknown;
|
|
22
|
+
};
|
|
23
|
+
stdout: {
|
|
24
|
+
write: (chunk: string) => boolean;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sends the query and resolves with the background's theme, or null when the terminal does not
|
|
29
|
+
* say. Everything read that is not a complete reply goes back onto stdin byte for byte: keys
|
|
30
|
+
* typed during start-up, a UTF-8 character cut off by the timeout, and the start of a reply cut
|
|
31
|
+
* off by it (the keypress filter drops the rest of that reply when it arrives). Leaves stdin
|
|
32
|
+
* paused and in the raw mode it found it in.
|
|
33
|
+
*/
|
|
34
|
+
export declare function queryBackgroundTheme(io: TerminalIO, timeoutMs: number): Promise<ThemeName | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Removes OSC 10/11 and DA1 replies from keyboard input, holding back the start of one that is
|
|
37
|
+
* split across chunks. Sits in front of the keypress parser so a reply that arrives after
|
|
38
|
+
* `queryBackgroundTheme` gave up never becomes prompt text. One filter per input stream.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createTerminalReplyFilter(): (data: string) => string;
|
|
41
|
+
/** Refines the process-wide caps' theme from the terminal's background, when it can tell. */
|
|
42
|
+
export declare function detectBackgroundTheme(io: TerminalIO): Promise<void>;
|
|
43
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../src/signal/background.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAoB,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAExE,eAAO,MAAM,gBAAgB,8BAAwB,CAAC;AAEtD,4FAA4F;AAC5F,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAYzC,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAMnE;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAE9E;AAED,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC,cAAc,GAAG;QAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;KAC3C,CAAC;IACF,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;KAAE,CAAC;CACjD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA0BjG;AA0ED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAOpE;AAED,6FAA6F;AAC7F,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { getCaps, setCaps } from "./caps.js";
|
|
2
|
+
const BACKGROUND_QUERY = "\x1B]11;?\x07\x1B[c";
|
|
3
|
+
const BACKGROUND_TIMEOUT_MS = 250;
|
|
4
|
+
const OSC11_REPLY = /\x1b\]11;rgba?:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})/i;
|
|
5
|
+
const DA1_REPLY = /\x1b\[\?[\d;]*c/;
|
|
6
|
+
function channel(hex) {
|
|
7
|
+
return parseInt(hex, 16) / (16 ** hex.length - 1);
|
|
8
|
+
}
|
|
9
|
+
function parseBackgroundReply(data) {
|
|
10
|
+
const match = OSC11_REPLY.exec(data);
|
|
11
|
+
if (match === null) return null;
|
|
12
|
+
const [r, g, b] = [match[1], match[2], match[3]].map((hex) => channel(hex ?? ""));
|
|
13
|
+
if (r === void 0 || g === void 0 || b === void 0) return null;
|
|
14
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b >= 0.5 ? "light" : "dark";
|
|
15
|
+
}
|
|
16
|
+
function shouldQueryBackground(caps, stdinIsTTY) {
|
|
17
|
+
return caps.palette === "signal" && caps.color !== "none" && caps.tty && stdinIsTTY;
|
|
18
|
+
}
|
|
19
|
+
function queryBackgroundTheme(io, timeoutMs) {
|
|
20
|
+
const { stdin, stdout } = io;
|
|
21
|
+
const wasRaw = stdin.isRaw === true;
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
let received = "";
|
|
24
|
+
const finish = () => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
stdin.removeListener("data", onData);
|
|
27
|
+
stdin.setRawMode?.(wasRaw);
|
|
28
|
+
stdin.pause();
|
|
29
|
+
const { keys, held } = stripReplies(received);
|
|
30
|
+
const rest = keys + held;
|
|
31
|
+
if (rest !== "") stdin.unshift(Buffer.from(rest, "latin1"));
|
|
32
|
+
resolve(parseBackgroundReply(received));
|
|
33
|
+
};
|
|
34
|
+
const onData = (chunk) => {
|
|
35
|
+
received += (typeof chunk === "string" ? Buffer.from(chunk) : chunk).toString("latin1");
|
|
36
|
+
if (DA1_REPLY.test(received)) finish();
|
|
37
|
+
};
|
|
38
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
39
|
+
stdin.setRawMode?.(true);
|
|
40
|
+
stdin.on("data", onData);
|
|
41
|
+
stdin.resume();
|
|
42
|
+
stdout.write(BACKGROUND_QUERY);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const MAX_REPLY_LENGTH = 64;
|
|
46
|
+
function scanOscReply(s, at) {
|
|
47
|
+
if (s.length < at + 3) return "none";
|
|
48
|
+
for (let k = 2; k < 5; k++) {
|
|
49
|
+
const ch = s[at + k];
|
|
50
|
+
if (ch === void 0) return "partial";
|
|
51
|
+
const ok = k === 2 ? ch === "1" : k === 3 ? ch === "0" || ch === "1" : ch === ";";
|
|
52
|
+
if (!ok) return "none";
|
|
53
|
+
}
|
|
54
|
+
for (let i = at + 5; i < s.length && i - at <= MAX_REPLY_LENGTH; i++) {
|
|
55
|
+
const ch = s[i] ?? "";
|
|
56
|
+
if (ch === "\x07") return i + 1;
|
|
57
|
+
if (ch === "\x1B") {
|
|
58
|
+
const next = s[i + 1];
|
|
59
|
+
if (next === void 0) return "partial";
|
|
60
|
+
return next === "\\" ? i + 2 : "none";
|
|
61
|
+
}
|
|
62
|
+
if (!/[0-9a-z:/]/i.test(ch)) return "none";
|
|
63
|
+
}
|
|
64
|
+
return s.length - at > MAX_REPLY_LENGTH ? "none" : "partial";
|
|
65
|
+
}
|
|
66
|
+
function scanDa1Reply(s, at) {
|
|
67
|
+
if (s[at + 2] !== "?") return "none";
|
|
68
|
+
for (let i = at + 3; i < s.length && i - at <= MAX_REPLY_LENGTH; i++) {
|
|
69
|
+
const ch = s[i] ?? "";
|
|
70
|
+
if (ch === "c") return i + 1;
|
|
71
|
+
if (!/[\d;]/.test(ch)) return "none";
|
|
72
|
+
}
|
|
73
|
+
return s.length - at > MAX_REPLY_LENGTH ? "none" : "partial";
|
|
74
|
+
}
|
|
75
|
+
function scanReply(s, at) {
|
|
76
|
+
const kind = s[at + 1];
|
|
77
|
+
if (kind === "]") return scanOscReply(s, at);
|
|
78
|
+
if (kind === "[") return scanDa1Reply(s, at);
|
|
79
|
+
return "none";
|
|
80
|
+
}
|
|
81
|
+
function stripReplies(input) {
|
|
82
|
+
let keys = "";
|
|
83
|
+
let i = 0;
|
|
84
|
+
while (i < input.length) {
|
|
85
|
+
const esc = input.indexOf("\x1B", i);
|
|
86
|
+
if (esc === -1) {
|
|
87
|
+
keys += input.slice(i);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
keys += input.slice(i, esc);
|
|
91
|
+
const end = scanReply(input, esc);
|
|
92
|
+
if (end === "partial") return { keys, held: input.slice(esc) };
|
|
93
|
+
if (end === "none") {
|
|
94
|
+
keys += "\x1B";
|
|
95
|
+
i = esc + 1;
|
|
96
|
+
} else {
|
|
97
|
+
i = end;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return { keys, held: "" };
|
|
101
|
+
}
|
|
102
|
+
function createTerminalReplyFilter() {
|
|
103
|
+
let held = "";
|
|
104
|
+
return (data) => {
|
|
105
|
+
const result = stripReplies(held + data);
|
|
106
|
+
held = result.held;
|
|
107
|
+
return result.keys;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function detectBackgroundTheme(io) {
|
|
111
|
+
const caps = getCaps();
|
|
112
|
+
if (!shouldQueryBackground(caps, io.stdin.isTTY === true)) return;
|
|
113
|
+
const theme = await queryBackgroundTheme(io, BACKGROUND_TIMEOUT_MS);
|
|
114
|
+
if (theme !== null && theme !== caps.theme) setCaps({ ...getCaps(), theme });
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
BACKGROUND_QUERY,
|
|
118
|
+
BACKGROUND_TIMEOUT_MS,
|
|
119
|
+
createTerminalReplyFilter,
|
|
120
|
+
detectBackgroundTheme,
|
|
121
|
+
parseBackgroundReply,
|
|
122
|
+
queryBackgroundTheme,
|
|
123
|
+
shouldQueryBackground
|
|
124
|
+
};
|