@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,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
const react_1 = require("@iconify/react");
|
|
28
|
-
const material_1 = require("@mui/material");
|
|
29
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
30
|
-
const react_2 = require("react");
|
|
31
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
32
|
-
const locale_1 = require("../../../../locale");
|
|
33
|
-
const session_1 = require("../../../../session");
|
|
34
|
-
const session_2 = require("../../api/session");
|
|
35
|
-
const assistant_1 = require("../../state/assistant");
|
|
36
|
-
const loading_1 = require("../../state/loading");
|
|
37
|
-
const session_3 = require("../../state/session");
|
|
38
|
-
const ParameterFormFields_1 = __importDefault(require("../form/ParameterFormFields"));
|
|
39
|
-
const RuntimeFormSubmit_1 = __importDefault(require("./RuntimeFormSubmit"));
|
|
40
|
-
function RuntimeFormForms(_a) {
|
|
41
|
-
var _b, _c, _d;
|
|
42
|
-
var { page } = _a, props = __rest(_a, ["page"]);
|
|
43
|
-
const { t } = (0, locale_1.useLocaleContext)();
|
|
44
|
-
const theme = (0, material_1.useTheme)();
|
|
45
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
|
|
46
|
-
const [agent] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
|
|
47
|
-
const spacing = {
|
|
48
|
-
md: 2.5,
|
|
49
|
-
xs: 2,
|
|
50
|
-
};
|
|
51
|
-
const lastParameters = (0, react_2.useMemo)(() => {
|
|
52
|
-
var _a;
|
|
53
|
-
if (page.sessionId) {
|
|
54
|
-
const { session, messages = [] } = (0, session_3.createSessionState)({ sessionId: page.sessionId }).getState();
|
|
55
|
-
const lastMessage = messages[messages.length - 1];
|
|
56
|
-
return (_a = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters) !== null && _a !== void 0 ? _a : session === null || session === void 0 ? void 0 : session.parameters;
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}, [page.sessionId]);
|
|
60
|
-
const defaultForm = (0, react_2.useMemo)(() => {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [
|
|
63
|
-
parameter.key,
|
|
64
|
-
(lastParameters === null || lastParameters === void 0 ? void 0 : lastParameters[parameter.key]) || parameter.defaultValue,
|
|
65
|
-
])) !== null && _b !== void 0 ? _b : []);
|
|
66
|
-
}, [agent.parameters, lastParameters]);
|
|
67
|
-
const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
|
|
68
|
-
const [error, setError] = (0, react_2.useState)();
|
|
69
|
-
const [expand, setExpand] = (0, react_2.useState)(false);
|
|
70
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
71
|
-
const [submitting, setSubmitting] = (0, react_2.useState)(false);
|
|
72
|
-
(0, react_2.useEffect)(() => {
|
|
73
|
-
form.reset(defaultForm);
|
|
74
|
-
}, [defaultForm]);
|
|
75
|
-
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (!authSession.user) {
|
|
77
|
-
// TODO:
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
setSubmitting(true);
|
|
82
|
-
let { sessionId } = page;
|
|
83
|
-
if (!sessionId) {
|
|
84
|
-
const session = yield loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const { created: session } = yield (0, session_2.createSession)({ assistantId: page.assistantId, parameters });
|
|
86
|
-
yield (0, session_3.createSessionState)({ sessionId: session.id }).getState().load();
|
|
87
|
-
return session;
|
|
88
|
-
}));
|
|
89
|
-
sessionId = session.id;
|
|
90
|
-
page.navigate({ page: 'session', assistantId: page.assistantId, sessionId: session.id });
|
|
91
|
-
}
|
|
92
|
-
const sid = sessionId;
|
|
93
|
-
yield new Promise((resolve, reject) => {
|
|
94
|
-
setTimeout(() => {
|
|
95
|
-
const session = (0, session_3.createSessionState)({ sessionId: sid }).getState();
|
|
96
|
-
session.execute({ assistantId: page.assistantId, parameters }).then(resolve).catch(reject);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
setError(error);
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
setSubmitting(false);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
const handleSubmit = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
var _e;
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
(_e = agent.parameters) === null || _e === void 0 ? void 0 : _e.some((parameter) => {
|
|
112
|
-
if (parameter.required && (0, isEmpty_1.default)(form.getValues(parameter.key))) {
|
|
113
|
-
setExpand(true);
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
});
|
|
118
|
-
// focus the first error field
|
|
119
|
-
form.trigger();
|
|
120
|
-
return form.handleSubmit(onSubmit)(e);
|
|
121
|
-
});
|
|
122
|
-
const openerMessage = (_b = agent.release) === null || _b === void 0 ? void 0 : _b.openerMessage;
|
|
123
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ component: "form" }, props, { onSubmit: handleSubmit, children: [isMobile && ((0, jsx_runtime_1.jsx)(material_1.Button, { sx: { minWidth: 0, px: 4, py: 0, opacity: 0.7, color: 'text.secondary' }, onClick: () => setExpand(!expand), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "tabler:chevron-compact-up", sx: {
|
|
124
|
-
fontSize: 24,
|
|
125
|
-
transform: `rotateX(${expand ? '180deg' : '0deg'})`,
|
|
126
|
-
transition: 'transform .3s ease-in-out',
|
|
127
|
-
} }) })), (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: expand || !isMobile, orientation: "vertical", sx: {
|
|
128
|
-
maxHeight: isMobile ? undefined : '40vh',
|
|
129
|
-
overflowY: 'auto',
|
|
130
|
-
}, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [openerMessage && (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { color: 'text.secondary', px: spacing }, children: openerMessage }), (0, jsx_runtime_1.jsx)(ParameterFormFields_1.default, { parameters: agent.parameters, form: form, sx: { pb: 2, px: spacing } })] }) }), (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, sx: {
|
|
131
|
-
px: spacing,
|
|
132
|
-
}, children: [error && (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", children: error.message }), (0, jsx_runtime_1.jsx)(RuntimeFormSubmit_1.default, { page: page, type: "submit", variant: "contained", fullWidth: true, loading: submitting,
|
|
133
|
-
// @ts-ignore
|
|
134
|
-
color: "black", sx: {
|
|
135
|
-
height: 40,
|
|
136
|
-
}, children: ((_d = (_c = agent.release) === null || _c === void 0 ? void 0 : _c.submitButton) === null || _d === void 0 ? void 0 : _d.title) || t('send') })] }) })] })));
|
|
137
|
-
}
|
|
138
|
-
exports.default = RuntimeFormForms;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
-
const material_1 = require("@mui/material");
|
|
19
|
-
const react_1 = require("react");
|
|
20
|
-
const session_1 = require("../../state/session");
|
|
21
|
-
const MessageItemView_1 = __importDefault(require("../message/MessageItemView"));
|
|
22
|
-
function RuntimeFormResult(_a) {
|
|
23
|
-
var { page } = _a, props = __rest(_a, ["page"]);
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: page.page === 'session' && (0, jsx_runtime_1.jsx)(ResultView, { page: page }) }) }) })));
|
|
25
|
-
}
|
|
26
|
-
exports.default = RuntimeFormResult;
|
|
27
|
-
function ResultView({ page }) {
|
|
28
|
-
const [, { messages = [] }] = (0, session_1.useSessionState)(page);
|
|
29
|
-
const message = messages[messages.length - 1];
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, children: message && (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { hideAvatar: true, page: page, message: message }, message.taskId) }));
|
|
31
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const material_1 = require("@mui/material");
|
|
8
|
-
const material_2 = require("../../../../mui/material");
|
|
9
|
-
const assistant_1 = require("../../state/assistant");
|
|
10
|
-
const PoweredBy_1 = __importDefault(require("../PoweredBy"));
|
|
11
|
-
const RuntimeFormForms_1 = __importDefault(require("./RuntimeFormForms"));
|
|
12
|
-
const RuntimeFormHeader_1 = __importDefault(require("./RuntimeFormHeader"));
|
|
13
|
-
const RuntimeFormResult_1 = __importDefault(require("./RuntimeFormResult"));
|
|
14
|
-
function RuntimeForm({ page }) {
|
|
15
|
-
const [agent] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
|
|
16
|
-
const theme = (0, material_1.useTheme)();
|
|
17
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
18
|
-
const spacing = {
|
|
19
|
-
md: 5,
|
|
20
|
-
xs: 2,
|
|
21
|
-
};
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
23
|
-
flex: 1,
|
|
24
|
-
display: 'flex',
|
|
25
|
-
}, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { divider: (0, jsx_runtime_1.jsx)(material_1.Divider, { orientation: "vertical", flexItem: true }), direction: {
|
|
26
|
-
md: 'row',
|
|
27
|
-
xs: 'column',
|
|
28
|
-
}, sx: {
|
|
29
|
-
flex: 1,
|
|
30
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
31
|
-
flex: 2,
|
|
32
|
-
px: spacing,
|
|
33
|
-
py: isMobile ? 4 : spacing,
|
|
34
|
-
pb: '0 !important',
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flexDirection: 'column',
|
|
37
|
-
justifyContent: 'space-between',
|
|
38
|
-
mb: {
|
|
39
|
-
xs: 1,
|
|
40
|
-
md: 0,
|
|
41
|
-
},
|
|
42
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: isMobile ? spacing : 1, spacing: spacing, children: [(0, jsx_runtime_1.jsx)(RuntimeFormHeader_1.default, { agent: agent }), (0, jsx_runtime_1.jsx)(RuntimeFormResult_1.default, { page: page })] }), !isMobile && (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { mt: spacing, mb: 0.5, px: 2, pt: 0 } })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
43
|
-
flex: {
|
|
44
|
-
md: 1,
|
|
45
|
-
xs: 0,
|
|
46
|
-
},
|
|
47
|
-
pt: spacing,
|
|
48
|
-
position: 'sticky',
|
|
49
|
-
bottom: 0,
|
|
50
|
-
// 从上透明到白色 0.72 的径向渐变
|
|
51
|
-
background: (theme) => `linear-gradient(180deg, ${(0, material_2.alpha)(theme.palette.background.default, 0.1)}, ${(0, material_2.alpha)(theme.palette.background.default, 1)} 16px)`,
|
|
52
|
-
}, children: [(0, jsx_runtime_1.jsx)(RuntimeFormForms_1.default, { page: page }), isMobile && (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { my: 0.5, px: 2 } })] })] }) }));
|
|
53
|
-
}
|
|
54
|
-
exports.default = RuntimeForm;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const react_1 = require("react");
|
|
16
|
-
const session_1 = require("../../../../session");
|
|
17
|
-
const session_2 = require("../../api/session");
|
|
18
|
-
const useAsync_1 = __importDefault(require("../../hooks/useAsync"));
|
|
19
|
-
const assistant_1 = require("../../state/assistant");
|
|
20
|
-
const loading_1 = require("../../state/loading");
|
|
21
|
-
const session_3 = require("../../state/session");
|
|
22
|
-
const utils_1 = require("../../utils");
|
|
23
|
-
function CheckSession({ cacheId, page, autoCreateSession, children, }) {
|
|
24
|
-
var _a;
|
|
25
|
-
const { assistantId, sessionId } = page;
|
|
26
|
-
(0, assistant_1.useAssistantState)({ assistantId });
|
|
27
|
-
const result = (0, useAsync_1.default)(() => {
|
|
28
|
-
if (sessionId && (0, session_3.createSessionState)({ sessionId }).getState().session)
|
|
29
|
-
return undefined;
|
|
30
|
-
return loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
var _a;
|
|
32
|
-
if (!sessionId) {
|
|
33
|
-
try {
|
|
34
|
-
// get the last session or create a new session if `autoCreateSession` is enabled
|
|
35
|
-
const { sessions } = yield (0, session_2.getSessions)((0, utils_1.parseIdentity)(assistantId, { rejectWhenError: true }));
|
|
36
|
-
const session = (_a = sessions[0]) !== null && _a !== void 0 ? _a : (autoCreateSession ? (yield (0, session_2.createSession)({ assistantId })).created : undefined);
|
|
37
|
-
if (session) {
|
|
38
|
-
yield (0, session_3.createSessionState)({ sessionId: session.id, session }).getState().load();
|
|
39
|
-
return [{ page: 'session', assistantId, sessionId: session.id }];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error('get first session or auto create a new session error', { error });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
try {
|
|
48
|
-
const state = (0, session_3.createSessionState)({ sessionId });
|
|
49
|
-
yield state.getState().load();
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error('load session error', { error });
|
|
53
|
-
return [{ page: 'assistant', assistantId, sessionId: undefined }, { replace: true }];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}));
|
|
58
|
-
}, [sessionId, cacheId]);
|
|
59
|
-
(0, react_1.useEffect)(() => {
|
|
60
|
-
if (result)
|
|
61
|
-
page.navigate(...result);
|
|
62
|
-
}, [result, page.navigate]);
|
|
63
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
64
|
-
(0, react_1.useEffect)(() => {
|
|
65
|
-
var _a;
|
|
66
|
-
if (!((_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did)) {
|
|
67
|
-
page.navigate({ page: 'assistant', assistantId: page.assistantId, sessionId: undefined }, { replace: true });
|
|
68
|
-
}
|
|
69
|
-
}, [(_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
|
|
70
|
-
if (result)
|
|
71
|
-
return null;
|
|
72
|
-
return children;
|
|
73
|
-
}
|
|
74
|
-
exports.default = CheckSession;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Box, CircularProgress, Stack, Typography } from '@mui/material';
|
|
3
|
-
// import { useEffect } from 'react';
|
|
4
|
-
// import { RelativeTime } from 'src/builtin/arcblock/ux';
|
|
5
|
-
// import { useLocaleContext } from 'src/builtin/locale';
|
|
6
|
-
// import { Session } from '../../api/session';
|
|
7
|
-
// import { useNavigateTo } from '../../hooks/navigate';
|
|
8
|
-
// import { createState } from '../../state';
|
|
9
|
-
// import Layout from '../layout';
|
|
10
|
-
// export default function SessionListView({ releaseId }: { releaseId: string }) {
|
|
11
|
-
// const { t } = useLocaleContext();
|
|
12
|
-
// const state = createState({ releaseId })();
|
|
13
|
-
// useEffect(() => {
|
|
14
|
-
// if (!state.sessions?.length) {
|
|
15
|
-
// state.getAssistant();
|
|
16
|
-
// } else {
|
|
17
|
-
// state.getSessions();
|
|
18
|
-
// }
|
|
19
|
-
// }, []);
|
|
20
|
-
// return (
|
|
21
|
-
// <Layout>
|
|
22
|
-
// <Typography
|
|
23
|
-
// component="h1"
|
|
24
|
-
// textAlign="center"
|
|
25
|
-
// sx={{
|
|
26
|
-
// fontWeight: 700,
|
|
27
|
-
// fontSize: 32,
|
|
28
|
-
// lineHeight: '44px',
|
|
29
|
-
// mt: 5,
|
|
30
|
-
// mb: 2.5,
|
|
31
|
-
// }}>
|
|
32
|
-
// {t('history')}
|
|
33
|
-
// </Typography>
|
|
34
|
-
// {!state.sessions?.length && (
|
|
35
|
-
// <Stack alignItems="center" gap={0.5} mt="10vh" mx={3}>
|
|
36
|
-
// {state.loading ? (
|
|
37
|
-
// <CircularProgress size={24} />
|
|
38
|
-
// ) : (
|
|
39
|
-
// <>
|
|
40
|
-
// <Typography fontSize={18}>💬</Typography>
|
|
41
|
-
// <Typography fontSize={12} sx={{ color: 'text.secondary' }}>
|
|
42
|
-
// {t('noData', { data: t('history') })}
|
|
43
|
-
// </Typography>
|
|
44
|
-
// </>
|
|
45
|
-
// )}
|
|
46
|
-
// </Stack>
|
|
47
|
-
// )}
|
|
48
|
-
// <Stack gap={2.5}>
|
|
49
|
-
// {state.sessions?.map((session) => <SessionItemView key={session.id} session={session} />)}
|
|
50
|
-
// </Stack>
|
|
51
|
-
// </Layout>
|
|
52
|
-
// );
|
|
53
|
-
// }
|
|
54
|
-
// function SessionItemView({ session }: { session: Session }) {
|
|
55
|
-
// const { locale } = useLocaleContext();
|
|
56
|
-
// const to = useNavigateTo();
|
|
57
|
-
// return (
|
|
58
|
-
// <Stack
|
|
59
|
-
// component={RouterLink}
|
|
60
|
-
// to={to({ page: 'session', sessionId: session.id })}
|
|
61
|
-
// gap={1.5}
|
|
62
|
-
// sx={{
|
|
63
|
-
// bgcolor: 'background.paper',
|
|
64
|
-
// p: 2.5,
|
|
65
|
-
// borderRadius: 1,
|
|
66
|
-
// boxShadow: 1,
|
|
67
|
-
// cursor: 'pointer',
|
|
68
|
-
// ':hover': {
|
|
69
|
-
// boxShadow: 2,
|
|
70
|
-
// },
|
|
71
|
-
// }}>
|
|
72
|
-
// <Box
|
|
73
|
-
// sx={{
|
|
74
|
-
// display: '-webkit-box',
|
|
75
|
-
// WebkitBoxOrient: 'vertical',
|
|
76
|
-
// WebkitLineClamp: 3,
|
|
77
|
-
// overflow: 'hidden',
|
|
78
|
-
// fontSize: 18,
|
|
79
|
-
// lineHeight: '32px',
|
|
80
|
-
// }}>
|
|
81
|
-
// {session.name || session.entry?.title}
|
|
82
|
-
// </Box>
|
|
83
|
-
// <Typography color="text.secondary">
|
|
84
|
-
// <RelativeTime locale={locale} value={session.updatedAt} relativeRange={600e3} />
|
|
85
|
-
// </Typography>
|
|
86
|
-
// </Stack>
|
|
87
|
-
// );
|
|
88
|
-
// }
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useLogin = void 0;
|
|
13
|
-
const react_1 = require("react");
|
|
14
|
-
const session_1 = require("../../../session");
|
|
15
|
-
const assistant_1 = require("../state/assistant");
|
|
16
|
-
const session_2 = require("../state/session");
|
|
17
|
-
const subscription_1 = require("../state/subscription");
|
|
18
|
-
function useLogin({ page }) {
|
|
19
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
20
|
-
return (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
yield new Promise((resolve) => {
|
|
22
|
-
authSession.login(() => resolve());
|
|
23
|
-
});
|
|
24
|
-
yield Promise.all([
|
|
25
|
-
(0, assistant_1.createAssistantState)({ assistantId: page.assistantId }).getState().load(),
|
|
26
|
-
(0, subscription_1.createSubscriptionState)({ aid: page.assistantId }).getState().load(),
|
|
27
|
-
page.sessionId && (0, session_2.createSessionState)({ sessionId: page.sessionId }).getState().load(),
|
|
28
|
-
]);
|
|
29
|
-
}), [authSession, page]);
|
|
30
|
-
}
|
|
31
|
-
exports.useLogin = useLogin;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useSetHeader = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const DID_1 = __importDefault(require("@arcblock/ux/lib/DID"));
|
|
9
|
-
const material_1 = require("@mui/material");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const ux_1 = require("../../../arcblock/ux");
|
|
12
|
-
const locale_1 = require("../../../locale");
|
|
13
|
-
const header_1 = require("../../../page/header");
|
|
14
|
-
const session_1 = require("../../../session");
|
|
15
|
-
const SocialShare_1 = __importDefault(require("../components/SocialShare"));
|
|
16
|
-
const ThemeProvider_1 = __importDefault(require("../components/ThemeProvider"));
|
|
17
|
-
const subscribe_1 = require("./subscribe");
|
|
18
|
-
const logoSize = 44;
|
|
19
|
-
function useSetHeader({ assistant, assistantId }) {
|
|
20
|
-
var _a;
|
|
21
|
-
const { subscribeLink, isPaymentProject } = (0, subscribe_1.useSubscribeLink)({ assistantId });
|
|
22
|
-
const theme = (0, material_1.useTheme)();
|
|
23
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
|
|
24
|
-
const { t, locale } = (0, locale_1.useLocaleContext)();
|
|
25
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
26
|
-
// set logo
|
|
27
|
-
(0, react_1.useEffect)(() => {
|
|
28
|
-
const { release } = assistant;
|
|
29
|
-
header_1.useHeaderState.setState((state) => {
|
|
30
|
-
state.logo = (release === null || release === void 0 ? void 0 : release.logo) && ((0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, size: logoSize, src: release === null || release === void 0 ? void 0 : release.logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, sx: {
|
|
31
|
-
width: logoSize,
|
|
32
|
-
height: logoSize,
|
|
33
|
-
} }));
|
|
34
|
-
if (!isMobile) {
|
|
35
|
-
state.brand = (release === null || release === void 0 ? void 0 : release.title) || assistant.name;
|
|
36
|
-
state.description = assistant.createdBy && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
37
|
-
display: 'inline-flex',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
gap: 0.5,
|
|
40
|
-
mt: 0.5,
|
|
41
|
-
}, children: [t('by'), " ", (0, jsx_runtime_1.jsx)(DID_1.default, { did: assistant.createdBy, copyable: false })] }));
|
|
42
|
-
}
|
|
43
|
-
const shareContent = `${(release === null || release === void 0 ? void 0 : release.title) || assistant.name}
|
|
44
|
-
|
|
45
|
-
${release === null || release === void 0 ? void 0 : release.description}
|
|
46
|
-
`;
|
|
47
|
-
state.addons = (...exists) => {
|
|
48
|
-
var _a;
|
|
49
|
-
return [
|
|
50
|
-
((_a = authSession === null || authSession === void 0 ? void 0 : authSession.user) === null || _a === void 0 ? void 0 : _a.did) && isPaymentProject && ((0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { disabled: !subscribeLink, variant: "outlined", href: subscribeLink,
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
color: "black", sx: {
|
|
53
|
-
// 字母不大写
|
|
54
|
-
textTransform: 'none',
|
|
55
|
-
}, children: subscribeLink ? t('subscribe') : t('subscribed') }) })),
|
|
56
|
-
(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }),
|
|
57
|
-
...exists,
|
|
58
|
-
].filter(Boolean);
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
return () => header_1.useHeaderState.setState((state) => {
|
|
62
|
-
state.logo = undefined;
|
|
63
|
-
state.brand = undefined;
|
|
64
|
-
state.description = undefined;
|
|
65
|
-
state.addons = (...exists) => [...exists];
|
|
66
|
-
});
|
|
67
|
-
}, [locale, isMobile, (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
|
|
68
|
-
}
|
|
69
|
-
exports.useSetHeader = useSetHeader;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useCurrentPage = exports.useNavigateWithQuery = exports.useNavigateTo = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const ufo_1 = require("ufo");
|
|
7
|
-
const error_1 = require("../error");
|
|
8
|
-
function useNavigateTo() {
|
|
9
|
-
const location = (0, react_router_dom_1.useLocation)();
|
|
10
|
-
return (0, react_1.useCallback)((query) => (0, ufo_1.withQuery)(`${location.pathname}${location.search}`, query), [location]);
|
|
11
|
-
}
|
|
12
|
-
exports.useNavigateTo = useNavigateTo;
|
|
13
|
-
function useNavigateWithQuery() {
|
|
14
|
-
const to = useNavigateTo();
|
|
15
|
-
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
16
|
-
return (0, react_1.useCallback)((query, options) => {
|
|
17
|
-
navigate(to(Object.assign(Object.assign({}, query), { page: query.page === 'assistant' ? undefined : query.page })), options);
|
|
18
|
-
}, [navigate, to]);
|
|
19
|
-
}
|
|
20
|
-
exports.useNavigateWithQuery = useNavigateWithQuery;
|
|
21
|
-
const PAGES = ['assistant', 'session'];
|
|
22
|
-
function isCurrentPage(page) {
|
|
23
|
-
return PAGES.includes(page);
|
|
24
|
-
}
|
|
25
|
-
function useCurrentPage(page) {
|
|
26
|
-
const { search } = (0, react_router_dom_1.useLocation)();
|
|
27
|
-
const { page: pageParam, assistantId, sessionId, } = (0, react_1.useMemo)(() => (0, ufo_1.getQuery)(search), [search]);
|
|
28
|
-
const navigate = useNavigateWithQuery();
|
|
29
|
-
const currentPage = isCurrentPage(pageParam) ? pageParam : 'assistant';
|
|
30
|
-
if (page && page !== currentPage)
|
|
31
|
-
throw new Error('Invalid page state');
|
|
32
|
-
if (currentPage === 'assistant' && assistantId)
|
|
33
|
-
return { page: currentPage, assistantId, navigate };
|
|
34
|
-
if (currentPage === 'session' && assistantId && sessionId)
|
|
35
|
-
return { page: currentPage, assistantId, sessionId, navigate };
|
|
36
|
-
throw new error_1.CustomError(404, 'Missing required query parameters `assistantId`');
|
|
37
|
-
}
|
|
38
|
-
exports.useCurrentPage = useCurrentPage;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSubscribeLink = void 0;
|
|
4
|
-
const ufo_1 = require("ufo");
|
|
5
|
-
const session_1 = require("../../../session");
|
|
6
|
-
const utils_1 = require("../../../utils");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const assistant_1 = require("../state/assistant");
|
|
9
|
-
const subscription_1 = require("../state/subscription");
|
|
10
|
-
function useSubscribeLink({ assistantId }) {
|
|
11
|
-
var _a, _b, _c, _d, _e;
|
|
12
|
-
const [, state] = (0, subscription_1.useSubscriptionState)({ aid: assistantId });
|
|
13
|
-
const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
|
|
14
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
15
|
-
const requireSubscribe = ((_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.enable) && !state.subscription;
|
|
16
|
-
const isPaymentProject = (_d = (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.payment) === null || _d === void 0 ? void 0 : _d.enable;
|
|
17
|
-
const subscribeLink = requireSubscribe && authSession.user && ((_e = state.release) === null || _e === void 0 ? void 0 : _e.paymentLinkId)
|
|
18
|
-
? getSubscribeLink({
|
|
19
|
-
aid: assistantId,
|
|
20
|
-
userId: authSession.user.did,
|
|
21
|
-
paymentLinkId: state.release.paymentLinkId,
|
|
22
|
-
})
|
|
23
|
-
: undefined;
|
|
24
|
-
return {
|
|
25
|
-
requireSubscribe,
|
|
26
|
-
subscribeLink,
|
|
27
|
-
isPaymentProject,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.useSubscribeLink = useSubscribeLink;
|
|
31
|
-
function getSubscribeLink({ aid, userId, paymentLinkId }) {
|
|
32
|
-
return (0, ufo_1.withQuery)((0, ufo_1.joinURL)('/', (0, utils_1.getComponentMountPoint)(constants_1.PAYMENT_KIT_DID), '/checkout/pay', paymentLinkId), {
|
|
33
|
-
'metadata.aid': aid,
|
|
34
|
-
'metadata.userId': userId,
|
|
35
|
-
redirect: window.location.href,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const PROMISE_CACHE = {};
|
|
4
|
-
function useAsync(fn, keys) {
|
|
5
|
-
const key = keys.join('_');
|
|
6
|
-
let cache = PROMISE_CACHE[key];
|
|
7
|
-
if (!cache) {
|
|
8
|
-
const promise = fn();
|
|
9
|
-
const isPromise = promise instanceof Promise;
|
|
10
|
-
cache = {
|
|
11
|
-
promise: Promise.resolve(promise)
|
|
12
|
-
.then((result) => {
|
|
13
|
-
PROMISE_CACHE[key].result = result;
|
|
14
|
-
})
|
|
15
|
-
.catch((error) => {
|
|
16
|
-
PROMISE_CACHE[key].error = error;
|
|
17
|
-
})
|
|
18
|
-
.finally(() => {
|
|
19
|
-
PROMISE_CACHE[key].done = true;
|
|
20
|
-
}),
|
|
21
|
-
done: !isPromise,
|
|
22
|
-
result: isPromise ? undefined : promise,
|
|
23
|
-
};
|
|
24
|
-
PROMISE_CACHE[key] = cache;
|
|
25
|
-
}
|
|
26
|
-
if (cache.error)
|
|
27
|
-
throw cache.error;
|
|
28
|
-
if (cache.done)
|
|
29
|
-
return cache.result;
|
|
30
|
-
throw cache.promise;
|
|
31
|
-
}
|
|
32
|
-
exports.default = useAsync;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useAssistantState = exports.createAssistantState = void 0;
|
|
13
|
-
const zustand_1 = require("zustand");
|
|
14
|
-
const immer_1 = require("zustand/middleware/immer");
|
|
15
|
-
const assistant_1 = require("../api/assistant");
|
|
16
|
-
const STATES = {};
|
|
17
|
-
const createAssistantState = ({ assistantId, assistant }) => {
|
|
18
|
-
var _a;
|
|
19
|
-
(_a = STATES[assistantId]) !== null && _a !== void 0 ? _a : (STATES[assistantId] = (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
|
|
20
|
-
assistant,
|
|
21
|
-
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
set((state) => {
|
|
23
|
-
state.loading = true;
|
|
24
|
-
});
|
|
25
|
-
try {
|
|
26
|
-
const assistant = yield (0, assistant_1.getAssistant)({ assistantId });
|
|
27
|
-
set((state) => {
|
|
28
|
-
state.assistant = assistant;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
set((state) => {
|
|
34
|
-
state.error = error;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
set((state) => {
|
|
39
|
-
state.loading = false;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}),
|
|
43
|
-
}))));
|
|
44
|
-
return STATES[assistantId];
|
|
45
|
-
};
|
|
46
|
-
exports.createAssistantState = createAssistantState;
|
|
47
|
-
const LOADING_TASKS = {};
|
|
48
|
-
function useAssistantState({ assistantId }) {
|
|
49
|
-
var _a;
|
|
50
|
-
const state = (0, exports.createAssistantState)({ assistantId })();
|
|
51
|
-
if (!state.assistant) {
|
|
52
|
-
if (state.error)
|
|
53
|
-
throw state.error;
|
|
54
|
-
(_a = LOADING_TASKS[assistantId]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[assistantId] = state.load());
|
|
55
|
-
throw LOADING_TASKS[assistantId];
|
|
56
|
-
}
|
|
57
|
-
return [state.assistant, state];
|
|
58
|
-
}
|
|
59
|
-
exports.useAssistantState = useAssistantState;
|