π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix: name the deployment's own app in web shell copy and OIDC clients (#22232)
LiJianed671490fa30
diff --git a/apps/desktop/pnpm-lock.yaml b/apps/desktop/pnpm-lock.yamlindex 2d6de65cc10..89bc277e0ce 100644--- a/apps/desktop/pnpm-lock.yaml+++ b/apps/desktop/pnpm-lock.yaml@@ -679,6 +679,9 @@ importers:../../packages/types:dependencies:+ '@lobechat/business-const':+ specifier: workspace:*+ version: link:../business/const'@lobehub/market-sdk':specifier: 0.46.0version: 0.46.0([email protected])([email protected])diff --git a/apps/server/src/services/toolExecution/index.ts b/apps/server/src/services/toolExecution/index.tsindex a067d87ffb1..03544db1d7c 100644--- a/apps/server/src/services/toolExecution/index.ts+++ b/apps/server/src/services/toolExecution/index.ts@@ -328,7 +328,7 @@ export class ToolExecutionService {: undefined;if (!tunnelTarget) {log('Device-only MCP %s:%s has no reachable device β failing fast', identifier, apiName);- const message = `MCP server '${identifier}' only your own machine can reach (stdio or local network). No online ${BRANDING_NAME} desktop app was found to run it (a device connected only through the \`lh connect\` CLI cannot run MCP servers) β open the LobeHub desktop app on the machine that hosts this MCP server, then retry.`;+ const message = `MCP server '${identifier}' only your own machine can reach (stdio or local network). No online ${BRANDING_NAME} desktop app was found to run it (a device connected only through the \`lh connect\` CLI cannot run MCP servers) β open the ${BRANDING_NAME} desktop app on the machine that hosts this MCP server, then retry.`;return {content: message,error: { code: 'MCP_DEVICE_UNAVAILABLE', message },diff --git a/packages/types/package.json b/packages/types/package.jsonindex 9fcd884af4e..2ec903e5510 100644--- a/packages/types/package.json+++ b/packages/types/package.json@@ -15,6 +15,7 @@"test:update": "vitest -u"},"dependencies": {+ "@lobechat/business-const": "workspace:*","@lobehub/market-sdk": "0.46.0","@lobehub/market-types": "^1.19.0","ajv": "^8.20.0",diff --git a/packages/types/src/agent/executionTargetRules.test.ts b/packages/types/src/agent/executionTargetRules.test.tsnew file mode 100644index 00000000000..785b767e78b--- /dev/null+++ b/packages/types/src/agent/executionTargetRules.test.ts@@ -0,0 +1,47 @@+import type * as BusinessConst from '@lobechat/business-const';+import { afterEach, describe, expect, it, vi } from 'vitest';++import type { ExecutionPlan } from './agencyConfig';++const offlineBoundDevice = {+ kind: 'device-unrouted',+ reason: 'bound-device-offline',+ target: 'device',+} as unknown as ExecutionPlan;++const loadDescribe = async (branding?: Partial<typeof BusinessConst>) => {+ vi.resetModules();+ if (branding) {+ vi.doMock('@lobechat/business-const', async (importOriginal) => ({+ ...(await importOriginal<typeof BusinessConst>()),+ ...branding,+ }));+ // Under vitest 5 a `doMock` only lands once the test file itself imports+ // something, so pull the mocked module in before the one under test.+ await import('@lobechat/business-const');+ }+ return (await import('./executionTargetRules')).describeLockedDevicePicker;+};++afterEach(() => {+ vi.doUnmock('@lobechat/business-const');+ vi.resetModules();+});++describe('describeLockedDevicePicker', () => {+ it('points at the upstream desktop app under default branding', async () => {+ const describeLockedDevicePicker = await loadDescribe();++ expect(describeLockedDevicePicker(offlineBoundDevice)).toContain(+ 'Tell the user to reconnect it (LobeHub desktop app or `lh connect`).',+ );+ });++ it("points at the deployment's own desktop app under custom branding", async () => {+ const describeLockedDevicePicker = await loadDescribe({ BRANDING_NAME: 'Acme' });+ const hint = describeLockedDevicePicker(offlineBoundDevice);++ expect(hint).toContain('Tell the user to reconnect it (Acme desktop app or `lh connect`).');+ expect(hint).not.toContain('LobeHub');+ });+});diff --git a/packages/types/src/agent/executionTargetRules.ts b/packages/types/src/agent/executionTargetRules.tsindex d016794a5e0..86dd936ffe7 100644--- a/packages/types/src/agent/executionTargetRules.ts+++ b/packages/types/src/agent/executionTargetRules.ts@@ -1,3 +1,5 @@+import { BRANDING_NAME } from '@lobechat/business-const';+import type { DeviceExecutionTarget, ExecutionPlan } from './agencyConfig';import type { RuntimeEnvMode } from './agentConfig';import type { LobeAgentChatConfig } from './chatConfig';@@ -59,5 +61,5 @@ export const describeLockedDevicePicker = (plan: ExecutionPlan): string | undefireturn plan.kind === 'device'? `Device switching is off for this run: it is locked to device "${plan.deviceId}", where the Local System tools already run. ${switchHint}`- : `Device switching is off for this run: it is locked to the user's bound device, which is offline. Tell the user to reconnect it (LobeHub desktop app or \`lh connect\`). ${switchHint}`;+ : `Device switching is off for this run: it is locked to the user's bound device, which is offline. Tell the user to reconnect it (${BRANDING_NAME} desktop app or \`lh connect\`). ${switchHint}`;};diff --git a/src/features/AuthShell/AuthContainer.tsx b/src/features/AuthShell/AuthContainer.tsxindex 192825f01d2..c6b46fcbc87 100644--- a/src/features/AuthShell/AuthContainer.tsx+++ b/src/features/AuthShell/AuthContainer.tsx@@ -1,5 +1,6 @@'use client';+import { BRANDING_NAME } from '@lobechat/business-const';import { Center, cx, Divider, Flexbox } from '@lobehub/ui';import { type FC, type PropsWithChildren } from 'react';@@ -21,7 +22,7 @@ const AuthContainer: FC<PropsWithChildren> = ({ children }) => {width={'100%'}><Flexbox horizontal align={'center'} padding={16} width={'100%'}>- <a aria-label={'LobeHub'} href={'/'} style={{ display: 'inline-flex' }}>+ <a aria-label={BRANDING_NAME} href={'/'} style={{ display: 'inline-flex' }}><ProductLogo size={40} /></a></Flexbox>diff --git a/src/features/MessageList/Body.tsx b/src/features/MessageList/Body.tsxindex df8a5bff897..ed8f228e965 100644--- a/src/features/MessageList/Body.tsx+++ b/src/features/MessageList/Body.tsx@@ -1,5 +1,6 @@'use client';+import { DEFAULT_INBOX_TITLE } from '@lobechat/const';import { agentDisplayName } from '@lobechat/types';import { Flexbox } from '@lobehub/ui';import * as stylex from '@stylexjs/stylex';@@ -138,7 +139,7 @@ const Body = memo(() => {const inboxTitle = useAgentStore((s) =>agentDisplayName(agentSelectors.getAgentMetaById(resolveInboxAgentRouteId(inboxAgentId))(s),- 'Lobe AI',+ DEFAULT_INBOX_TITLE,),);diff --git a/src/features/MessageList/InboxConversation.tsx b/src/features/MessageList/InboxConversation.tsxindex a678bf9aa3a..64b0e70a0c6 100644--- a/src/features/MessageList/InboxConversation.tsx+++ b/src/features/MessageList/InboxConversation.tsx@@ -1,6 +1,6 @@'use client';-import { DEFAULT_INBOX_AVATAR } from '@lobechat/const';+import { DEFAULT_INBOX_AVATAR, DEFAULT_INBOX_TITLE } from '@lobechat/const';import { agentDisplayName } from '@lobechat/types';import { Avatar } from '@lobehub/ui';import { memo } from 'react';@@ -27,7 +27,7 @@ const InboxConversation = memo<{ activeRouteId?: string; preview?: string }>();const prefetchAgent = usePrefetchAgent();const url = usePreservedAgentUrl(routeId);- const title = agentDisplayName(meta, 'Lobe AI');+ const title = agentDisplayName(meta, DEFAULT_INBOX_TITLE);const active = !!activeRouteId && (activeRouteId === routeId || activeRouteId === inboxAgentId);return (diff --git a/src/libs/localDatabase/indexedDBAdapter.ts b/src/libs/localDatabase/indexedDBAdapter.tsindex 62548ee4705..850d8e7e3a6 100644--- a/src/libs/localDatabase/indexedDBAdapter.ts+++ b/src/libs/localDatabase/indexedDBAdapter.ts@@ -1,3 +1,5 @@+import { BRANDING_NAME } from '@lobechat/business-const';+import {INDEXED_DB_NAME,INDEXED_DB_RECORD_STORE,@@ -52,7 +54,7 @@ const openDatabase = (onVersionChange: () => void): Promise<IDBDatabase> =>request.onblocked = () => {settled = true;- reject(new Error('IndexedDB upgrade was blocked by another LobeHub tab'));+ reject(new Error(`IndexedDB upgrade was blocked by another ${BRANDING_NAME} tab`));};request.onerror = () => {settled = true;diff --git a/src/libs/mcp/client.sdkErrors.test.ts b/src/libs/mcp/client.sdkErrors.test.tsindex 920eab817d1..13d9516710a 100644--- a/src/libs/mcp/client.sdkErrors.test.ts+++ b/src/libs/mcp/client.sdkErrors.test.ts@@ -1,3 +1,4 @@+import type * as BusinessConst from '@lobechat/business-const';import {Client,SdkError,@@ -52,10 +53,44 @@ describe('MCP SDK v2 error handling', () => {);await expect(httpClient().callTool('test', {})).resolves.toMatchObject({isError: true,- content: [{ type: 'text', text: expect.stringContaining('requires user input') }],+ content: [+ {+ type: 'text',+ text: 'This MCP tool requires user input that LobeHub does not support yet. Use a tool that does not require additional input.',+ },+ ],});});+ it("names the deployment's own app in the input_required failure under custom branding", async () => {+ vi.resetModules();+ vi.doMock('@lobechat/business-const', async (importOriginal) => ({+ ...(await importOriginal<typeof BusinessConst>()),+ BRANDING_NAME: 'Acme',+ }));+ // Under vitest 5 a `doMock` only lands once the test file itself imports+ // something, so pull the mocked module in before the one under test.+ await import('@lobechat/business-const');+ const sdk = await import('@modelcontextprotocol/client');+ const { MCPClient: BrandedClient } = await import('./client');+ vi.spyOn(sdk.Client.prototype, 'callTool').mockRejectedValue(+ new sdk.SdkError(sdk.SdkErrorCode.UnsupportedResultType, 'input_required', {+ resultType: 'input_required',+ method: 'tools/call',+ }),+ );++ const result = await new BrandedClient({+ name: 'test',+ type: 'http',+ url: 'https://mcp.example.com',+ }).callTool('test', {});++ expect(result.content[0].text).toContain('user input that Acme does not support yet');+ vi.doUnmock('@lobechat/business-const');+ vi.resetModules();+ });+it('classifies initialize HTTP 401 without a status in the message', async () => {vi.spyOn(Client.prototype, 'connect').mockRejectedValue(httpError(401));await expect(httpClient().initialize()).rejects.toMatchObject({diff --git a/src/libs/mcp/client.ts b/src/libs/mcp/client.tsindex 61013e5b2cf..37f4036dbbe 100644--- a/src/libs/mcp/client.ts+++ b/src/libs/mcp/client.ts@@ -1,5 +1,6 @@import { spawn } from 'node:child_process';+import { BRANDING_NAME } from '@lobechat/business-const';import { toRecord } from '@lobechat/utils/object';import {Client,@@ -473,7 +474,7 @@ export class MCPClient {content: [{type: 'text',- text: 'This MCP tool requires user input that LobeHub does not support yet. Use a tool that does not require additional input.',+ text: `This MCP tool requires user input that ${BRANDING_NAME} does not support yet. Use a tool that does not require additional input.`,},],isError: true,diff --git a/src/libs/metadata/metadata.test.ts b/src/libs/metadata/metadata.test.tsindex 20efa5d65c9..b9a5b6ae6d5 100644--- a/src/libs/metadata/metadata.test.ts+++ b/src/libs/metadata/metadata.test.ts@@ -1,7 +1,8 @@// @vitest-environment node+import type * as BusinessConst from '@lobechat/business-const';import { BRANDING_NAME } from '@lobechat/business-const';import { OG_URL } from '@lobechat/const';-import { describe, expect, it } from 'vitest';+import { afterEach, describe, expect, it, vi } from 'vitest';import { Meta } from './metadata';@@ -135,3 +136,43 @@ describe('Metadata', () => {});});});++describe('Metadata default description and branding', () => {+ const loadMeta = async (branding?: Partial<typeof BusinessConst>) => {+ vi.resetModules();+ if (branding) {+ vi.doMock('@lobechat/business-const', async (importOriginal) => ({+ ...(await importOriginal<typeof BusinessConst>()),+ ...branding,+ }));+ // Under vitest 5 a `doMock` only lands once the test file itself imports+ // something, so pull the mocked module in before the one under test.+ await import('@lobechat/business-const');+ }+ const { Meta: FreshMeta } = await import('./metadata');+ return new FreshMeta();+ };++ afterEach(() => {+ vi.doUnmock('@lobechat/business-const');+ vi.resetModules();+ });++ it('keeps the existing wording under default branding', async () => {+ const result = (await loadMeta()).generate({ title: 'Home', url: 'https://example.com' });++ expect(result.description).toContain(+ 'LobeChat offers you the best ChatGPT, OLLaMA, Gemini, Claude WebUI user experience',+ );+ });++ it("names the deployment's own app under custom branding", async () => {+ const result = (await loadMeta({ BRANDING_NAME: 'Acme', ORG_NAME: 'Acme Inc' })).generate({+ title: 'Home',+ url: 'https://example.com',+ });++ expect(result.description).toContain('Acme offers you the best');+ expect(result.description).not.toMatch(/LobeChat|LobeHub/);+ });+});diff --git a/src/libs/metadata/metadata.ts b/src/libs/metadata/metadata.tsindex ea0bdf30c6a..045c047586a 100644--- a/src/libs/metadata/metadata.ts+++ b/src/libs/metadata/metadata.ts@@ -4,7 +4,7 @@ import qs from 'query-string';import { DEFAULT_LANG } from '@/const/locale';import { OG_URL } from '@/const/url';-import { isCustomORG } from '@/const/version';+import { isCustomBranding, isCustomORG } from '@/const/version';import { type Locales } from '@/locales/resources';import { locales } from '@/locales/resources';import { getCanonicalUrl } from '@/server/utils/url';@@ -12,7 +12,9 @@ import { formatDescLength, formatTitleLength } from '@/utils/genOG';export class Meta {public generate({- description = 'LobeChat offers you the best ChatGPT, OLLaMA, Gemini, Claude WebUI user experience',+ description = isCustomBranding+ ? `${BRANDING_NAME} offers you the best ChatGPT, OLLaMA, Gemini, Claude WebUI user experience`+ : 'LobeChat offers you the best ChatGPT, OLLaMA, Gemini, Claude WebUI user experience',title,image = OG_URL,url,diff --git a/src/libs/oidc-provider/config.test.ts b/src/libs/oidc-provider/config.test.tsnew file mode 100644index 00000000000..e27aee7eae5--- /dev/null+++ b/src/libs/oidc-provider/config.test.ts@@ -0,0 +1,41 @@+// @vitest-environment node+import type * as BusinessConst from '@lobechat/business-const';+import { afterEach, describe, expect, it, vi } from 'vitest';++// The consent screen shows these names to the person signing in, so they name+// the deployment's own app rather than the upstream product.+const loadClientNames = async (branding?: Partial<typeof BusinessConst>) => {+ vi.resetModules();+ if (branding) {+ vi.doMock('@lobechat/business-const', async (importOriginal) => ({+ ...(await importOriginal<typeof BusinessConst>()),+ ...branding,+ }));+ // Under vitest 5 a `doMock` only lands once the test file itself imports+ // something, so pull the mocked module in before the one under test.+ await import('@lobechat/business-const');+ }+ const { defaultClients } = await import('./config');+ return Object.fromEntries(defaultClients.map((c) => [c.client_id, c.client_name]));+};++afterEach(() => {+ vi.doUnmock('@lobechat/business-const');+ vi.resetModules();+});++describe('OIDC default clients', () => {+ it('keep the upstream names under default branding', async () => {+ const names = await loadClientNames();++ expect(names['lobehub-desktop']).toBe('LobeHub Desktop');+ expect(names['lobehub-mobile']).toBe('LobeHub Mobile');+ });++ it("name the deployment's own desktop and mobile apps under custom branding", async () => {+ const names = await loadClientNames({ BRANDING_NAME: 'Acme' });++ expect(names['lobehub-desktop']).toBe('Acme Desktop');+ expect(names['lobehub-mobile']).toBe('Acme Mobile');+ });+});diff --git a/src/libs/oidc-provider/config.ts b/src/libs/oidc-provider/config.tsindex 33b6e1d9a6e..52b3641878b 100644--- a/src/libs/oidc-provider/config.ts+++ b/src/libs/oidc-provider/config.ts@@ -1,3 +1,4 @@+import { BRANDING_NAME } from '@lobechat/business-const';import { ACCEPTANCE_CLIENT_ID, ACCEPTANCE_REVIEW_SCOPE } from '@lobechat/const';import { type ClientMetadata } from 'oidc-provider';import urlJoin from 'url-join';@@ -18,7 +19,7 @@ export const defaultClients: ClientMetadata[] = [{application_type: 'web',client_id: 'lobehub-desktop',- client_name: 'LobeHub Desktop',+ client_name: `${BRANDING_NAME} Desktop`,// Only supports authorization code flowgrant_types: ['authorization_code', 'refresh_token'],@@ -46,7 +47,7 @@ export const defaultClients: ClientMetadata[] = [{application_type: 'native', // Mobile uses native typeclient_id: 'lobehub-mobile',- client_name: 'LobeHub Mobile',+ client_name: `${BRANDING_NAME} Mobile`,// Supports authorization code flow and refresh tokengrant_types: ['authorization_code', 'refresh_token'],logo_uri: 'https://hub-apac-1.lobeobjects.space/docs/73f69adfa1b802a0e250f6ff9d62f70b.png',