@lobehub/lobehub 2.0.0-next.47 → 2.0.0-next.49
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/.env.example +11 -0
- package/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/apps/desktop/src/main/controllers/AuthCtr.ts +27 -2
- package/apps/desktop/src/main/core/infrastructure/ProtocolManager.ts +9 -4
- package/changelog/v1.json +17 -0
- package/docs/development/database-schema.dbml +2 -0
- package/docs/self-hosting/environment-variables/basic.mdx +49 -3
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +49 -4
- package/locales/ar/chat.json +1 -0
- package/locales/ar/discover.json +45 -0
- package/locales/ar/marketAuth.json +42 -0
- package/locales/ar/setting.json +94 -1
- package/locales/ar/topic.json +1 -0
- package/locales/bg-BG/chat.json +1 -0
- package/locales/bg-BG/discover.json +45 -0
- package/locales/bg-BG/marketAuth.json +42 -0
- package/locales/bg-BG/setting.json +94 -1
- package/locales/bg-BG/topic.json +1 -0
- package/locales/de-DE/chat.json +1 -0
- package/locales/de-DE/discover.json +45 -0
- package/locales/de-DE/marketAuth.json +42 -0
- package/locales/de-DE/setting.json +94 -1
- package/locales/de-DE/topic.json +1 -0
- package/locales/en-US/chat.json +1 -0
- package/locales/en-US/discover.json +45 -0
- package/locales/en-US/marketAuth.json +42 -0
- package/locales/en-US/setting.json +94 -1
- package/locales/en-US/topic.json +1 -0
- package/locales/es-ES/chat.json +1 -0
- package/locales/es-ES/discover.json +45 -0
- package/locales/es-ES/marketAuth.json +42 -0
- package/locales/es-ES/setting.json +94 -1
- package/locales/es-ES/topic.json +1 -0
- package/locales/fa-IR/chat.json +1 -0
- package/locales/fa-IR/discover.json +45 -0
- package/locales/fa-IR/marketAuth.json +42 -0
- package/locales/fa-IR/setting.json +94 -1
- package/locales/fa-IR/topic.json +1 -0
- package/locales/fr-FR/chat.json +1 -0
- package/locales/fr-FR/discover.json +45 -0
- package/locales/fr-FR/marketAuth.json +42 -0
- package/locales/fr-FR/setting.json +94 -1
- package/locales/fr-FR/topic.json +1 -0
- package/locales/it-IT/chat.json +1 -0
- package/locales/it-IT/discover.json +45 -0
- package/locales/it-IT/marketAuth.json +42 -0
- package/locales/it-IT/setting.json +94 -1
- package/locales/it-IT/topic.json +1 -0
- package/locales/ja-JP/chat.json +1 -0
- package/locales/ja-JP/discover.json +45 -0
- package/locales/ja-JP/marketAuth.json +42 -0
- package/locales/ja-JP/setting.json +94 -1
- package/locales/ja-JP/topic.json +1 -0
- package/locales/ko-KR/chat.json +1 -0
- package/locales/ko-KR/discover.json +45 -0
- package/locales/ko-KR/marketAuth.json +42 -0
- package/locales/ko-KR/setting.json +94 -1
- package/locales/ko-KR/topic.json +1 -0
- package/locales/nl-NL/chat.json +1 -0
- package/locales/nl-NL/discover.json +45 -0
- package/locales/nl-NL/marketAuth.json +42 -0
- package/locales/nl-NL/setting.json +94 -1
- package/locales/nl-NL/topic.json +1 -0
- package/locales/pl-PL/chat.json +1 -0
- package/locales/pl-PL/discover.json +45 -0
- package/locales/pl-PL/marketAuth.json +42 -0
- package/locales/pl-PL/setting.json +94 -1
- package/locales/pl-PL/topic.json +1 -0
- package/locales/pt-BR/chat.json +1 -0
- package/locales/pt-BR/discover.json +45 -0
- package/locales/pt-BR/marketAuth.json +42 -0
- package/locales/pt-BR/setting.json +94 -1
- package/locales/pt-BR/topic.json +1 -0
- package/locales/ru-RU/chat.json +1 -0
- package/locales/ru-RU/discover.json +45 -0
- package/locales/ru-RU/marketAuth.json +42 -0
- package/locales/ru-RU/setting.json +94 -1
- package/locales/ru-RU/topic.json +1 -0
- package/locales/tr-TR/chat.json +1 -0
- package/locales/tr-TR/discover.json +45 -0
- package/locales/tr-TR/marketAuth.json +42 -0
- package/locales/tr-TR/setting.json +94 -1
- package/locales/tr-TR/topic.json +1 -0
- package/locales/vi-VN/chat.json +1 -0
- package/locales/vi-VN/discover.json +45 -0
- package/locales/vi-VN/marketAuth.json +42 -0
- package/locales/vi-VN/setting.json +94 -1
- package/locales/vi-VN/topic.json +1 -0
- package/locales/zh-CN/chat.json +1 -0
- package/locales/zh-CN/discover.json +45 -0
- package/locales/zh-CN/marketAuth.json +42 -0
- package/locales/zh-CN/setting.json +94 -1
- package/locales/zh-CN/topic.json +1 -0
- package/locales/zh-TW/chat.json +1 -0
- package/locales/zh-TW/discover.json +45 -0
- package/locales/zh-TW/marketAuth.json +42 -0
- package/locales/zh-TW/setting.json +94 -1
- package/locales/zh-TW/topic.json +1 -0
- package/package.json +34 -27
- package/packages/agent-runtime/src/core/InterventionChecker.ts +5 -16
- package/packages/agent-runtime/src/core/__tests__/InterventionChecker.test.ts +27 -80
- package/packages/agent-runtime/src/core/__tests__/runtime.test.ts +32 -13
- package/packages/agent-runtime/src/core/runtime.ts +7 -3
- package/packages/agent-runtime/src/types/event.ts +2 -1
- package/packages/agent-runtime/src/types/generalAgent.ts +1 -0
- package/packages/agent-runtime/src/types/instruction.ts +3 -2
- package/packages/agent-runtime/src/types/state.ts +3 -1
- package/packages/const/src/url.ts +1 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +4 -1
- package/packages/database/migrations/0044_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/0044_high_toxin.sql +1 -0
- package/packages/database/migrations/0045_add_tool_intervention.sql +1 -0
- package/packages/database/migrations/meta/0039_snapshot.json +1 -1
- package/packages/database/migrations/meta/0044_snapshot.json +7813 -0
- package/packages/database/migrations/meta/0045_snapshot.json +8431 -0
- package/packages/database/migrations/meta/_journal.json +14 -0
- package/packages/database/src/core/migrations.json +36 -7
- package/packages/database/src/models/message.ts +4 -1
- package/packages/database/src/models/session.ts +42 -1
- package/packages/database/src/schemas/agent.ts +1 -0
- package/packages/database/src/schemas/message.ts +5 -8
- package/packages/electron-client-ipc/src/events/index.ts +6 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +8 -0
- package/packages/fetch-sse/package.json +29 -0
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/fetchSSE.test.ts +4 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/__tests__/parseError.test.ts +7 -4
- package/packages/{utils/src/fetch → fetch-sse/src}/fetchSSE.ts +2 -2
- package/packages/{utils/src/fetch → fetch-sse/src}/parseError.ts +3 -3
- package/packages/model-bank/src/aiModels/mistral.ts +2 -1
- package/packages/model-runtime/src/core/contextBuilders/anthropic.test.ts +17 -11
- package/packages/model-runtime/src/core/contextBuilders/anthropic.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.test.ts +1 -1
- package/packages/model-runtime/src/core/contextBuilders/google.ts +3 -6
- package/packages/model-runtime/src/core/contextBuilders/openai.test.ts +4 -2
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.test.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +1 -1
- package/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts +3 -6
- package/packages/model-runtime/src/core/streams/openai/responsesStream.test.ts +1 -1
- package/packages/model-runtime/src/helpers/mergeChatMethodOptions.ts +2 -1
- package/packages/model-runtime/src/providers/aihubmix/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/anthropic/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/baichuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bedrock/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/providers/bfl/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/cloudflare/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/cohere/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/createImage.test.ts +2 -2
- package/packages/model-runtime/src/providers/google/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/google/generateObject.test.ts +1 -1
- package/packages/model-runtime/src/providers/google/index.test.ts +1 -4
- package/packages/model-runtime/src/providers/groq/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/hunyuan/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/minimax/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/mistral/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/moonshot/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/novita/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ollama/index.test.ts +43 -32
- package/packages/model-runtime/src/providers/ollama/index.ts +31 -7
- package/packages/model-runtime/src/providers/openrouter/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/perplexity/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ppio/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/qwen/createImage.test.ts +1 -1
- package/packages/model-runtime/src/providers/search1api/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/siliconcloud/createImage.ts +1 -1
- package/packages/model-runtime/src/providers/taichu/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/wenxin/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/zhipu/index.test.ts +1 -1
- package/packages/model-runtime/src/utils/errorResponse.test.ts +1 -1
- package/packages/obervability-otel/src/node.ts +15 -1
- package/packages/ssrf-safe-fetch/index.browser.ts +14 -0
- package/packages/ssrf-safe-fetch/package.json +8 -1
- package/packages/types/src/discover/assistants.ts +16 -0
- package/packages/types/src/index.ts +1 -0
- package/packages/types/src/message/common/base.ts +2 -2
- package/packages/types/src/message/common/tools.ts +16 -0
- package/packages/types/src/message/db/item.ts +15 -1
- package/packages/types/src/message/ui/chat.ts +7 -1
- package/packages/types/src/message/ui/params.ts +15 -1
- package/packages/types/src/meta.ts +4 -0
- package/packages/types/src/session/agentSession.ts +2 -0
- package/packages/types/src/tool/intervention.ts +2 -3
- package/packages/types/src/user/settings/tool.ts +15 -28
- package/packages/utils/src/imageToBase64.ts +17 -10
- package/packages/utils/src/index.ts +1 -1
- package/renovate.json +28 -11
- package/src/app/(backend)/market/agent/[[...segments]]/route.ts +153 -0
- package/src/app/(backend)/market/oidc/[[...segments]]/route.ts +207 -0
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +1 -0
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/PinList/index.tsx +4 -2
- package/src/app/[variants]/(main)/chat/components/topic/features/Topic/TopicListContent/TopicItem/TopicContent.tsx +1 -1
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/Item/Actions.tsx +1 -1
- package/src/app/[variants]/(main)/chat/settings/features/AgentInfoDescription/index.tsx +349 -0
- package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -2
- package/src/app/[variants]/(main)/chat/settings/features/PublishResultModal/index.tsx +64 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishButton.tsx +196 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/MarketPublishModal.tsx +358 -0
- package/src/app/[variants]/(main)/chat/settings/features/SmartAgentActionButton/index.tsx +75 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/AssistantDetailPage.tsx +11 -2
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +12 -1
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Nav.tsx +19 -12
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Related/index.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/TagList.tsx +14 -5
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/index.tsx +43 -29
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Versions/index.tsx +137 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/index.tsx +2 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Header.tsx +9 -10
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/AddAgent.tsx +105 -14
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/index.tsx +20 -6
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/StatusPage/index.tsx +113 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +3 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantPage.tsx +4 -1
- package/src/app/[variants]/(main)/discover/(list)/assistant/Client.tsx +6 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/index.tsx +7 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/List/Item.tsx +13 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/MarketSourceSwitch.tsx +64 -0
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +26 -7
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +10 -10
- package/src/app/[variants]/(main)/settings/_layout/type.ts +1 -1
- package/src/app/[variants]/(main)/settings/agent/index.tsx +11 -10
- package/src/app/[variants]/(main)/settings/common/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/page.tsx +13 -10
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/Item.tsx +35 -36
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/SearchResult.tsx +5 -5
- package/src/app/[variants]/(main)/settings/provider/_layout/Desktop/Container.tsx +10 -4
- package/src/app/market-auth-callback/layout.tsx +15 -0
- package/src/app/market-auth-callback/page.tsx +196 -0
- package/src/features/AgentSetting/AgentPrompt/TokenTag.tsx +3 -2
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/AgentSetting/store/action.ts +1 -1
- package/src/features/ChatInput/ActionBar/STT/browser.tsx +1 -1
- package/src/features/ChatInput/ActionBar/STT/openai.tsx +1 -1
- package/src/features/Conversation/Messages/Group/GroupChildren.tsx +20 -15
- package/src/features/Conversation/Messages/Group/GroupContext.tsx +15 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/BuiltinPluginTitle.tsx +2 -4
- package/src/features/Conversation/Messages/Group/Tool/Inspector/ToolTitle.tsx +3 -5
- package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +19 -7
- package/src/features/Conversation/Messages/Group/Tool/Render/Arguments/index.tsx +14 -12
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ApprovalActions.tsx +143 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/KeyValueEditor.tsx +213 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ModeSelector.tsx +134 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/index.tsx +99 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/RejectedResponse.tsx +45 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/index.tsx +23 -1
- package/src/features/Conversation/Messages/Group/Tool/index.tsx +42 -18
- package/src/features/Conversation/Messages/Group/Tools.tsx +3 -1
- package/src/features/Conversation/components/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/PluginTag/PluginStatus.tsx +1 -1
- package/src/hooks/useAgentOwnershipCheck.ts +143 -0
- package/src/instrumentation.node.ts +3 -2
- package/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx +364 -0
- package/src/layout/AuthProvider/MarketAuth/errors.ts +75 -0
- package/src/layout/AuthProvider/MarketAuth/index.ts +2 -0
- package/src/layout/AuthProvider/MarketAuth/oidc.ts +382 -0
- package/src/layout/AuthProvider/MarketAuth/types.ts +64 -0
- package/src/layout/AuthProvider/index.tsx +17 -4
- package/src/locales/default/chat.ts +22 -0
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/discover.ts +46 -0
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/marketAuth.ts +42 -0
- package/src/locales/default/setting.ts +94 -1
- package/src/locales/default/topic.ts +1 -0
- package/src/server/globalConfig/genServerAiProviderConfig.test.ts +5 -5
- package/src/server/globalConfig/genServerAiProviderConfig.ts +1 -1
- package/src/server/routers/lambda/market/index.ts +36 -14
- package/src/server/routers/lambda/message.ts +6 -3
- package/src/server/services/discover/index.test.ts +153 -11
- package/src/server/services/discover/index.ts +339 -40
- package/src/server/services/message/index.ts +13 -0
- package/src/server/sitemap.ts +49 -35
- package/src/services/_url.ts +15 -1
- package/src/services/chat/chat.test.ts +5 -5
- package/src/services/chat/clientModelRuntime.test.ts +1 -1
- package/src/services/chat/index.ts +6 -6
- package/src/services/chat/types.ts +1 -2
- package/src/services/discover.ts +16 -5
- package/src/services/electron/remoteServer.ts +8 -1
- package/src/services/marketApi.ts +124 -0
- package/src/services/message/index.ts +17 -2
- package/src/services/models.ts +2 -1
- package/src/store/chat/agents/GeneralChatAgent.ts +141 -24
- package/src/store/chat/agents/__tests__/GeneralChatAgent.test.ts +605 -0
- package/src/store/chat/agents/createAgentExecutors.ts +144 -26
- package/src/store/chat/agents/createToolEngine.ts +22 -0
- package/src/store/chat/slices/aiChat/actions/conversationControl.ts +106 -0
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +54 -26
- package/src/store/chat/slices/message/reducer.ts +2 -1
- package/src/store/chat/slices/plugin/actions/optimisticUpdate.ts +26 -1
- package/src/store/discover/slices/assistant/action.ts +20 -7
- package/src/store/user/slices/settings/action.ts +15 -0
- package/{packages/utils/src → src/utils}/electron/desktopRemoteRPCFetch.ts +1 -1
- package/{packages/utils/src → src/utils/server}/parseModels.ts +1 -2
- package/vitest.config.mts +2 -0
- package/packages/model-runtime/src/utils/imageToBase64.test.ts +0 -91
- package/packages/model-runtime/src/utils/imageToBase64.ts +0 -62
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/SubmitAgentModal.tsx +0 -98
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/index.tsx +0 -35
- package/src/app/[variants]/(main)/chat/settings/features/SubmitAgentButton/style.ts +0 -47
- /package/packages/{utils/src/fetch → fetch-sse/src}/headers.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/index.ts +0 -0
- /package/packages/{utils/src/fetch → fetch-sse/src}/request.ts +0 -0
- /package/{packages/utils/src → src/utils/server}/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{packages/utils/src → src/utils/server}/parseModels.test.ts +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ActionIcon, Button } from '@lobehub/ui';
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
import { LogIn, Share2, Upload } from 'lucide-react';
|
|
4
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { HEADER_ICON_SIZE } from '@/const/layoutTokens';
|
|
8
|
+
import { checkOwnership } from '@/hooks/useAgentOwnershipCheck';
|
|
9
|
+
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
|
|
10
|
+
import { resolveMarketAuthError } from '@/layout/AuthProvider/MarketAuth/errors';
|
|
11
|
+
import { useServerConfigStore } from '@/store/serverConfig';
|
|
12
|
+
|
|
13
|
+
import MarketPublishModal, { type MarketPublishAction } from './MarketPublishModal';
|
|
14
|
+
|
|
15
|
+
interface MarketPublishButtonProps {
|
|
16
|
+
action: MarketPublishAction;
|
|
17
|
+
marketIdentifier?: string;
|
|
18
|
+
modal?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const MarketPublishButton = memo<MarketPublishButtonProps>(
|
|
22
|
+
({ action, marketIdentifier, modal }) => {
|
|
23
|
+
const { t: tSetting } = useTranslation('setting');
|
|
24
|
+
const { t: tMarketAuth } = useTranslation('marketAuth');
|
|
25
|
+
const mobile = useServerConfigStore((s) => s.isMobile);
|
|
26
|
+
const [openState, setOpenState] = useState<{ submit: boolean; upload: boolean }>({
|
|
27
|
+
submit: false,
|
|
28
|
+
upload: false,
|
|
29
|
+
});
|
|
30
|
+
const { isAuthenticated, isLoading, session, signIn } = useMarketAuth();
|
|
31
|
+
|
|
32
|
+
const buttonCopy = useMemo(() => {
|
|
33
|
+
if (action === 'upload') {
|
|
34
|
+
return {
|
|
35
|
+
authenticated: {
|
|
36
|
+
icon: Upload,
|
|
37
|
+
text: tSetting('marketPublish.upload.button'),
|
|
38
|
+
title: tSetting('marketPublish.upload.tooltip'),
|
|
39
|
+
},
|
|
40
|
+
successMessage: tMarketAuth('messages.success.upload'),
|
|
41
|
+
unauthenticated: {
|
|
42
|
+
icon: LogIn,
|
|
43
|
+
text: tSetting('marketPublish.upload.button'),
|
|
44
|
+
title: tSetting('marketPublish.upload.tooltip'),
|
|
45
|
+
},
|
|
46
|
+
} as const;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const submitText = tSetting('submitAgentModal.tooltips');
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
authenticated: {
|
|
53
|
+
icon: Share2,
|
|
54
|
+
text: submitText,
|
|
55
|
+
title: submitText,
|
|
56
|
+
},
|
|
57
|
+
successMessage: tMarketAuth('messages.success.submit'),
|
|
58
|
+
unauthenticated: {
|
|
59
|
+
icon: LogIn,
|
|
60
|
+
text: tSetting('marketPublish.submit.button'),
|
|
61
|
+
title: tSetting('marketPublish.submit.tooltip'),
|
|
62
|
+
},
|
|
63
|
+
} as const;
|
|
64
|
+
}, [action, tMarketAuth, tSetting]);
|
|
65
|
+
|
|
66
|
+
const openModal = useCallback((target: MarketPublishAction) => {
|
|
67
|
+
setOpenState((prev) => ({ ...prev, [target]: true }));
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
const closeModal = useCallback((target: MarketPublishAction) => {
|
|
71
|
+
setOpenState((prev) => ({ ...prev, [target]: false }));
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
const handleButtonClick = useCallback(async () => {
|
|
75
|
+
console.log(
|
|
76
|
+
`[MarketPublishButton][${action}] Button clicked, isAuthenticated:`,
|
|
77
|
+
isAuthenticated,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (isAuthenticated) {
|
|
81
|
+
console.log(`[MarketPublishButton][${action}] User is authenticated, opening modal`);
|
|
82
|
+
openModal(action);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log(
|
|
87
|
+
`[MarketPublishButton][${action}] User not authenticated, starting authorization`,
|
|
88
|
+
);
|
|
89
|
+
try {
|
|
90
|
+
message.loading({ content: tMarketAuth('messages.loading'), key: 'market-auth' });
|
|
91
|
+
const accountId = await signIn();
|
|
92
|
+
message.success({ content: buttonCopy.successMessage, key: 'market-auth' });
|
|
93
|
+
|
|
94
|
+
let targetAction: MarketPublishAction = action;
|
|
95
|
+
|
|
96
|
+
if (marketIdentifier && accountId !== null) {
|
|
97
|
+
let accessToken = session?.accessToken;
|
|
98
|
+
|
|
99
|
+
if (!accessToken && typeof window !== 'undefined') {
|
|
100
|
+
const storedSession = sessionStorage.getItem('market_auth_session');
|
|
101
|
+
if (storedSession) {
|
|
102
|
+
try {
|
|
103
|
+
const parsed = JSON.parse(storedSession) as { accessToken?: string };
|
|
104
|
+
accessToken = parsed.accessToken;
|
|
105
|
+
} catch (parseError) {
|
|
106
|
+
console.error('[MarketPublishButton] Failed to parse stored session:', parseError);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (accessToken) {
|
|
112
|
+
try {
|
|
113
|
+
const isOwner = await checkOwnership({
|
|
114
|
+
accessToken,
|
|
115
|
+
accountId,
|
|
116
|
+
marketIdentifier,
|
|
117
|
+
skipCache: true,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
targetAction = isOwner ? 'upload' : 'submit';
|
|
121
|
+
} catch (ownershipError) {
|
|
122
|
+
console.error('[MarketPublishButton] Failed to confirm ownership:', ownershipError);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
openModal(targetAction);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error(`[MarketPublishButton][${action}] Authorization failed:`, error);
|
|
130
|
+
const normalizedError = resolveMarketAuthError(error);
|
|
131
|
+
message.error({
|
|
132
|
+
content: tMarketAuth(`errors.${normalizedError.code}`),
|
|
133
|
+
key: 'market-auth',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, [
|
|
137
|
+
action,
|
|
138
|
+
buttonCopy.successMessage,
|
|
139
|
+
isAuthenticated,
|
|
140
|
+
marketIdentifier,
|
|
141
|
+
openModal,
|
|
142
|
+
session?.accessToken,
|
|
143
|
+
signIn,
|
|
144
|
+
tMarketAuth,
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
const buttonProps = isAuthenticated ? buttonCopy.authenticated : buttonCopy.unauthenticated;
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
{modal ? (
|
|
152
|
+
<Button
|
|
153
|
+
block
|
|
154
|
+
disabled={isLoading}
|
|
155
|
+
icon={buttonProps.icon}
|
|
156
|
+
loading={isLoading}
|
|
157
|
+
onClick={handleButtonClick}
|
|
158
|
+
variant={'filled'}
|
|
159
|
+
>
|
|
160
|
+
{buttonProps.text}
|
|
161
|
+
</Button>
|
|
162
|
+
) : (
|
|
163
|
+
<ActionIcon
|
|
164
|
+
icon={buttonProps.icon}
|
|
165
|
+
loading={isLoading}
|
|
166
|
+
onClick={handleButtonClick}
|
|
167
|
+
size={HEADER_ICON_SIZE(mobile)}
|
|
168
|
+
title={buttonProps.title}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
{isAuthenticated && (
|
|
173
|
+
<>
|
|
174
|
+
<MarketPublishModal
|
|
175
|
+
action="submit"
|
|
176
|
+
onCancel={() => closeModal('submit')}
|
|
177
|
+
onSuccess={() => closeModal('submit')}
|
|
178
|
+
open={openState.submit}
|
|
179
|
+
/>
|
|
180
|
+
|
|
181
|
+
<MarketPublishModal
|
|
182
|
+
action="upload"
|
|
183
|
+
onCancel={() => closeModal('upload')}
|
|
184
|
+
onSuccess={() => closeModal('upload')}
|
|
185
|
+
open={openState.upload}
|
|
186
|
+
/>
|
|
187
|
+
</>
|
|
188
|
+
)}
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
MarketPublishButton.displayName = 'MarketPublishButton';
|
|
195
|
+
|
|
196
|
+
export default MarketPublishButton;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ModalForm, ProFormText } from '@ant-design/pro-components';
|
|
4
|
+
import { AgentItemDetail } from '@lobehub/market-sdk';
|
|
5
|
+
import { type ModalProps } from '@lobehub/ui';
|
|
6
|
+
import { Col, Row, Spin } from 'antd';
|
|
7
|
+
import isEqual from 'fast-deep-equal';
|
|
8
|
+
import { memo, useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
|
|
11
|
+
import { message } from '@/components/AntdStaticMethods';
|
|
12
|
+
import { useTokenCount } from '@/hooks/useTokenCount';
|
|
13
|
+
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
|
|
14
|
+
import { marketApiService } from '@/services/marketApi';
|
|
15
|
+
import { useAgentStore } from '@/store/agent';
|
|
16
|
+
import { agentChatConfigSelectors, agentSelectors } from '@/store/agent/selectors';
|
|
17
|
+
import { useGlobalStore } from '@/store/global';
|
|
18
|
+
import { globalGeneralSelectors } from '@/store/global/selectors';
|
|
19
|
+
import { useSessionStore } from '@/store/session';
|
|
20
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
21
|
+
|
|
22
|
+
import AgentInfoDescription from '../AgentInfoDescription';
|
|
23
|
+
import PublishResultModal from '../PublishResultModal';
|
|
24
|
+
|
|
25
|
+
export type MarketPublishAction = 'submit' | 'upload';
|
|
26
|
+
|
|
27
|
+
interface MarketPublishModalProps extends ModalProps {
|
|
28
|
+
action: MarketPublishAction;
|
|
29
|
+
onSuccess?: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface MarketPublishFormValues {
|
|
33
|
+
changelog: string;
|
|
34
|
+
identifier?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const MarketPublishModal = memo<MarketPublishModalProps>(
|
|
38
|
+
({ action, open, onCancel, onSuccess }) => {
|
|
39
|
+
const { t } = useTranslation('setting');
|
|
40
|
+
const isSubmit = action === 'submit';
|
|
41
|
+
const isUpload = action === 'upload';
|
|
42
|
+
|
|
43
|
+
const { session: marketSession, isAuthenticated } = useMarketAuth();
|
|
44
|
+
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
|
45
|
+
const updateSessionMeta = useSessionStore((s) => s.updateSessionMeta);
|
|
46
|
+
|
|
47
|
+
const systemRole = useAgentStore(agentSelectors.currentAgentSystemRole);
|
|
48
|
+
const language = useGlobalStore(globalGeneralSelectors.currentLanguage);
|
|
49
|
+
const agentConfig = useAgentStore(agentSelectors.currentAgentConfig);
|
|
50
|
+
const chatConfig = useAgentStore(agentChatConfigSelectors.currentChatConfig);
|
|
51
|
+
const plugins = useAgentStore(agentSelectors.currentAgentPlugins);
|
|
52
|
+
const ttsConfig = useAgentStore(agentSelectors.currentAgentTTS);
|
|
53
|
+
const model = useAgentStore(agentSelectors.currentAgentModel);
|
|
54
|
+
const provider = useAgentStore(agentSelectors.currentAgentModelProvider);
|
|
55
|
+
const knowledgeBases = useAgentStore(agentSelectors.currentAgentKnowledgeBases);
|
|
56
|
+
const files = useAgentStore(agentSelectors.currentAgentFiles);
|
|
57
|
+
|
|
58
|
+
const [remoteAgentData, setRemoteAgentData] = useState<
|
|
59
|
+
(AgentItemDetail & { description?: string; name?: string; title?: string }) | null
|
|
60
|
+
>(null);
|
|
61
|
+
const [loadingRemoteData, setLoadingRemoteData] = useState(false);
|
|
62
|
+
const [showResultModal, setShowResultModal] = useState(false);
|
|
63
|
+
const [publishResult, setPublishResult] = useState<{ identifier?: string }>({});
|
|
64
|
+
|
|
65
|
+
const messageKey = isSubmit ? 'submit' : 'upload-version';
|
|
66
|
+
const loadingMessage = isSubmit
|
|
67
|
+
? t('marketPublish.modal.loading.submit')
|
|
68
|
+
: t('marketPublish.modal.loading.upload');
|
|
69
|
+
const submitButtonText = t('marketPublish.modal.submitButton');
|
|
70
|
+
const modalTitle = isSubmit
|
|
71
|
+
? t('marketPublish.modal.title.submit')
|
|
72
|
+
: t('marketPublish.modal.title.upload');
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!isUpload) return;
|
|
76
|
+
const marketIdentifier = meta?.marketIdentifier;
|
|
77
|
+
const accessToken = marketSession?.accessToken;
|
|
78
|
+
if (!open || !isAuthenticated || !accessToken || !marketIdentifier) return;
|
|
79
|
+
|
|
80
|
+
let cancelled = false;
|
|
81
|
+
|
|
82
|
+
const run = async () => {
|
|
83
|
+
try {
|
|
84
|
+
setLoadingRemoteData(true);
|
|
85
|
+
marketApiService.setAccessToken(accessToken);
|
|
86
|
+
const data = await marketApiService.getAgentDetail(marketIdentifier);
|
|
87
|
+
if (!cancelled) {
|
|
88
|
+
console.log('data', data);
|
|
89
|
+
setRemoteAgentData(data);
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error('Failed to fetch remote agent data:', error);
|
|
93
|
+
if (!cancelled) {
|
|
94
|
+
message.error(t('marketPublish.modal.messages.fetchRemoteFailed'));
|
|
95
|
+
}
|
|
96
|
+
} finally {
|
|
97
|
+
if (!cancelled) {
|
|
98
|
+
setLoadingRemoteData(false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
void run();
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
cancelled = true;
|
|
107
|
+
};
|
|
108
|
+
}, [isAuthenticated, isUpload, marketSession?.accessToken, meta?.marketIdentifier, open]);
|
|
109
|
+
|
|
110
|
+
const tokenUsage = useTokenCount(systemRole);
|
|
111
|
+
|
|
112
|
+
const handleSubmit = useCallback(
|
|
113
|
+
async (values: MarketPublishFormValues) => {
|
|
114
|
+
if (!isAuthenticated || !marketSession?.accessToken) {
|
|
115
|
+
message.error(t('marketPublish.modal.messages.notAuthenticated'));
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const changelog = values.changelog?.trim();
|
|
120
|
+
if (!changelog) {
|
|
121
|
+
message.error({ content: t('marketPublish.modal.changelog.required'), key: messageKey });
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let identifier = meta?.marketIdentifier;
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
message.loading({ content: loadingMessage, key: messageKey });
|
|
129
|
+
marketApiService.setAccessToken(marketSession.accessToken);
|
|
130
|
+
|
|
131
|
+
if (isSubmit) {
|
|
132
|
+
identifier = values.identifier?.trim();
|
|
133
|
+
if (!identifier) {
|
|
134
|
+
message.error({ content: t('marketPublish.modal.identifier.required'), key: messageKey });
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await marketApiService.getAgentDetail(identifier);
|
|
140
|
+
} catch {
|
|
141
|
+
const createPayload: Record<string, unknown> = {
|
|
142
|
+
identifier,
|
|
143
|
+
name: meta?.title || '',
|
|
144
|
+
};
|
|
145
|
+
await marketApiService.createAgent(createPayload as any);
|
|
146
|
+
}
|
|
147
|
+
} else if (!identifier) {
|
|
148
|
+
message.error({ content: t('marketPublish.modal.messages.missingIdentifier'), key: messageKey });
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const versionPayload = {
|
|
153
|
+
avatar: meta?.avatar,
|
|
154
|
+
changelog,
|
|
155
|
+
config: {
|
|
156
|
+
chatConfig: {
|
|
157
|
+
displayMode: chatConfig?.displayMode,
|
|
158
|
+
enableHistoryCount: chatConfig?.enableHistoryCount,
|
|
159
|
+
historyCount: chatConfig?.historyCount,
|
|
160
|
+
maxTokens: agentConfig?.params?.max_tokens,
|
|
161
|
+
searchMode: chatConfig?.searchMode,
|
|
162
|
+
temperature: agentConfig?.params?.temperature,
|
|
163
|
+
topP: agentConfig?.params?.top_p,
|
|
164
|
+
},
|
|
165
|
+
description: meta?.description,
|
|
166
|
+
locale: language,
|
|
167
|
+
model: {
|
|
168
|
+
model,
|
|
169
|
+
parameters: agentConfig?.params,
|
|
170
|
+
provider,
|
|
171
|
+
},
|
|
172
|
+
plugins:
|
|
173
|
+
plugins?.map((plugin) => ({
|
|
174
|
+
enabled: true,
|
|
175
|
+
identifier: plugin,
|
|
176
|
+
settings: {},
|
|
177
|
+
})) || [],
|
|
178
|
+
systemRole: systemRole,
|
|
179
|
+
},
|
|
180
|
+
description: meta?.description || '',
|
|
181
|
+
identifier: identifier,
|
|
182
|
+
name: meta?.title || '',
|
|
183
|
+
tags: meta?.tags,
|
|
184
|
+
tokenUsage: tokenUsage,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
await marketApiService.createAgentVersion(versionPayload);
|
|
189
|
+
} catch (versionError) {
|
|
190
|
+
const errorMessage = versionError instanceof Error ? versionError.message : '未知错误';
|
|
191
|
+
message.error({
|
|
192
|
+
content: t('marketPublish.modal.messages.createVersionFailed', { message: errorMessage }),
|
|
193
|
+
key: messageKey,
|
|
194
|
+
});
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (isSubmit) {
|
|
199
|
+
updateSessionMeta({ marketIdentifier: identifier });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
setPublishResult({ identifier });
|
|
203
|
+
setShowResultModal(true);
|
|
204
|
+
|
|
205
|
+
message.destroy(messageKey);
|
|
206
|
+
onSuccess?.();
|
|
207
|
+
return true;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error('Market publish failed:', error);
|
|
210
|
+
const errorMessage = error instanceof Error ? error.message : '发布失败';
|
|
211
|
+
message.error({ content: t('marketPublish.modal.messages.publishFailed', { message: errorMessage }), key: messageKey });
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
[
|
|
216
|
+
agentConfig?.params,
|
|
217
|
+
chatConfig?.displayMode,
|
|
218
|
+
chatConfig?.enableHistoryCount,
|
|
219
|
+
chatConfig?.historyCount,
|
|
220
|
+
chatConfig?.searchMode,
|
|
221
|
+
isAuthenticated,
|
|
222
|
+
isSubmit,
|
|
223
|
+
language,
|
|
224
|
+
meta?.avatar,
|
|
225
|
+
meta?.description,
|
|
226
|
+
meta?.marketIdentifier,
|
|
227
|
+
meta?.tags,
|
|
228
|
+
meta?.title,
|
|
229
|
+
marketSession?.accessToken,
|
|
230
|
+
messageKey,
|
|
231
|
+
loadingMessage,
|
|
232
|
+
model,
|
|
233
|
+
onSuccess,
|
|
234
|
+
plugins,
|
|
235
|
+
provider,
|
|
236
|
+
systemRole,
|
|
237
|
+
tokenUsage,
|
|
238
|
+
updateSessionMeta,
|
|
239
|
+
],
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<>
|
|
244
|
+
<ModalForm<MarketPublishFormValues>
|
|
245
|
+
modalProps={{
|
|
246
|
+
bodyStyle: { height: '70vh', overflow: 'auto' },
|
|
247
|
+
destroyOnClose: true,
|
|
248
|
+
onCancel,
|
|
249
|
+
style: { minWidth: 750 },
|
|
250
|
+
}}
|
|
251
|
+
onFinish={handleSubmit}
|
|
252
|
+
open={open}
|
|
253
|
+
submitter={{
|
|
254
|
+
resetButtonProps: {
|
|
255
|
+
style: { display: 'none' },
|
|
256
|
+
},
|
|
257
|
+
submitButtonProps: {
|
|
258
|
+
children: submitButtonText,
|
|
259
|
+
},
|
|
260
|
+
}}
|
|
261
|
+
title={modalTitle}
|
|
262
|
+
width="80vw"
|
|
263
|
+
>
|
|
264
|
+
{isSubmit && (
|
|
265
|
+
<ProFormText
|
|
266
|
+
extra={t('marketPublish.modal.identifier.extra')}
|
|
267
|
+
label={t('marketPublish.modal.identifier.label')}
|
|
268
|
+
name="identifier"
|
|
269
|
+
placeholder={t('marketPublish.modal.identifier.placeholder')}
|
|
270
|
+
rules={[
|
|
271
|
+
{ message: t('marketPublish.modal.identifier.required'), required: true },
|
|
272
|
+
{ message: t('marketPublish.modal.identifier.patternError'), pattern: /^[\da-z-]+$/ },
|
|
273
|
+
{ max: 50, message: t('marketPublish.modal.identifier.lengthError'), min: 3 },
|
|
274
|
+
]}
|
|
275
|
+
/>
|
|
276
|
+
)}
|
|
277
|
+
|
|
278
|
+
<ProFormText
|
|
279
|
+
extra={t('marketPublish.modal.changelog.extra')}
|
|
280
|
+
label={t('marketPublish.modal.changelog.label')}
|
|
281
|
+
name="changelog"
|
|
282
|
+
placeholder={t('marketPublish.modal.changelog.placeholder')}
|
|
283
|
+
rules={[
|
|
284
|
+
{ message: t('marketPublish.modal.changelog.required'), required: true },
|
|
285
|
+
{ max: 500, message: t('marketPublish.modal.changelog.maxLengthError') },
|
|
286
|
+
]}
|
|
287
|
+
/>
|
|
288
|
+
|
|
289
|
+
{isUpload ? (
|
|
290
|
+
<Row gutter={24}>
|
|
291
|
+
<Col span={12}>
|
|
292
|
+
<div style={{ border: '1px solid #d9d9d9', borderRadius: '6px', padding: '16px' }}>
|
|
293
|
+
<h3 style={{ marginBottom: '16px', textAlign: 'center' }}>
|
|
294
|
+
{t('marketPublish.modal.comparison.remote')}
|
|
295
|
+
</h3>
|
|
296
|
+
{loadingRemoteData ? (
|
|
297
|
+
<div style={{ padding: '40px', textAlign: 'center' }}>
|
|
298
|
+
<Spin size="large" />
|
|
299
|
+
<div style={{ marginTop: '16px' }}>
|
|
300
|
+
{t('marketPublish.modal.loading.fetchingRemote')}
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
) : (
|
|
304
|
+
<AgentInfoDescription isRemote={true} meta={remoteAgentData || undefined} />
|
|
305
|
+
)}
|
|
306
|
+
</div>
|
|
307
|
+
</Col>
|
|
308
|
+
<Col span={12}>
|
|
309
|
+
<div style={{ border: '1px solid #d9d9d9', borderRadius: '6px', padding: '16px' }}>
|
|
310
|
+
<h3 style={{ marginBottom: '16px', textAlign: 'center' }}>
|
|
311
|
+
{t('marketPublish.modal.comparison.local')}
|
|
312
|
+
</h3>
|
|
313
|
+
<AgentInfoDescription
|
|
314
|
+
agentConfig={agentConfig}
|
|
315
|
+
chatConfig={chatConfig}
|
|
316
|
+
files={files}
|
|
317
|
+
knowledgeBases={knowledgeBases}
|
|
318
|
+
meta={meta}
|
|
319
|
+
model={model}
|
|
320
|
+
plugins={plugins}
|
|
321
|
+
provider={provider}
|
|
322
|
+
systemRole={systemRole}
|
|
323
|
+
ttsConfig={ttsConfig}
|
|
324
|
+
/>
|
|
325
|
+
</div>
|
|
326
|
+
</Col>
|
|
327
|
+
</Row>
|
|
328
|
+
) : (
|
|
329
|
+
<div style={{ marginTop: 24 }}>
|
|
330
|
+
<AgentInfoDescription
|
|
331
|
+
agentConfig={agentConfig}
|
|
332
|
+
chatConfig={chatConfig}
|
|
333
|
+
files={files}
|
|
334
|
+
knowledgeBases={knowledgeBases}
|
|
335
|
+
meta={meta}
|
|
336
|
+
model={model}
|
|
337
|
+
plugins={plugins}
|
|
338
|
+
provider={provider}
|
|
339
|
+
systemRole={systemRole}
|
|
340
|
+
ttsConfig={ttsConfig}
|
|
341
|
+
/>
|
|
342
|
+
</div>
|
|
343
|
+
)}
|
|
344
|
+
</ModalForm>
|
|
345
|
+
|
|
346
|
+
<PublishResultModal
|
|
347
|
+
identifier={publishResult.identifier}
|
|
348
|
+
onCancel={() => setShowResultModal(false)}
|
|
349
|
+
open={showResultModal}
|
|
350
|
+
/>
|
|
351
|
+
</>
|
|
352
|
+
);
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
MarketPublishModal.displayName = 'MarketPublishModal';
|
|
357
|
+
|
|
358
|
+
export default MarketPublishModal;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Button } from '@lobehub/ui';
|
|
2
|
+
import isEqual from 'fast-deep-equal';
|
|
3
|
+
import { Loader2 } from 'lucide-react';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { useAgentOwnershipCheck } from '@/hooks/useAgentOwnershipCheck';
|
|
8
|
+
import { useSessionStore } from '@/store/session';
|
|
9
|
+
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
10
|
+
|
|
11
|
+
import MarketPublishButton from './MarketPublishButton';
|
|
12
|
+
|
|
13
|
+
interface SmartAgentActionButtonProps {
|
|
14
|
+
modal?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 智能Agent操作按钮组件
|
|
19
|
+
* 根据Agent的所有权自动决定显示"提交新Agent"还是"上传新版本"按钮
|
|
20
|
+
*/
|
|
21
|
+
const SmartAgentActionButton = memo<SmartAgentActionButtonProps>(({ modal }) => {
|
|
22
|
+
const { t } = useTranslation('setting');
|
|
23
|
+
const meta = useSessionStore(sessionMetaSelectors.currentAgentMeta, isEqual);
|
|
24
|
+
const { isOwnAgent } = useAgentOwnershipCheck(meta?.marketIdentifier);
|
|
25
|
+
|
|
26
|
+
const buttonType = useMemo(() => {
|
|
27
|
+
if (!meta?.marketIdentifier) {
|
|
28
|
+
return 'submit';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isOwnAgent === null) {
|
|
32
|
+
return 'loading';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isOwnAgent === true) {
|
|
36
|
+
return 'upload';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return 'submit';
|
|
40
|
+
}, [meta?.marketIdentifier, isOwnAgent]);
|
|
41
|
+
|
|
42
|
+
switch (buttonType) {
|
|
43
|
+
case 'upload': {
|
|
44
|
+
return (
|
|
45
|
+
<MarketPublishButton
|
|
46
|
+
action="upload"
|
|
47
|
+
marketIdentifier={meta?.marketIdentifier}
|
|
48
|
+
modal={modal}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case 'submit': {
|
|
54
|
+
return (
|
|
55
|
+
<MarketPublishButton
|
|
56
|
+
action="submit"
|
|
57
|
+
marketIdentifier={meta?.marketIdentifier}
|
|
58
|
+
modal={modal}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
default: {
|
|
64
|
+
return (
|
|
65
|
+
<Button block={Boolean(modal)} disabled icon={Loader2} loading variant={'filled'}>
|
|
66
|
+
{t('checkingPermissions')}
|
|
67
|
+
</Button>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
SmartAgentActionButton.displayName = 'SmartAgentActionButton';
|
|
74
|
+
|
|
75
|
+
export default SmartAgentActionButton;
|
|
@@ -5,8 +5,9 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
5
5
|
import { useParams } from 'react-router-dom';
|
|
6
6
|
|
|
7
7
|
import { withSuspense } from '@/components/withSuspense';
|
|
8
|
+
import { useQuery } from '@/hooks/useQuery';
|
|
8
9
|
import { useDiscoverStore } from '@/store/discover';
|
|
9
|
-
import { DiscoverTab } from '@/types/discover';
|
|
10
|
+
import { AssistantMarketSource, DiscoverTab } from '@/types/discover';
|
|
10
11
|
|
|
11
12
|
import NotFound from '../components/NotFound';
|
|
12
13
|
import Breadcrumb from '../features/Breadcrumb';
|
|
@@ -14,6 +15,7 @@ import { TocProvider } from '../features/Toc/useToc';
|
|
|
14
15
|
import { DetailProvider } from './[...slugs]/features/DetailProvider';
|
|
15
16
|
import Details from './[...slugs]/features/Details';
|
|
16
17
|
import Header from './[...slugs]/features/Header';
|
|
18
|
+
import StatusPage from './[...slugs]/features/StatusPage';
|
|
17
19
|
import Loading from './[...slugs]/loading';
|
|
18
20
|
|
|
19
21
|
interface AssistantDetailPageProps {
|
|
@@ -24,13 +26,20 @@ const AssistantDetailPage = memo<AssistantDetailPageProps>(({ mobile }) => {
|
|
|
24
26
|
const params = useParams();
|
|
25
27
|
const slugs = params['*']?.split('/') || [];
|
|
26
28
|
const identifier = decodeURIComponent(slugs.join('/'));
|
|
29
|
+
const { version, source } = useQuery() as { source?: AssistantMarketSource; version?: string };
|
|
27
30
|
|
|
28
31
|
const useAssistantDetail = useDiscoverStore((s) => s.useAssistantDetail);
|
|
29
|
-
const { data, isLoading } = useAssistantDetail({ identifier });
|
|
32
|
+
const { data, isLoading } = useAssistantDetail({ identifier, source, version });
|
|
30
33
|
|
|
31
34
|
if (isLoading) return <Loading />;
|
|
32
35
|
if (!data) return <NotFound />;
|
|
33
36
|
|
|
37
|
+
// 检查助手状态
|
|
38
|
+
const status = (data as any)?.status;
|
|
39
|
+
if (status === 'unpublished' || status === 'archived' || status === 'deprecated') {
|
|
40
|
+
return <StatusPage status={status} />;
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
return (
|
|
35
44
|
<TocProvider>
|
|
36
45
|
<DetailProvider config={data}>
|