@lobehub/lobehub 2.0.0-next.185 → 2.0.0-next.187

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/e2e/src/support/webServer.ts +0 -1
  4. package/next.config.ts +14 -1
  5. package/package.json +2 -1
  6. package/packages/fetch-sse/src/__tests__/request.test.ts +608 -0
  7. package/packages/model-bank/src/aiModels/aihubmix.ts +44 -8
  8. package/packages/model-bank/src/aiModels/google.ts +49 -17
  9. package/packages/model-bank/src/aiModels/hunyuan.ts +20 -0
  10. package/packages/model-bank/src/aiModels/infiniai.ts +48 -7
  11. package/packages/model-bank/src/aiModels/lobehub.ts +13 -11
  12. package/packages/model-bank/src/aiModels/minimax.ts +46 -2
  13. package/packages/model-bank/src/aiModels/ollamacloud.ts +40 -5
  14. package/packages/model-bank/src/aiModels/openai.ts +6 -3
  15. package/packages/model-bank/src/aiModels/qwen.ts +1 -1
  16. package/packages/model-bank/src/aiModels/siliconcloud.ts +60 -0
  17. package/packages/model-bank/src/aiModels/vertexai.ts +77 -44
  18. package/packages/model-bank/src/aiModels/volcengine.ts +111 -2
  19. package/packages/model-bank/src/aiModels/zenmux.ts +19 -13
  20. package/packages/model-bank/src/aiModels/zhipu.ts +64 -2
  21. package/packages/model-bank/src/types/aiModel.ts +3 -0
  22. package/packages/model-runtime/src/providers/volcengine/index.ts +2 -1
  23. package/packages/model-runtime/src/providers/zhipu/index.test.ts +0 -27
  24. package/packages/model-runtime/src/providers/zhipu/index.ts +1 -1
  25. package/packages/model-runtime/src/utils/modelParse.ts +26 -21
  26. package/packages/types/src/agent/chatConfig.ts +6 -2
  27. package/packages/types/src/message/common/base.ts +1 -1
  28. package/packages/types/src/message/ui/chat.ts +3 -3
  29. package/packages/types/src/message/ui/extra.ts +2 -2
  30. package/packages/types/src/openai/plugin.ts +1 -1
  31. package/packages/types/src/session/agentSession.ts +1 -1
  32. package/packages/types/src/user/settings/index.ts +1 -1
  33. package/src/app/(backend)/oidc/[...oidc]/route.ts +2 -2
  34. package/src/app/[variants]/(auth)/oauth/consent/[uid]/page.tsx +2 -2
  35. package/src/envs/auth.ts +2 -0
  36. package/src/features/ChatInput/ActionBar/Model/ControlsForm.tsx +40 -1
  37. package/src/features/ChatInput/ActionBar/Model/GPT52ProReasoningEffortSlider.tsx +59 -0
  38. package/src/features/ChatInput/ActionBar/Model/GPT52ReasoningEffortSlider.tsx +61 -0
  39. package/src/features/ChatInput/ActionBar/Model/TextVerbositySlider.tsx +1 -1
  40. package/src/features/ChatInput/ActionBar/Model/ThinkingLevel2Slider.tsx +58 -0
  41. package/src/features/ChatInput/ActionBar/Model/ThinkingLevelSlider.tsx +10 -8
  42. package/src/libs/next/config/define-config.ts +19 -10
  43. package/src/libs/next/proxy/define-config.ts +4 -5
  44. package/src/libs/trpc/lambda/context.ts +9 -11
  45. package/src/server/services/oidc/oidcProvider.ts +2 -2
  46. package/src/services/chat/mecha/modelParamsResolver.ts +11 -0
  47. package/vercel.json +1 -1
  48. package/src/envs/oidc.ts +0 -18
@@ -6,9 +6,11 @@ import type { Header, Redirect } from 'next/dist/lib/load-custom-routes';
6
6
  import ReactComponentName from 'react-scan/react-component-name/webpack';
7
7
 
8
8
  interface CustomNextConfig {
9
+ experimental?: NextConfig['experimental'];
9
10
  headers?: Header[];
10
11
  redirects?: Redirect[];
11
12
  turbopack?: NextConfig['turbopack'];
13
+ webpack?: NextConfig['webpack'];
12
14
  }
13
15
 
