@blocklet/pages-kit 0.2.299 → 0.2.301
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/lib/cjs/builtin/async/ai-runtime/api/{assistant.js → agent.js} +5 -7
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +20 -18
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +5 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormHeader.js → Header/SimpleHeader.js} +9 -16
- package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +6 -8
- package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +2 -2
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +40 -57
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +8 -3
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
- package/lib/cjs/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
- package/lib/cjs/builtin/async/ai-runtime/constants.js +4 -1
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/index.js +16 -63
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +72 -0
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +11 -7
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +7 -4
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +6 -6
- package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +102 -0
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.js +25 -12
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +12 -12
- package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +91 -92
- package/lib/esm/builtin/async/ai-runtime/api/{assistant.js → agent.js} +3 -5
- package/lib/esm/builtin/async/ai-runtime/api/session.js +19 -17
- package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +2 -1
- package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +23 -0
- package/lib/esm/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +5 -4
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +19 -57
- package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +8 -3
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
- package/lib/esm/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
- package/lib/esm/builtin/async/ai-runtime/constants.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +3 -3
- package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +26 -0
- package/lib/esm/builtin/async/ai-runtime/index.js +13 -58
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +66 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +9 -5
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
- package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +73 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +63 -0
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +9 -9
- package/lib/esm/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
- package/lib/esm/builtin/async/ai-runtime/state/session.js +91 -88
- package/lib/types/builtin/async/ai-runtime/api/{assistant.d.ts → agent.d.ts} +4 -4
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +7 -13
- package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/{GlobalLoading.d.ts → GlobalLoading/index.d.ts} +1 -0
- package/lib/types/builtin/async/ai-runtime/components/Header/SimpleHeader.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/Layout/SimpleLayout.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/components/{RuntimeProvider.d.ts → RuntimeCommonProvider.d.ts} +1 -1
- package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +8 -59
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +14 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +13 -24
- package/lib/types/builtin/async/ai-runtime/runtime/ChatBotButton/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.d.ts +2 -2
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +10 -18
- package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +2 -2
- package/package.json +7 -7
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -49
- package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +0 -22
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
- package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +0 -104
- package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +0 -12
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -89
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -66
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -61
- package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +0 -44
- package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +0 -88
- package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -35
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -177
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +0 -48
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -121
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/constants.js +0 -6
- package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/session.js +0 -213
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -133
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -60
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -59
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -28
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -138
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -31
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +0 -54
- package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +0 -74
- package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
- package/lib/cjs/builtin/async/ai-runtime/hooks/auth.js +0 -31
- package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +0 -69
- package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +0 -38
- package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +0 -37
- package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +0 -32
- package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +0 -59
- package/lib/cjs/builtin/async/ai-runtime/state/index.js +0 -423
- package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +0 -52
- package/lib/cjs/builtin/async/ai-runtime/utils.js +0 -49
- package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -46
- package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
- package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +0 -98
- package/lib/esm/builtin/async/ai-runtime/components/common/index.js +0 -3
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -60
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -59
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -54
- package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +0 -38
- package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +0 -82
- package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +0 -8
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -29
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -146
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +0 -42
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -92
- package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +0 -50
- package/lib/esm/builtin/async/ai-runtime/components/runtime/constants.js +0 -3
- package/lib/esm/builtin/async/ai-runtime/components/runtime/state/session.js +0 -209
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -102
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -34
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -53
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -132
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +0 -30
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -25
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +0 -48
- package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +0 -68
- package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
- package/lib/esm/builtin/async/ai-runtime/hooks/auth.js +0 -27
- package/lib/esm/builtin/async/ai-runtime/hooks/header.js +0 -62
- package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +0 -32
- package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +0 -33
- package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +0 -29
- package/lib/esm/builtin/async/ai-runtime/state/assistant.js +0 -54
- package/lib/esm/builtin/async/ai-runtime/state/index.js +0 -423
- package/lib/esm/builtin/async/ai-runtime/state/subscription.js +0 -47
- package/lib/esm/builtin/async/ai-runtime/utils.js +0 -42
- package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +0 -13
- package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +0 -13
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +0 -28
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +0 -11
- package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +0 -14
- package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +0 -9
- package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/runtime/constants.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/assistant.d.ts +0 -17
- package/lib/types/builtin/async/ai-runtime/components/runtime/state/session.d.ts +0 -29
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +0 -6
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/hooks/auth.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +0 -25
- package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/utils.d.ts +0 -20
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
- /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
- /package/lib/esm/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{state/loading.d.ts → components/GlobalLoading/state.d.ts} +0 -0
- /package/lib/types/builtin/async/ai-runtime/components/{common/UserInfo.d.ts → UserInfo.d.ts} +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.d.ts +0 -0
- /package/lib/types/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.d.ts +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { joinURL, withQuery } from 'ufo';
|
|
2
|
-
import { useSessionContext } from '../../../session';
|
|
3
|
-
import { getComponentMountPoint } from '../../../utils';
|
|
4
|
-
import { PAYMENT_KIT_DID } from '../constants';
|
|
5
|
-
import { useAssistantState } from '../state/assistant';
|
|
6
|
-
import { useSubscriptionState } from '../state/subscription';
|
|
7
|
-
export function useSubscribeLink({ assistantId }) {
|
|
8
|
-
var _a, _b, _c, _d, _e;
|
|
9
|
-
const [, state] = useSubscriptionState({ aid: assistantId });
|
|
10
|
-
const [assistant] = useAssistantState({ assistantId });
|
|
11
|
-
const { session: authSession } = useSessionContext();
|
|
12
|
-
const requireSubscribe = ((_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.enable) && !state.subscription;
|
|
13
|
-
const isPaymentProject = (_d = (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.payment) === null || _d === void 0 ? void 0 : _d.enable;
|
|
14
|
-
const subscribeLink = requireSubscribe && authSession.user && ((_e = state.release) === null || _e === void 0 ? void 0 : _e.paymentLinkId)
|
|
15
|
-
? getSubscribeLink({
|
|
16
|
-
aid: assistantId,
|
|
17
|
-
userId: authSession.user.did,
|
|
18
|
-
paymentLinkId: state.release.paymentLinkId,
|
|
19
|
-
})
|
|
20
|
-
: undefined;
|
|
21
|
-
return {
|
|
22
|
-
requireSubscribe,
|
|
23
|
-
subscribeLink,
|
|
24
|
-
isPaymentProject,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function getSubscribeLink({ aid, userId, paymentLinkId }) {
|
|
28
|
-
return withQuery(joinURL('/', getComponentMountPoint(PAYMENT_KIT_DID), '/checkout/pay', paymentLinkId), {
|
|
29
|
-
'metadata.aid': aid,
|
|
30
|
-
'metadata.userId': userId,
|
|
31
|
-
redirect: window.location.href,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const PROMISE_CACHE = {};
|
|
2
|
-
export default function useAsync(fn, keys) {
|
|
3
|
-
const key = keys.join('_');
|
|
4
|
-
let cache = PROMISE_CACHE[key];
|
|
5
|
-
if (!cache) {
|
|
6
|
-
const promise = fn();
|
|
7
|
-
const isPromise = promise instanceof Promise;
|
|
8
|
-
cache = {
|
|
9
|
-
promise: Promise.resolve(promise)
|
|
10
|
-
.then((result) => {
|
|
11
|
-
PROMISE_CACHE[key].result = result;
|
|
12
|
-
})
|
|
13
|
-
.catch((error) => {
|
|
14
|
-
PROMISE_CACHE[key].error = error;
|
|
15
|
-
})
|
|
16
|
-
.finally(() => {
|
|
17
|
-
PROMISE_CACHE[key].done = true;
|
|
18
|
-
}),
|
|
19
|
-
done: !isPromise,
|
|
20
|
-
result: isPromise ? undefined : promise,
|
|
21
|
-
};
|
|
22
|
-
PROMISE_CACHE[key] = cache;
|
|
23
|
-
}
|
|
24
|
-
if (cache.error)
|
|
25
|
-
throw cache.error;
|
|
26
|
-
if (cache.done)
|
|
27
|
-
return cache.result;
|
|
28
|
-
throw cache.promise;
|
|
29
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { create } from 'zustand';
|
|
11
|
-
import { immer } from 'zustand/middleware/immer';
|
|
12
|
-
import { getAssistant } from '../api/assistant';
|
|
13
|
-
const STATES = {};
|
|
14
|
-
export const createAssistantState = ({ assistantId, assistant }) => {
|
|
15
|
-
var _a;
|
|
16
|
-
(_a = STATES[assistantId]) !== null && _a !== void 0 ? _a : (STATES[assistantId] = create()(immer((set) => ({
|
|
17
|
-
assistant,
|
|
18
|
-
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
set((state) => {
|
|
20
|
-
state.loading = true;
|
|
21
|
-
});
|
|
22
|
-
try {
|
|
23
|
-
const assistant = yield getAssistant({ assistantId });
|
|
24
|
-
set((state) => {
|
|
25
|
-
state.assistant = assistant;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
console.error(error);
|
|
30
|
-
set((state) => {
|
|
31
|
-
state.error = error;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
set((state) => {
|
|
36
|
-
state.loading = false;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}),
|
|
40
|
-
}))));
|
|
41
|
-
return STATES[assistantId];
|
|
42
|
-
};
|
|
43
|
-
const LOADING_TASKS = {};
|
|
44
|
-
export function useAssistantState({ assistantId }) {
|
|
45
|
-
var _a;
|
|
46
|
-
const state = createAssistantState({ assistantId })();
|
|
47
|
-
if (!state.assistant) {
|
|
48
|
-
if (state.error)
|
|
49
|
-
throw state.error;
|
|
50
|
-
(_a = LOADING_TASKS[assistantId]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[assistantId] = state.load());
|
|
51
|
-
throw LOADING_TASKS[assistantId];
|
|
52
|
-
}
|
|
53
|
-
return [state.assistant, state];
|
|
54
|
-
}
|
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { StoreApi, UseBoundStore, create } from 'zustand';
|
|
3
|
-
// import { immer } from 'zustand/middleware/immer';
|
|
4
|
-
// import { EventSourceParserStream } from '../../../stream';
|
|
5
|
-
// import { getComponentMountPoint, joinURL } from '../../../utils';
|
|
6
|
-
// import { Assistant, getAssistant } from '../api/assistant';
|
|
7
|
-
// import {
|
|
8
|
-
// Dataset,
|
|
9
|
-
// createDataset,
|
|
10
|
-
// createDocument,
|
|
11
|
-
// deleteDataset,
|
|
12
|
-
// deleteDocument,
|
|
13
|
-
// getDataset,
|
|
14
|
-
// getDatasets,
|
|
15
|
-
// getDocuments,
|
|
16
|
-
// updateDataset,
|
|
17
|
-
// updateDocument,
|
|
18
|
-
// } from '../api/dataset';
|
|
19
|
-
// import { deleteMessages, getMessages } from '../api/message';
|
|
20
|
-
// import { Session, createSession, getSessions, updateSession } from '../api/session';
|
|
21
|
-
// import { Subscription, getSubscription } from '../api/subscription';
|
|
22
|
-
// import { AI_STUDIO_DID } from '../constants';
|
|
23
|
-
// import { parseIdentity } from '../utils';
|
|
24
|
-
// const STATES: {
|
|
25
|
-
// assistant: { [key: string]: UseBoundStore<StoreApi<State>> };
|
|
26
|
-
// dataset: { [key: string]: ReturnType<typeof createDatasetState> };
|
|
27
|
-
// datasetDetail: { [key: string]: ReturnType<typeof createDatasetDetailState> };
|
|
28
|
-
// } = { assistant: {}, dataset: {}, datasetDetail: {} };
|
|
29
|
-
// export interface State {
|
|
30
|
-
// loading: boolean;
|
|
31
|
-
// loaded: boolean;
|
|
32
|
-
// assistant?: Assistant;
|
|
33
|
-
// sessions?: Session[];
|
|
34
|
-
// subscription?: Subscription;
|
|
35
|
-
// sessionMap: { [sessionId: string]: { session: Session } };
|
|
36
|
-
// computed: {
|
|
37
|
-
// get isChat(): boolean | undefined;
|
|
38
|
-
// get requireNewSubscription(): boolean | undefined;
|
|
39
|
-
// };
|
|
40
|
-
// }
|
|
41
|
-
// export const createState = ({
|
|
42
|
-
// releaseId,
|
|
43
|
-
// preload: { assistant, sessions, subscription } = {},
|
|
44
|
-
// }: {
|
|
45
|
-
// releaseId: string;
|
|
46
|
-
// preload?: {
|
|
47
|
-
// assistant?: Assistant;
|
|
48
|
-
// sessions?: Session[];
|
|
49
|
-
// subscription?: Subscription;
|
|
50
|
-
// };
|
|
51
|
-
// }) => {
|
|
52
|
-
// STATES.assistant[releaseId] ??= create<State>()(
|
|
53
|
-
// immer<State>((set, get) => ({
|
|
54
|
-
// loading: false,
|
|
55
|
-
// loaded: false,
|
|
56
|
-
// assistant,
|
|
57
|
-
// sessions,
|
|
58
|
-
// subscription,
|
|
59
|
-
// sessionMap: Object.fromEntries((sessions ?? []).map((session) => [session.id, { session }])),
|
|
60
|
-
// computed: {
|
|
61
|
-
// get isChat() {
|
|
62
|
-
// const parameters = get().assistant?.parameters;
|
|
63
|
-
// return parameters?.some((i) => i.key === 'question');
|
|
64
|
-
// },
|
|
65
|
-
// get requireNewSubscription() {
|
|
66
|
-
// // TODO: implement payment
|
|
67
|
-
// // const { subscription } = get();
|
|
68
|
-
// // const { paymentEnabled, paymentLinkId } = release;
|
|
69
|
-
// // return !!paymentEnabled && !!paymentLinkId && !subscription;
|
|
70
|
-
// return false;
|
|
71
|
-
// },
|
|
72
|
-
// get withCollection() {
|
|
73
|
-
// const parameters = get().assistant?.parameters;
|
|
74
|
-
// return parameters?.some((i) => i.key === 'datasetId');
|
|
75
|
-
// },
|
|
76
|
-
// },
|
|
77
|
-
// getPaymentLink({ userId }: { userId: string }) {
|
|
78
|
-
// // TODO: implement
|
|
79
|
-
// // return withQuery(
|
|
80
|
-
// // joinURL('/', getComponentMountPoint(PAYMENT_KIT_DID), '/checkout/pay', release.paymentLinkId),
|
|
81
|
-
// // {
|
|
82
|
-
// // 'metadata.releaseId': release.id,
|
|
83
|
-
// // 'metadata.userId': userId,
|
|
84
|
-
// // redirect: window.location.href,
|
|
85
|
-
// // }
|
|
86
|
-
// // );
|
|
87
|
-
// },
|
|
88
|
-
// getAssistant: async () => {
|
|
89
|
-
// set((state) => {
|
|
90
|
-
// state.loading = true;
|
|
91
|
-
// });
|
|
92
|
-
// try {
|
|
93
|
-
// const { subscription } = await getSubscription({ releaseId });
|
|
94
|
-
// const identity = parseIdentity(releaseId, { rejectWhenError: true });
|
|
95
|
-
// const [assistant, { sessions }] = await Promise.all([getAssistant(identity), getSessions(identity)]);
|
|
96
|
-
// set((state) => {
|
|
97
|
-
// state.assistant = assistant;
|
|
98
|
-
// state.sessions = sessions;
|
|
99
|
-
// state.subscription = subscription;
|
|
100
|
-
// state.sessionMap = Object.fromEntries(
|
|
101
|
-
// (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
|
|
102
|
-
// );
|
|
103
|
-
// });
|
|
104
|
-
// } finally {
|
|
105
|
-
// set((state) => {
|
|
106
|
-
// state.loading = false;
|
|
107
|
-
// state.loaded = true;
|
|
108
|
-
// });
|
|
109
|
-
// }
|
|
110
|
-
// },
|
|
111
|
-
// getSessions: async () => {
|
|
112
|
-
// const identity = parseIdentity(releaseId, { rejectWhenError: true });
|
|
113
|
-
// const { sessions } = await getSessions(identity);
|
|
114
|
-
// set((state) => {
|
|
115
|
-
// state.sessions = sessions;
|
|
116
|
-
// state.sessionMap = Object.fromEntries(
|
|
117
|
-
// (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
|
|
118
|
-
// );
|
|
119
|
-
// });
|
|
120
|
-
// },
|
|
121
|
-
// reloadMessages: async ({ sessionId }) => {
|
|
122
|
-
// set((state) => {
|
|
123
|
-
// const s = state.sessionMap[sessionId];
|
|
124
|
-
// if (!s) return;
|
|
125
|
-
// s.loading = true;
|
|
126
|
-
// });
|
|
127
|
-
// try {
|
|
128
|
-
// const { messages, count } = await getMessages({ sessionId });
|
|
129
|
-
// set((state) => {
|
|
130
|
-
// const s = state.sessionMap[sessionId];
|
|
131
|
-
// if (!s) return;
|
|
132
|
-
// s.messages = messages;
|
|
133
|
-
// s.messageCount = count;
|
|
134
|
-
// });
|
|
135
|
-
// } finally {
|
|
136
|
-
// set((state) => {
|
|
137
|
-
// const s = state.sessionMap[sessionId];
|
|
138
|
-
// if (!s) return;
|
|
139
|
-
// s.loading = false;
|
|
140
|
-
// });
|
|
141
|
-
// }
|
|
142
|
-
// },
|
|
143
|
-
// cleanSession: async ({ sessionId }) => {
|
|
144
|
-
// set((state) => {
|
|
145
|
-
// const s = state.sessionMap[sessionId];
|
|
146
|
-
// if (s) s.sessionReseting = true;
|
|
147
|
-
// });
|
|
148
|
-
// await deleteMessages({ sessionId });
|
|
149
|
-
// set((state) => {
|
|
150
|
-
// const s = state.sessionMap[sessionId];
|
|
151
|
-
// if (s) {
|
|
152
|
-
// s.sessionReseting = false;
|
|
153
|
-
// s.messages = [];
|
|
154
|
-
// }
|
|
155
|
-
// });
|
|
156
|
-
// },
|
|
157
|
-
// createSession: async ({ name, parameters, entry }) => {
|
|
158
|
-
// const identity = parseIdentity(releaseId);
|
|
159
|
-
// const { sessions, created } = await createSession({ ...identity, name, parameters, entry });
|
|
160
|
-
// set((state) => {
|
|
161
|
-
// state.sessions = sessions;
|
|
162
|
-
// state.sessionMap = Object.fromEntries(
|
|
163
|
-
// (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
|
|
164
|
-
// );
|
|
165
|
-
// });
|
|
166
|
-
// return created;
|
|
167
|
-
// },
|
|
168
|
-
// updateSession: async ({ sessionId, parameters }) => {
|
|
169
|
-
// set((state) => {
|
|
170
|
-
// const s = state.sessionMap[sessionId].session;
|
|
171
|
-
// if (s.parameters) Object.assign(s.parameters, parameters);
|
|
172
|
-
// });
|
|
173
|
-
// const { sessions } = await updateSession({ sessionId, parameters });
|
|
174
|
-
// set((state) => {
|
|
175
|
-
// state.sessions = sessions;
|
|
176
|
-
// state.sessionMap = Object.fromEntries(
|
|
177
|
-
// (sessions ?? []).map((session) => [session.id, { ...state.sessionMap[session.id], session }])
|
|
178
|
-
// );
|
|
179
|
-
// });
|
|
180
|
-
// },
|
|
181
|
-
// execute: async ({ sessionId, parameters, onResponseStart, assistantIdentity }) => {
|
|
182
|
-
// const identity = parseIdentity(releaseId);
|
|
183
|
-
// let message;
|
|
184
|
-
// const childMessages = [];
|
|
185
|
-
// const childMessagesMap = {};
|
|
186
|
-
// set((state) => {
|
|
187
|
-
// const session = state.sessionMap[sessionId];
|
|
188
|
-
// if (session) session.executing = true;
|
|
189
|
-
// });
|
|
190
|
-
// try {
|
|
191
|
-
// const res = await fetch(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/ai/call'), {
|
|
192
|
-
// method: 'POST',
|
|
193
|
-
// headers: {
|
|
194
|
-
// 'Content-Type': 'application/json',
|
|
195
|
-
// Accept: 'text/event-stream',
|
|
196
|
-
// },
|
|
197
|
-
// body: JSON.stringify({
|
|
198
|
-
// sessionId,
|
|
199
|
-
// parameters: { ...parameters, $clientTime: new Date().toISOString() },
|
|
200
|
-
// ...(assistantIdentity || identity),
|
|
201
|
-
// ref: (assistantIdentity || identity).projectRef,
|
|
202
|
-
// working: true,
|
|
203
|
-
// }),
|
|
204
|
-
// });
|
|
205
|
-
// if (!(res.status >= 200 && res.status < 300)) {
|
|
206
|
-
// let json: any;
|
|
207
|
-
// try {
|
|
208
|
-
// json = await res.json();
|
|
209
|
-
// } catch (error) {}
|
|
210
|
-
// const { message } = json.error;
|
|
211
|
-
// if (typeof message === 'string') {
|
|
212
|
-
// throw new Error(message);
|
|
213
|
-
// }
|
|
214
|
-
// throw new Error(`Unknown Error: ${res.status}`);
|
|
215
|
-
// }
|
|
216
|
-
// const stream = res
|
|
217
|
-
// .body!.pipeThrough(new TextDecoderStream())
|
|
218
|
-
// .pipeThrough(new EventSourceParserStream())
|
|
219
|
-
// .getReader();
|
|
220
|
-
// let responseStarted = false;
|
|
221
|
-
// for (;;) {
|
|
222
|
-
// const { value, done } = await stream.read();
|
|
223
|
-
// if (!responseStarted) {
|
|
224
|
-
// responseStarted = true;
|
|
225
|
-
// onResponseStart?.();
|
|
226
|
-
// }
|
|
227
|
-
// if (value?.type === 'CHUNK') {
|
|
228
|
-
// if (!message) {
|
|
229
|
-
// message = {
|
|
230
|
-
// taskId: value.taskId,
|
|
231
|
-
// parameters,
|
|
232
|
-
// loading: true,
|
|
233
|
-
// createdAt: new Date().toISOString(),
|
|
234
|
-
// };
|
|
235
|
-
// set((state) => {
|
|
236
|
-
// state.sessionMap[sessionId] ??= {};
|
|
237
|
-
// state.sessionMap[sessionId].messages ??= [];
|
|
238
|
-
// state.sessionMap[sessionId].messages.push(message);
|
|
239
|
-
// });
|
|
240
|
-
// }
|
|
241
|
-
// if (message.taskId === value.taskId) {
|
|
242
|
-
// set((state) => {
|
|
243
|
-
// const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
|
|
244
|
-
// if (!msg) return;
|
|
245
|
-
// msg.result ??= {};
|
|
246
|
-
// msg.result.content = (msg.result.content || '') + (value.delta.content || '');
|
|
247
|
-
// if (value.delta.object) {
|
|
248
|
-
// msg.result.objects ??= [];
|
|
249
|
-
// msg.result.objects.push(value.delta.object);
|
|
250
|
-
// if (value.delta.object.metadata) {
|
|
251
|
-
// const session = state.sessionMap[sessionId];
|
|
252
|
-
// session.metadata ??= {};
|
|
253
|
-
// deepMerge(session.metadata, value.delta.object.metadata);
|
|
254
|
-
// }
|
|
255
|
-
// }
|
|
256
|
-
// if (value.delta?.images?.length) {
|
|
257
|
-
// msg.result.images = (msg.result.images ?? []).concat(value.delta.images);
|
|
258
|
-
// }
|
|
259
|
-
// });
|
|
260
|
-
// } else if (value.respondAs && value.respondAs !== 'none') {
|
|
261
|
-
// let childMessage = childMessagesMap[value.taskId];
|
|
262
|
-
// if (!childMessage) {
|
|
263
|
-
// childMessage = {
|
|
264
|
-
// taskId: value.taskId,
|
|
265
|
-
// createdAt: new Date().toISOString(),
|
|
266
|
-
// respondAs: value.respondAs,
|
|
267
|
-
// };
|
|
268
|
-
// childMessagesMap[value.taskId] = childMessage;
|
|
269
|
-
// childMessages.push(childMessage);
|
|
270
|
-
// }
|
|
271
|
-
// childMessage.result ??= {};
|
|
272
|
-
// childMessage.result.content = (childMessage.result.content || '') + (value.delta.content || '');
|
|
273
|
-
// if (value.delta?.images?.length) {
|
|
274
|
-
// childMessage.result.images = (childMessage.result.images ?? []).concat(value.delta.images);
|
|
275
|
-
// }
|
|
276
|
-
// set((state) => {
|
|
277
|
-
// const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
|
|
278
|
-
// if (!msg) return;
|
|
279
|
-
// msg.result ??= {};
|
|
280
|
-
// msg.result.messages = JSON.parse(JSON.stringify(childMessages));
|
|
281
|
-
// });
|
|
282
|
-
// }
|
|
283
|
-
// }
|
|
284
|
-
// if (value?.type === 'ERROR') {
|
|
285
|
-
// set((state) => {
|
|
286
|
-
// const msg = state.sessionMap[sessionId]?.messages?.findLast((i) => i.taskId === message.taskId);
|
|
287
|
-
// if (msg) msg.error = value.error;
|
|
288
|
-
// else throw new Error(value.error.message);
|
|
289
|
-
// });
|
|
290
|
-
// }
|
|
291
|
-
// if (done) break;
|
|
292
|
-
// }
|
|
293
|
-
// } finally {
|
|
294
|
-
// set((state) => {
|
|
295
|
-
// const session = state.sessionMap[sessionId];
|
|
296
|
-
// session.executing = false;
|
|
297
|
-
// if (session && message) {
|
|
298
|
-
// const msg = session.messages?.findLast((i) => i.taskId === message.taskId);
|
|
299
|
-
// if (msg) msg.loading = false;
|
|
300
|
-
// }
|
|
301
|
-
// });
|
|
302
|
-
// }
|
|
303
|
-
// },
|
|
304
|
-
// }))
|
|
305
|
-
// );
|
|
306
|
-
// return STATES.assistant[releaseId]!;
|
|
307
|
-
// };
|
|
308
|
-
// export function createDatasetState({ releaseId, datasets }: { releaseId: string; datasets?: Dataset[] }) {
|
|
309
|
-
// STATES.dataset[releaseId] ??= create()(
|
|
310
|
-
// immer((set) => ({
|
|
311
|
-
// loading: false,
|
|
312
|
-
// list: datasets,
|
|
313
|
-
// error: undefined,
|
|
314
|
-
// creating: false,
|
|
315
|
-
// async reload() {
|
|
316
|
-
// try {
|
|
317
|
-
// set((state) => {
|
|
318
|
-
// state.loading = true;
|
|
319
|
-
// });
|
|
320
|
-
// const datasets = await getDatasets({ appId: releaseId });
|
|
321
|
-
// set((state) => {
|
|
322
|
-
// state.loading = false;
|
|
323
|
-
// state.list = datasets;
|
|
324
|
-
// state.error = undefined;
|
|
325
|
-
// });
|
|
326
|
-
// } catch (error) {
|
|
327
|
-
// set((state) => {
|
|
328
|
-
// state.loading = false;
|
|
329
|
-
// state.error = error;
|
|
330
|
-
// });
|
|
331
|
-
// }
|
|
332
|
-
// },
|
|
333
|
-
// async createDataset({ name, description }: { name: string; description?: string }) {
|
|
334
|
-
// try {
|
|
335
|
-
// set((state) => {
|
|
336
|
-
// state.creating = true;
|
|
337
|
-
// });
|
|
338
|
-
// const created = await createDataset({ appId: releaseId, name, description });
|
|
339
|
-
// await this.reload();
|
|
340
|
-
// return created;
|
|
341
|
-
// } finally {
|
|
342
|
-
// set((state) => {
|
|
343
|
-
// state.creating = false;
|
|
344
|
-
// });
|
|
345
|
-
// }
|
|
346
|
-
// },
|
|
347
|
-
// async updateDataset(datasetId: string, { name, description }: { name: string; description?: string }) {
|
|
348
|
-
// const updated = await updateDataset(datasetId, { name, description });
|
|
349
|
-
// await this.reload();
|
|
350
|
-
// return updated;
|
|
351
|
-
// },
|
|
352
|
-
// async deleteDataset(datasetId: string) {
|
|
353
|
-
// await deleteDataset(datasetId);
|
|
354
|
-
// await this.reload();
|
|
355
|
-
// },
|
|
356
|
-
// }))
|
|
357
|
-
// );
|
|
358
|
-
// return STATES.dataset[releaseId];
|
|
359
|
-
// }
|
|
360
|
-
// export function createDatasetDetailState({ datasetId, list }: { datasetId: string; list?: Document[] }) {
|
|
361
|
-
// STATES.datasetDetail[datasetId] ??= create()(
|
|
362
|
-
// immer((set, get) => ({
|
|
363
|
-
// loading: false,
|
|
364
|
-
// dataset: undefined,
|
|
365
|
-
// list,
|
|
366
|
-
// error: undefined,
|
|
367
|
-
// creating: false,
|
|
368
|
-
// async reload() {
|
|
369
|
-
// if (get().loading) return;
|
|
370
|
-
// set((state) => {
|
|
371
|
-
// state.loading = true;
|
|
372
|
-
// });
|
|
373
|
-
// try {
|
|
374
|
-
// const [dataset, { items }] = await Promise.all([getDataset({ datasetId }), getDocuments(datasetId)]);
|
|
375
|
-
// set((state) => {
|
|
376
|
-
// state.dataset = dataset;
|
|
377
|
-
// state.loading = false;
|
|
378
|
-
// state.list = items;
|
|
379
|
-
// state.error = undefined;
|
|
380
|
-
// });
|
|
381
|
-
// } catch (error) {
|
|
382
|
-
// set((state) => {
|
|
383
|
-
// state.loading = false;
|
|
384
|
-
// state.error = error;
|
|
385
|
-
// });
|
|
386
|
-
// }
|
|
387
|
-
// },
|
|
388
|
-
// async createDocument(type: 'text' | 'file', input: Parameters<typeof createDocument>[1]) {
|
|
389
|
-
// try {
|
|
390
|
-
// set((state) => {
|
|
391
|
-
// state.creating = true;
|
|
392
|
-
// });
|
|
393
|
-
// const created = await createDocument(datasetId, type, input);
|
|
394
|
-
// await this.reload();
|
|
395
|
-
// return created;
|
|
396
|
-
// } finally {
|
|
397
|
-
// set((state) => {
|
|
398
|
-
// state.creating = false;
|
|
399
|
-
// });
|
|
400
|
-
// }
|
|
401
|
-
// },
|
|
402
|
-
// async updateDocument(documentId: string, type: 'text', input: Parameters<typeof updateDocument>[1]) {
|
|
403
|
-
// try {
|
|
404
|
-
// set((state) => {
|
|
405
|
-
// state.updating = true;
|
|
406
|
-
// });
|
|
407
|
-
// const updated = await updateDocument(datasetId, documentId, type, input);
|
|
408
|
-
// await this.reload();
|
|
409
|
-
// return updated;
|
|
410
|
-
// } finally {
|
|
411
|
-
// set((state) => {
|
|
412
|
-
// state.updating = false;
|
|
413
|
-
// });
|
|
414
|
-
// }
|
|
415
|
-
// },
|
|
416
|
-
// async deleteDocument(documentId) {
|
|
417
|
-
// await deleteDocument(datasetId, documentId);
|
|
418
|
-
// await this.reload();
|
|
419
|
-
// },
|
|
420
|
-
// }))
|
|
421
|
-
// );
|
|
422
|
-
// return STATES.datasetDetail[datasetId];
|
|
423
|
-
// }
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { create } from 'zustand';
|
|
11
|
-
import { immer } from 'zustand/middleware/immer';
|
|
12
|
-
import { getRelease, getSubscription } from '../api/subscription';
|
|
13
|
-
const STATES = {};
|
|
14
|
-
export const createSubscriptionState = ({ aid }) => {
|
|
15
|
-
var _a;
|
|
16
|
-
(_a = STATES[aid]) !== null && _a !== void 0 ? _a : (STATES[aid] = create()(immer((set) => ({
|
|
17
|
-
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
set((state) => {
|
|
19
|
-
state.loading = true;
|
|
20
|
-
});
|
|
21
|
-
try {
|
|
22
|
-
const [{ subscription }, release] = yield Promise.all([getSubscription({ aid }), getRelease({ aid })]);
|
|
23
|
-
set((state) => {
|
|
24
|
-
state.subscription = subscription;
|
|
25
|
-
state.release = release;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
set((state) => {
|
|
30
|
-
state.loading = false;
|
|
31
|
-
state.loaded = true;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}),
|
|
35
|
-
}))));
|
|
36
|
-
return STATES[aid];
|
|
37
|
-
};
|
|
38
|
-
const LOADING_TASKS = {};
|
|
39
|
-
export function useSubscriptionState({ aid }) {
|
|
40
|
-
var _a;
|
|
41
|
-
const state = createSubscriptionState({ aid })();
|
|
42
|
-
if (!state.loaded && !state.subscription) {
|
|
43
|
-
(_a = LOADING_TASKS[aid]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[aid] = state.load());
|
|
44
|
-
throw LOADING_TASKS[aid];
|
|
45
|
-
}
|
|
46
|
-
return [state.subscription, state];
|
|
47
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Base64 } from 'js-base64';
|
|
2
|
-
export function parseIdentity(aid, options) {
|
|
3
|
-
let projectId;
|
|
4
|
-
let projectRef;
|
|
5
|
-
let assistantId;
|
|
6
|
-
try {
|
|
7
|
-
const s = Base64.decode(aid).split('/');
|
|
8
|
-
[projectId, projectRef, assistantId] = s.length === 3 ? s : s.length === 2 ? [s[0], 'main', s[1]] : [];
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
console.error('parse assistantId error', { error });
|
|
12
|
-
}
|
|
13
|
-
if (projectId && projectRef && assistantId)
|
|
14
|
-
return { projectId, projectRef, assistantId };
|
|
15
|
-
if (options === null || options === void 0 ? void 0 : options.rejectWhenError)
|
|
16
|
-
throw new Error(`Invalid assistant identity ${aid}`);
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
export function stringifyIdentity({ projectId, projectRef, assistantId, }) {
|
|
20
|
-
return Base64.encodeURI([projectId, projectRef, assistantId].join('/'));
|
|
21
|
-
}
|
|
22
|
-
function isObject(obj) {
|
|
23
|
-
return typeof obj === 'object' && !Array.isArray(obj);
|
|
24
|
-
}
|
|
25
|
-
export function deepMerge(target, source) {
|
|
26
|
-
if (isObject(target) && isObject(source)) {
|
|
27
|
-
for (const key of Object.keys(source)) {
|
|
28
|
-
if (isObject(source[key])) {
|
|
29
|
-
if (!target[key] || !isObject(target[key]))
|
|
30
|
-
target[key] = source[key];
|
|
31
|
-
deepMerge(target[key], source[key]);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
target[key] = source[key];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export const mergeSx = (initial, sx) => {
|
|
40
|
-
const mergedSx = [initial, ...(Array.isArray(sx) ? sx : [sx])];
|
|
41
|
-
return mergedSx;
|
|
42
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ListItemButtonProps } from '@mui/material';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export default function LoadingListItemButton({ children, confirmation, ...props }: ListItemButtonProps & {
|
|
4
|
-
confirmation?: ReactNode;
|
|
5
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type SizeProps = number | string;
|
|
3
|
-
export interface ChatBotProps {
|
|
4
|
-
assistantId: string;
|
|
5
|
-
size?: SizeProps;
|
|
6
|
-
bottom?: SizeProps;
|
|
7
|
-
right?: SizeProps;
|
|
8
|
-
popperHeight?: SizeProps;
|
|
9
|
-
popperWidth?: SizeProps;
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
}
|
|
12
|
-
export default function ChatBot({ assistantId, size, bottom, right, children, popperWidth, popperHeight, }: ChatBotProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
-
export {};
|