@blocklet/pages-kit 0.2.433 → 0.2.434
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.js +17 -0
- package/lib/cjs/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.js → components/LanguageField/index.js} +3 -3
- package/lib/cjs/builtin/{components.js → components/index.js} +1 -1
- package/lib/cjs/components/CustomComponentRenderer/context.js +13 -0
- package/lib/cjs/components/CustomComponentRenderer/index.js +5 -1
- package/lib/cjs/components/CustomComponentRenderer/state.js +20 -6
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime.js +1 -0
- package/lib/esm/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.js → components/LanguageField/index.js} +2 -2
- package/lib/esm/builtin/components/index.js +1 -0
- package/lib/esm/components/CustomComponentRenderer/context.js +9 -0
- package/lib/esm/components/CustomComponentRenderer/index.js +5 -1
- package/lib/esm/components/CustomComponentRenderer/state.js +21 -7
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime.d.ts +1 -0
- package/lib/types/builtin/components/index.d.ts +1 -0
- package/lib/types/components/CustomComponentRenderer/context.d.ts +14 -0
- package/lib/types/components/CustomComponentRenderer/index.d.ts +1 -0
- package/lib/types/components/CustomComponentRenderer/state.d.ts +5 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -5
- package/tsconfig.json +1 -1
- package/lib/cjs/builtin/async/ai-runtime/api/agent.js +0 -24
- package/lib/cjs/builtin/async/ai-runtime/api/asset.js +0 -25
- package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +0 -134
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +0 -46
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +0 -74
- package/lib/cjs/builtin/async/ai-runtime/api/secret.js +0 -24
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +0 -137
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +0 -62
- package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/BooleanField.js +0 -21
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/NumberField.js +0 -21
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/RadioField.js +0 -39
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/SelectField.js +0 -24
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/StringField.js +0 -35
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/index.js +0 -44
- package/lib/cjs/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +0 -80
- package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading/index.js +0 -27
- package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading/state.js +0 -39
- package/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +0 -49
- package/lib/cjs/builtin/async/ai-runtime/components/Layout/SimpleLayout.js +0 -21
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +0 -40
- package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer/index.js +0 -146
- package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +0 -55
- package/lib/cjs/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +0 -22
- package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +0 -49
- package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/index.js +0 -68
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +0 -25
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +0 -92
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/Community.js +0 -6
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +0 -255
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +0 -108
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +0 -191
- package/lib/cjs/builtin/async/ai-runtime/components/UserInfo.js +0 -55
- package/lib/cjs/builtin/async/ai-runtime/constants.js +0 -43
- package/lib/cjs/builtin/async/ai-runtime/contexts/ActiveAgent.js +0 -27
- package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +0 -31
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentMessage.js +0 -18
- package/lib/cjs/builtin/async/ai-runtime/contexts/Identity.js +0 -36
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +0 -52
- package/lib/cjs/builtin/async/ai-runtime/error.js +0 -10
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-agent-admin.js +0 -13
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +0 -109
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +0 -50
- package/lib/cjs/builtin/async/ai-runtime/index.js +0 -83
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +0 -237
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +0 -116
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +0 -48
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +0 -138
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +0 -19
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +0 -186
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +0 -24
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.js +0 -11
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +0 -24
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +0 -85
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +0 -64
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +0 -30
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +0 -13
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +0 -46
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +0 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +0 -65
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +0 -150
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +0 -26
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ShareView/index.js +0 -16
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +0 -38
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +0 -42
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +0 -94
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +0 -79
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +0 -34
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +0 -45
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +0 -28
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -82
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +0 -69
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +0 -55
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +0 -54
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +0 -189
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +0 -252
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +0 -300
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +0 -158
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +0 -60
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +0 -153
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +0 -80
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +0 -25
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +0 -68
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +0 -56
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/index.js +0 -12
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/utils.js +0 -13
- package/lib/cjs/builtin/async/ai-runtime/state/agent.js +0 -58
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +0 -48
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +0 -415
- package/lib/cjs/builtin/async/ai-runtime/utils/agent-inputs.js +0 -14
- package/lib/cjs/builtin/async/ai-runtime/utils/download-image.js +0 -40
- package/lib/cjs/builtin/async/ai-runtime/utils/fonts.js +0 -35
- package/lib/cjs/builtin/async/ai-runtime/utils/map-right.js +0 -10
- package/lib/cjs/builtin/async/ai-runtime/utils/runtime-output-schema.js +0 -7
- package/lib/cjs/builtin/async/ai-runtime/utils/zustand.js +0 -9
- package/lib/esm/builtin/async/ai-runtime/api/agent.js +0 -21
- package/lib/esm/builtin/async/ai-runtime/api/asset.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/api/dataset.js +0 -121
- package/lib/esm/builtin/async/ai-runtime/api/message.js +0 -42
- package/lib/esm/builtin/async/ai-runtime/api/request.js +0 -68
- package/lib/esm/builtin/async/ai-runtime/api/secret.js +0 -21
- package/lib/esm/builtin/async/ai-runtime/api/session.js +0 -128
- package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +0 -56
- package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +0 -30
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/BooleanField.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/NumberField.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/RadioField.js +0 -37
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/SelectField.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/StringField.js +0 -33
- package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/index.js +0 -38
- package/lib/esm/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +0 -76
- package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading/index.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading/state.js +0 -36
- package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +0 -23
- package/lib/esm/builtin/async/ai-runtime/components/Layout/SimpleLayout.js +0 -18
- package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +0 -38
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer/index.js +0 -118
- package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +0 -52
- package/lib/esm/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +0 -46
- package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/index.js +0 -42
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +0 -18
- package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +0 -63
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/Community.js +0 -4
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +0 -226
- package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +0 -100
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +0 -185
- package/lib/esm/builtin/async/ai-runtime/components/UserInfo.js +0 -47
- package/lib/esm/builtin/async/ai-runtime/constants.js +0 -39
- package/lib/esm/builtin/async/ai-runtime/contexts/ActiveAgent.js +0 -23
- package/lib/esm/builtin/async/ai-runtime/contexts/ComponentPreferences.js +0 -24
- package/lib/esm/builtin/async/ai-runtime/contexts/CurrentAgent.js +0 -30
- package/lib/esm/builtin/async/ai-runtime/contexts/CurrentMessage.js +0 -14
- package/lib/esm/builtin/async/ai-runtime/contexts/Identity.js +0 -28
- package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/error.js +0 -6
- package/lib/esm/builtin/async/ai-runtime/hooks/use-agent-admin.js +0 -10
- package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +0 -103
- package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +0 -44
- package/lib/esm/builtin/async/ai-runtime/index.js +0 -37
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +0 -234
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +0 -87
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +0 -19
- package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +0 -132
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +0 -13
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +0 -157
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +0 -18
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.js +0 -30
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.js +0 -8
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +0 -18
- package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +0 -56
- package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +0 -58
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +0 -24
- package/lib/esm/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +0 -7
- package/lib/esm/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +0 -40
- package/lib/esm/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +0 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +0 -59
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +0 -144
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +0 -20
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ShareView/index.js +0 -10
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +0 -35
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +0 -39
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +0 -65
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +0 -50
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +0 -28
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +0 -40
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +0 -22
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -53
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +0 -40
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +0 -49
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +0 -48
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +0 -183
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +0 -246
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +0 -294
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +0 -149
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +0 -55
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +0 -146
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +0 -75
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +0 -23
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +0 -42
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +0 -52
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/index.js +0 -3
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/utils.js +0 -9
- package/lib/esm/builtin/async/ai-runtime/state/agent.js +0 -55
- package/lib/esm/builtin/async/ai-runtime/state/runtime.js +0 -45
- package/lib/esm/builtin/async/ai-runtime/state/session.js +0 -408
- package/lib/esm/builtin/async/ai-runtime/utils/agent-inputs.js +0 -10
- package/lib/esm/builtin/async/ai-runtime/utils/download-image.js +0 -36
- package/lib/esm/builtin/async/ai-runtime/utils/fonts.js +0 -32
- package/lib/esm/builtin/async/ai-runtime/utils/map-right.js +0 -7
- package/lib/esm/builtin/async/ai-runtime/utils/runtime-output-schema.js +0 -4
- package/lib/esm/builtin/async/ai-runtime/utils/zustand.js +0 -6
- package/lib/esm/builtin/components.js +0 -1
- package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +0 -51
- package/lib/types/builtin/async/ai-runtime/api/asset.d.ts +0 -16
- package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +0 -39
- package/lib/types/builtin/async/ai-runtime/api/message.d.ts +0 -35
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +0 -12
- package/lib/types/builtin/async/ai-runtime/api/secret.d.ts +0 -12
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +0 -61
- package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +0 -14
- package/lib/types/builtin/async/ai-runtime/components/AgentErrorBoundary.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/BooleanField.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/NumberField.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/RadioField.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/SelectField.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/StringField.d.ts +0 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/index.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/GlobalLoading/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/GlobalLoading/state.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/Header/SimpleHeader.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/Layout/SimpleLayout.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/OutputFieldContainer/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/index.d.ts +0 -6
- package/lib/types/builtin/async/ai-runtime/components/RuntimeCommonProvider.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +0 -10
- package/lib/types/builtin/async/ai-runtime/components/ShareActions/Community.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/ShareActions/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +0 -20
- package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/components/UserInfo.d.ts +0 -18
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +0 -21
- package/lib/types/builtin/async/ai-runtime/contexts/ActiveAgent.d.ts +0 -9
- package/lib/types/builtin/async/ai-runtime/contexts/ComponentPreferences.d.ts +0 -11
- package/lib/types/builtin/async/ai-runtime/contexts/CurrentAgent.d.ts +0 -16
- package/lib/types/builtin/async/ai-runtime/contexts/CurrentMessage.d.ts +0 -15
- package/lib/types/builtin/async/ai-runtime/contexts/Identity.d.ts +0 -16
- package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/error.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/hooks/use-agent-admin.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +0 -78
- package/lib/types/builtin/async/ai-runtime/hooks/use-header-menu.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/index.d.ts +0 -36
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +0 -210
- package/lib/types/builtin/async/ai-runtime/runtime/ChatBotButton/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime/Runtime/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/AutoForm/index.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.d.ts +0 -12
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/ImagesView/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/MarkdownView/index.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/ShareView/index.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +0 -9
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.d.ts +0 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +0 -16
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimplePage/index.d.ts +0 -6
- package/lib/types/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Input.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Output.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Page.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +0 -20
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/Loading.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.d.ts +0 -17
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/index.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/utils.d.ts +0 -7
- package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +0 -12
- package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +0 -14
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +0 -60
- package/lib/types/builtin/async/ai-runtime/utils/agent-inputs.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/utils/download-image.d.ts +0 -4
- package/lib/types/builtin/async/ai-runtime/utils/fonts.d.ts +0 -5
- package/lib/types/builtin/async/ai-runtime/utils/map-right.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/utils/runtime-output-schema.d.ts +0 -3
- package/lib/types/builtin/async/ai-runtime/utils/zustand.d.ts +0 -2
- package/lib/types/builtin/components.d.ts +0 -1
- /package/lib/cjs/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.js +0 -0
- /package/lib/esm/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.js +0 -0
- /package/lib/types/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.d.ts → components/LanguageField/index.d.ts} +0 -0
- /package/lib/types/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.d.ts +0 -0
package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js
DELETED
|
@@ -1,45 +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 types_1 = require("@blocklet/ai-runtime/types");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
10
|
-
const asset_1 = require("../../api/asset");
|
|
11
|
-
const UserInfo_1 = __importDefault(require("../../components/UserInfo"));
|
|
12
|
-
const constants_1 = require("../../constants");
|
|
13
|
-
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
14
|
-
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
15
|
-
const use_appearances_1 = require("../../hooks/use-appearances");
|
|
16
|
-
const runtime_1 = require("../../state/runtime");
|
|
17
|
-
const MessageView_1 = require("./MessageView");
|
|
18
|
-
const OpeningMessageView = (0, react_1.memo)(({ isMessagesEmpty }) => {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
20
|
-
const { blockletDid, aid } = (0, runtime_1.useRuntimeState)();
|
|
21
|
-
const { hideAgentAvatar, backgroundImage } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
|
|
22
|
-
const hasBg = !!(backgroundImage === null || backgroundImage === void 0 ? void 0 : backgroundImage.url);
|
|
23
|
-
const openingMessage = (0, use_appearances_1.useOpeningMessage)();
|
|
24
|
-
const openingMessageOutput = (0, react_1.useMemo)(() => { var _a; return (_a = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingMessage); }, [openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent]);
|
|
25
|
-
const openingMessageComponentId = ((_b = openingMessageOutput === null || openingMessageOutput === void 0 ? void 0 : openingMessageOutput.appearance) === null || _b === void 0 ? void 0 : _b.componentId) ||
|
|
26
|
-
((_c = constants_1.DEFAULT_OUTPUT_COMPONENTS[types_1.RuntimeOutputVariable.openingMessage]) === null || _c === void 0 ? void 0 : _c.componentId);
|
|
27
|
-
const profile = (0, use_appearances_1.useProfile)();
|
|
28
|
-
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
29
|
-
const openingQuestions = (0, use_appearances_1.useOpeningQuestions)();
|
|
30
|
-
const openingQuestionsOutput = (0, react_1.useMemo)(() => { var _a; return (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingQuestions); }, [agent.outputVariables]);
|
|
31
|
-
const openingQuestionsComponentId = ((_d = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _d === void 0 ? void 0 : _d.componentId) ||
|
|
32
|
-
((_e = constants_1.DEFAULT_OUTPUT_COMPONENTS[types_1.RuntimeOutputVariable.openingQuestions]) === null || _e === void 0 ? void 0 : _e.componentId);
|
|
33
|
-
if ((!(openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.message) || !openingMessageComponentId) &&
|
|
34
|
-
(!openingQuestionsComponentId || !(openingQuestions === null || openingQuestions === void 0 ? void 0 : openingQuestions.questions.length) || !isMessagesEmpty)) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const children = ((0, jsx_runtime_1.jsxs)(MessageView_1.MessageBodyContainer, { children: [openingMessage && openingMessageOutput && openingMessageComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: openingMessageOutput.id, componentId: openingMessageComponentId, properties: (_f = openingMessageOutput.appearance) === null || _f === void 0 ? void 0 : _f.componentProperties, props: { output: openingMessageOutput, outputValue: openingMessage.message } })), isMessagesEmpty && openingQuestionsComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: agent.id, componentId: openingQuestionsComponentId, properties: (_g = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _g === void 0 ? void 0 : _g.componentProperties, props: { output: openingQuestionsOutput } }))] }));
|
|
38
|
-
return hideAgentAvatar ? (children) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: (0, asset_1.getAssetUrl)({
|
|
39
|
-
blockletDid,
|
|
40
|
-
aid,
|
|
41
|
-
filename: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar,
|
|
42
|
-
preset: 'avatar',
|
|
43
|
-
}), alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: children }));
|
|
44
|
-
});
|
|
45
|
-
exports.default = OpeningMessageView;
|
|
@@ -1,28 +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.default = UserMessageView;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const material_1 = require("@mui/material");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const MarkdownRenderer_1 = __importDefault(require("../../components/MarkdownRenderer"));
|
|
11
|
-
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
12
|
-
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
13
|
-
const agent_inputs_1 = require("../../utils/agent-inputs");
|
|
14
|
-
function UserMessageView() {
|
|
15
|
-
var _a;
|
|
16
|
-
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
17
|
-
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
18
|
-
const params = (0, react_1.useMemo)(() => {
|
|
19
|
-
var _a;
|
|
20
|
-
const inputs = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => { var _a, _b; return [((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || i.key, (_b = message.inputs) === null || _b === void 0 ? void 0 : _b[i.key]]; }).filter((i) => i[1]);
|
|
21
|
-
const q = inputs === null || inputs === void 0 ? void 0 : inputs.find((i) => i[0] === 'question');
|
|
22
|
-
return q ? [q] : inputs;
|
|
23
|
-
}, [agent.parameters, message.inputs]);
|
|
24
|
-
if ((params === null || params === void 0 ? void 0 : params.length) === 1) {
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: (_a = params[0]) === null || _a === void 0 ? void 0 : _a[1] });
|
|
26
|
-
}
|
|
27
|
-
return params === null || params === void 0 ? void 0 : params.map(([key, value]) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: { wordWrap: 'break-word' }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: { color: 'text.secondary' }, children: key }), "\u00A0\u00A0", (0, jsx_runtime_1.jsx)("span", { children: value })] }, key)));
|
|
28
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.default = SimpleChat;
|
|
41
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
-
const material_1 = require("@mui/material");
|
|
43
|
-
const react_1 = require("react");
|
|
44
|
-
const react_scroll_to_bottom_1 = require("react-scroll-to-bottom");
|
|
45
|
-
const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
|
|
46
|
-
const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
|
|
47
|
-
const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
|
|
48
|
-
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
49
|
-
const ComponentPreferences_1 = __importStar(require("../../contexts/ComponentPreferences"));
|
|
50
|
-
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
51
|
-
const session_1 = require("../../state/session");
|
|
52
|
-
const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
|
|
53
|
-
const InputsView_1 = __importDefault(require("./InputsView"));
|
|
54
|
-
const MessagesView_1 = __importDefault(require("./MessagesView"));
|
|
55
|
-
function SimpleChat(_a) {
|
|
56
|
-
var { scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["scrollViewProps"]);
|
|
57
|
-
(0, session_1.useAutoLoadSessionState)();
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.default, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] })) })));
|
|
59
|
-
}
|
|
60
|
-
function SimpleChatView() {
|
|
61
|
-
var _a;
|
|
62
|
-
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
63
|
-
const hasBg = !!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url);
|
|
64
|
-
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
65
|
-
// auto scroll to bottom when new message is sent
|
|
66
|
-
const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
|
|
67
|
-
const scrollToBottom = (0, react_scroll_to_bottom_1.useScrollToBottom)();
|
|
68
|
-
(0, react_1.useEffect)(() => {
|
|
69
|
-
if (running)
|
|
70
|
-
scrollToBottom({ behavior: 'smooth' });
|
|
71
|
-
}, [scrollToBottom, running]);
|
|
72
|
-
const sessionLoading = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading);
|
|
73
|
-
const loading = (0, session_1.useSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading) || sessionLoading;
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
75
|
-
position: 'sticky',
|
|
76
|
-
bottom: 0,
|
|
77
|
-
zIndex: 10,
|
|
78
|
-
borderRadius: 1,
|
|
79
|
-
bgcolor: (theme) => (0, material_1.alpha)(theme.palette.background.paper, 0.8),
|
|
80
|
-
backdropFilter: 'blur(16px)',
|
|
81
|
-
} }) })] }))] }));
|
|
82
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.default = SimpleOutput;
|
|
30
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
-
const types_1 = require("@blocklet/ai-runtime/types");
|
|
32
|
-
const material_1 = require("@mui/material");
|
|
33
|
-
const react_1 = require("react");
|
|
34
|
-
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
35
|
-
const AgentErrorBoundary_1 = __importStar(require("../../components/AgentErrorBoundary"));
|
|
36
|
-
const constants_1 = require("../../constants");
|
|
37
|
-
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
38
|
-
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
39
|
-
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
40
|
-
const ignoredOutputs = new Set([
|
|
41
|
-
types_1.RuntimeOutputVariable.appearancePage,
|
|
42
|
-
types_1.RuntimeOutputVariable.appearanceInput,
|
|
43
|
-
types_1.RuntimeOutputVariable.appearanceOutput,
|
|
44
|
-
types_1.RuntimeOutputVariable.openingQuestions,
|
|
45
|
-
types_1.RuntimeOutputVariable.openingMessage,
|
|
46
|
-
]);
|
|
47
|
-
function SimpleOutput() {
|
|
48
|
-
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
49
|
-
const CustomComponentActionsComponent = preferences === null || preferences === void 0 ? void 0 : preferences.customOutputActionsComponent;
|
|
50
|
-
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
51
|
-
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
52
|
-
const outputs = (0, react_1.useMemo)(() => {
|
|
53
|
-
var _a;
|
|
54
|
-
return (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.map((i) => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
return (Object.assign(Object.assign({}, i), { appearance: Object.assign(Object.assign({}, i.appearance), { componentId: ((_a = i.appearance) === null || _a === void 0 ? void 0 : _a.componentId) || ((_b = (0, constants_1.getDefaultOutputComponent)(i)) === null || _b === void 0 ? void 0 : _b.componentId) }) }));
|
|
57
|
-
}).filter((i) => { var _a; return !!((_a = i.appearance) === null || _a === void 0 ? void 0 : _a.componentId) && !ignoredOutputs.has(i.name); });
|
|
58
|
-
}, [agent.outputVariables]);
|
|
59
|
-
if (!(outputs === null || outputs === void 0 ? void 0 : outputs.length))
|
|
60
|
-
return null;
|
|
61
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [outputs.map((output) => {
|
|
62
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
63
|
-
const value = output.name === types_1.RuntimeOutputVariable.text
|
|
64
|
-
? ((_a = message.outputs) === null || _a === void 0 ? void 0 : _a.content) ||
|
|
65
|
-
((_d = (_c = (_b = message.outputs) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _d === void 0 ? void 0 : _d[types_1.RuntimeOutputVariable.text])
|
|
66
|
-
: (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.find((i) => i === null || i === void 0 ? void 0 : i[output.name])) === null || _g === void 0 ? void 0 : _g[output.name];
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: output.appearance.componentId, properties: output.appearance.componentProperties, props: Object.assign({ output, outputValue: value, writing: output.name === types_1.RuntimeOutputVariable.text && message.loading }, (((_h = output === null || output === void 0 ? void 0 : output.appearance) === null || _h === void 0 ? void 0 : _h.componentProps) || {})) }, output.id));
|
|
68
|
-
}), message.error && (0, jsx_runtime_1.jsx)(AgentErrorBoundary_1.AgentErrorView, { error: message.error }), CustomComponentActionsComponent && ((0, jsx_runtime_1.jsx)(AgentErrorBoundary_1.default, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentActionsComponent, {}) }) }))] }));
|
|
69
|
-
}
|
|
@@ -1,55 +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
|
-
exports.default = SimplePage;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const material_1 = require("@mui/material");
|
|
20
|
-
const react_1 = require("react");
|
|
21
|
-
const react_wrap_balancer_1 = __importDefault(require("react-wrap-balancer"));
|
|
22
|
-
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
23
|
-
const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
|
|
24
|
-
const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
|
|
25
|
-
const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
|
|
26
|
-
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
27
|
-
const ComponentPreferences_1 = __importDefault(require("../../contexts/ComponentPreferences"));
|
|
28
|
-
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
29
|
-
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
30
|
-
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
31
|
-
const session_1 = require("../../state/session");
|
|
32
|
-
function SimplePage(_a) {
|
|
33
|
-
var { resultTitle } = _a, preferences = __rest(_a, ["resultTitle"]);
|
|
34
|
-
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
35
|
-
(0, session_1.useAutoLoadSessionState)();
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.default, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }) })));
|
|
37
|
-
}
|
|
38
|
-
function AgentInputRender(_a) {
|
|
39
|
-
var props = __rest(_a, []);
|
|
40
|
-
const { appearanceInput } = (0, use_appearances_1.default)();
|
|
41
|
-
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
42
|
-
return null;
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties }) })));
|
|
44
|
-
}
|
|
45
|
-
function OutputView(_a) {
|
|
46
|
-
var { resultTitle } = _a, props = __rest(_a, ["resultTitle"]);
|
|
47
|
-
const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(0); });
|
|
48
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 4 }, props, { children: lastMessage && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { width: "100%", component: "h5", fontSize: 36, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(OutputItemView, { message: lastMessage }) })] })) })));
|
|
49
|
-
}
|
|
50
|
-
const OutputItemView = (0, react_1.memo)(({ message }) => {
|
|
51
|
-
const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
|
|
52
|
-
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
53
|
-
return null;
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }));
|
|
55
|
-
});
|
|
@@ -1,54 +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
|
-
exports.default = SuggestedQuestionsView;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const material_1 = require("@mui/material");
|
|
20
|
-
const joi_1 = __importDefault(require("joi"));
|
|
21
|
-
const react_1 = require("react");
|
|
22
|
-
const OutputFieldContainer_1 = __importDefault(require("../../components/OutputFieldContainer"));
|
|
23
|
-
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
24
|
-
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
25
|
-
const runtime_1 = require("../../state/runtime");
|
|
26
|
-
const session_1 = require("../../state/session");
|
|
27
|
-
const suggestedQuestionsSchema = joi_1.default.array().items(joi_1.default.object({
|
|
28
|
-
question: joi_1.default.string().required(),
|
|
29
|
-
}));
|
|
30
|
-
function SuggestedQuestionsView({ output, outputValue, onlyLastMessage, }) {
|
|
31
|
-
var _a;
|
|
32
|
-
const { message } = (_a = (0, CurrentMessage_1.useCurrentMessage)({ optional: true })) !== null && _a !== void 0 ? _a : {};
|
|
33
|
-
const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(0); });
|
|
34
|
-
const isLastMessage = !!message && message.id === (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.id);
|
|
35
|
-
const questions = (0, react_1.useMemo)(() => {
|
|
36
|
-
const result = suggestedQuestionsSchema.validate(outputValue, { allowUnknown: true });
|
|
37
|
-
if (result.error)
|
|
38
|
-
return undefined;
|
|
39
|
-
return result.value;
|
|
40
|
-
}, [outputValue]);
|
|
41
|
-
const { aid } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
42
|
-
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
43
|
-
if (!message || (!isLastMessage && onlyLastMessage) || !(questions === null || questions === void 0 ? void 0 : questions.length))
|
|
44
|
-
return null;
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 1, children: questions.map((item) => ((0, jsx_runtime_1.jsx)(MessageSuggestedQuestion, { onClick: () => {
|
|
46
|
-
execute({ aid, parameters: Object.assign(Object.assign({}, message.inputs), { question: item.question }) });
|
|
47
|
-
}, children: item.question }, item.question))) }) }));
|
|
48
|
-
}
|
|
49
|
-
function MessageSuggestedQuestion(_a) {
|
|
50
|
-
var props = __rest(_a, []);
|
|
51
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, props, { sx: Object.assign({ display: 'inline-block', border: 1, borderColor: 'rgba(229, 231, 235, 1)', borderRadius: 1, py: 1, px: 2, cursor: 'pointer', '&:hover': {
|
|
52
|
-
backgroundColor: 'rgba(239, 246, 255, 1)',
|
|
53
|
-
} }, props.sx) })));
|
|
54
|
-
}
|
|
@@ -1,189 +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
|
-
exports.default = V0Input;
|
|
16
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
-
const css_1 = require("@emotion/css");
|
|
18
|
-
const react_1 = require("@iconify/react");
|
|
19
|
-
const material_1 = require("@mui/material");
|
|
20
|
-
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
21
|
-
const omit_1 = __importDefault(require("lodash/omit"));
|
|
22
|
-
const react_2 = require("react");
|
|
23
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
24
|
-
const locale_1 = require("../../../../locale");
|
|
25
|
-
const AgentInputField_1 = __importDefault(require("../../components/AgentInputField"));
|
|
26
|
-
const LoadingButton_1 = __importDefault(require("../../components/LoadingButton"));
|
|
27
|
-
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
28
|
-
const use_appearances_1 = require("../../hooks/use-appearances");
|
|
29
|
-
const runtime_1 = require("../../state/runtime");
|
|
30
|
-
const session_1 = require("../../state/session");
|
|
31
|
-
const agent_inputs_1 = require("../../utils/agent-inputs");
|
|
32
|
-
const V0Runtime_1 = require("./contexts/V0Runtime");
|
|
33
|
-
function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQuestionField = true, chatMode = true, }) {
|
|
34
|
-
var _a, _b;
|
|
35
|
-
const { t } = (0, locale_1.useLocaleContext)();
|
|
36
|
-
const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
37
|
-
const [executeLoading, setExecuteLoading] = (0, react_2.useState)(false);
|
|
38
|
-
const opening = (0, use_appearances_1.useOpeningQuestions)();
|
|
39
|
-
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
40
|
-
const { running } = (0, session_1.useCurrentSessionState)((s) => s) || {};
|
|
41
|
-
const { currentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
|
|
42
|
-
const { setCurrentMessageTaskId } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
43
|
-
const parameters = (0, react_2.useMemo)(() => {
|
|
44
|
-
var _a;
|
|
45
|
-
return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => {
|
|
46
|
-
var _a;
|
|
47
|
-
return (Object.assign(Object.assign({}, i), { label: ((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || undefined }));
|
|
48
|
-
});
|
|
49
|
-
}, [agent.parameters]);
|
|
50
|
-
const defaultForm = useInitialFormValues();
|
|
51
|
-
const theme = useFormTheme();
|
|
52
|
-
const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
|
|
53
|
-
(0, react_2.useEffect)(() => {
|
|
54
|
-
if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
|
|
55
|
-
form.reset(chatMode ? (0, omit_1.default)(defaultForm, 'question') : defaultForm);
|
|
56
|
-
}
|
|
57
|
-
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
58
|
-
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
try {
|
|
60
|
-
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
61
|
-
return;
|
|
62
|
-
setExecuteLoading(true);
|
|
63
|
-
// in session page, send message
|
|
64
|
-
yield execute({
|
|
65
|
-
aid,
|
|
66
|
-
parameters,
|
|
67
|
-
onResponseStart: () => {
|
|
68
|
-
setCurrentMessageTaskId(undefined);
|
|
69
|
-
if (chatMode)
|
|
70
|
-
form.resetField('question', { defaultValue: '' });
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error(error);
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
setExecuteLoading(false);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: theme, children: [!currentSessionId && ((_a = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(material_1.Stack, { sx: {
|
|
82
|
-
flexDirection: 'row',
|
|
83
|
-
gap: 1,
|
|
84
|
-
mb: 1,
|
|
85
|
-
flexWrap: 'wrap',
|
|
86
|
-
}, children: (_b = opening === null || opening === void 0 ? void 0 : opening.questions) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
87
|
-
const { title, parameters, id } = item;
|
|
88
|
-
const question = (parameters === null || parameters === void 0 ? void 0 : parameters.questions) || title;
|
|
89
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", endIcon: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:arrow-down-right", style: {
|
|
90
|
-
marginLeft: -4,
|
|
91
|
-
} }), onClick: () => {
|
|
92
|
-
form.reset(Object.assign({}, parameters));
|
|
93
|
-
// auto execute message
|
|
94
|
-
// onSubmit({ ...parameters });
|
|
95
|
-
}, children: question }, id));
|
|
96
|
-
}) })), (0, jsx_runtime_1.jsxs)(Form, { id: "v0-input", component: "form", className: (0, css_1.cx)('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
|
|
97
|
-
const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
|
|
98
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: key, rules: {
|
|
99
|
-
required,
|
|
100
|
-
min: parameter.type === 'number' && typeof parameter.min === 'number'
|
|
101
|
-
? { value: parameter.min, message: '' }
|
|
102
|
-
: undefined,
|
|
103
|
-
max: parameter.type === 'number' && typeof parameter.max === 'number'
|
|
104
|
-
? { value: parameter.max, message: '' }
|
|
105
|
-
: undefined,
|
|
106
|
-
minLength: parameter.type === 'string' && typeof parameter.minLength === 'number'
|
|
107
|
-
? { value: parameter.minLength, message: '' }
|
|
108
|
-
: undefined,
|
|
109
|
-
maxLength: parameter.type === 'string' && typeof parameter.maxLength === 'number'
|
|
110
|
-
? { value: parameter.maxLength, message: '' }
|
|
111
|
-
: undefined,
|
|
112
|
-
}, render: ({ field, fieldState }) => {
|
|
113
|
-
var _a;
|
|
114
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
|
|
115
|
-
? {
|
|
116
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText || t('generate') }) })),
|
|
117
|
-
}
|
|
118
|
-
: undefined })] }));
|
|
119
|
-
} }) }, parameter.id));
|
|
120
|
-
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: executeLoading || running, sx: { height: 40 }, children: submitText || t('generate') }))] })] }));
|
|
121
|
-
}
|
|
122
|
-
const autoSetLastParameters = false;
|
|
123
|
-
function useInitialFormValues() {
|
|
124
|
-
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
125
|
-
const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(0); });
|
|
126
|
-
const [lastInputs, setLastInputs] = (0, react_2.useState)();
|
|
127
|
-
(0, react_2.useEffect)(() => {
|
|
128
|
-
if (autoSetLastParameters && !lastInputs) {
|
|
129
|
-
const lastParameters = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.inputs;
|
|
130
|
-
if (!(0, isEmpty_1.default)(lastParameters))
|
|
131
|
-
setLastInputs(lastParameters);
|
|
132
|
-
}
|
|
133
|
-
}, [lastMessage]);
|
|
134
|
-
return (0, react_2.useMemo)(() => {
|
|
135
|
-
var _a, _b;
|
|
136
|
-
if (lastInputs) {
|
|
137
|
-
return lastInputs;
|
|
138
|
-
}
|
|
139
|
-
return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [parameter.key, parameter.defaultValue])) !== null && _b !== void 0 ? _b : []);
|
|
140
|
-
}, [lastInputs, agent]);
|
|
141
|
-
}
|
|
142
|
-
function useFormTheme() {
|
|
143
|
-
const theme = (0, material_1.useTheme)();
|
|
144
|
-
return (0, react_2.useMemo)(() => {
|
|
145
|
-
const themeOptions = {
|
|
146
|
-
shape: {
|
|
147
|
-
borderRadius: 8,
|
|
148
|
-
},
|
|
149
|
-
components: {
|
|
150
|
-
MuiTextField: {
|
|
151
|
-
styleOverrides: {
|
|
152
|
-
root: ({ theme }) => theme.unstable_sx({
|
|
153
|
-
[`.${material_1.outlinedInputClasses.root}`]: {
|
|
154
|
-
[`.${material_1.outlinedInputClasses.notchedOutline}`]: {
|
|
155
|
-
borderWidth: 2,
|
|
156
|
-
borderColor: 'primary.light',
|
|
157
|
-
},
|
|
158
|
-
':hover': {
|
|
159
|
-
[`.${material_1.outlinedInputClasses.notchedOutline}`]: {
|
|
160
|
-
borderColor: 'primary.main',
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
}),
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
return (0, material_1.createTheme)(theme, themeOptions);
|
|
170
|
-
}, [theme]);
|
|
171
|
-
}
|
|
172
|
-
const Form = (0, material_1.styled)(material_1.Stack)(({ theme }) => theme.unstable_sx({
|
|
173
|
-
gap: 2,
|
|
174
|
-
'.form-item': {
|
|
175
|
-
gap: 0.5,
|
|
176
|
-
[`.${material_1.formLabelClasses.root}`]: {
|
|
177
|
-
fontWeight: 500,
|
|
178
|
-
color: 'text.primary',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
'&.label-position-start': {
|
|
182
|
-
'.form-item': {
|
|
183
|
-
display: 'flex',
|
|
184
|
-
flexDirection: 'row',
|
|
185
|
-
alignItems: 'center',
|
|
186
|
-
gap: 1,
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
}));
|