@lobehub/lobehub 2.0.0-next.9 → 2.0.0-next.91
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.desktop +1 -2
- package/.env.example +11 -3
- package/.env.example.development +0 -2
- package/.github/workflows/claude-auto-testing.yml +73 -0
- package/.github/workflows/claude-translate-comments.yml +67 -0
- package/.github/workflows/claude-translator.yml +1 -0
- package/.github/workflows/desktop-pr-build.yml +12 -9
- package/.github/workflows/e2e.yml +14 -0
- package/.github/workflows/release-desktop-beta.yml +4 -4
- package/.github/workflows/release.yml +2 -4
- package/.github/workflows/test.yml +44 -8
- package/.nvmrc +1 -1
- package/CHANGELOG.md +2028 -0
- package/Dockerfile +1 -3
- package/README.md +8 -51
- package/README.zh-CN.md +8 -51
- package/apps/desktop/package.json +19 -18
- package/apps/desktop/src/main/controllers/AuthCtr.ts +78 -39
- package/apps/desktop/src/main/controllers/LocalFileCtr.ts +80 -16
- package/apps/desktop/src/main/controllers/MenuCtr.ts +5 -5
- package/apps/desktop/src/main/controllers/NotificationCtr.ts +29 -29
- package/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts +16 -16
- package/apps/desktop/src/main/controllers/ShellCommandCtr.ts +242 -0
- package/apps/desktop/src/main/controllers/ShortcutCtr.ts +2 -2
- package/apps/desktop/src/main/controllers/TrayMenuCtr.ts +18 -18
- package/apps/desktop/src/main/controllers/UpdaterCtr.ts +4 -4
- package/apps/desktop/src/main/controllers/__tests__/AuthCtr.test.ts +706 -0
- package/apps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.ts +157 -1
- package/apps/desktop/src/main/controllers/__tests__/ShellCommandCtr.test.ts +499 -0
- package/apps/desktop/src/main/controllers/__tests__/TrayMenuCtr.test.ts +5 -5
- package/apps/desktop/src/main/controllers/index.ts +4 -4
- package/apps/desktop/src/main/core/infrastructure/ProtocolManager.ts +9 -4
- package/apps/desktop/src/main/core/infrastructure/UpdaterManager.ts +23 -2
- package/apps/desktop/src/main/modules/fileSearch/__tests__/macOS.integration.test.ts +357 -0
- package/apps/desktop/src/main/modules/fileSearch/impl/macOS.ts +30 -22
- package/apps/desktop/src/main/modules/networkProxy/__tests__/dispatcher.test.ts +401 -0
- package/apps/desktop/src/main/modules/networkProxy/__tests__/tester.test.ts +531 -0
- package/apps/desktop/src/main/modules/networkProxy/__tests__/urlBuilder.test.ts +349 -0
- package/apps/desktop/src/main/modules/networkProxy/__tests__/validator.test.ts +492 -0
- package/apps/desktop/src/main/modules/networkProxy/dispatcher.ts +16 -16
- package/apps/desktop/src/main/modules/networkProxy/tester.ts +11 -11
- package/apps/desktop/src/main/modules/networkProxy/urlBuilder.ts +3 -3
- package/apps/desktop/src/main/modules/networkProxy/validator.ts +10 -10
- package/apps/desktop/tsconfig.json +0 -1
- package/changelog/v1.json +706 -0
- package/docker-compose/local/.env.example +3 -0
- package/docs/development/database-schema.dbml +22 -14
- package/docs/self-hosting/advanced/auth/next-auth/auth0.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/auth0.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/authelia.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/authelia.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/authentik.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/authentik.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/casdoor.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/casdoor.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/github.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/github.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/google.mdx +32 -29
- package/docs/self-hosting/advanced/auth/next-auth/keycloak.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/keycloak.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/logto.mdx +5 -3
- package/docs/self-hosting/advanced/auth/next-auth/logto.zh-CN.mdx +5 -3
- package/docs/self-hosting/advanced/auth/next-auth/microsoft-entra-id.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/microsoft-entra-id.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/okta.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/okta.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/wechat.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/wechat.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/zitadel.mdx +2 -2
- package/docs/self-hosting/advanced/auth/next-auth/zitadel.zh-CN.mdx +2 -2
- package/docs/self-hosting/advanced/auth.mdx +32 -21
- package/docs/self-hosting/advanced/auth.zh-CN.mdx +30 -19
- package/docs/self-hosting/advanced/feature-flags.mdx +0 -1
- package/docs/self-hosting/advanced/feature-flags.zh-CN.mdx +0 -1
- package/docs/self-hosting/environment-variables/basic.mdx +49 -3
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +49 -4
- package/docs/self-hosting/server-database/docker-compose.mdx +29 -0
- package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +29 -0
- package/docs/usage/providers/comfyui.mdx +1 -1
- package/docs/usage/providers/comfyui.zh-CN.mdx +1 -1
- package/e2e/package.json +2 -2
- package/e2e/src/features/discover/detail-pages.feature +95 -0
- package/e2e/src/features/discover/interactions.feature +113 -0
- package/e2e/src/features/discover/smoke.feature +34 -1
- package/e2e/src/steps/discover/detail-pages.steps.ts +295 -0
- package/e2e/src/steps/discover/interactions.steps.ts +451 -0
- package/e2e/src/steps/discover/smoke.steps.ts +116 -4
- package/e2e/tsconfig.json +0 -1
- package/locales/ar/auth.json +45 -1
- package/locales/ar/chat.json +36 -0
- package/locales/ar/common.json +2 -0
- package/locales/ar/components.json +6 -0
- package/locales/ar/discover.json +45 -0
- package/locales/ar/error.json +2 -2
- package/locales/ar/file.json +87 -2
- package/locales/ar/labs.json +4 -0
- package/locales/ar/marketAuth.json +42 -0
- package/locales/ar/modelProvider.json +14 -2
- package/locales/ar/models.json +215 -89
- package/locales/ar/oauth.json +1 -0
- package/locales/ar/plugin.json +9 -1
- package/locales/ar/setting.json +94 -1
- package/locales/ar/tool.json +20 -1
- package/locales/ar/topic.json +1 -0
- package/locales/bg-BG/auth.json +45 -1
- package/locales/bg-BG/chat.json +36 -0
- package/locales/bg-BG/common.json +2 -0
- package/locales/bg-BG/components.json +6 -0
- package/locales/bg-BG/discover.json +45 -0
- package/locales/bg-BG/error.json +2 -2
- package/locales/bg-BG/file.json +87 -2
- package/locales/bg-BG/labs.json +4 -0
- package/locales/bg-BG/marketAuth.json +42 -0
- package/locales/bg-BG/modelProvider.json +14 -2
- package/locales/bg-BG/models.json +215 -89
- package/locales/bg-BG/oauth.json +1 -0
- package/locales/bg-BG/plugin.json +9 -1
- package/locales/bg-BG/setting.json +94 -1
- package/locales/bg-BG/tool.json +20 -1
- package/locales/bg-BG/topic.json +1 -0
- package/locales/de-DE/auth.json +45 -1
- package/locales/de-DE/chat.json +36 -0
- package/locales/de-DE/common.json +2 -0
- package/locales/de-DE/components.json +6 -0
- package/locales/de-DE/discover.json +45 -0
- package/locales/de-DE/error.json +2 -2
- package/locales/de-DE/file.json +87 -2
- package/locales/de-DE/labs.json +4 -0
- package/locales/de-DE/marketAuth.json +42 -0
- package/locales/de-DE/modelProvider.json +14 -2
- package/locales/de-DE/models.json +215 -89
- package/locales/de-DE/oauth.json +1 -0
- package/locales/de-DE/plugin.json +9 -1
- package/locales/de-DE/setting.json +94 -1
- package/locales/de-DE/tool.json +20 -1
- package/locales/de-DE/topic.json +1 -0
- package/locales/en-US/auth.json +45 -1
- package/locales/en-US/chat.json +36 -0
- package/locales/en-US/common.json +3 -0
- package/locales/en-US/components.json +6 -0
- package/locales/en-US/discover.json +45 -0
- package/locales/en-US/error.json +2 -2
- package/locales/en-US/file.json +87 -2
- package/locales/en-US/labs.json +4 -0
- package/locales/en-US/marketAuth.json +42 -0
- package/locales/en-US/modelProvider.json +14 -2
- package/locales/en-US/models.json +215 -89
- package/locales/en-US/oauth.json +1 -0
- package/locales/en-US/plugin.json +10 -2
- package/locales/en-US/setting.json +94 -1
- package/locales/en-US/tool.json +20 -1
- package/locales/en-US/topic.json +1 -0
- package/locales/es-ES/auth.json +45 -1
- package/locales/es-ES/chat.json +36 -0
- package/locales/es-ES/common.json +2 -0
- package/locales/es-ES/components.json +6 -0
- package/locales/es-ES/discover.json +45 -0
- package/locales/es-ES/error.json +2 -2
- package/locales/es-ES/file.json +87 -2
- package/locales/es-ES/labs.json +4 -0
- package/locales/es-ES/marketAuth.json +42 -0
- package/locales/es-ES/modelProvider.json +14 -2
- package/locales/es-ES/models.json +215 -89
- package/locales/es-ES/oauth.json +1 -0
- package/locales/es-ES/plugin.json +9 -1
- package/locales/es-ES/setting.json +94 -1
- package/locales/es-ES/tool.json +20 -1
- package/locales/es-ES/topic.json +1 -0
- package/locales/fa-IR/auth.json +45 -1
- package/locales/fa-IR/chat.json +36 -0
- package/locales/fa-IR/common.json +2 -0
- package/locales/fa-IR/components.json +6 -0
- package/locales/fa-IR/discover.json +45 -0
- package/locales/fa-IR/error.json +2 -2
- package/locales/fa-IR/file.json +87 -2
- package/locales/fa-IR/labs.json +4 -0
- package/locales/fa-IR/marketAuth.json +42 -0
- package/locales/fa-IR/modelProvider.json +14 -2
- package/locales/fa-IR/models.json +215 -89
- package/locales/fa-IR/oauth.json +1 -0
- package/locales/fa-IR/plugin.json +9 -1
- package/locales/fa-IR/setting.json +94 -1
- package/locales/fa-IR/tool.json +20 -1
- package/locales/fa-IR/topic.json +1 -0
- package/locales/fr-FR/auth.json +45 -1
- package/locales/fr-FR/chat.json +36 -0
- package/locales/fr-FR/common.json +2 -0
- package/locales/fr-FR/components.json +6 -0
- package/locales/fr-FR/discover.json +45 -0
- package/locales/fr-FR/error.json +2 -2
- package/locales/fr-FR/file.json +87 -2
- package/locales/fr-FR/labs.json +4 -0
- package/locales/fr-FR/marketAuth.json +42 -0
- package/locales/fr-FR/modelProvider.json +14 -2
- package/locales/fr-FR/models.json +215 -89
- package/locales/fr-FR/oauth.json +1 -0
- package/locales/fr-FR/plugin.json +9 -1
- package/locales/fr-FR/setting.json +94 -1
- package/locales/fr-FR/tool.json +20 -1
- package/locales/fr-FR/topic.json +1 -0
- package/locales/it-IT/auth.json +45 -1
- package/locales/it-IT/chat.json +36 -0
- package/locales/it-IT/common.json +2 -0
- package/locales/it-IT/components.json +6 -0
- package/locales/it-IT/discover.json +45 -0
- package/locales/it-IT/error.json +2 -2
- package/locales/it-IT/file.json +87 -2
- package/locales/it-IT/labs.json +4 -0
- package/locales/it-IT/marketAuth.json +42 -0
- package/locales/it-IT/modelProvider.json +14 -2
- package/locales/it-IT/models.json +215 -89
- package/locales/it-IT/oauth.json +1 -0
- package/locales/it-IT/plugin.json +9 -1
- package/locales/it-IT/setting.json +94 -1
- package/locales/it-IT/tool.json +20 -1
- package/locales/it-IT/topic.json +1 -0
- package/locales/ja-JP/auth.json +45 -1
- package/locales/ja-JP/chat.json +36 -0
- package/locales/ja-JP/common.json +2 -0
- package/locales/ja-JP/components.json +6 -0
- package/locales/ja-JP/discover.json +45 -0
- package/locales/ja-JP/error.json +2 -2
- package/locales/ja-JP/file.json +87 -2
- package/locales/ja-JP/labs.json +4 -0
- package/locales/ja-JP/marketAuth.json +42 -0
- package/locales/ja-JP/modelProvider.json +14 -2
- package/locales/ja-JP/models.json +215 -89
- package/locales/ja-JP/oauth.json +1 -0
- package/locales/ja-JP/plugin.json +9 -1
- package/locales/ja-JP/setting.json +94 -1
- package/locales/ja-JP/tool.json +20 -1
- package/locales/ja-JP/topic.json +1 -0
- package/locales/ko-KR/auth.json +45 -1
- package/locales/ko-KR/chat.json +36 -0
- package/locales/ko-KR/common.json +2 -0
- package/locales/ko-KR/components.json +6 -0
- package/locales/ko-KR/discover.json +45 -0
- package/locales/ko-KR/error.json +2 -2
- package/locales/ko-KR/file.json +87 -2
- package/locales/ko-KR/labs.json +4 -0
- package/locales/ko-KR/marketAuth.json +42 -0
- package/locales/ko-KR/modelProvider.json +14 -2
- package/locales/ko-KR/models.json +221 -95
- package/locales/ko-KR/oauth.json +1 -0
- package/locales/ko-KR/plugin.json +9 -1
- package/locales/ko-KR/setting.json +94 -1
- package/locales/ko-KR/tool.json +20 -1
- package/locales/ko-KR/topic.json +1 -0
- package/locales/nl-NL/auth.json +45 -1
- package/locales/nl-NL/chat.json +36 -0
- package/locales/nl-NL/common.json +2 -0
- package/locales/nl-NL/components.json +6 -0
- package/locales/nl-NL/discover.json +45 -0
- package/locales/nl-NL/error.json +2 -2
- package/locales/nl-NL/file.json +87 -2
- package/locales/nl-NL/labs.json +4 -0
- package/locales/nl-NL/marketAuth.json +42 -0
- package/locales/nl-NL/modelProvider.json +14 -2
- package/locales/nl-NL/models.json +215 -89
- package/locales/nl-NL/oauth.json +1 -0
- package/locales/nl-NL/plugin.json +9 -1
- package/locales/nl-NL/setting.json +94 -1
- package/locales/nl-NL/tool.json +20 -1
- package/locales/nl-NL/topic.json +1 -0
- package/locales/pl-PL/auth.json +45 -1
- package/locales/pl-PL/chat.json +36 -0
- package/locales/pl-PL/common.json +2 -0
- package/locales/pl-PL/components.json +6 -0
- package/locales/pl-PL/discover.json +45 -0
- package/locales/pl-PL/error.json +2 -2
- package/locales/pl-PL/file.json +87 -2
- package/locales/pl-PL/labs.json +4 -0
- package/locales/pl-PL/marketAuth.json +42 -0
- package/locales/pl-PL/modelProvider.json +14 -2
- package/locales/pl-PL/models.json +215 -89
- package/locales/pl-PL/oauth.json +1 -0
- package/locales/pl-PL/plugin.json +9 -1
- package/locales/pl-PL/setting.json +94 -1
- package/locales/pl-PL/tool.json +20 -1
- package/locales/pl-PL/topic.json +1 -0
- package/locales/pt-BR/auth.json +45 -1
- package/locales/pt-BR/chat.json +36 -0
- package/locales/pt-BR/common.json +2 -0
- package/locales/pt-BR/components.json +6 -0
- package/locales/pt-BR/discover.json +45 -0
- package/locales/pt-BR/error.json +2 -2
- package/locales/pt-BR/file.json +87 -2
- package/locales/pt-BR/labs.json +4 -0
- package/locales/pt-BR/marketAuth.json +42 -0
- package/locales/pt-BR/modelProvider.json +14 -2
- package/locales/pt-BR/models.json +215 -89
- package/locales/pt-BR/oauth.json +1 -0
- package/locales/pt-BR/plugin.json +9 -1
- package/locales/pt-BR/setting.json +94 -1
- package/locales/pt-BR/tool.json +20 -1
- package/locales/pt-BR/topic.json +1 -0
- package/locales/ru-RU/auth.json +45 -1
- package/locales/ru-RU/chat.json +36 -0
- package/locales/ru-RU/common.json +2 -0
- package/locales/ru-RU/components.json +6 -0
- package/locales/ru-RU/discover.json +45 -0
- package/locales/ru-RU/error.json +2 -2
- package/locales/ru-RU/file.json +87 -2
- package/locales/ru-RU/labs.json +4 -0
- package/locales/ru-RU/marketAuth.json +42 -0
- package/locales/ru-RU/modelProvider.json +14 -2
- package/locales/ru-RU/models.json +215 -89
- package/locales/ru-RU/oauth.json +1 -0
- package/locales/ru-RU/plugin.json +9 -1
- package/locales/ru-RU/setting.json +94 -1
- package/locales/ru-RU/tool.json +20 -1
- package/locales/ru-RU/topic.json +1 -0
- package/locales/tr-TR/auth.json +45 -1
- package/locales/tr-TR/chat.json +36 -0
- package/locales/tr-TR/common.json +2 -0
- package/locales/tr-TR/components.json +6 -0
- package/locales/tr-TR/discover.json +45 -0
- package/locales/tr-TR/error.json +2 -2
- package/locales/tr-TR/file.json +87 -2
- package/locales/tr-TR/labs.json +4 -0
- package/locales/tr-TR/marketAuth.json +42 -0
- package/locales/tr-TR/modelProvider.json +14 -2
- package/locales/tr-TR/models.json +215 -89
- package/locales/tr-TR/oauth.json +1 -0
- package/locales/tr-TR/plugin.json +9 -1
- package/locales/tr-TR/setting.json +94 -1
- package/locales/tr-TR/tool.json +20 -1
- package/locales/tr-TR/topic.json +1 -0
- package/locales/vi-VN/auth.json +45 -1
- package/locales/vi-VN/chat.json +36 -0
- package/locales/vi-VN/common.json +2 -0
- package/locales/vi-VN/components.json +6 -0
- package/locales/vi-VN/discover.json +45 -0
- package/locales/vi-VN/error.json +2 -2
- package/locales/vi-VN/file.json +87 -2
- package/locales/vi-VN/labs.json +4 -0
- package/locales/vi-VN/marketAuth.json +42 -0
- package/locales/vi-VN/modelProvider.json +14 -2
- package/locales/vi-VN/models.json +215 -89
- package/locales/vi-VN/oauth.json +1 -0
- package/locales/vi-VN/plugin.json +9 -1
- package/locales/vi-VN/setting.json +94 -1
- package/locales/vi-VN/tool.json +20 -1
- package/locales/vi-VN/topic.json +1 -0
- package/locales/zh-CN/auth.json +45 -1
- package/locales/zh-CN/chat.json +36 -0
- package/locales/zh-CN/common.json +3 -0
- package/locales/zh-CN/components.json +6 -0
- package/locales/zh-CN/discover.json +45 -0
- package/locales/zh-CN/error.json +2 -2
- package/locales/zh-CN/file.json +87 -2
- package/locales/zh-CN/labs.json +4 -0
- package/locales/zh-CN/marketAuth.json +42 -0
- package/locales/zh-CN/modelProvider.json +14 -2
- package/locales/zh-CN/models.json +215 -89
- package/locales/zh-CN/oauth.json +1 -0
- package/locales/zh-CN/plugin.json +9 -1
- package/locales/zh-CN/setting.json +94 -1
- package/locales/zh-CN/tool.json +20 -1
- package/locales/zh-CN/topic.json +1 -0
- package/locales/zh-TW/auth.json +45 -1
- package/locales/zh-TW/chat.json +36 -0
- package/locales/zh-TW/common.json +2 -0
- package/locales/zh-TW/components.json +6 -0
- package/locales/zh-TW/discover.json +45 -0
- package/locales/zh-TW/error.json +2 -2
- package/locales/zh-TW/file.json +87 -2
- package/locales/zh-TW/labs.json +4 -0
- package/locales/zh-TW/marketAuth.json +42 -0
- package/locales/zh-TW/modelProvider.json +14 -2
- package/locales/zh-TW/models.json +215 -89
- package/locales/zh-TW/oauth.json +1 -0
- package/locales/zh-TW/plugin.json +9 -1
- package/locales/zh-TW/setting.json +94 -1
- package/locales/zh-TW/tool.json +20 -1
- package/locales/zh-TW/topic.json +1 -0
- package/next.config.ts +10 -12
- package/package.json +79 -79
- package/packages/agent-runtime/package.json +1 -1
- 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 +141 -87
- package/packages/agent-runtime/src/core/runtime.ts +104 -20
- package/packages/agent-runtime/src/types/event.ts +4 -1
- package/packages/agent-runtime/src/types/generalAgent.ts +72 -0
- package/packages/agent-runtime/src/types/index.ts +1 -0
- package/packages/agent-runtime/src/types/instruction.ts +50 -7
- package/packages/agent-runtime/src/types/runtime.ts +7 -0
- package/packages/agent-runtime/src/types/state.ts +9 -1
- package/packages/const/package.json +1 -1
- package/packages/const/src/hotkeys.ts +3 -3
- package/packages/const/src/models.ts +4 -2
- package/packages/const/src/settings/tool.ts +1 -5
- package/packages/const/src/url.ts +1 -0
- package/packages/const/src/user.ts +4 -2
- package/packages/const/src/utils/merge.ts +3 -3
- package/packages/const/src/version.ts +0 -5
- package/packages/context-engine/package.json +2 -2
- package/packages/context-engine/src/base/BaseProcessor.ts +13 -13
- package/packages/context-engine/src/base/BaseProvider.ts +2 -2
- package/packages/context-engine/src/base/__tests__/BaseProcessor.test.ts +5 -5
- package/packages/context-engine/src/processors/GroupMessageFlatten.ts +8 -6
- package/packages/context-engine/src/processors/MessageCleanup.ts +7 -6
- package/packages/context-engine/src/processors/MessageContent.ts +17 -17
- package/packages/context-engine/src/processors/PlaceholderVariables.ts +4 -4
- package/packages/context-engine/src/processors/ToolCall.ts +19 -18
- package/packages/context-engine/src/processors/ToolMessageReorder.ts +10 -10
- package/packages/context-engine/src/processors/__tests__/GroupMessageFlatten.test.ts +12 -12
- package/packages/context-engine/src/processors/__tests__/MessageCleanup.test.ts +28 -0
- package/packages/context-engine/src/processors/__tests__/ToolCall.test.ts +59 -0
- package/packages/context-engine/src/providers/HistorySummary.ts +6 -6
- package/packages/context-engine/src/providers/ToolSystemRole.ts +7 -7
- package/packages/context-engine/src/tools/ToolNameResolver.ts +1 -0
- package/packages/context-engine/src/tools/ToolsEngine.ts +8 -8
- package/packages/context-engine/src/tools/__tests__/ToolNameResolver.test.ts +57 -0
- package/packages/context-engine/src/types.ts +36 -35
- package/packages/conversation-flow/package.json +13 -0
- package/packages/conversation-flow/src/__tests__/fixtures/index.ts +44 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistant-chain-with-followup.json +56 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/assistant-with-tools.json +145 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/assistantGroup/tools-with-branches.json +107 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/active-index-1.json +131 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-branch.json +96 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-group-branches.json +249 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/assistant-user-branch.json +123 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/conversation.json +128 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/index.ts +18 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/multi-assistant-group.json +260 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/branch/nested.json +179 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/simple.json +85 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/compare/with-tools.json +169 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts +12 -0
- package/packages/conversation-flow/src/__tests__/fixtures/inputs/linear-conversation.json +59 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistant-chain-with-followup.json +135 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/assistant-with-tools.json +340 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/tools-with-branches.json +261 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/active-index-1.json +246 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-branch.json +208 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-group-branches.json +481 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/assistant-user-branch.json +254 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/conversation.json +264 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/index.ts +18 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/multi-assistant-group.json +407 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/branch/nested.json +405 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/index.ts +8 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/simple.json +224 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/compare/with-tools.json +418 -0
- package/packages/conversation-flow/src/__tests__/fixtures/outputs/linear-conversation.json +138 -0
- package/packages/conversation-flow/src/__tests__/parse.test.ts +132 -0
- package/packages/conversation-flow/src/index.ts +17 -0
- package/packages/conversation-flow/src/indexing.ts +58 -0
- package/packages/conversation-flow/src/parse.ts +97 -0
- package/packages/conversation-flow/src/structuring.ts +38 -0
- package/packages/conversation-flow/src/transformation/BranchResolver.ts +66 -0
- package/packages/conversation-flow/src/transformation/ContextTreeBuilder.ts +292 -0
- package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +566 -0
- package/packages/conversation-flow/src/transformation/MessageCollector.ts +166 -0
- package/packages/conversation-flow/src/transformation/MessageTransformer.ts +177 -0
- package/packages/conversation-flow/src/transformation/__tests__/BranchResolver.test.ts +151 -0
- package/packages/conversation-flow/src/transformation/__tests__/ContextTreeBuilder.test.ts +385 -0
- package/packages/conversation-flow/src/transformation/__tests__/FlatListBuilder.test.ts +511 -0
- package/packages/conversation-flow/src/transformation/__tests__/MessageCollector.test.ts +220 -0
- package/packages/conversation-flow/src/transformation/__tests__/MessageTransformer.test.ts +286 -0
- package/packages/conversation-flow/src/transformation/index.ts +78 -0
- package/packages/conversation-flow/src/types/contextTree.ts +65 -0
- package/packages/conversation-flow/src/types/flatMessageList.ts +54 -0
- package/packages/conversation-flow/src/types/index.ts +25 -0
- package/packages/conversation-flow/src/types/shared.ts +63 -0
- package/packages/conversation-flow/vitest.config.mts +10 -0
- package/packages/database/migrations/0042_improve_agent_index.sql +1 -0
- package/packages/database/migrations/0043_add_ai_model_settings.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/0046_add_parent_id.sql +15 -0
- package/packages/database/migrations/meta/0039_snapshot.json +1 -1
- package/packages/database/migrations/meta/0042_snapshot.json +7800 -0
- package/packages/database/migrations/meta/0043_snapshot.json +8419 -0
- 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/0046_snapshot.json +7879 -0
- package/packages/database/migrations/meta/_journal.json +35 -0
- package/packages/database/package.json +3 -3
- package/packages/database/src/client/db.test.ts +1 -2
- package/packages/database/src/client/db.ts +6 -6
- package/packages/database/src/core/electron.ts +1 -1
- package/packages/database/src/core/migrations.json +42 -0
- package/packages/database/src/core/web-server.ts +2 -1
- package/packages/database/src/models/__tests__/apiKey.test.ts +444 -0
- package/packages/database/src/models/__tests__/asyncTask.test.ts +1 -2
- package/packages/database/src/models/__tests__/chunk.test.ts +38 -0
- package/packages/database/src/models/__tests__/file.test.ts +95 -31
- package/packages/database/src/models/__tests__/generation.test.ts +1 -2
- package/packages/database/src/models/__tests__/generationBatch.test.ts +1 -2
- package/packages/database/src/models/__tests__/messages/message.create.test.ts +549 -0
- package/packages/database/src/models/__tests__/messages/message.delete.test.ts +481 -0
- package/packages/database/src/models/__tests__/messages/message.query.test.ts +1187 -0
- package/packages/database/src/models/__tests__/messages/message.stats.test.ts +633 -0
- package/packages/database/src/models/__tests__/messages/message.update.test.ts +757 -0
- package/packages/database/src/models/agent.ts +16 -13
- package/packages/database/src/models/aiProvider.ts +7 -7
- package/packages/database/src/models/apiKey.ts +2 -2
- package/packages/database/src/models/chunk.ts +1 -1
- package/packages/database/src/models/document.ts +5 -6
- package/packages/database/src/models/drizzleMigration.ts +1 -1
- package/packages/database/src/models/file.ts +35 -10
- package/packages/database/src/models/message.ts +14 -86
- package/packages/database/src/models/oauthHandoff.ts +19 -19
- package/packages/database/src/models/session.ts +72 -20
- package/packages/database/src/models/topic.ts +10 -10
- package/packages/database/src/models/user.ts +2 -1
- package/packages/database/src/repositories/aiInfra/index.test.ts +205 -7
- package/packages/database/src/repositories/aiInfra/index.ts +9 -8
- package/packages/database/src/repositories/dataExporter/index.test.ts +1 -1
- package/packages/database/src/repositories/dataImporter/__tests__/index.test.ts +1 -2
- package/packages/database/src/repositories/dataImporter/deprecated/__tests__/index.test.ts +3 -2
- package/packages/database/src/repositories/dataImporter/deprecated/index.ts +8 -2
- package/packages/database/src/repositories/dataImporter/index.ts +1 -2
- package/packages/database/src/repositories/knowledge/index.test.ts +300 -0
- package/packages/database/src/repositories/knowledge/index.ts +420 -0
- package/packages/database/src/repositories/tableViewer/index.test.ts +1 -1
- package/packages/database/src/repositories/tableViewer/index.ts +4 -5
- package/packages/database/src/schemas/agent.ts +6 -3
- package/packages/database/src/schemas/aiInfra.ts +3 -2
- package/packages/database/src/schemas/file.ts +79 -0
- package/packages/database/src/schemas/index.ts +0 -1
- package/packages/database/src/schemas/message.ts +5 -8
- package/packages/database/src/schemas/rag.ts +32 -2
- package/packages/database/src/schemas/relations.ts +2 -3
- package/packages/database/src/schemas/topic.ts +2 -3
- package/packages/database/src/schemas/user.ts +1 -1
- package/packages/database/src/server/models/__tests__/user.test.ts +1 -1
- package/packages/database/src/utils/genWhere.test.ts +243 -0
- package/packages/electron-client-ipc/package.json +1 -1
- package/packages/electron-client-ipc/src/events/index.ts +6 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +8 -0
- package/packages/electron-client-ipc/src/types/localSystem.ts +30 -2
- package/packages/electron-server-ipc/package.json +2 -2
- package/packages/electron-server-ipc/src/ipcClient.ts +31 -31
- package/packages/electron-server-ipc/src/ipcServer.ts +15 -15
- package/packages/fetch-sse/package.json +29 -0
- package/packages/fetch-sse/src/__tests__/fetchSSE.test.ts +579 -0
- package/packages/fetch-sse/src/__tests__/parseError.test.ts +91 -0
- package/packages/fetch-sse/src/fetchSSE.ts +487 -0
- package/packages/fetch-sse/src/headers.ts +27 -0
- package/packages/fetch-sse/src/parseError.ts +24 -0
- package/packages/fetch-sse/src/request.ts +28 -0
- package/packages/file-loaders/package.json +3 -3
- package/packages/file-loaders/src/loaders/docx/index.ts +1 -1
- package/packages/memory-extract/package.json +4 -4
- package/packages/model-bank/src/aiModels/aihubmix.ts +167 -3
- package/packages/model-bank/src/aiModels/google.ts +76 -83
- package/packages/model-bank/src/aiModels/mistral.ts +2 -1
- package/packages/model-bank/src/aiModels/novita.ts +3 -2
- package/packages/model-bank/src/aiModels/nvidia.ts +14 -0
- package/packages/model-bank/src/aiModels/ollamacloud.ts +26 -4
- package/packages/model-bank/src/aiModels/openai.ts +109 -38
- package/packages/model-bank/src/aiModels/openrouter.ts +1 -0
- package/packages/model-bank/src/aiModels/qiniu.ts +126 -0
- package/packages/model-bank/src/aiModels/qwen.ts +164 -7
- package/packages/model-bank/src/aiModels/siliconcloud.ts +20 -0
- package/packages/model-bank/src/aiModels/vercelaigateway.ts +0 -17
- package/packages/model-bank/src/aiModels/vertexai.ts +2 -0
- package/packages/model-bank/src/aiModels/volcengine.ts +1 -1
- package/packages/model-bank/src/aiModels/wenxin.ts +1348 -291
- package/packages/model-bank/src/types/aiModel.ts +18 -2
- package/packages/model-runtime/package.json +3 -3
- 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 +480 -1
- package/packages/model-runtime/src/core/contextBuilders/google.ts +47 -7
- package/packages/model-runtime/src/core/contextBuilders/openai.test.ts +93 -7
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +47 -14
- 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 +111 -70
- package/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts +153 -127
- package/packages/model-runtime/src/core/streams/google/google-ai.test.ts +1115 -814
- package/packages/model-runtime/src/core/streams/google/index.ts +19 -5
- package/packages/model-runtime/src/core/streams/ollama.test.ts +67 -0
- package/packages/model-runtime/src/core/streams/ollama.ts +5 -5
- package/packages/model-runtime/src/core/streams/openai/__snapshots__/responsesStream.test.ts.snap +1007 -0
- package/packages/model-runtime/src/core/streams/openai/openai.test.ts +310 -0
- package/packages/model-runtime/src/core/streams/openai/openai.ts +67 -0
- package/packages/model-runtime/src/core/streams/openai/responsesStream.test.ts +1 -1
- package/packages/model-runtime/src/core/streams/protocol.ts +1 -0
- package/packages/model-runtime/src/core/streams/vertex-ai.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/index.ts +1 -0
- package/packages/model-runtime/src/core/usageConverters/utils/resolveImageSinglePrice.ts +34 -0
- 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/azureai/index.ts +34 -2
- 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/comfyui/__tests__/index.test.ts +1 -2
- package/packages/model-runtime/src/providers/comfyui/auth/AuthManager.ts +1 -2
- package/packages/model-runtime/src/providers/comfyui/index.ts +2 -7
- package/packages/model-runtime/src/providers/deepseek/index.test.ts +86 -0
- package/packages/model-runtime/src/providers/deepseek/index.ts +24 -0
- 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 +2 -5
- package/packages/model-runtime/src/providers/google/index.ts +17 -10
- 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/minimax/index.ts +36 -6
- 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/newapi/index.test.ts +3 -75
- package/packages/model-runtime/src/providers/newapi/index.ts +1 -14
- package/packages/model-runtime/src/providers/novita/__snapshots__/index.test.ts.snap +584 -0
- 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/openai/__snapshots__/index.test.ts.snap +517 -0
- package/packages/model-runtime/src/providers/openai/index.test.ts +44 -0
- package/packages/model-runtime/src/providers/openrouter/index.test.ts +4 -3
- package/packages/model-runtime/src/providers/openrouter/index.ts +1 -1
- package/packages/model-runtime/src/providers/perplexity/index.test.ts +1 -1
- package/packages/model-runtime/src/providers/ppio/__snapshots__/index.test.ts.snap +27 -0
- 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/wenxin/index.ts +22 -1
- package/packages/model-runtime/src/providers/zhipu/index.test.ts +1 -1
- package/packages/model-runtime/src/types/chat.ts +8 -0
- package/packages/model-runtime/src/types/toolsCalling.ts +3 -1
- package/packages/model-runtime/src/utils/errorResponse.test.ts +1 -1
- package/packages/model-runtime/src/utils/googleErrorParser.test.ts +125 -0
- package/packages/model-runtime/src/utils/googleErrorParser.ts +103 -77
- package/packages/model-runtime/src/utils/modelParse.ts +6 -0
- package/packages/obervability-otel/package.json +13 -13
- package/packages/obervability-otel/src/api.ts +2 -0
- package/packages/obervability-otel/src/node.ts +17 -7
- package/packages/obervability-otel/src/trpc/convention.ts +16 -0
- package/packages/obervability-otel/src/trpc/index.test.ts +38 -0
- package/packages/obervability-otel/src/trpc/index.ts +62 -0
- package/packages/obervability-otel/src/trpc/metrics.ts +31 -0
- package/packages/prompts/package.json +1 -1
- package/packages/ssrf-safe-fetch/index.browser.ts +14 -0
- package/packages/ssrf-safe-fetch/package.json +9 -2
- package/packages/types/src/agent/chatConfig.ts +19 -8
- package/packages/types/src/aiChat.ts +2 -0
- package/packages/types/src/aiProvider.ts +1 -1
- package/packages/types/src/discover/assistants.ts +16 -0
- package/packages/types/src/discover/mcp.ts +6 -0
- package/packages/types/src/document/index.ts +50 -38
- package/packages/types/src/exportConfig.ts +15 -15
- package/packages/types/src/fetch.ts +9 -9
- package/packages/types/src/files/index.ts +2 -0
- package/packages/types/src/files/list.ts +11 -1
- package/packages/types/src/files/upload.ts +1 -1
- package/packages/types/src/generation/index.ts +5 -5
- package/packages/types/src/hotkey.ts +5 -5
- package/packages/types/src/importer.ts +6 -6
- package/packages/types/src/index.ts +5 -1
- package/packages/types/src/llm.ts +1 -1
- package/packages/types/src/message/common/base.ts +2 -2
- package/packages/types/src/message/common/metadata.ts +22 -2
- package/packages/types/src/message/common/tools.ts +20 -1
- package/packages/types/src/message/db/item.ts +15 -1
- package/packages/types/src/message/ui/chat.ts +25 -2
- package/packages/types/src/message/ui/extra.ts +2 -2
- package/packages/types/src/message/ui/params.ts +66 -7
- package/packages/types/src/meta.ts +7 -3
- package/packages/types/src/openai/chat.ts +15 -15
- package/packages/types/src/openai/image.ts +1 -1
- package/packages/types/src/plugins/mcp.ts +33 -30
- package/packages/types/src/plugins/protocol.ts +43 -43
- package/packages/types/src/search.ts +4 -4
- package/packages/types/src/serverConfig.ts +2 -6
- package/packages/types/src/session/agentSession.ts +2 -0
- package/packages/types/src/tool/builtin.ts +15 -4
- package/packages/types/src/tool/intervention.ts +32 -3
- package/packages/types/src/tool/plugin.ts +3 -3
- package/packages/types/src/tool/search/index.ts +8 -2
- package/packages/types/src/topic/topic.ts +16 -2
- package/packages/types/src/usage/usageRecord.ts +54 -0
- package/packages/types/src/user/index.ts +2 -76
- package/packages/types/src/user/preference.ts +101 -0
- package/packages/types/src/user/settings/hotkey.ts +1 -1
- package/packages/types/src/user/settings/index.ts +22 -0
- package/packages/types/src/user/settings/tool.ts +2 -39
- package/packages/utils/package.json +2 -2
- package/packages/utils/src/apiKey.test.ts +139 -0
- package/packages/utils/src/client/clipboard.ts +2 -2
- package/packages/utils/src/client/exportFile.ts +10 -10
- package/packages/utils/src/client/parserPlaceholder.ts +18 -18
- package/packages/utils/src/client/topic.ts +10 -10
- package/packages/utils/src/client/xor-obfuscation.ts +11 -11
- package/packages/utils/src/clientIP.ts +6 -6
- package/packages/utils/src/colorUtils.test.ts +167 -0
- package/packages/utils/src/compass.ts +11 -11
- package/packages/utils/src/compressImage.ts +3 -3
- package/packages/utils/src/format.ts +2 -2
- package/packages/utils/src/imageToBase64.ts +17 -10
- package/packages/utils/src/index.ts +1 -1
- package/packages/utils/src/merge.ts +3 -3
- package/packages/utils/src/object.ts +3 -3
- package/packages/utils/src/sanitizeUTF8.ts +4 -4
- package/packages/utils/src/server/__tests__/response.test.ts +79 -0
- package/packages/utils/src/server/auth.ts +6 -6
- package/packages/utils/src/server/geo.ts +9 -9
- package/packages/utils/src/server/index.ts +1 -0
- package/packages/utils/src/server/response.ts +110 -0
- package/packages/utils/src/server/validateRedirectHost.test.ts +352 -0
- package/packages/utils/src/server/xor.ts +7 -7
- package/packages/utils/src/time.ts +4 -0
- package/packages/utils/src/tokenizer/index.ts +3 -11
- package/packages/utils/src/toolManifest.ts +4 -4
- package/packages/utils/src/trace.test.ts +359 -0
- package/packages/utils/src/uriParser.ts +4 -4
- package/packages/web-crawler/package.json +2 -2
- package/packages/web-crawler/src/crawImpl/browserless.ts +1 -1
- package/packages/web-crawler/src/crawImpl/naive.ts +9 -9
- package/packages/web-crawler/src/crawler.ts +5 -5
- package/packages/web-crawler/src/type.ts +4 -4
- package/packages/web-crawler/src/urlRules.ts +13 -13
- package/packages/web-crawler/src/utils/appUrlRules.ts +5 -5
- package/packages/web-crawler/tsconfig.json +0 -1
- package/renovate.json +40 -1
- package/scripts/migrateServerDB/errorHint.js +1 -7
- package/scripts/prebuild.mts +16 -6
- package/src/app/(backend)/api/webhooks/clerk/route.ts +1 -2
- package/src/app/(backend)/f/[id]/route.ts +55 -0
- 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/(backend)/middleware/auth/index.ts +8 -4
- package/src/app/(backend)/trpc/async/[trpc]/route.ts +9 -3
- package/src/app/(backend)/trpc/desktop/[trpc]/route.ts +15 -9
- package/src/app/(backend)/trpc/lambda/[trpc]/route.ts +9 -3
- package/src/app/(backend)/trpc/mobile/[trpc]/route.ts +9 -3
- package/src/app/(backend)/trpc/tools/[trpc]/route.ts +9 -3
- package/src/app/(backend)/webapi/chat/[provider]/route.ts +1 -1
- package/src/app/(backend)/webapi/models/[provider]/pull/route.ts +1 -1
- package/src/app/(backend)/webapi/models/[provider]/route.ts +1 -1
- package/src/app/(backend)/webapi/stt/openai/route.ts +0 -2
- package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +1 -1
- package/src/app/(backend)/webapi/tts/edge/route.ts +8 -2
- package/src/app/(backend)/webapi/tts/microsoft/route.ts +8 -2
- package/src/app/(backend)/webapi/tts/openai/route.ts +15 -3
- package/src/app/[variants]/(auth)/signup/[[...signup]]/page.tsx +1 -8
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/UserBanner.test.tsx +7 -4
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +13 -24
- package/src/app/[variants]/(main)/(mobile)/me/(home)/features/UserBanner.tsx +7 -11
- package/src/app/[variants]/(main)/(mobile)/me/(home)/features/useCategory.tsx +9 -41
- package/src/app/[variants]/(main)/(mobile)/me/(home)/index.tsx +25 -0
- package/src/app/[variants]/(main)/(mobile)/me/(home)/layout.tsx +13 -18
- package/src/app/[variants]/(main)/(mobile)/me/profile/features/Category.tsx +22 -27
- package/src/app/[variants]/(main)/(mobile)/me/profile/features/Header.tsx +3 -3
- package/src/app/[variants]/(main)/(mobile)/me/profile/index.tsx +16 -0
- package/src/app/[variants]/(main)/(mobile)/me/profile/layout.tsx +9 -11
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/Header.tsx +3 -3
- package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +8 -18
- package/src/app/[variants]/(main)/(mobile)/me/settings/index.tsx +16 -0
- package/src/app/[variants]/(main)/(mobile)/me/settings/layout.tsx +15 -13
- package/src/app/[variants]/(main)/changelog/_layout/Desktop/index.tsx +6 -5
- package/src/app/[variants]/(main)/changelog/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/changelog/_layout/Mobile/index.tsx +5 -5
- package/src/app/[variants]/(main)/changelog/features/Post.tsx +7 -4
- package/src/app/[variants]/(main)/changelog/index.tsx +55 -0
- package/src/app/[variants]/(main)/chat/_layout/Desktop/SessionPanel.tsx +12 -7
- package/src/app/[variants]/(main)/chat/_layout/Desktop/index.tsx +7 -10
- package/src/app/[variants]/(main)/chat/_layout/FeatureFlagsProvider.tsx +24 -0
- package/src/app/[variants]/(main)/chat/_layout/Mobile.tsx +6 -9
- package/src/app/[variants]/(main)/chat/_layout/type.ts +0 -1
- package/src/app/[variants]/(main)/chat/components/ConversationArea.tsx +29 -0
- package/src/app/[variants]/(main)/chat/components/PortalPanel.tsx +28 -0
- package/src/app/[variants]/(main)/chat/components/SessionPanel.tsx +33 -0
- package/src/app/[variants]/(main)/chat/components/TopicSidebar.tsx +30 -0
- package/src/app/[variants]/(main)/chat/components/WorkspaceLayout.tsx +60 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatHydration/index.tsx +42 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/Desktop/MessageFromUrl.tsx +30 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/Desktop/index.tsx +16 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/V1Mobile/index.tsx +89 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/V1Mobile/useSend.ts +109 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatInput/useSend.ts +322 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/ChatItem/Thread.tsx +62 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/ChatItem/index.tsx +85 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/Content.tsx +45 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/WelcomeChatItem/AgentWelcome/OpeningQuestions.tsx +75 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatList/WelcomeChatItem/GroupWelcome/GroupUsageSuggest.tsx +164 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ChatMinimap/index.tsx +380 -0
- package/src/app/[variants]/(main)/chat/components/conversation/features/ThreadHydration.tsx +45 -0
- package/src/app/[variants]/(main)/chat/components/topic/features/Topic/TopicListContent/TopicItem/TopicContent.tsx +250 -0
- package/src/app/[variants]/(main)/chat/features/PageTitle/index.tsx +1 -2
- package/src/app/[variants]/(main)/chat/index.tsx +29 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionHydration.tsx +47 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/Inbox/index.tsx +61 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/Item/Actions.tsx +204 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/Item/index.tsx +157 -0
- package/src/app/[variants]/(main)/chat/session/features/SessionListContent/List/index.tsx +100 -0
- package/src/app/[variants]/(main)/chat/session/layout/Mobile/SessionHeader.tsx +44 -0
- package/src/app/[variants]/(main)/chat/settings/_layout/Desktop/Header.tsx +3 -3
- package/src/app/[variants]/(main)/chat/settings/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/chat/settings/features/AgentInfoDescription/index.tsx +349 -0
- package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +3 -63
- 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)/chat/settings/index.tsx +65 -0
- package/src/app/[variants]/(main)/components/Link.tsx +21 -0
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Desktop/index.tsx +38 -0
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Mobile/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Capabilities/Block.tsx +27 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Nav.tsx +129 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Overview/TagList.tsx +56 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Overview/index.tsx +98 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Related/index.tsx +40 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/SystemRole/TagList.tsx +56 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/SystemRole/index.tsx +68 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/Versions/index.tsx +137 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Details/index.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Header.tsx +176 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Sidebar/ActionButton/AddAgent.tsx +178 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Sidebar/ActionButton/index.tsx +31 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Sidebar/Related/index.tsx +57 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/Sidebar/TocList/index.tsx +77 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/features/StatusPage/index.tsx +113 -0
- package/src/app/[variants]/(main)/discover/(detail)/assistant/index.tsx +63 -0
- package/src/app/[variants]/(main)/discover/(detail)/features/Breadcrumb.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Details/Related/index.tsx +32 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Details/Versions/index.tsx +76 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Details/index.tsx +59 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Sidebar/Related/index.tsx +44 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Sidebar/ServerConfig.tsx +36 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/features/Sidebar/TocList/index.tsx +98 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/index.tsx +59 -0
- package/src/app/[variants]/(main)/discover/(detail)/mcp/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Details/Overview/index.tsx +22 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Details/Parameter/ParameterItem.tsx +71 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Details/Related/index.tsx +31 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Details/index.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Header.tsx +112 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx +92 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Sidebar/ActionButton/index.tsx +32 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Sidebar/Related/index.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/features/Sidebar/RelatedProviders/index.tsx +34 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/index.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(detail)/model/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Details/Related/index.tsx +22 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Details/index.tsx +47 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Sidebar/ActionButton/ProviderConfig.tsx +91 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Sidebar/ActionButton/index.tsx +45 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Sidebar/Related/index.tsx +34 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/features/Sidebar/RelatedModels/index.tsx +43 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/index.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(detail)/provider/loading.tsx +1 -0
- package/src/app/[variants]/(main)/discover/(list)/(home)/index.tsx +59 -0
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/Nav.tsx +5 -4
- package/src/app/[variants]/(main)/discover/(list)/_layout/Desktop/index.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/Nav.tsx +3 -4
- package/src/app/[variants]/(main)/discover/(list)/_layout/Mobile/index.tsx +4 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/Client.tsx +6 -2
- package/src/app/[variants]/(main)/discover/(list)/assistant/_layout/Desktop.tsx +3 -4
- package/src/app/[variants]/(main)/discover/(list)/assistant/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/assistant/features/Category/index.tsx +8 -4
- 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)/assistant/index.tsx +61 -0
- package/src/app/[variants]/(main)/discover/(list)/features/Pagination.tsx +2 -1
- package/src/app/[variants]/(main)/discover/(list)/features/SortButton/index.tsx +29 -10
- package/src/app/[variants]/(main)/discover/(list)/mcp/_layout/Desktop.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/mcp/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/Category/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/mcp/features/List/Item.tsx +2 -1
- package/src/app/[variants]/(main)/discover/(list)/mcp/index.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(list)/model/_layout/Desktop.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/model/_layout/Mobile.tsx +3 -3
- package/src/app/[variants]/(main)/discover/(list)/model/features/Category/index.tsx +1 -1
- package/src/app/[variants]/(main)/discover/(list)/model/features/List/Item.tsx +2 -1
- package/src/app/[variants]/(main)/discover/(list)/model/index.tsx +51 -0
- package/src/app/[variants]/(main)/discover/(list)/provider/features/List/Item.tsx +2 -1
- package/src/app/[variants]/(main)/discover/(list)/provider/index.tsx +50 -0
- package/src/app/[variants]/(main)/discover/_layout/Desktop/index.tsx +4 -4
- package/src/app/[variants]/(main)/discover/_layout/Mobile/index.tsx +3 -3
- package/src/app/[variants]/(main)/discover/components/CategoryMenu.tsx +9 -1
- package/src/app/[variants]/(main)/discover/components/Title.tsx +1 -1
- package/src/app/[variants]/(main)/discover/features/Search.tsx +2 -2
- package/src/app/[variants]/(main)/discover/features/useNav.tsx +11 -12
- package/src/app/[variants]/(main)/hooks/useActiveTabKey.ts +40 -0
- package/src/app/[variants]/(main)/hooks/usePathname.ts +10 -0
- package/src/app/[variants]/(main)/hooks/useQuery.ts +12 -0
- package/src/app/[variants]/(main)/hooks/useRouter.ts +22 -0
- package/src/app/[variants]/(main)/hooks/useSearchParams.ts +11 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect/ImageModelItem.tsx +93 -0
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect/index.tsx +161 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicList.tsx +1 -0
- package/src/app/[variants]/(main)/image/@topic/features/Topics/TopicUrlSync.tsx +1 -1
- package/src/app/[variants]/(main)/image/ComingSoon.tsx +15 -0
- package/src/app/[variants]/(main)/image/_layout/Desktop/index.tsx +5 -2
- package/src/app/[variants]/(main)/image/_layout/DesktopWrapper.tsx +15 -0
- package/src/app/[variants]/(main)/image/_layout/Mobile/index.tsx +3 -1
- package/src/app/[variants]/(main)/image/features/ImageWorkspace/index.tsx +1 -2
- package/src/app/[variants]/(main)/image/features/PromptInput/index.tsx +1 -1
- package/src/app/[variants]/(main)/image/index.tsx +18 -0
- package/src/app/[variants]/(main)/knowledge/_layout/Desktop.tsx +17 -0
- package/src/app/[variants]/(main)/knowledge/_layout/Mobile.tsx +17 -0
- package/src/app/[variants]/(main)/knowledge/components/KnowledgeBaseItem/index.tsx +1 -3
- package/src/app/[variants]/(main)/knowledge/components/modal/ModalPageClient.tsx +4 -4
- package/src/app/[variants]/(main)/knowledge/hooks/useFileCategory.ts +6 -3
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/index.tsx +7 -10
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/menu/CategoryMenu.tsx +35 -0
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/menu/Head.tsx +1 -1
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/menu/Menu.tsx +2 -2
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/index.tsx +40 -18
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/layout/Container.tsx +1 -1
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/menu/CategoryMenu.tsx +148 -0
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/menu/KnowledgeBase.tsx +21 -8
- package/src/app/[variants]/(main)/labs/components/LabCard.tsx +8 -6
- package/src/app/[variants]/(main)/labs/index.tsx +74 -0
- package/src/app/[variants]/(main)/layouts/desktop/DesktopLayoutContainer.tsx +33 -0
- package/src/app/[variants]/(main)/layouts/desktop/SideBar/BottomActions.tsx +46 -0
- package/src/app/[variants]/(main)/layouts/desktop/SideBar/PinList/index.tsx +121 -0
- package/src/app/[variants]/(main)/layouts/desktop/SideBar/TopActions.test.tsx +141 -0
- package/src/app/[variants]/(main)/layouts/desktop/SideBar/TopActions.tsx +117 -0
- package/src/app/[variants]/(main)/layouts/desktop/index.tsx +73 -0
- package/src/app/[variants]/(main)/layouts/index.tsx +11 -0
- package/src/app/[variants]/(main)/layouts/mobile/NavBar.tsx +88 -0
- package/src/app/[variants]/(main)/layouts/mobile/index.tsx +46 -0
- package/src/app/[variants]/(main)/profile/(home)/desktop.tsx +26 -0
- package/src/app/[variants]/(main)/profile/(home)/index.tsx +26 -0
- package/src/app/[variants]/(main)/profile/@category/features/CategoryContent.tsx +5 -7
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +20 -20
- package/src/app/[variants]/(main)/profile/_layout/DesktopWrapper.tsx +14 -0
- package/src/app/[variants]/(main)/profile/_layout/Mobile/Header.tsx +3 -3
- package/src/app/[variants]/(main)/profile/_layout/Mobile/index.tsx +8 -11
- package/src/app/[variants]/(main)/profile/apikey/index.tsx +18 -0
- package/src/app/[variants]/(main)/profile/hooks/useCategory.tsx +24 -18
- package/src/app/[variants]/(main)/profile/security/index.tsx +29 -0
- package/src/app/[variants]/(main)/profile/stats/features/AssistantsRank.tsx +4 -4
- package/src/app/[variants]/(main)/profile/stats/features/ShareButton/Preview.tsx +2 -14
- package/src/app/[variants]/(main)/profile/stats/features/TopicsRank.tsx +4 -4
- package/src/app/[variants]/(main)/profile/stats/index.tsx +20 -0
- package/src/app/[variants]/(main)/profile/usage/Client.tsx +114 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageCards/ActiveModels/ModelTable.tsx +175 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageCards/ActiveModels/index.tsx +126 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageCards/MonthSpend.tsx +53 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageCards/TodaySpend.tsx +67 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageCards/index.tsx +19 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageTable.tsx +143 -0
- package/src/app/[variants]/(main)/profile/usage/features/UsageTrends.tsx +107 -0
- package/src/app/[variants]/(main)/profile/usage/features/components/UsageBarChart.tsx +48 -0
- package/src/app/[variants]/(main)/profile/usage/index.tsx +13 -0
- package/src/app/[variants]/(main)/settings/_layout/Desktop/Header.tsx +2 -2
- package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +4 -7
- package/src/app/[variants]/(main)/settings/_layout/DesktopWrapper.tsx +23 -0
- package/src/app/[variants]/(main)/settings/_layout/Mobile/Header.tsx +8 -7
- package/src/app/[variants]/(main)/settings/_layout/Mobile/index.tsx +2 -7
- package/src/app/[variants]/(main)/settings/_layout/MobileWrapper.tsx +23 -0
- package/src/app/[variants]/(main)/settings/_layout/SettingsContent.tsx +1 -12
- package/src/app/[variants]/(main)/settings/_layout/type.ts +0 -1
- package/src/app/[variants]/(main)/settings/agent/AgentMenu/Menu.tsx +2 -4
- package/src/app/[variants]/(main)/settings/agent/index.tsx +13 -14
- package/src/app/[variants]/(main)/settings/common/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/hooks/useCategory.tsx +8 -16
- package/src/app/[variants]/(main)/settings/page.tsx +11 -12
- package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/(list)/index.tsx +2 -3
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/All.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/Item.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/ProviderMenu/List.tsx +97 -7
- 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/[variants]/(main)/settings/provider/_layout/Mobile.tsx +2 -2
- package/src/app/[variants]/(main)/settings/provider/detail/azure/index.tsx +6 -8
- package/src/app/[variants]/(main)/settings/provider/detail/azureai/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/detail/bedrock/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/detail/cloudflare/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/detail/comfyui/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/detail/github/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/detail/index.tsx +4 -0
- package/src/app/[variants]/(main)/settings/provider/detail/vertexai/index.tsx +1 -1
- package/src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx +22 -9
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx +144 -8
- package/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelItem.tsx +74 -97
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx +3 -3
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/index.tsx +4 -8
- package/src/app/[variants]/(main)/settings/provider/features/customProviderSdkOptions.ts +1 -0
- package/src/app/[variants]/(main)/settings/storage/index.tsx +1 -9
- package/src/app/[variants]/(main)/settings/system-agent/index.tsx +1 -2
- package/src/app/[variants]/DesktopClientRouter.tsx +20 -0
- package/src/app/[variants]/DesktopRouter.tsx +20 -0
- package/src/app/[variants]/MobileClientRouter.tsx +20 -0
- package/src/app/[variants]/MobileRouter.tsx +20 -0
- package/src/app/[variants]/desktopRouter.config.tsx +474 -0
- package/src/app/[variants]/layout.tsx +1 -3
- package/src/app/[variants]/loaders/routeParams.ts +45 -0
- package/src/app/[variants]/loading/Server/Redirect.tsx +1 -1
- package/src/app/[variants]/loading/index.tsx +1 -10
- package/src/app/[variants]/mobileRouter.config.tsx +518 -0
- package/src/app/[variants]/oauth/ResultLayout.tsx +47 -0
- package/src/app/[variants]/oauth/callback/error/page.tsx +20 -33
- package/src/app/[variants]/oauth/callback/layout.tsx +1 -0
- package/src/app/[variants]/oauth/callback/success/page.tsx +8 -22
- package/src/app/[variants]/oauth/consent/[uid]/Consent/BuiltinConsent.tsx +47 -0
- package/src/app/[variants]/oauth/consent/[uid]/Consent/index.tsx +198 -0
- package/src/app/[variants]/oauth/consent/[uid]/Login.tsx +19 -4
- package/src/app/[variants]/page.tsx +20 -6
- package/src/app/desktop/devtools/page.tsx +1 -1
- package/src/app/desktop/layout.tsx +1 -1
- package/src/app/market-auth-callback/layout.tsx +39 -0
- package/src/app/market-auth-callback/page.tsx +196 -0
- package/src/components/Analytics/MainInterfaceTracker.tsx +2 -2
- package/src/components/BootErrorBoundary/index.tsx +129 -0
- package/src/components/FileIcon/index.tsx +1 -1
- package/src/components/InvalidAPIKey/APIKeyForm/Bedrock.tsx +8 -13
- package/src/components/InvalidAPIKey/APIKeyForm/useApiKey.ts +0 -12
- package/src/components/Link.tsx +12 -0
- package/src/components/Skeleton/SkeletonSwitch.tsx +13 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/mdx/constants.ts +1 -0
- package/src/config/db.ts +0 -5
- package/src/config/featureFlags/schema.test.ts +1 -5
- package/src/config/featureFlags/schema.ts +0 -9
- package/src/config/modelProviders/ai21.ts +1 -16
- package/src/config/modelProviders/ai302.ts +1 -128
- package/src/config/modelProviders/ai360.ts +1 -32
- package/src/config/modelProviders/aihubmix.ts +1 -0
- package/src/config/modelProviders/anthropic.ts +1 -71
- package/src/config/modelProviders/azure.ts +1 -51
- package/src/config/modelProviders/baichuan.ts +1 -57
- package/src/config/modelProviders/bedrock.ts +1 -276
- package/src/config/modelProviders/cloudflare.ts +1 -64
- package/src/config/modelProviders/deepseek.ts +1 -19
- package/src/config/modelProviders/fireworksai.ts +1 -174
- package/src/config/modelProviders/giteeai.ts +1 -135
- package/src/config/modelProviders/github.ts +1 -254
- package/src/config/modelProviders/google.ts +1 -130
- package/src/config/modelProviders/groq.ts +1 -119
- package/src/config/modelProviders/higress.ts +1 -1713
- package/src/config/modelProviders/huggingface.ts +1 -54
- package/src/config/modelProviders/hunyuan.ts +1 -83
- package/src/config/modelProviders/infiniai.ts +1 -74
- package/src/config/modelProviders/internlm.ts +1 -20
- package/src/config/modelProviders/mistral.ts +1 -95
- package/src/config/modelProviders/modelscope.ts +1 -27
- package/src/config/modelProviders/moonshot.ts +1 -29
- package/src/config/modelProviders/newapi.ts +1 -0
- package/src/config/modelProviders/novita.ts +1 -105
- package/src/config/modelProviders/ollama.ts +1 -325
- package/src/config/modelProviders/openai.ts +1 -242
- package/src/config/modelProviders/openrouter.ts +1 -240
- package/src/config/modelProviders/perplexity.ts +1 -45
- package/src/config/modelProviders/ppio.ts +1 -152
- package/src/config/modelProviders/qiniu.ts +1 -18
- package/src/config/modelProviders/qwen.ts +1 -245
- package/src/config/modelProviders/search1api.ts +1 -34
- package/src/config/modelProviders/sensenova.ts +1 -69
- package/src/config/modelProviders/siliconcloud.ts +1 -417
- package/src/config/modelProviders/spark.ts +1 -59
- package/src/config/modelProviders/stepfun.ts +1 -98
- package/src/config/modelProviders/taichu.ts +1 -18
- package/src/config/modelProviders/togetherai.ts +1 -274
- package/src/config/modelProviders/upstage.ts +1 -28
- package/src/config/modelProviders/wenxin.ts +3 -143
- package/src/config/modelProviders/xai.ts +1 -38
- package/src/config/modelProviders/zeroone.ts +1 -81
- package/src/config/modelProviders/zhipu.ts +1 -108
- package/src/envs/__tests__/app.test.ts +47 -13
- package/src/envs/app.ts +13 -9
- package/src/envs/auth.ts +0 -179
- 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/ChangelogModal/index.tsx +3 -3
- package/src/features/ChatInput/ActionBar/Knowledge/index.tsx +4 -5
- package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +23 -0
- package/src/features/ChatInput/ActionBar/Model/GPT51ReasoningEffortSlider.tsx +58 -0
- package/src/features/ChatInput/ActionBar/Model/ThinkingLevelSlider.tsx +56 -0
- package/src/features/ChatInput/ActionBar/STT/browser.tsx +6 -6
- package/src/features/ChatInput/ActionBar/STT/openai.tsx +6 -6
- package/src/features/ChatInput/ActionBar/Search/index.tsx +5 -7
- package/src/features/ChatInput/ActionBar/Token/TokenTag.tsx +2 -2
- package/src/features/ChatInput/ActionBar/Upload/index.tsx +1 -3
- package/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx +2 -17
- package/src/features/ChatInput/ActionBar/index.tsx +2 -2
- package/src/features/ChatInput/InputEditor/index.tsx +2 -2
- package/src/features/ChatItem/components/MessageContent.tsx +3 -1
- package/src/features/ChatItem/components/Title.tsx +20 -16
- package/src/features/ChatItem/style.ts +4 -0
- package/src/features/Conversation/Error/AccessCodeForm.tsx +1 -1
- package/src/features/Conversation/Error/ChatInvalidApiKey.tsx +1 -1
- package/src/features/Conversation/Error/ClerkLogin/index.tsx +1 -1
- package/src/features/Conversation/Error/OAuthForm.tsx +1 -1
- package/src/features/Conversation/Error/index.tsx +0 -5
- package/src/features/Conversation/MarkdownElements/LobeThinking/Render.tsx +3 -3
- package/src/features/Conversation/MarkdownElements/Thinking/Render.tsx +3 -3
- package/src/features/Conversation/MarkdownElements/remarkPlugins/__snapshots__/createRemarkSelfClosingTagPlugin.test.ts.snap +133 -0
- package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.test.ts +48 -0
- package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.ts +2 -1
- package/src/features/Conversation/Messages/Assistant/Actions/index.tsx +25 -10
- package/src/features/Conversation/Messages/Assistant/CollapsedMessage.tsx +37 -0
- package/src/features/Conversation/Messages/Assistant/Extra/index.test.tsx +4 -9
- package/src/features/Conversation/Messages/Assistant/Extra/index.tsx +8 -9
- package/src/features/Conversation/Messages/Assistant/MessageContent.tsx +23 -36
- package/src/features/Conversation/Messages/Assistant/index.tsx +297 -180
- package/src/features/Conversation/Messages/Default.tsx +1 -0
- package/src/features/Conversation/Messages/Group/Actions/WithContentId.tsx +200 -0
- package/src/features/Conversation/Messages/Group/Actions/WithoutContentId.tsx +93 -0
- package/src/features/Conversation/Messages/Group/Actions/index.tsx +21 -0
- package/src/features/Conversation/Messages/Group/CollapsedMessage.tsx +37 -0
- package/src/features/Conversation/Messages/Group/ContentBlock.tsx +89 -0
- package/src/features/Conversation/Messages/Group/EditState.tsx +51 -0
- package/src/features/Conversation/Messages/Group/Error/index.tsx +54 -0
- package/src/features/Conversation/Messages/Group/Group.tsx +70 -0
- package/src/features/Conversation/Messages/Group/GroupContext.ts +15 -0
- package/src/features/Conversation/Messages/Group/GroupItem.tsx +41 -0
- package/src/features/Conversation/Messages/Group/MessageContent.tsx +45 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/BuiltinPluginTitle.tsx +58 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/Debug.tsx +70 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/PluginResult.tsx +34 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/PluginState.tsx +18 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/StatusIndicator.tsx +41 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/ToolTitle.tsx +100 -0
- package/src/features/Conversation/Messages/Group/Tool/Inspector/index.tsx +221 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/AbortResponse.tsx +37 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Arguments/index.tsx +136 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/CustomRender.tsx +88 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ApprovalActions.tsx +164 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/Fallback.tsx +98 -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 +133 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/index.tsx +103 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/LoadingPlaceholder/index.tsx +29 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/PluginSettings.tsx +66 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/RejectedResponse.tsx +45 -0
- package/src/features/Conversation/Messages/Group/Tool/Render/index.tsx +140 -0
- package/src/features/Conversation/Messages/Group/Tool/index.tsx +98 -0
- package/src/features/Conversation/Messages/Group/Tools.tsx +48 -0
- package/src/features/Conversation/Messages/Group/index.tsx +210 -0
- package/src/features/Conversation/Messages/Supervisor/index.tsx +14 -5
- package/src/features/Conversation/Messages/Tool/Inspector/PluginResult.tsx +39 -0
- package/src/features/Conversation/Messages/Tool/Inspector/PluginState.tsx +23 -0
- package/src/features/Conversation/Messages/Tool/Inspector/Settings.tsx +40 -0
- package/src/features/Conversation/Messages/Tool/Inspector/ToolTitle.tsx +88 -0
- package/src/features/Conversation/Messages/Tool/Inspector/index.tsx +134 -0
- package/src/features/Conversation/Messages/Tool/Render/Arguments/ObjectEntity.tsx +81 -0
- package/src/features/Conversation/Messages/Tool/Render/Arguments/ValueCell.tsx +43 -0
- package/src/features/Conversation/Messages/Tool/Render/CustomRender.tsx +144 -0
- package/src/features/Conversation/Messages/Tool/Render/ErrorResponse.tsx +35 -0
- package/src/features/Conversation/Messages/Tool/Render/PluginSettings.tsx +69 -0
- package/src/features/Conversation/Messages/Tool/Render/index.tsx +46 -0
- package/src/features/Conversation/Messages/Tool/ToolItem.tsx +51 -0
- package/src/features/Conversation/Messages/Tool/index.tsx +58 -0
- package/src/features/Conversation/Messages/User/Actions/ActionsBar.tsx +159 -0
- package/src/features/Conversation/Messages/User/Actions/MessageBranch.tsx +107 -0
- package/src/features/Conversation/Messages/User/Actions/index.tsx +42 -0
- package/src/features/Conversation/Messages/User/index.tsx +59 -54
- package/src/features/Conversation/Messages/index.tsx +42 -19
- package/src/features/Conversation/components/AutoScroll.tsx +4 -4
- package/src/features/Conversation/components/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/Conversation/components/Extras/Usage/UsageDetail/AnimatedNumber.tsx +55 -0
- package/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx +43 -10
- package/src/features/Conversation/components/Extras/Usage/UsageDetail/tokens.ts +2 -5
- package/src/features/Conversation/components/Extras/Usage/index.tsx +13 -6
- package/src/features/Conversation/components/ShareMessageModal/ShareImage/Preview.tsx +2 -2
- package/src/features/Conversation/components/ShareMessageModal/index.tsx +3 -8
- package/src/features/Conversation/components/VirtualizedList/VirtuosoContext.ts +13 -13
- package/src/features/Conversation/components/VirtualizedList/index.tsx +98 -54
- package/src/features/Conversation/components/WideScreenContainer/index.tsx +10 -6
- package/src/features/Conversation/hooks/useChatListActionsBar.tsx +40 -14
- package/src/features/Conversation/hooks/useDoubleClickEdit.ts +3 -3
- package/src/features/DataImporter/index.tsx +16 -61
- package/src/features/DevPanel/PostgresViewer/usePgTable.ts +5 -12
- package/src/features/FileSidePanel/index.tsx +1 -1
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/MasonryItem.tsx +80 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/Item/MasonryItemWrapper.tsx +27 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/List.tsx +104 -23
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/MasonrySkeleton.tsx +62 -0
- package/src/features/KnowledgeBaseModal/AssignKnowledgeBase/index.tsx +3 -2
- package/src/features/KnowledgeBaseModal/CreateNew/CreateForm.tsx +1 -1
- package/src/features/KnowledgeManager/DocumentExplorer/DocumentActions.tsx +111 -0
- package/src/features/KnowledgeManager/DocumentExplorer/DocumentEditor.tsx +723 -0
- package/src/features/KnowledgeManager/DocumentExplorer/DocumentEditorPlaceholder.tsx +169 -0
- package/src/features/KnowledgeManager/DocumentExplorer/DocumentListItem.tsx +148 -0
- package/src/features/KnowledgeManager/DocumentExplorer/DocumentListSkeleton.tsx +39 -0
- package/src/features/KnowledgeManager/DocumentExplorer/NoteEditorModal.tsx +348 -0
- package/src/features/KnowledgeManager/DocumentExplorer/RenamePopover.tsx +163 -0
- package/src/features/KnowledgeManager/DocumentExplorer/index.tsx +318 -0
- package/src/features/KnowledgeManager/FileExplorer/FileListItem/index.tsx +270 -0
- package/src/features/KnowledgeManager/FileExplorer/MasonryFileItem/DefaultFileItem.tsx +149 -0
- package/src/features/KnowledgeManager/FileExplorer/MasonryFileItem/ImageFileItem.tsx +245 -0
- package/src/features/KnowledgeManager/FileExplorer/MasonryFileItem/MarkdownFileItem.tsx +232 -0
- package/src/features/KnowledgeManager/FileExplorer/MasonryFileItem/NoteFileItem.tsx +230 -0
- package/src/features/KnowledgeManager/FileExplorer/MasonryFileItem/index.tsx +398 -0
- package/src/features/KnowledgeManager/FileExplorer/ToolBar/ViewSwitcher.tsx +45 -0
- package/src/features/KnowledgeManager/FileExplorer/index.tsx +305 -0
- package/src/features/KnowledgeManager/Header/AddButton.tsx +118 -0
- package/src/features/KnowledgeManager/Header/FilesSearchBar.tsx +45 -0
- package/src/features/KnowledgeManager/Header/NewNoteButton.tsx +33 -0
- package/src/features/KnowledgeManager/Header/index.tsx +21 -0
- package/src/features/KnowledgeManager/Home/RecentDocumentCard.tsx +116 -0
- package/src/features/KnowledgeManager/Home/RecentDocuments.tsx +77 -0
- package/src/features/KnowledgeManager/Home/RecentFileCard.tsx +121 -0
- package/src/features/KnowledgeManager/Home/RecentFiles.tsx +73 -0
- package/src/features/KnowledgeManager/Home/RecentFilesSkeleton.tsx +81 -0
- package/src/features/KnowledgeManager/Home/UploadEntries.tsx +208 -0
- package/src/features/KnowledgeManager/Home/index.tsx +221 -0
- package/src/features/KnowledgeManager/index.tsx +75 -0
- package/src/features/LocalFile/LocalFile.tsx +55 -5
- package/src/features/MCP/utils.test.ts +91 -0
- package/src/features/MCP/utils.ts +20 -2
- package/src/features/ModelSwitchPanel/index.tsx +9 -25
- package/src/features/PluginStore/Content.tsx +2 -3
- package/src/features/PluginStore/McpList/index.tsx +6 -2
- package/src/features/PluginTag/PluginStatus.tsx +1 -1
- package/src/features/PluginsUI/Render/BuiltinType/index.test.tsx +10 -4
- package/src/features/PluginsUI/Render/BuiltinType/index.tsx +3 -3
- package/src/features/PluginsUI/Render/MCPType/index.tsx +72 -0
- package/src/features/PluginsUI/Render/StandaloneType/Iframe.tsx +5 -5
- package/src/features/PluginsUI/Render/index.tsx +17 -0
- package/src/features/Portal/Artifacts/Body/Renderer/SVG.tsx +23 -6
- package/src/features/Portal/FilePreview/Body/index.tsx +1 -1
- package/src/features/Portal/FilePreview/Header.tsx +1 -1
- package/src/features/Portal/GroupThread/Body/index.tsx +1 -1
- package/src/features/Portal/Home/Body/Plugins/ArtifactList/index.tsx +3 -3
- package/src/features/Portal/Thread/Chat/ChatInput/useSend.ts +3 -3
- package/src/features/ShareModal/ShareImage/Preview.tsx +2 -2
- package/src/features/ShareModal/ShareImage/index.tsx +15 -1
- package/src/features/ShareModal/ShareImage/type.ts +6 -0
- package/src/features/ShareModal/ShareJSON/index.tsx +2 -2
- package/src/features/ShareModal/ShareText/index.tsx +3 -3
- package/src/features/ShareModal/index.tsx +7 -13
- package/src/features/ShareModal/style.ts +40 -30
- package/src/features/User/UserPanel/PanelContent.tsx +8 -9
- package/src/features/User/UserPanel/useMenu.tsx +20 -14
- package/src/features/User/__tests__/PanelContent.test.tsx +13 -7
- package/src/helpers/isCanUseFC.ts +0 -8
- package/src/hooks/useAgentOwnershipCheck.ts +143 -0
- package/src/hooks/useCheckPluginsIsInstalled.ts +1 -4
- package/src/hooks/useDiscoverTab.ts +2 -2
- package/src/hooks/useEnabledChatModels.ts +0 -8
- package/src/hooks/useFetchGroups.ts +1 -4
- package/src/hooks/useFetchInstalledPlugins.ts +1 -4
- package/src/hooks/useFetchMessages.ts +1 -4
- package/src/hooks/useFetchSessions.ts +1 -4
- package/src/hooks/useFetchThreads.ts +1 -5
- package/src/hooks/useFetchTopics.ts +1 -4
- package/src/hooks/useHotkeys/chatScope.ts +16 -8
- package/src/hooks/useInterceptingRoutes.test.ts +22 -26
- package/src/hooks/useInterceptingRoutes.ts +6 -11
- package/src/hooks/useModelContextWindowTokens.ts +0 -8
- package/src/hooks/useModelHasContextWindowToken.ts +1 -10
- package/src/hooks/useModelSupportFiles.ts +1 -11
- package/src/hooks/useModelSupportReasoning.ts +1 -11
- package/src/hooks/useModelSupportToolUse.ts +1 -11
- package/src/hooks/useModelSupportVision.ts +1 -11
- package/src/hooks/usePinnedAgentState.ts +6 -6
- package/src/hooks/useQuery.ts +5 -0
- package/src/hooks/useQueryParam.ts +322 -0
- package/src/hooks/useQueryRoute.test.ts +2 -12
- package/src/hooks/useQueryRoute.ts +5 -5
- package/src/hooks/useScreenshot.ts +44 -28
- package/src/hooks/useShowMobileWorkspace.ts +1 -1
- package/src/hooks/useSwitchSession.ts +4 -3
- package/src/instrumentation.node.ts +3 -2
- package/src/layout/AuthProvider/Clerk/index.tsx +2 -16
- 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/layout/GlobalProvider/ImportSettings.tsx +22 -9
- package/src/layout/GlobalProvider/StoreInitialization.tsx +2 -5
- package/src/libs/mcp/__tests__/__snapshots__/index.test.ts.snap +0 -6
- package/src/libs/mcp/__tests__/index.test.ts +6 -6
- package/src/libs/mcp/client.ts +3 -2
- package/src/libs/mcp/types.ts +71 -0
- package/src/libs/next-auth/auth.config.ts +3 -6
- package/src/libs/next-auth/sso-providers/auth0.ts +0 -7
- package/src/libs/next-auth/sso-providers/authelia.ts +3 -5
- package/src/libs/next-auth/sso-providers/authentik.ts +0 -7
- package/src/libs/next-auth/sso-providers/cloudflare-zero-trust.ts +3 -6
- package/src/libs/next-auth/sso-providers/cognito.ts +1 -5
- package/src/libs/next-auth/sso-providers/generic-oidc.ts +3 -5
- package/src/libs/next-auth/sso-providers/github.ts +0 -6
- package/src/libs/next-auth/sso-providers/google.ts +0 -2
- package/src/libs/next-auth/sso-providers/keycloak.ts +0 -3
- package/src/libs/next-auth/sso-providers/logto.ts +3 -5
- package/src/libs/next-auth/sso-providers/okta.ts +0 -4
- package/src/libs/next-auth/sso-providers/zitadel.ts +0 -7
- package/src/libs/trpc/client/index.ts +0 -1
- package/src/libs/trpc/client/lambda.ts +14 -8
- package/src/libs/trpc/lambda/context.ts +4 -1
- package/src/libs/trpc/lambda/index.ts +5 -2
- package/src/libs/trpc/middleware/openTelemetry.ts +141 -0
- package/src/libs/trpc/utils/request-adapter.ts +20 -0
- package/src/locales/default/auth.ts +44 -0
- package/src/locales/default/chat.ts +37 -0
- package/src/locales/default/common.ts +3 -0
- package/src/locales/default/components.ts +6 -0
- package/src/locales/default/discover.ts +46 -0
- package/src/locales/default/error.ts +2 -2
- package/src/locales/default/file.ts +87 -2
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/labs.ts +4 -0
- package/src/locales/default/marketAuth.ts +42 -0
- package/src/locales/default/modelProvider.ts +16 -2
- package/src/locales/default/oauth.ts +1 -0
- package/src/locales/default/plugin.ts +10 -1
- package/src/locales/default/setting.ts +94 -1
- package/src/locales/default/tool.ts +19 -0
- package/src/locales/default/topic.ts +1 -0
- package/src/proxy.ts +13 -1
- package/src/server/globalConfig/genServerAiProviderConfig.test.ts +5 -5
- package/src/server/globalConfig/genServerAiProviderConfig.ts +1 -1
- package/src/server/globalConfig/index.ts +0 -23
- package/src/server/modules/ContentChunk/index.test.ts +372 -0
- package/src/server/modules/S3/index.test.ts +379 -0
- package/src/server/routers/async/__tests__/caller.test.ts +333 -0
- package/src/server/routers/async/caller.ts +2 -1
- package/src/server/routers/desktop/mcp.ts +22 -11
- package/src/server/routers/lambda/__tests__/aiChat.test.ts +1 -1
- package/src/server/routers/lambda/__tests__/file.test.ts +85 -6
- package/src/server/routers/lambda/__tests__/integration/message.integration.test.ts +771 -57
- package/src/server/routers/lambda/aiChat.ts +3 -2
- package/src/server/routers/lambda/config/__snapshots__/index.test.ts.snap +175 -12
- package/src/server/routers/lambda/config/index.test.ts +38 -30
- package/src/server/routers/lambda/document.ts +57 -0
- package/src/server/routers/lambda/file.ts +89 -2
- package/src/server/routers/lambda/index.ts +2 -0
- package/src/server/routers/lambda/knowledge.ts +94 -0
- package/src/server/routers/lambda/market/index.ts +38 -14
- package/src/server/routers/lambda/message.ts +52 -60
- package/src/server/routers/lambda/topic.ts +7 -1
- package/src/server/routers/lambda/usage.ts +36 -0
- package/src/server/routers/lambda/user.ts +32 -31
- package/src/server/routers/mobile/index.ts +14 -2
- package/src/server/routers/tools/mcp.ts +24 -7
- package/src/server/routers/tools/search.test.ts +1 -7
- package/src/server/routers/tools/search.ts +1 -4
- package/src/server/services/discover/index.test.ts +153 -11
- package/src/server/services/discover/index.ts +339 -40
- package/src/server/services/document/index.ts +103 -0
- package/src/server/services/file/impls/local.ts +4 -1
- package/src/server/services/file/index.ts +96 -1
- package/src/server/services/mcp/contentProcessor.ts +101 -0
- package/src/server/services/mcp/deps/MCPSystemDepsCheckService.test.ts +541 -0
- package/src/server/services/mcp/deps/checkers/ManualInstallationChecker.test.ts +162 -0
- package/src/server/services/mcp/deps/checkers/NpmInstallationChecker.test.ts +374 -0
- package/src/server/services/mcp/deps/checkers/PythonInstallationChecker.test.ts +368 -0
- package/src/server/services/mcp/index.test.ts +80 -25
- package/src/server/services/mcp/index.ts +37 -23
- package/src/server/services/message/__tests__/index.test.ts +338 -0
- package/src/server/services/message/index.ts +187 -0
- package/src/server/services/oidc/index.test.ts +232 -0
- package/src/server/services/oidc/index.ts +24 -0
- package/src/server/services/usage/index.test.ts +310 -0
- package/src/server/services/usage/index.ts +164 -0
- package/src/server/sitemap.ts +49 -35
- package/src/server/utils/createSpeechResponse.ts +55 -0
- package/src/services/__tests__/tool.test.ts +0 -3
- package/src/services/__tests__/upload.test.ts +92 -82
- package/src/services/_auth.ts +2 -11
- package/src/services/_header.ts +2 -10
- package/src/services/_url.ts +15 -1
- package/src/services/aiModel/index.test.ts +3 -6
- package/src/services/aiModel/index.ts +55 -7
- package/src/services/aiProvider/index.test.ts +2 -5
- package/src/services/aiProvider/index.ts +47 -7
- package/src/services/chat/chat.test.ts +68 -12
- package/src/services/chat/clientModelRuntime.test.ts +109 -173
- package/src/services/chat/contextEngineering.test.ts +4 -0
- package/src/services/chat/contextEngineering.ts +8 -7
- package/src/services/chat/helper.ts +7 -31
- package/src/services/chat/index.ts +20 -9
- package/src/services/chat/types.ts +1 -2
- package/src/services/chatGroup/index.ts +64 -9
- package/src/services/config.ts +2 -66
- package/src/services/discover.ts +28 -17
- package/src/services/document/index.ts +44 -0
- package/src/services/electron/desktopNotification.ts +6 -6
- package/src/services/electron/file.ts +6 -6
- package/src/services/electron/localFileService.ts +4 -0
- package/src/services/electron/remoteServer.ts +8 -1
- package/src/services/export/index.ts +9 -4
- package/src/services/file/index.ts +70 -10
- package/src/services/import/index.ts +132 -7
- package/src/services/marketApi.ts +124 -0
- package/src/services/mcp.test.ts +783 -0
- package/src/services/mcp.ts +39 -4
- package/src/services/message/__tests__/metadata-race-condition.test.ts +157 -0
- package/src/services/message/index.ts +235 -10
- package/src/services/message/server.test.ts +44 -0
- package/src/services/models.ts +4 -12
- package/src/services/plugin/index.test.ts +8 -0
- package/src/services/plugin/index.ts +51 -10
- package/src/services/search.ts +2 -2
- package/src/services/session/index.test.ts +8 -0
- package/src/services/session/index.ts +129 -10
- package/src/services/tableViewer/client.ts +12 -15
- package/src/services/thread/index.test.ts +8 -0
- package/src/services/thread/index.ts +37 -7
- package/src/services/topic/index.test.ts +8 -0
- package/src/services/topic/index.ts +74 -10
- package/src/services/upload.ts +14 -43
- package/src/services/usage.ts +13 -0
- package/src/services/user/index.test.ts +8 -0
- package/src/services/user/index.ts +50 -11
- package/src/services/utils/abortableRequest.test.ts +161 -0
- package/src/services/utils/abortableRequest.ts +67 -0
- package/src/store/aiInfra/slices/aiModel/action.test.ts +17 -9
- package/src/store/aiInfra/slices/aiProvider/__tests__/action.test.ts +125 -229
- package/src/store/aiInfra/slices/aiProvider/__tests__/selectors.test.ts +62 -0
- package/src/store/aiInfra/slices/aiProvider/action.ts +116 -37
- package/src/store/aiInfra/slices/aiProvider/selectors.ts +1 -1
- package/src/store/chat/agents/GeneralChatAgent.ts +377 -0
- package/src/store/chat/agents/__tests__/GeneralChatAgent.test.ts +1144 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/call-llm.test.ts +1217 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/call-tool.test.ts +1976 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/finish.test.ts +453 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/index.ts +4 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockInstructions.ts +126 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockMessages.ts +94 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockOperations.ts +96 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/fixtures/mockStore.ts +138 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/helpers/assertions.ts +185 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/helpers/index.ts +3 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/helpers/operationTestUtils.ts +94 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/helpers/testExecutor.ts +139 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/request-human-approve.test.ts +545 -0
- package/src/store/chat/agents/__tests__/createAgentExecutors/resolve-aborted-tools.test.ts +686 -0
- package/src/store/chat/agents/createAgentExecutors.ts +761 -0
- package/src/store/chat/agents/createToolEngine.ts +22 -0
- package/src/store/chat/helpers.test.ts +0 -99
- package/src/store/chat/helpers.ts +0 -11
- package/src/store/chat/initialState.ts +4 -1
- package/src/store/chat/selectors.ts +1 -0
- package/src/store/chat/slices/aiChat/__tests__/ai-chat.integration.test.ts +667 -0
- package/src/store/chat/slices/aiChat/actions/__tests__/cancel-functionality.test.ts +137 -27
- package/src/store/chat/slices/aiChat/actions/__tests__/conversationControl.test.ts +370 -0
- package/src/store/chat/slices/aiChat/actions/__tests__/conversationLifecycle.test.ts +267 -0
- package/src/store/chat/slices/aiChat/actions/__tests__/fixtures.ts +0 -2
- package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +19 -8
- package/src/store/chat/slices/aiChat/actions/__tests__/rag.test.ts +6 -6
- package/src/store/chat/slices/aiChat/actions/__tests__/streamingExecutor.test.ts +876 -0
- package/src/store/chat/slices/aiChat/actions/__tests__/streamingStates.test.ts +67 -0
- package/src/store/chat/slices/aiChat/actions/conversationControl.ts +220 -0
- package/src/store/chat/slices/aiChat/actions/conversationLifecycle.ts +421 -0
- package/src/store/chat/slices/aiChat/actions/generateAIGroupChat.ts +24 -39
- package/src/store/chat/slices/aiChat/actions/index.ts +12 -6
- package/src/store/chat/slices/aiChat/actions/rag.ts +9 -6
- package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +898 -0
- package/src/store/chat/slices/aiChat/actions/streamingStates.ts +50 -0
- package/src/store/chat/slices/aiChat/initialState.ts +0 -28
- package/src/store/chat/slices/aiChat/selectors.test.ts +280 -0
- package/src/store/chat/slices/aiChat/selectors.ts +31 -7
- package/src/store/chat/slices/builtinTool/actions/__tests__/localSystem.test.ts +29 -39
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +221 -47
- package/src/store/chat/slices/builtinTool/actions/interpreter.ts +86 -51
- package/src/store/chat/slices/builtinTool/actions/localSystem.ts +116 -203
- package/src/store/chat/slices/builtinTool/actions/search.ts +170 -58
- package/src/store/chat/slices/builtinTool/selectors.test.ts +258 -0
- package/src/store/chat/slices/builtinTool/selectors.ts +25 -4
- package/src/store/chat/slices/message/action.test.ts +482 -63
- package/src/store/chat/slices/message/actions/index.ts +39 -0
- package/src/store/chat/slices/message/actions/internals.ts +103 -0
- package/src/store/chat/slices/message/actions/optimisticUpdate.ts +343 -0
- package/src/store/chat/slices/message/actions/publicApi.ts +276 -0
- package/src/store/chat/slices/message/actions/query.ts +122 -0
- package/src/store/chat/slices/message/actions/runtimeState.ts +108 -0
- package/src/store/chat/slices/message/initialState.ts +8 -0
- package/src/store/chat/slices/message/reducer.test.ts +48 -370
- package/src/store/chat/slices/message/reducer.ts +19 -82
- package/src/store/chat/slices/message/selectors/chat.test.ts +22 -639
- package/src/store/chat/slices/message/selectors/chat.ts +77 -243
- package/src/store/chat/slices/message/selectors/dbMessage.test.ts +51 -0
- package/src/store/chat/slices/message/selectors/dbMessage.ts +147 -0
- package/src/store/chat/slices/message/selectors/displayMessage.test.ts +818 -0
- package/src/store/chat/slices/message/selectors/displayMessage.ts +352 -0
- package/src/store/chat/slices/message/selectors/messageState.ts +46 -12
- package/src/store/chat/slices/operation/__tests__/actions.test.ts +1049 -0
- package/src/store/chat/slices/operation/__tests__/integration.test.ts +342 -0
- package/src/store/chat/slices/operation/__tests__/selectors.test.ts +513 -0
- package/src/store/chat/slices/operation/actions.ts +658 -0
- package/src/store/chat/slices/operation/index.ts +4 -0
- package/src/store/chat/slices/operation/initialState.ts +44 -0
- package/src/store/chat/slices/operation/selectors.ts +375 -0
- package/src/store/chat/slices/operation/types.ts +160 -0
- package/src/store/chat/slices/plugin/action.test.ts +320 -352
- package/src/store/chat/slices/plugin/actions/index.ts +39 -0
- package/src/store/chat/slices/plugin/actions/internals.ts +69 -0
- package/src/store/chat/slices/plugin/actions/optimisticUpdate.ts +252 -0
- package/src/store/chat/slices/plugin/actions/pluginTypes.ts +264 -0
- package/src/store/chat/slices/plugin/actions/publicApi.ts +119 -0
- package/src/store/chat/slices/plugin/actions/workflow.ts +77 -0
- package/src/store/chat/slices/portal/selectors.test.ts +7 -7
- package/src/store/chat/slices/portal/selectors.ts +2 -2
- package/src/store/chat/slices/thread/action.test.ts +38 -32
- package/src/store/chat/slices/thread/action.ts +19 -12
- package/src/store/chat/slices/thread/selectors/index.ts +12 -8
- package/src/store/chat/slices/topic/action.test.ts +1 -1
- package/src/store/chat/slices/topic/action.ts +4 -5
- package/src/store/chat/slices/topic/reducer.ts +12 -5
- package/src/store/chat/slices/translate/action.test.ts +26 -32
- package/src/store/chat/slices/translate/action.ts +57 -44
- package/src/store/chat/store.ts +6 -3
- package/src/store/discover/slices/assistant/action.ts +20 -7
- package/src/store/file/initialState.ts +6 -1
- package/src/store/file/slices/chat/action.ts +3 -6
- package/src/store/file/slices/document/action.ts +359 -0
- package/src/store/file/slices/document/index.ts +3 -0
- package/src/store/file/slices/document/initialState.ts +22 -0
- package/src/store/file/slices/document/selectors.ts +25 -0
- package/src/store/file/slices/fileManager/action.test.ts +16 -9
- package/src/store/file/slices/fileManager/action.ts +12 -13
- package/src/store/file/store.ts +3 -0
- package/src/store/global/action.test.ts +3 -3
- package/src/store/global/actions/workspacePane.ts +2 -1
- package/src/store/global/initialState.ts +16 -3
- package/src/store/global/selectors/systemStatus.test.ts +0 -98
- package/src/store/global/selectors/systemStatus.ts +9 -30
- package/src/store/global/store.ts +1 -7
- package/src/store/serverConfig/selectors.test.ts +2 -2
- package/src/store/serverConfig/store.test.ts +0 -1
- package/src/store/session/slices/sessionGroup/action.test.ts +5 -5
- package/src/store/tool/slices/mcpStore/action.test.ts +95 -3
- package/src/store/tool/slices/mcpStore/action.ts +177 -53
- package/src/store/tool/slices/oldStore/initialState.ts +1 -2
- package/src/store/user/initialState.ts +1 -7
- package/src/store/user/selectors.ts +2 -5
- package/src/store/user/slices/common/action.test.ts +1 -4
- package/src/store/user/slices/common/action.ts +9 -4
- package/src/store/user/slices/preference/action.ts +8 -1
- package/src/store/user/slices/preference/selectors/index.ts +2 -0
- package/src/store/user/slices/preference/selectors/labPrefer.ts +10 -0
- package/src/store/user/slices/preference/selectors/preference.ts +32 -0
- package/src/store/user/slices/settings/action.ts +27 -0
- package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +0 -7
- package/src/store/user/slices/settings/selectors/index.ts +2 -0
- package/src/store/user/slices/settings/selectors/keyVaults.ts +21 -0
- package/src/store/user/slices/settings/selectors/settings.test.ts +0 -37
- package/src/store/user/slices/settings/selectors/settings.ts +0 -5
- package/src/store/user/slices/settings/selectors/toolIntervention.ts +17 -0
- package/src/store/user/store.ts +0 -3
- package/src/tools/code-interpreter/Render/index.tsx +1 -1
- package/src/tools/executionRuntimes.ts +3 -0
- package/src/tools/interventions.ts +30 -0
- package/src/tools/local-system/ExecutionRuntime/index.ts +407 -0
- package/src/tools/local-system/Intervention/EditLocalFile/index.tsx +89 -0
- package/src/tools/local-system/Intervention/MoveLocalFiles/MoveFileItem.tsx +56 -0
- package/src/tools/local-system/Intervention/MoveLocalFiles/index.tsx +26 -0
- package/src/tools/local-system/Intervention/RunCommand/index.tsx +54 -0
- package/src/tools/local-system/Intervention/WriteFile/index.tsx +72 -0
- package/src/tools/local-system/Intervention/index.ts +15 -0
- package/src/tools/local-system/Placeholder/ListFiles.tsx +3 -5
- package/src/tools/local-system/Placeholder/SearchFiles.tsx +2 -5
- package/src/tools/local-system/Render/EditLocalFile/index.tsx +67 -0
- package/src/tools/local-system/Render/ListFiles/index.tsx +16 -21
- package/src/tools/local-system/Render/MoveLocalFiles/MoveFileItem.tsx +56 -0
- package/src/tools/local-system/Render/MoveLocalFiles/index.tsx +26 -0
- package/src/tools/local-system/Render/ReadLocalFile/ReadFileView.tsx +55 -79
- package/src/tools/local-system/Render/RenameLocalFile/index.tsx +15 -20
- package/src/tools/local-system/Render/RunCommand/index.tsx +103 -27
- package/src/tools/local-system/Render/SearchFiles/SearchQuery/index.tsx +0 -1
- package/src/tools/local-system/Render/SearchFiles/index.tsx +15 -20
- package/src/tools/local-system/Render/WriteFile/index.tsx +2 -8
- package/src/tools/local-system/Render/index.ts +23 -0
- package/src/tools/local-system/index.ts +186 -4
- package/src/tools/local-system/systemRole.ts +62 -8
- package/src/tools/local-system/type.ts +4 -3
- package/src/tools/placeholders.ts +39 -8
- package/src/tools/renders.ts +35 -6
- package/src/tools/web-browsing/ExecutionRuntime/index.ts +5 -2
- package/src/tools/web-browsing/Placeholder/CrawlMultiPages.tsx +30 -0
- package/src/tools/web-browsing/Placeholder/CrawlSinglePage.tsx +12 -0
- package/src/tools/web-browsing/Placeholder/Search.tsx +4 -4
- package/src/tools/web-browsing/Portal/Search/Footer.tsx +11 -9
- package/src/tools/web-browsing/Render/CrawlMultiPages.tsx +15 -0
- package/src/tools/web-browsing/Render/CrawlSinglePage.tsx +15 -0
- package/src/tools/web-browsing/Render/Search/ConfigForm/Form.tsx +1 -1
- package/src/tools/web-browsing/Render/Search/index.tsx +39 -44
- package/src/tools/web-browsing/Render/index.ts +13 -0
- package/src/utils/electron/desktopRemoteRPCFetch.ts +87 -0
- package/src/utils/server/parseModels.ts +212 -0
- package/src/utils/server/routeVariants.test.ts +340 -0
- package/src/utils/server/routeVariants.ts +10 -10
- package/tsconfig.json +0 -1
- package/vitest.config.mts +2 -0
- package/Dockerfile.lite +0 -272
- package/packages/context-engine/ARCHITECTURE.md +0 -425
- package/packages/database/src/models/__tests__/message.grouping.test.ts +0 -812
- package/packages/database/src/models/__tests__/message.test.ts +0 -2704
- package/packages/database/src/schemas/document.ts +0 -106
- package/packages/database/src/utils/__tests__/groupMessages.test.ts +0 -1132
- package/packages/database/src/utils/groupMessages.ts +0 -361
- package/packages/model-runtime/src/utils/imageToBase64.test.ts +0 -91
- package/packages/model-runtime/src/utils/imageToBase64.ts +0 -62
- package/packages/utils/src/_deprecated/__snapshots__/parseModels.test.ts.snap +0 -104
- package/packages/utils/src/_deprecated/parseModels.test.ts +0 -287
- package/packages/utils/src/_deprecated/parseModels.ts +0 -165
- package/packages/utils/src/electron/desktopRemoteRPCFetch.ts +0 -87
- package/packages/utils/src/fetch/__tests__/fetchSSE.test.ts +0 -579
- package/packages/utils/src/fetch/__tests__/parseError.test.ts +0 -88
- package/packages/utils/src/fetch/fetchSSE.ts +0 -477
- package/packages/utils/src/fetch/headers.ts +0 -27
- package/packages/utils/src/fetch/parseError.ts +0 -24
- package/packages/utils/src/fetch/request.ts +0 -28
- package/packages/utils/src/parseModels.ts +0 -213
- package/packages/utils/src/tokenizer/client.ts +0 -35
- package/packages/utils/src/tokenizer/estimated.ts +0 -4
- package/packages/utils/src/tokenizer/server.ts +0 -11
- package/packages/utils/src/tokenizer/tokenizer.worker.ts +0 -12
- package/src/app/(backend)/trpc/edge/[trpc]/route.ts +0 -26
- package/src/app/(backend)/webapi/chat/azureai/route.test.ts +0 -25
- package/src/app/(backend)/webapi/chat/azureai/route.ts +0 -6
- package/src/app/(backend)/webapi/tokenizer/index.test.ts +0 -32
- package/src/app/(backend)/webapi/tokenizer/route.ts +0 -8
- package/src/app/[variants]/(main)/(mobile)/me/(home)/loading.tsx +0 -38
- package/src/app/[variants]/(main)/(mobile)/me/(home)/page.tsx +0 -40
- package/src/app/[variants]/(main)/(mobile)/me/data/features/Category.tsx +0 -48
- package/src/app/[variants]/(main)/(mobile)/me/data/features/Header.tsx +0 -33
- package/src/app/[variants]/(main)/(mobile)/me/data/layout.tsx +0 -13
- package/src/app/[variants]/(main)/(mobile)/me/data/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/data/page.tsx +0 -29
- package/src/app/[variants]/(main)/(mobile)/me/profile/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/profile/page.tsx +0 -30
- package/src/app/[variants]/(main)/(mobile)/me/settings/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/settings/page.tsx +0 -30
- package/src/app/[variants]/(main)/_layout/Desktop/DesktopLayoutContainer.tsx +0 -32
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/BottomActions.tsx +0 -46
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/PinList/index.tsx +0 -119
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/TopActions.test.tsx +0 -141
- package/src/app/[variants]/(main)/_layout/Desktop/SideBar/TopActions.tsx +0 -109
- package/src/app/[variants]/(main)/_layout/Desktop/index.tsx +0 -68
- package/src/app/[variants]/(main)/_layout/Mobile/NavBar.tsx +0 -88
- package/src/app/[variants]/(main)/_layout/Mobile/index.tsx +0 -43
- package/src/app/[variants]/(main)/changelog/layout.tsx +0 -10
- package/src/app/[variants]/(main)/changelog/modal/page.tsx +0 -23
- package/src/app/[variants]/(main)/changelog/page.tsx +0 -78
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatHydration/index.tsx +0 -42
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/MessageFromUrl.tsx +0 -32
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +0 -17
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/V1Mobile/index.tsx +0 -89
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/V1Mobile/useSend.ts +0 -104
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/useSend.ts +0 -321
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/Thread.tsx +0 -62
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/ChatItem/index.tsx +0 -91
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx +0 -43
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/AgentWelcome/OpeningQuestions.tsx +0 -75
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatList/WelcomeChatItem/GroupWelcome/GroupUsageSuggest.tsx +0 -164
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatMinimap/index.tsx +0 -385
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ThreadHydration.tsx +0 -45
- package/src/app/[variants]/(main)/chat/(workspace)/@topic/features/Topic/TopicListContent/TopicItem/TopicContent.tsx +0 -241
- package/src/app/[variants]/(main)/chat/(workspace)/layout.ts +0 -11
- package/src/app/[variants]/(main)/chat/(workspace)/page.tsx +0 -53
- package/src/app/[variants]/(main)/chat/@session/_layout/Mobile/SessionHeader.tsx +0 -44
- package/src/app/[variants]/(main)/chat/@session/default.tsx +0 -31
- package/src/app/[variants]/(main)/chat/@session/features/SessionHydration.tsx +0 -45
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/Inbox/index.tsx +0 -63
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/Actions.tsx +0 -229
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/index.tsx +0 -158
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/index.tsx +0 -100
- package/src/app/[variants]/(main)/chat/error.tsx +0 -3
- package/src/app/[variants]/(main)/chat/features/Migration/DBReader.ts +0 -290
- package/src/app/[variants]/(main)/chat/features/Migration/ExportConfigButton.tsx +0 -35
- package/src/app/[variants]/(main)/chat/features/Migration/Failed.tsx +0 -120
- package/src/app/[variants]/(main)/chat/features/Migration/Modal.tsx +0 -81
- package/src/app/[variants]/(main)/chat/features/Migration/Start.tsx +0 -108
- package/src/app/[variants]/(main)/chat/features/Migration/UpgradeButton.tsx +0 -71
- package/src/app/[variants]/(main)/chat/features/Migration/const.ts +0 -15
- package/src/app/[variants]/(main)/chat/features/Migration/index.tsx +0 -50
- package/src/app/[variants]/(main)/chat/layout.ts +0 -11
- package/src/app/[variants]/(main)/chat/loading.tsx +0 -3
- package/src/app/[variants]/(main)/chat/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/chat/settings/error.tsx +0 -3
- 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/src/app/[variants]/(main)/chat/settings/layout.tsx +0 -21
- package/src/app/[variants]/(main)/chat/settings/loading.tsx +0 -3
- package/src/app/[variants]/(main)/chat/settings/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/chat/settings/page.tsx +0 -62
- package/src/app/[variants]/(main)/discover/(detail)/_layout/Desktop.tsx +0 -30
- package/src/app/[variants]/(main)/discover/(detail)/_layout/DetailLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(detail)/assistant/AssistantDetailPage.tsx +0 -47
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/Client.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Capabilities/Block.tsx +0 -27
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Nav.tsx +0 -122
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/TagList.tsx +0 -47
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Overview/index.tsx +0 -96
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/Related/index.tsx +0 -31
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/TagList.tsx +0 -47
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/SystemRole/index.tsx +0 -54
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Details/index.tsx +0 -49
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Header.tsx +0 -177
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/AddAgent.tsx +0 -87
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/ActionButton/index.tsx +0 -31
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/Related/index.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(detail)/assistant/[...slugs]/features/Sidebar/TocList/index.tsx +0 -77
- package/src/app/[variants]/(main)/discover/(detail)/mcp/McpDetailPage.tsx +0 -51
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/Client.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/Related/index.tsx +0 -32
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/Versions/index.tsx +0 -76
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Details/index.tsx +0 -59
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/Related/index.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/ServerConfig.tsx +0 -36
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/features/Sidebar/TocList/index.tsx +0 -98
- package/src/app/[variants]/(main)/discover/(detail)/mcp/[slug]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/model/ModelDetailPage.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/Client.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Overview/index.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Parameter/ParameterItem.tsx +0 -71
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/Related/index.tsx +0 -31
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Details/index.tsx +0 -47
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Header.tsx +0 -112
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/ActionButton/ChatWithModel.tsx +0 -92
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/ActionButton/index.tsx +0 -32
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/Related/index.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/features/Sidebar/RelatedProviders/index.tsx +0 -34
- package/src/app/[variants]/(main)/discover/(detail)/model/[...slugs]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(detail)/provider/ProviderDetailPage.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/Client.tsx +0 -40
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/Related/index.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Details/index.tsx +0 -47
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/ActionButton/ProviderConfig.tsx +0 -97
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/ActionButton/index.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/Related/index.tsx +0 -34
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/features/Sidebar/RelatedModels/index.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(detail)/provider/[...slugs]/loading.tsx +0 -1
- package/src/app/[variants]/(main)/discover/(list)/(home)/HomePage.tsx +0 -45
- package/src/app/[variants]/(main)/discover/(list)/_layout/ListLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/assistant/AssistantPage.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/mcp/Client.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/mcp/McpLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/mcp/McpPage.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/model/Client.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/model/ModelLayout.tsx +0 -21
- package/src/app/[variants]/(main)/discover/(list)/model/ModelPage.tsx +0 -44
- package/src/app/[variants]/(main)/discover/(list)/provider/Client.tsx +0 -43
- package/src/app/[variants]/(main)/discover/(list)/provider/ProviderPage.tsx +0 -43
- package/src/app/[variants]/(main)/discover/DiscoverRouter.tsx +0 -170
- package/src/app/[variants]/(main)/discover/[[...path]]/page.tsx +0 -12
- package/src/app/[variants]/(main)/discover/_layout/DiscoverLayout.tsx +0 -22
- package/src/app/[variants]/(main)/discover/error.tsx +0 -3
- package/src/app/[variants]/(main)/discover/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/error.tsx +0 -3
- package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/components/ModelSelect.tsx +0 -161
- package/src/app/[variants]/(main)/image/layout.tsx +0 -19
- package/src/app/[variants]/(main)/image/page.tsx +0 -47
- package/src/app/[variants]/(main)/knowledge/KnowledgeRouter.tsx +0 -73
- package/src/app/[variants]/(main)/knowledge/[[...path]]/page.tsx +0 -12
- package/src/app/[variants]/(main)/knowledge/components/modal/page.tsx +0 -13
- package/src/app/[variants]/(main)/knowledge/layout.tsx +0 -12
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeBaseDetail/menu/MenuItems.tsx +0 -35
- package/src/app/[variants]/(main)/knowledge/routes/KnowledgeHome/menu/FileMenu.tsx +0 -75
- package/src/app/[variants]/(main)/labs/page.tsx +0 -86
- package/src/app/[variants]/(main)/layout.tsx +0 -10
- package/src/app/[variants]/(main)/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/profile/apikey/page.tsx +0 -32
- package/src/app/[variants]/(main)/profile/error.tsx +0 -3
- package/src/app/[variants]/(main)/profile/layout.tsx +0 -11
- package/src/app/[variants]/(main)/profile/loading.tsx +0 -3
- package/src/app/[variants]/(main)/profile/not-found.tsx +0 -1
- package/src/app/[variants]/(main)/profile/security/page.tsx +0 -28
- package/src/app/[variants]/(main)/profile/stats/page.tsx +0 -23
- package/src/app/[variants]/(main)/settings/storage/IndexedDBStorage.tsx +0 -55
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Cover.tsx +0 -48
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Hero.tsx +0 -29
- package/src/app/[variants]/@modal/(.)changelog/modal/features/Post.tsx +0 -57
- package/src/app/[variants]/@modal/(.)changelog/modal/features/PublishedTime.tsx +0 -50
- package/src/app/[variants]/@modal/(.)changelog/modal/features/ReadDetail.tsx +0 -72
- package/src/app/[variants]/@modal/(.)changelog/modal/features/VersionTag.tsx +0 -26
- package/src/app/[variants]/@modal/(.)changelog/modal/layout.tsx +0 -41
- package/src/app/[variants]/@modal/(.)changelog/modal/loading.tsx +0 -10
- package/src/app/[variants]/@modal/(.)changelog/modal/page.tsx +0 -38
- package/src/app/[variants]/@modal/_layout/ModalLayout.tsx +0 -63
- package/src/app/[variants]/@modal/_layout/SettingModalLayout.tsx +0 -71
- package/src/app/[variants]/@modal/default.tsx +0 -3
- package/src/app/[variants]/@modal/error.tsx +0 -3
- package/src/app/[variants]/@modal/layout.tsx +0 -7
- package/src/app/[variants]/@modal/loading.tsx +0 -5
- package/src/app/[variants]/loading/Client/Content.tsx +0 -48
- package/src/app/[variants]/loading/Client/Error.tsx +0 -27
- package/src/app/[variants]/loading/Client/Redirect.tsx +0 -47
- package/src/app/[variants]/loading/Client/index.tsx +0 -22
- package/src/app/[variants]/oauth/consent/[uid]/Consent.tsx +0 -189
- package/src/components/InnerLink.tsx +0 -20
- package/src/database/_deprecated/core/__tests__/db-upgrade.test.ts +0 -42
- package/src/database/_deprecated/core/__tests__/db.test.ts +0 -79
- package/src/database/_deprecated/core/__tests__/model.test.ts +0 -55
- package/src/database/_deprecated/core/db.ts +0 -246
- package/src/database/_deprecated/core/index.ts +0 -2
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/input.json +0 -55
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/output.json +0 -60
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.test.ts +0 -14
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.ts +0 -22
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +0 -105
- package/src/database/_deprecated/core/model.ts +0 -218
- package/src/database/_deprecated/core/schemas.ts +0 -88
- package/src/database/_deprecated/core/types/db.ts +0 -15
- package/src/database/_deprecated/models/__DEBUG.ts +0 -124
- package/src/database/_deprecated/models/__tests__/file.test.ts +0 -83
- package/src/database/_deprecated/models/__tests__/message.test.ts +0 -426
- package/src/database/_deprecated/models/__tests__/plugin.test.ts +0 -81
- package/src/database/_deprecated/models/__tests__/session.test.ts +0 -253
- package/src/database/_deprecated/models/__tests__/sessionGroup.test.ts +0 -220
- package/src/database/_deprecated/models/__tests__/topic.test.ts +0 -523
- package/src/database/_deprecated/models/__tests__/user.test.ts +0 -82
- package/src/database/_deprecated/models/file.ts +0 -51
- package/src/database/_deprecated/models/message.ts +0 -277
- package/src/database/_deprecated/models/plugin.ts +0 -62
- package/src/database/_deprecated/models/session.ts +0 -271
- package/src/database/_deprecated/models/sessionGroup.ts +0 -93
- package/src/database/_deprecated/models/topic.ts +0 -250
- package/src/database/_deprecated/models/user.ts +0 -69
- package/src/database/_deprecated/schemas/files.ts +0 -39
- package/src/database/_deprecated/schemas/message.ts +0 -50
- package/src/database/_deprecated/schemas/plugin.ts +0 -12
- package/src/database/_deprecated/schemas/session.ts +0 -54
- package/src/database/_deprecated/schemas/sessionGroup.ts +0 -8
- package/src/database/_deprecated/schemas/topic.ts +0 -12
- package/src/database/_deprecated/schemas/user.ts +0 -40
- package/src/envs/__tests__/auth.test.ts +0 -200
- package/src/features/ChatInput/ActionBar/Upload/ClientMode.tsx +0 -62
- package/src/features/Conversation/Error/InvalidAccessCode.tsx +0 -79
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginResult.tsx +0 -39
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/PluginState.tsx +0 -23
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/ToolTitle.tsx +0 -94
- package/src/features/Conversation/Messages/Assistant/Tool/Inspector/index.tsx +0 -147
- package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +0 -144
- package/src/features/Conversation/Messages/Assistant/Tool/Render/LoadingPlaceholder/index.tsx +0 -29
- package/src/features/Conversation/Messages/Assistant/Tool/Render/PluginSettings.tsx +0 -66
- package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +0 -76
- package/src/features/Conversation/Messages/Assistant/Tool/index.tsx +0 -76
- package/src/features/Conversation/Messages/User/Actions.tsx +0 -158
- package/src/features/DataImporter/_deprecated.ts +0 -43
- package/src/features/FileManager/FileList/FileListItem/index.tsx +0 -231
- package/src/features/FileManager/FileList/MasonryFileItem/index.tsx +0 -582
- package/src/features/FileManager/FileList/index.tsx +0 -266
- package/src/features/FileManager/Header/FilesSearchBar.tsx +0 -45
- package/src/features/FileManager/Header/index.tsx +0 -27
- package/src/features/FileManager/index.tsx +0 -36
- package/src/features/InitClientDB/EnableModal.tsx +0 -118
- package/src/features/InitClientDB/ErrorResult.tsx +0 -143
- package/src/features/InitClientDB/InitIndicator.tsx +0 -124
- package/src/features/InitClientDB/PGliteIcon.tsx +0 -28
- package/src/features/InitClientDB/features/DatabaseRepair/Backup.tsx +0 -75
- package/src/features/InitClientDB/features/DatabaseRepair/Diagnosis.tsx +0 -98
- package/src/features/InitClientDB/features/DatabaseRepair/Repair.tsx +0 -218
- package/src/features/InitClientDB/features/DatabaseRepair/index.tsx +0 -91
- package/src/features/InitClientDB/index.tsx +0 -37
- package/src/hooks/_header.ts +0 -23
- package/src/libs/trpc/client/edge.ts +0 -26
- package/src/libs/trpc/edge/context.ts +0 -71
- package/src/libs/trpc/edge/index.ts +0 -45
- package/src/libs/trpc/edge/init.ts +0 -26
- package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +0 -75
- package/src/libs/trpc/edge/middleware/jwtPayload.ts +0 -14
- package/src/migrations/FromV0ToV1.ts +0 -10
- package/src/migrations/FromV1ToV2/fixtures/input-v1-session.json +0 -191
- package/src/migrations/FromV1ToV2/fixtures/output-v2.json +0 -202
- package/src/migrations/FromV1ToV2/index.ts +0 -82
- package/src/migrations/FromV1ToV2/migrations.test.ts +0 -224
- package/src/migrations/FromV1ToV2/types/v1.ts +0 -78
- package/src/migrations/FromV1ToV2/types/v2.ts +0 -52
- package/src/migrations/FromV2ToV3/fixtures/input-v2-session.json +0 -72
- package/src/migrations/FromV2ToV3/fixtures/output-v3-from-v1.json +0 -203
- package/src/migrations/FromV2ToV3/fixtures/output-v3.json +0 -74
- package/src/migrations/FromV2ToV3/index.ts +0 -30
- package/src/migrations/FromV2ToV3/migrations.test.ts +0 -42
- package/src/migrations/FromV2ToV3/types/v3.ts +0 -27
- package/src/migrations/FromV3ToV4/fixtures/azure-input-v3.json +0 -79
- package/src/migrations/FromV3ToV4/fixtures/azure-output-v4.json +0 -75
- package/src/migrations/FromV3ToV4/fixtures/ollama-input-v3.json +0 -85
- package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +0 -86
- package/src/migrations/FromV3ToV4/fixtures/openai-input-v3.json +0 -77
- package/src/migrations/FromV3ToV4/fixtures/openai-output-v4.json +0 -77
- package/src/migrations/FromV3ToV4/fixtures/openrouter-input-v3.json +0 -82
- package/src/migrations/FromV3ToV4/fixtures/openrouter-output-v4.json +0 -85
- package/src/migrations/FromV3ToV4/fixtures/output-v4-from-v1.json +0 -203
- package/src/migrations/FromV3ToV4/index.ts +0 -102
- package/src/migrations/FromV3ToV4/migrations.test.ts +0 -195
- package/src/migrations/FromV3ToV4/types/v3.ts +0 -52
- package/src/migrations/FromV3ToV4/types/v4.ts +0 -37
- package/src/migrations/FromV4ToV5/fixtures/from-v1-to-v5-output.json +0 -245
- package/src/migrations/FromV4ToV5/fixtures/function-input-v4.json +0 -96
- package/src/migrations/FromV4ToV5/fixtures/function-output-v5.json +0 -120
- package/src/migrations/FromV4ToV5/index.ts +0 -58
- package/src/migrations/FromV4ToV5/migrations.test.ts +0 -49
- package/src/migrations/FromV4ToV5/types/v4.ts +0 -21
- package/src/migrations/FromV4ToV5/types/v5.ts +0 -27
- package/src/migrations/FromV5ToV6/fixtures/from-v1-to-v6-output.json +0 -247
- package/src/migrations/FromV5ToV6/fixtures/session-input-v5.json +0 -81
- package/src/migrations/FromV5ToV6/fixtures/session-output-v6.json +0 -85
- package/src/migrations/FromV5ToV6/index.ts +0 -61
- package/src/migrations/FromV5ToV6/migrations.test.ts +0 -50
- package/src/migrations/FromV5ToV6/types/v5.ts +0 -48
- package/src/migrations/FromV5ToV6/types/v6.ts +0 -63
- package/src/migrations/FromV6ToV7/fixtures/output-v7-from-v1.json +0 -203
- package/src/migrations/FromV6ToV7/fixtures/provider-input-v6.json +0 -103
- package/src/migrations/FromV6ToV7/fixtures/provider-output-v7.json +0 -118
- package/src/migrations/FromV6ToV7/index.ts +0 -101
- package/src/migrations/FromV6ToV7/migrations.test.ts +0 -64
- package/src/migrations/FromV6ToV7/types/v6.ts +0 -61
- package/src/migrations/FromV6ToV7/types/v7.ts +0 -69
- package/src/migrations/VersionController.test.ts +0 -88
- package/src/migrations/VersionController.ts +0 -67
- package/src/migrations/index.ts +0 -61
- package/src/server/globalConfig/_deprecated.test.ts +0 -92
- package/src/server/globalConfig/_deprecated.ts +0 -41
- package/src/server/routers/edge/appStatus.ts +0 -3
- package/src/server/routers/edge/index.ts +0 -14
- package/src/server/routers/edge/upload.ts +0 -16
- package/src/services/aiModel/client.ts +0 -70
- package/src/services/aiModel/server.test.ts +0 -122
- package/src/services/aiModel/server.ts +0 -51
- package/src/services/aiModel/type.ts +0 -32
- package/src/services/aiProvider/client.ts +0 -58
- package/src/services/aiProvider/server.ts +0 -43
- package/src/services/aiProvider/type.ts +0 -27
- package/src/services/baseClientService/index.ts +0 -9
- package/src/services/chatGroup/client.ts +0 -63
- package/src/services/chatGroup/server.ts +0 -67
- package/src/services/chatGroup/type.ts +0 -22
- package/src/services/export/_deprecated.ts +0 -155
- package/src/services/export/client.ts +0 -15
- package/src/services/export/server.ts +0 -9
- package/src/services/export/type.ts +0 -5
- package/src/services/file/ClientS3/index.test.ts +0 -115
- package/src/services/file/ClientS3/index.ts +0 -59
- package/src/services/file/_deprecated.test.ts +0 -119
- package/src/services/file/_deprecated.ts +0 -80
- package/src/services/file/client.test.ts +0 -199
- package/src/services/file/client.ts +0 -85
- package/src/services/file/server.ts +0 -53
- package/src/services/file/type.ts +0 -13
- package/src/services/import/_deprecated.ts +0 -115
- package/src/services/import/client.test.ts +0 -1015
- package/src/services/import/client.ts +0 -64
- package/src/services/import/server.ts +0 -133
- package/src/services/import/type.ts +0 -17
- package/src/services/message/__tests__/server.test.ts +0 -44
- package/src/services/message/_deprecated.test.ts +0 -398
- package/src/services/message/_deprecated.ts +0 -168
- package/src/services/message/client.test.ts +0 -410
- package/src/services/message/client.ts +0 -192
- package/src/services/message/server.ts +0 -155
- package/src/services/message/type.ts +0 -59
- package/src/services/plugin/_deprecated.test.ts +0 -162
- package/src/services/plugin/_deprecated.ts +0 -42
- package/src/services/plugin/client.test.ts +0 -177
- package/src/services/plugin/client.ts +0 -46
- package/src/services/plugin/server.ts +0 -42
- package/src/services/plugin/type.ts +0 -23
- package/src/services/session/_deprecated.test.ts +0 -440
- package/src/services/session/_deprecated.ts +0 -190
- package/src/services/session/client.test.ts +0 -413
- package/src/services/session/client.ts +0 -193
- package/src/services/session/server.test.ts +0 -260
- package/src/services/session/server.ts +0 -125
- package/src/services/session/type.ts +0 -82
- package/src/services/thread/client.ts +0 -51
- package/src/services/thread/server.ts +0 -32
- package/src/services/thread/type.ts +0 -21
- package/src/services/topic/_deprecated.test.ts +0 -245
- package/src/services/topic/_deprecated.ts +0 -75
- package/src/services/topic/client.ts +0 -89
- package/src/services/topic/pglite.test.ts +0 -212
- package/src/services/topic/server.ts +0 -57
- package/src/services/topic/type.ts +0 -40
- package/src/services/user/_deprecated.test.ts +0 -101
- package/src/services/user/_deprecated.ts +0 -70
- package/src/services/user/client.test.ts +0 -111
- package/src/services/user/client.ts +0 -104
- package/src/services/user/server.test.ts +0 -149
- package/src/services/user/server.ts +0 -47
- package/src/services/user/type.ts +0 -21
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +0 -1209
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +0 -718
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +0 -849
- package/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts +0 -591
- package/src/store/chat/slices/message/action.ts +0 -641
- package/src/store/chat/slices/plugin/action.ts +0 -505
- package/src/store/global/actions/clientDb.ts +0 -67
- package/src/store/middleware/createHyperStorage/index.test.ts +0 -341
- package/src/store/middleware/createHyperStorage/index.ts +0 -126
- package/src/store/middleware/createHyperStorage/indexedDB.test.ts +0 -64
- package/src/store/middleware/createHyperStorage/indexedDB.ts +0 -26
- package/src/store/middleware/createHyperStorage/keyMapper.ts +0 -57
- package/src/store/middleware/createHyperStorage/localStorage.ts +0 -18
- package/src/store/middleware/createHyperStorage/type.ts +0 -25
- package/src/store/middleware/createHyperStorage/urlStorage.test.ts +0 -84
- package/src/store/middleware/createHyperStorage/urlStorage.ts +0 -81
- package/src/store/user/slices/modelList/__snapshots__/action.test.ts.snap +0 -12
- package/src/store/user/slices/modelList/action.test.ts +0 -359
- package/src/store/user/slices/modelList/action.ts +0 -223
- package/src/store/user/slices/modelList/initialState.ts +0 -15
- package/src/store/user/slices/modelList/reducers/customModelCard.test.ts +0 -204
- package/src/store/user/slices/modelList/reducers/customModelCard.ts +0 -64
- package/src/store/user/slices/modelList/selectors/index.ts +0 -3
- package/src/store/user/slices/modelList/selectors/keyVaults.test.ts +0 -201
- package/src/store/user/slices/modelList/selectors/keyVaults.ts +0 -50
- package/src/store/user/slices/modelList/selectors/modelConfig.test.ts +0 -219
- package/src/store/user/slices/modelList/selectors/modelConfig.ts +0 -95
- package/src/store/user/slices/modelList/selectors/modelProvider.test.ts +0 -138
- package/src/store/user/slices/modelList/selectors/modelProvider.ts +0 -170
- package/src/store/user/slices/preference/selectors.ts +0 -34
- package/src/tools/local-system/Placeholder/index.tsx +0 -25
- package/src/tools/local-system/Render/index.tsx +0 -40
- package/src/tools/web-browsing/Placeholder/PageContent.tsx +0 -27
- package/src/tools/web-browsing/Placeholder/index.tsx +0 -40
- package/src/tools/web-browsing/Render/index.tsx +0 -57
- /package/packages/{utils/src/fetch → fetch-sse/src}/index.ts +0 -0
- /package/src/app/[variants]/{@modal/(.)changelog/modal → (main)/changelog}/features/Pagination.tsx +0 -0
- /package/src/app/[variants]/{@modal/(.)changelog/modal → (main)/changelog}/features/UpdateChangelogStatus.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/default.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Desktop/ClassicChat.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Desktop/GroupChat.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Desktop/useSendMenuItems.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Mobile/MentionedUsers/MentionedUserItem.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Mobile/MentionedUsers/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/Mobile/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/V1Mobile/ActionBar.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/V1Mobile/Files/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/V1Mobile/InputArea/Container.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/V1Mobile/InputArea/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/V1Mobile/Send.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatInput/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/ChatItem/OrchestratorThinking.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/ChatItem/ThreadItem.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/WelcomeChatItem/AgentWelcome/AddButton.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/WelcomeChatItem/AgentWelcome/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/WelcomeChatItem/GroupWelcome/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/WelcomeChatItem/GroupWelcome/useTemplateMatching.ts +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/WelcomeChatItem/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ChatList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ZenModeToast/Toast.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@conversation → components/conversation}/features/ZenModeToast/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/AgentSettings/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/AgentTeamSettings/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/ChangelogModal.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/SettingButton.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/ShareButton/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace) → components}/features/TelemetryNotification.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/HeaderAction.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Main.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Tags/HistoryLimitTags.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Tags/KnowledgeTag.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Tags/MemberCountTag.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Tags/SearchTags.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/Tags/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/ChatHeader/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/Portal.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/TopicPanel.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Desktop/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Mobile/ChatHeader/ChatHeaderTitle.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Mobile/ChatHeader/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Mobile/TopicModal.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/Mobile/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/_layout → components/layout}/type.ts +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/_layout/Desktop.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/_layout/Mobile.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/default.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/error.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/features/Body.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@portal → components/portal}/loading.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/_layout/Desktop.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/_layout/Mobile.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/default.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/AgentConfig/SystemRole.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/AgentConfig/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/ConfigLayout.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/ConfigSwitcher.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/GroupConfig/GroupMember.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/GroupConfig/GroupMemberItem.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/GroupConfig/GroupRole.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/GroupConfig/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/GroupConfig/style.ts +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/SkeletonList.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/Header.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/ByTimeMode/GroupItem.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/ByTimeMode/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/FlatMode/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/SearchResult/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/ThreadItem/Content.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/ThreadItem/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/ThreadList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/TopicItem/DefaultContent.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/TopicItem/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicListContent/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/TopicSearchBar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{(workspace)/@topic → components/topic}/features/Topic/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/CollapseGroup/Actions.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/CollapseGroup/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/DefaultMode.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/List/AddButton.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/ListItem/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/Modals/ConfigGroupModal/GroupItem.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/Modals/ConfigGroupModal/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/Modals/CreateGroupModal.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/Modals/RenameGroupModal.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/SearchMode.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionListContent/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SessionSearchBar.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session → session}/features/SkeletonList.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session/_layout → session/layout}/Desktop/PanelBody.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session/_layout → session/layout}/Desktop/SessionHeader.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session/_layout → session/layout}/Desktop/index.tsx +0 -0
- /package/src/app/[variants]/(main)/chat/{@session/_layout → session/layout}/Mobile/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/Knowledge.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/KnowledgeItem.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/PluginItem.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/Plugins.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Details/Capabilities/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/Summary/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/assistant/{[...slugs]/loading.tsx → loading.tsx} +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/ActionButton/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/ConnectionTypeAlert.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/mcp/{[slug]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Overview/ProviderList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Details/Parameter/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/RelatedProviders/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/model/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/DetailProvider.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Guide/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Nav.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Overview/ModelList/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Details/Overview/index.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Header.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/Related/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/RelatedModels/Item.tsx +0 -0
- /package/src/app/[variants]/(main)/discover/(detail)/provider/{[...slugs]/features → features}/Sidebar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/RegisterHotkeys.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/Avatar.test.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/Avatar.tsx +0 -0
- /package/src/app/[variants]/(main)/{_layout/Desktop → layouts/desktop}/SideBar/index.tsx +0 -0
- /package/src/app/[variants]/(main)/settings/provider/detail/newapi/{page.tsx → index.tsx} +0 -0
- /package/src/{app/[variants]/(main)/settings/provider/features/ProviderConfig → components/Skeleton}/SkeletonInput.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant → Group}/Tool/Inspector/Settings.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant → Group}/Tool/Render/Arguments/ObjectEntity.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant → Group}/Tool/Render/Arguments/ValueCell.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant → Group}/Tool/Render/ErrorResponse.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/BuiltinPluginTitle.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Inspector/Debug.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/Arguments/index.tsx +0 -0
- /package/src/features/Conversation/Messages/{Assistant/Tool → Tool}/Render/KeyValueEditor.tsx +0 -0
- /package/src/features/{FileManager/FileList/ToolBar → KnowledgeBaseModal/AssignKnowledgeBase}/ViewSwitcher.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/ChunkList/ChunkItem.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/ChunkList/index.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/Content.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/Loading/index.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/SimilaritySearchList/Item.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/SimilaritySearchList/index.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/ChunkDrawer/index.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/EmptyStatus.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/FileListItem/ChunkTag.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/FileListItem/DropdownMenu.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/FileSkeleton.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/MasonryFileItem/MasonryItemWrapper.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/MasonrySkeleton.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/ToolBar/Config.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/ToolBar/MultiSelectActions.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/ToolBar/index.tsx +0 -0
- /package/src/features/{FileManager/FileList → KnowledgeManager/FileExplorer}/useCheckTaskStatus.ts +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/Header/TogglePanelButton.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/Header/UploadFileButton.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/UploadDock/Item.tsx +0 -0
- /package/src/features/{FileManager → KnowledgeManager}/UploadDock/index.tsx +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
|
@@ -1,2704 +0,0 @@
|
|
|
1
|
-
import { DBMessageItem } from '@lobechat/types';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { eq } from 'drizzle-orm';
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
|
|
6
|
-
import { uuid } from '@/utils/uuid';
|
|
7
|
-
|
|
8
|
-
import { getTestDB } from '../../models/__tests__/_util';
|
|
9
|
-
import {
|
|
10
|
-
agents,
|
|
11
|
-
chatGroups,
|
|
12
|
-
chunks,
|
|
13
|
-
embeddings,
|
|
14
|
-
fileChunks,
|
|
15
|
-
files,
|
|
16
|
-
messagePlugins,
|
|
17
|
-
messageQueries,
|
|
18
|
-
messageQueryChunks,
|
|
19
|
-
messageTTS,
|
|
20
|
-
messageTranslates,
|
|
21
|
-
messages,
|
|
22
|
-
messagesFiles,
|
|
23
|
-
sessions,
|
|
24
|
-
topics,
|
|
25
|
-
users,
|
|
26
|
-
} from '../../schemas';
|
|
27
|
-
import { LobeChatDatabase } from '../../type';
|
|
28
|
-
import { MessageModel } from '../message';
|
|
29
|
-
import { codeEmbedding } from './fixtures/embedding';
|
|
30
|
-
|
|
31
|
-
const serverDB: LobeChatDatabase = await getTestDB();
|
|
32
|
-
|
|
33
|
-
const userId = 'message-db';
|
|
34
|
-
const messageModel = new MessageModel(serverDB, userId);
|
|
35
|
-
const embeddingsId = uuid();
|
|
36
|
-
|
|
37
|
-
beforeEach(async () => {
|
|
38
|
-
// Clear tables before each test case
|
|
39
|
-
await serverDB.transaction(async (trx) => {
|
|
40
|
-
await trx.delete(users);
|
|
41
|
-
await trx.insert(users).values([{ id: userId }, { id: '456' }]);
|
|
42
|
-
|
|
43
|
-
await trx.insert(sessions).values([
|
|
44
|
-
// { id: 'session1', userId },
|
|
45
|
-
// { id: 'session2', userId },
|
|
46
|
-
{ id: '1', userId },
|
|
47
|
-
]);
|
|
48
|
-
await trx.insert(files).values({
|
|
49
|
-
id: 'f1',
|
|
50
|
-
userId: userId,
|
|
51
|
-
url: 'abc',
|
|
52
|
-
name: 'file-1',
|
|
53
|
-
fileType: 'image/png',
|
|
54
|
-
size: 1000,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
await trx.insert(embeddings).values({
|
|
58
|
-
id: embeddingsId,
|
|
59
|
-
embeddings: codeEmbedding,
|
|
60
|
-
userId,
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
afterEach(async () => {
|
|
66
|
-
// Clear tables after each test case
|
|
67
|
-
await serverDB.delete(users);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('MessageModel', () => {
|
|
71
|
-
describe('query', () => {
|
|
72
|
-
it('should query messages by user ID', async () => {
|
|
73
|
-
// Create test data
|
|
74
|
-
await serverDB.insert(messages).values([
|
|
75
|
-
{ id: '1', userId, role: 'user', content: 'message 1', createdAt: new Date('2023-01-01') },
|
|
76
|
-
{ id: '2', userId, role: 'user', content: 'message 2', createdAt: new Date('2023-02-01') },
|
|
77
|
-
{
|
|
78
|
-
id: '3',
|
|
79
|
-
userId: '456',
|
|
80
|
-
role: 'user',
|
|
81
|
-
content: 'message 3',
|
|
82
|
-
createdAt: new Date('2023-03-01'),
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
|
|
86
|
-
// Call query method
|
|
87
|
-
const result = await messageModel.query();
|
|
88
|
-
|
|
89
|
-
// Assert result
|
|
90
|
-
expect(result).toHaveLength(2);
|
|
91
|
-
expect(result[0].id).toBe('1');
|
|
92
|
-
expect(result[1].id).toBe('2');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should return empty messages if not match the user ID', async () => {
|
|
96
|
-
// Create test data
|
|
97
|
-
await serverDB.insert(messages).values([
|
|
98
|
-
{ id: '1', userId: '456', role: 'user', content: '1', createdAt: new Date('2023-01-01') },
|
|
99
|
-
{ id: '2', userId: '456', role: 'user', content: '2', createdAt: new Date('2023-02-01') },
|
|
100
|
-
{ id: '3', userId: '456', role: 'user', content: '3', createdAt: new Date('2023-03-01') },
|
|
101
|
-
]);
|
|
102
|
-
|
|
103
|
-
// Call query method
|
|
104
|
-
const result = await messageModel.query();
|
|
105
|
-
|
|
106
|
-
// Assert result
|
|
107
|
-
expect(result).toHaveLength(0);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should query messages with pagination', async () => {
|
|
111
|
-
// Create test data
|
|
112
|
-
await serverDB.insert(messages).values([
|
|
113
|
-
{ id: '1', userId, role: 'user', content: 'message 1', createdAt: new Date('2023-01-01') },
|
|
114
|
-
{ id: '2', userId, role: 'user', content: 'message 2', createdAt: new Date('2023-02-01') },
|
|
115
|
-
{ id: '3', userId, role: 'user', content: 'message 3', createdAt: new Date('2023-03-01') },
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
// Test pagination
|
|
119
|
-
const result1 = await messageModel.query({ current: 0, pageSize: 2 });
|
|
120
|
-
expect(result1).toHaveLength(2);
|
|
121
|
-
|
|
122
|
-
const result2 = await messageModel.query({ current: 1, pageSize: 1 });
|
|
123
|
-
expect(result2).toHaveLength(1);
|
|
124
|
-
expect(result2[0].id).toBe('2');
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should filter messages by sessionId', async () => {
|
|
128
|
-
// Create test data
|
|
129
|
-
await serverDB.insert(sessions).values([
|
|
130
|
-
{ id: 'session1', userId },
|
|
131
|
-
{ id: 'session2', userId },
|
|
132
|
-
]);
|
|
133
|
-
await serverDB.insert(messages).values([
|
|
134
|
-
{
|
|
135
|
-
id: '1',
|
|
136
|
-
userId,
|
|
137
|
-
role: 'user',
|
|
138
|
-
sessionId: 'session1',
|
|
139
|
-
content: 'message 1',
|
|
140
|
-
createdAt: new Date('2022-02-01'),
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: '2',
|
|
144
|
-
userId,
|
|
145
|
-
role: 'user',
|
|
146
|
-
sessionId: 'session1',
|
|
147
|
-
content: 'message 2',
|
|
148
|
-
createdAt: new Date('2023-02-02'),
|
|
149
|
-
},
|
|
150
|
-
{ id: '3', userId, role: 'user', sessionId: 'session2', content: 'message 3' },
|
|
151
|
-
]);
|
|
152
|
-
|
|
153
|
-
// Test filtering by sessionId
|
|
154
|
-
const result = await messageModel.query({ sessionId: 'session1' });
|
|
155
|
-
expect(result).toHaveLength(2);
|
|
156
|
-
expect(result[0].id).toBe('1');
|
|
157
|
-
expect(result[1].id).toBe('2');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should filter messages by topicId', async () => {
|
|
161
|
-
// Create test data
|
|
162
|
-
const sessionId = 'session1';
|
|
163
|
-
await serverDB.insert(sessions).values([{ id: sessionId, userId }]);
|
|
164
|
-
const topicId = 'topic1';
|
|
165
|
-
await serverDB.insert(topics).values([
|
|
166
|
-
{ id: topicId, sessionId, userId },
|
|
167
|
-
{ id: 'topic2', sessionId, userId },
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
await serverDB.insert(messages).values([
|
|
171
|
-
{ id: '1', userId, role: 'user', topicId, content: '1', createdAt: new Date('2022-04-01') },
|
|
172
|
-
{ id: '2', userId, role: 'user', topicId, content: '2', createdAt: new Date('2023-02-01') },
|
|
173
|
-
{ id: '3', userId, role: 'user', topicId: 'topic2', content: 'message 3' },
|
|
174
|
-
]);
|
|
175
|
-
|
|
176
|
-
// Test filtering by topicId
|
|
177
|
-
const result = await messageModel.query({ topicId });
|
|
178
|
-
expect(result).toHaveLength(2);
|
|
179
|
-
expect(result[0].id).toBe('1');
|
|
180
|
-
expect(result[1].id).toBe('2');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should filter messages by groupId and expose group metadata', async () => {
|
|
184
|
-
await serverDB.transaction(async (trx) => {
|
|
185
|
-
await trx.insert(chatGroups).values([
|
|
186
|
-
{ id: 'group-1', userId, title: 'Group 1' },
|
|
187
|
-
{ id: 'group-2', userId, title: 'Group 2' },
|
|
188
|
-
]);
|
|
189
|
-
|
|
190
|
-
await trx.insert(agents).values([
|
|
191
|
-
{ id: 'agent-group', userId, title: 'Agent Group' },
|
|
192
|
-
{ id: 'agent-other', userId, title: 'Agent Other' },
|
|
193
|
-
]);
|
|
194
|
-
|
|
195
|
-
await trx.insert(messages).values([
|
|
196
|
-
{
|
|
197
|
-
id: 'group-message',
|
|
198
|
-
userId,
|
|
199
|
-
role: 'assistant',
|
|
200
|
-
content: 'group message',
|
|
201
|
-
groupId: 'group-1',
|
|
202
|
-
agentId: 'agent-group',
|
|
203
|
-
targetId: 'user',
|
|
204
|
-
createdAt: new Date('2024-01-01'),
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
id: 'other-message',
|
|
208
|
-
userId,
|
|
209
|
-
role: 'assistant',
|
|
210
|
-
content: 'other group message',
|
|
211
|
-
groupId: 'group-2',
|
|
212
|
-
agentId: 'agent-other',
|
|
213
|
-
targetId: 'user',
|
|
214
|
-
createdAt: new Date('2024-01-02'),
|
|
215
|
-
},
|
|
216
|
-
]);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
const result = await messageModel.query({ groupId: 'group-1' });
|
|
220
|
-
|
|
221
|
-
expect(result).toHaveLength(1);
|
|
222
|
-
expect(result[0].id).toBe('group-message');
|
|
223
|
-
expect(result[0].groupId).toBe('group-1');
|
|
224
|
-
expect(result[0].agentId).toBe('agent-group');
|
|
225
|
-
expect(result[0].targetId).toBe('user');
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should query messages with join', async () => {
|
|
229
|
-
// Create test data
|
|
230
|
-
await serverDB.transaction(async (trx) => {
|
|
231
|
-
await trx.insert(messages).values([
|
|
232
|
-
{
|
|
233
|
-
id: '1',
|
|
234
|
-
userId,
|
|
235
|
-
role: 'user',
|
|
236
|
-
content: 'message 1',
|
|
237
|
-
createdAt: new Date('2023-01-01'),
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: '2',
|
|
241
|
-
userId,
|
|
242
|
-
role: 'user',
|
|
243
|
-
content: 'message 2',
|
|
244
|
-
createdAt: new Date('2023-02-01'),
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
id: '3',
|
|
248
|
-
userId: '456',
|
|
249
|
-
role: 'user',
|
|
250
|
-
content: 'message 3',
|
|
251
|
-
createdAt: new Date('2023-03-01'),
|
|
252
|
-
},
|
|
253
|
-
]);
|
|
254
|
-
await trx.insert(files).values([
|
|
255
|
-
{ id: 'f-0', url: 'abc', name: 'file-1', userId, fileType: 'image/png', size: 1000 },
|
|
256
|
-
{ id: 'f-1', url: 'abc', name: 'file-1', userId, fileType: 'image/png', size: 100 },
|
|
257
|
-
{ id: 'f-3', url: 'abc', name: 'file-3', userId, fileType: 'image/png', size: 400 },
|
|
258
|
-
]);
|
|
259
|
-
await trx.insert(messageTTS).values([
|
|
260
|
-
{ id: '1', userId },
|
|
261
|
-
{ id: '2', voice: 'a', fileId: 'f-1', contentMd5: 'abc', userId },
|
|
262
|
-
]);
|
|
263
|
-
|
|
264
|
-
await trx.insert(messagesFiles).values([
|
|
265
|
-
{ fileId: 'f-0', messageId: '1', userId },
|
|
266
|
-
{ fileId: 'f-3', messageId: '1', userId },
|
|
267
|
-
]);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
const domain = 'http://abc.com';
|
|
271
|
-
// Call query method
|
|
272
|
-
const result = await messageModel.query(
|
|
273
|
-
{},
|
|
274
|
-
{ postProcessUrl: async (path) => `${domain}/${path}` },
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
// Assert result
|
|
278
|
-
expect(result).toHaveLength(2);
|
|
279
|
-
expect(result[0].id).toBe('1');
|
|
280
|
-
expect(result[0].imageList).toEqual([
|
|
281
|
-
{ alt: 'file-1', id: 'f-0', url: `${domain}/abc` },
|
|
282
|
-
{ alt: 'file-3', id: 'f-3', url: `${domain}/abc` },
|
|
283
|
-
]);
|
|
284
|
-
|
|
285
|
-
expect(result[1].id).toBe('2');
|
|
286
|
-
expect(result[1].imageList).toEqual([]);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('should include translate, tts and other extra fields in query result', async () => {
|
|
290
|
-
// Create test data
|
|
291
|
-
await serverDB.transaction(async (trx) => {
|
|
292
|
-
await trx.insert(messages).values([
|
|
293
|
-
{
|
|
294
|
-
id: '1',
|
|
295
|
-
userId,
|
|
296
|
-
role: 'user',
|
|
297
|
-
content: 'message 1',
|
|
298
|
-
createdAt: new Date('2023-01-01'),
|
|
299
|
-
},
|
|
300
|
-
]);
|
|
301
|
-
await trx
|
|
302
|
-
.insert(messageTranslates)
|
|
303
|
-
.values([{ id: '1', content: 'translated', from: 'en', to: 'zh', userId }]);
|
|
304
|
-
await trx
|
|
305
|
-
.insert(messageTTS)
|
|
306
|
-
.values([{ id: '1', voice: 'voice1', fileId: 'f1', contentMd5: 'md5', userId }]);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// Call query method
|
|
310
|
-
const result = await messageModel.query();
|
|
311
|
-
|
|
312
|
-
// Assert result
|
|
313
|
-
expect(result[0].extra!.translate).toEqual({ content: 'translated', from: 'en', to: 'zh' });
|
|
314
|
-
expect(result[0].extra!.tts).toEqual({
|
|
315
|
-
contentMd5: 'md5',
|
|
316
|
-
file: 'f1',
|
|
317
|
-
voice: 'voice1',
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('should handle edge cases of pagination parameters', async () => {
|
|
322
|
-
// Create test data
|
|
323
|
-
await serverDB.insert(messages).values([
|
|
324
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
325
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
326
|
-
{ id: '3', userId, role: 'user', content: 'message 3' },
|
|
327
|
-
]);
|
|
328
|
-
|
|
329
|
-
// 测试 current 和 pageSize 的边界情况
|
|
330
|
-
const result1 = await messageModel.query({ current: 0, pageSize: 2 });
|
|
331
|
-
expect(result1).toHaveLength(2);
|
|
332
|
-
|
|
333
|
-
const result2 = await messageModel.query({ current: 1, pageSize: 2 });
|
|
334
|
-
expect(result2).toHaveLength(1);
|
|
335
|
-
|
|
336
|
-
const result3 = await messageModel.query({ current: 2, pageSize: 2 });
|
|
337
|
-
expect(result3).toHaveLength(0);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe('query with messageQueries', () => {
|
|
341
|
-
it('should include ragQuery, ragQueryId and ragRawQuery in query results', async () => {
|
|
342
|
-
// Create test data
|
|
343
|
-
const messageId = 'msg-with-query';
|
|
344
|
-
const queryId = uuid();
|
|
345
|
-
|
|
346
|
-
await serverDB.insert(messages).values({
|
|
347
|
-
id: messageId,
|
|
348
|
-
userId,
|
|
349
|
-
role: 'user',
|
|
350
|
-
content: 'test message',
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
await serverDB.insert(messageQueries).values({
|
|
354
|
-
id: queryId,
|
|
355
|
-
messageId,
|
|
356
|
-
userQuery: 'original query',
|
|
357
|
-
rewriteQuery: 'rewritten query',
|
|
358
|
-
userId,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// Call query method
|
|
362
|
-
const result = await messageModel.query();
|
|
363
|
-
|
|
364
|
-
// Assert result
|
|
365
|
-
expect(result).toHaveLength(1);
|
|
366
|
-
expect(result[0].id).toBe(messageId);
|
|
367
|
-
expect(result[0].ragQueryId).toBe(queryId);
|
|
368
|
-
expect(result[0].ragQuery).toBe('rewritten query');
|
|
369
|
-
expect(result[0].ragRawQuery).toBe('original query');
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it.skip('should handle multiple message queries for the same message', async () => {
|
|
373
|
-
// Create test data
|
|
374
|
-
const messageId = 'msg-multi-query';
|
|
375
|
-
const queryId1 = uuid();
|
|
376
|
-
const queryId2 = uuid();
|
|
377
|
-
|
|
378
|
-
await serverDB.insert(messages).values({
|
|
379
|
-
id: messageId,
|
|
380
|
-
userId,
|
|
381
|
-
role: 'user',
|
|
382
|
-
content: 'test message',
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// 创建两个查询,但查询结果应该只包含一个(最新的)
|
|
386
|
-
await serverDB.insert(messageQueries).values([
|
|
387
|
-
{
|
|
388
|
-
id: queryId1,
|
|
389
|
-
messageId,
|
|
390
|
-
userQuery: 'original query 1',
|
|
391
|
-
rewriteQuery: 'rewritten query 1',
|
|
392
|
-
userId,
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
id: queryId2,
|
|
396
|
-
messageId,
|
|
397
|
-
userQuery: 'original query 2',
|
|
398
|
-
rewriteQuery: 'rewritten query 2',
|
|
399
|
-
userId,
|
|
400
|
-
},
|
|
401
|
-
]);
|
|
402
|
-
|
|
403
|
-
// Call query method
|
|
404
|
-
const result = await messageModel.query();
|
|
405
|
-
|
|
406
|
-
// Assert result - 应该只包含最新的查询
|
|
407
|
-
expect(result).toHaveLength(1);
|
|
408
|
-
expect(result[0].id).toBe(messageId);
|
|
409
|
-
expect(result[0].ragQueryId).toBe(queryId2);
|
|
410
|
-
expect(result[0].ragQuery).toBe('rewritten query 2');
|
|
411
|
-
expect(result[0].ragRawQuery).toBe('original query 2');
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
it('should handle complex query with multiple joins and file chunks', async () => {
|
|
416
|
-
await serverDB.transaction(async (trx) => {
|
|
417
|
-
const chunk1Id = uuid();
|
|
418
|
-
const query1Id = uuid();
|
|
419
|
-
// 创建基础消息
|
|
420
|
-
await trx.insert(messages).values({
|
|
421
|
-
id: 'msg1',
|
|
422
|
-
userId,
|
|
423
|
-
role: 'user',
|
|
424
|
-
content: 'test message',
|
|
425
|
-
createdAt: new Date('2023-01-01'),
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
// 创建文件
|
|
429
|
-
await trx.insert(files).values([
|
|
430
|
-
{
|
|
431
|
-
id: 'file1',
|
|
432
|
-
userId,
|
|
433
|
-
name: 'test.txt',
|
|
434
|
-
url: 'test-url',
|
|
435
|
-
fileType: 'text/plain',
|
|
436
|
-
size: 100,
|
|
437
|
-
},
|
|
438
|
-
]);
|
|
439
|
-
|
|
440
|
-
// 创建文件块
|
|
441
|
-
await trx.insert(chunks).values({
|
|
442
|
-
id: chunk1Id,
|
|
443
|
-
text: 'chunk content',
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
// 关联消息和文件
|
|
447
|
-
await trx.insert(messagesFiles).values({
|
|
448
|
-
messageId: 'msg1',
|
|
449
|
-
userId,
|
|
450
|
-
fileId: 'file1',
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
// 创建文件块关联
|
|
454
|
-
await trx.insert(fileChunks).values({
|
|
455
|
-
fileId: 'file1',
|
|
456
|
-
userId,
|
|
457
|
-
chunkId: chunk1Id,
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
// 创建消息查询
|
|
461
|
-
await trx.insert(messageQueries).values({
|
|
462
|
-
id: query1Id,
|
|
463
|
-
messageId: 'msg1',
|
|
464
|
-
userId,
|
|
465
|
-
userQuery: 'original query',
|
|
466
|
-
rewriteQuery: 'rewritten query',
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
// 创建消息查询块关联
|
|
470
|
-
await trx.insert(messageQueryChunks).values({
|
|
471
|
-
messageId: 'msg1',
|
|
472
|
-
queryId: query1Id,
|
|
473
|
-
chunkId: chunk1Id,
|
|
474
|
-
similarity: '0.95',
|
|
475
|
-
userId,
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
const result = await messageModel.query();
|
|
480
|
-
|
|
481
|
-
expect(result).toHaveLength(1);
|
|
482
|
-
expect(result[0].chunksList).toHaveLength(1);
|
|
483
|
-
expect(result[0].chunksList![0]).toMatchObject({
|
|
484
|
-
text: 'chunk content',
|
|
485
|
-
similarity: 0.95,
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
it('should return empty arrays for files and chunks if none exist', async () => {
|
|
490
|
-
await serverDB.insert(messages).values({
|
|
491
|
-
id: 'msg1',
|
|
492
|
-
userId,
|
|
493
|
-
role: 'user',
|
|
494
|
-
content: 'test message',
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
const result = await messageModel.query();
|
|
498
|
-
|
|
499
|
-
expect(result).toHaveLength(1);
|
|
500
|
-
expect(result[0].fileList).toEqual([]);
|
|
501
|
-
expect(result[0].imageList).toEqual([]);
|
|
502
|
-
expect(result[0].chunksList).toEqual([]);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
describe('queryAll', () => {
|
|
507
|
-
it('should return all messages belonging to the user in ascending order', async () => {
|
|
508
|
-
// Create test data
|
|
509
|
-
await serverDB.insert(messages).values([
|
|
510
|
-
{
|
|
511
|
-
id: '1',
|
|
512
|
-
userId,
|
|
513
|
-
role: 'user',
|
|
514
|
-
content: 'message 1',
|
|
515
|
-
createdAt: new Date('2023-01-01'),
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
id: '2',
|
|
519
|
-
userId,
|
|
520
|
-
role: 'user',
|
|
521
|
-
content: 'message 2',
|
|
522
|
-
createdAt: new Date('2023-02-01'),
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
id: '3',
|
|
526
|
-
userId: '456',
|
|
527
|
-
role: 'user',
|
|
528
|
-
content: 'message 3',
|
|
529
|
-
createdAt: new Date('2023-03-01'),
|
|
530
|
-
},
|
|
531
|
-
]);
|
|
532
|
-
|
|
533
|
-
// Call queryAll method
|
|
534
|
-
const result = await messageModel.queryAll();
|
|
535
|
-
|
|
536
|
-
// Assert result
|
|
537
|
-
expect(result).toHaveLength(2);
|
|
538
|
-
expect(result[0].id).toBe('1');
|
|
539
|
-
expect(result[1].id).toBe('2');
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
describe('findById', () => {
|
|
544
|
-
it('should find message by ID', async () => {
|
|
545
|
-
// Create test data
|
|
546
|
-
await serverDB.insert(messages).values([
|
|
547
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
548
|
-
{ id: '2', userId: '456', role: 'user', content: 'message 2' },
|
|
549
|
-
]);
|
|
550
|
-
|
|
551
|
-
// Call findById method
|
|
552
|
-
const result = await messageModel.findById('1');
|
|
553
|
-
|
|
554
|
-
// Assert result
|
|
555
|
-
expect(result?.id).toBe('1');
|
|
556
|
-
expect(result?.content).toBe('message 1');
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
it('should return undefined if message does not belong to user', async () => {
|
|
560
|
-
// Create test data
|
|
561
|
-
await serverDB
|
|
562
|
-
.insert(messages)
|
|
563
|
-
.values([{ id: '1', userId: '456', role: 'user', content: 'message 1' }]);
|
|
564
|
-
|
|
565
|
-
// Call findById method
|
|
566
|
-
const result = await messageModel.findById('1');
|
|
567
|
-
|
|
568
|
-
// Assert result
|
|
569
|
-
expect(result).toBeUndefined();
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
describe('queryBySessionId', () => {
|
|
574
|
-
it('should query messages by sessionId', async () => {
|
|
575
|
-
// Create test data
|
|
576
|
-
const sessionId = 'session1';
|
|
577
|
-
await serverDB.insert(sessions).values([
|
|
578
|
-
{ id: 'session1', userId },
|
|
579
|
-
{ id: 'session2', userId },
|
|
580
|
-
]);
|
|
581
|
-
await serverDB.insert(messages).values([
|
|
582
|
-
{
|
|
583
|
-
id: '1',
|
|
584
|
-
userId,
|
|
585
|
-
role: 'user',
|
|
586
|
-
sessionId,
|
|
587
|
-
content: 'message 1',
|
|
588
|
-
createdAt: new Date('2022-01-01'),
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
id: '2',
|
|
592
|
-
userId,
|
|
593
|
-
role: 'user',
|
|
594
|
-
sessionId,
|
|
595
|
-
content: 'message 2',
|
|
596
|
-
createdAt: new Date('2023-02-01'),
|
|
597
|
-
},
|
|
598
|
-
{ id: '3', userId, role: 'user', sessionId: 'session2', content: 'message 3' },
|
|
599
|
-
]);
|
|
600
|
-
|
|
601
|
-
// Call queryBySessionId method
|
|
602
|
-
const result = await messageModel.queryBySessionId(sessionId);
|
|
603
|
-
|
|
604
|
-
// Assert result
|
|
605
|
-
expect(result).toHaveLength(2);
|
|
606
|
-
expect(result[0].id).toBe('1');
|
|
607
|
-
expect(result[1].id).toBe('2');
|
|
608
|
-
});
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
describe('queryByKeyWord', () => {
|
|
612
|
-
it('should query messages by keyword', async () => {
|
|
613
|
-
// Create test data
|
|
614
|
-
await serverDB.insert(messages).values([
|
|
615
|
-
{ id: '1', userId, role: 'user', content: 'apple', createdAt: new Date('2022-02-01') },
|
|
616
|
-
{ id: '2', userId, role: 'user', content: 'banana' },
|
|
617
|
-
{ id: '3', userId, role: 'user', content: 'pear' },
|
|
618
|
-
{ id: '4', userId, role: 'user', content: 'apple pie', createdAt: new Date('2024-02-01') },
|
|
619
|
-
]);
|
|
620
|
-
|
|
621
|
-
// Test querying messages with specific keyword
|
|
622
|
-
const result = await messageModel.queryByKeyword('apple');
|
|
623
|
-
|
|
624
|
-
// Assert result
|
|
625
|
-
expect(result).toHaveLength(2);
|
|
626
|
-
expect(result[0].id).toBe('4');
|
|
627
|
-
expect(result[1].id).toBe('1');
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
it('should return empty array when keyword is empty', async () => {
|
|
631
|
-
// Create test data
|
|
632
|
-
await serverDB.insert(messages).values([
|
|
633
|
-
{ id: '1', userId, role: 'user', content: 'apple' },
|
|
634
|
-
{ id: '2', userId, role: 'user', content: 'banana' },
|
|
635
|
-
{ id: '3', userId, role: 'user', content: 'pear' },
|
|
636
|
-
{ id: '4', userId, role: 'user', content: 'apple pie' },
|
|
637
|
-
]);
|
|
638
|
-
|
|
639
|
-
// Test returning empty array when keyword is empty
|
|
640
|
-
const result = await messageModel.queryByKeyword('');
|
|
641
|
-
|
|
642
|
-
// Assert result
|
|
643
|
-
expect(result).toHaveLength(0);
|
|
644
|
-
});
|
|
645
|
-
});
|
|
646
|
-
|
|
647
|
-
describe('createMessage', () => {
|
|
648
|
-
it('should create a new message', async () => {
|
|
649
|
-
// Call createMessage method
|
|
650
|
-
await messageModel.create({ role: 'user', content: 'new message', sessionId: '1' });
|
|
651
|
-
|
|
652
|
-
// Assert result
|
|
653
|
-
const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
|
|
654
|
-
expect(result).toHaveLength(1);
|
|
655
|
-
expect(result[0].content).toBe('new message');
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
it('should create a message', async () => {
|
|
659
|
-
const sessionId = 'session1';
|
|
660
|
-
await serverDB.insert(sessions).values([{ id: sessionId, userId }]);
|
|
661
|
-
|
|
662
|
-
const result = await messageModel.create({
|
|
663
|
-
content: 'message 1',
|
|
664
|
-
role: 'user',
|
|
665
|
-
sessionId: 'session1',
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
expect(result.id).toBeDefined();
|
|
669
|
-
expect(result.content).toBe('message 1');
|
|
670
|
-
expect(result.role).toBe('user');
|
|
671
|
-
expect(result.sessionId).toBe('session1');
|
|
672
|
-
expect(result.userId).toBe(userId);
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
it('should generate message ID automatically', async () => {
|
|
676
|
-
// Call createMessage method
|
|
677
|
-
await messageModel.create({
|
|
678
|
-
role: 'user',
|
|
679
|
-
content: 'new message',
|
|
680
|
-
sessionId: '1',
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
// Assert result
|
|
684
|
-
const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
|
|
685
|
-
expect(result[0].id).toBeDefined();
|
|
686
|
-
expect(result[0].id).toHaveLength(18);
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it('should create a tool message and insert into messagePlugins table', async () => {
|
|
690
|
-
// Call create method
|
|
691
|
-
const result = await messageModel.create({
|
|
692
|
-
content: 'message 1',
|
|
693
|
-
role: 'tool',
|
|
694
|
-
sessionId: '1',
|
|
695
|
-
tool_call_id: 'tool1',
|
|
696
|
-
plugin: {
|
|
697
|
-
apiName: 'api1',
|
|
698
|
-
arguments: 'arg1',
|
|
699
|
-
identifier: 'plugin1',
|
|
700
|
-
type: 'default',
|
|
701
|
-
},
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
// Assert result
|
|
705
|
-
expect(result.id).toBeDefined();
|
|
706
|
-
expect(result.content).toBe('message 1');
|
|
707
|
-
expect(result.role).toBe('tool');
|
|
708
|
-
expect(result.sessionId).toBe('1');
|
|
709
|
-
|
|
710
|
-
const pluginResult = await serverDB
|
|
711
|
-
.select()
|
|
712
|
-
.from(messagePlugins)
|
|
713
|
-
.where(eq(messagePlugins.id, result.id));
|
|
714
|
-
expect(pluginResult).toHaveLength(1);
|
|
715
|
-
expect(pluginResult[0].identifier).toBe('plugin1');
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
it('should create tool message ', async () => {
|
|
719
|
-
// Call create method
|
|
720
|
-
const state = {
|
|
721
|
-
query: 'Composio',
|
|
722
|
-
answers: [],
|
|
723
|
-
results: [
|
|
724
|
-
{
|
|
725
|
-
url: 'https://www.composio.dev/',
|
|
726
|
-
score: 16,
|
|
727
|
-
title: 'Composio - Connect 90+ tools to your AI agents',
|
|
728
|
-
engine: 'bing',
|
|
729
|
-
content:
|
|
730
|
-
'Faster DevelopmentHigher ReliabilityBetter Integrations. Get Started Now. Our platform lets you ditch the specs and seamlessly integrate any tool you need in less than 5 mins.',
|
|
731
|
-
engines: ['bing', 'qwant', 'brave', 'duckduckgo'],
|
|
732
|
-
category: 'general',
|
|
733
|
-
template: 'default.html',
|
|
734
|
-
positions: [1, 1, 1, 1],
|
|
735
|
-
thumbnail: '',
|
|
736
|
-
parsed_url: ['https', 'www.composio.dev', '/', '', '', ''],
|
|
737
|
-
publishedDate: null,
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
url: 'https://www.composio.co/',
|
|
741
|
-
score: 10.75,
|
|
742
|
-
title: 'Composio',
|
|
743
|
-
engine: 'bing',
|
|
744
|
-
content:
|
|
745
|
-
'Composio was created to help streamline the entire book creation process! Writing. Take time out to write / Make a schedule to write consistently. We have writing software that optimizes your books for printing or ebook format. Figure out what you want to write. Collaborate and write with others. Professional editing is a necessity.',
|
|
746
|
-
engines: ['qwant', 'duckduckgo', 'google', 'bing', 'brave'],
|
|
747
|
-
category: 'general',
|
|
748
|
-
template: 'default.html',
|
|
749
|
-
positions: [5, 2, 1, 5, 4],
|
|
750
|
-
thumbnail: null,
|
|
751
|
-
parsed_url: ['https', 'www.composio.co', '/', '', '', ''],
|
|
752
|
-
publishedDate: null,
|
|
753
|
-
},
|
|
754
|
-
],
|
|
755
|
-
unresponsive_engines: [],
|
|
756
|
-
};
|
|
757
|
-
const result = await messageModel.create({
|
|
758
|
-
content: '[{}]',
|
|
759
|
-
plugin: {
|
|
760
|
-
apiName: 'searchWithSearXNG',
|
|
761
|
-
arguments: '{\n "query": "Composio"\n}',
|
|
762
|
-
identifier: 'lobe-web-browsing',
|
|
763
|
-
type: 'builtin',
|
|
764
|
-
},
|
|
765
|
-
pluginState: state,
|
|
766
|
-
role: 'tool',
|
|
767
|
-
tool_call_id: 'tool_call_ymxXC2J0',
|
|
768
|
-
sessionId: '1',
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
// Assert result
|
|
772
|
-
expect(result.id).toBeDefined();
|
|
773
|
-
expect(result.content).toBe('[{}]');
|
|
774
|
-
expect(result.role).toBe('tool');
|
|
775
|
-
expect(result.sessionId).toBe('1');
|
|
776
|
-
|
|
777
|
-
const pluginResult = await serverDB
|
|
778
|
-
.select()
|
|
779
|
-
.from(messagePlugins)
|
|
780
|
-
.where(eq(messagePlugins.id, result.id));
|
|
781
|
-
expect(pluginResult).toHaveLength(1);
|
|
782
|
-
expect(pluginResult[0].identifier).toBe('lobe-web-browsing');
|
|
783
|
-
expect(pluginResult[0].state!).toMatchObject(state);
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
describe('create with advanced parameters', () => {
|
|
787
|
-
it('should create a message with custom ID', async () => {
|
|
788
|
-
const customId = 'custom-msg-id';
|
|
789
|
-
|
|
790
|
-
const result = await messageModel.create(
|
|
791
|
-
{
|
|
792
|
-
role: 'user',
|
|
793
|
-
content: 'message with custom ID',
|
|
794
|
-
sessionId: '1',
|
|
795
|
-
},
|
|
796
|
-
customId,
|
|
797
|
-
);
|
|
798
|
-
|
|
799
|
-
expect(result.id).toBe(customId);
|
|
800
|
-
|
|
801
|
-
// Verify database records
|
|
802
|
-
const dbResult = await serverDB.select().from(messages).where(eq(messages.id, customId));
|
|
803
|
-
expect(dbResult).toHaveLength(1);
|
|
804
|
-
expect(dbResult[0].id).toBe(customId);
|
|
805
|
-
});
|
|
806
|
-
|
|
807
|
-
it.skip('should create a message with file chunks and RAG query ID', async () => {
|
|
808
|
-
// Create test data
|
|
809
|
-
const chunkId1 = uuid();
|
|
810
|
-
const chunkId2 = uuid();
|
|
811
|
-
const ragQueryId = uuid();
|
|
812
|
-
|
|
813
|
-
await serverDB.insert(chunks).values([
|
|
814
|
-
{ id: chunkId1, text: 'chunk text 1' },
|
|
815
|
-
{ id: chunkId2, text: 'chunk text 2' },
|
|
816
|
-
]);
|
|
817
|
-
|
|
818
|
-
// Call create method
|
|
819
|
-
const result = await messageModel.create({
|
|
820
|
-
role: 'assistant',
|
|
821
|
-
content: 'message with file chunks',
|
|
822
|
-
fileChunks: [
|
|
823
|
-
{ id: chunkId1, similarity: 0.95 },
|
|
824
|
-
{ id: chunkId2, similarity: 0.85 },
|
|
825
|
-
],
|
|
826
|
-
ragQueryId,
|
|
827
|
-
sessionId: '1',
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
// Verify message created successfully
|
|
831
|
-
expect(result.id).toBeDefined();
|
|
832
|
-
|
|
833
|
-
// Verify message query chunk associations created successfully
|
|
834
|
-
const queryChunks = await serverDB
|
|
835
|
-
.select()
|
|
836
|
-
.from(messageQueryChunks)
|
|
837
|
-
.where(eq(messageQueryChunks.messageId, result.id));
|
|
838
|
-
|
|
839
|
-
expect(queryChunks).toHaveLength(2);
|
|
840
|
-
expect(queryChunks[0].chunkId).toBe(chunkId1);
|
|
841
|
-
expect(queryChunks[0].queryId).toBe(ragQueryId);
|
|
842
|
-
expect(queryChunks[0].similarity).toBe('0.95');
|
|
843
|
-
expect(queryChunks[1].chunkId).toBe(chunkId2);
|
|
844
|
-
expect(queryChunks[1].similarity).toBe('0.85');
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
it('should create a message with files', async () => {
|
|
848
|
-
// Create test data
|
|
849
|
-
await serverDB.insert(files).values([
|
|
850
|
-
{
|
|
851
|
-
id: 'file1',
|
|
852
|
-
name: 'file1.txt',
|
|
853
|
-
fileType: 'text/plain',
|
|
854
|
-
size: 100,
|
|
855
|
-
url: 'url1',
|
|
856
|
-
userId,
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
id: 'file2',
|
|
860
|
-
name: 'file2.jpg',
|
|
861
|
-
fileType: 'image/jpeg',
|
|
862
|
-
size: 200,
|
|
863
|
-
url: 'url2',
|
|
864
|
-
userId,
|
|
865
|
-
},
|
|
866
|
-
]);
|
|
867
|
-
|
|
868
|
-
// Call create method
|
|
869
|
-
const result = await messageModel.create({
|
|
870
|
-
role: 'user',
|
|
871
|
-
content: 'message with files',
|
|
872
|
-
files: ['file1', 'file2'],
|
|
873
|
-
sessionId: '1',
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
// Verify message created successfully
|
|
877
|
-
expect(result.id).toBeDefined();
|
|
878
|
-
|
|
879
|
-
// Verify message file associations created successfully
|
|
880
|
-
const messageFiles = await serverDB
|
|
881
|
-
.select()
|
|
882
|
-
.from(messagesFiles)
|
|
883
|
-
.where(eq(messagesFiles.messageId, result.id));
|
|
884
|
-
|
|
885
|
-
expect(messageFiles).toHaveLength(2);
|
|
886
|
-
expect(messageFiles[0].fileId).toBe('file1');
|
|
887
|
-
expect(messageFiles[1].fileId).toBe('file2');
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
it('should create a message with custom timestamps', async () => {
|
|
891
|
-
const customCreatedAt = '2022-05-15T10:30:00Z';
|
|
892
|
-
const customUpdatedAt = '2022-05-16T11:45:00Z';
|
|
893
|
-
|
|
894
|
-
const result = await messageModel.create({
|
|
895
|
-
role: 'user',
|
|
896
|
-
content: 'message with custom timestamps',
|
|
897
|
-
createdAt: customCreatedAt as any,
|
|
898
|
-
updatedAt: customUpdatedAt as any,
|
|
899
|
-
sessionId: '1',
|
|
900
|
-
});
|
|
901
|
-
|
|
902
|
-
// Verify database records
|
|
903
|
-
const dbResult = await serverDB.select().from(messages).where(eq(messages.id, result.id));
|
|
904
|
-
|
|
905
|
-
// Date comparison needs to consider timezone and formatting, so use toISOString for comparison
|
|
906
|
-
expect(new Date(dbResult[0].createdAt!).toISOString()).toBe(
|
|
907
|
-
new Date(customCreatedAt).toISOString(),
|
|
908
|
-
);
|
|
909
|
-
expect(new Date(dbResult[0].updatedAt!).toISOString()).toBe(
|
|
910
|
-
new Date(customUpdatedAt).toISOString(),
|
|
911
|
-
);
|
|
912
|
-
});
|
|
913
|
-
});
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
describe('batchCreateMessages', () => {
|
|
917
|
-
it('should batch create messages', async () => {
|
|
918
|
-
// Prepare test data
|
|
919
|
-
const newMessages = [
|
|
920
|
-
{ id: '1', role: 'user', content: 'message 1' },
|
|
921
|
-
{ id: '2', role: 'assistant', content: 'message 2' },
|
|
922
|
-
] as DBMessageItem[];
|
|
923
|
-
|
|
924
|
-
// Call batchCreateMessages method
|
|
925
|
-
await messageModel.batchCreate(newMessages);
|
|
926
|
-
|
|
927
|
-
// Assert result
|
|
928
|
-
const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
|
|
929
|
-
expect(result).toHaveLength(2);
|
|
930
|
-
expect(result[0].content).toBe('message 1');
|
|
931
|
-
expect(result[1].content).toBe('message 2');
|
|
932
|
-
});
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
describe('createNewMessage', () => {
|
|
936
|
-
it('should create message and return id with messages list', async () => {
|
|
937
|
-
// Call createNewMessage method
|
|
938
|
-
const result = await messageModel.createNewMessage({
|
|
939
|
-
role: 'user',
|
|
940
|
-
content: 'test message',
|
|
941
|
-
sessionId: '1',
|
|
942
|
-
});
|
|
943
|
-
|
|
944
|
-
// Assert return structure
|
|
945
|
-
expect(result).toHaveProperty('id');
|
|
946
|
-
expect(result).toHaveProperty('messages');
|
|
947
|
-
expect(result.id).toBeDefined();
|
|
948
|
-
expect(result.messages).toBeInstanceOf(Array);
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
it('should return newly created message in messages list', async () => {
|
|
952
|
-
const content = 'new test message ' + Date.now();
|
|
953
|
-
|
|
954
|
-
const result = await messageModel.createNewMessage({
|
|
955
|
-
role: 'user',
|
|
956
|
-
content,
|
|
957
|
-
sessionId: '1',
|
|
958
|
-
});
|
|
959
|
-
|
|
960
|
-
// Verify newly created message is in the list
|
|
961
|
-
const createdMessage = result.messages.find((m) => m.id === result.id);
|
|
962
|
-
expect(createdMessage).toBeDefined();
|
|
963
|
-
expect(createdMessage?.content).toBe(content);
|
|
964
|
-
expect(createdMessage?.role).toBe('user');
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
it('should return all messages for the session', async () => {
|
|
968
|
-
// Create multiple messages
|
|
969
|
-
await messageModel.create({ role: 'user', content: 'message 1', sessionId: '1' });
|
|
970
|
-
await messageModel.create({ role: 'assistant', content: 'message 2', sessionId: '1' });
|
|
971
|
-
|
|
972
|
-
// Create third message and get complete list
|
|
973
|
-
const result = await messageModel.createNewMessage({
|
|
974
|
-
role: 'user',
|
|
975
|
-
content: 'message 3',
|
|
976
|
-
sessionId: '1',
|
|
977
|
-
});
|
|
978
|
-
|
|
979
|
-
// Verify all messages are returned
|
|
980
|
-
expect(result.messages.length).toBeGreaterThanOrEqual(3);
|
|
981
|
-
});
|
|
982
|
-
|
|
983
|
-
it('should apply groupAssistantMessages transformation', async () => {
|
|
984
|
-
// Create an assistant message with tools
|
|
985
|
-
const assistantMsg = await messageModel.create({
|
|
986
|
-
role: 'assistant',
|
|
987
|
-
content: 'Checking weather',
|
|
988
|
-
tools: [
|
|
989
|
-
{
|
|
990
|
-
id: 'tool-1',
|
|
991
|
-
identifier: 'weather',
|
|
992
|
-
apiName: 'getWeather',
|
|
993
|
-
arguments: '{"city":"Beijing"}',
|
|
994
|
-
type: 'default',
|
|
995
|
-
},
|
|
996
|
-
],
|
|
997
|
-
sessionId: '1',
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
// Create corresponding tool message
|
|
1001
|
-
const toolMsg = await messageModel.create({
|
|
1002
|
-
role: 'tool',
|
|
1003
|
-
content: 'Beijing: Sunny, 25°C',
|
|
1004
|
-
tool_call_id: 'tool-1',
|
|
1005
|
-
sessionId: '1',
|
|
1006
|
-
plugin: {
|
|
1007
|
-
identifier: 'weather',
|
|
1008
|
-
apiName: 'getWeather',
|
|
1009
|
-
arguments: '{"city":"Beijing"}',
|
|
1010
|
-
type: 'default',
|
|
1011
|
-
},
|
|
1012
|
-
});
|
|
1013
|
-
|
|
1014
|
-
// Create new message and get list
|
|
1015
|
-
const result = await messageModel.createNewMessage({
|
|
1016
|
-
role: 'user',
|
|
1017
|
-
content: 'Thanks!',
|
|
1018
|
-
sessionId: '1',
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
// Verify assistant message is grouped
|
|
1022
|
-
const groupMessage = result.messages.find((m) => m.id === assistantMsg.id);
|
|
1023
|
-
expect(groupMessage?.role).toBe('group');
|
|
1024
|
-
expect(groupMessage?.children).toBeDefined();
|
|
1025
|
-
expect(groupMessage?.children).toHaveLength(1);
|
|
1026
|
-
|
|
1027
|
-
// Verify tool results are merged into children
|
|
1028
|
-
const childBlock = groupMessage?.children?.[0];
|
|
1029
|
-
expect(childBlock?.tools).toBeDefined();
|
|
1030
|
-
expect(childBlock?.tools).toHaveLength(1);
|
|
1031
|
-
|
|
1032
|
-
// Verify tool contains execution result
|
|
1033
|
-
const tool = childBlock?.tools?.[0];
|
|
1034
|
-
expect(tool?.id).toBe('tool-1');
|
|
1035
|
-
expect(tool?.identifier).toBe('weather');
|
|
1036
|
-
expect(tool?.result).toBeDefined();
|
|
1037
|
-
expect(tool?.result?.content).toBe('Beijing: Sunny, 25°C');
|
|
1038
|
-
});
|
|
1039
|
-
|
|
1040
|
-
it('should filter messages by topicId if provided', async () => {
|
|
1041
|
-
const topicId = 'topic-1';
|
|
1042
|
-
await serverDB.insert(topics).values({ id: topicId, sessionId: '1', userId });
|
|
1043
|
-
|
|
1044
|
-
// Create messages with different topics
|
|
1045
|
-
await messageModel.create({ role: 'user', content: 'topic 1 msg', sessionId: '1', topicId });
|
|
1046
|
-
await messageModel.create({ role: 'user', content: 'no topic msg', sessionId: '1' });
|
|
1047
|
-
|
|
1048
|
-
// Create new message and specify topicId
|
|
1049
|
-
const result = await messageModel.createNewMessage({
|
|
1050
|
-
role: 'user',
|
|
1051
|
-
content: 'new topic msg',
|
|
1052
|
-
sessionId: '1',
|
|
1053
|
-
topicId,
|
|
1054
|
-
});
|
|
1055
|
-
|
|
1056
|
-
// Verify only messages from that topic are returned
|
|
1057
|
-
expect(result.messages.every((m) => m.topicId === topicId || m.topicId === undefined)).toBe(
|
|
1058
|
-
true,
|
|
1059
|
-
);
|
|
1060
|
-
expect(result.messages.find((m) => m.content === 'no topic msg')).toBeUndefined();
|
|
1061
|
-
});
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
describe('updateMessage', () => {
|
|
1065
|
-
it('should update message content', async () => {
|
|
1066
|
-
// Create test data
|
|
1067
|
-
await serverDB
|
|
1068
|
-
.insert(messages)
|
|
1069
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1070
|
-
|
|
1071
|
-
// Call updateMessage method
|
|
1072
|
-
await messageModel.update('1', { content: 'updated message' });
|
|
1073
|
-
|
|
1074
|
-
// Assert result
|
|
1075
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1076
|
-
expect(result[0].content).toBe('updated message');
|
|
1077
|
-
});
|
|
1078
|
-
|
|
1079
|
-
it('should only update messages belonging to the user', async () => {
|
|
1080
|
-
// Create test data
|
|
1081
|
-
await serverDB
|
|
1082
|
-
.insert(messages)
|
|
1083
|
-
.values([{ id: '1', userId: '456', role: 'user', content: 'message 1' }]);
|
|
1084
|
-
|
|
1085
|
-
// Call updateMessage method
|
|
1086
|
-
await messageModel.update('1', { content: 'updated message' });
|
|
1087
|
-
|
|
1088
|
-
// Assert result
|
|
1089
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1090
|
-
expect(result[0].content).toBe('message 1');
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
it('should update message tools', async () => {
|
|
1094
|
-
// Create test data
|
|
1095
|
-
await serverDB.insert(messages).values([
|
|
1096
|
-
{
|
|
1097
|
-
id: '1',
|
|
1098
|
-
userId,
|
|
1099
|
-
role: 'user',
|
|
1100
|
-
content: 'message 1',
|
|
1101
|
-
tools: [
|
|
1102
|
-
{
|
|
1103
|
-
id: 'call_Z8UU8LedZcoJHFGkfqYecjmT',
|
|
1104
|
-
type: 'builtin',
|
|
1105
|
-
apiName: 'searchWithSearXNG',
|
|
1106
|
-
arguments:
|
|
1107
|
-
'{"query":"杭州洪水 2023","searchEngines":["google","bing","baidu","duckduckgo","brave"]}',
|
|
1108
|
-
identifier: 'lobe-web-browsing',
|
|
1109
|
-
},
|
|
1110
|
-
],
|
|
1111
|
-
},
|
|
1112
|
-
]);
|
|
1113
|
-
|
|
1114
|
-
// Call updateMessage method
|
|
1115
|
-
await messageModel.update('1', {
|
|
1116
|
-
tools: [
|
|
1117
|
-
{
|
|
1118
|
-
id: 'call_Z8UU8LedZcoJHFGkfqYecjmT',
|
|
1119
|
-
type: 'builtin',
|
|
1120
|
-
apiName: 'searchWithSearXNG',
|
|
1121
|
-
arguments: '{"query":"2024 杭州暴雨","searchEngines":["duckduckgo","google","brave"]}',
|
|
1122
|
-
identifier: 'lobe-web-browsing',
|
|
1123
|
-
},
|
|
1124
|
-
],
|
|
1125
|
-
});
|
|
1126
|
-
|
|
1127
|
-
// Assert result
|
|
1128
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1129
|
-
expect((result[0].tools as any)[0].arguments).toBe(
|
|
1130
|
-
'{"query":"2024 杭州暴雨","searchEngines":["duckduckgo","google","brave"]}',
|
|
1131
|
-
);
|
|
1132
|
-
});
|
|
1133
|
-
|
|
1134
|
-
describe('update with imageList', () => {
|
|
1135
|
-
it('should update a message and add image files', async () => {
|
|
1136
|
-
// Create test data
|
|
1137
|
-
await serverDB.insert(messages).values({
|
|
1138
|
-
id: 'msg-to-update',
|
|
1139
|
-
userId,
|
|
1140
|
-
role: 'user',
|
|
1141
|
-
content: 'original content',
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
await serverDB.insert(files).values([
|
|
1145
|
-
{
|
|
1146
|
-
id: 'img1',
|
|
1147
|
-
name: 'image1.jpg',
|
|
1148
|
-
fileType: 'image/jpeg',
|
|
1149
|
-
size: 100,
|
|
1150
|
-
url: 'url1',
|
|
1151
|
-
userId,
|
|
1152
|
-
},
|
|
1153
|
-
{ id: 'img2', name: 'image2.png', fileType: 'image/png', size: 200, url: 'url2', userId },
|
|
1154
|
-
]);
|
|
1155
|
-
|
|
1156
|
-
// Call update method
|
|
1157
|
-
await messageModel.update('msg-to-update', {
|
|
1158
|
-
content: 'updated content',
|
|
1159
|
-
imageList: [
|
|
1160
|
-
{ id: 'img1', alt: 'image 1', url: 'url1' },
|
|
1161
|
-
{ id: 'img2', alt: 'image 2', url: 'url2' },
|
|
1162
|
-
],
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
// Verify message updated successfully
|
|
1166
|
-
const updatedMessage = await serverDB
|
|
1167
|
-
.select()
|
|
1168
|
-
.from(messages)
|
|
1169
|
-
.where(eq(messages.id, 'msg-to-update'));
|
|
1170
|
-
|
|
1171
|
-
expect(updatedMessage[0].content).toBe('updated content');
|
|
1172
|
-
|
|
1173
|
-
// Verify message file associations created successfully
|
|
1174
|
-
const messageFiles = await serverDB
|
|
1175
|
-
.select()
|
|
1176
|
-
.from(messagesFiles)
|
|
1177
|
-
.where(eq(messagesFiles.messageId, 'msg-to-update'));
|
|
1178
|
-
|
|
1179
|
-
expect(messageFiles).toHaveLength(2);
|
|
1180
|
-
expect(messageFiles[0].fileId).toBe('img1');
|
|
1181
|
-
expect(messageFiles[1].fileId).toBe('img2');
|
|
1182
|
-
});
|
|
1183
|
-
|
|
1184
|
-
it('should handle empty imageList', async () => {
|
|
1185
|
-
// Create test data
|
|
1186
|
-
await serverDB.insert(messages).values({
|
|
1187
|
-
id: 'msg-no-images',
|
|
1188
|
-
userId,
|
|
1189
|
-
role: 'user',
|
|
1190
|
-
content: 'original content',
|
|
1191
|
-
});
|
|
1192
|
-
|
|
1193
|
-
// Call update method without providing imageList
|
|
1194
|
-
await messageModel.update('msg-no-images', {
|
|
1195
|
-
content: 'updated content',
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
// Verify message updated successfully
|
|
1199
|
-
const updatedMessage = await serverDB
|
|
1200
|
-
.select()
|
|
1201
|
-
.from(messages)
|
|
1202
|
-
.where(eq(messages.id, 'msg-no-images'));
|
|
1203
|
-
|
|
1204
|
-
expect(updatedMessage[0].content).toBe('updated content');
|
|
1205
|
-
|
|
1206
|
-
// Verify no message file associations created
|
|
1207
|
-
const messageFiles = await serverDB
|
|
1208
|
-
.select()
|
|
1209
|
-
.from(messagesFiles)
|
|
1210
|
-
.where(eq(messagesFiles.messageId, 'msg-no-images'));
|
|
1211
|
-
|
|
1212
|
-
expect(messageFiles).toHaveLength(0);
|
|
1213
|
-
});
|
|
1214
|
-
|
|
1215
|
-
it('should update multiple fields at once', async () => {
|
|
1216
|
-
// Create test data
|
|
1217
|
-
await serverDB.insert(messages).values({
|
|
1218
|
-
id: 'msg-multi-update',
|
|
1219
|
-
userId,
|
|
1220
|
-
role: 'user',
|
|
1221
|
-
content: 'original content',
|
|
1222
|
-
model: 'gpt-3.5',
|
|
1223
|
-
});
|
|
1224
|
-
|
|
1225
|
-
// Call update method to update multiple fields
|
|
1226
|
-
await messageModel.update('msg-multi-update', {
|
|
1227
|
-
content: 'updated content',
|
|
1228
|
-
role: 'assistant',
|
|
1229
|
-
model: 'gpt-4',
|
|
1230
|
-
metadata: { tps: 1 },
|
|
1231
|
-
});
|
|
1232
|
-
|
|
1233
|
-
// Verify message updated successfully
|
|
1234
|
-
const updatedMessage = await serverDB
|
|
1235
|
-
.select()
|
|
1236
|
-
.from(messages)
|
|
1237
|
-
.where(eq(messages.id, 'msg-multi-update'));
|
|
1238
|
-
|
|
1239
|
-
expect(updatedMessage[0].content).toBe('updated content');
|
|
1240
|
-
expect(updatedMessage[0].role).toBe('assistant');
|
|
1241
|
-
expect(updatedMessage[0].model).toBe('gpt-4');
|
|
1242
|
-
expect(updatedMessage[0].metadata).toEqual({ tps: 1 });
|
|
1243
|
-
});
|
|
1244
|
-
});
|
|
1245
|
-
|
|
1246
|
-
describe('update with returnQuery option', () => {
|
|
1247
|
-
it('should return updated message list when sessionId is provided', async () => {
|
|
1248
|
-
// Create test data
|
|
1249
|
-
const sessionId = '1';
|
|
1250
|
-
await serverDB.insert(messages).values([
|
|
1251
|
-
{
|
|
1252
|
-
id: 'msg1',
|
|
1253
|
-
userId,
|
|
1254
|
-
sessionId,
|
|
1255
|
-
role: 'user',
|
|
1256
|
-
content: 'message 1',
|
|
1257
|
-
},
|
|
1258
|
-
{
|
|
1259
|
-
id: 'msg2',
|
|
1260
|
-
userId,
|
|
1261
|
-
sessionId,
|
|
1262
|
-
role: 'assistant',
|
|
1263
|
-
content: 'message 2',
|
|
1264
|
-
},
|
|
1265
|
-
]);
|
|
1266
|
-
|
|
1267
|
-
// Call update method with sessionId option
|
|
1268
|
-
const result = await messageModel.update(
|
|
1269
|
-
'msg1',
|
|
1270
|
-
{ content: 'updated message 1' },
|
|
1271
|
-
{ sessionId },
|
|
1272
|
-
);
|
|
1273
|
-
|
|
1274
|
-
// Verify return result contains message list
|
|
1275
|
-
expect(result.success).toBe(true);
|
|
1276
|
-
expect(result.messages).toBeDefined();
|
|
1277
|
-
expect(result.messages).toHaveLength(2);
|
|
1278
|
-
expect(result.messages![0].content).toBe('updated message 1');
|
|
1279
|
-
expect(result.messages![1].content).toBe('message 2');
|
|
1280
|
-
});
|
|
1281
|
-
|
|
1282
|
-
it('should return updated message list when topicId is provided', async () => {
|
|
1283
|
-
// Create test data
|
|
1284
|
-
const sessionId = '1';
|
|
1285
|
-
const topicId = 'topic-1';
|
|
1286
|
-
await serverDB.insert(topics).values({ id: topicId, sessionId, userId });
|
|
1287
|
-
await serverDB.insert(messages).values([
|
|
1288
|
-
{
|
|
1289
|
-
id: 'msg-topic1',
|
|
1290
|
-
userId,
|
|
1291
|
-
sessionId,
|
|
1292
|
-
topicId,
|
|
1293
|
-
role: 'user',
|
|
1294
|
-
content: 'topic message 1',
|
|
1295
|
-
},
|
|
1296
|
-
{
|
|
1297
|
-
id: 'msg-topic2',
|
|
1298
|
-
userId,
|
|
1299
|
-
sessionId,
|
|
1300
|
-
topicId,
|
|
1301
|
-
role: 'assistant',
|
|
1302
|
-
content: 'topic message 2',
|
|
1303
|
-
},
|
|
1304
|
-
]);
|
|
1305
|
-
|
|
1306
|
-
// Call update method with topicId option
|
|
1307
|
-
const result = await messageModel.update(
|
|
1308
|
-
'msg-topic1',
|
|
1309
|
-
{ content: 'updated topic message 1' },
|
|
1310
|
-
{ topicId, sessionId },
|
|
1311
|
-
);
|
|
1312
|
-
|
|
1313
|
-
// Verify return result contains message list
|
|
1314
|
-
expect(result.success).toBe(true);
|
|
1315
|
-
expect(result.messages).toBeDefined();
|
|
1316
|
-
expect(result.messages).toHaveLength(2);
|
|
1317
|
-
expect(result.messages![0].content).toBe('updated topic message 1');
|
|
1318
|
-
expect(result.messages![1].content).toBe('topic message 2');
|
|
1319
|
-
});
|
|
1320
|
-
|
|
1321
|
-
it('should return success without messages when options not provided', async () => {
|
|
1322
|
-
// Create test data
|
|
1323
|
-
await serverDB.insert(messages).values({
|
|
1324
|
-
id: 'msg-no-options',
|
|
1325
|
-
userId,
|
|
1326
|
-
role: 'user',
|
|
1327
|
-
content: 'original content',
|
|
1328
|
-
});
|
|
1329
|
-
|
|
1330
|
-
// Call update method,不提供选项
|
|
1331
|
-
const result = await messageModel.update('msg-no-options', {
|
|
1332
|
-
content: 'updated content',
|
|
1333
|
-
});
|
|
1334
|
-
|
|
1335
|
-
// 验证返回结果不包含消息列表
|
|
1336
|
-
expect(result.success).toBe(true);
|
|
1337
|
-
expect(result.messages).toBeUndefined();
|
|
1338
|
-
});
|
|
1339
|
-
});
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
describe('deleteMessage', () => {
|
|
1343
|
-
it('should delete a message', async () => {
|
|
1344
|
-
// Create test data
|
|
1345
|
-
await serverDB
|
|
1346
|
-
.insert(messages)
|
|
1347
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1348
|
-
|
|
1349
|
-
// 调用 deleteMessage 方法
|
|
1350
|
-
await messageModel.deleteMessage('1');
|
|
1351
|
-
|
|
1352
|
-
// Assert result
|
|
1353
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1354
|
-
expect(result).toHaveLength(0);
|
|
1355
|
-
});
|
|
1356
|
-
|
|
1357
|
-
it('should delete a message with tool calls', async () => {
|
|
1358
|
-
// Create test data
|
|
1359
|
-
await serverDB.transaction(async (trx) => {
|
|
1360
|
-
await trx.insert(messages).values([
|
|
1361
|
-
{ id: '1', userId, role: 'user', content: 'message 1', tools: [{ id: 'tool1' }] },
|
|
1362
|
-
{ id: '2', userId, role: 'tool', content: 'message 1' },
|
|
1363
|
-
]);
|
|
1364
|
-
await trx
|
|
1365
|
-
.insert(messagePlugins)
|
|
1366
|
-
.values([{ id: '2', toolCallId: 'tool1', identifier: 'plugin-1', userId }]);
|
|
1367
|
-
});
|
|
1368
|
-
|
|
1369
|
-
// 调用 deleteMessage 方法
|
|
1370
|
-
await messageModel.deleteMessage('1');
|
|
1371
|
-
|
|
1372
|
-
// Assert result
|
|
1373
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1374
|
-
expect(result).toHaveLength(0);
|
|
1375
|
-
|
|
1376
|
-
const result2 = await serverDB
|
|
1377
|
-
.select()
|
|
1378
|
-
.from(messagePlugins)
|
|
1379
|
-
.where(eq(messagePlugins.id, '2'));
|
|
1380
|
-
|
|
1381
|
-
expect(result2).toHaveLength(0);
|
|
1382
|
-
});
|
|
1383
|
-
|
|
1384
|
-
it('should only delete messages belonging to the user', async () => {
|
|
1385
|
-
// Create test data
|
|
1386
|
-
await serverDB
|
|
1387
|
-
.insert(messages)
|
|
1388
|
-
.values([{ id: '1', userId: '456', role: 'user', content: 'message 1' }]);
|
|
1389
|
-
|
|
1390
|
-
// 调用 deleteMessage 方法
|
|
1391
|
-
await messageModel.deleteMessage('1');
|
|
1392
|
-
|
|
1393
|
-
// Assert result
|
|
1394
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1395
|
-
expect(result).toHaveLength(1);
|
|
1396
|
-
});
|
|
1397
|
-
});
|
|
1398
|
-
|
|
1399
|
-
describe('deleteMessages', () => {
|
|
1400
|
-
it('should delete 2 messages', async () => {
|
|
1401
|
-
// Create test data
|
|
1402
|
-
await serverDB.insert(messages).values([
|
|
1403
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
1404
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
1405
|
-
]);
|
|
1406
|
-
|
|
1407
|
-
// 调用 deleteMessage 方法
|
|
1408
|
-
await messageModel.deleteMessages(['1', '2']);
|
|
1409
|
-
|
|
1410
|
-
// Assert result
|
|
1411
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1412
|
-
expect(result).toHaveLength(0);
|
|
1413
|
-
const result2 = await serverDB.select().from(messages).where(eq(messages.id, '2'));
|
|
1414
|
-
expect(result2).toHaveLength(0);
|
|
1415
|
-
});
|
|
1416
|
-
|
|
1417
|
-
it('should only delete messages belonging to the user', async () => {
|
|
1418
|
-
// Create test data
|
|
1419
|
-
await serverDB.insert(messages).values([
|
|
1420
|
-
{ id: '1', userId: '456', role: 'user', content: 'message 1' },
|
|
1421
|
-
{ id: '2', userId: '456', role: 'user', content: 'message 1' },
|
|
1422
|
-
]);
|
|
1423
|
-
|
|
1424
|
-
// 调用 deleteMessage 方法
|
|
1425
|
-
await messageModel.deleteMessages(['1', '2']);
|
|
1426
|
-
|
|
1427
|
-
// Assert result
|
|
1428
|
-
const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
|
|
1429
|
-
expect(result).toHaveLength(1);
|
|
1430
|
-
});
|
|
1431
|
-
});
|
|
1432
|
-
|
|
1433
|
-
describe('deleteAllMessages', () => {
|
|
1434
|
-
it('should delete all messages belonging to the user', async () => {
|
|
1435
|
-
// Create test data
|
|
1436
|
-
await serverDB.insert(messages).values([
|
|
1437
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
1438
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
1439
|
-
{ id: '3', userId: '456', role: 'user', content: 'message 3' },
|
|
1440
|
-
]);
|
|
1441
|
-
|
|
1442
|
-
// 调用 deleteAllMessages 方法
|
|
1443
|
-
await messageModel.deleteAllMessages();
|
|
1444
|
-
|
|
1445
|
-
// Assert result
|
|
1446
|
-
const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
|
|
1447
|
-
|
|
1448
|
-
expect(result).toHaveLength(0);
|
|
1449
|
-
|
|
1450
|
-
const otherResult = await serverDB.select().from(messages).where(eq(messages.userId, '456'));
|
|
1451
|
-
|
|
1452
|
-
expect(otherResult).toHaveLength(1);
|
|
1453
|
-
});
|
|
1454
|
-
});
|
|
1455
|
-
|
|
1456
|
-
describe('updatePluginState', () => {
|
|
1457
|
-
it('should update the state field in messagePlugins table', async () => {
|
|
1458
|
-
// Create test data
|
|
1459
|
-
await serverDB.insert(messages).values({ id: '1', content: 'abc', role: 'user', userId });
|
|
1460
|
-
await serverDB.insert(messagePlugins).values([
|
|
1461
|
-
{
|
|
1462
|
-
id: '1',
|
|
1463
|
-
toolCallId: 'tool1',
|
|
1464
|
-
identifier: 'plugin1',
|
|
1465
|
-
state: { key1: 'value1' },
|
|
1466
|
-
userId,
|
|
1467
|
-
},
|
|
1468
|
-
]);
|
|
1469
|
-
|
|
1470
|
-
// 调用 updatePluginState 方法
|
|
1471
|
-
await messageModel.updatePluginState('1', { key2: 'value2' });
|
|
1472
|
-
|
|
1473
|
-
// Assert result
|
|
1474
|
-
const result = await serverDB.select().from(messagePlugins).where(eq(messagePlugins.id, '1'));
|
|
1475
|
-
|
|
1476
|
-
expect(result[0].state).toEqual({ key1: 'value1', key2: 'value2' });
|
|
1477
|
-
});
|
|
1478
|
-
|
|
1479
|
-
it('should throw an error if plugin does not exist', async () => {
|
|
1480
|
-
// 调用 updatePluginState 方法
|
|
1481
|
-
await expect(messageModel.updatePluginState('1', { key: 'value' })).rejects.toThrowError(
|
|
1482
|
-
'Plugin not found',
|
|
1483
|
-
);
|
|
1484
|
-
});
|
|
1485
|
-
});
|
|
1486
|
-
describe('updateMessagePlugin', () => {
|
|
1487
|
-
it('should update the state field in messagePlugins table', async () => {
|
|
1488
|
-
// Create test data
|
|
1489
|
-
await serverDB.insert(messages).values({ id: '1', content: 'abc', role: 'user', userId });
|
|
1490
|
-
await serverDB.insert(messagePlugins).values([
|
|
1491
|
-
{
|
|
1492
|
-
id: '1',
|
|
1493
|
-
toolCallId: 'tool1',
|
|
1494
|
-
identifier: 'plugin1',
|
|
1495
|
-
state: { key1: 'value1' },
|
|
1496
|
-
userId,
|
|
1497
|
-
},
|
|
1498
|
-
]);
|
|
1499
|
-
|
|
1500
|
-
// 调用 updatePluginState 方法
|
|
1501
|
-
await messageModel.updateMessagePlugin('1', { identifier: 'plugin2' });
|
|
1502
|
-
|
|
1503
|
-
// Assert result
|
|
1504
|
-
const result = await serverDB.select().from(messagePlugins).where(eq(messagePlugins.id, '1'));
|
|
1505
|
-
|
|
1506
|
-
expect(result[0].identifier).toEqual('plugin2');
|
|
1507
|
-
});
|
|
1508
|
-
|
|
1509
|
-
it('should throw an error if plugin does not exist', async () => {
|
|
1510
|
-
// 调用 updatePluginState 方法
|
|
1511
|
-
await expect(messageModel.updatePluginState('1', { key: 'value' })).rejects.toThrowError(
|
|
1512
|
-
'Plugin not found',
|
|
1513
|
-
);
|
|
1514
|
-
});
|
|
1515
|
-
});
|
|
1516
|
-
|
|
1517
|
-
describe('updateMetadata', () => {
|
|
1518
|
-
it('should update metadata for an existing message', async () => {
|
|
1519
|
-
// Create test data
|
|
1520
|
-
await serverDB.insert(messages).values({
|
|
1521
|
-
id: 'msg-with-metadata',
|
|
1522
|
-
userId,
|
|
1523
|
-
role: 'user',
|
|
1524
|
-
content: 'test message',
|
|
1525
|
-
metadata: { existingKey: 'existingValue' },
|
|
1526
|
-
});
|
|
1527
|
-
|
|
1528
|
-
// 调用 updateMetadata 方法
|
|
1529
|
-
await messageModel.updateMetadata('msg-with-metadata', { newKey: 'newValue' });
|
|
1530
|
-
|
|
1531
|
-
// Assert result
|
|
1532
|
-
const result = await serverDB
|
|
1533
|
-
.select()
|
|
1534
|
-
.from(messages)
|
|
1535
|
-
.where(eq(messages.id, 'msg-with-metadata'));
|
|
1536
|
-
|
|
1537
|
-
expect(result[0].metadata).toEqual({
|
|
1538
|
-
existingKey: 'existingValue',
|
|
1539
|
-
newKey: 'newValue',
|
|
1540
|
-
});
|
|
1541
|
-
});
|
|
1542
|
-
|
|
1543
|
-
it('should merge new metadata with existing metadata using lodash merge behavior', async () => {
|
|
1544
|
-
// Create test data
|
|
1545
|
-
await serverDB.insert(messages).values({
|
|
1546
|
-
id: 'msg-merge-metadata',
|
|
1547
|
-
userId,
|
|
1548
|
-
role: 'assistant',
|
|
1549
|
-
content: 'test message',
|
|
1550
|
-
metadata: {
|
|
1551
|
-
level1: {
|
|
1552
|
-
level2a: 'original',
|
|
1553
|
-
level2b: { level3: 'deep' },
|
|
1554
|
-
},
|
|
1555
|
-
array: [1, 2, 3],
|
|
1556
|
-
},
|
|
1557
|
-
});
|
|
1558
|
-
|
|
1559
|
-
// 调用 updateMetadata 方法
|
|
1560
|
-
await messageModel.updateMetadata('msg-merge-metadata', {
|
|
1561
|
-
level1: {
|
|
1562
|
-
level2a: 'updated',
|
|
1563
|
-
level2c: 'new',
|
|
1564
|
-
},
|
|
1565
|
-
newTopLevel: 'value',
|
|
1566
|
-
});
|
|
1567
|
-
|
|
1568
|
-
// Assert result - 应该使用 lodash merge 行为
|
|
1569
|
-
const result = await serverDB
|
|
1570
|
-
.select()
|
|
1571
|
-
.from(messages)
|
|
1572
|
-
.where(eq(messages.id, 'msg-merge-metadata'));
|
|
1573
|
-
|
|
1574
|
-
expect(result[0].metadata).toEqual({
|
|
1575
|
-
level1: {
|
|
1576
|
-
level2a: 'updated',
|
|
1577
|
-
level2b: { level3: 'deep' },
|
|
1578
|
-
level2c: 'new',
|
|
1579
|
-
},
|
|
1580
|
-
array: [1, 2, 3],
|
|
1581
|
-
newTopLevel: 'value',
|
|
1582
|
-
});
|
|
1583
|
-
});
|
|
1584
|
-
|
|
1585
|
-
it('should handle non-existent message IDs', async () => {
|
|
1586
|
-
// 调用 updateMetadata 方法,尝试更新不存在的消息
|
|
1587
|
-
const result = await messageModel.updateMetadata('non-existent-id', { key: 'value' });
|
|
1588
|
-
|
|
1589
|
-
// Assert result - 应该返回 undefined
|
|
1590
|
-
expect(result).toBeUndefined();
|
|
1591
|
-
});
|
|
1592
|
-
|
|
1593
|
-
it('should handle empty metadata updates', async () => {
|
|
1594
|
-
// Create test data
|
|
1595
|
-
await serverDB.insert(messages).values({
|
|
1596
|
-
id: 'msg-empty-metadata',
|
|
1597
|
-
userId,
|
|
1598
|
-
role: 'user',
|
|
1599
|
-
content: 'test message',
|
|
1600
|
-
metadata: { originalKey: 'originalValue' },
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
// 调用 updateMetadata 方法,传递空对象
|
|
1604
|
-
await messageModel.updateMetadata('msg-empty-metadata', {});
|
|
1605
|
-
|
|
1606
|
-
// Assert result - 原始 metadata 应该保持不变
|
|
1607
|
-
const result = await serverDB
|
|
1608
|
-
.select()
|
|
1609
|
-
.from(messages)
|
|
1610
|
-
.where(eq(messages.id, 'msg-empty-metadata'));
|
|
1611
|
-
|
|
1612
|
-
expect(result[0].metadata).toEqual({ originalKey: 'originalValue' });
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
it('should handle message with null metadata', async () => {
|
|
1616
|
-
// Create test data
|
|
1617
|
-
await serverDB.insert(messages).values({
|
|
1618
|
-
id: 'msg-null-metadata',
|
|
1619
|
-
userId,
|
|
1620
|
-
role: 'user',
|
|
1621
|
-
content: 'test message',
|
|
1622
|
-
metadata: null,
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
|
-
// 调用 updateMetadata 方法
|
|
1626
|
-
await messageModel.updateMetadata('msg-null-metadata', { key: 'value' });
|
|
1627
|
-
|
|
1628
|
-
// Assert result - 应该创建新的 metadata
|
|
1629
|
-
const result = await serverDB
|
|
1630
|
-
.select()
|
|
1631
|
-
.from(messages)
|
|
1632
|
-
.where(eq(messages.id, 'msg-null-metadata'));
|
|
1633
|
-
|
|
1634
|
-
expect(result[0].metadata).toEqual({ key: 'value' });
|
|
1635
|
-
});
|
|
1636
|
-
|
|
1637
|
-
it('should only update messages belonging to the current user', async () => {
|
|
1638
|
-
// Create test data - 其他用户的消息
|
|
1639
|
-
await serverDB.insert(messages).values({
|
|
1640
|
-
id: 'msg-other-user',
|
|
1641
|
-
userId: '456',
|
|
1642
|
-
role: 'user',
|
|
1643
|
-
content: 'test message',
|
|
1644
|
-
metadata: { originalKey: 'originalValue' },
|
|
1645
|
-
});
|
|
1646
|
-
|
|
1647
|
-
// 调用 updateMetadata 方法
|
|
1648
|
-
const result = await messageModel.updateMetadata('msg-other-user', {
|
|
1649
|
-
hackedKey: 'hackedValue',
|
|
1650
|
-
});
|
|
1651
|
-
|
|
1652
|
-
// Assert result - 应该返回 undefined
|
|
1653
|
-
expect(result).toBeUndefined();
|
|
1654
|
-
|
|
1655
|
-
// 验证原始 metadata 未被修改
|
|
1656
|
-
const dbResult = await serverDB
|
|
1657
|
-
.select()
|
|
1658
|
-
.from(messages)
|
|
1659
|
-
.where(eq(messages.id, 'msg-other-user'));
|
|
1660
|
-
|
|
1661
|
-
expect(dbResult[0].metadata).toEqual({ originalKey: 'originalValue' });
|
|
1662
|
-
});
|
|
1663
|
-
|
|
1664
|
-
it('should handle complex nested metadata updates', async () => {
|
|
1665
|
-
// Create test data
|
|
1666
|
-
await serverDB.insert(messages).values({
|
|
1667
|
-
id: 'msg-complex-metadata',
|
|
1668
|
-
userId,
|
|
1669
|
-
role: 'assistant',
|
|
1670
|
-
content: 'test message',
|
|
1671
|
-
metadata: {
|
|
1672
|
-
config: {
|
|
1673
|
-
settings: {
|
|
1674
|
-
enabled: true,
|
|
1675
|
-
options: ['a', 'b'],
|
|
1676
|
-
},
|
|
1677
|
-
version: 1,
|
|
1678
|
-
},
|
|
1679
|
-
},
|
|
1680
|
-
});
|
|
1681
|
-
|
|
1682
|
-
// 调用 updateMetadata 方法
|
|
1683
|
-
await messageModel.updateMetadata('msg-complex-metadata', {
|
|
1684
|
-
config: {
|
|
1685
|
-
settings: {
|
|
1686
|
-
enabled: false,
|
|
1687
|
-
timeout: 5000,
|
|
1688
|
-
},
|
|
1689
|
-
newField: 'value',
|
|
1690
|
-
},
|
|
1691
|
-
stats: { count: 10 },
|
|
1692
|
-
});
|
|
1693
|
-
|
|
1694
|
-
// Assert result
|
|
1695
|
-
const result = await serverDB
|
|
1696
|
-
.select()
|
|
1697
|
-
.from(messages)
|
|
1698
|
-
.where(eq(messages.id, 'msg-complex-metadata'));
|
|
1699
|
-
|
|
1700
|
-
expect(result[0].metadata).toEqual({
|
|
1701
|
-
config: {
|
|
1702
|
-
settings: {
|
|
1703
|
-
enabled: false,
|
|
1704
|
-
options: ['a', 'b'],
|
|
1705
|
-
timeout: 5000,
|
|
1706
|
-
},
|
|
1707
|
-
version: 1,
|
|
1708
|
-
newField: 'value',
|
|
1709
|
-
},
|
|
1710
|
-
stats: { count: 10 },
|
|
1711
|
-
});
|
|
1712
|
-
});
|
|
1713
|
-
});
|
|
1714
|
-
|
|
1715
|
-
describe('updateTranslate', () => {
|
|
1716
|
-
it('should insert a new record if message does not exist in messageTranslates table', async () => {
|
|
1717
|
-
// Create test data
|
|
1718
|
-
await serverDB
|
|
1719
|
-
.insert(messages)
|
|
1720
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1721
|
-
|
|
1722
|
-
// 调用 updateTranslate 方法
|
|
1723
|
-
await messageModel.updateTranslate('1', {
|
|
1724
|
-
content: 'translated message 1',
|
|
1725
|
-
from: 'en',
|
|
1726
|
-
to: 'zh',
|
|
1727
|
-
});
|
|
1728
|
-
|
|
1729
|
-
// Assert result
|
|
1730
|
-
const result = await serverDB
|
|
1731
|
-
.select()
|
|
1732
|
-
.from(messageTranslates)
|
|
1733
|
-
.where(eq(messageTranslates.id, '1'));
|
|
1734
|
-
|
|
1735
|
-
expect(result).toHaveLength(1);
|
|
1736
|
-
expect(result[0].content).toBe('translated message 1');
|
|
1737
|
-
});
|
|
1738
|
-
|
|
1739
|
-
it('should update the corresponding fields if message exists in messageTranslates table', async () => {
|
|
1740
|
-
// Create test data
|
|
1741
|
-
await serverDB.transaction(async (trx) => {
|
|
1742
|
-
await trx
|
|
1743
|
-
.insert(messages)
|
|
1744
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1745
|
-
await trx
|
|
1746
|
-
.insert(messageTranslates)
|
|
1747
|
-
.values([{ id: '1', content: 'translated message 1', from: 'en', to: 'zh', userId }]);
|
|
1748
|
-
});
|
|
1749
|
-
|
|
1750
|
-
// 调用 updateTranslate 方法
|
|
1751
|
-
await messageModel.updateTranslate('1', { content: 'updated translated message 1' });
|
|
1752
|
-
|
|
1753
|
-
// Assert result
|
|
1754
|
-
const result = await serverDB
|
|
1755
|
-
.select()
|
|
1756
|
-
.from(messageTranslates)
|
|
1757
|
-
.where(eq(messageTranslates.id, '1'));
|
|
1758
|
-
|
|
1759
|
-
expect(result[0].content).toBe('updated translated message 1');
|
|
1760
|
-
});
|
|
1761
|
-
});
|
|
1762
|
-
|
|
1763
|
-
describe('updateTTS', () => {
|
|
1764
|
-
it('should insert a new record if message does not exist in messageTTS table', async () => {
|
|
1765
|
-
// Create test data
|
|
1766
|
-
await serverDB
|
|
1767
|
-
.insert(messages)
|
|
1768
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1769
|
-
|
|
1770
|
-
// 调用 updateTTS 方法
|
|
1771
|
-
await messageModel.updateTTS('1', { contentMd5: 'md5', file: 'f1', voice: 'voice1' });
|
|
1772
|
-
|
|
1773
|
-
// Assert result
|
|
1774
|
-
const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
|
|
1775
|
-
|
|
1776
|
-
expect(result).toHaveLength(1);
|
|
1777
|
-
expect(result[0].voice).toBe('voice1');
|
|
1778
|
-
});
|
|
1779
|
-
|
|
1780
|
-
it('should update the corresponding fields if message exists in messageTTS table', async () => {
|
|
1781
|
-
// Create test data
|
|
1782
|
-
await serverDB.transaction(async (trx) => {
|
|
1783
|
-
await trx
|
|
1784
|
-
.insert(messages)
|
|
1785
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
1786
|
-
await trx
|
|
1787
|
-
.insert(messageTTS)
|
|
1788
|
-
.values([{ id: '1', contentMd5: 'md5', fileId: 'f1', voice: 'voice1', userId }]);
|
|
1789
|
-
});
|
|
1790
|
-
|
|
1791
|
-
// 调用 updateTTS 方法
|
|
1792
|
-
await messageModel.updateTTS('1', { voice: 'updated voice1' });
|
|
1793
|
-
|
|
1794
|
-
// Assert result
|
|
1795
|
-
const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
|
|
1796
|
-
|
|
1797
|
-
expect(result[0].voice).toBe('updated voice1');
|
|
1798
|
-
});
|
|
1799
|
-
});
|
|
1800
|
-
|
|
1801
|
-
describe('deleteMessageTranslate', () => {
|
|
1802
|
-
it('should delete the message translate record', async () => {
|
|
1803
|
-
// Create test data
|
|
1804
|
-
await serverDB.insert(messages).values([{ id: '1', role: 'abc', userId }]);
|
|
1805
|
-
await serverDB.insert(messageTranslates).values([{ id: '1', userId }]);
|
|
1806
|
-
|
|
1807
|
-
// 调用 deleteMessageTranslate 方法
|
|
1808
|
-
await messageModel.deleteMessageTranslate('1');
|
|
1809
|
-
|
|
1810
|
-
// Assert result
|
|
1811
|
-
const result = await serverDB
|
|
1812
|
-
.select()
|
|
1813
|
-
.from(messageTranslates)
|
|
1814
|
-
.where(eq(messageTranslates.id, '1'));
|
|
1815
|
-
|
|
1816
|
-
expect(result).toHaveLength(0);
|
|
1817
|
-
});
|
|
1818
|
-
});
|
|
1819
|
-
|
|
1820
|
-
describe('deleteMessageTTS', () => {
|
|
1821
|
-
it('should delete the message TTS record', async () => {
|
|
1822
|
-
// Create test data
|
|
1823
|
-
await serverDB.insert(messages).values([{ id: '1', role: 'abc', userId }]);
|
|
1824
|
-
await serverDB.insert(messageTTS).values([{ userId, id: '1' }]);
|
|
1825
|
-
|
|
1826
|
-
// 调用 deleteMessageTTS 方法
|
|
1827
|
-
await messageModel.deleteMessageTTS('1');
|
|
1828
|
-
|
|
1829
|
-
// Assert result
|
|
1830
|
-
const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
|
|
1831
|
-
expect(result).toHaveLength(0);
|
|
1832
|
-
});
|
|
1833
|
-
});
|
|
1834
|
-
|
|
1835
|
-
describe('count', () => {
|
|
1836
|
-
it('should return the count of messages belonging to the user', async () => {
|
|
1837
|
-
// Create test data
|
|
1838
|
-
await serverDB.insert(messages).values([
|
|
1839
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
1840
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
1841
|
-
{ id: '3', userId: '456', role: 'user', content: 'message 3' },
|
|
1842
|
-
]);
|
|
1843
|
-
|
|
1844
|
-
// 调用 count 方法
|
|
1845
|
-
const result = await messageModel.count();
|
|
1846
|
-
|
|
1847
|
-
// Assert result
|
|
1848
|
-
expect(result).toBe(2);
|
|
1849
|
-
});
|
|
1850
|
-
|
|
1851
|
-
describe('count with date filters', () => {
|
|
1852
|
-
beforeEach(async () => {
|
|
1853
|
-
// Create test data,包含不同日期的消息
|
|
1854
|
-
await serverDB.insert(messages).values([
|
|
1855
|
-
{
|
|
1856
|
-
id: 'date1',
|
|
1857
|
-
userId,
|
|
1858
|
-
role: 'user',
|
|
1859
|
-
content: 'message 1',
|
|
1860
|
-
createdAt: new Date('2023-01-15'),
|
|
1861
|
-
},
|
|
1862
|
-
{
|
|
1863
|
-
id: 'date2',
|
|
1864
|
-
userId,
|
|
1865
|
-
role: 'user',
|
|
1866
|
-
content: 'message 2',
|
|
1867
|
-
createdAt: new Date('2023-02-15'),
|
|
1868
|
-
},
|
|
1869
|
-
{
|
|
1870
|
-
id: 'date3',
|
|
1871
|
-
userId,
|
|
1872
|
-
role: 'user',
|
|
1873
|
-
content: 'message 3',
|
|
1874
|
-
createdAt: new Date('2023-03-15'),
|
|
1875
|
-
},
|
|
1876
|
-
{
|
|
1877
|
-
id: 'date4',
|
|
1878
|
-
userId,
|
|
1879
|
-
role: 'user',
|
|
1880
|
-
content: 'message 4',
|
|
1881
|
-
createdAt: new Date('2023-04-15'),
|
|
1882
|
-
},
|
|
1883
|
-
]);
|
|
1884
|
-
});
|
|
1885
|
-
|
|
1886
|
-
it('should count messages with startDate filter', async () => {
|
|
1887
|
-
const result = await messageModel.count({ startDate: '2023-02-01' });
|
|
1888
|
-
expect(result).toBe(3); // 2月15日, 3月15日, 4月15日的消息
|
|
1889
|
-
});
|
|
1890
|
-
|
|
1891
|
-
it('should count messages with endDate filter', async () => {
|
|
1892
|
-
const result = await messageModel.count({ endDate: '2023-03-01' });
|
|
1893
|
-
expect(result).toBe(2); // 1月15日, 2月15日的消息
|
|
1894
|
-
});
|
|
1895
|
-
|
|
1896
|
-
it('should count messages with both startDate and endDate filters', async () => {
|
|
1897
|
-
const result = await messageModel.count({
|
|
1898
|
-
startDate: '2023-02-01',
|
|
1899
|
-
endDate: '2023-03-31',
|
|
1900
|
-
});
|
|
1901
|
-
expect(result).toBe(2); // 2月15日, 3月15日的消息
|
|
1902
|
-
});
|
|
1903
|
-
|
|
1904
|
-
it('should count messages with range filter', async () => {
|
|
1905
|
-
const result = await messageModel.count({
|
|
1906
|
-
range: ['2023-02-01', '2023-04-01'],
|
|
1907
|
-
});
|
|
1908
|
-
expect(result).toBe(2); // 2月15日, 3月15日的消息
|
|
1909
|
-
});
|
|
1910
|
-
|
|
1911
|
-
it('should handle edge cases in date filters', async () => {
|
|
1912
|
-
// 边界日期
|
|
1913
|
-
const result1 = await messageModel.count({
|
|
1914
|
-
startDate: '2023-01-15',
|
|
1915
|
-
endDate: '2023-04-15',
|
|
1916
|
-
});
|
|
1917
|
-
expect(result1).toBe(4); // 包含所有消息
|
|
1918
|
-
|
|
1919
|
-
// 没有消息的日期范围
|
|
1920
|
-
const result2 = await messageModel.count({
|
|
1921
|
-
startDate: '2023-05-01',
|
|
1922
|
-
endDate: '2023-06-01',
|
|
1923
|
-
});
|
|
1924
|
-
expect(result2).toBe(0);
|
|
1925
|
-
|
|
1926
|
-
// 精确到一天
|
|
1927
|
-
const result3 = await messageModel.count({
|
|
1928
|
-
startDate: '2023-01-15',
|
|
1929
|
-
endDate: '2023-01-15',
|
|
1930
|
-
});
|
|
1931
|
-
expect(result3).toBe(1);
|
|
1932
|
-
});
|
|
1933
|
-
});
|
|
1934
|
-
});
|
|
1935
|
-
|
|
1936
|
-
describe('findMessageQueriesById', () => {
|
|
1937
|
-
it('should return undefined for non-existent message query', async () => {
|
|
1938
|
-
const result = await messageModel.findMessageQueriesById('non-existent-id');
|
|
1939
|
-
expect(result).toBeUndefined();
|
|
1940
|
-
});
|
|
1941
|
-
|
|
1942
|
-
it('should return message query with embeddings', async () => {
|
|
1943
|
-
const query1Id = uuid();
|
|
1944
|
-
const embeddings1Id = uuid();
|
|
1945
|
-
|
|
1946
|
-
await serverDB.transaction(async (trx) => {
|
|
1947
|
-
await trx.insert(messages).values({ id: 'msg1', userId, role: 'user', content: 'abc' });
|
|
1948
|
-
|
|
1949
|
-
await trx.insert(embeddings).values({
|
|
1950
|
-
id: embeddings1Id,
|
|
1951
|
-
embeddings: codeEmbedding,
|
|
1952
|
-
});
|
|
1953
|
-
|
|
1954
|
-
await trx.insert(messageQueries).values({
|
|
1955
|
-
id: query1Id,
|
|
1956
|
-
messageId: 'msg1',
|
|
1957
|
-
userQuery: 'test query',
|
|
1958
|
-
rewriteQuery: 'rewritten query',
|
|
1959
|
-
embeddingsId: embeddings1Id,
|
|
1960
|
-
userId,
|
|
1961
|
-
});
|
|
1962
|
-
});
|
|
1963
|
-
|
|
1964
|
-
const result = await messageModel.findMessageQueriesById('msg1');
|
|
1965
|
-
|
|
1966
|
-
expect(result).toBeDefined();
|
|
1967
|
-
expect(result).toMatchObject({
|
|
1968
|
-
id: query1Id,
|
|
1969
|
-
userQuery: 'test query',
|
|
1970
|
-
rewriteQuery: 'rewritten query',
|
|
1971
|
-
embeddings: codeEmbedding,
|
|
1972
|
-
});
|
|
1973
|
-
});
|
|
1974
|
-
});
|
|
1975
|
-
|
|
1976
|
-
describe('deleteMessagesBySession', () => {
|
|
1977
|
-
it('should delete messages by session ID', async () => {
|
|
1978
|
-
await serverDB.insert(sessions).values([
|
|
1979
|
-
{ id: 'session1', userId },
|
|
1980
|
-
{ id: 'session2', userId },
|
|
1981
|
-
]);
|
|
1982
|
-
|
|
1983
|
-
await serverDB.insert(messages).values([
|
|
1984
|
-
{
|
|
1985
|
-
id: '1',
|
|
1986
|
-
userId,
|
|
1987
|
-
sessionId: 'session1',
|
|
1988
|
-
role: 'user',
|
|
1989
|
-
content: 'message 1',
|
|
1990
|
-
},
|
|
1991
|
-
{
|
|
1992
|
-
id: '2',
|
|
1993
|
-
userId,
|
|
1994
|
-
sessionId: 'session1',
|
|
1995
|
-
role: 'assistant',
|
|
1996
|
-
content: 'message 2',
|
|
1997
|
-
},
|
|
1998
|
-
{
|
|
1999
|
-
id: '3',
|
|
2000
|
-
userId,
|
|
2001
|
-
sessionId: 'session2',
|
|
2002
|
-
role: 'user',
|
|
2003
|
-
content: 'message 3',
|
|
2004
|
-
},
|
|
2005
|
-
]);
|
|
2006
|
-
|
|
2007
|
-
await messageModel.deleteMessagesBySession('session1');
|
|
2008
|
-
|
|
2009
|
-
const remainingMessages = await serverDB
|
|
2010
|
-
.select()
|
|
2011
|
-
.from(messages)
|
|
2012
|
-
.where(eq(messages.userId, userId));
|
|
2013
|
-
|
|
2014
|
-
expect(remainingMessages).toHaveLength(1);
|
|
2015
|
-
expect(remainingMessages[0].id).toBe('3');
|
|
2016
|
-
});
|
|
2017
|
-
|
|
2018
|
-
it('should delete messages by session ID and topic ID', async () => {
|
|
2019
|
-
await serverDB.insert(sessions).values([{ id: 'session1', userId }]);
|
|
2020
|
-
await serverDB.insert(topics).values([
|
|
2021
|
-
{ id: 'topic1', sessionId: 'session1', userId },
|
|
2022
|
-
{ id: 'topic2', sessionId: 'session1', userId },
|
|
2023
|
-
]);
|
|
2024
|
-
|
|
2025
|
-
await serverDB.insert(messages).values([
|
|
2026
|
-
{
|
|
2027
|
-
id: '1',
|
|
2028
|
-
userId,
|
|
2029
|
-
sessionId: 'session1',
|
|
2030
|
-
topicId: 'topic1',
|
|
2031
|
-
role: 'user',
|
|
2032
|
-
content: 'message 1',
|
|
2033
|
-
},
|
|
2034
|
-
{
|
|
2035
|
-
id: '2',
|
|
2036
|
-
userId,
|
|
2037
|
-
sessionId: 'session1',
|
|
2038
|
-
topicId: 'topic2',
|
|
2039
|
-
role: 'assistant',
|
|
2040
|
-
content: 'message 2',
|
|
2041
|
-
},
|
|
2042
|
-
]);
|
|
2043
|
-
|
|
2044
|
-
await messageModel.deleteMessagesBySession('session1', 'topic1');
|
|
2045
|
-
|
|
2046
|
-
const remainingMessages = await serverDB
|
|
2047
|
-
.select()
|
|
2048
|
-
.from(messages)
|
|
2049
|
-
.where(eq(messages.userId, userId));
|
|
2050
|
-
|
|
2051
|
-
expect(remainingMessages).toHaveLength(1);
|
|
2052
|
-
expect(remainingMessages[0].id).toBe('2');
|
|
2053
|
-
});
|
|
2054
|
-
});
|
|
2055
|
-
|
|
2056
|
-
describe('genId', () => {
|
|
2057
|
-
it('should generate unique message IDs', () => {
|
|
2058
|
-
const model = new MessageModel(serverDB, userId);
|
|
2059
|
-
// @ts-ignore - accessing private method for testing
|
|
2060
|
-
const id1 = model.genId();
|
|
2061
|
-
// @ts-ignore - accessing private method for testing
|
|
2062
|
-
const id2 = model.genId();
|
|
2063
|
-
|
|
2064
|
-
expect(id1).toHaveLength(18);
|
|
2065
|
-
expect(id2).toHaveLength(18);
|
|
2066
|
-
expect(id1).not.toBe(id2);
|
|
2067
|
-
expect(id1).toMatch(/^msg_/);
|
|
2068
|
-
expect(id2).toMatch(/^msg_/);
|
|
2069
|
-
});
|
|
2070
|
-
});
|
|
2071
|
-
|
|
2072
|
-
describe('countWords', () => {
|
|
2073
|
-
it('should count total words of messages belonging to the user', async () => {
|
|
2074
|
-
// Create test data
|
|
2075
|
-
await serverDB.insert(messages).values([
|
|
2076
|
-
{ id: '1', userId, role: 'user', content: 'hello world' },
|
|
2077
|
-
{ id: '2', userId, role: 'user', content: 'test message' },
|
|
2078
|
-
{ id: '3', userId: '456', role: 'user', content: 'other user message' },
|
|
2079
|
-
]);
|
|
2080
|
-
|
|
2081
|
-
// 调用 countWords 方法
|
|
2082
|
-
const result = await messageModel.countWords();
|
|
2083
|
-
|
|
2084
|
-
// Assert result - 'hello world' + 'test message' = 23 characters
|
|
2085
|
-
expect(result).toEqual(23);
|
|
2086
|
-
});
|
|
2087
|
-
|
|
2088
|
-
it('should count words within date range', async () => {
|
|
2089
|
-
// Create test data
|
|
2090
|
-
await serverDB.insert(messages).values([
|
|
2091
|
-
{
|
|
2092
|
-
id: '1',
|
|
2093
|
-
userId,
|
|
2094
|
-
role: 'user',
|
|
2095
|
-
content: 'old message',
|
|
2096
|
-
createdAt: new Date('2023-01-01'),
|
|
2097
|
-
},
|
|
2098
|
-
{
|
|
2099
|
-
id: '2',
|
|
2100
|
-
userId,
|
|
2101
|
-
role: 'user',
|
|
2102
|
-
content: 'new message',
|
|
2103
|
-
createdAt: new Date('2023-06-01'),
|
|
2104
|
-
},
|
|
2105
|
-
]);
|
|
2106
|
-
|
|
2107
|
-
// 调用 countWords 方法,设置日期范围
|
|
2108
|
-
const result = await messageModel.countWords({
|
|
2109
|
-
range: ['2023-05-01', '2023-07-01'],
|
|
2110
|
-
});
|
|
2111
|
-
|
|
2112
|
-
// Assert result - 只计算 'new message' = 11 characters
|
|
2113
|
-
expect(result).toEqual(11);
|
|
2114
|
-
});
|
|
2115
|
-
|
|
2116
|
-
it('should handle empty content', async () => {
|
|
2117
|
-
// Create test data
|
|
2118
|
-
await serverDB.insert(messages).values([
|
|
2119
|
-
{ id: '1', userId, role: 'user', content: '' },
|
|
2120
|
-
{ id: '2', userId, role: 'user', content: null },
|
|
2121
|
-
]);
|
|
2122
|
-
|
|
2123
|
-
// 调用 countWords 方法
|
|
2124
|
-
const result = await messageModel.countWords();
|
|
2125
|
-
|
|
2126
|
-
// Assert result
|
|
2127
|
-
expect(result).toEqual(0);
|
|
2128
|
-
});
|
|
2129
|
-
});
|
|
2130
|
-
|
|
2131
|
-
describe('getHeatmaps', () => {
|
|
2132
|
-
it('should return heatmap data for the last year', async () => {
|
|
2133
|
-
// 使用固定日期进行测试
|
|
2134
|
-
vi.useFakeTimers();
|
|
2135
|
-
const fixedDate = new Date('2023-04-07T13:00:00Z');
|
|
2136
|
-
vi.setSystemTime(fixedDate);
|
|
2137
|
-
|
|
2138
|
-
const today = dayjs(fixedDate);
|
|
2139
|
-
const twoDaysAgoDate = today.subtract(2, 'day').format('YYYY-MM-DD');
|
|
2140
|
-
const oneDayAgoDate = today.subtract(1, 'day').format('YYYY-MM-DD');
|
|
2141
|
-
const todayDate = today.format('YYYY-MM-DD');
|
|
2142
|
-
|
|
2143
|
-
// Create test data
|
|
2144
|
-
await serverDB.insert(messages).values([
|
|
2145
|
-
{
|
|
2146
|
-
id: '1',
|
|
2147
|
-
userId,
|
|
2148
|
-
role: 'user',
|
|
2149
|
-
content: 'message 1',
|
|
2150
|
-
createdAt: today.subtract(2, 'day').toDate(),
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
id: '2',
|
|
2154
|
-
userId,
|
|
2155
|
-
role: 'user',
|
|
2156
|
-
content: 'message 2',
|
|
2157
|
-
createdAt: today.subtract(2, 'day').toDate(),
|
|
2158
|
-
},
|
|
2159
|
-
{
|
|
2160
|
-
id: '3',
|
|
2161
|
-
userId,
|
|
2162
|
-
role: 'user',
|
|
2163
|
-
content: 'message 3',
|
|
2164
|
-
createdAt: today.subtract(1, 'day').toDate(),
|
|
2165
|
-
},
|
|
2166
|
-
]);
|
|
2167
|
-
|
|
2168
|
-
// 调用 getHeatmaps 方法
|
|
2169
|
-
const result = await messageModel.getHeatmaps();
|
|
2170
|
-
|
|
2171
|
-
// Assert result
|
|
2172
|
-
expect(result.length).toBeGreaterThanOrEqual(366);
|
|
2173
|
-
expect(result.length).toBeLessThan(368);
|
|
2174
|
-
|
|
2175
|
-
// 检查两天前的数据
|
|
2176
|
-
const twoDaysAgo = result.find((item) => item.date === twoDaysAgoDate);
|
|
2177
|
-
expect(twoDaysAgo?.count).toBe(2);
|
|
2178
|
-
expect(twoDaysAgo?.level).toBe(1);
|
|
2179
|
-
|
|
2180
|
-
// 检查一天前的数据
|
|
2181
|
-
const oneDayAgo = result.find((item) => item.date === oneDayAgoDate);
|
|
2182
|
-
expect(oneDayAgo?.count).toBe(1);
|
|
2183
|
-
expect(oneDayAgo?.level).toBe(1);
|
|
2184
|
-
|
|
2185
|
-
// 检查今天的数据
|
|
2186
|
-
const todayData = result.find((item) => item.date === todayDate);
|
|
2187
|
-
expect(todayData?.count).toBe(0);
|
|
2188
|
-
expect(todayData?.level).toBe(0);
|
|
2189
|
-
|
|
2190
|
-
vi.useRealTimers();
|
|
2191
|
-
});
|
|
2192
|
-
|
|
2193
|
-
it('should calculate correct levels based on message count', async () => {
|
|
2194
|
-
// 使用固定日期进行测试
|
|
2195
|
-
vi.useFakeTimers();
|
|
2196
|
-
const fixedDate = new Date('2023-05-15T12:00:00Z');
|
|
2197
|
-
vi.setSystemTime(fixedDate);
|
|
2198
|
-
|
|
2199
|
-
const today = dayjs(fixedDate);
|
|
2200
|
-
const fourDaysAgoDate = today.subtract(4, 'day').format('YYYY-MM-DD');
|
|
2201
|
-
const threeDaysAgoDate = today.subtract(3, 'day').format('YYYY-MM-DD');
|
|
2202
|
-
const twoDaysAgoDate = today.subtract(2, 'day').format('YYYY-MM-DD');
|
|
2203
|
-
const oneDayAgoDate = today.subtract(1, 'day').format('YYYY-MM-DD');
|
|
2204
|
-
const todayDate = today.format('YYYY-MM-DD');
|
|
2205
|
-
|
|
2206
|
-
// Create test data - 不同数量的消息以测试不同的等级
|
|
2207
|
-
await serverDB.insert(messages).values([
|
|
2208
|
-
// 1 message - level 1
|
|
2209
|
-
{
|
|
2210
|
-
id: '1',
|
|
2211
|
-
userId,
|
|
2212
|
-
role: 'user',
|
|
2213
|
-
content: 'message 1',
|
|
2214
|
-
createdAt: today.subtract(4, 'day').toDate(),
|
|
2215
|
-
},
|
|
2216
|
-
// 6 messages - level 2
|
|
2217
|
-
...Array(6)
|
|
2218
|
-
.fill(0)
|
|
2219
|
-
.map((_, i) => ({
|
|
2220
|
-
id: `2-${i}`,
|
|
2221
|
-
userId,
|
|
2222
|
-
role: 'user',
|
|
2223
|
-
content: `message 2-${i}`,
|
|
2224
|
-
createdAt: today.subtract(3, 'day').toDate(),
|
|
2225
|
-
})),
|
|
2226
|
-
// 11 messages - level 3
|
|
2227
|
-
...Array(11)
|
|
2228
|
-
.fill(0)
|
|
2229
|
-
.map((_, i) => ({
|
|
2230
|
-
id: `3-${i}`,
|
|
2231
|
-
userId,
|
|
2232
|
-
role: 'user',
|
|
2233
|
-
content: `message 3-${i}`,
|
|
2234
|
-
createdAt: today.subtract(2, 'day').toDate(),
|
|
2235
|
-
})),
|
|
2236
|
-
// 16 messages - level 4
|
|
2237
|
-
...Array(16)
|
|
2238
|
-
.fill(0)
|
|
2239
|
-
.map((_, i) => ({
|
|
2240
|
-
id: `4-${i}`,
|
|
2241
|
-
userId,
|
|
2242
|
-
role: 'user',
|
|
2243
|
-
content: `message 4-${i}`,
|
|
2244
|
-
createdAt: today.subtract(1, 'day').toDate(),
|
|
2245
|
-
})),
|
|
2246
|
-
// 21 messages - level 4
|
|
2247
|
-
...Array(21)
|
|
2248
|
-
.fill(0)
|
|
2249
|
-
.map((_, i) => ({
|
|
2250
|
-
id: `5-${i}`,
|
|
2251
|
-
userId,
|
|
2252
|
-
role: 'user',
|
|
2253
|
-
content: `message 5-${i}`,
|
|
2254
|
-
createdAt: today.toDate(),
|
|
2255
|
-
})),
|
|
2256
|
-
]);
|
|
2257
|
-
|
|
2258
|
-
// 调用 getHeatmaps 方法
|
|
2259
|
-
const result = await messageModel.getHeatmaps();
|
|
2260
|
-
|
|
2261
|
-
// 检查不同天数的等级
|
|
2262
|
-
const fourDaysAgo = result.find((item) => item.date === fourDaysAgoDate);
|
|
2263
|
-
expect(fourDaysAgo?.count).toBe(1);
|
|
2264
|
-
expect(fourDaysAgo?.level).toBe(1);
|
|
2265
|
-
|
|
2266
|
-
const threeDaysAgo = result.find((item) => item.date === threeDaysAgoDate);
|
|
2267
|
-
expect(threeDaysAgo?.count).toBe(6);
|
|
2268
|
-
expect(threeDaysAgo?.level).toBe(2);
|
|
2269
|
-
|
|
2270
|
-
const twoDaysAgo = result.find((item) => item.date === twoDaysAgoDate);
|
|
2271
|
-
expect(twoDaysAgo?.count).toBe(11);
|
|
2272
|
-
expect(twoDaysAgo?.level).toBe(3);
|
|
2273
|
-
|
|
2274
|
-
const oneDayAgo = result.find((item) => item.date === oneDayAgoDate);
|
|
2275
|
-
expect(oneDayAgo?.count).toBe(16);
|
|
2276
|
-
expect(oneDayAgo?.level).toBe(4);
|
|
2277
|
-
|
|
2278
|
-
const todayData = result.find((item) => item.date === todayDate);
|
|
2279
|
-
expect(todayData?.count).toBe(21);
|
|
2280
|
-
expect(todayData?.level).toBe(4);
|
|
2281
|
-
|
|
2282
|
-
vi.useRealTimers();
|
|
2283
|
-
});
|
|
2284
|
-
|
|
2285
|
-
it.skip('should return time count correctly when 19:00 time', async () => {
|
|
2286
|
-
// 使用固定日期进行测试
|
|
2287
|
-
vi.useFakeTimers();
|
|
2288
|
-
const fixedDate = new Date('2025-04-02T19:00:00Z');
|
|
2289
|
-
vi.setSystemTime(fixedDate);
|
|
2290
|
-
|
|
2291
|
-
const today = dayjs(fixedDate);
|
|
2292
|
-
const twoDaysAgoDate = today.subtract(2, 'day').format('YYYY-MM-DD');
|
|
2293
|
-
const oneDayAgoDate = today.subtract(1, 'day').format('YYYY-MM-DD');
|
|
2294
|
-
const todayDate = today.format('YYYY-MM-DD');
|
|
2295
|
-
|
|
2296
|
-
// Create test data
|
|
2297
|
-
await serverDB.insert(messages).values([
|
|
2298
|
-
{
|
|
2299
|
-
id: '1',
|
|
2300
|
-
userId,
|
|
2301
|
-
role: 'user',
|
|
2302
|
-
content: 'message 1',
|
|
2303
|
-
createdAt: today.subtract(2, 'day').toDate(),
|
|
2304
|
-
},
|
|
2305
|
-
{
|
|
2306
|
-
id: '2',
|
|
2307
|
-
userId,
|
|
2308
|
-
role: 'user',
|
|
2309
|
-
content: 'message 2',
|
|
2310
|
-
createdAt: today.subtract(2, 'day').toDate(),
|
|
2311
|
-
},
|
|
2312
|
-
{
|
|
2313
|
-
id: '3',
|
|
2314
|
-
userId,
|
|
2315
|
-
role: 'user',
|
|
2316
|
-
content: 'message 3',
|
|
2317
|
-
createdAt: today.subtract(1, 'day').toDate(),
|
|
2318
|
-
},
|
|
2319
|
-
]);
|
|
2320
|
-
|
|
2321
|
-
// 调用 getHeatmaps 方法
|
|
2322
|
-
const result = await messageModel.getHeatmaps();
|
|
2323
|
-
|
|
2324
|
-
// Assert result
|
|
2325
|
-
expect(result.length).toBeGreaterThanOrEqual(366);
|
|
2326
|
-
expect(result.length).toBeLessThan(368);
|
|
2327
|
-
|
|
2328
|
-
// 检查两天前的数据
|
|
2329
|
-
const twoDaysAgo = result.find((item) => item.date === twoDaysAgoDate);
|
|
2330
|
-
expect(twoDaysAgo?.count).toBe(2);
|
|
2331
|
-
expect(twoDaysAgo?.level).toBe(1);
|
|
2332
|
-
|
|
2333
|
-
// 检查一天前的数据
|
|
2334
|
-
const oneDayAgo = result.find((item) => item.date === oneDayAgoDate);
|
|
2335
|
-
expect(oneDayAgo?.count).toBe(1);
|
|
2336
|
-
expect(oneDayAgo?.level).toBe(1);
|
|
2337
|
-
|
|
2338
|
-
// 检查今天的数据
|
|
2339
|
-
const todayData = result.find((item) => item.date === todayDate);
|
|
2340
|
-
expect(todayData?.count).toBe(0);
|
|
2341
|
-
expect(todayData?.level).toBe(0);
|
|
2342
|
-
|
|
2343
|
-
vi.useRealTimers();
|
|
2344
|
-
});
|
|
2345
|
-
|
|
2346
|
-
it('should handle empty data', async () => {
|
|
2347
|
-
// 不创建任何消息数据
|
|
2348
|
-
|
|
2349
|
-
// 调用 getHeatmaps 方法
|
|
2350
|
-
const result = await messageModel.getHeatmaps();
|
|
2351
|
-
|
|
2352
|
-
// Assert result
|
|
2353
|
-
expect(result.length).toBeGreaterThanOrEqual(366);
|
|
2354
|
-
expect(result.length).toBeLessThan(368);
|
|
2355
|
-
|
|
2356
|
-
// 检查所有数据的 count 和 level 是否为 0
|
|
2357
|
-
result.forEach((item) => {
|
|
2358
|
-
expect(item.count).toBe(0);
|
|
2359
|
-
expect(item.level).toBe(0);
|
|
2360
|
-
});
|
|
2361
|
-
});
|
|
2362
|
-
});
|
|
2363
|
-
|
|
2364
|
-
describe('rankModels', () => {
|
|
2365
|
-
it('should rank models by usage count', async () => {
|
|
2366
|
-
// Create test data
|
|
2367
|
-
await serverDB.insert(messages).values([
|
|
2368
|
-
{ id: '1', userId, role: 'assistant', content: 'message 1', model: 'gpt-3.5' },
|
|
2369
|
-
{ id: '2', userId, role: 'assistant', content: 'message 2', model: 'gpt-3.5' },
|
|
2370
|
-
{ id: '3', userId, role: 'assistant', content: 'message 3', model: 'gpt-4' },
|
|
2371
|
-
{ id: '4', userId: '456', role: 'assistant', content: 'message 4', model: 'gpt-3.5' }, // 其他用户的消息
|
|
2372
|
-
]);
|
|
2373
|
-
|
|
2374
|
-
// 调用 rankModels 方法
|
|
2375
|
-
const result = await messageModel.rankModels();
|
|
2376
|
-
|
|
2377
|
-
// Assert result
|
|
2378
|
-
expect(result).toHaveLength(2);
|
|
2379
|
-
expect(result[0]).toEqual({ id: 'gpt-3.5', count: 2 }); // 当前用户使用 gpt-3.5 两次
|
|
2380
|
-
expect(result[1]).toEqual({ id: 'gpt-4', count: 1 }); // 当前用户使用 gpt-4 一次
|
|
2381
|
-
});
|
|
2382
|
-
|
|
2383
|
-
it('should only count messages with model field', async () => {
|
|
2384
|
-
// Create test data,包括没有 model 字段的消息
|
|
2385
|
-
await serverDB.insert(messages).values([
|
|
2386
|
-
{ id: '1', userId, role: 'assistant', content: 'message 1', model: 'gpt-3.5' },
|
|
2387
|
-
{ id: '2', userId, role: 'assistant', content: 'message 2', model: null },
|
|
2388
|
-
{ id: '3', userId, role: 'user', content: 'message 3' }, // 用户消息通常没有 model
|
|
2389
|
-
]);
|
|
2390
|
-
|
|
2391
|
-
// 调用 rankModels 方法
|
|
2392
|
-
const result = await messageModel.rankModels();
|
|
2393
|
-
|
|
2394
|
-
// Assert result
|
|
2395
|
-
expect(result).toHaveLength(1);
|
|
2396
|
-
expect(result[0]).toEqual({ id: 'gpt-3.5', count: 1 });
|
|
2397
|
-
});
|
|
2398
|
-
|
|
2399
|
-
it('should return empty array when no models are used', async () => {
|
|
2400
|
-
// Create test data,所有消息都没有 model
|
|
2401
|
-
await serverDB.insert(messages).values([
|
|
2402
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
2403
|
-
{ id: '2', userId, role: 'assistant', content: 'message 2' },
|
|
2404
|
-
]);
|
|
2405
|
-
|
|
2406
|
-
// 调用 rankModels 方法
|
|
2407
|
-
const result = await messageModel.rankModels();
|
|
2408
|
-
|
|
2409
|
-
// Assert result
|
|
2410
|
-
expect(result).toHaveLength(0);
|
|
2411
|
-
});
|
|
2412
|
-
|
|
2413
|
-
it('should order models by count in descending order', async () => {
|
|
2414
|
-
// Create test data,使用不同次数的模型
|
|
2415
|
-
await serverDB.insert(messages).values([
|
|
2416
|
-
{ id: '1', userId, role: 'assistant', content: 'message 1', model: 'gpt-4' },
|
|
2417
|
-
{ id: '2', userId, role: 'assistant', content: 'message 2', model: 'gpt-3.5' },
|
|
2418
|
-
{ id: '3', userId, role: 'assistant', content: 'message 3', model: 'gpt-3.5' },
|
|
2419
|
-
{ id: '4', userId, role: 'assistant', content: 'message 4', model: 'claude' },
|
|
2420
|
-
{ id: '5', userId, role: 'assistant', content: 'message 5', model: 'gpt-3.5' },
|
|
2421
|
-
]);
|
|
2422
|
-
|
|
2423
|
-
// 调用 rankModels 方法
|
|
2424
|
-
const result = await messageModel.rankModels();
|
|
2425
|
-
|
|
2426
|
-
// Assert result
|
|
2427
|
-
expect(result).toHaveLength(3);
|
|
2428
|
-
expect(result[0]).toEqual({ id: 'gpt-3.5', count: 3 }); // 最多使用
|
|
2429
|
-
expect(result[1]).toEqual({ id: 'claude', count: 1 });
|
|
2430
|
-
expect(result[2]).toEqual({ id: 'gpt-4', count: 1 });
|
|
2431
|
-
});
|
|
2432
|
-
});
|
|
2433
|
-
|
|
2434
|
-
describe('hasMoreThanN', () => {
|
|
2435
|
-
it('should return true when message count is greater than N', async () => {
|
|
2436
|
-
// Create test data
|
|
2437
|
-
await serverDB.insert(messages).values([
|
|
2438
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
2439
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
2440
|
-
{ id: '3', userId, role: 'user', content: 'message 3' },
|
|
2441
|
-
]);
|
|
2442
|
-
|
|
2443
|
-
// 测试不同的 N 值
|
|
2444
|
-
const result1 = await messageModel.hasMoreThanN(2); // 3 > 2
|
|
2445
|
-
const result2 = await messageModel.hasMoreThanN(3); // 3 ≯ 3
|
|
2446
|
-
const result3 = await messageModel.hasMoreThanN(4); // 3 ≯ 4
|
|
2447
|
-
|
|
2448
|
-
expect(result1).toBe(true);
|
|
2449
|
-
expect(result2).toBe(false);
|
|
2450
|
-
expect(result3).toBe(false);
|
|
2451
|
-
});
|
|
2452
|
-
|
|
2453
|
-
it('should only count messages belonging to the user', async () => {
|
|
2454
|
-
// Create test data,包括其他用户的消息
|
|
2455
|
-
await serverDB.insert(messages).values([
|
|
2456
|
-
{ id: '1', userId, role: 'user', content: 'message 1' },
|
|
2457
|
-
{ id: '2', userId, role: 'user', content: 'message 2' },
|
|
2458
|
-
{ id: '3', userId: '456', role: 'user', content: 'message 3' }, // 其他用户的消息
|
|
2459
|
-
]);
|
|
2460
|
-
|
|
2461
|
-
const result = await messageModel.hasMoreThanN(2);
|
|
2462
|
-
|
|
2463
|
-
expect(result).toBe(false); // 当前用户只有 2 条消息,不大于 2
|
|
2464
|
-
});
|
|
2465
|
-
|
|
2466
|
-
it('should return false when no messages exist', async () => {
|
|
2467
|
-
const result = await messageModel.hasMoreThanN(0);
|
|
2468
|
-
expect(result).toBe(false);
|
|
2469
|
-
});
|
|
2470
|
-
|
|
2471
|
-
it('should handle edge cases', async () => {
|
|
2472
|
-
// 创建一条消息
|
|
2473
|
-
await serverDB
|
|
2474
|
-
.insert(messages)
|
|
2475
|
-
.values([{ id: '1', userId, role: 'user', content: 'message 1' }]);
|
|
2476
|
-
|
|
2477
|
-
// 测试边界情况
|
|
2478
|
-
const result1 = await messageModel.hasMoreThanN(0); // 1 > 0
|
|
2479
|
-
const result2 = await messageModel.hasMoreThanN(1); // 1 ≯ 1
|
|
2480
|
-
const result3 = await messageModel.hasMoreThanN(-1); // 1 > -1
|
|
2481
|
-
|
|
2482
|
-
expect(result1).toBe(true);
|
|
2483
|
-
expect(result2).toBe(false);
|
|
2484
|
-
expect(result3).toBe(true);
|
|
2485
|
-
});
|
|
2486
|
-
});
|
|
2487
|
-
|
|
2488
|
-
describe('createMessageQuery', () => {
|
|
2489
|
-
it('should create a new message query', async () => {
|
|
2490
|
-
// Create test data
|
|
2491
|
-
await serverDB.insert(messages).values({
|
|
2492
|
-
id: 'msg1',
|
|
2493
|
-
userId,
|
|
2494
|
-
role: 'user',
|
|
2495
|
-
content: 'test message',
|
|
2496
|
-
});
|
|
2497
|
-
|
|
2498
|
-
// 调用 createMessageQuery 方法
|
|
2499
|
-
const result = await messageModel.createMessageQuery({
|
|
2500
|
-
messageId: 'msg1',
|
|
2501
|
-
userQuery: 'original query',
|
|
2502
|
-
rewriteQuery: 'rewritten query',
|
|
2503
|
-
embeddingsId,
|
|
2504
|
-
});
|
|
2505
|
-
|
|
2506
|
-
// Assert result
|
|
2507
|
-
expect(result).toBeDefined();
|
|
2508
|
-
expect(result.id).toBeDefined();
|
|
2509
|
-
expect(result.messageId).toBe('msg1');
|
|
2510
|
-
expect(result.userQuery).toBe('original query');
|
|
2511
|
-
expect(result.rewriteQuery).toBe('rewritten query');
|
|
2512
|
-
expect(result.userId).toBe(userId);
|
|
2513
|
-
|
|
2514
|
-
// 验证数据库中的记录
|
|
2515
|
-
const dbResult = await serverDB
|
|
2516
|
-
.select()
|
|
2517
|
-
.from(messageQueries)
|
|
2518
|
-
.where(eq(messageQueries.id, result.id));
|
|
2519
|
-
|
|
2520
|
-
expect(dbResult).toHaveLength(1);
|
|
2521
|
-
expect(dbResult[0].messageId).toBe('msg1');
|
|
2522
|
-
expect(dbResult[0].userQuery).toBe('original query');
|
|
2523
|
-
expect(dbResult[0].rewriteQuery).toBe('rewritten query');
|
|
2524
|
-
});
|
|
2525
|
-
|
|
2526
|
-
it('should create a message query with embeddings ID', async () => {
|
|
2527
|
-
// Create test data
|
|
2528
|
-
await serverDB.insert(messages).values({
|
|
2529
|
-
id: 'msg2',
|
|
2530
|
-
userId,
|
|
2531
|
-
role: 'user',
|
|
2532
|
-
content: 'test message',
|
|
2533
|
-
});
|
|
2534
|
-
|
|
2535
|
-
// 调用 createMessageQuery 方法
|
|
2536
|
-
const result = await messageModel.createMessageQuery({
|
|
2537
|
-
messageId: 'msg2',
|
|
2538
|
-
userQuery: 'test query',
|
|
2539
|
-
rewriteQuery: 'test rewritten query',
|
|
2540
|
-
embeddingsId,
|
|
2541
|
-
});
|
|
2542
|
-
|
|
2543
|
-
// Assert result
|
|
2544
|
-
expect(result).toBeDefined();
|
|
2545
|
-
expect(result.embeddingsId).toBe(embeddingsId);
|
|
2546
|
-
|
|
2547
|
-
// 验证数据库中的记录
|
|
2548
|
-
const dbResult = await serverDB
|
|
2549
|
-
.select()
|
|
2550
|
-
.from(messageQueries)
|
|
2551
|
-
.where(eq(messageQueries.id, result.id));
|
|
2552
|
-
|
|
2553
|
-
expect(dbResult[0].embeddingsId).toBe(embeddingsId);
|
|
2554
|
-
});
|
|
2555
|
-
|
|
2556
|
-
it('should generate a unique ID for each message query', async () => {
|
|
2557
|
-
// Create test data
|
|
2558
|
-
await serverDB.insert(messages).values({
|
|
2559
|
-
id: 'msg3',
|
|
2560
|
-
userId,
|
|
2561
|
-
role: 'user',
|
|
2562
|
-
content: 'test message',
|
|
2563
|
-
});
|
|
2564
|
-
|
|
2565
|
-
// 连续创建两个消息查询
|
|
2566
|
-
const result1 = await messageModel.createMessageQuery({
|
|
2567
|
-
messageId: 'msg3',
|
|
2568
|
-
userQuery: 'query 1',
|
|
2569
|
-
rewriteQuery: 'rewritten query 1',
|
|
2570
|
-
embeddingsId,
|
|
2571
|
-
});
|
|
2572
|
-
|
|
2573
|
-
const result2 = await messageModel.createMessageQuery({
|
|
2574
|
-
messageId: 'msg3',
|
|
2575
|
-
userQuery: 'query 2',
|
|
2576
|
-
rewriteQuery: 'rewritten query 2',
|
|
2577
|
-
embeddingsId,
|
|
2578
|
-
});
|
|
2579
|
-
|
|
2580
|
-
// Assert result
|
|
2581
|
-
expect(result1.id).not.toBe(result2.id);
|
|
2582
|
-
});
|
|
2583
|
-
});
|
|
2584
|
-
|
|
2585
|
-
describe('updateMessageRAG', () => {
|
|
2586
|
-
it('should insert message query chunks for RAG', async () => {
|
|
2587
|
-
// prepare message and query
|
|
2588
|
-
const messageId = 'rag-msg-1';
|
|
2589
|
-
const queryId = uuid();
|
|
2590
|
-
const chunk1 = uuid();
|
|
2591
|
-
const chunk2 = uuid();
|
|
2592
|
-
|
|
2593
|
-
await serverDB.transaction(async (trx) => {
|
|
2594
|
-
await trx.insert(messages).values({ id: messageId, role: 'user', userId, content: 'c' });
|
|
2595
|
-
await trx.insert(chunks).values([
|
|
2596
|
-
{ id: chunk1, text: 'a' },
|
|
2597
|
-
{ id: chunk2, text: 'b' },
|
|
2598
|
-
]);
|
|
2599
|
-
await trx
|
|
2600
|
-
.insert(messageQueries)
|
|
2601
|
-
.values({ id: queryId, messageId, userId, userQuery: 'q', rewriteQuery: 'rq' });
|
|
2602
|
-
});
|
|
2603
|
-
|
|
2604
|
-
await messageModel.updateMessageRAG(messageId, {
|
|
2605
|
-
ragQueryId: queryId,
|
|
2606
|
-
fileChunks: [
|
|
2607
|
-
{ id: chunk1, similarity: 0.9 },
|
|
2608
|
-
{ id: chunk2, similarity: 0.8 },
|
|
2609
|
-
],
|
|
2610
|
-
});
|
|
2611
|
-
|
|
2612
|
-
const rows = await serverDB
|
|
2613
|
-
.select()
|
|
2614
|
-
.from(messageQueryChunks)
|
|
2615
|
-
.where(eq(messageQueryChunks.messageId, messageId));
|
|
2616
|
-
|
|
2617
|
-
expect(rows).toHaveLength(2);
|
|
2618
|
-
const s1 = rows.find((r) => r.chunkId === chunk1)!;
|
|
2619
|
-
const s2 = rows.find((r) => r.chunkId === chunk2)!;
|
|
2620
|
-
expect(s1.queryId).toBe(queryId);
|
|
2621
|
-
expect(s1.similarity).toBe('0.90000');
|
|
2622
|
-
expect(s2.similarity).toBe('0.80000');
|
|
2623
|
-
});
|
|
2624
|
-
});
|
|
2625
|
-
|
|
2626
|
-
describe('deleteMessageQuery', () => {
|
|
2627
|
-
it('should delete a message query by ID', async () => {
|
|
2628
|
-
// Create test data
|
|
2629
|
-
const queryId = uuid();
|
|
2630
|
-
await serverDB.insert(messages).values({
|
|
2631
|
-
id: 'msg4',
|
|
2632
|
-
userId,
|
|
2633
|
-
role: 'user',
|
|
2634
|
-
content: 'test message',
|
|
2635
|
-
});
|
|
2636
|
-
|
|
2637
|
-
await serverDB.insert(messageQueries).values({
|
|
2638
|
-
id: queryId,
|
|
2639
|
-
messageId: 'msg4',
|
|
2640
|
-
userQuery: 'test query',
|
|
2641
|
-
rewriteQuery: 'rewritten query',
|
|
2642
|
-
userId,
|
|
2643
|
-
});
|
|
2644
|
-
|
|
2645
|
-
// 验证查询已创建
|
|
2646
|
-
const beforeDelete = await serverDB
|
|
2647
|
-
.select()
|
|
2648
|
-
.from(messageQueries)
|
|
2649
|
-
.where(eq(messageQueries.id, queryId));
|
|
2650
|
-
|
|
2651
|
-
expect(beforeDelete).toHaveLength(1);
|
|
2652
|
-
|
|
2653
|
-
// 调用 deleteMessageQuery 方法
|
|
2654
|
-
await messageModel.deleteMessageQuery(queryId);
|
|
2655
|
-
|
|
2656
|
-
// 验证查询已删除
|
|
2657
|
-
const afterDelete = await serverDB
|
|
2658
|
-
.select()
|
|
2659
|
-
.from(messageQueries)
|
|
2660
|
-
.where(eq(messageQueries.id, queryId));
|
|
2661
|
-
|
|
2662
|
-
expect(afterDelete).toHaveLength(0);
|
|
2663
|
-
});
|
|
2664
|
-
|
|
2665
|
-
it('should only delete message queries belonging to the user', async () => {
|
|
2666
|
-
// Create test data - 其他用户的查询
|
|
2667
|
-
const queryId = uuid();
|
|
2668
|
-
await serverDB.insert(messages).values({
|
|
2669
|
-
id: 'msg5',
|
|
2670
|
-
userId: '456',
|
|
2671
|
-
role: 'user',
|
|
2672
|
-
content: 'test message',
|
|
2673
|
-
});
|
|
2674
|
-
|
|
2675
|
-
await serverDB.insert(messageQueries).values({
|
|
2676
|
-
id: queryId,
|
|
2677
|
-
messageId: 'msg5',
|
|
2678
|
-
userQuery: 'test query',
|
|
2679
|
-
rewriteQuery: 'rewritten query',
|
|
2680
|
-
userId: '456', // 其他用户
|
|
2681
|
-
});
|
|
2682
|
-
|
|
2683
|
-
// 调用 deleteMessageQuery 方法
|
|
2684
|
-
await messageModel.deleteMessageQuery(queryId);
|
|
2685
|
-
|
|
2686
|
-
// 验证查询未被删除
|
|
2687
|
-
const afterDelete = await serverDB
|
|
2688
|
-
.select()
|
|
2689
|
-
.from(messageQueries)
|
|
2690
|
-
.where(eq(messageQueries.id, queryId));
|
|
2691
|
-
|
|
2692
|
-
expect(afterDelete).toHaveLength(1);
|
|
2693
|
-
});
|
|
2694
|
-
|
|
2695
|
-
it('should throw error when deleting non-existent message query', async () => {
|
|
2696
|
-
// 调用 deleteMessageQuery 方法删除不存在的查询
|
|
2697
|
-
try {
|
|
2698
|
-
await messageModel.deleteMessageQuery('non-existent-id');
|
|
2699
|
-
} catch (e) {
|
|
2700
|
-
expect(e).toBeInstanceOf(Error);
|
|
2701
|
-
}
|
|
2702
|
-
});
|
|
2703
|
-
});
|
|
2704
|
-
});
|