@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
package/src/views/Stacks.tsx
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { Button } from '@citric
|
|
2
|
-
import { Search } from '@citric/icons'
|
|
1
|
+
import { Button, Tab } from '@stack-spot/citric-react'
|
|
3
2
|
import { Placeholder } from '@stack-spot/portal-components/Placeholder'
|
|
4
|
-
import { aiClient } from '@stack-spot/portal-network'
|
|
5
|
-
import {
|
|
3
|
+
import { aiClient, workspaceAiClient } from '@stack-spot/portal-network'
|
|
4
|
+
import { VisibilityLevelEnum } from '@stack-spot/portal-network/api/ai'
|
|
5
|
+
import { WorkspaceResponse } from '@stack-spot/portal-network/api/workspace-ai'
|
|
6
6
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
7
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
7
|
+
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
8
|
+
import { NavigationComponent } from '../components/ComponentNavigator'
|
|
8
9
|
import { DescribedRadioGroup } from '../components/form/DescribedRadioGroup'
|
|
9
|
-
import {
|
|
10
|
+
import { RightPanelContentList } from '../components/RightPanelContentList'
|
|
10
11
|
import { RightPanelTabs } from '../components/RightPanelTabs'
|
|
12
|
+
import { WorkspaceTabNavigator } from '../components/WorkspaceTabNavigator'
|
|
11
13
|
import { useCurrentChat, useWidget, useWidgetState } from '../context/hooks'
|
|
14
|
+
import { Scope } from '../features'
|
|
12
15
|
import { useRightPanel } from '../right-panel/hooks'
|
|
16
|
+
import { ChatProperties } from '../state/ChatState'
|
|
17
|
+
import { checkIsTrial } from '../utils/check-is-trial'
|
|
13
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Renders the Stack selection form in the Right Panel if this is the panel that is currently opened.
|
|
21
|
+
*/
|
|
14
22
|
export const Stacks = () => {
|
|
15
23
|
const t = useTranslate(dictionary)
|
|
16
24
|
const panel = useWidgetState('panel')
|
|
@@ -27,59 +35,160 @@ export const Stacks = () => {
|
|
|
27
35
|
return null
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
const StacksPanel =
|
|
38
|
+
const StacksPanel = () => {
|
|
31
39
|
const t = useTranslate(dictionary)
|
|
32
40
|
const chat = useCurrentChat()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
const isTrial = checkIsTrial()
|
|
42
|
+
const stack = useRef(chat.get('stack'))
|
|
43
|
+
const features = useWidgetState('features')
|
|
44
|
+
const isGroupResourcesByScope = features?.groupResourcesByScope
|
|
45
|
+
const scopes = features?.scopes ?? []
|
|
46
|
+
const spotId = features?.workspaceId
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
stack.current = chat.get('stack')
|
|
50
|
+
}, [chat])
|
|
51
|
+
|
|
52
|
+
const allTabsMap: Partial<Record<Scope, Omit<Tab, 'key'>>> = {
|
|
53
|
+
favorite: { label: t.favorites, content: <StacksTab key="favorites" visibility="favorite" stack={stack} /> },
|
|
54
|
+
personal: { label: t.personal, content: <StacksTab key="personal" visibility="personal" stack={stack} /> },
|
|
55
|
+
shared: { label: t.shared, content: <StacksTab key="shared" visibility="shared" stack={stack} /> },
|
|
56
|
+
workspace: { label: t.spots, content: <StacksTabWorkspace key="workspace" visibility="workspace" stack={stack} /> },
|
|
57
|
+
account: { label: t.account, content: <StacksTab key="account" visibility="account" stack={stack} /> },
|
|
58
|
+
}
|
|
59
|
+
const defaultScopes: Scope[] = ['favorite', 'personal', 'shared', 'workspace', 'account']
|
|
60
|
+
|
|
61
|
+
const rawScopes: Scope[] = scopes?.length ? scopes : defaultScopes
|
|
62
|
+
|
|
63
|
+
const scopesToRender: Scope[] = isTrial
|
|
64
|
+
? ['favorite', 'personal']
|
|
65
|
+
: rawScopes
|
|
66
|
+
|
|
67
|
+
const tabs = scopesToRender
|
|
68
|
+
.map(scope => scope in allTabsMap ? { key: scope, ...allTabsMap[scope] } : undefined)
|
|
69
|
+
.filter(Boolean) as Tab[]
|
|
70
|
+
|
|
71
|
+
return (isGroupResourcesByScope ? (
|
|
72
|
+
<RightPanelTabs key={chat.id} tabs={tabs} />
|
|
73
|
+
) : (
|
|
74
|
+
<RightPanelContentList><StacksTab stack={stack} workspaceId={spotId} /></RightPanelContentList>
|
|
75
|
+
))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface StacksTabProps {
|
|
79
|
+
visibility?: VisibilityLevelEnum,
|
|
80
|
+
workspaceId?: string,
|
|
81
|
+
stack: React.MutableRefObject<ChatProperties['stack']>,
|
|
82
|
+
showSubmitButton?: boolean,
|
|
39
83
|
}
|
|
40
84
|
|
|
41
|
-
const StacksTab = ({ visibility
|
|
85
|
+
export const StacksTab = ({ visibility, workspaceId, stack, showSubmitButton = true }: StacksTabProps) => {
|
|
42
86
|
const t = useTranslate(dictionary)
|
|
43
87
|
const { close } = useRightPanel()
|
|
44
88
|
const chat = useCurrentChat()
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const [
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
const listFavorites = aiClient.aiStacks.useQuery({ visibility: 'favorite' })
|
|
90
|
+
const [addFavorite, pendingAddFav] = aiClient.addFavoriteStackAi.useMutation()
|
|
91
|
+
const [removeFavorite, pendingRemoveFav] = aiClient.removeFavoriteStackAi.useMutation()
|
|
92
|
+
const [submitEnabled, setSubmitEnabled] = useState(false)
|
|
93
|
+
|
|
94
|
+
const removeFavoriteStack = async (idOrSlug: string) => {
|
|
95
|
+
try {
|
|
96
|
+
await removeFavorite({ stackId: idOrSlug })
|
|
97
|
+
await aiClient.aiStacks.invalidate()
|
|
98
|
+
} catch (error) {
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.error(error)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
105
|
+
const onRemoveFavorite = (idOrSlug: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
106
|
+
try {
|
|
107
|
+
await removeFavoriteStack(idOrSlug)
|
|
108
|
+
if (!pendingRemoveFav){
|
|
109
|
+
resolve(true)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
} catch (error) {
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.error(error)
|
|
115
|
+
reject(error)
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const addFavoriteStack = async (idOrSlug: string) => {
|
|
120
|
+
try {
|
|
121
|
+
await addFavorite({ stackId: idOrSlug })
|
|
122
|
+
await aiClient.aiStacks.invalidate()
|
|
123
|
+
} catch (error) {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.error(error)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
130
|
+
const onAddFavorite = (idOrSlug: string) => new Promise<boolean>(async (resolve, reject) => {
|
|
131
|
+
try {
|
|
132
|
+
await addFavoriteStack(idOrSlug)
|
|
133
|
+
if (!pendingAddFav){
|
|
134
|
+
resolve(true)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
} catch (error) {
|
|
138
|
+
// eslint-disable-next-line no-console
|
|
139
|
+
console.error(error)
|
|
140
|
+
reject(error)
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const stacks = workspaceId
|
|
145
|
+
? workspaceAiClient.getStackFromWorkspaceAi.useQuery({ workspaceId })
|
|
146
|
+
//@ts-ignore
|
|
147
|
+
: aiClient.aiStacks.useQuery({ visibility, order: 'a-to-z' })
|
|
148
|
+
|
|
149
|
+
const initialValue = useMemo(() => {
|
|
150
|
+
const currentStackId = stack.current ? stack.current.id : chat.get('stack')?.id
|
|
151
|
+
const initial = stacks.find(s => s.id === currentStackId)
|
|
152
|
+
if (initial) setSubmitEnabled(true)
|
|
153
|
+
return initial
|
|
154
|
+
}, [stacks])
|
|
52
155
|
|
|
53
156
|
function submit() {
|
|
54
|
-
if (
|
|
157
|
+
if (stack.current) chat.set('stack', stack.current)
|
|
55
158
|
close()
|
|
56
159
|
}
|
|
57
160
|
|
|
58
161
|
return (
|
|
59
162
|
<>
|
|
60
163
|
<div className="content">
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
className="option-list"
|
|
74
|
-
/>}
|
|
75
|
-
{!!stacks.length && !filtered.length && <Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} />}
|
|
76
|
-
{!stacks.length && <Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
164
|
+
<DescribedRadioGroup
|
|
165
|
+
options={stacks}
|
|
166
|
+
initialValue={initialValue}
|
|
167
|
+
data={s => ({ idOrSlug: s.id, description: s.use_case, name: s.name, listFavorites, onAddFavorite, onRemoveFavorite })}
|
|
168
|
+
emptyResults={<Placeholder title={t.noSearchResults} description={t.noSearchResultsDescription} className="no-data-placeholder"/>}
|
|
169
|
+
emptyDataset={<Placeholder title={t.noData} description={t.noDataDescription} />}
|
|
170
|
+
onChange={(s) => {
|
|
171
|
+
stack.current = s ? { ...s, label: s.name } : undefined
|
|
172
|
+
setSubmitEnabled(true)
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
77
175
|
</div>
|
|
78
|
-
<Button onClick={submit} disabled={!
|
|
176
|
+
{!!stacks.length && showSubmitButton && <Button onClick={submit} disabled={!submitEnabled}>{t.apply}</Button>}
|
|
79
177
|
</>
|
|
80
178
|
)
|
|
81
179
|
}
|
|
82
180
|
|
|
181
|
+
function StacksTabWorkspace({ stack, visibility, showSubmitButton }: StacksTabProps) {
|
|
182
|
+
const workspaceTabComponents = useMemo(() => ({ stack: StacksTab }), [stack])
|
|
183
|
+
|
|
184
|
+
const buildNavigateParams = (workspace: WorkspaceResponse): NavigationComponent<typeof workspaceTabComponents> => ({
|
|
185
|
+
component: 'stack',
|
|
186
|
+
props: { visibility, workspaceId: workspace.id, stack, showSubmitButton },
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
return <WorkspaceTabNavigator components={workspaceTabComponents} getNavigateParam={buildNavigateParams} />
|
|
190
|
+
}
|
|
191
|
+
|
|
83
192
|
const dictionary = {
|
|
84
193
|
en: {
|
|
85
194
|
title: 'Stacks AI',
|
|
@@ -92,6 +201,8 @@ const dictionary = {
|
|
|
92
201
|
noSearchResultsDescription: 'Please, try another search term.',
|
|
93
202
|
noData: 'There are no stacks in this category yet.',
|
|
94
203
|
noDataDescription: 'Use the tabs above to try other categories or use the AI portal to create new stacks.',
|
|
204
|
+
favorites: 'Favorites',
|
|
205
|
+
spots: 'Spots',
|
|
95
206
|
},
|
|
96
207
|
pt: {
|
|
97
208
|
title: 'Stacks AI',
|
|
@@ -104,5 +215,7 @@ const dictionary = {
|
|
|
104
215
|
noSearchResultsDescription: 'Por favor, tente outra busca.',
|
|
105
216
|
noData: 'Ainda não há stacks nesta categoria.',
|
|
106
217
|
noDataDescription: 'Use as abas acima para tentar outras categorias ou use o Portal AI para criar novas stacks.',
|
|
218
|
+
favorites: 'Favoritos',
|
|
219
|
+
spots: 'Spots',
|
|
107
220
|
},
|
|
108
221
|
} satisfies Dictionary
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Handle, Position } from '@xyflow/react'
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
renderSource?: boolean,
|
|
5
|
+
renderTarget?: boolean,
|
|
6
|
+
targetPosition?: Position,
|
|
7
|
+
sourcePosition?: Position,
|
|
8
|
+
}
|
|
9
|
+
export const HandleGroup = ({ renderSource = true, renderTarget = true, targetPosition, sourcePosition }: Props) => (
|
|
10
|
+
<>
|
|
11
|
+
{renderTarget && <Handle type="target" position={targetPosition || Position.Left} isConnectable className="target-handle" />}
|
|
12
|
+
{renderSource && <Handle type="source" position={sourcePosition || Position.Right} isConnectable className="source-handle" />}
|
|
13
|
+
</>
|
|
14
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Icon, WithIcon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Avatar, Column, IconBox, Row, Skeleton, Text } from '@stack-spot/citric-react'
|
|
3
|
+
import { AnimatedHeight } from '@stack-spot/portal-components/AnimatedHeight'
|
|
4
|
+
import { ChatAgentTool } from '@stack-spot/portal-network'
|
|
5
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
6
|
+
import { Position } from '@xyflow/react'
|
|
7
|
+
import { useChatEntry } from '../../../context/hooks'
|
|
8
|
+
import { useStepsDictionary } from '../dictionary'
|
|
9
|
+
import { getTitle, getTypeIcon } from '../utils'
|
|
10
|
+
import { HandleGroup } from './HandleGroup'
|
|
11
|
+
import { useResizeObserver } from './hooks'
|
|
12
|
+
import { NodeData } from './types'
|
|
13
|
+
|
|
14
|
+
const ToolItem = ({ tool, index, onClick }: { tool: ChatAgentTool, index: number, onClick?: (index: number) => void }) => {
|
|
15
|
+
const { name, image, input, status } = tool
|
|
16
|
+
|
|
17
|
+
if (status === 'running') {
|
|
18
|
+
return <Skeleton height="48px" bgLevel={600} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="tool" onClick={() => onClick?.(index)}>
|
|
23
|
+
<Row gap="4px" alignItems="center" mb={2}>
|
|
24
|
+
{image
|
|
25
|
+
? <Avatar size="xxs" image={image} name={name} />
|
|
26
|
+
: <Icon icon="Cog" group="outline" />
|
|
27
|
+
}
|
|
28
|
+
<Text weight="500" className="title">{name}</Text>
|
|
29
|
+
</Row>
|
|
30
|
+
<Text nowrapEllipsis color="light.700">{input}</Text>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ListTools = ({ tools, onClick }: { tools: ChatAgentTool[], onClick?: (toolIndex?: number) => void }) => (
|
|
36
|
+
<AnimatedHeight>
|
|
37
|
+
<Column gap="8px">
|
|
38
|
+
{tools.map((tool, index) => (
|
|
39
|
+
<Column key={`${tool.id}-${index}`} className="wrapper-tool">
|
|
40
|
+
<ToolItem tool={tool} index={index} onClick={onClick} />
|
|
41
|
+
</Column>
|
|
42
|
+
))}
|
|
43
|
+
</Column>
|
|
44
|
+
</AnimatedHeight>
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
const NodeBox = ({ title, icon, content, onClick }: { title: string, icon: WithIcon, content?: string, onClick?: () => void }) => (
|
|
48
|
+
<Column onClick={onClick} style={{ cursor: onClick ? 'pointer' : 'default' }}>
|
|
49
|
+
<Row gap="4px" alignItems="center">
|
|
50
|
+
<IconBox {...icon} appearance="none" colorScheme="light" size="sm" />
|
|
51
|
+
<Text className="step-index" weight="500">{title}</Text>
|
|
52
|
+
</Row>
|
|
53
|
+
<Text nowrapEllipsis color="light.700">
|
|
54
|
+
{content}
|
|
55
|
+
</Text>
|
|
56
|
+
</Column>
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
interface Props {
|
|
60
|
+
data: NodeData,
|
|
61
|
+
targetPosition?: Position,
|
|
62
|
+
sourcePosition?: Position,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const NodeDynamic = ({ data, ...props }: Props) => {
|
|
66
|
+
const { step, index, onClick, onResize, message } = data
|
|
67
|
+
const content = useChatEntry(message)?.content
|
|
68
|
+
const t = useStepsDictionary()
|
|
69
|
+
const ref = useResizeObserver(onResize)
|
|
70
|
+
|
|
71
|
+
const tools = step.type === 'step' ? step?.attempts?.[0]?.tools : undefined
|
|
72
|
+
|
|
73
|
+
const renderContent = () => {
|
|
74
|
+
if (step.type === 'planning') {
|
|
75
|
+
return <NodeBox title={t.userPrompt} content={step.user_question} icon={{ ...getTypeIcon(step.type) }} />
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (step.type === 'step') {
|
|
79
|
+
return tools?.length ? <ListTools onClick={onClick} tools={tools} /> : null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (step.type === 'answer') {
|
|
83
|
+
return <Column p={3} bg="light.400" onClick={() => onClick?.(index)}>
|
|
84
|
+
<NodeBox onClick={onClick} title={t.finalAnswer} content={content} icon={{ ...getTypeIcon(step.type) }} />
|
|
85
|
+
</Column>
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div ref={ref} aria-label={getTitle(t, step, index)}>
|
|
91
|
+
<div className={listToClass(['chart-node', null, step.status])} >
|
|
92
|
+
{renderContent()}
|
|
93
|
+
<HandleGroup {...props} renderSource={step.type !== 'answer'} renderTarget={step.type !== 'planning'} />
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Icon } from '@stack-spot/citric-icons'
|
|
2
|
+
import { Text } from '@stack-spot/citric-react'
|
|
3
|
+
import { listToClass } from '@stack-spot/portal-theme'
|
|
4
|
+
import { Position } from '@xyflow/react'
|
|
5
|
+
import { StackedBadge } from '../../../components/StackedBadge'
|
|
6
|
+
import { useStepsDictionary } from '../dictionary'
|
|
7
|
+
import { getStatusIcon, getTitle, getTypeIcon } from '../utils'
|
|
8
|
+
import { HandleGroup } from './HandleGroup'
|
|
9
|
+
import { NodeData } from './types'
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data: NodeData,
|
|
13
|
+
targetPosition?: Position,
|
|
14
|
+
sourcePosition?: Position,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const NodeStep = ({ data: { step, index, nextStatus, onClick }, ...props }: Props) => {
|
|
18
|
+
const t = useStepsDictionary()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
className={listToClass(['chart-node', step.type, nextStatus])}
|
|
23
|
+
onClick={() => onClick?.()}
|
|
24
|
+
onKeyDown={e => e.key === 'Enter' && onClick?.()}
|
|
25
|
+
tabIndex={0}
|
|
26
|
+
role="button"
|
|
27
|
+
aria-label={getTitle(t, step, index)}
|
|
28
|
+
>
|
|
29
|
+
<header>
|
|
30
|
+
<Icon {...getTypeIcon(step.type)} />
|
|
31
|
+
<Text className="step-index">{getTitle(t, step, index)}</Text>
|
|
32
|
+
{getStatusIcon(step.status)}
|
|
33
|
+
</header>
|
|
34
|
+
{step.type === 'planning' && <Text className="step-title">{step.goal}</Text>}
|
|
35
|
+
{step.type === 'step' && step.input && <Text className="step-title">{step.input}</Text>}
|
|
36
|
+
{step.type === 'step' && <div className="step-details">
|
|
37
|
+
<Text className={listToClass(['step-description', !!step.attempts[0].tools?.length && 'with-tools'])}>
|
|
38
|
+
{step.output}
|
|
39
|
+
</Text>
|
|
40
|
+
{!!step.attempts[0].tools?.length && <StackedBadge
|
|
41
|
+
label={t.tools}
|
|
42
|
+
images={step.attempts[0].tools?.slice(0, 3).map(
|
|
43
|
+
tool => ({ key: tool.id, name: tool.name ?? '', url: tool.image, icon: <Icon icon="Cog" /> }),
|
|
44
|
+
)}
|
|
45
|
+
/>}
|
|
46
|
+
</div>}
|
|
47
|
+
<HandleGroup {...props} renderSource={step.type !== 'answer'} renderTarget={step.type !== 'planning'} /> </div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { debounce } from 'lodash'
|
|
2
|
+
import { useEffect, useRef } from 'react'
|
|
3
|
+
|
|
4
|
+
interface Size {
|
|
5
|
+
width: number,
|
|
6
|
+
height: number,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useResizeObserver = (callback?: (size: Size) => void, delay = 50) => {
|
|
10
|
+
const ref = useRef<HTMLDivElement | null>(null)
|
|
11
|
+
const previousSizeRef = useRef<Size | null>(null)
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!ref.current || !callback) return
|
|
15
|
+
|
|
16
|
+
const debouncedCallback = debounce((newSize: Size) => {
|
|
17
|
+
const prevSize = previousSizeRef.current
|
|
18
|
+
const hasChanged = !prevSize || prevSize.width !== newSize.width || prevSize.height !== newSize.height
|
|
19
|
+
|
|
20
|
+
if (hasChanged) {
|
|
21
|
+
previousSizeRef.current = newSize
|
|
22
|
+
callback(newSize)
|
|
23
|
+
}
|
|
24
|
+
}, delay)
|
|
25
|
+
|
|
26
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
27
|
+
if (!entries.length) return
|
|
28
|
+
const { width, height } = entries[0].contentRect
|
|
29
|
+
debouncedCallback({ width, height })
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
resizeObserver.observe(ref.current)
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
resizeObserver.disconnect()
|
|
36
|
+
debouncedCallback.cancel()
|
|
37
|
+
}
|
|
38
|
+
}, [callback])
|
|
39
|
+
|
|
40
|
+
return ref
|
|
41
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ChatStep } from '@stack-spot/portal-network'
|
|
2
|
+
import { listToClass, theme } from '@stack-spot/portal-theme'
|
|
3
|
+
import { Background, Controls, Edge, MarkerType, ReactFlow, ReactFlowProvider, useReactFlow } from '@xyflow/react'
|
|
4
|
+
import '@xyflow/react/dist/style.css'
|
|
5
|
+
import { last } from 'lodash'
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
7
|
+
import { useChatEntry } from '../../../context/hooks'
|
|
8
|
+
import { ChatEntry } from '../../../state/ChatEntry'
|
|
9
|
+
import { LayoutDirection, useLayoutedElements } from './layout'
|
|
10
|
+
import { NodeDynamic } from './NodeDynamic'
|
|
11
|
+
import { NodeStep } from './NodeStep'
|
|
12
|
+
import { FlowChartBox } from './styled'
|
|
13
|
+
import { NodeFullProps } from './types'
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
message: ChatEntry,
|
|
17
|
+
onClick: (step: ChatStep, toolIndex?: number) => void,
|
|
18
|
+
direction?: LayoutDirection,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const NODE_TYPES = {
|
|
22
|
+
step: { planning: NodeStep, step: NodeStep, answer: NodeStep },
|
|
23
|
+
stepDynamic: { planning: NodeDynamic, step: NodeDynamic, answer: NodeDynamic },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Flow = ({ message, onClick, direction = 'LR' }: Props) => {
|
|
27
|
+
const steps = useChatEntry(message).steps
|
|
28
|
+
const [nodeSizes, setNodeSizes] = useState<Record<string, { width: number, height: number }>>({})
|
|
29
|
+
const reactFlowInstance = useReactFlow()
|
|
30
|
+
|
|
31
|
+
const isDynamic = useMemo(() => steps?.some((step) => step.id === 'dynamic'), [steps])
|
|
32
|
+
const nodeTypes = useMemo(() => NODE_TYPES[isDynamic ? 'stepDynamic' : 'step'], [isDynamic])
|
|
33
|
+
|
|
34
|
+
const handleNodeSizeChange = useCallback((id: string, size: { width: number, height: number }) => {
|
|
35
|
+
setNodeSizes((prev) => {
|
|
36
|
+
const current = prev[id]
|
|
37
|
+
if (current?.width === size.width && current?.height === size.height) return prev
|
|
38
|
+
return { ...prev, [id]: size }
|
|
39
|
+
})
|
|
40
|
+
}, [])
|
|
41
|
+
|
|
42
|
+
const baseElements = useMemo(() => {
|
|
43
|
+
const nodes = steps?.map((s, index) => {
|
|
44
|
+
const nodeSize = nodeSizes[s.id]
|
|
45
|
+
return {
|
|
46
|
+
id: s.id,
|
|
47
|
+
type: s.type,
|
|
48
|
+
focusable: false,
|
|
49
|
+
...(nodeSize && { width: nodeSize.width, height: nodeSize.height }),
|
|
50
|
+
origin: [1, 0],
|
|
51
|
+
data: {
|
|
52
|
+
message,
|
|
53
|
+
step: s,
|
|
54
|
+
index,
|
|
55
|
+
nextStatus: steps[index + 1]?.status,
|
|
56
|
+
onClick: (toolIndex) => onClick(s, toolIndex),
|
|
57
|
+
onResize: (size) => handleNodeSizeChange(s.id, size),
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}) as NodeFullProps[] ?? []
|
|
61
|
+
const edges: Edge[] = []
|
|
62
|
+
for (let i = 0; i < nodes.length - 1; i++) {
|
|
63
|
+
edges.push({
|
|
64
|
+
id: `${nodes[i].id}-${nodes[i + 1].id}`,
|
|
65
|
+
source: nodes[i].id,
|
|
66
|
+
target: nodes[i + 1].id,
|
|
67
|
+
className: listToClass(['edge', nodes[i]?.data?.nextStatus ?? 'pending']),
|
|
68
|
+
focusable: false,
|
|
69
|
+
markerEnd: {
|
|
70
|
+
type: MarkerType.Arrow,
|
|
71
|
+
strokeWidth: 2,
|
|
72
|
+
color: theme.color.light[700],
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
return { nodes, edges }
|
|
77
|
+
}, [steps, nodeSizes, message, onClick, handleNodeSizeChange])
|
|
78
|
+
|
|
79
|
+
const { nodes, edges } = useLayoutedElements(baseElements.nodes, baseElements.edges, direction)
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const lastNode = last(nodes)
|
|
83
|
+
const isRunning = lastNode?.data?.step?.status === 'running'
|
|
84
|
+
const shouldFitView = nodes.length > 2 && isRunning || (lastNode?.height ?? 0 > 180) && isRunning
|
|
85
|
+
if (shouldFitView) {
|
|
86
|
+
reactFlowInstance.fitView({ duration: 1000, padding: { bottom: '120px', top: '20px' } })
|
|
87
|
+
}
|
|
88
|
+
}, [nodes, edges, reactFlowInstance])
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<FlowChartBox>
|
|
92
|
+
<ReactFlow
|
|
93
|
+
nodes={nodes}
|
|
94
|
+
edges={edges}
|
|
95
|
+
nodeTypes={nodeTypes}
|
|
96
|
+
snapToGrid={true}
|
|
97
|
+
fitView
|
|
98
|
+
maxZoom={1}
|
|
99
|
+
>
|
|
100
|
+
<Controls orientation="horizontal" className="controls" showInteractive={false} />
|
|
101
|
+
<Background />
|
|
102
|
+
</ReactFlow>
|
|
103
|
+
</FlowChartBox>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const FlowChart = (props: Props) => (
|
|
108
|
+
<ReactFlowProvider>
|
|
109
|
+
<Flow {...props} />
|
|
110
|
+
</ReactFlowProvider>
|
|
111
|
+
)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import dagre from '@dagrejs/dagre'
|
|
2
|
+
import { Edge, Position } from '@xyflow/react'
|
|
3
|
+
import { useMemo } from 'react'
|
|
4
|
+
import { answerNodeSize, planningNodeSize, stepNodeSize } from './styled'
|
|
5
|
+
import { NodeFullProps } from './types'
|
|
6
|
+
|
|
7
|
+
const nodesSizes = {
|
|
8
|
+
step: stepNodeSize,
|
|
9
|
+
planning: planningNodeSize,
|
|
10
|
+
answer: answerNodeSize,
|
|
11
|
+
tool: stepNodeSize,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type LayoutDirection = 'TB' | 'BT' | 'LR' | 'RL'
|
|
15
|
+
|
|
16
|
+
const getHandlePositions = (direction: LayoutDirection) => {
|
|
17
|
+
switch (direction) {
|
|
18
|
+
case 'TB':
|
|
19
|
+
return { target: Position.Top, source: Position.Bottom }
|
|
20
|
+
case 'BT':
|
|
21
|
+
return { target: Position.Bottom, source: Position.Top }
|
|
22
|
+
case 'LR':
|
|
23
|
+
return { target: Position.Left, source: Position.Right }
|
|
24
|
+
case 'RL':
|
|
25
|
+
return { target: Position.Right, source: Position.Left }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useLayoutedElements(nodes: NodeFullProps[], edges: Edge[], direction: LayoutDirection = 'LR') {
|
|
30
|
+
const dagreGraph = useMemo(() => new dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({})), [])
|
|
31
|
+
|
|
32
|
+
return useMemo(() => {
|
|
33
|
+
dagreGraph.setGraph({ rankdir: direction })
|
|
34
|
+
|
|
35
|
+
nodes.forEach((node) => {
|
|
36
|
+
const { width, height } = nodesSizes[node.type]
|
|
37
|
+
const nodeWidth = node.width ?? width
|
|
38
|
+
const nodeHeight = node.height ?? height
|
|
39
|
+
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight })
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
edges.forEach((edge) => {
|
|
43
|
+
dagreGraph.setEdge(edge.source, edge.target)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
dagre.layout(dagreGraph)
|
|
47
|
+
|
|
48
|
+
const { target, source } = getHandlePositions(direction)
|
|
49
|
+
|
|
50
|
+
const newNodes: NodeFullProps[] = nodes.map((node) => {
|
|
51
|
+
const { width, height } = nodesSizes[node.type]
|
|
52
|
+
const nodeWidth = node?.width ?? width
|
|
53
|
+
const nodeHeight = node.height ?? height
|
|
54
|
+
const nodeWithPosition = dagreGraph.node(node.id)
|
|
55
|
+
const newNode = {
|
|
56
|
+
...node,
|
|
57
|
+
targetPosition: target,
|
|
58
|
+
sourcePosition: source,
|
|
59
|
+
// We are shifting the dagre node position (anchor=center center) to the top left
|
|
60
|
+
// so it matches the React Flow node anchor point (top left).
|
|
61
|
+
position: {
|
|
62
|
+
x: nodeWithPosition.x - nodeWidth / 2,
|
|
63
|
+
y: nodeWithPosition.y - nodeHeight / 2,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return newNode
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return { nodes: newNodes, edges }
|
|
71
|
+
}, [nodes, edges])
|
|
72
|
+
}
|
|
73
|
+
|