dexto 1.6.1 → 1.6.3
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/analytics/wrapper.js +1 -1
- package/dist/cli/auth/dexto-api-key.d.ts +34 -0
- package/dist/cli/auth/dexto-api-key.d.ts.map +1 -0
- package/dist/cli/auth/dexto-api-key.js +161 -0
- package/dist/cli/auth/index.d.ts +2 -1
- package/dist/cli/auth/index.d.ts.map +1 -1
- package/dist/cli/auth/index.js +2 -1
- package/dist/cli/auth/oauth.d.ts +10 -0
- package/dist/cli/auth/oauth.d.ts.map +1 -1
- package/dist/cli/auth/oauth.js +142 -39
- package/dist/cli/auth/service.d.ts +1 -0
- package/dist/cli/auth/service.d.ts.map +1 -1
- package/dist/cli/auth/service.js +1 -0
- package/dist/cli/commands/auth/login.d.ts.map +1 -1
- package/dist/cli/commands/auth/login.js +40 -105
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +157 -120
- package/dist/cli/utils/config-validation.js +3 -3
- package/dist/cli/utils/options.d.ts.map +1 -1
- package/dist/cli/utils/options.js +6 -0
- package/dist/cli/utils/scaffolding-utils.d.ts.map +1 -1
- package/dist/cli/utils/scaffolding-utils.js +38 -4
- package/dist/index-main.js +78 -11
- package/dist/index.js +12 -0
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +18 -11
- package/dist/webui/assets/index-d6c-yJNn.js +2059 -0
- package/dist/webui/assets/index-yKdFLN1k.css +1 -0
- package/dist/webui/assets/react-vendor-l0sNRNKZ.js +1 -0
- package/dist/webui/assets/tanstack-BjCuxfF-.js +41 -0
- package/dist/webui/index.html +3 -4
- package/package.json +13 -23
- package/dist/cli/assets/sounds/SOURCES.md +0 -35
- package/dist/cli/assets/sounds/boot.wav +0 -0
- package/dist/cli/assets/sounds/chime.wav +0 -0
- package/dist/cli/assets/sounds/coin.wav +0 -0
- package/dist/cli/assets/sounds/confirm.wav +0 -0
- package/dist/cli/assets/sounds/levelup.wav +0 -0
- package/dist/cli/assets/sounds/ping.wav +0 -0
- package/dist/cli/assets/sounds/powerup.wav +0 -0
- package/dist/cli/assets/sounds/startup.wav +0 -0
- package/dist/cli/assets/sounds/success.wav +0 -0
- package/dist/cli/assets/sounds/treasure.wav +0 -0
- package/dist/cli/assets/sounds/win.wav +0 -0
- package/dist/cli/commands/interactive-commands/auth/index.d.ts +0 -12
- package/dist/cli/commands/interactive-commands/auth/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/auth/index.js +0 -20
- package/dist/cli/commands/interactive-commands/command-parser.d.ts +0 -56
- package/dist/cli/commands/interactive-commands/command-parser.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/command-parser.js +0 -173
- package/dist/cli/commands/interactive-commands/commands.d.ts +0 -52
- package/dist/cli/commands/interactive-commands/commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/commands.js +0 -142
- package/dist/cli/commands/interactive-commands/documentation-commands.d.ts +0 -15
- package/dist/cli/commands/interactive-commands/documentation-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/documentation-commands.js +0 -39
- package/dist/cli/commands/interactive-commands/exit-handler.d.ts +0 -12
- package/dist/cli/commands/interactive-commands/exit-handler.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/exit-handler.js +0 -20
- package/dist/cli/commands/interactive-commands/exit-stats.d.ts +0 -24
- package/dist/cli/commands/interactive-commands/exit-stats.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/exit-stats.js +0 -17
- package/dist/cli/commands/interactive-commands/export/index.d.ts +0 -13
- package/dist/cli/commands/interactive-commands/export/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/export/index.js +0 -21
- package/dist/cli/commands/interactive-commands/general-commands.d.ts +0 -22
- package/dist/cli/commands/interactive-commands/general-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/general-commands.js +0 -508
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts +0 -13
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/mcp/index.js +0 -18
- package/dist/cli/commands/interactive-commands/model/index.d.ts +0 -13
- package/dist/cli/commands/interactive-commands/model/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/model/index.js +0 -19
- package/dist/cli/commands/interactive-commands/plugin/index.d.ts +0 -13
- package/dist/cli/commands/interactive-commands/plugin/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/plugin/index.js +0 -18
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts +0 -25
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.js +0 -284
- package/dist/cli/commands/interactive-commands/session/index.d.ts +0 -16
- package/dist/cli/commands/interactive-commands/session/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/session/index.js +0 -15
- package/dist/cli/commands/interactive-commands/session/session-commands.d.ts +0 -32
- package/dist/cli/commands/interactive-commands/session/session-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/session/session-commands.js +0 -65
- package/dist/cli/commands/interactive-commands/system/index.d.ts +0 -13
- package/dist/cli/commands/interactive-commands/system/index.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/system/index.js +0 -12
- package/dist/cli/commands/interactive-commands/system/system-commands.d.ts +0 -6
- package/dist/cli/commands/interactive-commands/system/system-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/system/system-commands.js +0 -188
- package/dist/cli/commands/interactive-commands/tool-commands.d.ts +0 -15
- package/dist/cli/commands/interactive-commands/tool-commands.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/tool-commands.js +0 -24
- package/dist/cli/commands/interactive-commands/utils/arg-parser.d.ts +0 -57
- package/dist/cli/commands/interactive-commands/utils/arg-parser.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/utils/arg-parser.js +0 -81
- package/dist/cli/commands/interactive-commands/utils/command-output.d.ts +0 -40
- package/dist/cli/commands/interactive-commands/utils/command-output.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/utils/command-output.js +0 -56
- package/dist/cli/commands/interactive-commands/utils/format-output.d.ts +0 -14
- package/dist/cli/commands/interactive-commands/utils/format-output.d.ts.map +0 -1
- package/dist/cli/commands/interactive-commands/utils/format-output.js +0 -18
- package/dist/cli/ink-cli/InkCLIRefactored.d.ts +0 -52
- package/dist/cli/ink-cli/InkCLIRefactored.d.ts.map +0 -1
- package/dist/cli/ink-cli/InkCLIRefactored.js +0 -231
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts +0 -44
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/ApprovalPrompt.js +0 -323
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts +0 -18
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.js +0 -48
- package/dist/cli/ink-cli/components/CustomInput.d.ts +0 -17
- package/dist/cli/ink-cli/components/CustomInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/CustomInput.js +0 -51
- package/dist/cli/ink-cli/components/CustomTextInput.d.ts +0 -16
- package/dist/cli/ink-cli/components/CustomTextInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/CustomTextInput.js +0 -36
- package/dist/cli/ink-cli/components/EditableMultiLineInput.d.ts +0 -19
- package/dist/cli/ink-cli/components/EditableMultiLineInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/EditableMultiLineInput.js +0 -120
- package/dist/cli/ink-cli/components/ElicitationForm.d.ts +0 -24
- package/dist/cli/ink-cli/components/ElicitationForm.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/ElicitationForm.js +0 -592
- package/dist/cli/ink-cli/components/ErrorBoundary.d.ts +0 -20
- package/dist/cli/ink-cli/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/ErrorBoundary.js +0 -29
- package/dist/cli/ink-cli/components/Footer.d.ts +0 -22
- package/dist/cli/ink-cli/components/Footer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/Footer.js +0 -76
- package/dist/cli/ink-cli/components/HistorySearchBar.d.ts +0 -17
- package/dist/cli/ink-cli/components/HistorySearchBar.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/HistorySearchBar.js +0 -8
- package/dist/cli/ink-cli/components/MultiLineInput.d.ts +0 -12
- package/dist/cli/ink-cli/components/MultiLineInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/MultiLineInput.js +0 -27
- package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts +0 -26
- package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/ResourceAutocomplete.js +0 -385
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts +0 -28
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.js +0 -412
- package/dist/cli/ink-cli/components/StatusBar.d.ts +0 -41
- package/dist/cli/ink-cli/components/StatusBar.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/StatusBar.js +0 -116
- package/dist/cli/ink-cli/components/TextBufferInput.d.ts +0 -52
- package/dist/cli/ink-cli/components/TextBufferInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/TextBufferInput.js +0 -490
- package/dist/cli/ink-cli/components/TodoPanel.d.ts +0 -26
- package/dist/cli/ink-cli/components/TodoPanel.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/TodoPanel.js +0 -62
- package/dist/cli/ink-cli/components/base/BaseAutocomplete.d.ts +0 -29
- package/dist/cli/ink-cli/components/base/BaseAutocomplete.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/base/BaseAutocomplete.js +0 -98
- package/dist/cli/ink-cli/components/base/BaseSelector.d.ts +0 -37
- package/dist/cli/ink-cli/components/base/BaseSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/base/BaseSelector.js +0 -128
- package/dist/cli/ink-cli/components/base/index.d.ts +0 -6
- package/dist/cli/ink-cli/components/base/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/base/index.js +0 -5
- package/dist/cli/ink-cli/components/chat/ChatView.d.ts +0 -19
- package/dist/cli/ink-cli/components/chat/ChatView.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/ChatView.js +0 -11
- package/dist/cli/ink-cli/components/chat/Footer.d.ts +0 -9
- package/dist/cli/ink-cli/components/chat/Footer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/Footer.js +0 -8
- package/dist/cli/ink-cli/components/chat/Header.d.ts +0 -18
- package/dist/cli/ink-cli/components/chat/Header.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/Header.js +0 -16
- package/dist/cli/ink-cli/components/chat/MessageItem.d.ts +0 -21
- package/dist/cli/ink-cli/components/chat/MessageItem.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/MessageItem.js +0 -182
- package/dist/cli/ink-cli/components/chat/MessageList.d.ts +0 -16
- package/dist/cli/ink-cli/components/chat/MessageList.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/MessageList.js +0 -20
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.d.ts +0 -16
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/QueuedMessagesDisplay.js +0 -27
- package/dist/cli/ink-cli/components/chat/ToolIcon.d.ts +0 -18
- package/dist/cli/ink-cli/components/chat/ToolIcon.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/ToolIcon.js +0 -36
- package/dist/cli/ink-cli/components/chat/index.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/index.js +0 -9
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/ConfigBox.js +0 -6
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/HelpBox.js +0 -15
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/LogConfigBox.js +0 -9
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionHistoryBox.js +0 -37
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/SessionListBox.js +0 -9
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/ShortcutsBox.js +0 -6
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/StatsBox.js +0 -29
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.d.ts +0 -45
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/StyledBox.js +0 -38
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.d.ts +0 -10
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/SyspromptBox.js +0 -6
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.d.ts +0 -13
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/chat/styled-boxes/index.js +0 -12
- package/dist/cli/ink-cli/components/input/InputArea.d.ts +0 -46
- package/dist/cli/ink-cli/components/input/InputArea.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/input/InputArea.js +0 -6
- package/dist/cli/ink-cli/components/input/index.d.ts +0 -5
- package/dist/cli/ink-cli/components/input/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/input/index.js +0 -4
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts +0 -27
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.js +0 -182
- package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts +0 -29
- package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/modes/StaticCLI.js +0 -114
- package/dist/cli/ink-cli/components/modes/index.d.ts +0 -10
- package/dist/cli/ink-cli/components/modes/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/modes/index.js +0 -9
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.d.ts +0 -26
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/ApiKeyInput.js +0 -92
- package/dist/cli/ink-cli/components/overlays/CommandOutputOverlay.d.ts +0 -13
- package/dist/cli/ink-cli/components/overlays/CommandOutputOverlay.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/CommandOutputOverlay.js +0 -60
- package/dist/cli/ink-cli/components/overlays/ContextStatsOverlay.d.ts +0 -26
- package/dist/cli/ink-cli/components/overlays/ContextStatsOverlay.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/ContextStatsOverlay.js +0 -241
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts +0 -29
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.js +0 -301
- package/dist/cli/ink-cli/components/overlays/ExportWizard.d.ts +0 -22
- package/dist/cli/ink-cli/components/overlays/ExportWizard.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/ExportWizard.js +0 -308
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts +0 -23
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.js +0 -70
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts +0 -20
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.js +0 -81
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts +0 -31
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.js +0 -297
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.d.ts +0 -22
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpAddChoice.js +0 -59
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.d.ts +0 -26
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpAddSelector.js +0 -73
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpCustomTypeSelector.js +0 -51
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.d.ts +0 -29
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpCustomWizard.js +0 -215
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts +0 -22
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.js +0 -80
- package/dist/cli/ink-cli/components/overlays/McpSelector.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/McpSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpSelector.js +0 -52
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts +0 -28
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpServerActions.js +0 -93
- package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts +0 -29
- package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/McpServerList.js +0 -116
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts +0 -28
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.js +0 -743
- package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts +0 -27
- package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PluginActions.js +0 -66
- package/dist/cli/ink-cli/components/overlays/PluginList.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/PluginList.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PluginList.js +0 -70
- package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PluginManager.js +0 -63
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.d.ts +0 -22
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PromptAddChoice.js +0 -52
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.d.ts +0 -29
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PromptAddWizard.js +0 -166
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.d.ts +0 -27
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PromptDeleteSelector.js +0 -119
- package/dist/cli/ink-cli/components/overlays/PromptList.d.ts +0 -33
- package/dist/cli/ink-cli/components/overlays/PromptList.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/PromptList.js +0 -143
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.d.ts +0 -23
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/SearchOverlay.js +0 -189
- package/dist/cli/ink-cli/components/overlays/SessionRenameOverlay.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/SessionRenameOverlay.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/SessionRenameOverlay.js +0 -63
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.d.ts +0 -26
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/SessionSelectorRefactored.js +0 -126
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/SessionSubcommandSelector.js +0 -42
- package/dist/cli/ink-cli/components/overlays/SoundsSelector.d.ts +0 -21
- package/dist/cli/ink-cli/components/overlays/SoundsSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/SoundsSelector.js +0 -566
- package/dist/cli/ink-cli/components/overlays/StreamSelector.d.ts +0 -20
- package/dist/cli/ink-cli/components/overlays/StreamSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/StreamSelector.js +0 -58
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts +0 -26
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.js +0 -697
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.d.ts +0 -25
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/LocalModelWizard.js +0 -604
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.d.ts +0 -15
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/index.js +0 -14
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts +0 -42
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.js +0 -547
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts +0 -25
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ApiKeyStep.js +0 -29
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts +0 -17
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/ProviderSelector.js +0 -11
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts +0 -20
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/SetupInfoBanner.js +0 -10
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts +0 -30
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/WizardStepInput.js +0 -13
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.d.ts +0 -8
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/shared/index.js +0 -7
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.d.ts +0 -85
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/types.js +0 -38
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.d.ts +0 -21
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/DiffRenderer.js +0 -65
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts +0 -30
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.js +0 -67
- package/dist/cli/ink-cli/components/renderers/FileRenderer.d.ts +0 -21
- package/dist/cli/ink-cli/components/renderers/FileRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/FileRenderer.js +0 -37
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.d.ts +0 -21
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/GenericRenderer.js +0 -26
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.d.ts +0 -20
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/SearchRenderer.js +0 -26
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.d.ts +0 -21
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/ShellRenderer.js +0 -15
- package/dist/cli/ink-cli/components/renderers/diff-shared.d.ts +0 -61
- package/dist/cli/ink-cli/components/renderers/diff-shared.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/diff-shared.js +0 -158
- package/dist/cli/ink-cli/components/renderers/index.d.ts +0 -28
- package/dist/cli/ink-cli/components/renderers/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/renderers/index.js +0 -36
- package/dist/cli/ink-cli/components/shared/FocusOverlayFrame.d.ts +0 -7
- package/dist/cli/ink-cli/components/shared/FocusOverlayFrame.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/shared/FocusOverlayFrame.js +0 -8
- package/dist/cli/ink-cli/components/shared/HintBar.d.ts +0 -6
- package/dist/cli/ink-cli/components/shared/HintBar.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/shared/HintBar.js +0 -6
- package/dist/cli/ink-cli/components/shared/MarkdownText.d.ts +0 -38
- package/dist/cli/ink-cli/components/shared/MarkdownText.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/shared/MarkdownText.js +0 -389
- package/dist/cli/ink-cli/components/shared/VirtualizedList.d.ts +0 -44
- package/dist/cli/ink-cli/components/shared/VirtualizedList.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/shared/VirtualizedList.js +0 -300
- package/dist/cli/ink-cli/components/shared/text-buffer.d.ts +0 -185
- package/dist/cli/ink-cli/components/shared/text-buffer.d.ts.map +0 -1
- package/dist/cli/ink-cli/components/shared/text-buffer.js +0 -1338
- package/dist/cli/ink-cli/constants/processingPhrases.d.ts +0 -10
- package/dist/cli/ink-cli/constants/processingPhrases.d.ts.map +0 -1
- package/dist/cli/ink-cli/constants/processingPhrases.js +0 -92
- package/dist/cli/ink-cli/constants/spinnerFrames.d.ts +0 -2
- package/dist/cli/ink-cli/constants/spinnerFrames.d.ts.map +0 -1
- package/dist/cli/ink-cli/constants/spinnerFrames.js +0 -1
- package/dist/cli/ink-cli/constants/tips.d.ts +0 -15
- package/dist/cli/ink-cli/constants/tips.d.ts.map +0 -1
- package/dist/cli/ink-cli/constants/tips.js +0 -58
- package/dist/cli/ink-cli/containers/InputContainer.d.ts +0 -62
- package/dist/cli/ink-cli/containers/InputContainer.d.ts.map +0 -1
- package/dist/cli/ink-cli/containers/InputContainer.js +0 -643
- package/dist/cli/ink-cli/containers/OverlayContainer.d.ts +0 -42
- package/dist/cli/ink-cli/containers/OverlayContainer.d.ts.map +0 -1
- package/dist/cli/ink-cli/containers/OverlayContainer.js +0 -1840
- package/dist/cli/ink-cli/containers/index.d.ts +0 -6
- package/dist/cli/ink-cli/containers/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/containers/index.js +0 -5
- package/dist/cli/ink-cli/contexts/KeypressContext.d.ts +0 -36
- package/dist/cli/ink-cli/contexts/KeypressContext.d.ts.map +0 -1
- package/dist/cli/ink-cli/contexts/KeypressContext.js +0 -461
- package/dist/cli/ink-cli/contexts/MouseContext.d.ts +0 -27
- package/dist/cli/ink-cli/contexts/MouseContext.d.ts.map +0 -1
- package/dist/cli/ink-cli/contexts/MouseContext.js +0 -102
- package/dist/cli/ink-cli/contexts/ScrollProvider.d.ts +0 -33
- package/dist/cli/ink-cli/contexts/ScrollProvider.d.ts.map +0 -1
- package/dist/cli/ink-cli/contexts/ScrollProvider.js +0 -170
- package/dist/cli/ink-cli/contexts/SoundContext.d.ts +0 -23
- package/dist/cli/ink-cli/contexts/SoundContext.d.ts.map +0 -1
- package/dist/cli/ink-cli/contexts/SoundContext.js +0 -22
- package/dist/cli/ink-cli/contexts/index.d.ts +0 -8
- package/dist/cli/ink-cli/contexts/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/contexts/index.js +0 -7
- package/dist/cli/ink-cli/hooks/index.d.ts +0 -12
- package/dist/cli/ink-cli/hooks/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/index.js +0 -14
- package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts +0 -49
- package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useAgentEvents.js +0 -369
- package/dist/cli/ink-cli/hooks/useAnimationTick.d.ts +0 -11
- package/dist/cli/ink-cli/hooks/useAnimationTick.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useAnimationTick.js +0 -54
- package/dist/cli/ink-cli/hooks/useBatchedScroll.d.ts +0 -14
- package/dist/cli/ink-cli/hooks/useBatchedScroll.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useBatchedScroll.js +0 -25
- package/dist/cli/ink-cli/hooks/useCLIState.d.ts +0 -52
- package/dist/cli/ink-cli/hooks/useCLIState.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useCLIState.js +0 -224
- package/dist/cli/ink-cli/hooks/useElapsedTime.d.ts +0 -24
- package/dist/cli/ink-cli/hooks/useElapsedTime.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useElapsedTime.js +0 -69
- package/dist/cli/ink-cli/hooks/useGitBranch.d.ts +0 -13
- package/dist/cli/ink-cli/hooks/useGitBranch.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useGitBranch.js +0 -35
- package/dist/cli/ink-cli/hooks/useHistorySearch.d.ts +0 -61
- package/dist/cli/ink-cli/hooks/useHistorySearch.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useHistorySearch.js +0 -210
- package/dist/cli/ink-cli/hooks/useInputHistory.d.ts +0 -18
- package/dist/cli/ink-cli/hooks/useInputHistory.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useInputHistory.js +0 -26
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts +0 -136
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.js +0 -715
- package/dist/cli/ink-cli/hooks/useKeyboardShortcuts.d.ts +0 -21
- package/dist/cli/ink-cli/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useKeyboardShortcuts.js +0 -80
- package/dist/cli/ink-cli/hooks/useKeypress.d.ts +0 -18
- package/dist/cli/ink-cli/hooks/useKeypress.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useKeypress.js +0 -26
- package/dist/cli/ink-cli/hooks/usePhraseCycler.d.ts +0 -30
- package/dist/cli/ink-cli/hooks/usePhraseCycler.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/usePhraseCycler.js +0 -68
- package/dist/cli/ink-cli/hooks/useStreaming.d.ts +0 -19
- package/dist/cli/ink-cli/hooks/useStreaming.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useStreaming.js +0 -26
- package/dist/cli/ink-cli/hooks/useTerminalSize.d.ts +0 -14
- package/dist/cli/ink-cli/hooks/useTerminalSize.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useTerminalSize.js +0 -31
- package/dist/cli/ink-cli/hooks/useTokenCounter.d.ts +0 -46
- package/dist/cli/ink-cli/hooks/useTokenCounter.d.ts.map +0 -1
- package/dist/cli/ink-cli/hooks/useTokenCounter.js +0 -122
- package/dist/cli/ink-cli/services/CommandService.d.ts +0 -58
- package/dist/cli/ink-cli/services/CommandService.d.ts.map +0 -1
- package/dist/cli/ink-cli/services/CommandService.js +0 -64
- package/dist/cli/ink-cli/services/InputService.d.ts +0 -40
- package/dist/cli/ink-cli/services/InputService.d.ts.map +0 -1
- package/dist/cli/ink-cli/services/InputService.js +0 -87
- package/dist/cli/ink-cli/services/MessageService.d.ts +0 -35
- package/dist/cli/ink-cli/services/MessageService.d.ts.map +0 -1
- package/dist/cli/ink-cli/services/MessageService.js +0 -49
- package/dist/cli/ink-cli/services/index.d.ts +0 -8
- package/dist/cli/ink-cli/services/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/services/index.js +0 -7
- package/dist/cli/ink-cli/services/processStream.d.ts +0 -75
- package/dist/cli/ink-cli/services/processStream.d.ts.map +0 -1
- package/dist/cli/ink-cli/services/processStream.js +0 -951
- package/dist/cli/ink-cli/state/actions.d.ts +0 -124
- package/dist/cli/ink-cli/state/actions.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/actions.js +0 -8
- package/dist/cli/ink-cli/state/index.d.ts +0 -10
- package/dist/cli/ink-cli/state/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/index.js +0 -8
- package/dist/cli/ink-cli/state/initialState.d.ts +0 -12
- package/dist/cli/ink-cli/state/initialState.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/initialState.js +0 -58
- package/dist/cli/ink-cli/state/reducer.d.ts +0 -15
- package/dist/cli/ink-cli/state/reducer.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/reducer.js +0 -341
- package/dist/cli/ink-cli/state/streaming-state.d.ts +0 -27
- package/dist/cli/ink-cli/state/streaming-state.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/streaming-state.js +0 -39
- package/dist/cli/ink-cli/state/types.d.ts +0 -378
- package/dist/cli/ink-cli/state/types.d.ts.map +0 -1
- package/dist/cli/ink-cli/state/types.js +0 -5
- package/dist/cli/ink-cli/utils/bracketedPaste.d.ts +0 -22
- package/dist/cli/ink-cli/utils/bracketedPaste.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/bracketedPaste.js +0 -27
- package/dist/cli/ink-cli/utils/clipboardUtils.d.ts +0 -49
- package/dist/cli/ink-cli/utils/clipboardUtils.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/clipboardUtils.js +0 -356
- package/dist/cli/ink-cli/utils/commandOverlays.d.ts +0 -33
- package/dist/cli/ink-cli/utils/commandOverlays.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/commandOverlays.js +0 -85
- package/dist/cli/ink-cli/utils/debugLog.d.ts +0 -38
- package/dist/cli/ink-cli/utils/debugLog.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/debugLog.js +0 -66
- package/dist/cli/ink-cli/utils/elicitationSchema.d.ts +0 -11
- package/dist/cli/ink-cli/utils/elicitationSchema.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/elicitationSchema.js +0 -80
- package/dist/cli/ink-cli/utils/idGenerator.d.ts +0 -10
- package/dist/cli/ink-cli/utils/idGenerator.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/idGenerator.js +0 -12
- package/dist/cli/ink-cli/utils/index.d.ts +0 -9
- package/dist/cli/ink-cli/utils/index.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/index.js +0 -13
- package/dist/cli/ink-cli/utils/input.d.ts +0 -25
- package/dist/cli/ink-cli/utils/input.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/input.js +0 -56
- package/dist/cli/ink-cli/utils/inputParsing.d.ts +0 -31
- package/dist/cli/ink-cli/utils/inputParsing.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/inputParsing.js +0 -70
- package/dist/cli/ink-cli/utils/llm-provider-display.d.ts +0 -3
- package/dist/cli/ink-cli/utils/llm-provider-display.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/llm-provider-display.js +0 -22
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts +0 -125
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/messageFormatting.js +0 -485
- package/dist/cli/ink-cli/utils/mouse.d.ts +0 -61
- package/dist/cli/ink-cli/utils/mouse.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/mouse.js +0 -209
- package/dist/cli/ink-cli/utils/overlayPresentation.d.ts +0 -19
- package/dist/cli/ink-cli/utils/overlayPresentation.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/overlayPresentation.js +0 -33
- package/dist/cli/ink-cli/utils/overlaySizing.d.ts +0 -19
- package/dist/cli/ink-cli/utils/overlaySizing.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/overlaySizing.js +0 -11
- package/dist/cli/ink-cli/utils/soundNotification.d.ts +0 -77
- package/dist/cli/ink-cli/utils/soundNotification.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/soundNotification.js +0 -226
- package/dist/cli/ink-cli/utils/streamSplitter.d.ts +0 -44
- package/dist/cli/ink-cli/utils/streamSplitter.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/streamSplitter.js +0 -154
- package/dist/cli/ink-cli/utils/textUtils.d.ts +0 -63
- package/dist/cli/ink-cli/utils/textUtils.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/textUtils.js +0 -248
- package/dist/cli/ink-cli/utils/toolUtils.d.ts +0 -20
- package/dist/cli/ink-cli/utils/toolUtils.d.ts.map +0 -1
- package/dist/cli/ink-cli/utils/toolUtils.js +0 -25
- package/dist/webui/assets/index-C9JXwpvo.css +0 -1
- package/dist/webui/assets/index-CKhumsZA.js +0 -2059
- package/dist/webui/assets/react-vendor-gH-7aFTg.js +0 -17
- package/dist/webui/assets/tanstack-Br79RQ-n.js +0 -25
|
@@ -1,951 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process Stream Service
|
|
3
|
-
*
|
|
4
|
-
* Processes the async iterator from agent.stream() and updates UI state.
|
|
5
|
-
* This replaces the event bus subscriptions for streaming events,
|
|
6
|
-
* providing direct, synchronous control over the streaming lifecycle.
|
|
7
|
-
*
|
|
8
|
-
* Architecture:
|
|
9
|
-
* - Messages being streamed are tracked in `pendingMessages` (rendered dynamically)
|
|
10
|
-
* - Only finalized messages are added to `messages` (rendered in <Static>)
|
|
11
|
-
* - Progressive finalization: large streaming content is split at safe markdown
|
|
12
|
-
* boundaries, moving completed paragraphs to Static to reduce flickering
|
|
13
|
-
* - This prevents duplicate output in static terminal mode
|
|
14
|
-
*
|
|
15
|
-
* IMPORTANT: React batching fix (see commit history for race condition details)
|
|
16
|
-
* - We use a local `localPending` array that mirrors React state synchronously
|
|
17
|
-
* - This allows us to flatten nested setState calls (which caused ordering bugs)
|
|
18
|
-
* - Nested setState: inner setMessages inside setPendingMessages callback gets
|
|
19
|
-
* queued and runs AFTER other setMessages calls in the same batch
|
|
20
|
-
* - Flattened: setMessages and setPendingMessages are sibling calls, processed in order
|
|
21
|
-
*/
|
|
22
|
-
import { createDebugLogger } from '../utils/debugLog.js';
|
|
23
|
-
import { ApprovalType as ApprovalTypeEnum, ApprovalStatus } from '@dexto/core';
|
|
24
|
-
import { generateMessageId } from '../utils/idGenerator.js';
|
|
25
|
-
import { checkForSplit } from '../utils/streamSplitter.js';
|
|
26
|
-
import { formatToolHeader, shouldHideTool } from '../utils/messageFormatting.js';
|
|
27
|
-
import { isAutoApprovableInEditMode } from '../utils/toolUtils.js';
|
|
28
|
-
import { capture } from '../../../analytics/index.js';
|
|
29
|
-
import chalk from 'chalk';
|
|
30
|
-
/**
|
|
31
|
-
* Build error message with recovery guidance if available
|
|
32
|
-
*/
|
|
33
|
-
function buildErrorContent(error, prefix) {
|
|
34
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
-
let errorContent = `${prefix}${errorMessage}`;
|
|
36
|
-
// Add recovery guidance if available (for DextoRuntimeError)
|
|
37
|
-
if (error instanceof Error && 'recovery' in error && error.recovery) {
|
|
38
|
-
const recoveryMessages = Array.isArray(error.recovery) ? error.recovery : [error.recovery];
|
|
39
|
-
errorContent += '\n\n' + recoveryMessages.map((msg) => `💡 ${msg}`).join('\n');
|
|
40
|
-
}
|
|
41
|
-
return errorContent;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Processes the async iterator from agent.stream() and updates UI state.
|
|
45
|
-
*
|
|
46
|
-
* For static mode compatibility:
|
|
47
|
-
* - Streaming content goes to `pendingMessages` (rendered dynamically)
|
|
48
|
-
* - Finalized content is moved to `messages` (rendered in <Static>)
|
|
49
|
-
*
|
|
50
|
-
* @param iterator - The async iterator from agent.stream()
|
|
51
|
-
* @param setters - State setters for updating UI
|
|
52
|
-
* @param options - Configuration options
|
|
53
|
-
*/
|
|
54
|
-
export async function processStream(iterator, setters, options) {
|
|
55
|
-
const { setMessages, setPendingMessages, setDequeuedBuffer, setUi, setSession: _setSession, setQueuedMessages, setApproval, setApprovalQueue, } = setters;
|
|
56
|
-
const useStreaming = options?.useStreaming ?? true;
|
|
57
|
-
// Link approval IDs to tool call IDs so we can finalize tool UI when an approval
|
|
58
|
-
// is cancelled/denied (otherwise tool messages can remain stuck in "Waiting...").
|
|
59
|
-
const approvalIdToToolCallId = new Map();
|
|
60
|
-
// Track streaming state (synchronous, not React state)
|
|
61
|
-
const state = {
|
|
62
|
-
messageId: null,
|
|
63
|
-
content: '',
|
|
64
|
-
lastInputTokens: 0,
|
|
65
|
-
cumulativeOutputTokens: 0,
|
|
66
|
-
finalizedContent: '',
|
|
67
|
-
splitCounter: 0,
|
|
68
|
-
textFinalizedBeforeTool: false,
|
|
69
|
-
nonStreamingAccumulatedText: '',
|
|
70
|
-
};
|
|
71
|
-
// LOCAL PENDING TRACKING - mirrors React state synchronously
|
|
72
|
-
// This allows us to flatten nested setState calls (which caused ordering bugs).
|
|
73
|
-
// See: https://github.com/facebook/react/issues/8132 - nested setState not supported
|
|
74
|
-
let localPending = [];
|
|
75
|
-
/**
|
|
76
|
-
* Extract text content from ContentPart array
|
|
77
|
-
*/
|
|
78
|
-
const extractTextContent = (content) => {
|
|
79
|
-
return content
|
|
80
|
-
.filter((part) => part.type === 'text')
|
|
81
|
-
.map((part) => part.text)
|
|
82
|
-
.join('\n');
|
|
83
|
-
};
|
|
84
|
-
const formatQueuedMessagesForDisplay = (messages) => {
|
|
85
|
-
const userMessages = messages.filter((message) => message.kind !== 'background');
|
|
86
|
-
if (userMessages.length === 0) {
|
|
87
|
-
return '';
|
|
88
|
-
}
|
|
89
|
-
if (userMessages.length === 1) {
|
|
90
|
-
return extractTextContent(userMessages[0]?.content ?? []) || '[attachment]';
|
|
91
|
-
}
|
|
92
|
-
return userMessages
|
|
93
|
-
.map((message, index) => {
|
|
94
|
-
const prefix = userMessages.length === 2 ? (index === 0 ? 'First' : 'Also') : `[${index + 1}]`;
|
|
95
|
-
const content = extractTextContent(message.content) || '[attachment]';
|
|
96
|
-
return `${prefix}: ${content}`;
|
|
97
|
-
})
|
|
98
|
-
.join('\n\n');
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Move a message from pending to finalized.
|
|
102
|
-
* FLATTENED: Uses localPending to avoid nested setState (which breaks ordering).
|
|
103
|
-
*/
|
|
104
|
-
const finalizeMessage = (messageId, updates = {}) => {
|
|
105
|
-
const msg = localPending.find((m) => m.id === messageId);
|
|
106
|
-
if (msg) {
|
|
107
|
-
// Add to messages FIRST (sibling call, not nested)
|
|
108
|
-
setMessages((prev) => [...prev, { ...msg, ...updates }]);
|
|
109
|
-
}
|
|
110
|
-
// Update local tracking
|
|
111
|
-
localPending = localPending.filter((m) => m.id !== messageId);
|
|
112
|
-
// Then update React state (sibling call)
|
|
113
|
-
setPendingMessages(localPending);
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Move all pending messages to finalized (used at run:complete and message:dequeued).
|
|
117
|
-
* FLATTENED: Uses localPending to avoid nested setState.
|
|
118
|
-
*/
|
|
119
|
-
const finalizeAllPending = () => {
|
|
120
|
-
if (localPending.length > 0) {
|
|
121
|
-
// Add to messages FIRST (sibling call, not nested)
|
|
122
|
-
const toFinalize = [...localPending];
|
|
123
|
-
setMessages((prev) => [...prev, ...toFinalize]);
|
|
124
|
-
}
|
|
125
|
-
// Update local tracking
|
|
126
|
-
localPending = [];
|
|
127
|
-
// Then update React state (sibling call)
|
|
128
|
-
setPendingMessages([]);
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Move dequeued buffer to messages (called at start of new run)
|
|
132
|
-
* This ensures user messages appear in correct order after previous response
|
|
133
|
-
* NOTE: This still uses nested setState but dequeuedBuffer is separate from
|
|
134
|
-
* the main message flow and only flushed at llm:thinking (start of run)
|
|
135
|
-
*/
|
|
136
|
-
const flushDequeuedBuffer = () => {
|
|
137
|
-
setDequeuedBuffer((buffer) => {
|
|
138
|
-
if (buffer.length > 0) {
|
|
139
|
-
setMessages((prev) => [...prev, ...buffer]);
|
|
140
|
-
}
|
|
141
|
-
return [];
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Add message to pending (updates both local tracking and React state)
|
|
146
|
-
*/
|
|
147
|
-
const addToPending = (msg) => {
|
|
148
|
-
localPending = [...localPending, msg];
|
|
149
|
-
setPendingMessages(localPending);
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Update a message in pending (updates both local tracking and React state)
|
|
153
|
-
*/
|
|
154
|
-
const updatePending = (messageId, updates) => {
|
|
155
|
-
localPending = localPending.map((m) => (m.id === messageId ? { ...m, ...updates } : m));
|
|
156
|
-
setPendingMessages(localPending);
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Remove a message from pending without finalizing (updates both local and React state)
|
|
160
|
-
*/
|
|
161
|
-
const removeFromPending = (messageId) => {
|
|
162
|
-
localPending = localPending.filter((m) => m.id !== messageId);
|
|
163
|
-
setPendingMessages(localPending);
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Clear all pending (updates both local tracking and React state)
|
|
167
|
-
*/
|
|
168
|
-
const clearPending = () => {
|
|
169
|
-
localPending = [];
|
|
170
|
-
setPendingMessages([]);
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Update toolStatus for a pending message by ID
|
|
174
|
-
* Used for tool status transitions: pending → pending_approval → running → finished
|
|
175
|
-
*/
|
|
176
|
-
const updatePendingStatus = (messageId, status) => {
|
|
177
|
-
localPending = localPending.map((msg) => msg.id === messageId ? { ...msg, toolStatus: status } : msg);
|
|
178
|
-
setPendingMessages(localPending);
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Progressive finalization: split large streaming content at safe markdown
|
|
182
|
-
* boundaries and move completed portions to Static to reduce flickering.
|
|
183
|
-
*
|
|
184
|
-
* Safe to use with message queueing because dequeued user messages are
|
|
185
|
-
* rendered in a separate buffer AFTER pendingMessages, guaranteeing
|
|
186
|
-
* correct visual order regardless of React batching timing.
|
|
187
|
-
*
|
|
188
|
-
* RACE CONDITION FIX: We clear the pending message content BEFORE adding
|
|
189
|
-
* the split, then restore with afterContent. This ensures any intermediate
|
|
190
|
-
* render sees empty pending (not stale full content), avoiding duplication.
|
|
191
|
-
*/
|
|
192
|
-
const progressiveFinalize = (content) => {
|
|
193
|
-
const splitResult = checkForSplit(content);
|
|
194
|
-
if (splitResult.shouldSplit && splitResult.before && splitResult.after !== undefined) {
|
|
195
|
-
// Add the completed portion directly to finalized messages
|
|
196
|
-
state.splitCounter++;
|
|
197
|
-
const splitId = `${state.messageId}-split-${state.splitCounter}`;
|
|
198
|
-
const beforeContent = splitResult.before;
|
|
199
|
-
const afterContent = splitResult.after;
|
|
200
|
-
const isFirstSplit = state.splitCounter === 1;
|
|
201
|
-
// STEP 1: Clear pending message content to avoid showing stale content
|
|
202
|
-
// during React's batched render cycle
|
|
203
|
-
if (state.messageId) {
|
|
204
|
-
localPending = localPending.map((m) => m.id === state.messageId ? { ...m, content: '', isContinuation: true } : m);
|
|
205
|
-
setPendingMessages(localPending);
|
|
206
|
-
}
|
|
207
|
-
// STEP 2: Add split message to finalized
|
|
208
|
-
setMessages((prev) => [
|
|
209
|
-
...prev,
|
|
210
|
-
{
|
|
211
|
-
id: splitId,
|
|
212
|
-
role: 'assistant',
|
|
213
|
-
content: beforeContent,
|
|
214
|
-
timestamp: new Date(),
|
|
215
|
-
isStreaming: false,
|
|
216
|
-
// First split shows the indicator, subsequent splits are continuations
|
|
217
|
-
isContinuation: !isFirstSplit,
|
|
218
|
-
},
|
|
219
|
-
]);
|
|
220
|
-
// STEP 3: Restore pending with afterContent
|
|
221
|
-
if (state.messageId) {
|
|
222
|
-
localPending = localPending.map((m) => m.id === state.messageId ? { ...m, content: afterContent } : m);
|
|
223
|
-
setPendingMessages(localPending);
|
|
224
|
-
}
|
|
225
|
-
// Track total finalized content for final message assembly
|
|
226
|
-
state.finalizedContent += beforeContent;
|
|
227
|
-
// Return only the remaining content for pending
|
|
228
|
-
return afterContent;
|
|
229
|
-
}
|
|
230
|
-
return content;
|
|
231
|
-
};
|
|
232
|
-
// Debug logging: enable via DEXTO_DEBUG_STREAM=true
|
|
233
|
-
const debug = createDebugLogger('stream');
|
|
234
|
-
debug.reset();
|
|
235
|
-
debug.log('CONFIG', { useStreaming });
|
|
236
|
-
try {
|
|
237
|
-
for await (const event of iterator) {
|
|
238
|
-
debug.log(`EVENT: ${event.name}`, {
|
|
239
|
-
...(event.name === 'llm:chunk' &&
|
|
240
|
-
'chunkType' in event && {
|
|
241
|
-
chunkType: event.chunkType,
|
|
242
|
-
contentLen: event.content?.length,
|
|
243
|
-
}),
|
|
244
|
-
...(event.name === 'llm:tool-call' &&
|
|
245
|
-
'toolName' in event && {
|
|
246
|
-
toolName: event.toolName,
|
|
247
|
-
}),
|
|
248
|
-
});
|
|
249
|
-
switch (event.name) {
|
|
250
|
-
case 'llm:thinking': {
|
|
251
|
-
debug.log('THINKING: resetting state', {
|
|
252
|
-
prevMessageId: state.messageId,
|
|
253
|
-
prevContentLen: state.content.length,
|
|
254
|
-
});
|
|
255
|
-
// Flush dequeued buffer to messages at start of new run
|
|
256
|
-
// This ensures user messages appear after the previous response
|
|
257
|
-
flushDequeuedBuffer();
|
|
258
|
-
// Start thinking state, reset streaming state
|
|
259
|
-
setUi((prev) => ({ ...prev, isThinking: true }));
|
|
260
|
-
state.messageId = null;
|
|
261
|
-
state.content = '';
|
|
262
|
-
state.lastInputTokens = 0;
|
|
263
|
-
state.cumulativeOutputTokens = 0;
|
|
264
|
-
state.finalizedContent = '';
|
|
265
|
-
state.splitCounter = 0;
|
|
266
|
-
state.textFinalizedBeforeTool = false;
|
|
267
|
-
state.nonStreamingAccumulatedText = '';
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
case 'llm:chunk': {
|
|
271
|
-
// In non-streaming mode, accumulate text but don't update UI
|
|
272
|
-
// We need to track text so we can add it BEFORE tool calls (ordering fix)
|
|
273
|
-
if (!useStreaming) {
|
|
274
|
-
if (event.chunkType === 'text') {
|
|
275
|
-
state.nonStreamingAccumulatedText += event.content;
|
|
276
|
-
debug.log('CHUNK (non-stream): accumulated', {
|
|
277
|
-
chunkLen: event.content?.length,
|
|
278
|
-
totalLen: state.nonStreamingAccumulatedText.length,
|
|
279
|
-
preview: state.nonStreamingAccumulatedText.slice(0, 50),
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
// End thinking state when first chunk arrives
|
|
285
|
-
setUi((prev) => ({ ...prev, isThinking: false }));
|
|
286
|
-
if (event.chunkType === 'text') {
|
|
287
|
-
debug.log('CHUNK (stream): text', {
|
|
288
|
-
hasMessageId: !!state.messageId,
|
|
289
|
-
chunkLen: event.content?.length,
|
|
290
|
-
currentContentLen: state.content.length,
|
|
291
|
-
preview: event.content?.slice(0, 30),
|
|
292
|
-
});
|
|
293
|
-
// Create streaming message on first text chunk
|
|
294
|
-
if (!state.messageId) {
|
|
295
|
-
const newId = generateMessageId('assistant');
|
|
296
|
-
state.messageId = newId;
|
|
297
|
-
state.content = event.content;
|
|
298
|
-
state.finalizedContent = '';
|
|
299
|
-
state.splitCounter = 0;
|
|
300
|
-
// Add to PENDING (not messages) - renders dynamically
|
|
301
|
-
addToPending({
|
|
302
|
-
id: newId,
|
|
303
|
-
role: 'assistant',
|
|
304
|
-
content: event.content,
|
|
305
|
-
timestamp: new Date(),
|
|
306
|
-
isStreaming: true,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
// Accumulate content
|
|
311
|
-
state.content += event.content;
|
|
312
|
-
// Check for progressive finalization (move completed paragraphs to Static)
|
|
313
|
-
// progressiveFinalize updates pending message internally when split occurs
|
|
314
|
-
const pendingContent = progressiveFinalize(state.content);
|
|
315
|
-
const splitOccurred = pendingContent !== state.content;
|
|
316
|
-
// Update state with remaining content
|
|
317
|
-
state.content = pendingContent;
|
|
318
|
-
// Only update pending if no split occurred (split already handled by progressiveFinalize)
|
|
319
|
-
if (!splitOccurred) {
|
|
320
|
-
const messageId = state.messageId;
|
|
321
|
-
// Mark as continuation if we've had any splits
|
|
322
|
-
const isContinuation = state.splitCounter > 0;
|
|
323
|
-
updatePending(messageId, {
|
|
324
|
-
content: pendingContent,
|
|
325
|
-
isContinuation,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case 'llm:response': {
|
|
333
|
-
// In non-streaming mode, end thinking state when response arrives
|
|
334
|
-
// (In streaming mode, thinking ends when first chunk arrives)
|
|
335
|
-
if (!useStreaming) {
|
|
336
|
-
setUi((prev) => ({ ...prev, isThinking: false }));
|
|
337
|
-
}
|
|
338
|
-
// Track token usage: replace input (last context), accumulate output
|
|
339
|
-
// Subtract cacheWriteTokens to exclude system prompt on first call
|
|
340
|
-
if (event.tokenUsage) {
|
|
341
|
-
const rawInputTokens = event.tokenUsage.inputTokens ?? 0;
|
|
342
|
-
const cacheWriteTokens = event.tokenUsage.cacheWriteTokens ?? 0;
|
|
343
|
-
const inputTokens = Math.max(0, rawInputTokens - cacheWriteTokens);
|
|
344
|
-
if (inputTokens > 0) {
|
|
345
|
-
state.lastInputTokens = inputTokens;
|
|
346
|
-
}
|
|
347
|
-
if (event.tokenUsage.outputTokens) {
|
|
348
|
-
state.cumulativeOutputTokens += event.tokenUsage.outputTokens;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
// Track token usage analytics
|
|
352
|
-
if (event.tokenUsage &&
|
|
353
|
-
(event.tokenUsage.inputTokens || event.tokenUsage.outputTokens)) {
|
|
354
|
-
// Calculate estimate accuracy if both estimate and actual are available
|
|
355
|
-
let estimateAccuracyPercent;
|
|
356
|
-
if (event.estimatedInputTokens !== undefined &&
|
|
357
|
-
event.tokenUsage.inputTokens) {
|
|
358
|
-
const diff = event.estimatedInputTokens - event.tokenUsage.inputTokens;
|
|
359
|
-
estimateAccuracyPercent = Math.round((diff / event.tokenUsage.inputTokens) * 100);
|
|
360
|
-
}
|
|
361
|
-
capture('dexto_llm_tokens_consumed', {
|
|
362
|
-
source: 'cli',
|
|
363
|
-
sessionId: event.sessionId,
|
|
364
|
-
provider: event.provider,
|
|
365
|
-
model: event.model,
|
|
366
|
-
inputTokens: event.tokenUsage.inputTokens,
|
|
367
|
-
outputTokens: event.tokenUsage.outputTokens,
|
|
368
|
-
reasoningTokens: event.tokenUsage.reasoningTokens,
|
|
369
|
-
totalTokens: event.tokenUsage.totalTokens,
|
|
370
|
-
cacheReadTokens: event.tokenUsage.cacheReadTokens,
|
|
371
|
-
cacheWriteTokens: event.tokenUsage.cacheWriteTokens,
|
|
372
|
-
estimatedInputTokens: event.estimatedInputTokens,
|
|
373
|
-
estimateAccuracyPercent,
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
const finalContent = event.content || '';
|
|
377
|
-
if (state.messageId) {
|
|
378
|
-
// Finalize existing streaming message (streaming mode)
|
|
379
|
-
const messageId = state.messageId;
|
|
380
|
-
const content = state.content || finalContent;
|
|
381
|
-
// Move from pending to finalized
|
|
382
|
-
finalizeMessage(messageId, { content, isStreaming: false });
|
|
383
|
-
// Reset for potential next response (multi-step)
|
|
384
|
-
state.messageId = null;
|
|
385
|
-
state.content = '';
|
|
386
|
-
}
|
|
387
|
-
else if (finalContent && !state.textFinalizedBeforeTool) {
|
|
388
|
-
// No streaming message exists - add directly to finalized
|
|
389
|
-
// This handles: non-streaming mode, or multi-step turns after tool calls
|
|
390
|
-
// Skip if text was already finalized before tools (avoid duplication)
|
|
391
|
-
setMessages((prev) => [
|
|
392
|
-
...prev,
|
|
393
|
-
{
|
|
394
|
-
id: generateMessageId('assistant'),
|
|
395
|
-
role: 'assistant',
|
|
396
|
-
content: finalContent,
|
|
397
|
-
timestamp: new Date(),
|
|
398
|
-
isStreaming: false,
|
|
399
|
-
},
|
|
400
|
-
]);
|
|
401
|
-
}
|
|
402
|
-
// Reset the flag for this response (new text after tools will create new message)
|
|
403
|
-
state.textFinalizedBeforeTool = false;
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
case 'llm:tool-call': {
|
|
407
|
-
if (shouldHideTool(event.toolName)) {
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
debug.log('TOOL-CALL: state check', {
|
|
411
|
-
toolName: event.toolName,
|
|
412
|
-
hasMessageId: !!state.messageId,
|
|
413
|
-
contentLen: state.content.length,
|
|
414
|
-
nonStreamAccumLen: state.nonStreamingAccumulatedText.length,
|
|
415
|
-
contentPreview: state.content.slice(0, 50),
|
|
416
|
-
nonStreamPreview: state.nonStreamingAccumulatedText.slice(0, 50),
|
|
417
|
-
useStreaming,
|
|
418
|
-
});
|
|
419
|
-
// ORDERING FIX: Add any accumulated text BEFORE adding tool
|
|
420
|
-
// This ensures text appears before tools in the message list.
|
|
421
|
-
// Streaming mode: handle pending assistant message before tool
|
|
422
|
-
if (state.messageId) {
|
|
423
|
-
if (state.content) {
|
|
424
|
-
// Finalize pending message with content
|
|
425
|
-
const messageId = state.messageId;
|
|
426
|
-
const content = state.content;
|
|
427
|
-
const isContinuation = state.splitCounter > 0;
|
|
428
|
-
debug.log('TOOL-CALL: finalizing pending message', {
|
|
429
|
-
messageId,
|
|
430
|
-
contentLen: content.length,
|
|
431
|
-
});
|
|
432
|
-
finalizeMessage(messageId, {
|
|
433
|
-
content,
|
|
434
|
-
isStreaming: false,
|
|
435
|
-
isContinuation,
|
|
436
|
-
});
|
|
437
|
-
// Mark that we finalized text early - prevents duplicate in llm:response
|
|
438
|
-
state.textFinalizedBeforeTool = true;
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
// Empty pending message (first chunk had no content) - remove it
|
|
442
|
-
// This prevents empty bullets when LLM/SDK sends empty initial chunk
|
|
443
|
-
debug.log('TOOL-CALL: removing empty pending message', {
|
|
444
|
-
messageId: state.messageId,
|
|
445
|
-
});
|
|
446
|
-
removeFromPending(state.messageId);
|
|
447
|
-
}
|
|
448
|
-
state.messageId = null;
|
|
449
|
-
state.content = '';
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
debug.log('TOOL-CALL: no pending message to finalize');
|
|
453
|
-
}
|
|
454
|
-
// Non-streaming mode: add accumulated text as finalized message
|
|
455
|
-
if (!useStreaming && state.nonStreamingAccumulatedText) {
|
|
456
|
-
debug.log('TOOL-CALL: adding non-stream accumulated text', {
|
|
457
|
-
len: state.nonStreamingAccumulatedText.length,
|
|
458
|
-
});
|
|
459
|
-
setMessages((prev) => [
|
|
460
|
-
...prev,
|
|
461
|
-
{
|
|
462
|
-
id: generateMessageId('assistant'),
|
|
463
|
-
role: 'assistant',
|
|
464
|
-
content: state.nonStreamingAccumulatedText,
|
|
465
|
-
timestamp: new Date(),
|
|
466
|
-
isStreaming: false,
|
|
467
|
-
},
|
|
468
|
-
]);
|
|
469
|
-
state.nonStreamingAccumulatedText = '';
|
|
470
|
-
// Mark that we finalized text early - prevents duplicate in llm:response
|
|
471
|
-
state.textFinalizedBeforeTool = true;
|
|
472
|
-
}
|
|
473
|
-
const toolMessageId = event.callId
|
|
474
|
-
? `tool-${event.callId}`
|
|
475
|
-
: generateMessageId('tool');
|
|
476
|
-
// Format tool header using shared utility
|
|
477
|
-
const { header: toolContent } = formatToolHeader({
|
|
478
|
-
toolName: event.toolName,
|
|
479
|
-
args: event.args || {},
|
|
480
|
-
...(event.presentationSnapshot !== undefined && {
|
|
481
|
-
presentationSnapshot: event.presentationSnapshot,
|
|
482
|
-
}),
|
|
483
|
-
});
|
|
484
|
-
// Add call description if present (dim styling, on new line)
|
|
485
|
-
// NOTE: This should come from tool call metadata (e.g., __meta.callDescription),
|
|
486
|
-
// not from tool args, to keep approval + history consistent.
|
|
487
|
-
let finalToolContent = toolContent;
|
|
488
|
-
const callDescription = event.callDescription;
|
|
489
|
-
if (typeof callDescription === 'string' && callDescription.trim().length > 0) {
|
|
490
|
-
finalToolContent += `\n${chalk.dim(callDescription)}`;
|
|
491
|
-
}
|
|
492
|
-
// Tool calls start in 'pending' state (don't know if approval needed yet)
|
|
493
|
-
// Status transitions: pending → pending_approval (if approval needed) → running → finished
|
|
494
|
-
// Or for pre-approved: pending → running → finished
|
|
495
|
-
addToPending({
|
|
496
|
-
id: toolMessageId,
|
|
497
|
-
role: 'tool',
|
|
498
|
-
content: finalToolContent,
|
|
499
|
-
timestamp: new Date(),
|
|
500
|
-
toolStatus: 'pending',
|
|
501
|
-
});
|
|
502
|
-
// Track tool called analytics
|
|
503
|
-
capture('dexto_tool_called', {
|
|
504
|
-
source: 'cli',
|
|
505
|
-
sessionId: event.sessionId,
|
|
506
|
-
toolName: event.toolName,
|
|
507
|
-
});
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
case 'llm:tool-result': {
|
|
511
|
-
if (shouldHideTool(event.toolName)) {
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
// Extract structured display data and content from sanitized result
|
|
515
|
-
const sanitized = event.sanitized;
|
|
516
|
-
const toolDisplayData = sanitized?.meta?.display;
|
|
517
|
-
const toolContent = sanitized?.content;
|
|
518
|
-
// Generate text preview for fallback display
|
|
519
|
-
let resultPreview = '';
|
|
520
|
-
try {
|
|
521
|
-
const result = event.sanitized || event.rawResult;
|
|
522
|
-
if (result) {
|
|
523
|
-
let resultStr = '';
|
|
524
|
-
if (typeof result === 'string') {
|
|
525
|
-
resultStr = result;
|
|
526
|
-
}
|
|
527
|
-
else if (result && typeof result === 'object') {
|
|
528
|
-
const resultObj = result;
|
|
529
|
-
if (Array.isArray(resultObj.content)) {
|
|
530
|
-
resultStr = resultObj.content
|
|
531
|
-
.filter((item) => typeof item === 'object' &&
|
|
532
|
-
item !== null &&
|
|
533
|
-
'type' in item &&
|
|
534
|
-
item.type === 'text')
|
|
535
|
-
.map((item) => item.text || '')
|
|
536
|
-
.join('\n');
|
|
537
|
-
}
|
|
538
|
-
else if (resultObj.text) {
|
|
539
|
-
resultStr = resultObj.text;
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
resultStr = JSON.stringify(result, null, 2);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
const maxChars = 400;
|
|
546
|
-
if (resultStr.length > maxChars) {
|
|
547
|
-
resultPreview = resultStr.slice(0, maxChars) + '\n...';
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
resultPreview = resultStr;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
catch {
|
|
555
|
-
resultPreview = '';
|
|
556
|
-
}
|
|
557
|
-
if (event.callId) {
|
|
558
|
-
const toolMessageId = `tool-${event.callId}`;
|
|
559
|
-
// Finalize tool message - move to messages with result and display data
|
|
560
|
-
finalizeMessage(toolMessageId, {
|
|
561
|
-
toolResult: resultPreview,
|
|
562
|
-
toolStatus: 'finished',
|
|
563
|
-
isError: !event.success,
|
|
564
|
-
...(toolDisplayData && { toolDisplayData }),
|
|
565
|
-
...(toolContent && { toolContent }),
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
// Handle plan_review tool results - update UI state when plan is approved
|
|
569
|
-
if (event.toolName === 'plan_review' && event.success !== false) {
|
|
570
|
-
try {
|
|
571
|
-
const planReviewResult = event.rawResult;
|
|
572
|
-
if (planReviewResult?.approved) {
|
|
573
|
-
// User approved the plan - disable plan mode
|
|
574
|
-
setUi((prev) => ({
|
|
575
|
-
...prev,
|
|
576
|
-
planModeActive: false,
|
|
577
|
-
planModeInitialized: false,
|
|
578
|
-
}));
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
catch {
|
|
582
|
-
// Silently ignore parsing errors - plan mode state remains unchanged
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
// Track tool result analytics
|
|
586
|
-
capture('dexto_tool_result', {
|
|
587
|
-
source: 'cli',
|
|
588
|
-
sessionId: event.sessionId,
|
|
589
|
-
toolName: event.toolName || 'unknown',
|
|
590
|
-
success: event.success !== false,
|
|
591
|
-
});
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
594
|
-
case 'llm:error': {
|
|
595
|
-
const errorContent = buildErrorContent(event.error, 'Error: ');
|
|
596
|
-
// Add error message to finalized
|
|
597
|
-
setMessages((prev) => [
|
|
598
|
-
...prev,
|
|
599
|
-
{
|
|
600
|
-
id: generateMessageId('error'),
|
|
601
|
-
role: 'system',
|
|
602
|
-
content: errorContent,
|
|
603
|
-
timestamp: new Date(),
|
|
604
|
-
},
|
|
605
|
-
]);
|
|
606
|
-
// Only stop processing for non-recoverable errors (fatal)
|
|
607
|
-
// Tool errors are recoverable - agent continues after them
|
|
608
|
-
if (event.recoverable !== true) {
|
|
609
|
-
// Cancel any streaming message in pending
|
|
610
|
-
if (state.messageId) {
|
|
611
|
-
removeFromPending(state.messageId);
|
|
612
|
-
state.messageId = null;
|
|
613
|
-
state.content = '';
|
|
614
|
-
}
|
|
615
|
-
// Clear any remaining pending messages
|
|
616
|
-
clearPending();
|
|
617
|
-
setUi((prev) => ({
|
|
618
|
-
...prev,
|
|
619
|
-
isProcessing: false,
|
|
620
|
-
isCancelling: false,
|
|
621
|
-
isThinking: false,
|
|
622
|
-
}));
|
|
623
|
-
}
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
case 'llm:unsupported-input': {
|
|
627
|
-
// Show warning for unsupported features (e.g., model doesn't support tool calling)
|
|
628
|
-
const warningContent = '⚠️ ' + event.errors.join('\n⚠️ ');
|
|
629
|
-
setMessages((prev) => [
|
|
630
|
-
...prev,
|
|
631
|
-
{
|
|
632
|
-
id: generateMessageId('warning'),
|
|
633
|
-
role: 'system',
|
|
634
|
-
content: warningContent,
|
|
635
|
-
timestamp: new Date(),
|
|
636
|
-
},
|
|
637
|
-
]);
|
|
638
|
-
break;
|
|
639
|
-
}
|
|
640
|
-
case 'run:complete': {
|
|
641
|
-
const { durationMs } = event;
|
|
642
|
-
// Total = lastInput + cumulativeOutput (avoids double-counting shared context)
|
|
643
|
-
const totalTokens = state.lastInputTokens + state.cumulativeOutputTokens;
|
|
644
|
-
// Ensure any remaining pending messages are finalized
|
|
645
|
-
finalizeAllPending();
|
|
646
|
-
// Add run summary message at the END (not inserted in middle)
|
|
647
|
-
// IMPORTANT: Ink's <Static> tracks rendered items by array position, not key.
|
|
648
|
-
// Inserting in the middle shifts existing items, causing them to re-render.
|
|
649
|
-
// Always append to avoid duplicate rendering.
|
|
650
|
-
if (durationMs > 0 || totalTokens > 0) {
|
|
651
|
-
const summaryMessage = {
|
|
652
|
-
id: generateMessageId('summary'),
|
|
653
|
-
role: 'system',
|
|
654
|
-
content: '', // Content rendered via styledType
|
|
655
|
-
timestamp: new Date(),
|
|
656
|
-
styledType: 'run-summary',
|
|
657
|
-
styledData: {
|
|
658
|
-
durationMs,
|
|
659
|
-
totalTokens,
|
|
660
|
-
},
|
|
661
|
-
};
|
|
662
|
-
setMessages((prev) => [...prev, summaryMessage]);
|
|
663
|
-
}
|
|
664
|
-
setUi((prev) => ({
|
|
665
|
-
...prev,
|
|
666
|
-
isProcessing: false,
|
|
667
|
-
isCancelling: false,
|
|
668
|
-
isThinking: false,
|
|
669
|
-
isCompacting: false,
|
|
670
|
-
}));
|
|
671
|
-
// Play completion sound to notify user task is done
|
|
672
|
-
options.soundService?.playCompleteSound();
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
case 'message:dequeued': {
|
|
676
|
-
// Queued message is being processed
|
|
677
|
-
// NOTE: llm:thinking only fires ONCE at the start of execute(),
|
|
678
|
-
// NOT when each queued message starts. So we must finalize here.
|
|
679
|
-
// 1. Finalize any pending from previous response
|
|
680
|
-
// This ensures the previous assistant response is in messages
|
|
681
|
-
// before we add the next user message
|
|
682
|
-
finalizeAllPending();
|
|
683
|
-
if (event.messages?.some((message) => message.kind === 'background')) {
|
|
684
|
-
const userText = event.messages
|
|
685
|
-
? formatQueuedMessagesForDisplay(event.messages)
|
|
686
|
-
: '';
|
|
687
|
-
if (userText) {
|
|
688
|
-
setMessages((prev) => [
|
|
689
|
-
...prev,
|
|
690
|
-
{
|
|
691
|
-
id: generateMessageId('user'),
|
|
692
|
-
role: 'user',
|
|
693
|
-
content: userText,
|
|
694
|
-
timestamp: new Date(),
|
|
695
|
-
},
|
|
696
|
-
]);
|
|
697
|
-
}
|
|
698
|
-
setQueuedMessages([]);
|
|
699
|
-
setUi((prev) => ({ ...prev, isProcessing: true }));
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
// 2. Add user message directly to messages (not buffer)
|
|
703
|
-
// The buffer approach doesn't work because llm:thinking
|
|
704
|
-
// doesn't fire between queued message runs
|
|
705
|
-
const textContent = extractTextContent(event.content);
|
|
706
|
-
if (textContent || event.content.length > 0) {
|
|
707
|
-
setMessages((prev) => [
|
|
708
|
-
...prev,
|
|
709
|
-
{
|
|
710
|
-
id: generateMessageId('user'),
|
|
711
|
-
role: 'user',
|
|
712
|
-
content: textContent || '[attachment]',
|
|
713
|
-
timestamp: new Date(),
|
|
714
|
-
},
|
|
715
|
-
]);
|
|
716
|
-
}
|
|
717
|
-
// Clear queue state - message was consumed
|
|
718
|
-
setQueuedMessages([]);
|
|
719
|
-
// Set processing state for the queued message run
|
|
720
|
-
setUi((prev) => ({ ...prev, isProcessing: true }));
|
|
721
|
-
break;
|
|
722
|
-
}
|
|
723
|
-
case 'tool:running': {
|
|
724
|
-
// Tool execution actually started (after approval if needed)
|
|
725
|
-
// Update status from 'pending' or 'pending_approval' to 'running'
|
|
726
|
-
const runningToolId = `tool-${event.toolCallId}`;
|
|
727
|
-
updatePendingStatus(runningToolId, 'running');
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
// Note: context:compacting and context:compacted are handled in useAgentEvents.ts
|
|
731
|
-
// as the single source of truth for both manual /compact and auto-compaction
|
|
732
|
-
case 'approval:request': {
|
|
733
|
-
// Handle approval requests in processStream (NOT useAgentEvents) to ensure
|
|
734
|
-
// proper ordering - text messages must be added BEFORE approval UI shows.
|
|
735
|
-
// This fixes a race condition where direct event bus subscription in
|
|
736
|
-
// useAgentEvents fired before the iterator processed llm:tool-call.
|
|
737
|
-
// Check for auto-approval of edit/write tools FIRST
|
|
738
|
-
// Read from ref to get latest value (may have changed mid-stream)
|
|
739
|
-
const autoApproveEdits = options.autoApproveEditsRef.current;
|
|
740
|
-
const { eventBus } = options;
|
|
741
|
-
if (autoApproveEdits && event.type === ApprovalTypeEnum.TOOL_APPROVAL) {
|
|
742
|
-
// Type is narrowed - metadata is now ToolApprovalMetadata
|
|
743
|
-
const { toolName, directoryAccess } = event.metadata;
|
|
744
|
-
const hasDirectoryAccess = typeof directoryAccess === 'object' && directoryAccess !== null;
|
|
745
|
-
if (!hasDirectoryAccess && isAutoApprovableInEditMode(toolName)) {
|
|
746
|
-
// Auto-approve immediately - emit response and let tool:running handle status
|
|
747
|
-
eventBus.emit('approval:response', {
|
|
748
|
-
approvalId: event.approvalId,
|
|
749
|
-
status: ApprovalStatus.APPROVED,
|
|
750
|
-
sessionId: event.sessionId,
|
|
751
|
-
data: {},
|
|
752
|
-
});
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
// Manual approval needed - update tool status to 'pending_approval'
|
|
757
|
-
// Extract toolCallId based on approval type
|
|
758
|
-
const toolCallId = event.type === ApprovalTypeEnum.TOOL_APPROVAL
|
|
759
|
-
? event.metadata.toolCallId
|
|
760
|
-
: undefined;
|
|
761
|
-
if (toolCallId) {
|
|
762
|
-
approvalIdToToolCallId.set(event.approvalId, toolCallId);
|
|
763
|
-
updatePendingStatus(`tool-${toolCallId}`, 'pending_approval');
|
|
764
|
-
}
|
|
765
|
-
// Show approval UI (moved from useAgentEvents for ordering)
|
|
766
|
-
if (event.type === ApprovalTypeEnum.TOOL_APPROVAL ||
|
|
767
|
-
event.type === ApprovalTypeEnum.COMMAND_CONFIRMATION ||
|
|
768
|
-
event.type === ApprovalTypeEnum.ELICITATION ||
|
|
769
|
-
event.type === ApprovalTypeEnum.DIRECTORY_ACCESS) {
|
|
770
|
-
const newApproval = {
|
|
771
|
-
approvalId: event.approvalId,
|
|
772
|
-
type: event.type,
|
|
773
|
-
timestamp: event.timestamp,
|
|
774
|
-
metadata: event.metadata,
|
|
775
|
-
};
|
|
776
|
-
if (event.sessionId !== undefined) {
|
|
777
|
-
newApproval.sessionId = event.sessionId;
|
|
778
|
-
}
|
|
779
|
-
if (event.timeout !== undefined) {
|
|
780
|
-
newApproval.timeout = event.timeout;
|
|
781
|
-
}
|
|
782
|
-
// Queue if there's already an approval, otherwise show immediately
|
|
783
|
-
setApproval((current) => {
|
|
784
|
-
if (current !== null) {
|
|
785
|
-
setApprovalQueue((queue) => [...queue, newApproval]);
|
|
786
|
-
return current;
|
|
787
|
-
}
|
|
788
|
-
setUi((prev) => ({ ...prev, activeOverlay: 'approval' }));
|
|
789
|
-
return newApproval;
|
|
790
|
-
});
|
|
791
|
-
// Play approval sound to notify user
|
|
792
|
-
options.soundService?.playApprovalSound();
|
|
793
|
-
}
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
case 'approval:response': {
|
|
797
|
-
// Handle approval responses.
|
|
798
|
-
//
|
|
799
|
-
// 1) Dismiss auto-approved parallel tool calls (existing behavior)
|
|
800
|
-
// 2) Finalize tool UI immediately for denied/cancelled approvals so tool
|
|
801
|
-
// messages don't remain stuck in "Waiting..." (pending_approval).
|
|
802
|
-
const { approvalId } = event;
|
|
803
|
-
const toolCallId = approvalIdToToolCallId.get(approvalId);
|
|
804
|
-
if (toolCallId) {
|
|
805
|
-
approvalIdToToolCallId.delete(approvalId);
|
|
806
|
-
// If the tool was waiting for approval and gets denied/cancelled,
|
|
807
|
-
// we may not get a corresponding llm:tool-result event (the tool never ran).
|
|
808
|
-
// Finalize it here so the UI reflects the outcome immediately.
|
|
809
|
-
if (event.status !== ApprovalStatus.APPROVED) {
|
|
810
|
-
finalizeMessage(`tool-${toolCallId}`, {
|
|
811
|
-
toolStatus: 'finished',
|
|
812
|
-
toolResult: 'Cancelled',
|
|
813
|
-
isError: true,
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
// Step 1: Remove from queue if present
|
|
818
|
-
setApprovalQueue((queue) => queue.filter((a) => a.approvalId !== approvalId));
|
|
819
|
-
// Step 2: If this is the current approval, dismiss and show next
|
|
820
|
-
// We use the same pattern as completeApproval in OverlayContainer:
|
|
821
|
-
// setApprovalQueue as coordinator, calling setApproval inside
|
|
822
|
-
setApproval((currentApproval) => {
|
|
823
|
-
if (currentApproval?.approvalId !== approvalId) {
|
|
824
|
-
return currentApproval; // Not current, nothing to do
|
|
825
|
-
}
|
|
826
|
-
// Current approval was responded to - show next or close
|
|
827
|
-
// Note: queue was already filtered in Step 1, so we read updated queue
|
|
828
|
-
setApprovalQueue((queue) => {
|
|
829
|
-
if (queue.length > 0) {
|
|
830
|
-
const [next, ...rest] = queue;
|
|
831
|
-
setApproval(next);
|
|
832
|
-
setUi((prev) => ({ ...prev, activeOverlay: 'approval' }));
|
|
833
|
-
return rest;
|
|
834
|
-
}
|
|
835
|
-
else {
|
|
836
|
-
setUi((prev) => ({ ...prev, activeOverlay: 'none' }));
|
|
837
|
-
return [];
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
return null; // Clear current while setApprovalQueue handles next
|
|
841
|
-
});
|
|
842
|
-
break;
|
|
843
|
-
}
|
|
844
|
-
case 'service:event': {
|
|
845
|
-
// Handle service events - extensible pattern for non-core services
|
|
846
|
-
debug.log('SERVICE-EVENT received', {
|
|
847
|
-
service: event.service,
|
|
848
|
-
eventType: event.event,
|
|
849
|
-
toolCallId: event.toolCallId,
|
|
850
|
-
sessionId: event.sessionId,
|
|
851
|
-
});
|
|
852
|
-
// Handle agent-spawner progress events
|
|
853
|
-
if (event.service === 'agent-spawner' && event.event === 'progress') {
|
|
854
|
-
const { toolCallId, data } = event;
|
|
855
|
-
// Guard against null/non-object data payloads
|
|
856
|
-
if (toolCallId && data && typeof data === 'object') {
|
|
857
|
-
// Update the tool message with sub-agent progress
|
|
858
|
-
const toolMessageId = `tool-${toolCallId}`;
|
|
859
|
-
const progressData = data;
|
|
860
|
-
debug.log('SERVICE-EVENT updating progress', {
|
|
861
|
-
toolMessageId,
|
|
862
|
-
toolsCalled: progressData.toolsCalled,
|
|
863
|
-
currentTool: progressData.currentTool,
|
|
864
|
-
tokenUsage: progressData.tokenUsage,
|
|
865
|
-
});
|
|
866
|
-
updatePending(toolMessageId, {
|
|
867
|
-
subAgentProgress: {
|
|
868
|
-
task: progressData.task,
|
|
869
|
-
agentId: progressData.agentId,
|
|
870
|
-
...(progressData.runtimeAgentId !== undefined && {
|
|
871
|
-
runtimeAgentId: progressData.runtimeAgentId,
|
|
872
|
-
}),
|
|
873
|
-
...(progressData.subAgentLogFilePath !== undefined && {
|
|
874
|
-
subAgentLogFilePath: progressData.subAgentLogFilePath,
|
|
875
|
-
}),
|
|
876
|
-
toolsCalled: progressData.toolsCalled,
|
|
877
|
-
currentTool: progressData.currentTool,
|
|
878
|
-
...(progressData.currentArgs && {
|
|
879
|
-
currentArgs: progressData.currentArgs,
|
|
880
|
-
}),
|
|
881
|
-
...(progressData.tokenUsage && {
|
|
882
|
-
tokenUsage: progressData.tokenUsage,
|
|
883
|
-
}),
|
|
884
|
-
},
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
// Handle todo update events
|
|
889
|
-
if (event.service === 'todo' && event.event === 'updated') {
|
|
890
|
-
const { data, sessionId } = event;
|
|
891
|
-
if (data && typeof data === 'object' && sessionId) {
|
|
892
|
-
const todoData = data;
|
|
893
|
-
if (!Array.isArray(todoData.todos)) {
|
|
894
|
-
debug.log('SERVICE-EVENT todo updated: invalid payload', {
|
|
895
|
-
sessionId,
|
|
896
|
-
});
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
debug.log('SERVICE-EVENT todo updated', {
|
|
900
|
-
sessionId,
|
|
901
|
-
todoCount: todoData.todos.length,
|
|
902
|
-
stats: todoData.stats,
|
|
903
|
-
});
|
|
904
|
-
// Update todos state via the setter passed in options
|
|
905
|
-
if (options.setTodos) {
|
|
906
|
-
options.setTodos(todoData.todos);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
break;
|
|
911
|
-
}
|
|
912
|
-
// Ignore other events
|
|
913
|
-
default:
|
|
914
|
-
break;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
catch (error) {
|
|
919
|
-
// Handle iterator errors (e.g., aborted)
|
|
920
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
921
|
-
// Expected when cancelled, clean up UI state
|
|
922
|
-
clearPending();
|
|
923
|
-
setUi((prev) => ({
|
|
924
|
-
...prev,
|
|
925
|
-
isProcessing: false,
|
|
926
|
-
isCancelling: false,
|
|
927
|
-
isThinking: false,
|
|
928
|
-
}));
|
|
929
|
-
}
|
|
930
|
-
else {
|
|
931
|
-
// Unexpected error, show to user
|
|
932
|
-
clearPending();
|
|
933
|
-
const errorContent = buildErrorContent(error, 'Stream error: ');
|
|
934
|
-
setMessages((prev) => [
|
|
935
|
-
...prev,
|
|
936
|
-
{
|
|
937
|
-
id: generateMessageId('error'),
|
|
938
|
-
role: 'system',
|
|
939
|
-
content: errorContent,
|
|
940
|
-
timestamp: new Date(),
|
|
941
|
-
},
|
|
942
|
-
]);
|
|
943
|
-
setUi((prev) => ({
|
|
944
|
-
...prev,
|
|
945
|
-
isProcessing: false,
|
|
946
|
-
isCancelling: false,
|
|
947
|
-
isThinking: false,
|
|
948
|
-
}));
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|