14
16
  export function defineConfig(config: CustomNextConfig) {
@@ -56,6 +58,7 @@ export function defineConfig(config: CustomNextConfig) {
56
58
  webVitalsAttribution: ['CLS', 'LCP'],
57
59
  webpackBuildWorker: true,
58
60
  webpackMemoryOptimizations: true,
61
+ ...config.experimental,
59
62
  },
60
63
  async headers() {
61
64
  const securityHeaders = [
@@ -325,20 +328,20 @@ export function defineConfig(config: CustomNextConfig) {
325
328
  ignoreBuildErrors: true,
326
329
  },
327
330
 
328
- webpack(config) {
329
- config.experiments = {
331
+ webpack(baseWebpackConfig, options) {
332
+ baseWebpackConfig.experiments = {
330
333
  asyncWebAssembly: true,
331
334
  layers: true,
332
335
  };
333
336
 
334
337
  // 开启该插件会导致 pglite 的 fs bundler 被改表
335
338
  if (enableReactScan) {
336
- config.plugins.push(ReactComponentName({}));
339
+ baseWebpackConfig.plugins.push(ReactComponentName({}));
337
340
  }
338
341
 
339
342
  // to fix shikiji compile error
340
343
  // refs: https://github.com/antfu/shikiji/issues/23
341
- config.module.rules.push({
344
+ baseWebpackConfig.module.rules.push({
342
345
  resolve: {
343
346
  fullySpecified: false,
344
347
  },
@@ -347,14 +350,14 @@ export function defineConfig(config: CustomNextConfig) {
347
350
  });
348
351
 
349
352
  // https://github.com/pinojs/pino/issues/688#issuecomment-637763276
350
- config.externals.push('pino-pretty');
353
+ baseWebpackConfig.externals.push('pino-pretty');
351
354
 
352
- config.resolve.alias.canvas = false;
355
+ baseWebpackConfig.resolve.alias.canvas = false;
353
356
 
354
357
  // to ignore epub2 compile error
355
358
  // refs: https://github.com/lobehub/lobe-chat/discussions/6769
356
- config.resolve.fallback = {
357
- ...config.resolve.fallback,
359
+ baseWebpackConfig.resolve.fallback = {
360
+ ...baseWebpackConfig.resolve.fallback,
358
361
  zipfile: false,
359
362
  };
360
363
 
@@ -364,7 +367,7 @@ export function defineConfig(config: CustomNextConfig) {
364
367
  ) {
365
368
  // fix the Worker URL cross-origin issue
366
369
  // refs: https://github.com/lobehub/lobe-chat/pull/9624
367
- config.module.rules.push({
370
+ baseWebpackConfig.module.rules.push({
368
371
  generator: {
369
372
  // @see https://webpack.js.org/configuration/module/#rulegeneratorpublicpath
370
373
  publicPath: '/_next/',
@@ -375,7 +378,13 @@ export function defineConfig(config: CustomNextConfig) {
375
378
  });
376
379
  }
377
380
 
378
- return config;
381
+ const updatedConfig = baseWebpackConfig;
382
+
383
+ if (config.webpack) {
384
+ return config.webpack(updatedConfig, options);
385
+ }
386
+
387
+ return updatedConfig;
379
388
  },
380
389
  };
381
390
 
@@ -12,7 +12,6 @@ import { LOBE_THEME_APPEARANCE } from '@/const/theme';
12
12
  import { isDesktop } from '@/const/version';
13
13
  import { appEnv } from '@/envs/app';
14
14
  import { authEnv } from '@/envs/auth';
15
- import { oidcEnv } from '@/envs/oidc';
16
15
  import NextAuth from '@/libs/next-auth';
17
16
  import { type Locales } from '@/locales/resources';
18
17
  import { parseBrowserLanguage } from '@/utils/locale';
@@ -236,7 +235,7 @@ export function defineConfig() {
236
235
  response.headers.set(OAUTH_AUTHORIZED, 'true');
237
236
 
238
237
  // If OIDC is enabled and user is logged in, add OIDC session pre-sync header
239
- if (oidcEnv.ENABLE_OIDC && session?.user?.id) {
238
+ if (authEnv.ENABLE_OIDC && session?.user?.id) {
240
239
  logNextAuth('OIDC session pre-sync: Setting %s = %s', OIDC_SESSION_HEADER, session.user.id);
241
240
  response.headers.set(OIDC_SESSION_HEADER, session.user.id);
242
241
  }
@@ -285,10 +284,10 @@ export function defineConfig() {
285
284
  });
286
285
 
287
286
  // If OIDC is enabled and Clerk user is logged in, add OIDC session pre-sync header
288
- if (oidcEnv.ENABLE_OIDC && data.userId) {
287
+ if (authEnv.ENABLE_OIDC && data.userId) {
289
288
  logClerk('OIDC session pre-sync: Setting %s = %s', OIDC_SESSION_HEADER, data.userId);
290
289
  response.headers.set(OIDC_SESSION_HEADER, data.userId);
291
- } else if (oidcEnv.ENABLE_OIDC) {
290
+ } else if (authEnv.ENABLE_OIDC) {
292
291
  logClerk('No Clerk user detected, not setting OIDC session sync header');
293
292
  }
294
293
 
@@ -351,7 +350,7 @@ export function defineConfig() {
351
350
  enableBetterAuth: authEnv.NEXT_PUBLIC_ENABLE_BETTER_AUTH,
352
351
  enableClerk: authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH,
353
352
  enableNextAuth: authEnv.NEXT_PUBLIC_ENABLE_NEXT_AUTH,
354
- enableOIDC: oidcEnv.ENABLE_OIDC,
353
+ enableOIDC: authEnv.ENABLE_OIDC,
355
354
  });
356
355
 
357
356
  return {
@@ -1,17 +1,17 @@
1
- import { type ClientSecretPayload } from '@lobechat/types';
2
- import { parse } from 'cookie';
3
- import debug from 'debug';
4
- import { type User } from 'next-auth';
5
- import { type NextRequest } from 'next/server';
6
-
7
1
  import {
8
2
  LOBE_CHAT_AUTH_HEADER,
9
3
  LOBE_CHAT_OIDC_AUTH_HEADER,
10
4
  enableBetterAuth,
11
5
  enableClerk,
12
6
  enableNextAuth,
13
- } from '@/const/auth';
14
- import { oidcEnv } from '@/envs/oidc';
7
+ } from '@lobechat/const';
8
+ import { type ClientSecretPayload } from '@lobechat/types';
9
+ import { parse } from 'cookie';
10
+ import debug from 'debug';
11
+ import { type User } from 'next-auth';
12
+ import { type NextRequest } from 'next/server';
13
+
14
+ import { authEnv } from '@/envs/auth';
15
15
  import { ClerkAuth, type IClerkAuth } from '@/libs/clerk-auth';
16
16
  import { validateOIDCJWT } from '@/libs/oidc-provider/jwt';
17
17
 
@@ -129,11 +129,9 @@ export const createLambdaContext = async (request: NextRequest): Promise<LambdaC
129
129
  let oidcAuth = null;
130
130
 
131
131
  // Prioritize checking for OIDC authentication (both standard Authorization and custom Oidc-Auth headers)
132
- if (oidcEnv.ENABLE_OIDC) {
132
+ if (authEnv.ENABLE_OIDC) {
133
133
  log('OIDC enabled, attempting OIDC authentication');
134
- const standardAuthorization = request.headers.get('Authorization');
135
134
  const oidcAuthToken = request.headers.get(LOBE_CHAT_OIDC_AUTH_HEADER);
136
- log('Standard Authorization header: %s', standardAuthorization ? 'exists' : 'not found');
137
135
  log('Oidc-Auth header: %s', oidcAuthToken ? 'exists' : 'not found');
138
136
 
139
137
  try {
@@ -1,5 +1,5 @@
1
1
  import { getDBInstance } from '@/database/core/web-server';
2
- import { oidcEnv } from '@/envs/oidc';
2
+ import { authEnv } from '@/envs/auth';
3
3
  import { type OIDCProvider, createOIDCProvider } from '@/libs/oidc-provider/provider';
4
4
 
5
5
  /**
@@ -13,7 +13,7 @@ let provider: OIDCProvider;
13
13
  */
14
14
  export const getOIDCProvider = async (): Promise<OIDCProvider> => {
15
15
  if (!provider) {
16
- if (!oidcEnv.ENABLE_OIDC) {
16
+ if (!authEnv.ENABLE_OIDC) {
17
17
  throw new Error('OIDC is not enabled. Set ENABLE_OIDC=1 to enable it.');
18
18
  }
19
19
 
@@ -95,6 +95,17 @@ export const resolveModelExtendParams = (ctx: ModelParamsContext): ModelExtendPa
95
95
  extendParams.reasoning_effort = chatConfig.gpt5_1ReasoningEffort;
96
96
  }
97
97
 
98
+ if (modelExtendParams.includes('gpt5_2ReasoningEffort') && chatConfig.gpt5_2ReasoningEffort) {
99
+ extendParams.reasoning_effort = chatConfig.gpt5_2ReasoningEffort;
100
+ }
101
+
102
+ if (
103
+ modelExtendParams.includes('gpt5_2ProReasoningEffort') &&
104
+ chatConfig.gpt5_2ProReasoningEffort
105
+ ) {
106
+ extendParams.reasoning_effort = chatConfig.gpt5_2ProReasoningEffort;
107
+ }
108
+
98
109
  // Text verbosity
99
110
  if (modelExtendParams.includes('textVerbosity') && chatConfig.textVerbosity) {
100
111
  extendParams.verbosity = chatConfig.textVerbosity;
package/vercel.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "buildCommand": "bun run build",
2
+ "buildCommand": "bun run build:vercel",
3
3
  "installCommand": "npx bun@1.2.23 install"
4
4
  }
package/src/envs/oidc.ts DELETED
@@ -1,18 +0,0 @@
1
- import { createEnv } from '@t3-oss/env-nextjs';
2
- import { z } from 'zod';
3
-
4
- export const oidcEnv = createEnv({
5
- client: {},
6
- runtimeEnv: {
7
- ENABLE_OIDC: process.env.ENABLE_OIDC === '1',
8
- OIDC_JWKS_KEY: process.env.OIDC_JWKS_KEY,
9
- },
10
- server: {
11
- // 是否启用 OIDC
12
- ENABLE_OIDC: z.boolean().optional().default(false),
13
- // OIDC 签名密钥
14
- // 必须是一个包含私钥的 JWKS (JSON Web Key Set) 格式的 JSON 字符串。
15
- // 可以使用 `node scripts/generate-oidc-jwk.mjs` 命令生成。
16
- OIDC_JWKS_KEY: z.string().optional(),
17
- },
18
- });