Commit Graph

62 Commits

Author SHA1 Message Date
Innei
687b36c81c ♻️ refactor: migrate frontend from Next.js App Router to Vite SPA (#12404)
* init plan

* 📝 docs: update SPA plan for dev mode Worker cross-origin handling

- Clarified the handling of Worker cross-origin issues in dev mode, emphasizing the need for `workerPatch` to wrap cross-origin URLs as blob URLs.
- Enhanced the explanation of the dev mode's resource URL rewriting process for better understanding.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: Phase 1 - 环境变量整治

- Fix Pyodide env var mismatch (NEXT_PUBLIC_PYPI_INDEX_URL → pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL)
- Consolidate python.ts to use pythonEnv instead of direct process.env
- Remove NEXT_PUBLIC_ prefix from server-side MARKET_BASE_URL (5 files)

* 🏗️ chore: Phase 2 - Vite 工程搭建

- Add vite.config.ts with dual build (desktop/mobile via MOBILE env)
- Add index.html SPA template with __SERVER_CONFIG__ placeholder
- Add entry.desktop.tsx and entry.mobile.tsx SPA entry points
- Add dev:spa, dev:spa:mobile, build:spa, build:spa:copy scripts
- Install @vitejs/plugin-react and linkedom

* ♻️ refactor: Phase 3 - 第一方包 Next.js 解耦

- Replace next/link with <a> in builtin-tool-web-browsing (4 files, external links)
- Replace next/image with <img> in builtin-tool-agent-builder/InstallPlugin.tsx
- Add Vite import.meta.env compat for isDesktop in const/version.ts, builtin-tool-gtd, builtin-tool-group-management

* ♻️ refactor: Phase 4a - Auth 页面改用直接 next/navigation 和 next/link

- 9 auth files: @/libs/next/navigation → next/navigation
- 5 auth files: @/libs/next/Link → next/link
- Auth pages remain in Next.js App Router, need direct Next.js imports

* ♻️ refactor: Phase 4b - Next.js 抽象层替换为 react-router-dom/vanilla React

- navigation.ts: useRouter/usePathname/useSearchParams/useParams → react-router-dom
- navigation.ts: redirect/notFound → custom error throws
- navigation.ts: useServerInsertedHTML → no-op for SPA
- Link.tsx: next/link → react-router-dom Link adapter (href→to, external→<a>)
- Image.tsx: next/image → <img> wrapper with fill/style support
- dynamic.tsx: next/dynamic → React.lazy + Suspense wrapper

*  feat: Phase 5 - 新建 SPAGlobalProvider

- Create SPAServerConfig type (analyticsConfig, clientEnv, theme, featureFlags, locale)
- Add window.__SERVER_CONFIG__ and __MOBILE__ to global.d.ts
- Create SPAGlobalProvider (client-only Provider tree mirroring GlobalProvider)
- Includes AuthProvider for user session support
- Update entry.desktop.tsx and entry.mobile.tsx to wrap with SPAGlobalProvider

* ♻️ refactor: add SPA catch-all route handler with Vite dev proxy

- Create (spa)/[[...path]]/route.ts for serving SPA HTML
- Dev mode: proxy Vite dev server, rewrite asset URLs, inject Worker patch
- Prod mode: read pre-built HTML templates
- Build SPAServerConfig with analytics, theme, clientEnv, featureFlags
- Update middleware to pass SPA routes through to catch-all

* ♻️ refactor: skip auth checks for SPA routes in middleware

SPA pages are all public (no sensitive data in HTML).
Auth is handled client-side by SPAGlobalProvider's AuthProvider.
Only Next.js auth routes and API endpoints go through session checks.

* ♻️ refactor: replace Next.js-specific analytics with vanilla JS

- Google.tsx: replace @next/third-parties/google with direct gtag script
- ReactScan.tsx: replace react-scan/monitoring/next with generic script
- Desktop.tsx: replace next/script with native script injection

* ♻️ refactor: migrate @t3-oss/env-nextjs to @t3-oss/env-core

Replace framework-specific env validation with framework-agnostic version.
Add clientPrefix where client schemas exist.

* ♻️ refactor: replace next-mdx-remote/rsc with react-markdown

Use client-side react-markdown for MDX rendering instead of
Next.js RSC-dependent next-mdx-remote.

* 🔧 chore: update build scripts and Dockerfile for SPA integration

- build:docker now includes SPA build + copy steps
- dev defaults to Vite SPA, dev:next for Next.js backend
- Dockerfile copies public/spa/ assets for production
- Add public/spa/ to .gitignore (build artifact)

* 🗑️ chore: remove old Next.js route segment files and serwist PWA

- Delete [variants] page.tsx, error.tsx, not-found.tsx, loading.tsx
- Delete root loading.tsx and empty [[...path]] directory
- Delete unused loaders directory
- Remove @serwist/next PWA wrapper from Next.js config

* plan2

*  feat: add locale detection script to index.html for SPA dev mode

* ♻️ refactor: remove locale and theme from SPAServerConfig

*  feat: add [locale] segment with force-static and SEO meta generation

* ♻️ refactor: remove theme/locale reads from SPAGlobalProvider

*  feat: set vite base to /spa/ for production builds

*  feat: auto-generate spaHtmlTemplates from vite build output

* 🔧 chore: register dev:next task in turbo.json for parallel dev startup

* ♻️ refactor: rename (spa) route group to spa segment, rewrite SPA routes via middleware

*  feat: add Vite-compatible i18n/locale modules with import.meta.glob and resolve aliases

* 🔧 fix: use custom Vite plugin for module redirects instead of resolve.alias

* very important

* build

* 🔧 chore: update build scripts and clean up Vite configuration by removing unused plugin and code

Signed-off-by: Innei <tukon479@gmail.com>

* 🗑️ refactor: remove all electron modifier scripts

Modifiers are no longer needed with Vite SPA renderer build.

*  feat: add Vite renderer entry to electron-vite config

Add renderer build configuration to electron-vite, replacing the old
Next.js shadow workspace build flow. Delete buildNextApp.mts and
moveNextExports.ts, update package.json scripts accordingly.

*  feat: add .desktop suffix files for eager i18n loading

Create 4 .desktop files that use import.meta.glob({ eager: true })
for synchronous locale access in Electron desktop builds, replacing
the async lazy-loading used in web SPA builds.

* 🔧 refactor: adapt Electron main process for Vite renderer

Replace nextExportDir with rendererDir, update protocol from
app://next to app://renderer, simplify file resolution to SPA
fallback pattern, update _next/ asset paths to /assets/.

* 🔧 chore: update electron-builder files config for Vite renderer

Replace dist/next references with dist/renderer, remove Next.js
specific exclusion rules no longer applicable to Vite output.

* 🗑️ chore: remove @ast-grep/napi dependency

No longer needed after removing electron modifier scripts.

* 🔧 refactor: unify isDesktop to __ELECTRON__ compile-time constant

Remove NEXT_PUBLIC_IS_DESKTOP_APP and VITE_IS_DESKTOP_APP env vars.
Unify isDesktop in @lobechat/const using __ELECTRON__ defined by Vite.
Re-export from builtin-tool packages. Scripts use DESKTOP_BUILD.

* update

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: use electron-vite ELECTRON_RENDERER_URL instead of hardcoded port 3015

Replace hardcoded http://localhost:3015 with process.env.ELECTRON_RENDERER_URL
injected by electron-vite dev server. Clean up stale Next.js references.

* 🐛 fix: use local renderer-entry shim to resolve Vite root path issue

HTML entry ../../src/entry.desktop.tsx resolves to /src/entry.desktop.tsx
in URL space, which Vite cannot find within apps/desktop/ root. Add a
local shim that imports across root via module resolver instead.

* 🔧 refactor: extract shared renderer Vite config into sharedRendererConfig

Deduplicate plugins (nodeModuleStub, platformResolve, tsconfigPaths) and
define (__MOBILE__, __ELECTRON__, process.env) between root vite.config.ts
and electron.vite.config.ts renderer section.

* 🔧 refactor: move all renderer plugins and optimizeDeps into shared config

sharedRendererPlugins now includes react, codeInspectorPlugin alongside
nodeModuleStub, platformResolve, tsconfigPaths. Add sharedOptimizeDeps
for pre-bundling list. Both root and electron configs consume shared only.

* 🐛 fix: set electron renderer root to monorepo root for correct glob resolution

import.meta.glob with absolute paths (e.g. /node_modules/antd/...) resolved
within apps/desktop/ instead of monorepo root. Change renderer root to ROOT_DIR,
add electronDesktopHtmlPlugin middleware to rewrite / to /apps/desktop/index.html,
and remove the now-unnecessary renderer-entry.ts shim.

* desktop vite !!

Signed-off-by: Innei <tukon479@gmail.com>

* sync import !!

Signed-off-by: Innei <tukon479@gmail.com>

* clean ci!!

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: update SPA path structure and clean up dependencies

- Changed the path in .gitignore and related files from [locale] to [variants] for SPA templates.
- Updated index.html to set body height to 100%.
- Cleaned up package.json by removing unused dependencies and reorganizing devDependencies.
- Refactored RendererUrlManager to use a constant for SPA entry HTML path.
- Removed obsolete route.ts file from the SPA structure.
- Adjusted proxy configuration to reflect the new SPA path structure.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update build script to include mobile SPA build

- Modified the build script in package.json to add the mobile SPA build step.
- Ensured the build process accommodates both desktop and mobile SPA versions.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update build scripts and improve file encoding consistency

- Modified the build script in package.json to ensure the SPA copy step runs after the build.
- Updated file encoding in generateSpaTemplates.mts from 'utf-8' to 'utf8' for consistency.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 fix: correct Blob import syntax and update global server config type

- Fixed the Blob import syntax in route.ts to ensure proper module loading.
- Updated the global server configuration type in global.d.ts for improved type safety.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 test: update RendererUrlManager test to reflect new file path

- Modified the mock implementation in RendererUrlManager.test.ts to check for the updated file path '/mock/export/out/apps/desktop/index.html'.
- Adjusted the expected resolved path in the test to match the new structure.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: remove catch-all example file and update imports

- Deleted the catch-all example file `catch-all.eg.ts` to streamline the codebase.
- Updated import paths in `ClientResponsiveLayout.tsx` and `ClientResponsiveContent/index.tsx` to use the new dynamic import location.
- Added type declarations for HTML templates in `spaHtmlTemplates.d.ts`.
- Adjusted `tsconfig.json` to include the updated file structure.
- Enhanced type definitions in `global.d.ts` and fixed locale loading in `locale.vite.ts`.

Signed-off-by: Innei <tukon479@gmail.com>

* e2e

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: remove unused build script for Vercel deployment

- Deleted the `build:vercel` script from package.json to streamline the build process.
- Ensured the remaining build scripts are organized and relevant.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 config: update Vite build input for mobile support

- Changed the build input path in vite.config.ts to conditionally use 'index.mobile.html' for mobile builds, enhancing support for mobile SPA versions.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 feat: add compatibility checks for import maps and cascade layers

- Implemented functions to check for browser support of import maps and CSS cascade layers.
- Redirected users to a compatibility page if their browser does not support the required features.
- Updated the build script in package.json to use the experimental analyze command for better performance.

Signed-off-by: Innei <tukon479@gmail.com>

* chore: rename

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 feat: refactor authentication layout and introduce global providers

- Created a new `RootLayout` component to streamline the layout structure.
- Removed the old layout file for variants and integrated necessary features into the new layout.
- Added `AuthGlobalProvider` to manage authentication context and server configurations.
- Introduced language and theme selection components for enhanced user experience.
- Updated various components to utilize the new context and improve modularity.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 config: exclude build artifacts from serverless functions

- Updated the `next.config.ts` to exclude SPA, desktop, and mobile build artifacts from serverless functions.
- Added paths for `public/spa/**`, `dist/**`, `apps/desktop/build/**`, and `packages/database/migrations/**` to the exclusion list.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 config: refine exclusion of build artifacts from serverless functions

- Updated `next.config.ts` to specify exclusion paths for desktop and mobile build artifacts.
- Changed exclusions from `dist/**` and `apps/desktop/build/**` to `dist/desktop/**`, `dist/mobile/**`, and `apps/desktop/**` for better clarity and organization.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 fix: update BrowserRouter basename for local development

- Modified the `ClientRouter` component to conditionally set the `basename` of `BrowserRouter` based on the `__DEBUG_PROXY__` variable, improving local development experience.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 feat: implement mobile SPA workflow and S3 asset management

- Added a new workflow for building and uploading mobile SPA assets to S3, including environment variable configurations in `.env.example`.
- Updated `package.json` to include a new script for the mobile SPA workflow.
- Enhanced the Vite configuration to support dynamic CDN base paths.
- Refactored the template generation script to handle mobile HTML templates more effectively.
- Introduced new modules for uploading assets to S3 and generating mobile HTML templates.

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix: extract origin from MOBILE_S3_PUBLIC_DOMAIN to prevent double key prefix

* 🔧 fix: update mobile HTML template to use the latest asset versions

- Modified the mobile HTML template to reference the updated JavaScript asset version for improved functionality.
- Ensured consistency in the template structure while maintaining existing styles and scripts.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update dependencies and refine service worker integration

- Removed outdated dependencies related to Serwist from package.json and tsconfig.json.
- Added vite-plugin-pwa to enhance PWA capabilities in the Vite configuration.
- Updated service worker registration logic in the PWA installation component.
- Introduced a new local development proxy route for debugging purposes.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: refactor development scripts and remove Turbo configuration

- Updated the `dev` script in `package.json` to use a new startup sequence script for improved development workflow.
- Removed the outdated `turbo.json` configuration file as it is no longer needed.
- Introduced `devStartupSequence.mts` to manage the startup of Next.js and Vite processes concurrently.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 feat: update entry points and introduce debug proxy for local development

- Changed the main entry point in `index.html` from `entry.desktop.tsx` to `entry.web.tsx` for improved web compatibility.
- Added an `initialize.ts` file to enable `immer`'s `enableMapSet` functionality.
- Introduced a new `__DEBUG_PROXY__` variable in global types to support local development proxy features.
- Implemented a debug proxy route to facilitate local development with dynamic HTML injection and script handling.
- Removed outdated mobile routing components to streamline the codebase.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: replace BrowserRouter with RouterProvider for improved routing

- Updated entry points for desktop, mobile, and web to utilize RouterProvider and createAppRouter for better routing management.
- Removed the deprecated renderRoutes function in favor of a more streamlined router configuration.
- Enhanced router setup to support error boundaries and dynamic routing.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: remove direct access handling for SPA routes in proxy configuration

- Eliminated the handling of direct access to pre-rendered SPA pages in the proxy configuration.
- Simplified the request processing logic by removing checks for SPA routes, streamlining the middleware response flow.

Signed-off-by: Innei <tukon479@gmail.com>

* update

* 🔧 refactor: enhance Worker instantiation logic in mobile HTML template

* 🐛 fix: remove duplicate waitForPageWorkspaceReady calls in page CRUD e2e steps

* 🔧 refactor: simplify createTracePayload function by using btoa for base64 encoding

* 🔧 refactor: specify locales in import.meta.glob for dayjs and antd

* 🔧 refactor: replace Node.js Buffer with web-compatible btoa for base64 encoding in file upload

* 🐛 fix: disable consistent-type-imports rule for mdx files to prevent eslint crash

* 🔧 refactor: add height style to root div for consistent layout

* 🔧 refactor: replace btoa with Buffer for base64 encoding in trace and file upload handling

* 🔧 refactor: extract nextjsOnlyRoutes to a separate file for better organization

* 🔧 refactor: enable Immer MapSet plugin in tests for better state management

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 refactor: integrate sharedRollupOutput configuration and increase cache size for better performance

Signed-off-by: Innei <tukon479@gmail.com>

* 🗑️ chore: remove obsolete desktop.routes.test.ts file as it is no longer needed

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix: use cross-env for env vars in npm scripts (Windows CI)

Co-authored-by: Cursor <cursoragent@cursor.com>

* 🔧 chore: update Dockerfile for web-only build and adjust npm scripts to use pnpm

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: enhance Dockerfile prebuild process with environment checks and add new dependencies

- Updated Dockerfile to include environment checks before removing desktop-only code.
- Added new dependencies in package.json: @aws-sdk/client-bedrock-runtime, @opentelemetry/auto-instrumentations-node, @opentelemetry/resources, @opentelemetry/sdk-metrics, and ajv.
- Configured Rollup to exclude @aws-sdk/client-bedrock-runtime from the SPA bundle.
- Introduced dockerPrebuild.mts script for environment variable validation and information logging.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: enhance Vite and Electron configurations with environment loading and trace encoding improvements

- Updated Vite and Electron configurations to load environment variables using loadEnv.
- Modified trace encoding in utils to use TextEncoder for better compatibility.
- Adjusted sharedRendererConfig to expose only necessary public environment variables.

Signed-off-by: Innei <tukon479@gmail.com>

* 🗑️ chore: remove plans directory (migrated to discussion)

* ♻️ refactor: inject NEXT_PUBLIC_* env per key in Vite define

Co-authored-by: Cursor <cursoragent@cursor.com>

*  feat: add loading screen with animation to enhance user experience

- Introduced a loading screen with a brand logo and animations for better visual feedback during loading times.
- Implemented CSS styles for the loading screen and animations in index.html.
- Removed the loading screen from the DOM once the layout is ready using useLayoutEffect in SPAGlobalProvider.

Signed-off-by: Innei <tukon479@gmail.com>

* 🗑️ chore: remove unnecessary external dependency from Vite configuration

- Eliminated the external dependency '@aws-sdk/client-bedrock-runtime' from the Vite configuration to streamline the build process for the SPA bundle.

Signed-off-by: Innei <tukon479@gmail.com>

*  feat: add web app manifest link in index.html and enable PWA support in Vite configuration

- Added a link to the web app manifest in index.html to enhance PWA capabilities.
- Enabled manifest support in Vite configuration for improved service worker functionality.

Signed-off-by: Innei <tukon479@gmail.com>

* 🔧 chore: update link rel attributes for improved SEO and consistency

- Modified link rel attributes in multiple components to remove 'noreferrer' and standardize to 'nofollow'.
- Adjusted imports in PageContent components for better organization.

Signed-off-by: Innei <tukon479@gmail.com>

* update provider

*  feat: enhance loading experience and update package dependencies

- Added a loading screen with animations and a brand logo in index.html for improved user feedback during loading times.
- Introduced CSS styles for the loading screen and animations.
- Updated package.json files across multiple packages to include "@lobechat/const" as a dependency.

Signed-off-by: Innei <tukon479@gmail.com>

* fix: update proxy

Signed-off-by: Innei <tukon479@gmail.com>

* 🗑️ chore: remove GlobalLayout and Locale components

- Deleted GlobalLayout and Locale components from the GlobalProvider directory to streamline the codebase.
- This removal is part of a refactor to simplify the layout structure and improve maintainability.

Signed-off-by: Innei <tukon479@gmail.com>

* chore: clean up console logs and improve component structure

- Removed unnecessary console log statements from AgentForkTag components in both agent and community directories to enhance code cleanliness.
- Refactored UserAgentList component for better readability by restructuring the useUserDetailContext hook and adjusting the layout of Flexbox components.

Signed-off-by: Innei <tukon479@gmail.com>

* chore: remove console log from MemoryAnalysis component

* chore: update mobile HTML template with new asset links

- Replaced the previous asset links in the mobile HTML template with updated versions to ensure the latest resources are utilized.
- Adjusted the link rel attributes for module preloading to enhance performance and loading efficiency.

Signed-off-by: Innei <tukon479@gmail.com>

* fix: correct variable assignment in createClientTaskThread integration test

- Updated the assignment of the second parent message in the createClientTaskThread integration test to improve clarity and ensure proper data handling.
- Changed the variable name from 'secondParentMsg' to 'inserted' for better context before extracting the first message from the inserted results.

Signed-off-by: Innei <tukon479@gmail.com>

* refactor: simplify authentication check in define-config

- Removed the dependency on the isDesktop variable in the authentication check to streamline the logic.
- Enhanced the clarity of the redirection process for protected routes by focusing solely on the isLoggedIn status.

Signed-off-by: Innei <tukon479@gmail.com>

*  feat(dev): enhance local development setup with debug proxy instructions

- Added detailed instructions for starting the development environment in CLAUDE.md, including commands for SPA and full-stack modes.
- Updated README.md and README.zh-CN.md to reflect new commands and the debug proxy URL for local development.
- Introduced a Vite plugin to print the debug proxy URL upon server start, facilitating easier local development against the production backend.
- Corrected the debug proxy route in entry.web.tsx and define-config.ts for consistency.

This improves the developer experience by providing clear guidance and tools for local development.

Signed-off-by: Innei <tukon479@gmail.com>

* optimize perf

* optimize perf

* optimize perf

* remove speedy plugin

* add dayjs vendor

* Revert "remove speedy plugin"

This reverts commit bf986afeb1.

---------

Signed-off-by: Innei <tukon479@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-28 00:01:01 +08:00
Zhijie He
0674eee0d4 🐛 fix: fix qwen3 embedding error due to batch size limitation (#12382)
fix: fix embdding chunk_size limit for qwen

apply suggestion

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

fix: fix embdding chunk_size limit for qwen

fix: fix embdding chunk_size limit for qwen
2026-02-21 01:15:14 +08:00
Arvin Xu
4a87b31246 📝 docs: improve docs (#12013)
Update docs
2026-01-31 19:46:44 +08:00
YuTengjing
f3210a3f57 🐛 fix(auth): add AUTH_DISABLE_EMAIL_PASSWORD env to enable SSO-only mode (#12009) 2026-01-31 18:25:22 +08:00
YuTengjing
1eff8646f7 feat: remove NextAuth (#11732) 2026-01-23 23:57:08 +08:00
YuTengjing
395595a2c8 feat: remove Clerk authentication code (#11711) 2026-01-23 14:41:22 +08:00
YuTengjing
c0f9875195 ♻️ refactor(auth): remove NEXT_PUBLIC_AUTH_URL env variable (#11658) 2026-01-21 11:51:46 +08:00
Shinji-Li
e3ec79e28d feat: support klavis mcp connector (#10584)
* feat: support klavis mcp connector

* feat: update klavis item & klavis call tools

* feat: update the noraml klavis mcp (no need oauth)

* fix: rollback test

* fix: fixed test ci

* feat: update the klavis select model & locals settings

* fix: change the klavis id to klavis types

* fix: delete the klavis into getGlobalConfig

* fix: delete useless migrations

* fix: improve the code

* feat: update test & update the klavis const var

* fix: change it to const

* feat: use swr to replace useEffect
2025-12-05 14:43:22 +08:00
Neko
36750adc3a 🔨 chore: support to have Redis and providers (#10391)
* feat: added redis providers (ioredis, upstash)

For environment annotation of Vitest, read more: https://github.com/capricorn86/happy-dom/issues/1042#issuecomment-3585851354

Co-authored-by: Makito <5277268+sumimakito@users.noreply.github.com>

* chore: changed as suggested

---------

Co-authored-by: Makito <5277268+sumimakito@users.noreply.github.com>
2025-11-28 11:35:35 +08:00
YuTengjing
dc62cc969d feat: support better-auth (#10215) 2025-11-27 20:10:40 +08:00
YuTengjing
4f7bc5acd2 🐛 fix: add SSRF protection (#10152) 2025-11-11 19:39:36 +08:00
Arvin Xu
f2ab2fcef6 ♻️ refactor: remove NEXT_PUBLIC_SERVICE_MODE env and use server by default (#10017)
* remove NEXT_PUBLIC_SERVICE_MODE

* update

* fix tests

* update e2e workflow

* update config

* Rename DATABASE_TEST_URL to DATABASE_URL
2025-11-04 00:34:37 +08:00
Shinji-Li
490fee002e feat: use env to control clerk allow origin feature (#9863)
feat: use clerk allow origin feature
2025-10-24 12:08:22 +08:00
YuTengjing
de7368bc25 feat: add new setting for default image num (#9618) 2025-10-12 23:56:17 +08:00
WangYK
5a4b0fd344 feat: support Vercel AI Gateway provider (#8883)
*  feat: support Vercel AI Gateway provider

* fix: add `vercelaigateway` to package.json.exports

* chore: 把 runtime 挪到 providers 目录下
2025-09-16 16:49:54 +08:00
Maple Gao
a66856dc83 🐛 fix: enhance NewAPI with environment variables and fix routers compatibility (#9110)
 feat: enhance NewAPI with environment variables and fix routers compatibility

- Add NEWAPI_API_KEY and NEWAPI_PROXY_URL environment variable support
- Update documentation for NewAPI configuration options
- Fix routers baseURL handling to prevent duplicate version paths
- Remove /v1 baseURL requirement to avoid SDK compatibility issues
- Auto-detect model capabilities based on provider detection
- Support dynamic routing to correct provider endpoints

This resolves URL duplication issues like /v1beta/v1beta/ and ensures
proper routing to Anthropic, Google, OpenAI, and XAI endpoints.
2025-09-06 11:30:12 +08:00
sxjeru
c15791d852 💄 style: Support new provider Nebius (#8903)
* feat: add Nebius model support and configuration

* feat(nebius): enhance model definitions and add support for image and embedding models

* Implement code changes to enhance functionality and improve performance

* feat(nebius): remove 'created' field from model standardization

* feat(novita): format model pricing and enhance model data structure

* feat: 更新模型处理逻辑,优化模型字段和定价格式

* feat(openrouter): 更新模型接口,优化价格格式和上下文窗口大小

* feat: 添加定价格式化功能,更新模型接口以支持新的定价结构

* fix test

* feat: 添加Hermes-4-70B和Hermes-4-405B模型,更新定价结构

* feat: add functionCall, reasoning, and vision properties to model list

* 拆分 pr

* Delete src/config/aiModels/nebius.ts

* Delete src/config/aiModels/index.ts

* Delete src/config/aiModels/openrouter.ts

* add change

* 添加 nebius 模型的导出路径

* Update providers.tsx

* 更新 Gemini 2.5 Flash Image Preview 模型名称为 "Nano Banana"

* fix

---------

Co-authored-by: Arvin Xu <arvinx@foxmail.com>
2025-09-01 09:38:59 +08:00
Shinji-Li
9250540912 🐛 fix: add Content-Security-Policy env (#8752)
* fix: add Content-Security-Policy

* feat: add env to control csp open or not

* update env
2025-08-29 17:14:04 +08:00
YuTengjing
45f05a0169 📝 docs: add BFL provider documentation (#8933) 2025-08-26 17:26:45 +08:00
JI4JUN
e172055a52 feat: support 302ai provider (#8362)
*  feat: support 302.AI provider

* 📝 docs: update docs of 302.AI

* 🐛 fix: error 404 of images in ai302.mdx and ai302.zh-CN.mdx

* 🐛 fix: fix issue of failing tests
2025-08-05 15:50:13 +08:00
hedeqiang
4db6485410 feat: support aihubmix provider (#8038)
* feata: support aihubmix provider

* style: update aihubmix

* style: update LobeOpenAICompatibleFactory

* Delete docs/usage/providers/aihubmix.mdx

* style: update model list

* style: i18n

* Update aihubmix.zh-CN.mdx

* Update aihubmix.ts

* ♻️ refactor: rename agent runtime to model runtime

*  feat: support aihubmix as router runtime

* update App header

* update

* update models

* update models link

* update i18n

* fix

* fix

---------

Co-authored-by: Arvin Xu <arvinx@foxmail.com>
2025-08-01 09:52:11 +08:00
wangjifeng
d4baae5df0 💄 style: add MCP_TOOL_TIMEOUT env and improve debug usage guide (#8357)
* feat: add MCP_TOOL_TIMEOUT config and doc, and improve debug usage guide

* feat: add MCP_TOOL_TIMEOUT config and doc, remove connect timeout

* feat: add MCP_TOOL_TIMEOUT config and doc, remove connect timeout

* docs: update .env.example, comment out MCP_TOOL_TIMEOUT and improve env parsing in client

* docs: update .env.example MCP_TOOL_TIMEOUT default value to 60000 to match code
2025-07-08 12:48:31 +08:00
Zhifeng Li
c9b8e9f655 feat: add Qiniu Provider (#7649)
*  feat: Add Qiniu

*  feat: Add Qiniu Image
2025-05-15 11:08:49 +08:00
WangYK
72d76feff6 feat: add infini-ai provider (#7012)
*  feat: support infini-ai provider

* 🐛 fix: correct typo `infinigenceai` -> `infiniai`
2025-03-21 17:45:59 +08:00
cnJasonZ
23a3fdaee9 feat: add new model provider PPIO (#6133)
* feat: add new model provider PPIO

* feat: add usage docs; fix model configs

* fix: fix ppio runtime; fix model configs

* fix: fix default model list

* fix

* fix: fix locales providers.json

---------

Co-authored-by: Jason <ggbbddjm@gmail.com>
Co-authored-by: arvinxx <arvinx@foxmail.com>
2025-03-03 17:23:28 +08:00
Arvin Xu
c599fcc3aa 👷 build: fix docker build failed (#6628)
* try to fix

* try to fix

* try to fix

* fix docker build

* try to fix

* try to fix docker build

* try to fix docker build

* update docs

* try  to not copy pg and drizzle orm

* remove /deps

* update
2025-03-02 21:58:57 +08:00
hedeqiang
025d0bcd62 🐛 fix: fix tencent cloud api issue (#6058)
* fix: tencentcloud

* fix: tencentcloud
2025-02-12 22:27:52 +08:00
Arvin Xu
e529108ff6 feat: refactor the auth condition in Next Auth (#5866)
This upgrade includes two changes:

For users deploying with Vercel using next-auth, it is necessary to add the environment variable `NEXT_PUBLIC_ENABLE_NEXT_AUTH=1` to ensure Next Auth is enabled; other users are not affected.
For users using clerk in self-built images, it is necessary to additionally configure `NEXT_PUBLIC_ENABLE_NEXT_AUTH=0` to disable Next Auth

Other standard deployment scenarios (using Clerk in Vercel and using next-auth in Docker) are not affected

For More detail, refer to https://github.com/lobehub/lobe-chat/issues/5804

本次升级存在两个变更:

- 针对使用 Vercel 部署中使用 next-auth 的用户,需要额外添加 `NEXT_PUBLIC_ENABLE_NEXT_AUTH=1` 环境变量来确保开启 Next Auth
- 针对使用自构建镜像中使用 clerk 的用户,需要额外配置 `NEXT_PUBLIC_ENABLE_NEXT_AUTH=0` 环境变量来关闭 Next Auth

其他标准部署场景(Vercel 中使用 Clerk 与 Docker 中使用 next-auth )不受影响

变更详情原因查看 https://github.com/lobehub/lobe-chat/issues/5804
2025-02-08 10:25:28 +08:00
hcygnaw
39410f8910 📝 docs: Add DEEPSEEK_PROXY_URL configuration to environment variables (#5691)
* 📝 docs: Add DEEPSEEK_PROXY_URL configuration to environment variables

* Simplify changes.

* Revert index.ts

* revert changes

---------

Co-authored-by: yichuan <wang-yichuan@outlook.com>
2025-02-04 22:20:15 +08:00
Henry Yee
eed9357ab5 feat: support to customize Embedding model with env (#5177)
* feat: 添加嵌入模型配置支持,更新相关文档和测试

* feat: 重构文件配置,更新默认设置和相关测试

* ♻ Code Refactoring
- Update the file configuration and standardize the model naming to camel case.
2025-01-15 11:17:20 +08:00
CanisMinor
df3ac87bb3 feat: Add changelog modal (#4800)
*  feat: Add changelog modal

* 💄 style: Update changelog style

*  test: Add test

* 🔧 chore: Add CDN workflow

*  test: Fix test

*  test: Fix test

* 📝 docs: Update changelog

* 📝 docs: Update cdn

* refactor version

* feat: 实现 changelog 初始化入口,新增后端应用层状态初始化入口

* 🐛 fix: Fix useCheckLatestChangelogId

* 🔧 chore: Update types

* 🐛 fix: Fix lint

* upgrade

*  feat: Update env

* 🔧 chore: Rename DOC_S3 env

*  test: Update test

* 👷 ci: Fix build lint error

* ♻️ refactor: Refactor models

* 💄 style: Add feature flag

*  test: Fix test

* 💄 style: Rm mobile modal

* 💄 style: Update canonical url

---------

Co-authored-by: arvinxx <arvinx@foxmail.com>
2024-12-26 11:02:47 +08:00
BrandonStudio
efb7adf89a feat: Support Cloudflare Workers AI (#3402)
* Delete .nvmrc

* feat: Add Cloudflare as a model provider

This commit adds support for Cloudflare as a model provider. It includes changes to the `ModelProvider` enum, the `UserKeyVaults` interface, the `getServerGlobalConfig` function, the `DEFAULT_LLM_CONFIG` constant, the `getLLMConfig` function, the `AgentRuntime` class, and the `DEFAULT_MODEL_PROVIDER_LIST` constant.

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix icon

* fix

* Create .nvmrc

* Delete src/config/modelProviders/.nvmrc

* CF -> CLOUDFLARE

* revert

* chore: Update agentRuntime.ts and auth.ts to support Cloudflare account ID in payload

* Add provider setting

* fix

* Update cloudflare.ts

* fix

* Update cloudflare.ts

* accountID

* fix

* i18n

* save changes

* commit check

* disable function calling for now

* does not catch errors when fetching models

* ready to add base url

* commit check

* revert change

* revert string boolean check

* fix type error on Vercel.
refer to https://github.com/vercel/next.js/issues/38736#issuecomment-1278917422

* i18n by groq/llama-3.1-8b-instant

* rename env var

* add test

* Revert changes that are not relavant to Cloudflare and result in merge conflicts.

* add test for models()

* move helper code to standalone file

* add test for helper methods

* remove encoder

* Merge main into cf-chat-m

* remove brand

* remove template comment

* add provider card

* Update lobe-icons

* Fix setting layout

* minor modification of model list

---------

Co-authored-by: sxjeru <sxjeru@gmail.com>
2024-11-12 01:21:16 +08:00
Arthals
2820697103 📝docs: align variable names (#4369) 2024-10-14 21:50:22 +08:00
Arvin Xu
16584031a7 ♻️ refactor: refactor s3 env and support path-style for minio (#3559)
* ♻️ refactor: refactor the `NEXT_PUBLIC_S3_DOMAIN` to `S3_PUBLIC_DOMAIN`

* 👷 build: support path-style for s3
2024-08-22 22:52:25 +08:00
sxjeru
0781dc5233 feat: Add SiliconCloud model provider (#3092)
* feat: Add SiliconCloud as a model provider

* model icon

* Update index.ts

* Update siliconcloud.ts

* Update .env.example

* Add docs

* Update siliconcloud.ts

* Update siliconcloud.ts

* Update siliconcloud.ts

* Update siliconcloud.ts
2024-08-14 10:36:04 +08:00
Rubu Jam
a4938ebae3 💄 style(config): Update Azure model and API versions (#3405)
* 💄 style(config): Update Azure model and API versions

* 💄 style: Modify text
2024-08-06 02:03:59 +08:00
cy948
5a0b972275 feat: Add NextAuth as authentication service in server database (#2935)
* ♻️ refactor: make db edge compatible

*  feat: LobeNextAuth Adapter

* 🗃️ chore: change db schema

* 🐛 fix: userid not pass to session

* 🐛 fix: nextauth enable status updater

*  test: nextauth

* ♻️ refactor: nextauth db schema

* 📝 docs: add envs to .env.example

* ♻️ refactor: split nextauth module

* 🐛 fix: login button not shown on mobile

* ♻️ refactor: use hooks instead envs

* 🐛 fix: wrong login redirect

*  feat: add error page for nextauth

* 🐛 fix: nextauth should not goto /me/profile

* 🗃️ chore: add db migrate sqls

*  test(test): Add findByEmail tests for UserModel

* ♻️ refactor: Nextauth jsdoc

*  test: enableAuth

*  test(trpc-middleware): Mock nextauth import

*  test(use-category): Nextauth should not render profile

*  test: Mock nextauth import

* ♻️ refactor: Add store selector for enableAuth

* ♻️ replace s.enableAuth with authSelector

* 💄 style: Split Context to Clerk auth and NextAuth auth

* 💄 style: Rename migration file to 0004_add_next_auth

* 🐛 fix: userid not exists

*  test: pass test for auth action

* ♻️ refactor: use static method on UserModel

*  revert: revert `src/config/auth.ts`

*  revert: `preference` in `schemas/lobechat.ts`

* ♻️ refactor: split auth to clerkAuth & nextAuth in trpc context

* ♻️ refactor: remove consts in nextauth schema

*  revert: revert db migration files

* 🗃️ refactor: rename `emailVerified` to `emailVerifiedAt`

* 🗃️ chore: generate migration files

* ♻️ refactor: move `AuthErrorPage` to `api/auth/error/`

* ♻️ refactor: move nextauth schema to
`src/database/server/schemas`

* ♻️ refactor: add type annotation to `LobeNextAuthDbAdapter`

*  test: `LobeNextAuthDbAdapter`

*  test: `updateAuthenticatorCounter`

*  test: `listAuthenticatorsByUserId`

* ♻️ refactor: remove login buttion in settings

* 🐛 fix: link to exist account by email

* 🗃️ chore: add `full_name` to user table

* 🗃️ chore: add `full_name` to user in migration file

* 🐛 fix: duplicate providerAccountId user created

* ♻️ refactor: use `providerAccountId` as user id

* 🐛 fix: wrong request when not logined and nextauth enabled
2024-08-02 19:48:17 +08:00
Arvin Xu
2b54caeda1 💄 style: update brand and improve docs (#2917)
* 💄 style: update logo style

* ♻️ refactor: hide webrtc sync by default

* 🔧 chore: improve db migration script

* 💄 style: rename to assistant

* 💄 style: update brand

* 💄 style: update brand

* ️ perf: dynamic pwa install

*  test: fix tests

* 📝 docs: update docs

* 📝 docs: update env

* 📝 docs: update docs
2024-06-18 21:00:17 +08:00
wyw
75cd63aa39 feat: Support Qwen as new model provider (#2715)
Co-authored-by: mingholy.lmh <mingholy.lmh@gmail.com>
2024-06-04 11:38:56 +08:00
Rubu Jam
18028f340d feat: Support DeepSeek as new model provider (#2446)
*  feat: support DeepSeek as provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

*  feat: Support DeepSeek as new model provider

* 💄 style: Translate some content

*  feat: Support DeepSeek as new model provider

* 🐛 fix: Clean up the code and resolve a bug
2024-05-14 10:53:08 +08:00
Ryo Shen
00abd82687 feat: support minimax as a new provider (#2087)
* add minimax as provider

* add i18n token

* update

* update

* Revert "add i18n token"

This reverts commit 4be6d6797b4b60baa965243dc772a023b10b96f6.

* add i18n token

* add doc

* update i18n

* implement MinimaxStream

* use fetchSSE function

* fix TypeError and SyntaxError

* add unit test

* add agent runtime

* add debug log

* use fetch function directly

* refactor(minimax): streamline response parsing logic

* remove redundant error response check

* fix code style
2024-04-29 10:57:48 +08:00
Arvin Xu
562d18926a feat: fully support ollama with browser request mode (#2168)
* 🌐 style: add i18n

* 🐛 fix: fix ollama chat error

* 💄 style: improve ollama request mode

* 🚸 style: improve ollama setup guide

* 📝 docs: remove v1 suffix

* 🐛 fix: keep server mode if user use proxy
2024-04-24 13:38:10 +08:00
Maple Gao
722921d10e 📖 docs: Add custom models new ENV set and ollama non-local configurations (#1969)
* 📖 docs: Add custom models new ENV set and ollama non-local configurations.

* 📖 docs: fix more CUSTOM_Models in docs

* Update .env.example

* Update azure-openai.mdx

* Update azure-openai.zh-CN.mdx
2024-04-11 14:00:01 +08:00
arvinxx
2190a9585b ♻️ refactor: refactor openAI to openai and azure 2024-04-11 00:36:05 +08:00
Tung Pham
d6921efc4a feat: Support TogetherAI as new model provider (#1709)
* Support TogetherAI as new model provider

* Setting>LLM>TogetherAI temporary use text only, waiting for new icon for TogetherAI

* Add TOGETHERAI_API_KEY env into Dockerfile and update env docs

* Clean up debug log

* Avoid conflict CI test: model google/gemma-7b-it with openrouter

* Add test case for agent runtime TogetherAI
2024-03-29 17:00:40 +08:00
HansKing98
39a131c00e 📝 docs: Update ZEROONE_API_KEY in .env.example (#1754)
01.AI Service 
change 'ZEROONEAI_API_KEY' to 'ZEROONE_API_KEY'
2024-03-27 14:43:46 +08:00
Linghui Gong
78baa16457 🐛 fix: support openrouter custom models env (#1647)
*  feat: add openrouter custom models env

*  add OPENROUTER_CUSTOM_MODELS env var test case
2024-03-25 22:34:06 +08:00
Maple Gao
08342fd5f1 feat: support 01.AI as a new provider (#1627)
* add: Support 01-AI Models

* 🔧 chore: fix a config typo for model desc

* 🌐 add: Base 01.AI locale json

* 🐛 fix: remove custom model name and dark mode Logo for 01AI

* 💄 optimize: optimize the 01AI/Groq icon show and fix unused import

* 💄 optimize: optimize the settings icon show rules

*  feat: add 01.AI APIKey Error Form

* 💄 fix: PR 01.AI review issue

* 💄 revert: Groq logo change

* 🌐 style: update locale
2024-03-25 19:56:38 +08:00
Linghui Gong
780b1a225f feat: support openrouter as a new model provider (#1572)
*  feat: add openrouter provider

*  feat: add openrouter default headers

* 🐛 fix: test case bug
2024-03-16 21:17:37 +08:00
Arvin Xu
a04c364f04 feat: support groq as a model provider (#1569)
*  feat: support model provider groq (#1562)

* add Groq localization (#1570)

* 🐛 fix: fix groq logo and document

* 🌐 style: add i18n

---------

Co-authored-by: Jiaqi Cai <45190310+jcdiv47@users.noreply.github.com>
Co-authored-by: PedroZ <sdustpedro@gmail.com>
2024-03-15 23:54:29 +08:00