@lobehub/chat 1.98.2 → 1.99.1
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/.cursor/rules/backend-architecture.mdc +93 -17
- package/.cursor/rules/cursor-ux.mdc +45 -35
- package/.cursor/rules/project-introduce.mdc +72 -6
- package/.cursor/rules/rules-attach.mdc +16 -7
- package/.eslintrc.js +10 -0
- package/CHANGELOG.md +44 -0
- package/apps/desktop/README.md +7 -0
- package/apps/desktop/electron-builder.js +5 -0
- package/apps/desktop/package.json +2 -1
- package/apps/desktop/src/main/appBrowsers.ts +1 -1
- package/apps/desktop/src/main/const/dir.ts +3 -0
- package/apps/desktop/src/main/controllers/UploadFileCtr.ts +13 -8
- package/apps/desktop/src/main/core/App.ts +8 -0
- package/apps/desktop/src/main/core/BrowserManager.ts +5 -2
- package/apps/desktop/src/main/core/StaticFileServerManager.ts +221 -0
- package/apps/desktop/src/main/services/fileSrv.ts +231 -44
- package/apps/desktop/src/main/utils/next-electron-rsc.ts +36 -5
- package/changelog/v1.json +14 -0
- package/docs/development/database-schema.dbml +70 -0
- package/locales/ar/common.json +2 -0
- package/locales/ar/components.json +35 -0
- package/locales/ar/error.json +2 -0
- package/locales/ar/image.json +100 -0
- package/locales/ar/metadata.json +4 -0
- package/locales/ar/modelProvider.json +1 -0
- package/locales/ar/models.json +15 -0
- package/locales/ar/plugin.json +22 -0
- package/locales/ar/providers.json +3 -0
- package/locales/ar/setting.json +5 -0
- package/locales/bg-BG/common.json +2 -0
- package/locales/bg-BG/components.json +35 -0
- package/locales/bg-BG/error.json +2 -0
- package/locales/bg-BG/image.json +100 -0
- package/locales/bg-BG/metadata.json +4 -0
- package/locales/bg-BG/modelProvider.json +1 -0
- package/locales/bg-BG/models.json +15 -0
- package/locales/bg-BG/plugin.json +22 -0
- package/locales/bg-BG/providers.json +3 -0
- package/locales/bg-BG/setting.json +5 -0
- package/locales/de-DE/common.json +2 -0
- package/locales/de-DE/components.json +35 -0
- package/locales/de-DE/error.json +2 -0
- package/locales/de-DE/image.json +100 -0
- package/locales/de-DE/metadata.json +4 -0
- package/locales/de-DE/modelProvider.json +1 -0
- package/locales/de-DE/models.json +15 -0
- package/locales/de-DE/plugin.json +22 -0
- package/locales/de-DE/providers.json +3 -0
- package/locales/de-DE/setting.json +5 -0
- package/locales/en-US/common.json +2 -0
- package/locales/en-US/components.json +35 -0
- package/locales/en-US/error.json +2 -0
- package/locales/en-US/image.json +100 -0
- package/locales/en-US/metadata.json +4 -0
- package/locales/en-US/modelProvider.json +1 -0
- package/locales/en-US/models.json +15 -0
- package/locales/en-US/plugin.json +22 -0
- package/locales/en-US/providers.json +3 -0
- package/locales/en-US/setting.json +5 -0
- package/locales/es-ES/common.json +2 -0
- package/locales/es-ES/components.json +35 -0
- package/locales/es-ES/error.json +2 -0
- package/locales/es-ES/image.json +100 -0
- package/locales/es-ES/metadata.json +4 -0
- package/locales/es-ES/modelProvider.json +1 -0
- package/locales/es-ES/models.json +15 -0
- package/locales/es-ES/plugin.json +22 -0
- package/locales/es-ES/providers.json +3 -0
- package/locales/es-ES/setting.json +5 -0
- package/locales/fa-IR/common.json +2 -0
- package/locales/fa-IR/components.json +35 -0
- package/locales/fa-IR/error.json +2 -0
- package/locales/fa-IR/image.json +100 -0
- package/locales/fa-IR/metadata.json +4 -0
- package/locales/fa-IR/modelProvider.json +1 -0
- package/locales/fa-IR/models.json +15 -0
- package/locales/fa-IR/plugin.json +22 -0
- package/locales/fa-IR/providers.json +3 -0
- package/locales/fa-IR/setting.json +5 -0
- package/locales/fr-FR/common.json +2 -0
- package/locales/fr-FR/components.json +35 -0
- package/locales/fr-FR/error.json +2 -0
- package/locales/fr-FR/image.json +100 -0
- package/locales/fr-FR/metadata.json +4 -0
- package/locales/fr-FR/modelProvider.json +1 -0
- package/locales/fr-FR/models.json +15 -0
- package/locales/fr-FR/plugin.json +22 -0
- package/locales/fr-FR/providers.json +3 -0
- package/locales/fr-FR/setting.json +5 -0
- package/locales/it-IT/common.json +2 -0
- package/locales/it-IT/components.json +35 -0
- package/locales/it-IT/error.json +2 -0
- package/locales/it-IT/image.json +100 -0
- package/locales/it-IT/metadata.json +4 -0
- package/locales/it-IT/modelProvider.json +1 -0
- package/locales/it-IT/models.json +15 -0
- package/locales/it-IT/plugin.json +22 -0
- package/locales/it-IT/providers.json +3 -0
- package/locales/it-IT/setting.json +5 -0
- package/locales/ja-JP/common.json +2 -0
- package/locales/ja-JP/components.json +35 -0
- package/locales/ja-JP/error.json +2 -0
- package/locales/ja-JP/image.json +100 -0
- package/locales/ja-JP/metadata.json +4 -0
- package/locales/ja-JP/modelProvider.json +1 -0
- package/locales/ja-JP/models.json +15 -0
- package/locales/ja-JP/plugin.json +22 -0
- package/locales/ja-JP/providers.json +3 -0
- package/locales/ja-JP/setting.json +5 -0
- package/locales/ko-KR/common.json +2 -0
- package/locales/ko-KR/components.json +35 -0
- package/locales/ko-KR/error.json +2 -0
- package/locales/ko-KR/image.json +100 -0
- package/locales/ko-KR/metadata.json +4 -0
- package/locales/ko-KR/modelProvider.json +1 -0
- package/locales/ko-KR/models.json +15 -0
- package/locales/ko-KR/plugin.json +22 -0
- package/locales/ko-KR/providers.json +3 -0
- package/locales/ko-KR/setting.json +5 -0
- package/locales/nl-NL/common.json +2 -0
- package/locales/nl-NL/components.json +35 -0
- package/locales/nl-NL/error.json +2 -0
- package/locales/nl-NL/image.json +100 -0
- package/locales/nl-NL/metadata.json +4 -0
- package/locales/nl-NL/modelProvider.json +1 -0
- package/locales/nl-NL/models.json +15 -0
- package/locales/nl-NL/plugin.json +22 -0
- package/locales/nl-NL/providers.json +3 -0
- package/locales/nl-NL/setting.json +5 -0
- package/locales/pl-PL/common.json +2 -0
- package/locales/pl-PL/components.json +35 -0
- package/locales/pl-PL/error.json +2 -0
- package/locales/pl-PL/image.json +100 -0
- package/locales/pl-PL/metadata.json +4 -0
- package/locales/pl-PL/modelProvider.json +1 -0
- package/locales/pl-PL/models.json +15 -0
- package/locales/pl-PL/plugin.json +22 -0
- package/locales/pl-PL/providers.json +3 -0
- package/locales/pl-PL/setting.json +5 -0
- package/locales/pt-BR/common.json +2 -0
- package/locales/pt-BR/components.json +35 -0
- package/locales/pt-BR/error.json +2 -0
- package/locales/pt-BR/image.json +100 -0
- package/locales/pt-BR/metadata.json +4 -0
- package/locales/pt-BR/modelProvider.json +1 -0
- package/locales/pt-BR/models.json +15 -0
- package/locales/pt-BR/plugin.json +22 -0
- package/locales/pt-BR/providers.json +3 -0
- package/locales/pt-BR/setting.json +5 -0
- package/locales/ru-RU/common.json +2 -0
- package/locales/ru-RU/components.json +35 -0
- package/locales/ru-RU/error.json +2 -0
- package/locales/ru-RU/image.json +100 -0
- package/locales/ru-RU/metadata.json +4 -0
- package/locales/ru-RU/modelProvider.json +1 -0
- package/locales/ru-RU/models.json +15 -0
- package/locales/ru-RU/plugin.json +22 -0
- package/locales/ru-RU/providers.json +3 -0
- package/locales/ru-RU/setting.json +5 -0
- package/locales/tr-TR/common.json +2 -0
- package/locales/tr-TR/components.json +35 -0
- package/locales/tr-TR/error.json +2 -0
- package/locales/tr-TR/image.json +100 -0
- package/locales/tr-TR/metadata.json +4 -0
- package/locales/tr-TR/modelProvider.json +1 -0
- package/locales/tr-TR/models.json +15 -0
- package/locales/tr-TR/plugin.json +22 -0
- package/locales/tr-TR/providers.json +3 -0
- package/locales/tr-TR/setting.json +5 -0
- package/locales/vi-VN/common.json +2 -0
- package/locales/vi-VN/components.json +35 -0
- package/locales/vi-VN/error.json +2 -0
- package/locales/vi-VN/image.json +100 -0
- package/locales/vi-VN/metadata.json +4 -0
- package/locales/vi-VN/modelProvider.json +1 -0
- package/locales/vi-VN/models.json +15 -0
- package/locales/vi-VN/plugin.json +22 -0
- package/locales/vi-VN/providers.json +3 -0
- package/locales/vi-VN/setting.json +5 -0
- package/locales/zh-CN/common.json +2 -0
- package/locales/zh-CN/components.json +35 -0
- package/locales/zh-CN/error.json +2 -0
- package/locales/zh-CN/image.json +100 -0
- package/locales/zh-CN/metadata.json +4 -0
- package/locales/zh-CN/modelProvider.json +1 -0
- package/locales/zh-CN/models.json +15 -0
- package/locales/zh-CN/plugin.json +22 -0
- package/locales/zh-CN/providers.json +3 -0
- package/locales/zh-CN/setting.json +5 -0
- package/locales/zh-TW/common.json +2 -0
- package/locales/zh-TW/components.json +35 -0
- package/locales/zh-TW/error.json +2 -0
- package/locales/zh-TW/image.json +100 -0
- package/locales/zh-TW/metadata.json +4 -0
- package/locales/zh-TW/modelProvider.json +1 -0
- package/locales/zh-TW/models.json +15 -0
- package/locales/zh-TW/plugin.json +22 -0
- package/locales/zh-TW/providers.json +3 -0
- package/locales/zh-TW/setting.json +5 -0
- package/package.json +11 -4
- package/packages/electron-server-ipc/src/events/file.ts +3 -1
- package/packages/electron-server-ipc/src/types/file.ts +15 -0
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/TopActions.tsx +11 -1
- package/src/app/[variants]/(main)/image/@menu/components/AspectRatioSelect/index.tsx +73 -0
- package/src/app/[variants]/(main)/image/@menu/components/SeedNumberInput/index.tsx +39 -0
- package/src/app/[variants]/(main)/image/@menu/components/SizeSelect/index.tsx +89 -0
- package/src/app/[variants]/(main)/image/@menu/default.tsx +11 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/AspectRatioSelect.tsx +24 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/DimensionControlGroup.tsx +107 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageNum.tsx +290 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageUpload.tsx +504 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageUrl.tsx +18 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ImageUrlsUpload.tsx +19 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect.tsx +155 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/ImageManageModal.tsx +415 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/MultiImagesUpload/index.tsx +732 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/SeedNumberInput.tsx +24 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/SizeSelect.tsx +17 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/SizeSliderInput.tsx +15 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/StepsSliderInput.tsx +11 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/constants.ts +1 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/index.tsx +93 -0
- package/src/app/[variants]/(main)/image/@topic/default.tsx +17 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/NewTopicButton.tsx +64 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/SkeletonList.tsx +34 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicItem.tsx +136 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicItemContainer.tsx +91 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicList.tsx +57 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicUrlSync.tsx +37 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/index.tsx +19 -0
- package/src/app/[variants]/(main)/image/NotSupportClient.tsx +153 -0
- package/src/app/[variants]/(main)/image/_layout/Desktop/Container.tsx +35 -0
- package/src/app/[variants]/(main)/image/_layout/Desktop/RegisterHotkeys.tsx +10 -0
- package/src/app/[variants]/(main)/image/_layout/Desktop/index.tsx +30 -0
- package/src/app/[variants]/(main)/image/_layout/Mobile/index.tsx +14 -0
- package/src/app/[variants]/(main)/image/_layout/type.ts +7 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/BatchItem.tsx +196 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/ActionButtons.tsx +60 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/ElapsedTime.tsx +90 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/ErrorState.tsx +65 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/LoadingState.tsx +44 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/SuccessState.tsx +49 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/index.tsx +154 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/styles.ts +51 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/types.ts +39 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/GenerationItem/utils.ts +11 -0
- package/src/app/[variants]/(main)/image/features/GenerationFeed/index.tsx +97 -0
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/Content.tsx +48 -0
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/EmptyState.tsx +37 -0
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/SkeletonList.tsx +50 -0
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/index.tsx +23 -0
- package/src/app/[variants]/(main)/image/features/PromptInput/Title.tsx +38 -0
- package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +114 -0
- package/src/app/[variants]/(main)/image/layout.tsx +19 -0
- package/src/app/[variants]/(main)/image/loading.tsx +3 -0
- package/src/app/[variants]/(main)/image/page.tsx +47 -0
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +2 -1
- package/src/chains/summaryGenerationTitle.ts +25 -0
- package/src/components/ImageItem/index.tsx +9 -6
- package/src/{features/Conversation/Error → components/InvalidAPIKey}/APIKeyForm/Bedrock.tsx +3 -4
- package/src/{features/Conversation/Error → components/InvalidAPIKey}/APIKeyForm/ProviderApiKeyForm.tsx +5 -4
- package/src/components/InvalidAPIKey/APIKeyForm/index.tsx +108 -0
- package/src/{features/Conversation/Error → components/InvalidAPIKey}/APIKeyForm/useApiKey.ts +2 -1
- package/src/components/InvalidAPIKey/index.tsx +30 -0
- package/src/components/KeyValueEditor/index.tsx +203 -0
- package/src/components/KeyValueEditor/utils.ts +42 -0
- package/src/config/aiModels/fal.ts +52 -0
- package/src/config/aiModels/index.ts +3 -0
- package/src/config/aiModels/openai.ts +20 -6
- package/src/config/llm.ts +6 -0
- package/src/config/modelProviders/fal.ts +21 -0
- package/src/config/modelProviders/index.ts +3 -0
- package/src/config/paramsSchemas/fal/flux-kontext-dev.ts +8 -0
- package/src/config/paramsSchemas/fal/flux-pro-kontext.ts +11 -0
- package/src/config/paramsSchemas/fal/flux-schnell.ts +9 -0
- package/src/config/paramsSchemas/fal/imagen4.ts +10 -0
- package/src/config/paramsSchemas/openai/gpt-image-1.ts +10 -0
- package/src/const/hotkeys.ts +2 -2
- package/src/const/image.ts +6 -0
- package/src/const/settings/systemAgent.ts +1 -0
- package/src/database/client/migrations.json +27 -0
- package/src/database/migrations/0026_add_autovacuum_tuning.sql +2 -0
- package/src/database/migrations/0027_ai_image.sql +47 -0
- package/src/database/migrations/meta/0027_snapshot.json +6003 -0
- package/src/database/migrations/meta/_journal.json +7 -0
- package/src/database/models/__tests__/asyncTask.test.ts +7 -5
- package/src/database/models/__tests__/file.test.ts +287 -0
- package/src/database/models/__tests__/generation.test.ts +786 -0
- package/src/database/models/__tests__/generationBatch.test.ts +614 -0
- package/src/database/models/__tests__/generationTopic.test.ts +411 -0
- package/src/database/models/aiModel.ts +2 -0
- package/src/database/models/asyncTask.ts +1 -1
- package/src/database/models/file.ts +28 -20
- package/src/database/models/generation.ts +197 -0
- package/src/database/models/generationBatch.ts +212 -0
- package/src/database/models/generationTopic.ts +131 -0
- package/src/database/repositories/aiInfra/index.test.ts +157 -1
- package/src/database/repositories/aiInfra/index.ts +37 -19
- package/src/database/repositories/tableViewer/index.test.ts +1 -1
- package/src/database/schemas/file.ts +8 -0
- package/src/database/schemas/generation.ts +127 -0
- package/src/database/schemas/index.ts +1 -0
- package/src/database/schemas/relations.ts +45 -1
- package/src/database/type.ts +2 -0
- package/src/database/utils/idGenerator.ts +3 -0
- package/src/features/Conversation/Error/ChatInvalidApiKey.tsx +39 -0
- package/src/features/Conversation/Error/InvalidAccessCode.tsx +2 -2
- package/src/features/Conversation/Error/index.tsx +3 -3
- package/src/features/ImageSidePanel/index.tsx +83 -0
- package/src/features/ImageTopicPanel/index.tsx +79 -0
- package/src/features/PluginDevModal/MCPManifestForm/CollapsibleSection.tsx +62 -0
- package/src/features/PluginDevModal/MCPManifestForm/QuickImportSection.tsx +158 -0
- package/src/features/PluginDevModal/MCPManifestForm/index.tsx +99 -155
- package/src/features/PluginStore/McpList/Detail/Settings/index.tsx +5 -2
- package/src/hooks/useDownloadImage.ts +31 -0
- package/src/hooks/useFetchGenerationTopics.ts +13 -0
- package/src/hooks/useHotkeys/imageScope.ts +48 -0
- package/src/libs/mcp/client.ts +55 -22
- package/src/libs/mcp/types.ts +42 -6
- package/src/libs/model-runtime/BaseAI.ts +3 -1
- package/src/libs/model-runtime/ModelRuntime.test.ts +80 -0
- package/src/libs/model-runtime/ModelRuntime.ts +15 -1
- package/src/libs/model-runtime/UniformRuntime/index.ts +4 -1
- package/src/libs/model-runtime/fal/index.test.ts +442 -0
- package/src/libs/model-runtime/fal/index.ts +88 -0
- package/src/libs/model-runtime/openai/index.test.ts +396 -2
- package/src/libs/model-runtime/openai/index.ts +129 -3
- package/src/libs/model-runtime/runtimeMap.ts +2 -0
- package/src/libs/model-runtime/types/image.ts +25 -0
- package/src/libs/model-runtime/types/type.ts +1 -0
- package/src/libs/model-runtime/utils/openaiCompatibleFactory/index.ts +10 -0
- package/src/libs/standard-parameters/index.ts +1 -0
- package/src/libs/standard-parameters/meta-schema.test.ts +214 -0
- package/src/libs/standard-parameters/meta-schema.ts +147 -0
- package/src/libs/swr/index.ts +1 -0
- package/src/libs/trpc/async/asyncAuth.ts +29 -8
- package/src/libs/trpc/async/context.ts +42 -4
- package/src/libs/trpc/async/index.ts +17 -4
- package/src/libs/trpc/async/init.ts +8 -0
- package/src/libs/trpc/client/lambda.ts +19 -2
- package/src/locales/default/common.ts +2 -0
- package/src/locales/default/components.ts +35 -0
- package/src/locales/default/error.ts +2 -0
- package/src/locales/default/image.ts +100 -0
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/metadata.ts +4 -0
- package/src/locales/default/modelProvider.ts +2 -0
- package/src/locales/default/plugin.ts +22 -0
- package/src/locales/default/setting.ts +5 -0
- package/src/middleware.ts +1 -0
- package/src/server/modules/ElectronIPCClient/index.ts +9 -1
- package/src/server/modules/S3/index.ts +15 -0
- package/src/server/routers/async/caller.ts +9 -1
- package/src/server/routers/async/image.ts +253 -0
- package/src/server/routers/async/index.ts +2 -0
- package/src/server/routers/lambda/aiProvider.test.ts +2 -0
- package/src/server/routers/lambda/generation.test.ts +267 -0
- package/src/server/routers/lambda/generation.ts +86 -0
- package/src/server/routers/lambda/generationBatch.test.ts +376 -0
- package/src/server/routers/lambda/generationBatch.ts +56 -0
- package/src/server/routers/lambda/generationTopic.test.ts +508 -0
- package/src/server/routers/lambda/generationTopic.ts +93 -0
- package/src/server/routers/lambda/image.ts +248 -0
- package/src/server/routers/lambda/index.ts +8 -0
- package/src/server/routers/tools/mcp.ts +15 -0
- package/src/server/services/file/__tests__/index.test.ts +135 -0
- package/src/server/services/file/impls/local.test.ts +153 -52
- package/src/server/services/file/impls/local.ts +70 -46
- package/src/server/services/file/impls/s3.test.ts +114 -0
- package/src/server/services/file/impls/s3.ts +40 -0
- package/src/server/services/file/impls/type.ts +10 -0
- package/src/server/services/file/index.ts +14 -0
- package/src/server/services/generation/index.ts +239 -0
- package/src/server/services/mcp/index.ts +20 -2
- package/src/services/__tests__/generation.test.ts +40 -0
- package/src/services/__tests__/generationBatch.test.ts +36 -0
- package/src/services/__tests__/generationTopic.test.ts +72 -0
- package/src/services/electron/file.ts +3 -1
- package/src/services/generation.ts +16 -0
- package/src/services/generationBatch.ts +25 -0
- package/src/services/generationTopic.ts +28 -0
- package/src/services/image.ts +33 -0
- package/src/services/mcp.ts +12 -7
- package/src/services/upload.ts +43 -9
- package/src/store/aiInfra/slices/aiProvider/action.ts +31 -6
- package/src/store/aiInfra/slices/aiProvider/initialState.ts +1 -0
- package/src/store/aiInfra/slices/aiProvider/selectors.ts +3 -0
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +5 -5
- package/src/store/chat/slices/message/action.ts +2 -2
- package/src/store/chat/slices/translate/action.ts +1 -1
- package/src/store/global/initialState.ts +9 -0
- package/src/store/global/selectors/systemStatus.ts +8 -0
- package/src/store/image/index.ts +2 -0
- package/src/store/image/initialState.ts +25 -0
- package/src/store/image/selectors.ts +4 -0
- package/src/store/image/slices/createImage/action.test.ts +330 -0
- package/src/store/image/slices/createImage/action.ts +134 -0
- package/src/store/image/slices/createImage/initialState.ts +9 -0
- package/src/store/image/slices/createImage/selectors.test.ts +114 -0
- package/src/store/image/slices/createImage/selectors.ts +9 -0
- package/src/store/image/slices/generationBatch/action.test.ts +495 -0
- package/src/store/image/slices/generationBatch/action.ts +303 -0
- package/src/store/image/slices/generationBatch/initialState.ts +13 -0
- package/src/store/image/slices/generationBatch/reducer.test.ts +568 -0
- package/src/store/image/slices/generationBatch/reducer.ts +101 -0
- package/src/store/image/slices/generationBatch/selectors.test.ts +307 -0
- package/src/store/image/slices/generationBatch/selectors.ts +36 -0
- package/src/store/image/slices/generationConfig/action.test.ts +351 -0
- package/src/store/image/slices/generationConfig/action.ts +295 -0
- package/src/store/image/slices/generationConfig/hooks.test.ts +304 -0
- package/src/store/image/slices/generationConfig/hooks.ts +118 -0
- package/src/store/image/slices/generationConfig/index.ts +1 -0
- package/src/store/image/slices/generationConfig/initialState.ts +37 -0
- package/src/store/image/slices/generationConfig/selectors.test.ts +204 -0
- package/src/store/image/slices/generationConfig/selectors.ts +25 -0
- package/src/store/image/slices/generationTopic/action.test.ts +687 -0
- package/src/store/image/slices/generationTopic/action.ts +319 -0
- package/src/store/image/slices/generationTopic/index.ts +2 -0
- package/src/store/image/slices/generationTopic/initialState.ts +14 -0
- package/src/store/image/slices/generationTopic/reducer.test.ts +198 -0
- package/src/store/image/slices/generationTopic/reducer.ts +66 -0
- package/src/store/image/slices/generationTopic/selectors.test.ts +103 -0
- package/src/store/image/slices/generationTopic/selectors.ts +15 -0
- package/src/store/image/store.ts +42 -0
- package/src/store/image/utils/size.ts +51 -0
- package/src/store/tool/slices/customPlugin/action.ts +10 -1
- package/src/store/tool/slices/mcpStore/action.ts +6 -4
- package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +4 -0
- package/src/store/user/slices/settings/selectors/systemAgent.ts +2 -0
- package/src/types/aiModel.ts +8 -3
- package/src/types/aiProvider.ts +2 -0
- package/src/types/asyncTask.ts +2 -0
- package/src/types/files/index.ts +5 -0
- package/src/types/generation/index.ts +80 -0
- package/src/types/hotkey.ts +2 -0
- package/src/types/plugins/mcp.ts +2 -6
- package/src/types/tool/plugin.ts +8 -0
- package/src/types/user/settings/keyVaults.ts +5 -0
- package/src/types/user/settings/systemAgent.ts +1 -0
- package/src/utils/client/downloadFile.ts +33 -4
- package/src/utils/number.test.ts +105 -0
- package/src/utils/number.ts +25 -0
- package/src/utils/server/__tests__/geo.test.ts +6 -3
- package/src/utils/storeDebug.test.ts +152 -0
- package/src/utils/storeDebug.ts +16 -7
- package/src/utils/time.test.ts +259 -0
- package/src/utils/time.ts +18 -0
- package/src/utils/units.ts +61 -0
- package/src/utils/url.test.ts +358 -9
- package/src/utils/url.ts +105 -3
- package/{vitest.server.config.ts → vitest.config.server.ts} +3 -0
- package/.cursor/rules/i18n/i18n-auto-attached.mdc +0 -6
- package/src/features/Conversation/Error/APIKeyForm/index.tsx +0 -105
- package/src/features/Conversation/Error/InvalidAPIKey.tsx +0 -16
- package/src/features/PluginDevModal/MCPManifestForm/EnvEditor.tsx +0 -227
- /package/.cursor/rules/{i18n/i18n.mdc → i18n.mdc} +0 -0
- /package/src/app/[variants]/(main)/settings/system-agent/features/{createForm.tsx → SystemAgentForm.tsx} +0 -0
- /package/src/{features/Conversation/Error → components/InvalidAPIKey}/APIKeyForm/LoadingContext.ts +0 -0
@@ -189,6 +189,13 @@
|
|
189
189
|
"when": 1752212281564,
|
190
190
|
"tag": "0026_add_autovacuum_tuning",
|
191
191
|
"breakpoints": true
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"idx": 27,
|
195
|
+
"version": "7",
|
196
|
+
"when": 1752413805765,
|
197
|
+
"tag": "0027_ai_image",
|
198
|
+
"breakpoints": true
|
192
199
|
}
|
193
200
|
],
|
194
201
|
"version": "6"
|
@@ -123,7 +123,8 @@ describe('AsyncTaskModel', () => {
|
|
123
123
|
|
124
124
|
describe('checkTimeoutTasks', () => {
|
125
125
|
it('should mark tasks as error if they timeout', async () => {
|
126
|
-
|
126
|
+
// Create a task with old timestamp (beyond timeout)
|
127
|
+
const timeoutDate = new Date(Date.now() - ASYNC_TASK_TIMEOUT - 1000);
|
127
128
|
|
128
129
|
const { id } = await serverDB
|
129
130
|
.insert(asyncTasks)
|
@@ -131,7 +132,7 @@ describe('AsyncTaskModel', () => {
|
|
131
132
|
type: AsyncTaskType.Chunking,
|
132
133
|
status: AsyncTaskStatus.Processing,
|
133
134
|
userId,
|
134
|
-
createdAt:
|
135
|
+
createdAt: timeoutDate,
|
135
136
|
})
|
136
137
|
.returning()
|
137
138
|
.then((res) => res[0]);
|
@@ -143,18 +144,19 @@ describe('AsyncTaskModel', () => {
|
|
143
144
|
});
|
144
145
|
expect(updatedTask?.status).toBe(AsyncTaskStatus.Error);
|
145
146
|
expect(updatedTask?.error).toBeDefined();
|
146
|
-
|
147
|
-
vi.useRealTimers();
|
148
147
|
});
|
149
148
|
|
150
149
|
it('should not mark tasks as error if they are not timed out', async () => {
|
150
|
+
// Create a task with recent timestamp (within timeout)
|
151
|
+
const recentDate = new Date();
|
152
|
+
|
151
153
|
const { id } = await serverDB
|
152
154
|
.insert(asyncTasks)
|
153
155
|
.values({
|
154
156
|
type: AsyncTaskType.Chunking,
|
155
157
|
status: AsyncTaskStatus.Processing,
|
156
158
|
userId,
|
157
|
-
createdAt:
|
159
|
+
createdAt: recentDate,
|
158
160
|
})
|
159
161
|
.returning()
|
160
162
|
.then((res) => res[0]);
|
@@ -733,4 +733,291 @@ describe('FileModel', () => {
|
|
733
733
|
expect(remainingFiles[0].hashId).toBe('hash2');
|
734
734
|
});
|
735
735
|
});
|
736
|
+
|
737
|
+
describe('Transaction Support', () => {
|
738
|
+
describe('create with transaction', () => {
|
739
|
+
it('should create file within provided transaction', async () => {
|
740
|
+
const params = {
|
741
|
+
name: 'test-file-txn.txt',
|
742
|
+
url: 'https://example.com/test-file-txn.txt',
|
743
|
+
size: 100,
|
744
|
+
fileType: 'text/plain',
|
745
|
+
fileHash: 'test-hash-txn',
|
746
|
+
};
|
747
|
+
|
748
|
+
// 在事务中创建文件
|
749
|
+
const result = await serverDB.transaction(async (trx) => {
|
750
|
+
const { id } = await fileModel.create(params, true, trx);
|
751
|
+
|
752
|
+
// 在事务内验证文件已创建
|
753
|
+
const file = await trx.query.files.findFirst({ where: eq(files.id, id) });
|
754
|
+
expect(file).toMatchObject({ ...params, userId });
|
755
|
+
|
756
|
+
return { id };
|
757
|
+
});
|
758
|
+
|
759
|
+
// 事务提交后,验证文件仍然存在
|
760
|
+
const file = await serverDB.query.files.findFirst({ where: eq(files.id, result.id) });
|
761
|
+
expect(file).toMatchObject({ ...params, userId });
|
762
|
+
|
763
|
+
// 验证全局文件也被创建
|
764
|
+
const globalFile = await serverDB.query.globalFiles.findFirst({
|
765
|
+
where: eq(globalFiles.hashId, params.fileHash),
|
766
|
+
});
|
767
|
+
expect(globalFile).toBeDefined();
|
768
|
+
});
|
769
|
+
|
770
|
+
it('should rollback file creation when transaction fails', async () => {
|
771
|
+
const params = {
|
772
|
+
name: 'test-file-rollback.txt',
|
773
|
+
url: 'https://example.com/test-file-rollback.txt',
|
774
|
+
size: 100,
|
775
|
+
fileType: 'text/plain',
|
776
|
+
fileHash: 'test-hash-rollback',
|
777
|
+
};
|
778
|
+
|
779
|
+
let createdFileId: string | undefined;
|
780
|
+
|
781
|
+
// 故意让事务失败
|
782
|
+
await expect(
|
783
|
+
serverDB.transaction(async (trx) => {
|
784
|
+
const { id } = await fileModel.create(params, true, trx);
|
785
|
+
createdFileId = id;
|
786
|
+
|
787
|
+
// 在事务内验证文件已创建
|
788
|
+
const file = await trx.query.files.findFirst({ where: eq(files.id, id) });
|
789
|
+
expect(file).toMatchObject({ ...params, userId });
|
790
|
+
|
791
|
+
// 抛出错误导致事务回滚
|
792
|
+
throw new Error('Intentional rollback');
|
793
|
+
}),
|
794
|
+
).rejects.toThrow('Intentional rollback');
|
795
|
+
|
796
|
+
// 验证文件创建被回滚
|
797
|
+
if (createdFileId) {
|
798
|
+
const file = await serverDB.query.files.findFirst({
|
799
|
+
where: eq(files.id, createdFileId),
|
800
|
+
});
|
801
|
+
expect(file).toBeUndefined();
|
802
|
+
}
|
803
|
+
|
804
|
+
// 验证全局文件创建也被回滚
|
805
|
+
const globalFile = await serverDB.query.globalFiles.findFirst({
|
806
|
+
where: eq(globalFiles.hashId, params.fileHash),
|
807
|
+
});
|
808
|
+
expect(globalFile).toBeUndefined();
|
809
|
+
});
|
810
|
+
|
811
|
+
it('should create file with knowledgeBase within transaction', async () => {
|
812
|
+
const params = {
|
813
|
+
name: 'test-kb-file.txt',
|
814
|
+
url: 'https://example.com/test-kb-file.txt',
|
815
|
+
size: 100,
|
816
|
+
fileType: 'text/plain',
|
817
|
+
knowledgeBaseId: 'kb1',
|
818
|
+
};
|
819
|
+
|
820
|
+
const result = await serverDB.transaction(async (trx) => {
|
821
|
+
const { id } = await fileModel.create(params, false, trx);
|
822
|
+
|
823
|
+
// 验证知识库文件关联已创建
|
824
|
+
const kbFile = await trx.query.knowledgeBaseFiles.findFirst({
|
825
|
+
where: eq(knowledgeBaseFiles.fileId, id),
|
826
|
+
});
|
827
|
+
expect(kbFile).toMatchObject({ fileId: id, knowledgeBaseId: 'kb1', userId });
|
828
|
+
|
829
|
+
return { id };
|
830
|
+
});
|
831
|
+
|
832
|
+
// 事务提交后验证
|
833
|
+
const kbFile = await serverDB.query.knowledgeBaseFiles.findFirst({
|
834
|
+
where: eq(knowledgeBaseFiles.fileId, result.id),
|
835
|
+
});
|
836
|
+
expect(kbFile).toMatchObject({
|
837
|
+
fileId: result.id,
|
838
|
+
knowledgeBaseId: 'kb1',
|
839
|
+
userId,
|
840
|
+
});
|
841
|
+
});
|
842
|
+
});
|
843
|
+
|
844
|
+
describe('delete with transaction', () => {
|
845
|
+
it('should delete file within provided transaction', async () => {
|
846
|
+
// 先创建文件和全局文件
|
847
|
+
await fileModel.createGlobalFile({
|
848
|
+
hashId: 'delete-txn-hash',
|
849
|
+
url: 'https://example.com/delete-txn.txt',
|
850
|
+
size: 100,
|
851
|
+
fileType: 'text/plain',
|
852
|
+
creator: userId,
|
853
|
+
});
|
854
|
+
|
855
|
+
const { id } = await fileModel.create({
|
856
|
+
name: 'delete-txn-file.txt',
|
857
|
+
url: 'https://example.com/delete-txn.txt',
|
858
|
+
size: 100,
|
859
|
+
fileType: 'text/plain',
|
860
|
+
fileHash: 'delete-txn-hash',
|
861
|
+
});
|
862
|
+
|
863
|
+
// 在事务中删除文件
|
864
|
+
await serverDB.transaction(async (trx) => {
|
865
|
+
await fileModel.delete(id, true, trx);
|
866
|
+
|
867
|
+
// 在事务内验证文件已删除
|
868
|
+
const file = await trx.query.files.findFirst({ where: eq(files.id, id) });
|
869
|
+
expect(file).toBeUndefined();
|
870
|
+
});
|
871
|
+
|
872
|
+
// 事务提交后验证文件仍然被删除
|
873
|
+
const file = await serverDB.query.files.findFirst({ where: eq(files.id, id) });
|
874
|
+
expect(file).toBeUndefined();
|
875
|
+
|
876
|
+
// 验证全局文件也被删除(因为没有其他引用)
|
877
|
+
const globalFile = await serverDB.query.globalFiles.findFirst({
|
878
|
+
where: eq(globalFiles.hashId, 'delete-txn-hash'),
|
879
|
+
});
|
880
|
+
expect(globalFile).toBeUndefined();
|
881
|
+
});
|
882
|
+
|
883
|
+
it('should rollback file deletion when transaction fails', async () => {
|
884
|
+
// 先创建文件和全局文件
|
885
|
+
await fileModel.createGlobalFile({
|
886
|
+
hashId: 'rollback-delete-hash',
|
887
|
+
url: 'https://example.com/rollback-delete.txt',
|
888
|
+
size: 100,
|
889
|
+
fileType: 'text/plain',
|
890
|
+
creator: userId,
|
891
|
+
});
|
892
|
+
|
893
|
+
const { id } = await fileModel.create({
|
894
|
+
name: 'rollback-delete-file.txt',
|
895
|
+
url: 'https://example.com/rollback-delete.txt',
|
896
|
+
size: 100,
|
897
|
+
fileType: 'text/plain',
|
898
|
+
fileHash: 'rollback-delete-hash',
|
899
|
+
});
|
900
|
+
|
901
|
+
// 故意让事务失败
|
902
|
+
await expect(
|
903
|
+
serverDB.transaction(async (trx) => {
|
904
|
+
await fileModel.delete(id, true, trx);
|
905
|
+
|
906
|
+
// 在事务内验证文件已删除
|
907
|
+
const file = await trx.query.files.findFirst({ where: eq(files.id, id) });
|
908
|
+
expect(file).toBeUndefined();
|
909
|
+
|
910
|
+
// 抛出错误导致事务回滚
|
911
|
+
throw new Error('Intentional rollback for delete');
|
912
|
+
}),
|
913
|
+
).rejects.toThrow('Intentional rollback for delete');
|
914
|
+
|
915
|
+
// 验证文件删除被回滚,文件仍然存在
|
916
|
+
const file = await serverDB.query.files.findFirst({ where: eq(files.id, id) });
|
917
|
+
expect(file).toBeDefined();
|
918
|
+
expect(file?.name).toBe('rollback-delete-file.txt');
|
919
|
+
|
920
|
+
// 验证全局文件也被回滚,仍然存在
|
921
|
+
const globalFile = await serverDB.query.globalFiles.findFirst({
|
922
|
+
where: eq(globalFiles.hashId, 'rollback-delete-hash'),
|
923
|
+
});
|
924
|
+
expect(globalFile).toBeDefined();
|
925
|
+
});
|
926
|
+
|
927
|
+
it('should delete file but preserve global file when removeGlobalFile=false in transaction', async () => {
|
928
|
+
// 先创建文件和全局文件
|
929
|
+
await fileModel.createGlobalFile({
|
930
|
+
hashId: 'preserve-global-hash',
|
931
|
+
url: 'https://example.com/preserve-global.txt',
|
932
|
+
size: 100,
|
933
|
+
fileType: 'text/plain',
|
934
|
+
creator: userId,
|
935
|
+
});
|
936
|
+
|
937
|
+
const { id } = await fileModel.create({
|
938
|
+
name: 'preserve-global-file.txt',
|
939
|
+
url: 'https://example.com/preserve-global.txt',
|
940
|
+
size: 100,
|
941
|
+
fileType: 'text/plain',
|
942
|
+
fileHash: 'preserve-global-hash',
|
943
|
+
});
|
944
|
+
|
945
|
+
// 在事务中删除文件,但不删除全局文件
|
946
|
+
await serverDB.transaction(async (trx) => {
|
947
|
+
await fileModel.delete(id, false, trx);
|
948
|
+
});
|
949
|
+
|
950
|
+
// 验证文件被删除
|
951
|
+
const file = await serverDB.query.files.findFirst({ where: eq(files.id, id) });
|
952
|
+
expect(file).toBeUndefined();
|
953
|
+
|
954
|
+
// 验证全局文件被保留
|
955
|
+
const globalFile = await serverDB.query.globalFiles.findFirst({
|
956
|
+
where: eq(globalFiles.hashId, 'preserve-global-hash'),
|
957
|
+
});
|
958
|
+
expect(globalFile).toBeDefined();
|
959
|
+
});
|
960
|
+
});
|
961
|
+
|
962
|
+
describe('mixed operations in transaction', () => {
|
963
|
+
it('should support create and delete operations in same transaction', async () => {
|
964
|
+
// 先创建一个要删除的文件
|
965
|
+
await fileModel.createGlobalFile({
|
966
|
+
hashId: 'mixed-delete-hash',
|
967
|
+
url: 'https://example.com/mixed-delete.txt',
|
968
|
+
size: 100,
|
969
|
+
fileType: 'text/plain',
|
970
|
+
creator: userId,
|
971
|
+
});
|
972
|
+
|
973
|
+
const { id: deleteFileId } = await fileModel.create({
|
974
|
+
name: 'mixed-delete-file.txt',
|
975
|
+
url: 'https://example.com/mixed-delete.txt',
|
976
|
+
size: 100,
|
977
|
+
fileType: 'text/plain',
|
978
|
+
fileHash: 'mixed-delete-hash',
|
979
|
+
});
|
980
|
+
|
981
|
+
// 在同一个事务中删除旧文件并创建新文件
|
982
|
+
const result = await serverDB.transaction(async (trx) => {
|
983
|
+
// 删除旧文件
|
984
|
+
await fileModel.delete(deleteFileId, true, trx);
|
985
|
+
|
986
|
+
// 创建新文件
|
987
|
+
const { id: newFileId } = await fileModel.create(
|
988
|
+
{
|
989
|
+
name: 'mixed-create-file.txt',
|
990
|
+
url: 'https://example.com/mixed-create.txt',
|
991
|
+
size: 200,
|
992
|
+
fileType: 'text/plain',
|
993
|
+
fileHash: 'mixed-create-hash',
|
994
|
+
},
|
995
|
+
true,
|
996
|
+
trx,
|
997
|
+
);
|
998
|
+
|
999
|
+
return { newFileId };
|
1000
|
+
});
|
1001
|
+
|
1002
|
+
// 验证旧文件被删除
|
1003
|
+
const deletedFile = await serverDB.query.files.findFirst({
|
1004
|
+
where: eq(files.id, deleteFileId),
|
1005
|
+
});
|
1006
|
+
expect(deletedFile).toBeUndefined();
|
1007
|
+
|
1008
|
+
// 验证新文件被创建
|
1009
|
+
const newFile = await serverDB.query.files.findFirst({
|
1010
|
+
where: eq(files.id, result.newFileId),
|
1011
|
+
});
|
1012
|
+
expect(newFile).toBeDefined();
|
1013
|
+
expect(newFile?.name).toBe('mixed-create-file.txt');
|
1014
|
+
|
1015
|
+
// 验证新的全局文件被创建
|
1016
|
+
const newGlobalFile = await serverDB.query.globalFiles.findFirst({
|
1017
|
+
where: eq(globalFiles.hashId, 'mixed-create-hash'),
|
1018
|
+
});
|
1019
|
+
expect(newGlobalFile).toBeDefined();
|
1020
|
+
});
|
1021
|
+
});
|
1022
|
+
});
|
736
1023
|
});
|