@stack-spot/ai-chat-widget 0.11.0 → 1.0.0-dev.1768324407795
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/CHANGELOG.md +972 -0
- package/README.md +1 -0
- package/dist/StackspotAIWidget.d.ts +48 -7
- package/dist/StackspotAIWidget.d.ts.map +1 -1
- package/dist/StackspotAIWidget.js +22 -23
- package/dist/StackspotAIWidget.js.map +1 -1
- package/dist/app-metadata.json +175 -0
- package/dist/assets/placeholder.png +0 -0
- package/dist/chat-interceptors/CustomInputs.d.ts +4 -1
- package/dist/chat-interceptors/CustomInputs.d.ts.map +1 -1
- package/dist/chat-interceptors/CustomInputs.js +10 -1
- package/dist/chat-interceptors/CustomInputs.js.map +1 -1
- package/dist/chat-interceptors/quick-command-questions.d.ts +10 -0
- package/dist/chat-interceptors/quick-command-questions.d.ts.map +1 -1
- package/dist/chat-interceptors/quick-command-questions.js +12 -2
- package/dist/chat-interceptors/quick-command-questions.js.map +1 -1
- package/dist/chat-interceptors/quick-commands.d.ts +11 -0
- package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
- package/dist/chat-interceptors/quick-commands.js +241 -48
- package/dist/chat-interceptors/quick-commands.js.map +1 -1
- package/dist/chat-interceptors/send-message.d.ts +26 -1
- package/dist/chat-interceptors/send-message.d.ts.map +1 -1
- package/dist/chat-interceptors/send-message.js +227 -26
- package/dist/chat-interceptors/send-message.js.map +1 -1
- package/dist/components/AdaptiveTextArea.d.ts +15 -3
- package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
- package/dist/components/AdaptiveTextArea.js +22 -10
- package/dist/components/AdaptiveTextArea.js.map +1 -1
- package/dist/components/AgentCard/AgentCardCreate.d.ts +4 -0
- package/dist/components/AgentCard/AgentCardCreate.d.ts.map +1 -0
- package/dist/components/AgentCard/AgentCardCreate.js +33 -0
- package/dist/components/AgentCard/AgentCardCreate.js.map +1 -0
- package/dist/components/AgentCard/dictionary.d.ts +23 -0
- package/dist/components/AgentCard/dictionary.d.ts.map +1 -0
- package/dist/components/AgentCard/dictionary.js +23 -0
- package/dist/components/AgentCard/dictionary.js.map +1 -0
- package/dist/components/AgentCard/index.d.ts +5 -0
- package/dist/components/AgentCard/index.d.ts.map +1 -0
- package/dist/components/AgentCard/index.js +55 -0
- package/dist/components/AgentCard/index.js.map +1 -0
- package/dist/components/AnimatedOpacity.d.ts +8 -0
- package/dist/components/AnimatedOpacity.d.ts.map +1 -0
- package/dist/components/AnimatedOpacity.js +46 -0
- package/dist/components/AnimatedOpacity.js.map +1 -0
- package/dist/components/AutoFocus.d.ts +23 -0
- package/dist/components/AutoFocus.d.ts.map +1 -0
- package/dist/components/AutoFocus.js +23 -0
- package/dist/components/AutoFocus.js.map +1 -0
- package/dist/components/ButtonFavorite.d.ts +40 -0
- package/dist/components/ButtonFavorite.d.ts.map +1 -0
- package/dist/components/ButtonFavorite.js +25 -0
- package/dist/components/ButtonFavorite.js.map +1 -0
- package/dist/components/Code.d.ts +2 -1
- package/dist/components/Code.d.ts.map +1 -1
- package/dist/components/Code.js +52 -24
- package/dist/components/Code.js.map +1 -1
- package/dist/components/ComponentNavigator.d.ts +38 -0
- package/dist/components/ComponentNavigator.d.ts.map +1 -0
- package/dist/components/ComponentNavigator.js +31 -0
- package/dist/components/ComponentNavigator.js.map +1 -0
- package/dist/components/Fading.d.ts +32 -0
- package/dist/components/Fading.d.ts.map +1 -0
- package/dist/components/Fading.js +33 -0
- package/dist/components/Fading.js.map +1 -0
- package/dist/components/FadingOverflow.d.ts +25 -0
- package/dist/components/FadingOverflow.d.ts.map +1 -1
- package/dist/components/FadingOverflow.js +16 -8
- package/dist/components/FadingOverflow.js.map +1 -1
- package/dist/components/FileDescription.d.ts +10 -0
- package/dist/components/FileDescription.d.ts.map +1 -0
- package/dist/components/FileDescription.js +84 -0
- package/dist/components/FileDescription.js.map +1 -0
- package/dist/components/HistoryList.d.ts +15 -0
- package/dist/components/HistoryList.d.ts.map +1 -1
- package/dist/components/HistoryList.js +6 -2
- package/dist/components/HistoryList.js.map +1 -1
- package/dist/components/ListResource.d.ts +29 -0
- package/dist/components/ListResource.d.ts.map +1 -0
- package/dist/components/ListResource.js +17 -0
- package/dist/components/ListResource.js.map +1 -0
- package/dist/components/Markdown.d.ts.map +1 -1
- package/dist/components/Markdown.js +2 -2
- package/dist/components/Markdown.js.map +1 -1
- package/dist/components/Modal.d.ts +9 -0
- package/dist/components/Modal.d.ts.map +1 -0
- package/dist/components/Modal.js +56 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/QuickStartButton.d.ts +2 -4
- package/dist/components/QuickStartButton.d.ts.map +1 -1
- package/dist/components/QuickStartButton.js +7 -39
- package/dist/components/QuickStartButton.js.map +1 -1
- package/dist/components/RightPanelContentList.d.ts +10 -0
- package/dist/components/RightPanelContentList.d.ts.map +1 -0
- package/dist/components/RightPanelContentList.js +7 -0
- package/dist/components/RightPanelContentList.js.map +1 -0
- package/dist/components/RightPanelForm.d.ts +3 -0
- package/dist/components/RightPanelForm.d.ts.map +1 -1
- package/dist/components/RightPanelForm.js +57 -17
- package/dist/components/RightPanelForm.js.map +1 -1
- package/dist/components/RightPanelTabs.d.ts +4 -4
- package/dist/components/RightPanelTabs.d.ts.map +1 -1
- package/dist/components/RightPanelTabs.js +7 -16
- package/dist/components/RightPanelTabs.js.map +1 -1
- package/dist/components/Selector/index.d.ts +54 -0
- package/dist/components/Selector/index.d.ts.map +1 -0
- package/dist/components/Selector/index.js +143 -0
- package/dist/components/Selector/index.js.map +1 -0
- package/dist/components/Selector/styled.d.ts +4 -0
- package/dist/components/Selector/styled.d.ts.map +1 -0
- package/dist/components/Selector/styled.js +157 -0
- package/dist/components/Selector/styled.js.map +1 -0
- package/dist/components/StackedBadge.d.ts +14 -0
- package/dist/components/StackedBadge.d.ts.map +1 -0
- package/dist/components/StackedBadge.js +56 -0
- package/dist/components/StackedBadge.js.map +1 -0
- package/dist/components/TabManager.d.ts +6 -0
- package/dist/components/TabManager.d.ts.map +1 -1
- package/dist/components/TabManager.js +16 -28
- package/dist/components/TabManager.js.map +1 -1
- package/dist/components/ToolBadge.d.ts +9 -0
- package/dist/components/ToolBadge.d.ts.map +1 -0
- package/dist/components/ToolBadge.js +34 -0
- package/dist/components/ToolBadge.js.map +1 -0
- package/dist/components/WorkspaceTabNavigator.d.ts +17 -0
- package/dist/components/WorkspaceTabNavigator.d.ts.map +1 -0
- package/dist/components/WorkspaceTabNavigator.js +93 -0
- package/dist/components/WorkspaceTabNavigator.js.map +1 -0
- package/dist/components/form/DescribedCheckboxGroup.d.ts +30 -2
- package/dist/components/form/DescribedCheckboxGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedCheckboxGroup.js +75 -21
- package/dist/components/form/DescribedCheckboxGroup.js.map +1 -1
- package/dist/components/form/DescribedRadioGroup.d.ts +31 -2
- package/dist/components/form/DescribedRadioGroup.d.ts.map +1 -1
- package/dist/components/form/DescribedRadioGroup.js +65 -16
- package/dist/components/form/DescribedRadioGroup.js.map +1 -1
- package/dist/components/form/dictionary.d.ts +19 -0
- package/dist/components/form/dictionary.d.ts.map +1 -0
- package/dist/components/form/dictionary.js +19 -0
- package/dist/components/form/dictionary.js.map +1 -0
- package/dist/components/form/styled.d.ts.map +1 -1
- package/dist/components/form/styled.js +1 -2
- package/dist/components/form/styled.js.map +1 -1
- package/dist/components/form/types.d.ts +42 -0
- package/dist/components/form/types.d.ts.map +1 -1
- package/dist/context/AIWidgetProvider.d.ts +19 -0
- package/dist/context/AIWidgetProvider.d.ts.map +1 -1
- package/dist/context/AIWidgetProvider.js +19 -0
- package/dist/context/AIWidgetProvider.js.map +1 -1
- package/dist/context/hooks.d.ts +61 -4
- package/dist/context/hooks.d.ts.map +1 -1
- package/dist/context/hooks.js +83 -13
- package/dist/context/hooks.js.map +1 -1
- package/dist/features.d.ts +72 -10
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +23 -8
- package/dist/features.js.map +1 -1
- package/dist/hooks/midnight-update-view.d.ts +5 -0
- package/dist/hooks/midnight-update-view.d.ts.map +1 -0
- package/dist/hooks/midnight-update-view.js +30 -0
- package/dist/hooks/midnight-update-view.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/layout.css +95 -28
- package/dist/regex.d.ts +3 -0
- package/dist/regex.d.ts.map +1 -0
- package/dist/regex.js +3 -0
- package/dist/regex.js.map +1 -0
- package/dist/right-panel/DefaultPanel.d.ts +3 -0
- package/dist/right-panel/DefaultPanel.d.ts.map +1 -1
- package/dist/right-panel/DefaultPanel.js +5 -4
- package/dist/right-panel/DefaultPanel.js.map +1 -1
- package/dist/right-panel/RightPanel.d.ts +3 -0
- package/dist/right-panel/RightPanel.d.ts.map +1 -1
- package/dist/right-panel/RightPanel.js +3 -0
- package/dist/right-panel/RightPanel.js.map +1 -1
- package/dist/right-panel/RightPanelProvider.d.ts +15 -0
- package/dist/right-panel/RightPanelProvider.d.ts.map +1 -1
- package/dist/right-panel/RightPanelProvider.js.map +1 -1
- package/dist/right-panel/constants.d.ts +2 -0
- package/dist/right-panel/constants.d.ts.map +1 -0
- package/dist/right-panel/constants.js +2 -0
- package/dist/right-panel/constants.js.map +1 -0
- package/dist/right-panel/hooks.d.ts +6 -0
- package/dist/right-panel/hooks.d.ts.map +1 -1
- package/dist/right-panel/hooks.js +8 -1
- package/dist/right-panel/hooks.js.map +1 -1
- package/dist/state/ChatEntry.d.ts +182 -8
- package/dist/state/ChatEntry.d.ts.map +1 -1
- package/dist/state/ChatEntry.js +26 -3
- package/dist/state/ChatEntry.js.map +1 -1
- package/dist/state/ChatState.d.ts +116 -14
- package/dist/state/ChatState.d.ts.map +1 -1
- package/dist/state/ChatState.js +49 -8
- package/dist/state/ChatState.js.map +1 -1
- package/dist/state/ChatTabsController.d.ts +50 -1
- package/dist/state/ChatTabsController.d.ts.map +1 -1
- package/dist/state/ChatTabsController.js +77 -8
- package/dist/state/ChatTabsController.js.map +1 -1
- package/dist/state/ObservableState.d.ts +14 -0
- package/dist/state/ObservableState.d.ts.map +1 -1
- package/dist/state/ObservableState.js +14 -0
- package/dist/state/ObservableState.js.map +1 -1
- package/dist/state/WidgetState.d.ts +62 -2
- package/dist/state/WidgetState.d.ts.map +1 -1
- package/dist/state/WidgetState.js +49 -2
- package/dist/state/WidgetState.js.map +1 -1
- package/dist/state/constants.d.ts +5 -0
- package/dist/state/constants.d.ts.map +1 -0
- package/dist/state/constants.js +10 -0
- package/dist/state/constants.js.map +1 -0
- package/dist/state/types.d.ts +10 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/types.d.ts +20 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/chat.d.ts +11 -4
- package/dist/utils/chat.d.ts.map +1 -1
- package/dist/utils/chat.js +13 -11
- package/dist/utils/chat.js.map +1 -1
- package/dist/utils/check-is-trial.d.ts +2 -0
- package/dist/utils/check-is-trial.d.ts.map +1 -0
- package/dist/utils/check-is-trial.js +6 -0
- package/dist/utils/check-is-trial.js.map +1 -0
- package/dist/utils/copy-to-clipboard.d.ts +6 -0
- package/dist/utils/copy-to-clipboard.d.ts.map +1 -0
- package/dist/utils/copy-to-clipboard.js +30 -0
- package/dist/utils/copy-to-clipboard.js.map +1 -0
- package/dist/utils/date.d.ts +26 -2
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +28 -3
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/download.d.ts +5 -0
- package/dist/utils/download.d.ts.map +1 -1
- package/dist/utils/download.js +5 -0
- package/dist/utils/download.js.map +1 -1
- package/dist/utils/error.d.ts +2 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +54 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/knowledge-source.d.ts +12 -2
- package/dist/utils/knowledge-source.d.ts.map +1 -1
- package/dist/utils/knowledge-source.js +16 -0
- package/dist/utils/knowledge-source.js.map +1 -1
- package/dist/utils/planning-tool.d.ts +17 -0
- package/dist/utils/planning-tool.d.ts.map +1 -0
- package/dist/utils/planning-tool.js +32 -0
- package/dist/utils/planning-tool.js.map +1 -0
- package/dist/utils/programming-languages.d.ts.map +1 -1
- package/dist/utils/programming-languages.js +10 -0
- package/dist/utils/programming-languages.js.map +1 -1
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js +5 -1
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/tools.d.ts +23 -0
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +23 -0
- package/dist/utils/tools.js.map +1 -0
- package/dist/utils/update-tool-step.d.ts +3 -0
- package/dist/utils/update-tool-step.d.ts.map +1 -0
- package/dist/utils/update-tool-step.js +23 -0
- package/dist/utils/update-tool-step.js.map +1 -0
- package/dist/utils/upload/FileUpload.d.ts +21 -0
- package/dist/utils/upload/FileUpload.d.ts.map +1 -0
- package/dist/utils/upload/FileUpload.js +54 -0
- package/dist/utils/upload/FileUpload.js.map +1 -0
- package/dist/utils/upload/UploadManager.d.ts +42 -0
- package/dist/utils/upload/UploadManager.d.ts.map +1 -0
- package/dist/utils/upload/UploadManager.js +138 -0
- package/dist/utils/upload/UploadManager.js.map +1 -0
- package/dist/utils/upload/context.d.ts +15 -0
- package/dist/utils/upload/context.d.ts.map +1 -0
- package/dist/utils/upload/context.js +37 -0
- package/dist/utils/upload/context.js.map +1 -0
- package/dist/utils/upload/errors.d.ts +17 -0
- package/dist/utils/upload/errors.d.ts.map +1 -0
- package/dist/utils/upload/errors.js +27 -0
- package/dist/utils/upload/errors.js.map +1 -0
- package/dist/utils/upload/types.d.ts +7 -0
- package/dist/utils/upload/types.d.ts.map +1 -0
- package/dist/{components/Tooltip → utils/upload}/types.js.map +1 -1
- package/dist/utils/upload/use-paste-upload.d.ts +8 -0
- package/dist/utils/upload/use-paste-upload.d.ts.map +1 -0
- package/dist/utils/upload/use-paste-upload.js +19 -0
- package/dist/utils/upload/use-paste-upload.js.map +1 -0
- package/dist/utils/upload/utils.d.ts +4 -0
- package/dist/utils/upload/utils.d.ts.map +1 -0
- package/dist/utils/upload/utils.js +10 -0
- package/dist/utils/upload/utils.js.map +1 -0
- package/dist/utils/url.d.ts +2 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +8 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/views/Agents/AgentDescription.d.ts +4 -0
- package/dist/views/Agents/AgentDescription.d.ts.map +1 -0
- package/dist/views/Agents/AgentDescription.js +38 -0
- package/dist/views/Agents/AgentDescription.js.map +1 -0
- package/dist/views/Agents/AgentsPanel.d.ts +5 -0
- package/dist/views/Agents/AgentsPanel.d.ts.map +1 -0
- package/dist/views/Agents/AgentsPanel.js +45 -0
- package/dist/views/Agents/AgentsPanel.js.map +1 -0
- package/dist/views/Agents/AgentsTab.d.ts +11 -0
- package/dist/views/Agents/AgentsTab.d.ts.map +1 -0
- package/dist/views/Agents/AgentsTab.js +82 -0
- package/dist/views/Agents/AgentsTab.js.map +1 -0
- package/dist/views/Agents/dictionary.d.ts +2 -0
- package/dist/views/Agents/dictionary.d.ts.map +1 -0
- package/dist/views/Agents/dictionary.js +43 -0
- package/dist/views/Agents/dictionary.js.map +1 -0
- package/dist/views/Agents/index.d.ts +5 -0
- package/dist/views/Agents/index.d.ts.map +1 -0
- package/dist/views/Agents/index.js +21 -0
- package/dist/views/Agents/index.js.map +1 -0
- package/dist/views/Agents/styled.d.ts +3 -0
- package/dist/views/Agents/styled.d.ts.map +1 -0
- package/dist/views/Agents/styled.js +68 -0
- package/dist/views/Agents/styled.js.map +1 -0
- package/dist/views/Agents/useAgentFavorites.d.ts +8 -0
- package/dist/views/Agents/useAgentFavorites.d.ts.map +1 -0
- package/dist/views/Agents/useAgentFavorites.js +59 -0
- package/dist/views/Agents/useAgentFavorites.js.map +1 -0
- package/dist/views/Chat/AgentInfo.d.ts +5 -1
- package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
- package/dist/views/Chat/AgentInfo.js +6 -5
- package/dist/views/Chat/AgentInfo.js.map +1 -1
- package/dist/views/Chat/ButtonExecutionDetail.d.ts +5 -0
- package/dist/views/Chat/ButtonExecutionDetail.d.ts.map +1 -0
- package/dist/views/Chat/ButtonExecutionDetail.js +34 -0
- package/dist/views/Chat/ButtonExecutionDetail.js.map +1 -0
- package/dist/views/Chat/ChatMessage.d.ts +56 -4
- package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessage.js +160 -24
- package/dist/views/Chat/ChatMessage.js.map +1 -1
- package/dist/views/Chat/ChatMessages.d.ts +6 -2
- package/dist/views/Chat/ChatMessages.d.ts.map +1 -1
- package/dist/views/Chat/ChatMessages.js +5 -2
- package/dist/views/Chat/ChatMessages.js.map +1 -1
- package/dist/views/Chat/StepsList.d.ts +14 -0
- package/dist/views/Chat/StepsList.d.ts.map +1 -0
- package/dist/views/Chat/StepsList.js +192 -0
- package/dist/views/Chat/StepsList.js.map +1 -0
- package/dist/views/Chat/chat-scroll.d.ts +1 -1
- package/dist/views/Chat/chat-scroll.js +1 -1
- package/dist/views/Chat/events.d.ts +22 -0
- package/dist/views/Chat/events.d.ts.map +1 -0
- package/dist/views/Chat/events.js +67 -0
- package/dist/views/Chat/events.js.map +1 -0
- package/dist/views/Chat/index.d.ts +9 -2
- package/dist/views/Chat/index.d.ts.map +1 -1
- package/dist/views/Chat/index.js +5 -2
- package/dist/views/Chat/index.js.map +1 -1
- package/dist/views/Chat/styled.d.ts +3 -1
- package/dist/views/Chat/styled.d.ts.map +1 -1
- package/dist/views/Chat/styled.js +152 -31
- package/dist/views/Chat/styled.js.map +1 -1
- package/dist/views/ChatHistory/ChatHistoryPanel.d.ts +4 -4
- package/dist/views/ChatHistory/ChatHistoryPanel.d.ts.map +1 -1
- package/dist/views/ChatHistory/ChatHistoryPanel.js +6 -2
- package/dist/views/ChatHistory/ChatHistoryPanel.js.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.d.ts +4 -3
- package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
- package/dist/views/ChatHistory/HistoryItem.js +16 -37
- package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
- package/dist/views/ChatHistory/dictionary.d.ts +1 -1
- package/dist/views/ChatHistory/index.d.ts +4 -4
- package/dist/views/ChatHistory/index.d.ts.map +1 -1
- package/dist/views/ChatHistory/index.js +6 -3
- package/dist/views/ChatHistory/index.js.map +1 -1
- package/dist/views/ChatHistory/styled.d.ts.map +1 -1
- package/dist/views/ChatHistory/styled.js +3 -5
- package/dist/views/ChatHistory/styled.js.map +1 -1
- package/dist/views/ChatHistory/utils.d.ts +17 -2
- package/dist/views/ChatHistory/utils.d.ts.map +1 -1
- package/dist/views/ChatHistory/utils.js +140 -9
- package/dist/views/ChatHistory/utils.js.map +1 -1
- package/dist/views/ChatTabSelection.d.ts +6 -4
- package/dist/views/ChatTabSelection.d.ts.map +1 -1
- package/dist/views/ChatTabSelection.js +40 -15
- package/dist/views/ChatTabSelection.js.map +1 -1
- package/dist/views/Editor.d.ts +3 -0
- package/dist/views/Editor.d.ts.map +1 -1
- package/dist/views/Editor.js +23 -16
- package/dist/views/Editor.js.map +1 -1
- package/dist/views/Home/BuiltInAgent.d.ts +6 -0
- package/dist/views/Home/BuiltInAgent.d.ts.map +1 -0
- package/dist/views/Home/BuiltInAgent.js +37 -0
- package/dist/views/Home/BuiltInAgent.js.map +1 -0
- package/dist/views/Home/CustomAgent.d.ts +5 -0
- package/dist/views/Home/CustomAgent.d.ts.map +1 -0
- package/dist/views/Home/CustomAgent.js +23 -0
- package/dist/views/Home/CustomAgent.js.map +1 -0
- package/dist/views/Home/index.d.ts +8 -0
- package/dist/views/Home/index.d.ts.map +1 -0
- package/dist/views/Home/index.js +34 -0
- package/dist/views/Home/index.js.map +1 -0
- package/dist/views/Home/styled.d.ts +2 -0
- package/dist/views/Home/styled.d.ts.map +1 -0
- package/dist/views/Home/styled.js +74 -0
- package/dist/views/Home/styled.js.map +1 -0
- package/dist/views/Home/types.d.ts +16 -0
- package/dist/views/Home/types.d.ts.map +1 -0
- package/dist/views/Home/types.js +2 -0
- package/dist/views/Home/types.js.map +1 -0
- package/dist/views/KSDocument.d.ts +3 -0
- package/dist/views/KSDocument.d.ts.map +1 -1
- package/dist/views/KSDocument.js +7 -4
- package/dist/views/KSDocument.js.map +1 -1
- package/dist/views/KnowledgeSources.d.ts +12 -0
- package/dist/views/KnowledgeSources.d.ts.map +1 -1
- package/dist/views/KnowledgeSources.js +123 -33
- package/dist/views/KnowledgeSources.js.map +1 -1
- package/dist/views/MessageInput/AgentSelector.d.ts +5 -0
- package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -0
- package/dist/views/MessageInput/AgentSelector.js +66 -0
- package/dist/views/MessageInput/AgentSelector.js.map +1 -0
- package/dist/views/MessageInput/ButtonAgent.d.ts +2 -0
- package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -0
- package/dist/views/MessageInput/ButtonAgent.js +35 -0
- package/dist/views/MessageInput/ButtonAgent.js.map +1 -0
- package/dist/views/MessageInput/ButtonBar.d.ts +13 -0
- package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -0
- package/dist/views/MessageInput/ButtonBar.js +15 -0
- package/dist/views/MessageInput/ButtonBar.js.map +1 -0
- package/dist/views/MessageInput/ContextBar.d.ts +9 -0
- package/dist/views/MessageInput/ContextBar.d.ts.map +1 -0
- package/dist/views/MessageInput/ContextBar.js +51 -0
- package/dist/views/MessageInput/ContextBar.js.map +1 -0
- package/dist/views/MessageInput/ModelSwitcher/index.d.ts +2 -0
- package/dist/views/MessageInput/ModelSwitcher/index.d.ts.map +1 -0
- package/dist/views/MessageInput/ModelSwitcher/index.js +25 -0
- package/dist/views/MessageInput/ModelSwitcher/index.js.map +1 -0
- package/dist/views/MessageInput/ModelSwitcher/utils.d.ts +30 -0
- package/dist/views/MessageInput/ModelSwitcher/utils.d.ts.map +1 -0
- package/dist/views/MessageInput/ModelSwitcher/utils.js +91 -0
- package/dist/views/MessageInput/ModelSwitcher/utils.js.map +1 -0
- package/dist/views/MessageInput/QuickCommandSelector.d.ts +5 -0
- package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -0
- package/dist/views/MessageInput/QuickCommandSelector.js +104 -0
- package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -0
- package/dist/views/MessageInput/SelectContent.d.ts +2 -0
- package/dist/views/MessageInput/SelectContent.d.ts.map +1 -0
- package/dist/views/MessageInput/SelectContent.js +84 -0
- package/dist/views/MessageInput/SelectContent.js.map +1 -0
- package/dist/views/MessageInput/UploadBar.d.ts +2 -0
- package/dist/views/MessageInput/UploadBar.d.ts.map +1 -0
- package/dist/views/MessageInput/UploadBar.js +74 -0
- package/dist/views/MessageInput/UploadBar.js.map +1 -0
- package/dist/views/MessageInput/UploadDragNDrop.d.ts +14 -0
- package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -0
- package/dist/views/MessageInput/UploadDragNDrop.js +51 -0
- package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -0
- package/dist/views/MessageInput/chat-entry-history.d.ts +11 -0
- package/dist/views/MessageInput/chat-entry-history.d.ts.map +1 -0
- package/dist/views/MessageInput/chat-entry-history.js +78 -0
- package/dist/views/MessageInput/chat-entry-history.js.map +1 -0
- package/dist/views/MessageInput/dictionary.d.ts +1 -1
- package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
- package/dist/views/MessageInput/dictionary.js +52 -10
- package/dist/views/MessageInput/dictionary.js.map +1 -1
- package/dist/views/MessageInput/index.d.ts +9 -6
- package/dist/views/MessageInput/index.d.ts.map +1 -1
- package/dist/views/MessageInput/index.js +112 -20
- package/dist/views/MessageInput/index.js.map +1 -1
- package/dist/views/MessageInput/styled.d.ts +13 -1
- package/dist/views/MessageInput/styled.d.ts.map +1 -1
- package/dist/views/MessageInput/styled.js +223 -85
- package/dist/views/MessageInput/styled.js.map +1 -1
- package/dist/views/MinimizedHeader.d.ts +4 -0
- package/dist/views/MinimizedHeader.d.ts.map +1 -1
- package/dist/views/MinimizedHeader.js +9 -7
- package/dist/views/MinimizedHeader.js.map +1 -1
- package/dist/views/Resources.d.ts +2 -0
- package/dist/views/Resources.d.ts.map +1 -0
- package/dist/views/Resources.js +69 -0
- package/dist/views/Resources.js.map +1 -0
- package/dist/views/Stacks.d.ts +12 -0
- package/dist/views/Stacks.d.ts.map +1 -1
- package/dist/views/Stacks.js +117 -21
- package/dist/views/Stacks.js.map +1 -1
- package/dist/views/Steps/FlowChart/HandleGroup.d.ts +10 -0
- package/dist/views/Steps/FlowChart/HandleGroup.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/HandleGroup.js +4 -0
- package/dist/views/Steps/FlowChart/HandleGroup.js.map +1 -0
- package/dist/views/Steps/FlowChart/NodeDynamic.d.ts +15 -0
- package/dist/views/Steps/FlowChart/NodeDynamic.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/NodeDynamic.js +41 -0
- package/dist/views/Steps/FlowChart/NodeDynamic.js.map +1 -0
- package/dist/views/Steps/FlowChart/NodeStep.d.ts +10 -0
- package/dist/views/Steps/FlowChart/NodeStep.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/NodeStep.js +13 -0
- package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -0
- package/dist/views/Steps/FlowChart/hooks.d.ts +7 -0
- package/dist/views/Steps/FlowChart/hooks.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/hooks.js +31 -0
- package/dist/views/Steps/FlowChart/hooks.js.map +1 -0
- package/dist/views/Steps/FlowChart/index.d.ts +12 -0
- package/dist/views/Steps/FlowChart/index.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/index.js +78 -0
- package/dist/views/Steps/FlowChart/index.js.map +1 -0
- package/dist/views/Steps/FlowChart/layout.d.ts +8 -0
- package/dist/views/Steps/FlowChart/layout.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/layout.js +59 -0
- package/dist/views/Steps/FlowChart/layout.js.map +1 -0
- package/dist/views/Steps/FlowChart/styled.d.ts +14 -0
- package/dist/views/Steps/FlowChart/styled.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/styled.js +156 -0
- package/dist/views/Steps/FlowChart/styled.js.map +1 -0
- package/dist/views/Steps/FlowChart/types.d.ts +25 -0
- package/dist/views/Steps/FlowChart/types.d.ts.map +1 -0
- package/dist/views/Steps/FlowChart/types.js +2 -0
- package/dist/views/Steps/FlowChart/types.js.map +1 -0
- package/dist/views/Steps/StepModal.d.ts +10 -0
- package/dist/views/Steps/StepModal.d.ts.map +1 -0
- package/dist/views/Steps/StepModal.js +139 -0
- package/dist/views/Steps/StepModal.js.map +1 -0
- package/dist/views/Steps/StepsPanel.d.ts +6 -0
- package/dist/views/Steps/StepsPanel.d.ts.map +1 -0
- package/dist/views/Steps/StepsPanel.js +18 -0
- package/dist/views/Steps/StepsPanel.js.map +1 -0
- package/dist/views/Steps/dictionary.d.ts +43 -0
- package/dist/views/Steps/dictionary.d.ts.map +1 -0
- package/dist/views/Steps/dictionary.js +45 -0
- package/dist/views/Steps/dictionary.js.map +1 -0
- package/dist/views/Steps/index.d.ts +5 -0
- package/dist/views/Steps/index.d.ts.map +1 -0
- package/dist/views/Steps/index.js +30 -0
- package/dist/views/Steps/index.js.map +1 -0
- package/dist/views/Steps/utils.d.ts +7 -0
- package/dist/views/Steps/utils.d.ts.map +1 -0
- package/dist/views/Steps/utils.js +32 -0
- package/dist/views/Steps/utils.js.map +1 -0
- package/dist/views/Tools.d.ts +2 -0
- package/dist/views/Tools.d.ts.map +1 -0
- package/dist/views/Tools.js +53 -0
- package/dist/views/Tools.js.map +1 -0
- package/dist/views/Workspaces/WorkspacesTab.d.ts +20 -0
- package/dist/views/Workspaces/WorkspacesTab.d.ts.map +1 -0
- package/dist/views/Workspaces/WorkspacesTab.js +61 -0
- package/dist/views/Workspaces/WorkspacesTab.js.map +1 -0
- package/dist/views/Workspaces/index.d.ts +5 -0
- package/dist/views/Workspaces/index.d.ts.map +1 -0
- package/dist/views/Workspaces/index.js +69 -0
- package/dist/views/Workspaces/index.js.map +1 -0
- package/package.dev.json +3 -0
- package/package.json +21 -13
- package/package.stg.json +4 -0
- package/src/StackspotAIWidget.tsx +96 -37
- package/src/app-metadata.json +175 -0
- package/src/assets/placeholder.png +0 -0
- package/src/chat-interceptors/CustomInputs.ts +14 -1
- package/src/chat-interceptors/quick-command-questions.ts +12 -2
- package/src/chat-interceptors/quick-commands.ts +286 -52
- package/src/chat-interceptors/send-message.ts +253 -25
- package/src/components/AdaptiveTextArea.tsx +36 -11
- package/src/components/AgentCard/AgentCardCreate.tsx +42 -0
- package/src/components/AgentCard/dictionary.ts +25 -0
- package/src/components/AgentCard/index.tsx +82 -0
- package/src/components/AnimatedOpacity.tsx +55 -0
- package/src/components/AutoFocus.tsx +42 -0
- package/src/components/ButtonFavorite.tsx +78 -0
- package/src/components/Code.tsx +94 -59
- package/src/components/ComponentNavigator.tsx +99 -0
- package/src/components/Fading.tsx +66 -0
- package/src/components/FadingOverflow.tsx +39 -12
- package/src/components/FileDescription.tsx +118 -0
- package/src/components/HistoryList.tsx +19 -2
- package/src/components/ListResource.tsx +60 -0
- package/src/components/Markdown.tsx +2 -1
- package/src/components/Modal.tsx +85 -0
- package/src/components/QuickStartButton.tsx +15 -47
- package/src/components/RightPanelContentList.tsx +15 -0
- package/src/components/RightPanelForm.tsx +64 -22
- package/src/components/RightPanelTabs.tsx +7 -32
- package/src/components/Selector/index.tsx +312 -0
- package/src/components/Selector/styled.ts +158 -0
- package/src/components/StackedBadge.tsx +77 -0
- package/src/components/TabManager.tsx +36 -36
- package/src/components/ToolBadge.tsx +67 -0
- package/src/components/WorkspaceTabNavigator.tsx +172 -0
- package/src/components/form/DescribedCheckboxGroup.tsx +135 -33
- package/src/components/form/DescribedRadioGroup.tsx +136 -32
- package/src/components/form/dictionary.ts +18 -0
- package/src/components/form/styled.ts +1 -2
- package/src/components/form/types.ts +45 -1
- package/src/context/AIWidgetProvider.tsx +19 -0
- package/src/context/hooks.ts +86 -16
- package/src/features.ts +90 -16
- package/src/hooks/midnight-update-view.ts +36 -0
- package/src/images.d.ts +5 -0
- package/src/index.ts +16 -0
- package/src/layout.css +95 -28
- package/src/regex.ts +2 -0
- package/src/right-panel/DefaultPanel.tsx +7 -7
- package/src/right-panel/RightPanel.tsx +3 -0
- package/src/right-panel/RightPanelProvider.tsx +15 -0
- package/src/right-panel/constants.ts +1 -0
- package/src/right-panel/hooks.tsx +8 -1
- package/src/state/ChatEntry.ts +189 -9
- package/src/state/ChatState.ts +131 -14
- package/src/state/ChatTabsController.ts +78 -8
- package/src/state/ObservableState.ts +14 -0
- package/src/state/WidgetState.ts +86 -3
- package/src/state/constants.ts +13 -0
- package/src/state/types.ts +12 -1
- package/src/types.ts +21 -4
- package/src/utils/chat.ts +15 -14
- package/src/utils/check-is-trial.ts +6 -0
- package/src/utils/copy-to-clipboard.ts +29 -0
- package/src/utils/date.ts +28 -4
- package/src/utils/download.ts +5 -0
- package/src/utils/error.ts +56 -0
- package/src/utils/knowledge-source.ts +18 -2
- package/src/utils/planning-tool.ts +41 -0
- package/src/utils/programming-languages.ts +10 -0
- package/src/utils/string.ts +5 -1
- package/src/utils/tools.ts +32 -0
- package/src/utils/update-tool-step.tsx +27 -0
- package/src/utils/upload/FileUpload.ts +63 -0
- package/src/utils/upload/UploadManager.ts +156 -0
- package/src/utils/upload/context.tsx +44 -0
- package/src/utils/upload/errors.ts +34 -0
- package/src/utils/upload/types.ts +7 -0
- package/src/utils/upload/use-paste-upload.tsx +30 -0
- package/src/utils/upload/utils.ts +12 -0
- package/src/utils/url.ts +8 -0
- package/src/views/Agents/AgentDescription.tsx +107 -0
- package/src/views/Agents/AgentsPanel.tsx +57 -0
- package/src/views/Agents/AgentsTab.tsx +126 -0
- package/src/views/Agents/dictionary.ts +45 -0
- package/src/views/Agents/index.tsx +26 -0
- package/src/views/Agents/styled.ts +69 -0
- package/src/views/Agents/useAgentFavorites.ts +63 -0
- package/src/views/Chat/AgentInfo.tsx +13 -8
- package/src/views/Chat/ButtonExecutionDetail.tsx +46 -0
- package/src/views/Chat/ChatMessage.tsx +465 -79
- package/src/views/Chat/ChatMessages.tsx +15 -4
- package/src/views/Chat/StepsList.tsx +394 -0
- package/src/views/Chat/chat-scroll.ts +1 -1
- package/src/views/Chat/events.ts +71 -0
- package/src/views/Chat/index.tsx +17 -3
- package/src/views/Chat/styled.ts +158 -32
- package/src/views/ChatHistory/ChatHistoryPanel.tsx +8 -5
- package/src/views/ChatHistory/HistoryItem.tsx +23 -44
- package/src/views/ChatHistory/index.tsx +6 -4
- package/src/views/ChatHistory/styled.ts +3 -5
- package/src/views/ChatHistory/utils.ts +144 -11
- package/src/views/ChatTabSelection.tsx +47 -20
- package/src/views/Editor.tsx +28 -18
- package/src/views/Home/BuiltInAgent.tsx +67 -0
- package/src/views/Home/CustomAgent.tsx +36 -0
- package/src/views/Home/index.tsx +48 -0
- package/src/views/Home/styled.ts +74 -0
- package/src/views/Home/types.ts +16 -0
- package/src/views/KSDocument.tsx +11 -8
- package/src/views/KnowledgeSources.tsx +169 -62
- package/src/views/MessageInput/AgentSelector.tsx +92 -0
- package/src/views/MessageInput/ButtonAgent.tsx +73 -0
- package/src/views/MessageInput/ButtonBar.tsx +57 -0
- package/src/views/MessageInput/ContextBar.tsx +117 -0
- package/src/views/MessageInput/ModelSwitcher/index.tsx +69 -0
- package/src/views/MessageInput/ModelSwitcher/utils.tsx +143 -0
- package/src/views/MessageInput/QuickCommandSelector.tsx +137 -0
- package/src/views/MessageInput/SelectContent.tsx +99 -0
- package/src/views/MessageInput/UploadBar.tsx +107 -0
- package/src/views/MessageInput/UploadDragNDrop.tsx +79 -0
- package/src/views/MessageInput/chat-entry-history.ts +97 -0
- package/src/views/MessageInput/dictionary.ts +52 -10
- package/src/views/MessageInput/index.tsx +154 -51
- package/src/views/MessageInput/styled.ts +226 -85
- package/src/views/MinimizedHeader.tsx +11 -10
- package/src/views/Resources.tsx +108 -0
- package/src/views/Stacks.tsx +152 -39
- package/src/views/Steps/FlowChart/HandleGroup.tsx +14 -0
- package/src/views/Steps/FlowChart/NodeDynamic.tsx +97 -0
- package/src/views/Steps/FlowChart/NodeStep.tsx +49 -0
- package/src/views/Steps/FlowChart/hooks.ts +41 -0
- package/src/views/Steps/FlowChart/index.tsx +111 -0
- package/src/views/Steps/FlowChart/layout.ts +73 -0
- package/src/views/Steps/FlowChart/styled.ts +157 -0
- package/src/views/Steps/FlowChart/types.ts +28 -0
- package/src/views/Steps/StepModal.tsx +233 -0
- package/src/views/Steps/StepsPanel.tsx +31 -0
- package/src/views/Steps/dictionary.ts +48 -0
- package/src/views/Steps/index.tsx +36 -0
- package/src/views/Steps/utils.tsx +34 -0
- package/src/views/Tools.tsx +77 -0
- package/src/views/Workspaces/WorkspacesTab.tsx +116 -0
- package/src/views/Workspaces/index.tsx +78 -0
- package/tsconfig.json +8 -3
- package/dist/components/Accordion.d.ts +0 -10
- package/dist/components/Accordion.d.ts.map +0 -1
- package/dist/components/Accordion.js +0 -46
- package/dist/components/Accordion.js.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts +0 -30
- package/dist/components/FallbackBoundary/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/ErrorBoundary.js +0 -38
- package/dist/components/FallbackBoundary/ErrorBoundary.js.map +0 -1
- package/dist/components/FallbackBoundary/Loading.d.ts +0 -2
- package/dist/components/FallbackBoundary/Loading.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/Loading.js +0 -12
- package/dist/components/FallbackBoundary/Loading.js.map +0 -1
- package/dist/components/FallbackBoundary/index.d.ts +0 -6
- package/dist/components/FallbackBoundary/index.d.ts.map +0 -1
- package/dist/components/FallbackBoundary/index.js +0 -9
- package/dist/components/FallbackBoundary/index.js.map +0 -1
- package/dist/components/IconInput.d.ts +0 -7
- package/dist/components/IconInput.d.ts.map +0 -1
- package/dist/components/IconInput.js +0 -58
- package/dist/components/IconInput.js.map +0 -1
- package/dist/components/OverlayMenu.d.ts +0 -10
- package/dist/components/OverlayMenu.d.ts.map +0 -1
- package/dist/components/OverlayMenu.js +0 -58
- package/dist/components/OverlayMenu.js.map +0 -1
- package/dist/components/ProgressBar.d.ts +0 -11
- package/dist/components/ProgressBar.d.ts.map +0 -1
- package/dist/components/ProgressBar.js +0 -126
- package/dist/components/ProgressBar.js.map +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.d.ts.map +0 -1
- package/dist/components/Tooltip/Tooltip.js +0 -17
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.d.ts +0 -13
- package/dist/components/Tooltip/TooltipAPI.d.ts.map +0 -1
- package/dist/components/Tooltip/TooltipAPI.js +0 -90
- package/dist/components/Tooltip/TooltipAPI.js.map +0 -1
- package/dist/components/Tooltip/context.d.ts +0 -5
- package/dist/components/Tooltip/context.d.ts.map +0 -1
- package/dist/components/Tooltip/context.js +0 -18
- package/dist/components/Tooltip/context.js.map +0 -1
- package/dist/components/Tooltip/index.d.ts +0 -3
- package/dist/components/Tooltip/index.d.ts.map +0 -1
- package/dist/components/Tooltip/index.js +0 -3
- package/dist/components/Tooltip/index.js.map +0 -1
- package/dist/components/Tooltip/style.d.ts +0 -4
- package/dist/components/Tooltip/style.d.ts.map +0 -1
- package/dist/components/Tooltip/style.js +0 -22
- package/dist/components/Tooltip/style.js.map +0 -1
- package/dist/components/Tooltip/types.d.ts +0 -14
- package/dist/components/Tooltip/types.d.ts.map +0 -1
- package/dist/views/Agents.d.ts +0 -2
- package/dist/views/Agents.d.ts.map +0 -1
- package/dist/views/Agents.js +0 -143
- package/dist/views/Agents.js.map +0 -1
- package/dist/views/Home.d.ts +0 -6
- package/dist/views/Home.d.ts.map +0 -1
- package/dist/views/Home.js +0 -68
- package/dist/views/Home.js.map +0 -1
- package/dist/views/MessageInput/ButtonGroup.d.ts +0 -12
- package/dist/views/MessageInput/ButtonGroup.d.ts.map +0 -1
- package/dist/views/MessageInput/ButtonGroup.js +0 -24
- package/dist/views/MessageInput/ButtonGroup.js.map +0 -1
- package/dist/views/MessageInput/InfoBar.d.ts +0 -2
- package/dist/views/MessageInput/InfoBar.d.ts.map +0 -1
- package/dist/views/MessageInput/InfoBar.js +0 -35
- package/dist/views/MessageInput/InfoBar.js.map +0 -1
- package/dist/views/Workspaces.d.ts +0 -2
- package/dist/views/Workspaces.d.ts.map +0 -1
- package/dist/views/Workspaces.js +0 -62
- package/dist/views/Workspaces.js.map +0 -1
- package/src/components/Accordion.tsx +0 -64
- package/src/components/FallbackBoundary/ErrorBoundary.tsx +0 -48
- package/src/components/FallbackBoundary/Loading.tsx +0 -14
- package/src/components/FallbackBoundary/index.tsx +0 -15
- package/src/components/IconInput.tsx +0 -70
- package/src/components/OverlayMenu.tsx +0 -77
- package/src/components/ProgressBar.tsx +0 -153
- package/src/components/Tooltip/Tooltip.tsx +0 -36
- package/src/components/Tooltip/TooltipAPI.ts +0 -84
- package/src/components/Tooltip/context.tsx +0 -24
- package/src/components/Tooltip/index.ts +0 -2
- package/src/components/Tooltip/style.tsx +0 -24
- package/src/components/Tooltip/types.ts +0 -15
- package/src/views/Agents.tsx +0 -200
- package/src/views/Home.tsx +0 -109
- package/src/views/MessageInput/ButtonGroup.tsx +0 -91
- package/src/views/MessageInput/InfoBar.tsx +0 -82
- package/src/views/Workspaces.tsx +0 -92
- /package/dist/{components/Tooltip → utils/upload}/types.js +0 -0
|
@@ -1,44 +1,272 @@
|
|
|
1
|
-
import { aiClient, StackspotAPIError } from '@stack-spot/portal-network'
|
|
2
|
-
import {
|
|
1
|
+
import { AgentInfo, aiClient, ChatResponseWithPMResources, ChatResponseWithSteps, ChatStep, StackspotAPIError, StreamCanceledError } from '@stack-spot/portal-network'
|
|
2
|
+
import { ChatResponse3 } from '@stack-spot/portal-network/api/ai'
|
|
3
|
+
import { findLast } from 'lodash'
|
|
4
|
+
import { ChatEntry, KnowledgeSource, TextChatEntry } from '../state/ChatEntry'
|
|
3
5
|
import { ChatState } from '../state/ChatState'
|
|
6
|
+
import { LabeledWithImage } from '../state/types'
|
|
4
7
|
import { buildConversationContext } from '../utils/chat'
|
|
8
|
+
import { treatHTMLInErrorMessage } from '../utils/error'
|
|
5
9
|
import { genericSourcesToKnowledgeSources } from '../utils/knowledge-source'
|
|
10
|
+
import { planningToolDictionaryHelper } from '../utils/planning-tool'
|
|
6
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Transforms a chat response from the backend into a chat entry that can be added to the chat.
|
|
14
|
+
* @param response the original response.
|
|
15
|
+
* @param knowledgeSources the knowledge sources already in format used by the chat.
|
|
16
|
+
* @param agent the current chat agent.
|
|
17
|
+
* @param tools the tools for the current chat agent.
|
|
18
|
+
* @param includeDate whether or not to include the date in the chat entry.
|
|
19
|
+
* @returns the TextChatEntry to build a ChatEntry.
|
|
20
|
+
*/
|
|
21
|
+
export function createEntryValueFromChatResponse(
|
|
22
|
+
response: Partial<ChatResponseWithSteps> & ChatResponseWithPMResources,
|
|
23
|
+
knowledgeSources: KnowledgeSource[] | undefined,
|
|
24
|
+
agent: LabeledWithImage | undefined,
|
|
25
|
+
includeDate = false,
|
|
26
|
+
): TextChatEntry {
|
|
27
|
+
const entry = {
|
|
28
|
+
agentType: 'bot',
|
|
29
|
+
type: 'md',
|
|
30
|
+
content: response.answer ?? '',
|
|
31
|
+
messageId: response.message_id ?? undefined,
|
|
32
|
+
knowledgeSources,
|
|
33
|
+
agent: agent,
|
|
34
|
+
updated: includeDate ? new Date().toISOString() : undefined,
|
|
35
|
+
steps: response.steps,
|
|
36
|
+
tools: response.tools,
|
|
37
|
+
opportunities: response.opportunities,
|
|
38
|
+
hypothesis: response.hypothesis,
|
|
39
|
+
prfaq: response.prfaq,
|
|
40
|
+
done: false,
|
|
41
|
+
}
|
|
42
|
+
return entry as TextChatEntry
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function buildPrompt(content: string, data?: any) {
|
|
46
|
+
if (data === undefined || data === '' || data === null) return content || '.' // prevents empty strings
|
|
47
|
+
return typeof data === 'string' ? data : JSON.stringify(data)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//Verify if the last planning in the messages has status awaiting_approval
|
|
51
|
+
const getLastPlanningAwaiting = (messages: ChatEntry[]) => findLast(messages, item => {
|
|
52
|
+
const steps = item.getValue().steps
|
|
53
|
+
if (steps) {
|
|
54
|
+
const hasPlanning = steps.find((step) => step.type === 'planning')
|
|
55
|
+
return hasPlanning ? hasPlanning.status === 'awaiting_approval' : false
|
|
56
|
+
}
|
|
57
|
+
return false
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const updateToolStatus = (agentInfo: AgentInfo, messages: ChatEntry[]) => {
|
|
61
|
+
const executionId = agentInfo.id
|
|
62
|
+
|
|
63
|
+
if (executionId) {
|
|
64
|
+
//Update message with type step which contains the planning steps
|
|
65
|
+
const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(executionId)
|
|
66
|
+
const originalItem = messages.find((message) => `${message.id}` === messageId)
|
|
67
|
+
const originalItemValue = originalItem?.getValue()
|
|
68
|
+
let update = false
|
|
69
|
+
const status = agentInfo.action === 'start' ? 'running' : 'success'
|
|
70
|
+
const step = originalItemValue?.steps
|
|
71
|
+
?.find(step => step.type === 'step' && step.attempts?.[0]?.tools?.[0]?.executionId === executionId)
|
|
72
|
+
if (step && step.status !== status) {
|
|
73
|
+
step.status = status
|
|
74
|
+
update = true
|
|
75
|
+
}
|
|
76
|
+
if (update) {
|
|
77
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const updateStepMessage = (step: ChatStep, messages: ChatEntry[]) => {
|
|
83
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(messages)
|
|
84
|
+
|
|
85
|
+
if (lastPlanningAwaiting) {
|
|
86
|
+
const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
|
|
87
|
+
const originalItemValue = originalItem?.getValue()
|
|
88
|
+
originalItemValue?.steps?.filter((messageStep) => {
|
|
89
|
+
if (messageStep.id === step.id) {
|
|
90
|
+
messageStep = { ...step }
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const updatePlanningMessage = (messages: ChatEntry[]) => {
|
|
99
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(messages)
|
|
100
|
+
|
|
101
|
+
if (lastPlanningAwaiting) {
|
|
102
|
+
const originalItem = messages.find((message) => message.id === lastPlanningAwaiting.id)
|
|
103
|
+
const originalItemValue = originalItem?.getValue()
|
|
104
|
+
originalItemValue?.steps?.map((step) => {
|
|
105
|
+
if (step.type === 'planning' && step.status === 'awaiting_approval') {
|
|
106
|
+
step.status = 'success'
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function helperSendMessage(messages: ChatEntry[], value: Partial<ChatResponseWithSteps> & { opportunities?: any },
|
|
114
|
+
chat: ChatState, botEntry: ChatEntry, knowledgeSources: KnowledgeSource[] | undefined) {
|
|
115
|
+
if (value.agent_info?.type === 'planning') {
|
|
116
|
+
if (value.agent_info.action === 'start') {
|
|
117
|
+
chat.set('isPlaning', true)
|
|
118
|
+
} else {
|
|
119
|
+
chat.set('isPlaning', false)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (value.agent_info?.type === 'chat' && value.agent_info?.action === 'end') {
|
|
124
|
+
//When an error happens, the step can still be running, so we enforce the error
|
|
125
|
+
const stepRunning = findLast(value.steps, (item) => item.status === 'running')
|
|
126
|
+
if (stepRunning?.status) {
|
|
127
|
+
stepRunning.status = 'error'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (value.sources?.length !== knowledgeSources?.length && chat.get('features').showSourcesInResponse) {
|
|
132
|
+
knowledgeSources = genericSourcesToKnowledgeSources(value.sources)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(messages)
|
|
136
|
+
if (lastPlanningAwaiting && value.steps) {
|
|
137
|
+
value.steps?.map(step => {
|
|
138
|
+
if (step.type === 'planning') {
|
|
139
|
+
updatePlanningMessage(messages)
|
|
140
|
+
} else if (step.type === 'step') {
|
|
141
|
+
updateStepMessage(step, messages)
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (value.agent_info?.type === 'tool' && value.agent_info?.action !== 'awaiting_approval') {
|
|
147
|
+
updateToolStatus(value.agent_info, messages)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (value.steps) {
|
|
151
|
+
const tool = findLast(value.steps, (item) => item.type === 'tool')
|
|
152
|
+
if (tool && tool.status === 'running') {
|
|
153
|
+
const messageId = planningToolDictionaryHelper.getMessageIdPlanningStepFromToolExecutionId(tool.id)
|
|
154
|
+
const originalItem = messages.find((message) => `${message.id}` === messageId)
|
|
155
|
+
const originalItemValue = originalItem?.getValue()
|
|
156
|
+
let update = false
|
|
157
|
+
const step = originalItemValue?.steps?.find(step => step.type === 'step')
|
|
158
|
+
if (step && step.attempts?.[0]?.tools?.[0]?.executionId === tool.id) {
|
|
159
|
+
step.attempts?.forEach((attempt, i) => {
|
|
160
|
+
const newAttempt = tool.attempts?.[i]
|
|
161
|
+
if (!newAttempt) return
|
|
162
|
+
attempt.tools = attempt.tools?.map((origTool, j) => {
|
|
163
|
+
const newTool = newAttempt.tools?.[j]
|
|
164
|
+
if (!newTool || origTool?.executionId !== newTool?.executionId) return origTool
|
|
165
|
+
update = true
|
|
166
|
+
return { ...origTool, ...newTool }
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
if (step.attempts.length < tool.attempts.length) {
|
|
170
|
+
step.attempts.push(tool.attempts[tool.attempts.length - 1])
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (update) {
|
|
174
|
+
originalItem?.setValue({ ...originalItemValue as TextChatEntry })
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const hasPlanning = botEntry.getValue().hasPlanning || chat.get('isPlaning')
|
|
180
|
+
botEntry.setValue({ ...createEntryValueFromChatResponse(value, knowledgeSources, chat.get('agent')), hasPlanning })
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The chat interceptor that sends the message to the AI agent, interprets the response and adds it to the chat.
|
|
185
|
+
*
|
|
186
|
+
* The message added to the chat is streamed, i.e. it changes over time, until it's completed.
|
|
187
|
+
*
|
|
188
|
+
* @param entry the chat entry.
|
|
189
|
+
* @param chat the chat state.
|
|
190
|
+
* @param signal a signal that can be canceled by the user.
|
|
191
|
+
* @returns undefined
|
|
192
|
+
*/
|
|
7
193
|
export async function sendMessageInterceptor(entry: ChatEntry, chat: ChatState, signal: AbortSignal) {
|
|
8
|
-
const { agentType, content } = entry.getValue()
|
|
194
|
+
const { agentType, content, data } = entry.getValue()
|
|
9
195
|
if (agentType !== 'user') return
|
|
10
|
-
const context = buildConversationContext(chat)
|
|
196
|
+
const context = buildConversationContext(chat, entry)
|
|
11
197
|
chat.set('isLoading', true)
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
198
|
+
const untitled = chat.untitled
|
|
199
|
+
const messages = chat.getMessages()
|
|
200
|
+
const isFirstMessage = messages.length === 1
|
|
201
|
+
if (untitled) {
|
|
202
|
+
chat.set('label', content || entry.getValue().upload?.[0]?.name || 'Chat')
|
|
203
|
+
chat.untitled = false
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const stream = aiClient.sendChatMessage({ context, user_prompt: buildPrompt(content, data) })
|
|
15
207
|
signal.addEventListener('abort', () => stream.cancel())
|
|
16
208
|
const botEntry = ChatEntry.createStreamedBotEntry()
|
|
17
|
-
chat
|
|
209
|
+
// we add the chat entry and show the streaming if the streaming feature is enabled
|
|
210
|
+
if (chat.get('features').streaming) {
|
|
211
|
+
chat.pushMessage(botEntry)
|
|
212
|
+
}
|
|
18
213
|
let knowledgeSources: KnowledgeSource[] | undefined
|
|
214
|
+
|
|
19
215
|
stream.onChange(value => {
|
|
20
|
-
|
|
21
|
-
knowledgeSources = genericSourcesToKnowledgeSources(value.sources)
|
|
22
|
-
}
|
|
23
|
-
botEntry.setValue({
|
|
24
|
-
agentType: 'bot',
|
|
25
|
-
type: 'md',
|
|
26
|
-
content: value.answer ?? '',
|
|
27
|
-
messageId: value.message_id ?? undefined,
|
|
28
|
-
knowledgeSources,
|
|
29
|
-
updated: new Date().toISOString(),
|
|
30
|
-
agent: chat.get('agent'),
|
|
31
|
-
})
|
|
216
|
+
helperSendMessage(messages, value, chat, botEntry, knowledgeSources)
|
|
32
217
|
})
|
|
218
|
+
|
|
219
|
+
let finalValue: Partial<ChatResponse3> | undefined
|
|
33
220
|
try {
|
|
34
|
-
await stream.getValue()
|
|
35
|
-
|
|
36
|
-
|
|
221
|
+
finalValue = await stream.getValue()
|
|
222
|
+
|
|
223
|
+
const lastPlanningAwaiting = getLastPlanningAwaiting(messages)
|
|
224
|
+
if (lastPlanningAwaiting) {
|
|
225
|
+
const value = lastPlanningAwaiting.getValue()
|
|
226
|
+
value.content = finalValue.answer || value.content
|
|
227
|
+
lastPlanningAwaiting.setValue(value)
|
|
228
|
+
}
|
|
229
|
+
// if the streaming feature is not enabled, we only add the chat entry once the streaming has finished
|
|
230
|
+
if (!chat.get('features').streaming) {
|
|
231
|
+
chat.pushMessage(botEntry)
|
|
232
|
+
}
|
|
37
233
|
} catch (error: any) {
|
|
234
|
+
if (error instanceof StreamCanceledError) {
|
|
235
|
+
finalValue = stream.getPartialValue()
|
|
236
|
+
} else {
|
|
237
|
+
botEntry.setValue({
|
|
238
|
+
...botEntry.getValue(),
|
|
239
|
+
error: treatHTMLInErrorMessage(
|
|
240
|
+
error instanceof StackspotAPIError ? error.translate() : (error.message ?? `${error}`),
|
|
241
|
+
error.status ?? 500,
|
|
242
|
+
),
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (finalValue?.answer) {
|
|
38
247
|
botEntry.setValue({
|
|
39
|
-
...botEntry.getValue(),
|
|
40
|
-
|
|
248
|
+
...createEntryValueFromChatResponse(finalValue, botEntry.getValue().knowledgeSources, chat.get('agent'), true),
|
|
249
|
+
hasPlanning: botEntry.getValue().hasPlanning,
|
|
41
250
|
})
|
|
251
|
+
aiClient.chat.invalidate({ conversationId: chat.id })
|
|
252
|
+
if (isFirstMessage) {
|
|
253
|
+
// if the chat has a title and this was its first message, we need to rename it according to the title, otherwise, the backend will
|
|
254
|
+
// keep the name generated by default.
|
|
255
|
+
if (!untitled) {
|
|
256
|
+
try {
|
|
257
|
+
await aiClient.renameChat.mutate({
|
|
258
|
+
conversationId: chat.id,
|
|
259
|
+
conversationUpdateTitleRequest: { title: chat.get('label') },
|
|
260
|
+
})
|
|
261
|
+
} catch (error) {
|
|
262
|
+
// eslint-disable-next-line no-console
|
|
263
|
+
console.warn('Failed to rename chat:', chat.get('label'), error)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// this makes sure to update the chat history
|
|
267
|
+
aiClient.chats.invalidate()
|
|
268
|
+
}
|
|
42
269
|
}
|
|
270
|
+
botEntry.setValue({ ...botEntry.getValue(), done: true })
|
|
43
271
|
chat.set('isLoading', false)
|
|
44
272
|
}
|
|
@@ -1,34 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import { Textarea } from '@stack-spot/citric-react'
|
|
3
|
+
import { forwardRef, useEffect, useRef } from 'react'
|
|
3
4
|
import { PropsOf } from '../types'
|
|
4
5
|
|
|
5
6
|
interface Props extends PropsOf<typeof Textarea> {
|
|
7
|
+
/**
|
|
8
|
+
* A function to run whenever the height of the text area increases.
|
|
9
|
+
*/
|
|
6
10
|
onIncreaseSize?: () => void,
|
|
11
|
+
/**
|
|
12
|
+
* A function to run whenever the text area value becomes empty.
|
|
13
|
+
*/
|
|
7
14
|
onResetSize?: () => void,
|
|
8
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The maximum height this textarea can get to.
|
|
17
|
+
*/
|
|
18
|
+
maxHeight?: () => number,
|
|
9
19
|
}
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The adaptive textarea grows in height whenever needed until the maximum height is reached.
|
|
23
|
+
*/
|
|
24
|
+
export const AdaptiveTextArea = forwardRef<HTMLTextAreaElement, Props>((
|
|
25
|
+
{ value, onIncreaseSize, onResetSize, style, maxHeight, ...props },
|
|
26
|
+
externalRef,
|
|
27
|
+
) => {
|
|
28
|
+
const localRef = useRef<HTMLTextAreaElement>(null)
|
|
29
|
+
const ref = externalRef as React.RefObject<HTMLTextAreaElement> ?? localRef
|
|
30
|
+
|
|
31
|
+
const handleIncreaseSize = (newHeight: number) => {
|
|
32
|
+
onIncreaseSize?.()
|
|
33
|
+
if (maxHeight && newHeight > maxHeight?.() && ref.current) {
|
|
34
|
+
ref.current.style.overflowY = 'auto'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
13
37
|
|
|
14
38
|
useEffect(() => {
|
|
15
39
|
if (!ref.current) return
|
|
16
40
|
const height = ref.current.clientHeight
|
|
17
41
|
const scroll = ref.current.scrollHeight
|
|
18
|
-
|
|
42
|
+
const computedMaxHeight = maxHeight?.() ?? 0
|
|
43
|
+
if (!maxHeight || height < computedMaxHeight) {
|
|
19
44
|
ref.current.style.overflowY = 'hidden'
|
|
20
45
|
if (height < scroll) {
|
|
21
46
|
ref.current.style.height = `${scroll}px`
|
|
22
|
-
|
|
47
|
+
handleIncreaseSize(scroll)
|
|
23
48
|
}
|
|
24
|
-
} else if (
|
|
49
|
+
} else if (computedMaxHeight) {
|
|
25
50
|
ref.current.style.overflowY = 'auto'
|
|
26
51
|
}
|
|
27
52
|
if (!value) {
|
|
28
53
|
ref.current.style.height = ''
|
|
29
54
|
onResetSize?.()
|
|
30
55
|
}
|
|
31
|
-
}, [value
|
|
56
|
+
}, [value])
|
|
32
57
|
|
|
33
|
-
return <Textarea {...props} ref={ref} value={value} style={{ ...style, maxHeight }} />
|
|
34
|
-
}
|
|
58
|
+
return <Textarea {...props} ref={ref} value={value} style={{ ...style, maxHeight: maxHeight?.() }} />
|
|
59
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IconBox, Link, Text } from '@stack-spot/citric-react'
|
|
2
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
3
|
+
import { useTranslate } from '@stack-spot/portal-translate'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
import { dictionary } from './dictionary'
|
|
6
|
+
|
|
7
|
+
const StyledCard = styled(Link)`
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
transition: background-color 0.3s;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 12px;
|
|
14
|
+
border: 1px solid ${theme.color.light[600]};
|
|
15
|
+
text-decoration: none;
|
|
16
|
+
padding-right: 16px !important;
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: ${theme.color.light[500]};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.text-box {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: 2px;
|
|
26
|
+
color: ${theme.color.light['contrastText']}
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
export const AgentCardCreate = ({ urlCreateAgent }: { urlCreateAgent: string }) => {
|
|
31
|
+
const t = useTranslate(dictionary)
|
|
32
|
+
return (
|
|
33
|
+
<StyledCard href={urlCreateAgent} role="link" tabIndex={0} className={'agent-card'}>
|
|
34
|
+
<IconBox appearance="square" size="md" icon="PlusMini" />
|
|
35
|
+
<div className="text-box">
|
|
36
|
+
<Text appearance="body2">
|
|
37
|
+
{`${t.create} ${t.agent}`}
|
|
38
|
+
</Text>
|
|
39
|
+
</div>
|
|
40
|
+
</StyledCard>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Dictionary } from '@stack-spot/portal-translate'
|
|
2
|
+
|
|
3
|
+
export const dictionary = {
|
|
4
|
+
en: {
|
|
5
|
+
'built_in': 'Built-in',
|
|
6
|
+
'recently_used': 'Recent',
|
|
7
|
+
workspace: 'Spot',
|
|
8
|
+
personal: 'Personal',
|
|
9
|
+
account: 'Account',
|
|
10
|
+
shared: 'Shared',
|
|
11
|
+
agent: 'Agent',
|
|
12
|
+
create: 'Create',
|
|
13
|
+
},
|
|
14
|
+
pt: {
|
|
15
|
+
'built_in': 'Embutido',
|
|
16
|
+
'recently_used': 'Recente',
|
|
17
|
+
workspace: 'Spot',
|
|
18
|
+
personal: 'Personal',
|
|
19
|
+
account: 'Conta',
|
|
20
|
+
shared: 'Compartilhado',
|
|
21
|
+
agent: 'Agente',
|
|
22
|
+
create: 'Criar',
|
|
23
|
+
},
|
|
24
|
+
} satisfies Dictionary
|
|
25
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Card, ImageWithFallback, Text } from '@stack-spot/citric-react'
|
|
2
|
+
import { listToClass, theme } from '@stack-spot/portal-theme'
|
|
3
|
+
import { useTranslate } from '@stack-spot/portal-translate'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
import placeholder from '../../assets/placeholder.png'
|
|
6
|
+
import { useCurrentChat, useCurrentChatState } from '../../context/hooks'
|
|
7
|
+
import { LabeledAgent } from '../../state/types'
|
|
8
|
+
import { dictionary } from './dictionary'
|
|
9
|
+
|
|
10
|
+
const StyledCard = styled(Card)`
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
border-radius: 8px;
|
|
13
|
+
transition: background-color 0.3s;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 12px;
|
|
17
|
+
|
|
18
|
+
&:hover, &:focus {
|
|
19
|
+
background-color: ${theme.color.light[500]} !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.active {
|
|
23
|
+
background-color: ${theme.color.light[600]} !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
img {
|
|
27
|
+
width: 125px;
|
|
28
|
+
height: 130px;
|
|
29
|
+
border-radius: 8px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h6 {
|
|
33
|
+
max-width: 125px;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.agent-type {
|
|
40
|
+
display: flex;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.text-box {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
gap: 2px;
|
|
48
|
+
}
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export const AgentCard = ({ agent }: { agent: LabeledAgent }) => {
|
|
52
|
+
const t = useTranslate(dictionary)
|
|
53
|
+
const chat = useCurrentChat()
|
|
54
|
+
const currentAgent = useCurrentChatState('agent')
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<StyledCard
|
|
58
|
+
onClick={() => chat.set('agent', agent)}
|
|
59
|
+
role="button"
|
|
60
|
+
tabIndex={0}
|
|
61
|
+
bgLevel={400}
|
|
62
|
+
className={listToClass(['agent-card', currentAgent?.id === agent.id && 'active'])}
|
|
63
|
+
>
|
|
64
|
+
<ImageWithFallback src={agent.image ?? ''} fallback={<img src={placeholder} />} />
|
|
65
|
+
<div className="text-box">
|
|
66
|
+
{agent.visibility_level && (
|
|
67
|
+
<div className="agent-type">
|
|
68
|
+
<Text appearance="microtext1" color="light.700">
|
|
69
|
+
{t[agent.visibility_level.toLowerCase() as keyof typeof t]}
|
|
70
|
+
</Text>
|
|
71
|
+
<Text appearance="microtext1">
|
|
72
|
+
{t.agent}
|
|
73
|
+
</Text>
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
<Text appearance="h6">
|
|
77
|
+
{agent.label}
|
|
78
|
+
</Text>
|
|
79
|
+
</div>
|
|
80
|
+
</StyledCard>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
3
|
+
import { forwardRef, useEffect, useRef, useState } from 'react'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children: React.ReactNode | React.ReactNode[],
|
|
8
|
+
durationMs?: number,
|
|
9
|
+
visible: boolean,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Styled = styled.div<{ $durationMs: number }>`
|
|
13
|
+
opacity: 0;
|
|
14
|
+
transition: opacity ${({ $durationMs }) => $durationMs / 1000}s;
|
|
15
|
+
&.visible {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const AnimatedOpacity = forwardRef<HTMLDivElement, Props>(({ children, visible, durationMs = 300 }, ref) => {
|
|
21
|
+
const [content, setContent] = useState(visible ? children : null)
|
|
22
|
+
const animation = useRef<number | undefined>()
|
|
23
|
+
const previousVisible = useRef<boolean | undefined>()
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const isFirstRender = previousVisible === undefined
|
|
27
|
+
const isChangingVisibility = visible !== previousVisible.current
|
|
28
|
+
previousVisible.current = visible
|
|
29
|
+
if (isFirstRender) return
|
|
30
|
+
if (isChangingVisibility) {
|
|
31
|
+
if (animation.current) {
|
|
32
|
+
window.clearTimeout(animation.current)
|
|
33
|
+
animation.current = undefined
|
|
34
|
+
return setContent(visible ? children : null)
|
|
35
|
+
}
|
|
36
|
+
if (visible) setContent(children)
|
|
37
|
+
animation.current = window.setTimeout(() => {
|
|
38
|
+
if (!visible) setContent(null)
|
|
39
|
+
animation.current = undefined
|
|
40
|
+
}, durationMs)
|
|
41
|
+
} else if (visible || !animation.current) {
|
|
42
|
+
setContent(visible ? children : null)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
window.clearTimeout(animation.current)
|
|
47
|
+
}
|
|
48
|
+
}, [visible, children])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Styled ref={ref} $durationMs={durationMs} className={listToClass(['fade-animation', visible && 'visible'])}>
|
|
52
|
+
{content}
|
|
53
|
+
</Styled>
|
|
54
|
+
)
|
|
55
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import { focusFirstChild, TagPriorityElement } from '@stack-spot/portal-components'
|
|
3
|
+
import { forwardRef, RefObject, useEffect, useRef } from 'react'
|
|
4
|
+
import { styled } from 'styled-components'
|
|
5
|
+
|
|
6
|
+
interface Props extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/**
|
|
8
|
+
* A delay in ms to focus the first focusable element.
|
|
9
|
+
*/
|
|
10
|
+
delay?: number,
|
|
11
|
+
/**
|
|
12
|
+
* Instead of focusing the first element overall, focus the first according to this list of priorities.
|
|
13
|
+
*
|
|
14
|
+
* 'other' means elements that are normally not focusable, but have positive tabIndex values.
|
|
15
|
+
*/
|
|
16
|
+
priority?: TagPriorityElement[],
|
|
17
|
+
/**
|
|
18
|
+
* Ignores any element that matches this query selector.
|
|
19
|
+
*/
|
|
20
|
+
ignore?: string,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const FlexibleDiv = styled.div`
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
flex: 1;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Focus the first focusable child as soon as the component mounts.
|
|
32
|
+
*/
|
|
33
|
+
export const AutoFocus = forwardRef<HTMLDivElement, Props>(({ children, delay = 0, priority, ignore, ...props }, externalRef) => {
|
|
34
|
+
const localRef = useRef<HTMLDivElement>(null)
|
|
35
|
+
const ref = externalRef as RefObject<HTMLDivElement> ?? localRef
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setTimeout(() => focusFirstChild(ref.current, { priority, ignore }), delay)
|
|
39
|
+
}, [])
|
|
40
|
+
|
|
41
|
+
return <FlexibleDiv ref={ref} {...props}>{children}</FlexibleDiv>
|
|
42
|
+
})
|