@lobehub/chat 1.17.7 → 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 +25 -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/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/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
@@ -4,7 +4,11 @@ import { appEnv } from '@/config/app';
|
|
4
4
|
import { DEFAULT_LANG, isLocaleNotSupport } from '@/const/locale';
|
5
5
|
import { Locales, normalizeLocale } from '@/locales/resources';
|
6
6
|
|
7
|
-
|
7
|
+
const checkSupportLocale = (lang: Locales) => {
|
8
|
+
return isLocaleNotSupport(lang) || normalizeLocale(lang) !== 'zh-CN';
|
9
|
+
};
|
10
|
+
|
11
|
+
export class AssistantStore {
|
8
12
|
private readonly baseUrl: string;
|
9
13
|
|
10
14
|
constructor(baseUrl?: string) {
|
@@ -12,13 +16,13 @@ export class AgentMarket {
|
|
12
16
|
}
|
13
17
|
|
14
18
|
getAgentIndexUrl = (lang: Locales = DEFAULT_LANG) => {
|
15
|
-
if (
|
19
|
+
if (checkSupportLocale(lang)) return this.baseUrl;
|
16
20
|
|
17
21
|
return urlJoin(this.baseUrl, `index.${normalizeLocale(lang)}.json`);
|
18
22
|
};
|
19
23
|
|
20
24
|
getAgentUrl = (identifier: string, lang: Locales = DEFAULT_LANG) => {
|
21
|
-
if (
|
25
|
+
if (checkSupportLocale(lang)) return urlJoin(this.baseUrl, `${identifier}.json`);
|
22
26
|
|
23
27
|
return urlJoin(this.baseUrl, `${identifier}.${normalizeLocale(lang)}.json`);
|
24
28
|
};
|
@@ -0,0 +1,352 @@
|
|
1
|
+
import { cloneDeep, isString, merge, uniqBy } from 'lodash-es';
|
2
|
+
import pMap from 'p-map';
|
3
|
+
|
4
|
+
import { DEFAULT_MODEL_PROVIDER_LIST } from '@/config/modelProviders';
|
5
|
+
import {
|
6
|
+
DEFAULT_DISCOVER_ASSISTANT_ITEM,
|
7
|
+
DEFAULT_DISCOVER_MODEL_ITEM,
|
8
|
+
DEFAULT_DISCOVER_PLUGIN_ITEM,
|
9
|
+
DEFAULT_DISCOVER_PROVIDER_ITEM,
|
10
|
+
} from '@/const/discover';
|
11
|
+
import { DEFAULT_LANG } from '@/const/locale';
|
12
|
+
import { Locales } from '@/locales/resources';
|
13
|
+
import { AssistantStore } from '@/server/modules/AssistantStore';
|
14
|
+
import { PluginStore } from '@/server/modules/PluginStore';
|
15
|
+
import {
|
16
|
+
AssistantCategory,
|
17
|
+
DiscoverAssistantItem,
|
18
|
+
DiscoverModelItem,
|
19
|
+
DiscoverPlugintem,
|
20
|
+
DiscoverProviderItem,
|
21
|
+
PluginCategory,
|
22
|
+
} from '@/types/discover';
|
23
|
+
import { getToolManifest } from '@/utils/toolManifest';
|
24
|
+
|
25
|
+
const revalidate: number = 3600;
|
26
|
+
|
27
|
+
export class DiscoverService {
|
28
|
+
assistantStore = new AssistantStore();
|
29
|
+
pluginStore = new PluginStore();
|
30
|
+
|
31
|
+
// Assistants
|
32
|
+
searchAssistant = async (locale: Locales, keywords: string): Promise<DiscoverAssistantItem[]> => {
|
33
|
+
const list = await this.getAssistantList(locale);
|
34
|
+
return list.filter((item) => {
|
35
|
+
return [item.author, item.meta.title, item.meta.description, item.meta?.tags]
|
36
|
+
.flat()
|
37
|
+
.filter(Boolean)
|
38
|
+
.join(',')
|
39
|
+
.toLowerCase()
|
40
|
+
.includes(decodeURIComponent(keywords).toLowerCase());
|
41
|
+
});
|
42
|
+
};
|
43
|
+
|
44
|
+
getAssistantCategory = async (
|
45
|
+
locale: Locales,
|
46
|
+
category: AssistantCategory,
|
47
|
+
): Promise<DiscoverAssistantItem[]> => {
|
48
|
+
const list = await this.getAssistantList(locale);
|
49
|
+
return list.filter((item) => item.meta.category === category);
|
50
|
+
};
|
51
|
+
|
52
|
+
getAssistantList = async (locale: Locales): Promise<DiscoverAssistantItem[]> => {
|
53
|
+
let res = await fetch(this.assistantStore.getAgentIndexUrl(locale), {
|
54
|
+
next: { revalidate },
|
55
|
+
});
|
56
|
+
|
57
|
+
if (!res.ok) {
|
58
|
+
res = await fetch(this.assistantStore.getAgentIndexUrl(DEFAULT_LANG), {
|
59
|
+
next: { revalidate },
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
const json = await res.json();
|
64
|
+
|
65
|
+
return json.agents;
|
66
|
+
};
|
67
|
+
|
68
|
+
getAssistantById = async (
|
69
|
+
locale: Locales,
|
70
|
+
identifier: string,
|
71
|
+
): Promise<DiscoverAssistantItem | undefined> => {
|
72
|
+
let res = await fetch(this.assistantStore.getAgentUrl(identifier, locale), {
|
73
|
+
next: { revalidate: 12 * revalidate },
|
74
|
+
});
|
75
|
+
|
76
|
+
if (!res.ok) {
|
77
|
+
res = await fetch(this.assistantStore.getAgentUrl(DEFAULT_LANG), {
|
78
|
+
next: { revalidate: 12 * revalidate },
|
79
|
+
});
|
80
|
+
}
|
81
|
+
|
82
|
+
let assistant = await res.json();
|
83
|
+
|
84
|
+
if (!assistant) return;
|
85
|
+
|
86
|
+
assistant = merge(cloneDeep(DEFAULT_DISCOVER_ASSISTANT_ITEM), assistant);
|
87
|
+
|
88
|
+
const categoryItems = await this.getAssistantCategory(
|
89
|
+
locale,
|
90
|
+
assistant.meta.category || AssistantCategory.General,
|
91
|
+
);
|
92
|
+
|
93
|
+
assistant = {
|
94
|
+
...assistant,
|
95
|
+
suggestions: categoryItems
|
96
|
+
.filter((item) => item.identifier !== assistant.identifier)
|
97
|
+
.slice(0, 5) as any,
|
98
|
+
};
|
99
|
+
|
100
|
+
return assistant;
|
101
|
+
};
|
102
|
+
|
103
|
+
getAssistantByIds = async (
|
104
|
+
locale: Locales,
|
105
|
+
identifiers: string[],
|
106
|
+
): Promise<DiscoverAssistantItem[]> => {
|
107
|
+
const list = await pMap(
|
108
|
+
identifiers,
|
109
|
+
async (identifier) => this.getAssistantById(locale, identifier),
|
110
|
+
{
|
111
|
+
concurrency: 5,
|
112
|
+
},
|
113
|
+
);
|
114
|
+
|
115
|
+
return list.filter(Boolean) as DiscoverAssistantItem[];
|
116
|
+
};
|
117
|
+
|
118
|
+
// Tools
|
119
|
+
|
120
|
+
searchPlugin = async (locale: Locales, keywords: string): Promise<DiscoverPlugintem[]> => {
|
121
|
+
const list = await this.getPluginList(locale);
|
122
|
+
return list.filter((item) => {
|
123
|
+
return [item.author, item.meta.title, item.meta.description, item.meta?.tags]
|
124
|
+
.flat()
|
125
|
+
.filter(Boolean)
|
126
|
+
.join(',')
|
127
|
+
.toLowerCase()
|
128
|
+
.includes(decodeURIComponent(keywords).toLowerCase());
|
129
|
+
});
|
130
|
+
};
|
131
|
+
|
132
|
+
getPluginCategory = async (
|
133
|
+
locale: Locales,
|
134
|
+
category: PluginCategory,
|
135
|
+
): Promise<DiscoverPlugintem[]> => {
|
136
|
+
const list = await this.getPluginList(locale);
|
137
|
+
return list.filter((item) => item.meta.category === category);
|
138
|
+
};
|
139
|
+
|
140
|
+
getPluginList = async (locale: Locales): Promise<DiscoverPlugintem[]> => {
|
141
|
+
let res = await fetch(this.pluginStore.getPluginIndexUrl(locale), {
|
142
|
+
next: { revalidate: 12 * revalidate },
|
143
|
+
});
|
144
|
+
|
145
|
+
if (!res.ok) {
|
146
|
+
res = await fetch(this.pluginStore.getPluginIndexUrl(DEFAULT_LANG), {
|
147
|
+
next: { revalidate: 12 * revalidate },
|
148
|
+
});
|
149
|
+
}
|
150
|
+
|
151
|
+
const json = await res.json();
|
152
|
+
return json.plugins;
|
153
|
+
};
|
154
|
+
|
155
|
+
getPluginByIds = async (locale: Locales, identifiers: string[]): Promise<DiscoverPlugintem[]> => {
|
156
|
+
let list = await pMap(
|
157
|
+
identifiers,
|
158
|
+
async (identifier) => this.getPluginById(locale, identifier),
|
159
|
+
{
|
160
|
+
concurrency: 5,
|
161
|
+
},
|
162
|
+
);
|
163
|
+
|
164
|
+
return list.filter(Boolean) as DiscoverPlugintem[];
|
165
|
+
};
|
166
|
+
|
167
|
+
getPluginById = async (
|
168
|
+
locale: Locales,
|
169
|
+
identifier: string,
|
170
|
+
withManifest?: boolean,
|
171
|
+
): Promise<DiscoverPlugintem | undefined> => {
|
172
|
+
const list = await this.getPluginList(locale);
|
173
|
+
let plugin = list.find((item) => item.identifier === identifier) as DiscoverPlugintem;
|
174
|
+
|
175
|
+
if (!plugin) return;
|
176
|
+
|
177
|
+
plugin = merge(cloneDeep(DEFAULT_DISCOVER_PLUGIN_ITEM), plugin);
|
178
|
+
|
179
|
+
if (withManifest) {
|
180
|
+
const manifest = isString(plugin?.manifest)
|
181
|
+
? await getToolManifest(plugin.manifest)
|
182
|
+
: plugin?.manifest;
|
183
|
+
|
184
|
+
plugin = {
|
185
|
+
...plugin,
|
186
|
+
manifest,
|
187
|
+
} as DiscoverPlugintem;
|
188
|
+
}
|
189
|
+
|
190
|
+
const categoryItems = await this.getPluginCategory(
|
191
|
+
locale,
|
192
|
+
plugin.meta.category || PluginCategory.Tools,
|
193
|
+
);
|
194
|
+
|
195
|
+
plugin = {
|
196
|
+
...plugin,
|
197
|
+
suggestions: categoryItems
|
198
|
+
.filter((item) => item.identifier !== plugin.identifier)
|
199
|
+
.slice(0, 5) as any,
|
200
|
+
} as DiscoverPlugintem;
|
201
|
+
|
202
|
+
return plugin;
|
203
|
+
};
|
204
|
+
|
205
|
+
// Providers
|
206
|
+
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
208
|
+
getProviderList = async (locale: Locales): Promise<DiscoverProviderItem[]> => {
|
209
|
+
const list = DEFAULT_MODEL_PROVIDER_LIST.filter((item) => item.chatModels.length > 0);
|
210
|
+
return list.map((item) => {
|
211
|
+
const provider = {
|
212
|
+
identifier: item.id,
|
213
|
+
meta: {
|
214
|
+
...item,
|
215
|
+
title: item.name,
|
216
|
+
},
|
217
|
+
models: item.chatModels.map((item) => item.id),
|
218
|
+
};
|
219
|
+
return merge(cloneDeep(DEFAULT_DISCOVER_PROVIDER_ITEM), provider) as DiscoverProviderItem;
|
220
|
+
});
|
221
|
+
};
|
222
|
+
|
223
|
+
searchProvider = async (locale: Locales, keywords: string): Promise<DiscoverProviderItem[]> => {
|
224
|
+
const list = await this.getProviderList(locale);
|
225
|
+
return list.filter((item) => {
|
226
|
+
return [item.identifier, item.meta.title]
|
227
|
+
.filter(Boolean)
|
228
|
+
.join(',')
|
229
|
+
.toLowerCase()
|
230
|
+
.includes(decodeURIComponent(keywords).toLowerCase());
|
231
|
+
});
|
232
|
+
};
|
233
|
+
|
234
|
+
getProviderById = async (
|
235
|
+
locale: Locales,
|
236
|
+
id: string,
|
237
|
+
): Promise<DiscoverProviderItem | undefined> => {
|
238
|
+
const list = await this.getProviderList(locale);
|
239
|
+
let provider = list.find((item) => item.identifier === id);
|
240
|
+
|
241
|
+
if (!provider) return;
|
242
|
+
|
243
|
+
provider = {
|
244
|
+
...provider,
|
245
|
+
suggestions: list
|
246
|
+
.filter((item) => item.identifier !== provider?.identifier)
|
247
|
+
.slice(0, 5) as any,
|
248
|
+
};
|
249
|
+
|
250
|
+
return merge(cloneDeep(DEFAULT_DISCOVER_PROVIDER_ITEM), provider) as DiscoverProviderItem;
|
251
|
+
};
|
252
|
+
|
253
|
+
getProviderByIds = async (
|
254
|
+
locale: Locales,
|
255
|
+
identifiers: string[],
|
256
|
+
): Promise<DiscoverProviderItem[]> => {
|
257
|
+
const list = await pMap(
|
258
|
+
identifiers,
|
259
|
+
async (identifier) => this.getProviderById(locale, identifier),
|
260
|
+
{
|
261
|
+
concurrency: 5,
|
262
|
+
},
|
263
|
+
);
|
264
|
+
|
265
|
+
return list.filter(Boolean) as DiscoverProviderItem[];
|
266
|
+
};
|
267
|
+
|
268
|
+
// Models
|
269
|
+
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
271
|
+
private _getModelList = async (locale: Locales): Promise<DiscoverModelItem[]> => {
|
272
|
+
const list = DEFAULT_MODEL_PROVIDER_LIST.filter((item) => item.chatModels.length > 0);
|
273
|
+
const providers = await this.getProviderList(locale);
|
274
|
+
|
275
|
+
return list.flatMap((provider) => {
|
276
|
+
return provider.chatModels.map((item) => {
|
277
|
+
const ids = item.id.split('/')[1] || item.id;
|
278
|
+
const providerIds = providers
|
279
|
+
.filter((provider) => provider.models.join('').includes(ids))
|
280
|
+
.map((provider) => provider.identifier);
|
281
|
+
const model = {
|
282
|
+
identifier: item.id,
|
283
|
+
meta: {
|
284
|
+
...item,
|
285
|
+
category: provider.id,
|
286
|
+
title: item.displayName || item.id,
|
287
|
+
},
|
288
|
+
providers: providerIds,
|
289
|
+
suggestions: [],
|
290
|
+
};
|
291
|
+
return merge(cloneDeep(DEFAULT_DISCOVER_MODEL_ITEM), model) as DiscoverModelItem;
|
292
|
+
});
|
293
|
+
});
|
294
|
+
};
|
295
|
+
|
296
|
+
getModelList = async (locale: Locales): Promise<DiscoverModelItem[]> => {
|
297
|
+
const list = await this._getModelList(locale);
|
298
|
+
|
299
|
+
return uniqBy(list, (item) => {
|
300
|
+
const ids = item.identifier.split('/');
|
301
|
+
return ids[1] || item.identifier;
|
302
|
+
});
|
303
|
+
};
|
304
|
+
|
305
|
+
searchModel = async (locale: Locales, keywords: string): Promise<DiscoverModelItem[]> => {
|
306
|
+
const list = await this.getModelList(locale);
|
307
|
+
return list.filter((item) => {
|
308
|
+
return [item.identifier, item.meta.title, item.meta.description, item.providers]
|
309
|
+
.flat()
|
310
|
+
.filter(Boolean)
|
311
|
+
.join(',')
|
312
|
+
.toLowerCase()
|
313
|
+
.includes(decodeURIComponent(keywords).toLowerCase());
|
314
|
+
});
|
315
|
+
};
|
316
|
+
|
317
|
+
getModelCategory = async (locale: Locales, category: string): Promise<DiscoverModelItem[]> => {
|
318
|
+
const list = await this._getModelList(locale);
|
319
|
+
return list.filter((item) => item.meta.category === category);
|
320
|
+
};
|
321
|
+
|
322
|
+
getModelById = async (locale: Locales, id: string): Promise<DiscoverModelItem | undefined> => {
|
323
|
+
const list = await this.getModelList(locale);
|
324
|
+
let model = list.find((item) => item.identifier === id);
|
325
|
+
|
326
|
+
if (!model) return;
|
327
|
+
|
328
|
+
const categoryItems = model?.meta?.category
|
329
|
+
? await this.getModelCategory(locale, model.meta.category)
|
330
|
+
: [];
|
331
|
+
|
332
|
+
model = {
|
333
|
+
...model,
|
334
|
+
suggestions: categoryItems
|
335
|
+
.filter((item) => item.identifier !== model?.identifier)
|
336
|
+
.slice(0, 5) as any,
|
337
|
+
};
|
338
|
+
|
339
|
+
return merge(cloneDeep(DEFAULT_DISCOVER_MODEL_ITEM), model);
|
340
|
+
};
|
341
|
+
|
342
|
+
getModelByIds = async (locale: Locales, identifiers: string[]): Promise<DiscoverModelItem[]> => {
|
343
|
+
const list = await pMap(
|
344
|
+
identifiers,
|
345
|
+
async (identifier) => this.getModelById(locale, identifier),
|
346
|
+
{
|
347
|
+
concurrency: 5,
|
348
|
+
},
|
349
|
+
);
|
350
|
+
return list.filter(Boolean) as DiscoverModelItem[];
|
351
|
+
};
|
352
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import matter from 'gray-matter';
|
2
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
3
|
+
import { join } from 'node:path';
|
4
|
+
|
5
|
+
const LAST_MODIFIED = new Date().toISOString();
|
6
|
+
|
7
|
+
export class DocService {
|
8
|
+
async getDocByPath(locale: string, path: string) {
|
9
|
+
const extra = locale === 'zh-CN' ? '.zh-CN.mdx' : '.mdx';
|
10
|
+
|
11
|
+
const localPath = join(process.cwd(), 'docs/', path) + extra;
|
12
|
+
|
13
|
+
const isLocalePathExist = existsSync(localPath);
|
14
|
+
|
15
|
+
if (!isLocalePathExist) return;
|
16
|
+
|
17
|
+
const text: string = readFileSync(localPath, 'utf8');
|
18
|
+
|
19
|
+
if (!text) return;
|
20
|
+
|
21
|
+
const { data, content } = matter(text);
|
22
|
+
|
23
|
+
const regex = /^#\s(.+)/;
|
24
|
+
const match = regex.exec(content);
|
25
|
+
const matches = content.split(regex);
|
26
|
+
const description = matches[1] ? matches[1].trim() : '';
|
27
|
+
return {
|
28
|
+
date: data?.date ? new Date(data.date) : new Date(LAST_MODIFIED),
|
29
|
+
description: description.replaceAll('\n', '').replaceAll(' ', ' ').slice(0, 160),
|
30
|
+
tags: [],
|
31
|
+
title: match ? match[1] : '',
|
32
|
+
...data,
|
33
|
+
content,
|
34
|
+
};
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
// 很奇怪,需要加一行这个 `readdirSync` 才能在 vercel 部署后读到 md 文件
|
39
|
+
// 否则没法正常找到 mdx 文件
|
40
|
+
readdirSync(join(process.cwd(), 'docs'));
|
@@ -6,15 +6,20 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
7
7
|
|
8
8
|
import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
|
9
|
-
import { NS, normalizeLocale } from '@/locales/resources';
|
9
|
+
import { Locales, NS, normalizeLocale } from '@/locales/resources';
|
10
10
|
import { isDev } from '@/utils/env';
|
11
11
|
|
12
|
-
export const
|
12
|
+
export const getLocale = async (hl?: string): Promise<Locales> => {
|
13
|
+
if (hl) return normalizeLocale(hl) as Locales;
|
14
|
+
const cookieStore = cookies();
|
15
|
+
const defaultLang = cookieStore.get(LOBE_LOCALE_COOKIE);
|
16
|
+
return (defaultLang?.value || DEFAULT_LANG) as Locales;
|
17
|
+
};
|
18
|
+
|
19
|
+
export const translation = async (ns: NS = 'common', hl?: string) => {
|
13
20
|
let i18ns = {};
|
21
|
+
const lng = await getLocale(hl);
|
14
22
|
try {
|
15
|
-
const cookieStore = cookies();
|
16
|
-
const defaultLang = cookieStore.get(LOBE_LOCALE_COOKIE);
|
17
|
-
const lng = defaultLang?.value || DEFAULT_LANG;
|
18
23
|
let filepath = join(process.cwd(), `locales/${normalizeLocale(lng)}/${ns}.json`);
|
19
24
|
const isExist = existsSync(filepath);
|
20
25
|
if (!isExist)
|
@@ -29,6 +34,7 @@ export const translation = async (ns: NS = 'common') => {
|
|
29
34
|
}
|
30
35
|
|
31
36
|
return {
|
37
|
+
locale: lng,
|
32
38
|
t: (key: string, options: { [key: string]: string } = {}) => {
|
33
39
|
if (!i18ns) return key;
|
34
40
|
let content = get(i18ns, key);
|
@@ -78,7 +78,7 @@ getWolframCloudResults guidelines:
|
|
78
78
|
}
|
79
79
|
`;
|
80
80
|
|
81
|
-
exports[`ToolService >
|
81
|
+
exports[`ToolService > getToolManifest > support OpenAPI manifest > should get plugin manifest 1`] = `
|
82
82
|
{
|
83
83
|
"$schema": "../node_modules/@lobehub/chat-plugin-sdk/schema.json",
|
84
84
|
"api": [
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
UserModelProviderConfig,
|
10
10
|
} from '@/types/user/settings';
|
11
11
|
|
12
|
-
import { getProviderAuthPayload } from '
|
12
|
+
import { getProviderAuthPayload } from '../_auth';
|
13
13
|
|
14
14
|
// Mock data for different providers
|
15
15
|
const mockZhiPuAPIKey = 'zhipu-api-key';
|
@@ -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',
|