@lobehub/chat 1.17.6 → 1.18.0
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.
Potentially problematic release.
This version of @lobehub/chat might be problematic. Click here for more details.
- package/CHANGELOG.md +58 -0
- package/locales/ar/common.json +1 -1
- package/locales/ar/discover.json +204 -0
- package/locales/ar/metadata.json +20 -3
- package/locales/ar/models.json +845 -0
- package/locales/ar/providers.json +80 -0
- package/locales/bg-BG/common.json +1 -1
- package/locales/bg-BG/discover.json +204 -0
- package/locales/bg-BG/metadata.json +20 -3
- package/locales/bg-BG/models.json +845 -0
- package/locales/bg-BG/providers.json +80 -0
- package/locales/de-DE/common.json +1 -1
- package/locales/de-DE/discover.json +204 -0
- package/locales/de-DE/metadata.json +20 -3
- package/locales/de-DE/models.json +845 -0
- package/locales/de-DE/providers.json +80 -0
- package/locales/en-US/common.json +1 -1
- package/locales/en-US/discover.json +204 -0
- package/locales/en-US/metadata.json +20 -3
- package/locales/en-US/models.json +845 -0
- package/locales/en-US/providers.json +80 -0
- package/locales/es-ES/common.json +1 -1
- package/locales/es-ES/discover.json +204 -0
- package/locales/es-ES/metadata.json +20 -3
- package/locales/es-ES/models.json +845 -0
- package/locales/es-ES/providers.json +80 -0
- package/locales/fr-FR/common.json +1 -1
- package/locales/fr-FR/discover.json +204 -0
- package/locales/fr-FR/metadata.json +20 -3
- package/locales/fr-FR/models.json +845 -0
- package/locales/fr-FR/providers.json +80 -0
- package/locales/it-IT/common.json +1 -1
- package/locales/it-IT/discover.json +204 -0
- package/locales/it-IT/metadata.json +20 -3
- package/locales/it-IT/models.json +845 -0
- package/locales/it-IT/providers.json +80 -0
- package/locales/ja-JP/common.json +1 -1
- package/locales/ja-JP/discover.json +204 -0
- package/locales/ja-JP/metadata.json +20 -3
- package/locales/ja-JP/models.json +845 -0
- package/locales/ja-JP/providers.json +80 -0
- package/locales/ko-KR/common.json +1 -1
- package/locales/ko-KR/discover.json +204 -0
- package/locales/ko-KR/metadata.json +20 -3
- package/locales/ko-KR/models.json +845 -0
- package/locales/ko-KR/providers.json +80 -0
- package/locales/nl-NL/common.json +1 -1
- package/locales/nl-NL/discover.json +204 -0
- package/locales/nl-NL/metadata.json +20 -3
- package/locales/nl-NL/models.json +845 -0
- package/locales/nl-NL/providers.json +80 -0
- package/locales/pl-PL/common.json +1 -1
- package/locales/pl-PL/discover.json +204 -0
- package/locales/pl-PL/metadata.json +20 -3
- package/locales/pl-PL/models.json +845 -0
- package/locales/pl-PL/providers.json +80 -0
- package/locales/pt-BR/common.json +1 -1
- package/locales/pt-BR/discover.json +204 -0
- package/locales/pt-BR/metadata.json +20 -3
- package/locales/pt-BR/models.json +845 -0
- package/locales/pt-BR/providers.json +80 -0
- package/locales/ru-RU/common.json +1 -1
- package/locales/ru-RU/discover.json +204 -0
- package/locales/ru-RU/metadata.json +20 -3
- package/locales/ru-RU/models.json +845 -0
- package/locales/ru-RU/providers.json +80 -0
- package/locales/tr-TR/common.json +1 -1
- package/locales/tr-TR/discover.json +204 -0
- package/locales/tr-TR/metadata.json +20 -3
- package/locales/tr-TR/models.json +845 -0
- package/locales/tr-TR/providers.json +80 -0
- package/locales/vi-VN/common.json +1 -1
- package/locales/vi-VN/discover.json +204 -0
- package/locales/vi-VN/metadata.json +20 -3
- package/locales/vi-VN/models.json +845 -0
- package/locales/vi-VN/providers.json +80 -0
- package/locales/zh-CN/common.json +1 -1
- package/locales/zh-CN/discover.json +204 -0
- package/locales/zh-CN/metadata.json +20 -3
- package/locales/zh-CN/models.json +845 -0
- package/locales/zh-CN/providers.json +80 -0
- package/locales/zh-CN/welcome.json +1 -1
- package/locales/zh-TW/common.json +1 -1
- package/locales/zh-TW/discover.json +204 -0
- package/locales/zh-TW/metadata.json +20 -3
- package/locales/zh-TW/models.json +845 -0
- package/locales/zh-TW/providers.json +80 -0
- package/package.json +3 -2
- package/src/app/(main)/@nav/_layout/Desktop/TopActions.test.tsx +3 -3
- package/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx +3 -3
- package/src/app/(main)/@nav/_layout/Mobile.tsx +3 -3
- package/src/app/(main)/_layout/Mobile.tsx +9 -1
- package/src/app/(main)/discover/(detail)/_layout/Desktop.tsx +24 -0
- package/src/app/(main)/discover/(detail)/_layout/Mobile/Header.tsx +25 -0
- package/src/app/(main)/discover/(detail)/_layout/Mobile/index.tsx +17 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx +35 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/AddAgent.tsx +86 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/TopicList.tsx +74 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/ConversationExample/index.tsx +100 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx +118 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/SuggestionItem.tsx +62 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/ToolItem.tsx +19 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/InfoSidebar/index.tsx +64 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/SystemRole.tsx +35 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/features/Temp.tsx +44 -0
- package/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx +121 -0
- package/src/app/(main)/discover/(detail)/error.tsx +5 -0
- package/src/app/(main)/discover/(detail)/features/Back.tsx +42 -0
- package/src/app/(main)/discover/(detail)/features/Block.tsx +50 -0
- package/src/app/(main)/discover/(detail)/features/DetailLayout.tsx +91 -0
- package/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx +82 -0
- package/src/app/(main)/discover/(detail)/features/ShareButton.tsx +160 -0
- package/src/app/(main)/discover/(detail)/features/SidebarContainer.tsx +19 -0
- package/src/app/(main)/discover/(detail)/layout.tsx +12 -0
- package/src/app/(main)/discover/(detail)/loading.tsx +38 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Actions.tsx +46 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ChatWithModel.tsx +93 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +85 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/SuggestionItem.tsx +75 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ParameterList/ParameterItem.tsx +71 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ParameterList/index.tsx +110 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/ProviderItem.tsx +152 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/features/ProviderList/index.tsx +45 -0
- package/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx +114 -0
- package/src/app/(main)/discover/(detail)/not-found.tsx +3 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Actions.tsx +35 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx +114 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/SuggestionItem.tsx +62 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/InstallPlugin.tsx +87 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/ParameterList.tsx +95 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/features/Schema.tsx +23 -0
- package/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx +103 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/Actions.tsx +49 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/Header.tsx +73 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/SuggestionItem.tsx +75 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/InfoSidebar/index.tsx +49 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/ModelItem.tsx +148 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ModelList/index.tsx +60 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/features/ProviderConfig.tsx +80 -0
- package/src/app/(main)/discover/(detail)/provider/[slug]/page.tsx +116 -0
- package/src/app/(main)/discover/(list)/(home)/Client.tsx +42 -0
- package/src/app/(main)/discover/(list)/(home)/features/AssistantList.tsx +33 -0
- package/src/app/(main)/discover/(list)/(home)/features/ModelList.tsx +22 -0
- package/src/app/(main)/discover/(list)/(home)/features/PluginList.tsx +25 -0
- package/src/app/(main)/discover/(list)/(home)/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/(home)/page.tsx +54 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/Nav.tsx +118 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/index.tsx +37 -0
- package/src/app/(main)/discover/(list)/_layout/Desktop/useScroll.ts +33 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/Header.tsx +62 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/Nav.tsx +94 -0
- package/src/app/(main)/discover/(list)/_layout/Mobile/index.tsx +27 -0
- package/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx +64 -0
- package/src/app/(main)/discover/(list)/assistants/_layout/Desktop.tsx +22 -0
- package/src/app/(main)/discover/(list)/assistants/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/assistants/features/Card.tsx +176 -0
- package/src/app/(main)/discover/(list)/assistants/features/Category.tsx +48 -0
- package/src/app/(main)/discover/(list)/assistants/features/List.tsx +97 -0
- package/src/app/(main)/discover/(list)/assistants/features/useCategory.tsx +116 -0
- package/src/app/(main)/discover/(list)/assistants/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/assistants/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/assistants/page.tsx +51 -0
- package/src/app/(main)/discover/(list)/error.tsx +5 -0
- package/src/app/(main)/{market → discover/(list)}/layout.tsx +4 -3
- package/src/app/(main)/discover/(list)/loading.tsx +39 -0
- package/src/app/(main)/discover/(list)/models/[slug]/page.tsx +70 -0
- package/src/app/(main)/discover/(list)/models/_layout/Desktop.tsx +28 -0
- package/src/app/(main)/discover/(list)/models/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/models/features/Card.tsx +116 -0
- package/src/app/(main)/discover/(list)/models/features/Category.tsx +67 -0
- package/src/app/(main)/discover/(list)/models/features/List.tsx +72 -0
- package/src/app/(main)/discover/(list)/models/features/const.ts +9 -0
- package/src/app/(main)/discover/(list)/models/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/models/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/models/page.tsx +61 -0
- package/src/app/(main)/discover/(list)/not-found.tsx +3 -0
- package/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx +64 -0
- package/src/app/(main)/discover/(list)/plugins/_layout/Desktop.tsx +22 -0
- package/src/app/(main)/discover/(list)/plugins/_layout/Mobile.tsx +9 -0
- package/src/app/(main)/discover/(list)/plugins/features/Card.tsx +154 -0
- package/src/app/(main)/discover/(list)/plugins/features/Category.tsx +45 -0
- package/src/app/(main)/discover/(list)/plugins/features/List.tsx +96 -0
- package/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx +80 -0
- package/src/app/(main)/discover/(list)/plugins/layout.tsx +12 -0
- package/src/app/(main)/discover/(list)/plugins/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/plugins/page.tsx +52 -0
- package/src/app/(main)/discover/(list)/providers/features/Card.tsx +117 -0
- package/src/app/(main)/discover/(list)/providers/features/List.tsx +71 -0
- package/src/app/(main)/discover/(list)/providers/loading.tsx +1 -0
- package/src/app/(main)/discover/(list)/providers/page.tsx +52 -0
- package/src/app/(main)/discover/_layout/Desktop/Header.tsx +36 -0
- package/src/app/(main)/discover/_layout/Desktop/index.tsx +21 -0
- package/src/app/(main)/discover/_layout/Mobile/index.tsx +9 -0
- package/src/app/(main)/{market/features/AgentCard/AgentCardBanner.tsx → discover/components/CardBanner.tsx} +5 -5
- package/src/app/(main)/discover/components/CategoryContainer.tsx +18 -0
- package/src/app/(main)/discover/components/CategoryMenu.tsx +39 -0
- package/src/app/(main)/discover/components/GitHubAvatar.tsx +19 -0
- package/src/app/(main)/discover/components/GridLoadingCard.tsx +69 -0
- package/src/app/(main)/discover/components/ListLoading.tsx +66 -0
- package/src/app/(main)/discover/components/Loading.tsx +17 -0
- package/src/app/(main)/discover/components/SearchResultCount.tsx +37 -0
- package/src/app/(main)/discover/components/Statistic.tsx +92 -0
- package/src/app/(main)/discover/components/Title.tsx +76 -0
- package/src/app/(main)/discover/components/VirtuosoGridList/index.tsx +52 -0
- package/src/app/(main)/discover/components/VirtuosoGridList/useScrollParent.ts +19 -0
- package/src/app/(main)/discover/error.tsx +5 -0
- package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/Inner.tsx +9 -10
- package/src/app/(main)/{market/features/ShareAgentButton → discover/features/CreateButton}/index.tsx +9 -9
- package/src/app/(main)/discover/features/LikeButton.tsx +73 -0
- package/src/app/(main)/discover/features/ModelFeatureTags.tsx +77 -0
- package/src/app/(main)/discover/features/StoreSearchBar.tsx +84 -0
- package/src/app/(main)/discover/features/const.ts +2 -0
- package/src/app/(main)/discover/features/useNav.tsx +71 -0
- package/src/app/(main)/discover/layout.tsx +12 -0
- package/src/app/(main)/discover/loading.tsx +9 -0
- package/src/app/(main)/discover/not-found.tsx +3 -0
- package/src/app/(main)/discover/search/_layout/Desktop.tsx +42 -0
- package/src/app/(main)/discover/search/_layout/Mobile/Header.tsx +31 -0
- package/src/app/(main)/discover/search/_layout/Mobile/Nav.tsx +56 -0
- package/src/app/(main)/discover/search/_layout/Mobile/index.tsx +32 -0
- package/src/app/(main)/discover/search/features/AssistantsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/Category.tsx +41 -0
- package/src/app/(main)/discover/search/features/ModelsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/PluginsResult.tsx +27 -0
- package/src/app/(main)/discover/search/features/ProvidersResult.tsx +26 -0
- package/src/app/(main)/discover/search/layout.tsx +12 -0
- package/src/app/(main)/discover/search/loading.tsx +1 -0
- package/src/app/(main)/discover/search/page.tsx +78 -0
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +0 -6
- package/src/app/(main)/welcome/features/Actions.tsx +1 -1
- package/src/app/@modal/(.)discover/assistant/[slug]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/layout.tsx +29 -0
- package/src/app/@modal/(.)discover/loading.tsx +3 -0
- package/src/app/@modal/(.)discover/model/[...slugs]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/plugin/[slug]/page.tsx +1 -0
- package/src/app/@modal/(.)discover/provider/[slug]/page.tsx +1 -0
- package/src/app/@modal/features/InterceptingContext.tsx +9 -0
- package/src/app/@modal/layout.tsx +58 -21
- package/src/app/api/{market → assistant}/[id]/route.ts +2 -3
- package/src/app/api/{market → assistant/store}/route.ts +2 -5
- package/src/app/api/plugin/store/route.ts +1 -4
- package/src/app/metadata.ts +3 -0
- package/src/app/redirect/page.tsx +15 -0
- package/src/components/FetchErrorNotification/Description.tsx +2 -0
- package/src/components/InterceptingLink/index.tsx +27 -0
- package/src/components/mdx/CodeBlock.tsx +46 -0
- package/src/components/mdx/Link.tsx +21 -0
- package/src/components/mdx/index.tsx +51 -0
- package/src/config/modelProviders/ollama.ts +0 -8
- package/src/const/discover.ts +63 -1
- package/src/features/Conversation/Error/PluginSettings.tsx +1 -1
- package/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx +1 -1
- package/src/features/Conversation/components/InboxWelcome/AgentsSuggest.tsx +41 -24
- package/src/features/MobileTabBar/index.tsx +3 -3
- package/src/features/PluginDetailModal/APIs.tsx +1 -1
- package/src/features/PluginDevModal/UrlManifestForm.tsx +1 -1
- package/src/features/PluginStore/PluginItem/Action.tsx +1 -1
- package/src/features/PluginsUI/Render/DefaultType/index.tsx +1 -1
- package/src/features/PluginsUI/Render/StandaloneType/index.tsx +1 -1
- package/src/hooks/useInterceptingRoutes.ts +21 -1
- package/src/hooks/useShare.tsx +191 -0
- package/src/libs/agent-runtime/utils/streams/openai.test.ts +43 -0
- package/src/libs/agent-runtime/utils/streams/openai.ts +1 -1
- package/src/locales/create.ts +1 -1
- package/src/locales/default/common.ts +1 -1
- package/src/locales/default/discover.ts +205 -0
- package/src/locales/default/index.ts +6 -2
- package/src/locales/default/metadata.ts +23 -3
- package/src/locales/default/models.ts +15 -0
- package/src/locales/default/providers.ts +15 -0
- package/src/locales/default/welcome.ts +1 -1
- package/src/locales/resources.ts +2 -0
- package/src/server/ld.ts +85 -11
- package/src/server/metadata.ts +41 -3
- package/src/{app/api/market/AgentMarket.test.ts → server/modules/AssistantStore/index.test.ts} +15 -15
- package/src/{app/api/market/AgentMarket.ts → server/modules/AssistantStore/index.ts} +7 -3
- package/src/{app/api/plugin/store/Store.test.ts → server/modules/PluginStore/index.test.ts} +1 -1
- package/src/server/services/discover/index.ts +352 -0
- package/src/server/services/doc/index.tsx +40 -0
- package/src/server/translation.ts +11 -5
- package/src/services/__tests__/__snapshots__/tool.test.ts.snap +1 -1
- package/src/services/{_auth.test.ts → __tests__/_auth.test.ts} +1 -1
- package/src/services/__tests__/assistant.test.ts +82 -0
- package/src/services/__tests__/tool.test.ts +13 -13
- package/src/services/_url.ts +2 -2
- package/src/services/assistant.ts +30 -0
- package/src/services/chat.ts +1 -1
- package/src/services/tool.ts +7 -129
- package/src/store/chat/slices/plugin/action.test.ts +112 -0
- package/src/store/chat/slices/plugin/action.ts +1 -3
- package/src/store/global/initialState.ts +1 -1
- package/src/store/tool/selectors/tool.test.ts +1 -1
- package/src/store/tool/slices/customPlugin/action.test.ts +1 -1
- package/src/store/tool/slices/customPlugin/action.ts +1 -1
- package/src/store/tool/slices/plugin/action.ts +1 -1
- package/src/store/tool/slices/plugin/selectors.test.ts +3 -3
- package/src/store/tool/slices/plugin/selectors.ts +3 -3
- package/src/store/tool/slices/store/action.test.ts +16 -22
- package/src/store/tool/slices/store/action.ts +8 -8
- package/src/types/discover.ts +152 -0
- package/src/types/llm.ts +4 -2
- package/src/types/meta.ts +1 -0
- package/src/utils/format.test.ts +191 -112
- package/src/utils/format.ts +36 -0
- package/src/utils/toolManifest.ts +124 -0
- package/src/app/(main)/market/@detail/default.tsx +0 -12
- package/src/app/(main)/market/@detail/features/AgentDetailContent.tsx +0 -73
- package/src/app/(main)/market/@detail/features/Banner.tsx +0 -46
- package/src/app/(main)/market/@detail/features/Comment.tsx +0 -16
- package/src/app/(main)/market/@detail/features/Header.tsx +0 -81
- package/src/app/(main)/market/@detail/features/Loading.tsx +0 -63
- package/src/app/(main)/market/@detail/features/TokenTag.tsx +0 -27
- package/src/app/(main)/market/@detail/features/style.ts +0 -32
- package/src/app/(main)/market/_layout/Desktop/DetailSidebar.tsx +0 -84
- package/src/app/(main)/market/_layout/Desktop/Header.tsx +0 -29
- package/src/app/(main)/market/_layout/Desktop/Hero.tsx +0 -40
- package/src/app/(main)/market/_layout/Desktop/index.tsx +0 -46
- package/src/app/(main)/market/_layout/Mobile/DetailModal.tsx +0 -32
- package/src/app/(main)/market/_layout/Mobile/Header.tsx +0 -20
- package/src/app/(main)/market/_layout/Mobile/index.tsx +0 -25
- package/src/app/(main)/market/_layout/type.ts +0 -6
- package/src/app/(main)/market/features/AgentCard/index.tsx +0 -139
- package/src/app/(main)/market/features/AgentList.tsx +0 -103
- package/src/app/(main)/market/features/AgentSearchBar.tsx +0 -42
- package/src/app/(main)/market/features/TagList.tsx +0 -69
- package/src/app/(main)/market/loading.tsx +0 -15
- package/src/app/(main)/market/page.tsx +0 -44
- package/src/const/market.ts +0 -15
- package/src/locales/default/market.ts +0 -32
- package/src/services/market.ts +0 -22
- package/src/store/market/action.ts +0 -82
- package/src/store/market/index.ts +0 -3
- package/src/store/market/initialState.ts +0 -19
- package/src/store/market/selectors.ts +0 -38
- package/src/store/market/store.ts +0 -48
- package/src/types/market.ts +0 -20
- /package/src/{app/api/plugin/store/Store.ts → server/modules/PluginStore/index.ts} +0 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
2
|
+
|
3
|
+
import { globalHelpers } from '@/store/user/helpers';
|
4
|
+
|
5
|
+
import { assistantService } from '../assistant';
|
6
|
+
|
7
|
+
// Mocking modules and functions
|
8
|
+
|
9
|
+
vi.mock('@/store/user/helpers', () => ({
|
10
|
+
globalHelpers: {
|
11
|
+
getCurrentLanguage: vi.fn(),
|
12
|
+
},
|
13
|
+
}));
|
14
|
+
|
15
|
+
beforeEach(() => {
|
16
|
+
vi.resetAllMocks();
|
17
|
+
});
|
18
|
+
|
19
|
+
describe('AssistantService', () => {
|
20
|
+
describe('getAssistantList', () => {
|
21
|
+
it('should fetch and return the assistant list', async () => {
|
22
|
+
// Arrange
|
23
|
+
const fakeResponse = { agents: [{ name: 'TestAssisstant' }] };
|
24
|
+
(globalHelpers.getCurrentLanguage as Mock).mockReturnValue('tt');
|
25
|
+
global.fetch = vi.fn(() =>
|
26
|
+
Promise.resolve({
|
27
|
+
json: () => Promise.resolve(fakeResponse),
|
28
|
+
}),
|
29
|
+
) as any;
|
30
|
+
|
31
|
+
// Act
|
32
|
+
const assistantList = await assistantService.getAssistantList();
|
33
|
+
|
34
|
+
// Assert
|
35
|
+
expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
|
36
|
+
expect(fetch).toHaveBeenCalledWith('/api/assistant/store?locale=tt');
|
37
|
+
expect(assistantList).toEqual(fakeResponse.agents);
|
38
|
+
});
|
39
|
+
|
40
|
+
it('should handle fetch error', async () => {
|
41
|
+
// Arrange
|
42
|
+
const fakeUrl = 'http://fake-url.com/plugins.json';
|
43
|
+
(globalHelpers.getCurrentLanguage as Mock).mockReturnValue('en');
|
44
|
+
global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
|
45
|
+
|
46
|
+
// Act & Assert
|
47
|
+
await expect(assistantService.getAssistantList()).rejects.toThrow('Network error');
|
48
|
+
});
|
49
|
+
});
|
50
|
+
describe('getAssistantList', () => {
|
51
|
+
it('should fetch and return the assistant list', async () => {
|
52
|
+
// Arrange
|
53
|
+
const fakeResponse = { identifier: 'test-assisstant' };
|
54
|
+
(globalHelpers.getCurrentLanguage as Mock).mockReturnValue('tt');
|
55
|
+
global.fetch = vi.fn(() =>
|
56
|
+
Promise.resolve({
|
57
|
+
json: () => Promise.resolve(fakeResponse),
|
58
|
+
}),
|
59
|
+
) as any;
|
60
|
+
|
61
|
+
// Act
|
62
|
+
const assistant = await assistantService.getAssistantById('test-assisstant');
|
63
|
+
|
64
|
+
// Assert
|
65
|
+
expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
|
66
|
+
expect(fetch).toHaveBeenCalledWith('/api/assistant/test-assisstant?locale=tt');
|
67
|
+
expect(assistant.identifier).toEqual(fakeResponse.identifier);
|
68
|
+
});
|
69
|
+
|
70
|
+
it('should handle fetch error', async () => {
|
71
|
+
// Arrange
|
72
|
+
const fakeUrl = 'http://fake-url.com/plugins.json';
|
73
|
+
(globalHelpers.getCurrentLanguage as Mock).mockReturnValue('en');
|
74
|
+
global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
|
75
|
+
|
76
|
+
// Act & Assert
|
77
|
+
await expect(assistantService.getAssistantById('test-assisstant')).rejects.toThrow(
|
78
|
+
'Network error',
|
79
|
+
);
|
80
|
+
});
|
81
|
+
});
|
82
|
+
});
|
@@ -19,7 +19,7 @@ beforeEach(() => {
|
|
19
19
|
});
|
20
20
|
|
21
21
|
describe('ToolService', () => {
|
22
|
-
describe('
|
22
|
+
describe('getToolList', () => {
|
23
23
|
it('should fetch and return the plugin list', async () => {
|
24
24
|
// Arrange
|
25
25
|
const fakeResponse = { plugins: [{ name: 'TestPlugin' }] };
|
@@ -31,12 +31,12 @@ describe('ToolService', () => {
|
|
31
31
|
) as any;
|
32
32
|
|
33
33
|
// Act
|
34
|
-
const pluginList = await toolService.
|
34
|
+
const pluginList = await toolService.getToolList();
|
35
35
|
|
36
36
|
// Assert
|
37
37
|
expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled();
|
38
38
|
expect(fetch).toHaveBeenCalledWith('/api/plugin/store?locale=tt');
|
39
|
-
expect(pluginList).toEqual(fakeResponse);
|
39
|
+
expect(pluginList).toEqual(fakeResponse.plugins);
|
40
40
|
});
|
41
41
|
|
42
42
|
it('should handle fetch error', async () => {
|
@@ -46,11 +46,11 @@ describe('ToolService', () => {
|
|
46
46
|
global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
|
47
47
|
|
48
48
|
// Act & Assert
|
49
|
-
await expect(toolService.
|
49
|
+
await expect(toolService.getToolList()).rejects.toThrow('Network error');
|
50
50
|
});
|
51
51
|
});
|
52
52
|
|
53
|
-
describe('
|
53
|
+
describe('getToolManifest', () => {
|
54
54
|
it('should return manifest', async () => {
|
55
55
|
const manifestUrl = 'http://fake-url.com/manifest.json';
|
56
56
|
|
@@ -98,7 +98,7 @@ describe('ToolService', () => {
|
|
98
98
|
}),
|
99
99
|
) as any;
|
100
100
|
|
101
|
-
const manifest = await toolService.
|
101
|
+
const manifest = await toolService.getToolManifest(manifestUrl);
|
102
102
|
|
103
103
|
expect(fetch).toHaveBeenCalledWith(manifestUrl);
|
104
104
|
expect(manifest).toEqual(fakeManifest);
|
@@ -106,7 +106,7 @@ describe('ToolService', () => {
|
|
106
106
|
|
107
107
|
it('should return error on noManifest', async () => {
|
108
108
|
try {
|
109
|
-
await toolService.
|
109
|
+
await toolService.getToolManifest();
|
110
110
|
} catch (e) {
|
111
111
|
expect(e).toEqual(new TypeError('noManifest'));
|
112
112
|
}
|
@@ -124,7 +124,7 @@ describe('ToolService', () => {
|
|
124
124
|
) as any;
|
125
125
|
|
126
126
|
try {
|
127
|
-
await toolService.
|
127
|
+
await toolService.getToolManifest(manifestUrl);
|
128
128
|
} catch (e) {
|
129
129
|
expect(e).toEqual(new TypeError('manifestInvalid'));
|
130
130
|
}
|
@@ -135,7 +135,7 @@ describe('ToolService', () => {
|
|
135
135
|
global.fetch = vi.fn(() => Promise.reject(new Error('Network error')));
|
136
136
|
|
137
137
|
try {
|
138
|
-
await toolService.
|
138
|
+
await toolService.getToolManifest(manifestUrl);
|
139
139
|
} catch (e) {
|
140
140
|
expect(e).toEqual(new TypeError('fetchError'));
|
141
141
|
}
|
@@ -156,7 +156,7 @@ describe('ToolService', () => {
|
|
156
156
|
) as any;
|
157
157
|
|
158
158
|
try {
|
159
|
-
await toolService.
|
159
|
+
await toolService.getToolManifest(manifestUrl);
|
160
160
|
} catch (e) {
|
161
161
|
expect(e).toEqual(new TypeError('urlError'));
|
162
162
|
}
|
@@ -174,7 +174,7 @@ describe('ToolService', () => {
|
|
174
174
|
) as any;
|
175
175
|
|
176
176
|
try {
|
177
|
-
await toolService.
|
177
|
+
await toolService.getToolManifest(manifestUrl);
|
178
178
|
} catch (e) {
|
179
179
|
expect(e).toEqual(new TypeError('fetchError'));
|
180
180
|
}
|
@@ -214,7 +214,7 @@ describe('ToolService', () => {
|
|
214
214
|
}),
|
215
215
|
) as any;
|
216
216
|
|
217
|
-
const manifest = await toolService.
|
217
|
+
const manifest = await toolService.getToolManifest(manifestUrl);
|
218
218
|
|
219
219
|
expect(manifest).toMatchSnapshot();
|
220
220
|
});
|
@@ -252,7 +252,7 @@ describe('ToolService', () => {
|
|
252
252
|
) as any;
|
253
253
|
|
254
254
|
try {
|
255
|
-
await toolService.
|
255
|
+
await toolService.getToolManifest(manifestUrl);
|
256
256
|
} catch (e) {
|
257
257
|
expect(e).toEqual(new TypeError('openAPIInvalid'));
|
258
258
|
}
|
package/src/services/_url.ts
CHANGED
@@ -21,8 +21,8 @@ export const API_ENDPOINTS = mapWithBasePath({
|
|
21
21
|
oauth: '/api/auth',
|
22
22
|
|
23
23
|
// agent markets
|
24
|
-
|
25
|
-
|
24
|
+
assistantStore: '/api/assistant/store',
|
25
|
+
assistant: (identifier: string) => withBasePath(`/api/assistant/${identifier}`),
|
26
26
|
|
27
27
|
// plugins
|
28
28
|
gateway: '/api/plugin/gateway',
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { cloneDeep, merge } from 'lodash-es';
|
2
|
+
|
3
|
+
import { DEFAULT_DISCOVER_ASSISTANT_ITEM } from '@/const/discover';
|
4
|
+
import { globalHelpers } from '@/store/user/helpers';
|
5
|
+
import { DiscoverAssistantItem } from '@/types/discover';
|
6
|
+
|
7
|
+
import { API_ENDPOINTS } from './_url';
|
8
|
+
|
9
|
+
class AssistantService {
|
10
|
+
getAssistantList = async (): Promise<DiscoverAssistantItem[]> => {
|
11
|
+
const locale = globalHelpers.getCurrentLanguage();
|
12
|
+
|
13
|
+
const res = await fetch(`${API_ENDPOINTS.assistantStore}?locale=${locale}`);
|
14
|
+
|
15
|
+
const json = await res.json();
|
16
|
+
|
17
|
+
return json.agents;
|
18
|
+
};
|
19
|
+
|
20
|
+
getAssistantById = async (identifier: string): Promise<DiscoverAssistantItem> => {
|
21
|
+
const locale = globalHelpers.getCurrentLanguage();
|
22
|
+
|
23
|
+
const res = await fetch(`${API_ENDPOINTS.assistant(identifier)}?locale=${locale}`);
|
24
|
+
|
25
|
+
const assistant: DiscoverAssistantItem = await res.json();
|
26
|
+
|
27
|
+
return merge(cloneDeep(DEFAULT_DISCOVER_ASSISTANT_ITEM), assistant);
|
28
|
+
};
|
29
|
+
}
|
30
|
+
export const assistantService = new AssistantService();
|
package/src/services/chat.ts
CHANGED
@@ -335,7 +335,7 @@ class ChatService {
|
|
335
335
|
const s = useToolStore.getState();
|
336
336
|
|
337
337
|
const settings = pluginSelectors.getPluginSettingsById(params.identifier)(s);
|
338
|
-
const manifest = pluginSelectors.
|
338
|
+
const manifest = pluginSelectors.getToolManifestById(params.identifier)(s);
|
339
339
|
|
340
340
|
const traceHeader = createTraceHeader(this.mapTrace(options?.trace, TraceTagMap.ToolCalling));
|
341
341
|
|
package/src/services/tool.ts
CHANGED
@@ -1,144 +1,22 @@
|
|
1
|
-
import {
|
2
|
-
LobeChatPluginManifest,
|
3
|
-
LobeChatPluginsMarketIndex,
|
4
|
-
pluginManifestSchema,
|
5
|
-
} from '@lobehub/chat-plugin-sdk';
|
6
|
-
|
7
1
|
import { globalHelpers } from '@/store/user/helpers';
|
8
|
-
import {
|
2
|
+
import { DiscoverPlugintem } from '@/types/discover';
|
3
|
+
import { convertOpenAIManifestToLobeManifest, getToolManifest } from '@/utils/toolManifest';
|
9
4
|
|
10
5
|
import { API_ENDPOINTS } from './_url';
|
11
6
|
|
12
7
|
class ToolService {
|
13
|
-
|
14
|
-
// 2. 发送请求
|
15
|
-
let res: Response;
|
16
|
-
try {
|
17
|
-
res = await (proxy ? fetch(API_ENDPOINTS.proxy, { body: url, method: 'POST' }) : fetch(url));
|
18
|
-
} catch {
|
19
|
-
throw new TypeError('fetchError');
|
20
|
-
}
|
21
|
-
|
22
|
-
if (!res.ok) {
|
23
|
-
throw new TypeError('fetchError');
|
24
|
-
}
|
25
|
-
|
26
|
-
let data;
|
27
|
-
const contentType = res.headers.get('Content-Type');
|
28
|
-
|
29
|
-
try {
|
30
|
-
if (contentType === 'application/json') {
|
31
|
-
data = await res.json();
|
32
|
-
} else {
|
33
|
-
const { default: YAML } = await import('yaml');
|
34
|
-
|
35
|
-
const yaml = await res.text();
|
36
|
-
data = YAML.parse(yaml);
|
37
|
-
}
|
38
|
-
} catch {
|
39
|
-
throw new TypeError('urlError');
|
40
|
-
}
|
41
|
-
|
42
|
-
return data;
|
43
|
-
};
|
44
|
-
/**
|
45
|
-
* get plugin list from store
|
46
|
-
*/
|
47
|
-
getPluginList = async (): Promise<LobeChatPluginsMarketIndex> => {
|
8
|
+
getToolList = async (): Promise<DiscoverPlugintem[]> => {
|
48
9
|
const locale = globalHelpers.getCurrentLanguage();
|
49
10
|
|
50
11
|
const res = await fetch(`${API_ENDPOINTS.pluginStore}?locale=${locale}`);
|
51
12
|
|
52
|
-
|
53
|
-
};
|
54
|
-
|
55
|
-
getPluginManifest = async (
|
56
|
-
url?: string,
|
57
|
-
useProxy: boolean = false,
|
58
|
-
): Promise<LobeChatPluginManifest> => {
|
59
|
-
// 1. valid plugin
|
60
|
-
if (!url) {
|
61
|
-
throw new TypeError('noManifest');
|
62
|
-
}
|
63
|
-
|
64
|
-
// 2. 发送请求
|
13
|
+
const json = await res.json();
|
65
14
|
|
66
|
-
|
67
|
-
|
68
|
-
// @ts-ignore
|
69
|
-
// if there is a description_for_model, it is an OpenAI plugin
|
70
|
-
// we need convert to lobe plugin
|
71
|
-
if (data['description_for_model']) {
|
72
|
-
data = this.convertOpenAIManifestToLobeManifest(data as any);
|
73
|
-
}
|
74
|
-
|
75
|
-
// 3. 校验插件文件格式规范
|
76
|
-
const parser = pluginManifestSchema.safeParse(data);
|
77
|
-
|
78
|
-
if (!parser.success) {
|
79
|
-
throw new TypeError('manifestInvalid', { cause: parser.error });
|
80
|
-
}
|
81
|
-
|
82
|
-
// 4. if exist OpenAPI api, merge the OpenAPIs to api
|
83
|
-
if (parser.data.openapi) {
|
84
|
-
const openapiJson = await this._fetchJSON(parser.data.openapi, useProxy);
|
85
|
-
|
86
|
-
try {
|
87
|
-
const { OpenAPIConvertor } = await import('@lobehub/chat-plugin-sdk/openapi');
|
88
|
-
|
89
|
-
const convertor = new OpenAPIConvertor(openapiJson);
|
90
|
-
const openAPIs = await convertor.convertOpenAPIToPluginSchema();
|
91
|
-
data.api = [...data.api, ...openAPIs];
|
92
|
-
|
93
|
-
data.settings = await convertor.convertAuthToSettingsSchema(data.settings);
|
94
|
-
} catch (error) {
|
95
|
-
throw new TypeError('openAPIInvalid', { cause: error });
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
return data;
|
15
|
+
return json.plugins;
|
100
16
|
};
|
101
17
|
|
102
|
-
|
103
|
-
|
104
|
-
): LobeChatPluginManifest => {
|
105
|
-
const manifest: LobeChatPluginManifest = {
|
106
|
-
api: [],
|
107
|
-
homepage: data.legal_info_url,
|
108
|
-
identifier: data.name_for_model,
|
109
|
-
meta: {
|
110
|
-
avatar: data.logo_url,
|
111
|
-
description: data.description_for_human,
|
112
|
-
title: data.name_for_human,
|
113
|
-
},
|
114
|
-
openapi: data.api.url,
|
115
|
-
systemRole: data.description_for_model,
|
116
|
-
type: 'default',
|
117
|
-
version: '1',
|
118
|
-
};
|
119
|
-
switch (data.auth.type) {
|
120
|
-
case 'none': {
|
121
|
-
break;
|
122
|
-
}
|
123
|
-
case 'service_http': {
|
124
|
-
manifest.settings = {
|
125
|
-
properties: {
|
126
|
-
apiAuthKey: {
|
127
|
-
default: data.auth.verification_tokens['openai'],
|
128
|
-
description: 'API Key',
|
129
|
-
format: 'password',
|
130
|
-
title: 'API Key',
|
131
|
-
type: 'string',
|
132
|
-
},
|
133
|
-
},
|
134
|
-
type: 'object',
|
135
|
-
};
|
136
|
-
break;
|
137
|
-
}
|
138
|
-
}
|
139
|
-
|
140
|
-
return manifest;
|
141
|
-
};
|
18
|
+
getToolManifest = getToolManifest;
|
19
|
+
convertOpenAIManifestToLobeManifest = convertOpenAIManifestToLobeManifest;
|
142
20
|
}
|
143
21
|
|
144
22
|
export const toolService = new ToolService();
|
@@ -33,6 +33,118 @@ afterEach(() => {
|
|
33
33
|
});
|
34
34
|
|
35
35
|
describe('ChatPluginAction', () => {
|
36
|
+
describe('summaryPluginContent', () => {
|
37
|
+
it('should summarize plugin content', async () => {
|
38
|
+
const messageId = 'message-id';
|
39
|
+
const toolMessage = {
|
40
|
+
id: messageId,
|
41
|
+
role: 'tool',
|
42
|
+
content: 'Tool content to summarize',
|
43
|
+
} as ChatMessage;
|
44
|
+
|
45
|
+
const internal_coreProcessMessageMock = vi.fn();
|
46
|
+
|
47
|
+
act(() => {
|
48
|
+
useChatStore.setState({
|
49
|
+
activeId: 'session-id',
|
50
|
+
messagesMap: { [messageMapKey('session-id')]: [toolMessage] },
|
51
|
+
internal_coreProcessMessage: internal_coreProcessMessageMock,
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
const { result } = renderHook(() => useChatStore());
|
56
|
+
|
57
|
+
await act(async () => {
|
58
|
+
await result.current.summaryPluginContent(messageId);
|
59
|
+
});
|
60
|
+
|
61
|
+
expect(internal_coreProcessMessageMock).toHaveBeenCalledWith(
|
62
|
+
[
|
63
|
+
{
|
64
|
+
role: 'assistant',
|
65
|
+
content: '作为一名总结专家,请结合以上系统提示词,将以下内容进行总结:',
|
66
|
+
},
|
67
|
+
{
|
68
|
+
...toolMessage,
|
69
|
+
meta: {
|
70
|
+
avatar: '🤯',
|
71
|
+
backgroundColor: 'rgba(0,0,0,0)',
|
72
|
+
description: undefined,
|
73
|
+
title: undefined,
|
74
|
+
},
|
75
|
+
content: toolMessage.content,
|
76
|
+
role: 'assistant',
|
77
|
+
name: undefined,
|
78
|
+
tool_call_id: undefined,
|
79
|
+
},
|
80
|
+
],
|
81
|
+
messageId,
|
82
|
+
);
|
83
|
+
});
|
84
|
+
|
85
|
+
it('should not summarize non-tool messages', async () => {
|
86
|
+
const messageId = 'message-id';
|
87
|
+
const nonToolMessage = {
|
88
|
+
id: messageId,
|
89
|
+
role: 'user',
|
90
|
+
content: 'User message',
|
91
|
+
} as ChatMessage;
|
92
|
+
|
93
|
+
const internal_coreProcessMessageMock = vi.fn();
|
94
|
+
|
95
|
+
act(() => {
|
96
|
+
useChatStore.setState({
|
97
|
+
activeId: 'session-id',
|
98
|
+
messagesMap: { [messageMapKey('session-id')]: [nonToolMessage] },
|
99
|
+
internal_coreProcessMessage: internal_coreProcessMessageMock,
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
103
|
+
const { result } = renderHook(() => useChatStore());
|
104
|
+
|
105
|
+
await act(async () => {
|
106
|
+
await result.current.summaryPluginContent(messageId);
|
107
|
+
});
|
108
|
+
|
109
|
+
expect(internal_coreProcessMessageMock).not.toHaveBeenCalled();
|
110
|
+
});
|
111
|
+
});
|
112
|
+
|
113
|
+
describe('internal_togglePluginApiCalling', () => {
|
114
|
+
it('should toggle plugin API calling state', () => {
|
115
|
+
const internal_toggleLoadingArraysMock = vi.fn();
|
116
|
+
|
117
|
+
act(() => {
|
118
|
+
useChatStore.setState({
|
119
|
+
internal_toggleLoadingArrays: internal_toggleLoadingArraysMock,
|
120
|
+
});
|
121
|
+
});
|
122
|
+
|
123
|
+
const { result } = renderHook(() => useChatStore());
|
124
|
+
|
125
|
+
const messageId = 'message-id';
|
126
|
+
const action = 'test-action';
|
127
|
+
|
128
|
+
result.current.internal_togglePluginApiCalling(true, messageId, action);
|
129
|
+
|
130
|
+
expect(internal_toggleLoadingArraysMock).toHaveBeenCalledWith(
|
131
|
+
'pluginApiLoadingIds',
|
132
|
+
true,
|
133
|
+
messageId,
|
134
|
+
action,
|
135
|
+
);
|
136
|
+
|
137
|
+
result.current.internal_togglePluginApiCalling(false, messageId, action);
|
138
|
+
|
139
|
+
expect(internal_toggleLoadingArraysMock).toHaveBeenCalledWith(
|
140
|
+
'pluginApiLoadingIds',
|
141
|
+
false,
|
142
|
+
messageId,
|
143
|
+
action,
|
144
|
+
);
|
145
|
+
});
|
146
|
+
});
|
147
|
+
|
36
148
|
describe('fillPluginMessageContent', () => {
|
37
149
|
it('should update message content and trigger the ai message', async () => {
|
38
150
|
// 设置模拟函数的返回值
|
@@ -445,9 +445,7 @@ export const chatPlugin: StateCreator<
|
|
445
445
|
// if the apiName is md5, try to find the correct apiName in the plugins
|
446
446
|
if (apiName.startsWith(PLUGIN_SCHEMA_API_MD5_PREFIX)) {
|
447
447
|
const md5 = apiName.replace(PLUGIN_SCHEMA_API_MD5_PREFIX, '');
|
448
|
-
const manifest = pluginSelectors.
|
449
|
-
useToolStore.getState(),
|
450
|
-
);
|
448
|
+
const manifest = pluginSelectors.getToolManifestById(identifier)(useToolStore.getState());
|
451
449
|
|
452
450
|
const api = manifest?.api.find((api) => Md5.hashStr(api.name).toString() === md5);
|
453
451
|
if (api) {
|
@@ -154,7 +154,7 @@ describe('toolSelectors', () => {
|
|
154
154
|
});
|
155
155
|
});
|
156
156
|
|
157
|
-
describe('
|
157
|
+
describe('getToolManifestLoadingStatus', () => {
|
158
158
|
it('should return "loading" if the plugin manifest is being loaded', () => {
|
159
159
|
const result = toolSelectors.getManifestLoadingStatus('plugin-2')(mockState);
|
160
160
|
expect(result).toBe('loading');
|
@@ -42,7 +42,7 @@ export const createCustomPluginSlice: StateCreator<
|
|
42
42
|
const { refreshPlugins, updateInstallLoadingState } = get();
|
43
43
|
try {
|
44
44
|
updateInstallLoadingState(id, true);
|
45
|
-
const manifest = await toolService.
|
45
|
+
const manifest = await toolService.getToolManifest(
|
46
46
|
plugin.customParams?.manifestUrl,
|
47
47
|
plugin.customParams?.useProxy,
|
48
48
|
);
|
@@ -61,7 +61,7 @@ export const createPluginSlice: StateCreator<
|
|
61
61
|
},
|
62
62
|
useCheckPluginsIsInstalled: (plugins) => useSWR(plugins, get().checkPluginsIsInstalled),
|
63
63
|
validatePluginSettings: async (identifier) => {
|
64
|
-
const manifest = pluginSelectors.
|
64
|
+
const manifest = pluginSelectors.getToolManifestById(identifier)(get());
|
65
65
|
if (!manifest || !manifest.settings) return;
|
66
66
|
const settings = pluginSelectors.getPluginSettingsById(identifier)(get());
|
67
67
|
|
@@ -58,9 +58,9 @@ const mockState = {
|
|
58
58
|
} as ToolStoreState;
|
59
59
|
|
60
60
|
describe('pluginSelectors', () => {
|
61
|
-
describe('
|
62
|
-
it('
|
63
|
-
const result = pluginSelectors.
|
61
|
+
describe('getToolManifestById', () => {
|
62
|
+
it('getToolManifestById should return the correct manifest', () => {
|
63
|
+
const result = pluginSelectors.getToolManifestById('plugin-1')(mockState);
|
64
64
|
expect(result).toEqual(mockState.installedPlugins[0].manifest);
|
65
65
|
});
|
66
66
|
});
|
@@ -27,7 +27,7 @@ const getCustomPluginById = (id: string) => (s: ToolStoreState) =>
|
|
27
27
|
| LobeToolCustomPlugin
|
28
28
|
| undefined;
|
29
29
|
|
30
|
-
const
|
30
|
+
const getToolManifestById = (id: string) => (s: ToolStoreState) =>
|
31
31
|
getInstalledPluginById(id)(s)?.manifest;
|
32
32
|
|
33
33
|
const getPluginSettingsById = (id: string) => (s: ToolStoreState) =>
|
@@ -59,7 +59,7 @@ const installedCustomPluginMetaList = (s: ToolStoreState) =>
|
|
59
59
|
installedPluginMetaList(s).filter((p) => p.type === 'customPlugin');
|
60
60
|
|
61
61
|
const isPluginHasUI = (id: string) => (s: ToolStoreState) => {
|
62
|
-
const plugin =
|
62
|
+
const plugin = getToolManifestById(id)(s);
|
63
63
|
|
64
64
|
return !!plugin?.ui;
|
65
65
|
};
|
@@ -67,9 +67,9 @@ const isPluginHasUI = (id: string) => (s: ToolStoreState) => {
|
|
67
67
|
export const pluginSelectors = {
|
68
68
|
getCustomPluginById,
|
69
69
|
getInstalledPluginById,
|
70
|
-
getPluginManifestById,
|
71
70
|
getPluginMetaById,
|
72
71
|
getPluginSettingsById,
|
72
|
+
getToolManifestById,
|
73
73
|
installedCustomPluginMetaList,
|
74
74
|
installedPluginManifestList,
|
75
75
|
installedPluginMetaList,
|