π€― 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(connector): canonicalize connector ownership (#18763)
Neko601a7b59bc72
diff --git a/packages/agent-manager-runtime/src/AgentManagerRuntime.ts b/packages/agent-manager-runtime/src/AgentManagerRuntime.tsindex 74d6e19b543..fbea4abb235 100644--- a/packages/agent-manager-runtime/src/AgentManagerRuntime.ts+++ b/packages/agent-manager-runtime/src/AgentManagerRuntime.ts@@ -14,7 +14,8 @@* Services must be injected via constructor for runtime-agnostic usage* (e.g., server-side services vs client-side services).*/-import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';+import type { ComposioAppType, LobehubSkillProviderType } from '@lobechat/const';+import { resolveConnectorCatalogItem } from '@lobechat/const';import {marketToolsResultsPrompt,modelsResultsPrompt,@@ -38,7 +39,9 @@ import {lobehubSkillStoreSelectors,pluginSelectors,} from '@/store/tool/selectors';+import type { ComposioServer } from '@/store/tool/slices/composioStore/types';import { ComposioServerStatus } from '@/store/tool/slices/composioStore/types';+import type { LobehubSkillServer } from '@/store/tool/slices/lobehubSkillStore/types';import { LobehubSkillStatus } from '@/store/tool/slices/lobehubSkillStore/types';import { getUserStoreState } from '@/store/user';import { userProfileSelectors } from '@/store/user/selectors';@@ -729,41 +732,39 @@ export class AgentManagerRuntime {const toolState = getToolStoreState();if (source === 'official') {- // Check if it's a Composio toolconst isComposioEnabled =typeof window !== 'undefined' &&window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio;+ const isLobehubSkillEnabled =+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill;+ const connector = resolveConnectorCatalogItem(identifier, {+ composio: Boolean(isComposioEnabled),+ lobehub: Boolean(isLobehubSkillEnabled),+ });- if (isComposioEnabled) {+ if (connector?.type === 'composio') {const composioServer = composioStoreSelectors.getServers(toolState).find((s) => s.identifier === identifier);- const composioAppInfo = COMPOSIO_APP_TYPES.find((t) => t.identifier === identifier);-- if (composioAppInfo) {- return this.handleComposioInstall(agentId, identifier, composioAppInfo, composioServer);- }+ return this.handleComposioInstall(+ agentId,+ identifier,+ connector.serverType,+ composioServer,+ );}- // Check if it's a LobehubSkill provider- const isLobehubSkillEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill;-- if (isLobehubSkillEnabled) {+ if (connector?.type === 'lobehub') {const lobehubSkillServer = lobehubSkillStoreSelectors.getServers(toolState).find((s) => s.identifier === identifier);- const lobehubSkillProviderInfo = LOBEHUB_SKILL_PROVIDERS.find((p) => p.id === identifier);-- if (lobehubSkillProviderInfo) {- return this.handleLobehubSkillInstall(- agentId,- identifier,- lobehubSkillProviderInfo,- lobehubSkillServer,- );- }+ return this.handleLobehubSkillInstall(+ agentId,+ identifier,+ connector.provider,+ lobehubSkillServer,+ );}// Check if it's a builtin tool@@ -831,8 +832,8 @@ export class AgentManagerRuntime {private async handleComposioInstall(agentId: string,identifier: string,- composioAppInfo: (typeof COMPOSIO_APP_TYPES)[0],- composioServer: any,+ composioAppInfo: ComposioAppType,+ composioServer?: ComposioServer,): Promise<BuiltinToolResult> {if (composioServer) {if (composioServer.status === ComposioServerStatus.ACTIVE) {@@ -960,8 +961,8 @@ export class AgentManagerRuntime {private async handleLobehubSkillInstall(agentId: string,identifier: string,- providerInfo: (typeof LOBEHUB_SKILL_PROVIDERS)[0],- server: any,+ providerInfo: LobehubSkillProviderType,+ server?: LobehubSkillServer,): Promise<BuiltinToolResult> {if (server?.status === LobehubSkillStatus.CONNECTED) {await this.enablePluginForAgent(agentId, identifier);diff --git a/packages/agent-manager-runtime/src/__tests__/AgentManagerRuntime.test.ts b/packages/agent-manager-runtime/src/__tests__/AgentManagerRuntime.test.tsindex 13794e3548c..235b82ba0f1 100644--- a/packages/agent-manager-runtime/src/__tests__/AgentManagerRuntime.test.ts+++ b/packages/agent-manager-runtime/src/__tests__/AgentManagerRuntime.test.ts@@ -1,6 +1,9 @@import { beforeEach, describe, expect, it, vi } from 'vitest';import { getAgentStoreState } from '@/store/agent';+import { composioStoreSelectors, lobehubSkillStoreSelectors } from '@/store/tool/selectors';+import { ComposioServerStatus } from '@/store/tool/slices/composioStore/types';+import { LobehubSkillStatus } from '@/store/tool/slices/lobehubSkillStore/types';import { AgentManagerRuntime } from '../AgentManagerRuntime';import type { IAgentService, IDiscoverService } from '../types';@@ -142,6 +145,9 @@ describe('AgentManagerRuntime', () => {beforeEach(() => {vi.clearAllMocks();+ vi.mocked(composioStoreSelectors.getServers).mockReturnValue([]);+ vi.mocked(lobehubSkillStoreSelectors.getServers).mockReturnValue([]);+ Reflect.deleteProperty(window, 'global_serverConfigStore');runtime = new AgentManagerRuntime({agentService: mockAgentService,discoverService: mockDiscoverService,@@ -780,6 +786,51 @@ describe('AgentManagerRuntime', () => {});describe('installPlugin', () => {+ /** @example An unqualified GitHub install selects the canonical LobeHub owner. */+ it('routes colliding official connector identifiers to LobeHub', async () => {+ // ROOT CAUSE:+ //+ // Official connector installation used to check the Composio catalog first.+ // Because GitHub exists in both catalogs, the agent builder opened Composio+ // even though the generic connector catalog assigns GitHub to LobeHub.+ //+ // We fixed this by resolving the shared catalog owner before dispatching+ // to either authorization runtime.+ window.global_serverConfigStore = {+ getState: () => ({+ serverConfig: { enableComposio: true, enableLobehubSkill: true },+ }),+ } as unknown as NonNullable<typeof window.global_serverConfigStore>;+ vi.mocked(composioStoreSelectors.getServers).mockReturnValue([+ {+ appSlug: 'GITHUB',+ authConfigId: 'auth-config-id',+ connectedAccountId: 'connected-account-id',+ createdAt: 1,+ identifier: 'github',+ label: 'GitHub',+ status: ComposioServerStatus.ACTIVE,+ },+ ]);+ vi.mocked(lobehubSkillStoreSelectors.getServers).mockReturnValue([+ {+ identifier: 'github',+ isConnected: true,+ name: 'GitHub',+ status: LobehubSkillStatus.CONNECTED,+ },+ ]);++ const result = await runtime.installPlugin('agent-id', {+ identifier: 'github',+ source: 'official',+ });++ expect(result.success).toBe(true);+ expect(result.content).toContain('Successfully enabled LobehubSkill provider');+ expect(result.state).toMatchObject({ isLobehubSkill: true, pluginId: 'github' });+ });+it('should install builtin tool', async () => {const result = await runtime.installPlugin('agent-id', {identifier: 'lobe-web-browsing',diff --git a/packages/builtin-tool-agent-builder/src/client/Intervention/InstallPlugin.tsx b/packages/builtin-tool-agent-builder/src/client/Intervention/InstallPlugin.tsxindex d21a5c6bb2d..7c82a2b1802 100644--- a/packages/builtin-tool-agent-builder/src/client/Intervention/InstallPlugin.tsx+++ b/packages/builtin-tool-agent-builder/src/client/Intervention/InstallPlugin.tsx@@ -1,6 +1,6 @@'use client';-import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';+import { resolveConnectorCatalogItem } from '@lobechat/const';import type { BuiltinInterventionProps } from '@lobechat/types';import { Flexbox } from '@lobehub/ui';import { Avatar } from '@lobehub/ui/base-ui';@@ -8,6 +8,7 @@ import { CheckCircle } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useToolStore } from '@/store/tool';import {composioStoreSelectors,@@ -31,6 +32,8 @@ const InstallPluginIntervention = memo<BuiltinInterventionProps<InstallPluginPar({ args }) => {const { identifier, source } = args;const { t } = useTranslation('chat');+ const isComposioEnabled = useServerConfigStore(serverConfigSelectors.enableComposio);+ const isLobehubSkillEnabled = useServerConfigStore(serverConfigSelectors.enableLobehubSkill);// Tool store selectorsconst isPluginInstalled = useToolStore((s) => pluginSelectors.isPluginInstalled(identifier)(s));@@ -53,12 +56,14 @@ const InstallPluginIntervention = memo<BuiltinInterventionProps<InstallPluginPars.builtinTools.find((tool) => tool.identifier === identifier),);- // Check if it's a Composio tool- const composioAppInfo = COMPOSIO_APP_TYPES.find((t) => t.identifier === identifier);+ const connector = resolveConnectorCatalogItem(identifier, {+ composio: isComposioEnabled,+ lobehub: isLobehubSkillEnabled,+ });+ const composioAppInfo = connector?.type === 'composio' ? connector.serverType : undefined;const isComposio = source === 'official' && !!composioAppInfo;- // Check if it's a LobehubSkill provider- const lobehubSkillProviderInfo = LOBEHUB_SKILL_PROVIDERS.find((p) => p.id === identifier);+ const lobehubSkillProviderInfo = connector?.type === 'lobehub' ? connector.provider : undefined;const isLobehubSkill = source === 'official' && !!lobehubSkillProviderInfo;// Render success state (already installed)diff --git a/packages/const/src/connectorCatalog.test.ts b/packages/const/src/connectorCatalog.test.tsnew file mode 100644index 00000000000..0bb0a19d3c2--- /dev/null+++ b/packages/const/src/connectorCatalog.test.ts@@ -0,0 +1,65 @@+import { describe, expect, it } from 'vitest';++import { getComposioAppByIdentifier } from './composio';+import { getConnectorCatalog, resolveConnectorCatalogItem } from './connectorCatalog';++describe('connectorCatalog', () => {+ /**+ * @example Generic connector surfaces render one canonical owner for overlapping identifiers.+ */+ it('prefers LobeHub for GitHub, Notion, and X collisions', () => {+ // ROOT CAUSE:+ //+ // The onboarding flow added GitHub, Notion, and X to the raw Composio capability catalog.+ // Generic connector surfaces then concatenated that catalog with LobeHub providers, producing+ // duplicate rows and sending unqualified agent plugin IDs through Composio authorization.+ //+ // Before: github/notion/twitter each resolved to both LobeHub and Composio.+ // After: each unqualified identifier resolves once, with LobeHub as its canonical owner.+ const catalog = getConnectorCatalog({ composio: true, lobehub: true });++ for (const identifier of ['github', 'notion', 'twitter']) {+ const matches = catalog.filter((item) =>+ item.type === 'lobehub'+ ? item.provider.id === identifier+ : item.serverType.identifier === identifier,+ );+ expect(matches).toHaveLength(1);+ expect(matches[0]?.type).toBe('lobehub');+ }+ });++ /**+ * @example Explicit onboarding flows can still request the raw Composio GitHub definition.+ */+ it('preserves source-qualified Composio capability lookup', () => {+ expect(getComposioAppByIdentifier('github')).toMatchObject({+ appSlug: 'GITHUB',+ identifier: 'github',+ });+ });++ /**+ * @example A disabled canonical owner does not expose a conflicting fallback authorization path.+ */+ it('does not fall back to Composio when an overlapping LobeHub owner is disabled', () => {+ const catalog = getConnectorCatalog({ composio: true, lobehub: false });++ for (const identifier of ['github', 'notion', 'twitter']) {+ expect(+ catalog.some((item) =>+ item.type === 'lobehub'+ ? item.provider.id === identifier+ : item.serverType.identifier === identifier,+ ),+ ).toBe(false);+ }++ expect(+ resolveConnectorCatalogItem('twitter', { composio: true, lobehub: false }),+ ).toBeUndefined();+ expect(resolveConnectorCatalogItem('gmail', { composio: true, lobehub: false })).toMatchObject({+ type: 'composio',+ });+ });+});diff --git a/packages/const/src/connectorCatalog.ts b/packages/const/src/connectorCatalog.tsnew file mode 100644index 00000000000..6c35c63f852--- /dev/null+++ b/packages/const/src/connectorCatalog.ts@@ -0,0 +1,80 @@+import type { ComposioAppType } from './composio';+import { COMPOSIO_APP_TYPES } from './composio';+import type { LobehubSkillProviderType } from './lobehubSkill';+import { LOBEHUB_SKILL_PROVIDERS } from './lobehubSkill';++/** Feature availability used when resolving an unqualified connector identifier. */+export interface ConnectorCatalogAvailability {+ /** Whether Composio-backed connectors may be selected. */+ composio: boolean;+ /** Whether LobeHub Market connectors may be selected. */+ lobehub: boolean;+}++/** A connector definition with its owning authorization system attached. */+export type ConnectorCatalogItem =+ | { provider: LobehubSkillProviderType; type: 'lobehub' }+ | { serverType: ComposioAppType; type: 'composio' };++/**+ * Resolves the owner of an unqualified connector identifier.+ *+ * Use when:+ * - A generic connector surface only stores an identifier such as `github`+ * - LobeHub and Composio catalogs may contain the same identifier+ *+ * Expects:+ * - Explicitly source-qualified flows use their declared source instead+ * - LobeHub owns collisions even when its connector integration is unavailable+ *+ * Returns:+ * - The single connector definition that generic product surfaces should render+ */+export const resolveConnectorCatalogItem = (+ identifier: string,+ availability: ConnectorCatalogAvailability,+): ConnectorCatalogItem | undefined => {+ const provider = LOBEHUB_SKILL_PROVIDERS.find((item) => item.id === identifier);+ if (provider) return availability.lobehub ? { provider, type: 'lobehub' } : undefined;++ if (availability.composio) {+ const serverType = COMPOSIO_APP_TYPES.find((item) => item.identifier === identifier);+ if (serverType) return { serverType, type: 'composio' };+ }+};++/**+ * Builds the connector catalog for generic, unqualified product surfaces.+ *+ * Use when:+ * - Rendering connector discovery, settings, or agent tool pickers+ * - Every visible identifier must map to exactly one authorization system+ *+ * Expects:+ * - Explicit onboarding/provider registries continue to use their source-qualified catalogs+ *+ * Returns:+ * - LobeHub connectors first, followed by non-conflicting Composio connectors+ */+export const getConnectorCatalog = (+ availability: ConnectorCatalogAvailability,+): ConnectorCatalogItem[] => {+ const identifiers = new Set(LOBEHUB_SKILL_PROVIDERS.map((provider) => provider.id));+ const catalog: ConnectorCatalogItem[] = [];++ if (availability.lobehub) {+ for (const provider of LOBEHUB_SKILL_PROVIDERS) {+ catalog.push({ provider, type: 'lobehub' });+ }+ }++ if (availability.composio) {+ for (const serverType of COMPOSIO_APP_TYPES) {+ if (identifiers.has(serverType.identifier)) continue;+ identifiers.add(serverType.identifier);+ catalog.push({ serverType, type: 'composio' });+ }+ }++ return catalog;+};diff --git a/packages/const/src/index.ts b/packages/const/src/index.tsindex 304d068add5..86d27a0eaa3 100644--- a/packages/const/src/index.ts+++ b/packages/const/src/index.ts@@ -3,6 +3,7 @@ export * from './agentName';export * from './apiKeyScope';export * from './bot';export * from './composio';+export * from './connectorCatalog';export * from './currency';export * from './desktop';export * from './desktopGlobalShortcuts';diff --git a/src/features/AgentHome/index.tsx b/src/features/AgentHome/index.tsxindex 15a22b60678..5873acd10f1 100644--- a/src/features/AgentHome/index.tsx+++ b/src/features/AgentHome/index.tsx@@ -4,7 +4,7 @@ import { Flexbox } from '@lobehub/ui';import isEqual from 'fast-deep-equal';import { memo } from 'react';-import ToolAuthAlert from '@/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert';+import ToolAuthAlert from '@/features/Conversation/AgentWelcome/ToolAuthAlert';import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.tsx b/src/features/ChatInput/ActionBar/Tools/useControls.tsxindex 2c2239b60bf..5a9dc51a974 100644--- a/src/features/ChatInput/ActionBar/Tools/useControls.tsx+++ b/src/features/ChatInput/ActionBar/Tools/useControls.tsx@@ -1,9 +1,4 @@-import {- COMPOSIO_APP_TYPES,- LOBEHUB_SKILL_PROVIDERS,- RECOMMENDED_SKILLS,- RecommendedSkillType,-} from '@lobechat/const';+import { getConnectorCatalog, RECOMMENDED_SKILLS, RecommendedSkillType } from '@lobechat/const';import { type AgentPluginMode, getDisabledPluginIds } from '@lobechat/types';import type { ItemType } from '@lobehub/ui';import { Icon, Popover, SearchBar, stopPropagation, Tooltip } from '@lobehub/ui';@@ -839,11 +834,22 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =[allComposioServers],);- // Get all Composio server type identifier sets (used for filtering builtinList)- // Using COMPOSIO_APP_TYPES instead of connected servers here, because we want to filter out all possible Composio types- const allComposioTypeIdentifiers = useMemo(- () => new Set(COMPOSIO_APP_TYPES.map((type) => type.identifier)),- [],+ const connectorCatalog = useMemo(+ () =>+ getConnectorCatalog({+ composio: isComposioEnabledInEnv,+ lobehub: isLobehubSkillEnabled,+ }),+ [isComposioEnabledInEnv, isLobehubSkillEnabled],+ );+ const connectorIdentifiers = useMemo(+ () =>+ new Set(+ connectorCatalog.map((item) =>+ item.type === 'lobehub' ? item.provider.id : item.serverType.identifier,+ ),+ ),+ [connectorCatalog],);// Get all skill identifier sets (used for filtering builtinList)const allSkillIdentifiers = useMemo(() => {@@ -854,14 +860,11 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =return ids;}, [installedBuiltinSkills, marketAgentSkills, userAgentSkills]);- // Filter out Composio tools and skills from builtinList (they will be displayed separately)+ // Filter out connectors and skills from builtinList (they are displayed separately)const filteredBuiltinList = useMemo(() => {- let list = builtinList;- if (isComposioEnabledInEnv) {- list = list.filter((item) => !allComposioTypeIdentifiers.has(item.identifier));- }+ const list = builtinList.filter((item) => !connectorIdentifiers.has(item.identifier));return list.filter((item) => !allSkillIdentifiers.has(item.identifier));- }, [builtinList, allComposioTypeIdentifiers, isComposioEnabledInEnv, allSkillIdentifiers]);+ }, [builtinList, connectorIdentifiers, allSkillIdentifiers]);// Get recommended Composio skill IDsconst recommendedComposioIds = useMemo(@@ -893,6 +896,32 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =[allLobehubSkillServers],);+ const visibleComposioTypes = useMemo(+ () =>+ connectorCatalog+ .filter((item) => item.type === 'composio')+ .map(({ serverType }) => serverType)+ .filter(+ (type) =>+ installedComposioIds.has(type.identifier) ||+ recommendedComposioIds.has(type.identifier) ||+ checkedSet.has(type.identifier) ||+ disabledIdSet.has(type.identifier),+ ),+ [connectorCatalog, installedComposioIds, recommendedComposioIds, checkedSet, disabledIdSet],+ );+ const visibleLobehubProviders = useMemo(+ () =>+ connectorCatalog+ .filter((item) => item.type === 'lobehub')+ .map(({ provider }) => provider)+ .filter(+ (provider) =>+ installedLobehubIds.has(provider.id) || recommendedLobehubIds.has(provider.id),+ ),+ [connectorCatalog, installedLobehubIds, recommendedLobehubIds],+ );+// Remove a Composio connection AND drop its identifier from the agent's// plugins. `ComposioServerItem.handleConnect` optimistically adds the new// server id to `plugins` before OAuth completes, so deleting the connection@@ -920,13 +949,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =const composioServerItems = useMemo(() =>isComposioEnabledInEnv- ? COMPOSIO_APP_TYPES.filter(- (type) =>- installedComposioIds.has(type.identifier) ||- recommendedComposioIds.has(type.identifier) ||- checkedSet.has(type.identifier) ||- disabledIdSet.has(type.identifier),- ).map((type) => {+ ? visibleComposioTypes.map((type) => {const server = getServerByName(type.identifier);const icon = (<ComposioSkillIcon icon={type.icon} label={type.label} size={SKILL_ICON_SIZE} />@@ -1016,8 +1039,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =: [],[isComposioEnabledInEnv,- installedComposioIds,- recommendedComposioIds,+ visibleComposioTypes,agentId,t,createManagedSkillItem,@@ -1034,10 +1056,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =const lobehubSkillItems = useMemo(() =>isLobehubSkillEnabled- ? LOBEHUB_SKILL_PROVIDERS.filter(- (provider) =>- installedLobehubIds.has(provider.id) || recommendedLobehubIds.has(provider.id),- ).map((provider) => {+ ? visibleLobehubProviders.map((provider) => {const server = allLobehubSkillServers.find((s) => s.identifier === provider.id);const icon = (<LobehubSkillIcon@@ -1087,9 +1106,8 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =: [],[isLobehubSkillEnabled,+ visibleLobehubProviders,allLobehubSkillServers,- installedLobehubIds,- recommendedLobehubIds,agentId,t,createManagedSkillItem,diff --git a/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsx b/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsxsimilarity index 68%rename from src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsxrename to src/features/Conversation/AgentWelcome/ToolAuthAlert.tsxindex ffb4d4d10fe..c8f3d6d1431 100644--- a/src/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert.tsx+++ b/src/features/Conversation/AgentWelcome/ToolAuthAlert.tsx@@ -1,9 +1,8 @@'use client';-import { type ComposioAppType } from '@lobechat/const';-import { COMPOSIO_APP_TYPES } from '@lobechat/const';+import type { TaskTemplateConnectorReference } from '@lobechat/const';import { Flexbox, Icon } from '@lobehub/ui';-import { ActionIcon, Alert, Avatar, Button, Text } from '@lobehub/ui/base-ui';+import { ActionIcon, Alert, Avatar, Button, Text, toast } from '@lobehub/ui/base-ui';import { Divider } from 'antd';import { createStaticStyles, cssVar, cx } from 'antd-style';import isEqual from 'fast-deep-equal';@@ -12,15 +11,28 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { contextSelectors, useConversationStore } from '@/features/Conversation/store';+import {+ ConnectorConnectionMarketAuthRequiredError,+ ConnectorConnectionPopupBlockedError,+ useConnectorConnection,+} from '@/features/RecommendTaskTemplates/useConnectorConnection';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';import { useAgentStore } from '@/store/agent';import { agentByIdSelectors } from '@/store/agent/selectors';+import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';import { useToolStore } from '@/store/tool';-import { type ComposioServer } from '@/store/tool/slices/composioStore';import { ComposioServerStatus, composioStoreSelectors } from '@/store/tool/slices/composioStore';+import { lobehubSkillStoreSelectors } from '@/store/tool/slices/lobehubSkillStore/selectors';import { useUserStore } from '@/store/user';import { userProfileSelectors } from '@/store/user/selectors';+import type {+ PendingComposioTool,+ PendingLobehubTool,+ PendingMarketTool,+} from './resolvePendingAuthTools';+import { resolvePendingAuthTools } from './resolvePendingAuthTools';+const styles = createStaticStyles(({ css }) => ({// Reveal the remove icon only when the row is hovered.row: css`@@ -37,29 +49,16 @@ const styles = createStaticStyles(({ css }) => ({// Tools that require Market authenticationconst MARKET_AUTH_TOOLS = [{+ authType: 'market',avatar: 'π»',identifier: 'lobe-cloud-sandbox',label: 'Cloud Sandbox',},-];+] satisfies PendingMarketTool[];const POLL_INTERVAL_MS = 1000;const POLL_TIMEOUT_MS = 15_000;-interface PendingComposioTool extends ComposioAppType {- authType: 'composio';- server?: ComposioServer;-}--interface PendingMarketTool {- authType: 'market';- avatar: string;- identifier: string;- label: string;-}--type PendingAuthTool = PendingComposioTool | PendingMarketTool;-interface ComposioToolAuthItemProps {onAuthComplete: () => void;tool: PendingComposioTool;@@ -156,7 +155,7 @@ const ComposioToolAuthItem = memo<ComposioToolAuthItemProps>(({ tool, onAuthComp}}, 500);},- [refreshComposioConnectionStatus, startFallbackPolling],+ [startFallbackPolling],);const openOAuthWindow = useCallback(@@ -268,6 +267,92 @@ const ComposioToolAuthItem = memo<ComposioToolAuthItemProps>(({ tool, onAuthCompComposioToolAuthItem.displayName = 'ComposioToolAuthItem';+interface LobehubToolAuthItemProps {+ tool: PendingLobehubTool;+}++const LobehubToolAuthItem = ({ tool }: LobehubToolAuthItemProps) => {+ const { t } = useTranslation('chat');+ const { t: tCommon } = useTranslation('common');+ const removePlugin = useAgentStore((state) => state.removePlugin);+ const connectorSpecs = useMemo<TaskTemplateConnectorReference[]>(+ () => [{ identifier: tool.id, source: 'lobehub' }],+ [tool.id],+ );+ const { connect, isConnecting } = useConnectorConnection(connectorSpecs);++ const handleAuthorize = async () => {+ try {+ await connect();+ } catch (error) {+ // MarketAuthProvider already surfaces this interruption; avoid a duplicate toast.+ if (error instanceof ConnectorConnectionMarketAuthRequiredError) return;+ toast.error(+ tCommon(+ error instanceof ConnectorConnectionPopupBlockedError+ ? 'taskTemplate.action.connect.popupBlocked'+ : 'taskTemplate.action.connect.error',+ ),+ );+ }+ };++ const handleRemove = async () => {+ try {+ await removePlugin(tool.id);+ } catch (error) {+ console.error('[ToolAuthAlert] Failed to remove plugin:', error);+ }+ };++ const icon =+ typeof tool.icon === 'string' ? (+ <Avatar alt={tool.label} avatar={tool.icon} size={20} style={{ flex: 'none' }} />+ ) : (+ <Icon fill={cssVar.colorText} icon={tool.icon} size={20} />+ );++ return (+ <Flexbox+ horizontal+ align="center"+ className={cx(styles.row)}+ gap={12}+ justify="space-between"+ style={{ cursor: 'pointer' }}+ onClick={handleAuthorize}+ >+ <Flexbox horizontal align="center" gap={8}>+ {icon}+ <Text>{tool.label}</Text>+ <ActionIcon+ className={cx('tool-auth-remove', styles.removeIcon)}+ icon={XIcon}+ size="small"+ title={t('toolAuth.remove')}+ onClick={(event) => {+ event.stopPropagation();+ void handleRemove();+ }}+ />+ </Flexbox>+ <Button+ disabled={isConnecting}+ icon={PlusIcon}+ loading={isConnecting}+ size="small"+ type="text"+ onClick={(event) => {+ event.stopPropagation();+ void handleAuthorize();+ }}+ >+ {isConnecting ? t('toolAuth.authorizing') : t('toolAuth.authorize')}+ </Button>+ </Flexbox>+ );+};+interface MarketToolAuthItemProps {tool: PendingMarketTool;}@@ -340,47 +425,45 @@ const ToolAuthAlert = memo(() => {const agentId = useConversationStore(contextSelectors.agentId);const plugins = useAgentStore(agentByIdSelectors.getAgentPluginsById(agentId), isEqual);+ const isComposioEnabled = useServerConfigStore(serverConfigSelectors.enableComposio);+ const isLobehubSkillEnabled = useServerConfigStore(serverConfigSelectors.enableLobehubSkill);const composioServers = useToolStore(composioStoreSelectors.getServers, isEqual);+ const lobehubServers = useToolStore(lobehubSkillStoreSelectors.getServers, isEqual);// Connections load asynchronously via `useFetchUserComposioConnections` (fired by// ChatInput on the same page). Until they arrive, `composioServers` is the empty// fallback β don't treat a missing server as "needs auth" or the card flashes a// false unauthorized state on refresh before the real status loads.const isComposioServersInit = useToolStore((s) => s.isComposioServersInit);+ const useFetchLobehubSkillConnections = useToolStore(+ (state) => state.useFetchLobehubSkillConnections,+ );+ const lobehubConnections = useFetchLobehubSkillConnections(isLobehubSkillEnabled);+ const isLobehubServersInit = !isLobehubSkillEnabled || !lobehubConnections.isLoading;const { isAuthenticated: isMarketAuthenticated } = useMarketAuth();- // Filter out tools that need authorization- const pendingAuthTools = useMemo<PendingAuthTool[]>(() => {- const result: PendingAuthTool[] = [];-- for (const pluginId of plugins) {- // Check if this is a Composio tool- const composioType = COMPOSIO_APP_TYPES.find((t) => t.identifier === pluginId);- if (composioType) {- const server = composioServers.find((s) => s.identifier === pluginId);- // A missing server only means "not installed" once connections have loaded;- // before that, skip it to avoid flashing a false unauthorized state.- if (!server) {- if (isComposioServersInit) {- result.push({ ...composioType, authType: 'composio', server });- }- continue;- }- // Pending auth- if (server.status === ComposioServerStatus.PENDING_AUTH) {- result.push({ ...composioType, authType: 'composio', server });- }- continue;- }-- // Check if this is a Market auth tool- const marketTool = MARKET_AUTH_TOOLS.find((t) => t.identifier === pluginId);- if (marketTool && !isMarketAuthenticated) {- result.push({ ...marketTool, authType: 'market' });- }- }-- return result;- }, [plugins, composioServers, isComposioServersInit, isMarketAuthenticated]);+ const pendingAuthTools = useMemo(+ () =>+ resolvePendingAuthTools({+ availability: { composio: isComposioEnabled, lobehub: isLobehubSkillEnabled },+ composioInitialized: isComposioServersInit,+ composioServers,+ lobehubInitialized: isLobehubServersInit,+ lobehubServers,+ marketAuthenticated: isMarketAuthenticated,+ marketTools: MARKET_AUTH_TOOLS,+ plugins,+ }),+ [+ composioServers,+ isComposioEnabled,+ isComposioServersInit,+ isLobehubServersInit,+ isLobehubSkillEnabled,+ isMarketAuthenticated,+ lobehubServers,+ plugins,+ ],+ );// Don't render if no pending auth toolsif (pendingAuthTools.length === 0) {@@ -397,19 +480,23 @@ const ToolAuthAlert = memo(() => {{t('toolAuth.hint')}<Divider dashed style={{ marginBlock: 12 }} /><Flexbox gap={12} style={{ marginTop: 8 }}>- {pendingAuthTools.map((tool) =>- tool.authType === 'composio' ? (- <ComposioToolAuthItem- key={tool.identifier}- tool={tool}- onAuthComplete={() => {- // Component will re-render and tool will be removed from list- }}- />- ) : (- <MarketToolAuthItem key={tool.identifier} tool={tool} />- ),- )}+ {pendingAuthTools.map((tool) => {+ if (tool.authType === 'composio') {+ return (+ <ComposioToolAuthItem+ key={tool.identifier}+ tool={tool}+ onAuthComplete={() => {+ // Component will re-render and tool will be removed from list+ }}+ />+ );+ }+ if (tool.authType === 'lobehub') {+ return <LobehubToolAuthItem key={tool.id} tool={tool} />;+ }+ return <MarketToolAuthItem key={tool.identifier} tool={tool} />;+ })}</Flexbox></>}diff --git a/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.test.ts b/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.test.tsnew file mode 100644index 00000000000..e4c718d6162--- /dev/null+++ b/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.test.ts@@ -0,0 +1,110 @@+import { describe, expect, it } from 'vitest';++import { ComposioServerStatus } from '@/store/tool/slices/composioStore';++import { resolvePendingAuthTools } from './resolvePendingAuthTools';++const BASE_INPUT = {+ availability: { composio: true, lobehub: true },+ composioInitialized: true,+ composioServers: [],+ lobehubInitialized: true,+ lobehubServers: [],+ marketAuthenticated: true,+ marketTools: [+ {+ authType: 'market' as const,+ avatar: 'π»',+ identifier: 'lobe-cloud-sandbox',+ label: 'Cloud Sandbox',+ },+ ],+};++describe('resolvePendingAuthTools', () => {+ /**+ * @example Unqualified GitHub, Notion, and X plugins request their LobeHub connector OAuth.+ */+ it('routes overlapping plugins to their canonical LobeHub owner', () => {+ const result = resolvePendingAuthTools({+ ...BASE_INPUT,+ plugins: ['github', 'notion', 'twitter'],+ });++ expect(result.map(({ authType }) => authType)).toEqual(['lobehub', 'lobehub', 'lobehub']);+ expect(result.map((tool) => ('id' in tool ? tool.id : tool.identifier))).toEqual([+ 'github',+ 'notion',+ 'twitter',+ ]);+ });++ /**+ * @example A stale pending Composio GitHub connection cannot override canonical ownership.+ */+ it('routes a stale pending Composio collision to LobeHub', () => {+ // ROOT CAUSE:+ //+ // A persisted Composio server does not record whether the agent plugin came+ // from source-qualified onboarding. Treating every matching row as explicit+ // provenance sends affected GitHub/X users back through the broken provider.+ //+ // Historical collision rows are cleaned up by an out-of-band SQL backfill;+ // runtime ownership therefore remains canonical even if a stale row survives.+ const result = resolvePendingAuthTools({+ ...BASE_INPUT,+ composioServers: [+ {+ appSlug: 'GITHUB',+ authConfigId: 'auth-github',+ connectedAccountId: 'account-github',+ createdAt: 1,+ identifier: 'github',+ label: 'GitHub',+ status: ComposioServerStatus.PENDING_AUTH,+ },+ ],+ plugins: ['github'],+ });++ expect(result).toHaveLength(1);+ expect(result[0]?.authType).toBe('lobehub');+ });++ /**+ * @example An active legacy Composio collision cannot override canonical ownership after migration.+ */+ it('routes an active legacy Composio collision to LobeHub', () => {+ const result = resolvePendingAuthTools({+ ...BASE_INPUT,+ composioServers: [+ {+ appSlug: 'GITHUB',+ authConfigId: 'auth-github',+ connectedAccountId: 'account-github',+ createdAt: 1,+ identifier: 'github',+ label: 'GitHub',+ status: ComposioServerStatus.ACTIVE,+ },+ ],+ plugins: ['github'],+ });++ expect(result).toHaveLength(1);+ expect(result[0]?.authType).toBe('lobehub');+ });++ /**+ * @example Connection stores do not emit false unauthorized rows before their first load settles.+ */+ it('waits for the owning connector store to initialize', () => {+ const result = resolvePendingAuthTools({+ ...BASE_INPUT,+ lobehubInitialized: false,+ plugins: ['twitter'],+ });++ expect(result).toEqual([]);+ });+});diff --git a/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.ts b/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.tsnew file mode 100644index 00000000000..5f28a213695--- /dev/null+++ b/src/features/Conversation/AgentWelcome/resolvePendingAuthTools.ts@@ -0,0 +1,120 @@+import type {+ ComposioAppType,+ ConnectorCatalogAvailability,+ LobehubSkillProviderType,+} from '@lobechat/const';+import { resolveConnectorCatalogItem } from '@lobechat/const';++import type { ComposioServer } from '@/store/tool/slices/composioStore';+import { ComposioServerStatus } from '@/store/tool/slices/composioStore';+import type { LobehubSkillServer } from '@/store/tool/slices/lobehubSkillStore/types';+import { LobehubSkillStatus } from '@/store/tool/slices/lobehubSkillStore/types';++/** A Composio connector that still requires authorization. */+export interface PendingComposioTool extends ComposioAppType {+ /** Authorization system used by the alert row. */+ authType: 'composio';+ /** Existing pending connection, when one has already been created. */+ server?: ComposioServer;+}++/** A LobeHub Market connector that still requires provider authorization. */+export interface PendingLobehubTool extends LobehubSkillProviderType {+ /** Authorization system used by the alert row. */+ authType: 'lobehub';+ /** Current provider connection state, when it has already been checked. */+ server?: LobehubSkillServer;+}++/** A built-in capability that requires the shared Market session. */+export interface PendingMarketTool {+ /** Authorization system used by the alert row. */+ authType: 'market';+ /** Display avatar for the built-in capability. */+ avatar: string;+ /** Agent plugin identifier. */+ identifier: string;+ /** User-facing capability name. */+ label: string;+}++/** One unresolved authorization requirement displayed by the agent welcome card. */+export type PendingAuthTool = PendingComposioTool | PendingLobehubTool | PendingMarketTool;++/** Inputs needed to derive pending authorization rows without reading React stores. */+export interface ResolvePendingAuthToolsInput {+ /** Enabled connector systems for canonical source resolution. */+ availability: ConnectorCatalogAvailability;+ /** Whether the first Composio connection request has settled. */+ composioInitialized: boolean;+ /** Current Composio connection states. */+ composioServers: ComposioServer[];+ /** Whether the first LobeHub Market connection request has settled. */+ lobehubInitialized: boolean;+ /** Current LobeHub Market connection states. */+ lobehubServers: LobehubSkillServer[];+ /** Whether the shared Market session is authenticated. */+ marketAuthenticated: boolean;+ /** Built-in capabilities gated only by the shared Market session. */+ marketTools: PendingMarketTool[];+ /** Active agent plugin identifiers. */+ plugins: string[];+}++/**+ * Resolves agent plugin identifiers into their pending authorization rows.+ *+ * Use when:+ * - Agent configuration stores unqualified connector identifiers+ * - The welcome card must choose exactly one OAuth system for each identifier+ *+ * Expects:+ * - Connection initialization flags prevent transient false unauthorized rows+ * - Connector catalog ownership is resolved before legacy Market-only tools+ *+ * Returns:+ * - Deduplicated pending rows in agent plugin order+ */+export const resolvePendingAuthTools = ({+ availability,+ composioInitialized,+ composioServers,+ lobehubInitialized,+ lobehubServers,+ marketAuthenticated,+ marketTools,+ plugins,+}: ResolvePendingAuthToolsInput): PendingAuthTool[] => {+ const pending: PendingAuthTool[] = [];+ const seenIdentifiers = new Set<string>();++ for (const identifier of plugins) {+ if (seenIdentifiers.has(identifier)) continue;+ seenIdentifiers.add(identifier);++ const composioServer = composioServers.find((item) => item.identifier === identifier);+ const lobehubServer = lobehubServers.find((item) => item.identifier === identifier);++ const connector = resolveConnectorCatalogItem(identifier, availability);+ if (connector?.type === 'lobehub') {+ if (!lobehubInitialized) continue;+ if (lobehubServer?.status !== LobehubSkillStatus.CONNECTED) {+ pending.push({ ...connector.provider, authType: 'lobehub', server: lobehubServer });+ }+ continue;+ }++ if (connector?.type === 'composio') {+ if (!composioInitialized) continue;+ if (!composioServer || composioServer.status === ComposioServerStatus.PENDING_AUTH) {+ pending.push({ ...connector.serverType, authType: 'composio', server: composioServer });+ }+ continue;+ }++ const marketTool = marketTools.find((item) => item.identifier === identifier);+ if (marketTool && !marketAuthenticated) pending.push(marketTool);+ }++ return pending;+};diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsxindex 7e1f687f0de..0e7ae1b1fc2 100644--- a/src/features/ProfileEditor/AgentTool.tsx+++ b/src/features/ProfileEditor/AgentTool.tsx@@ -1,6 +1,6 @@'use client';-import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';+import { getConnectorCatalog } from '@lobechat/const';import { getActivePluginIds, upsertPluginMode } from '@lobechat/types';import type { ItemType } from '@lobehub/ui';import { Flexbox, Icon } from '@lobehub/ui';@@ -240,10 +240,34 @@ const AgentTool = memo<AgentToolProps>([togglePlugin],);- // Get all Composio server type identifiers (used to filter the builtin list)- const allComposioTypeIdentifiers = useMemo(- () => new Set(COMPOSIO_APP_TYPES.map((type) => type.identifier)),- [],+ const connectorCatalog = useMemo(+ () =>+ getConnectorCatalog({+ composio: isComposioEnabledInEnv,+ lobehub: isLobehubSkillEnabled,+ }),+ [isComposioEnabledInEnv, isLobehubSkillEnabled],+ );+ const connectorIdentifiers = useMemo(+ () =>+ new Set(+ connectorCatalog.map((item) =>+ item.type === 'lobehub' ? item.provider.id : item.serverType.identifier,+ ),+ ),+ [connectorCatalog],+ );+ const composioConnectorTypes = useMemo(+ () =>+ connectorCatalog+ .filter((item) => item.type === 'composio')+ .map(({ serverType }) => serverType),+ [connectorCatalog],+ );+ const lobehubConnectorProviders = useMemo(+ () =>+ connectorCatalog.filter((item) => item.type === 'lobehub').map(({ provider }) => provider),+ [connectorCatalog],);// Get all skill identifiers (used to filter the builtin list)@@ -269,10 +293,8 @@ const AgentTool = memo<AgentToolProps>() as ListType;}- // Filter out Composio tools if Composio is enabled- if (isComposioEnabledInEnv) {- list = list.filter((item) => !allComposioTypeIdentifiers.has(item.identifier));- }+ // Connector identifiers are rendered through their canonical owner below.+ list = list.filter((item) => !connectorIdentifiers.has(item.identifier));// Filter out skills (they are shown separately)list = list.filter((item) => !allSkillIdentifiers.has(item.identifier));@@ -280,8 +302,7 @@ const AgentTool = memo<AgentToolProps>(return list;}, [profileBuiltinList,- allComposioTypeIdentifiers,- isComposioEnabledInEnv,+ connectorIdentifiers,filterAvailableInWeb,useAllMetaList,allSkillIdentifiers,@@ -291,7 +312,7 @@ const AgentTool = memo<AgentToolProps>(const composioServerItems = useMemo(() =>isComposioEnabledInEnv- ? COMPOSIO_APP_TYPES.map((type) => ({+ ? composioConnectorTypes.map((type) => ({icon: (<ComposioSkillIcon icon={type.icon} label={type.label} size={SKILL_ICON_SIZE} />),@@ -320,14 +341,14 @@ const AgentTool = memo<AgentToolProps>(),})): [],- [isComposioEnabledInEnv, allComposioServers, effectiveAgentId, t],+ [isComposioEnabledInEnv, composioConnectorTypes, allComposioServers, effectiveAgentId, t],);// LobeHub Skill Provider list itemsconst lobehubSkillItems = useMemo(() =>isLobehubSkillEnabled- ? LOBEHUB_SKILL_PROVIDERS.map((provider) => ({+ ? lobehubConnectorProviders.map((provider) => ({icon: (<LobehubSkillIconicon={provider.icon}@@ -356,7 +377,7 @@ const AgentTool = memo<AgentToolProps>(),})): [],- [isLobehubSkillEnabled, effectiveAgentId, t],+ [isLobehubSkillEnabled, lobehubConnectorProviders, effectiveAgentId, t],);// Handle plugin remove via Tag close - use byId actions@@ -731,14 +752,11 @@ const AgentTool = memo<AgentToolProps>(// 2. Installed pluginsfor (const plugin of installedPluginList) all.add(plugin.identifier);- // 3. Composio server types (if enabled)- if (isComposioEnabledInEnv) {- for (const type of COMPOSIO_APP_TYPES) all.add(type.identifier);- }-- // 4. LobeHub Skill providers (if enabled)- if (isLobehubSkillEnabled) {- for (const provider of LOBEHUB_SKILL_PROVIDERS) all.add(provider.id);+ // 3. Canonical connector identifiers+ for (const connector of connectorCatalog) {+ all.add(+ connector.type === 'lobehub' ? connector.provider.id : connector.serverType.identifier,+ );}// 5. Builtin skills@@ -757,8 +775,7 @@ const AgentTool = memo<AgentToolProps>(}, [knownBuiltinList,installedPluginList,- isComposioEnabledInEnv,- isLobehubSkillEnabled,+ connectorCatalog,installedBuiltinSkills,marketAgentSkills,userAgentSkills,diff --git a/src/features/ProfileEditor/PluginTag.test.tsx b/src/features/ProfileEditor/PluginTag.test.tsxindex 6f21a9749a4..e57a9075027 100644--- a/src/features/ProfileEditor/PluginTag.test.tsx+++ b/src/features/ProfileEditor/PluginTag.test.tsx@@ -37,7 +37,7 @@ vi.mock('antd-style', async (importOriginal) => ({createStaticStyles: () => ({}),cssVar: new Proxy({}, { get: () => 'var(--x)' }),}));-vi.mock('@lobehub/const', () => ({ COMPOSIO_APP_TYPES: [], LOBEHUB_SKILL_PROVIDERS: [] }));+vi.mock('@lobechat/const', () => ({ resolveConnectorCatalogItem: () => undefined }));vi.mock('@lobehub/ui/icons', () => ({ McpIcon: () => null }));vi.mock('@/components/Plugins/PluginAvatar', () => ({ default: () => null }));vi.mock('@lobehub/ui/base-ui', async (importOriginal) => ({diff --git a/src/features/ProfileEditor/PluginTag.tsx b/src/features/ProfileEditor/PluginTag.tsxindex cdb3775bc6b..b5d34592a52 100644--- a/src/features/ProfileEditor/PluginTag.tsx+++ b/src/features/ProfileEditor/PluginTag.tsx@@ -1,7 +1,7 @@'use client';-import { type ComposioAppType, type LobehubSkillProviderType } from '@lobechat/const';-import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';+import type { ComposioAppType, LobehubSkillProviderType } from '@lobechat/const';+import { resolveConnectorCatalogItem } from '@lobechat/const';import { Flexbox, Icon, Tooltip } from '@lobehub/ui';import { Avatar, Tag } from '@lobehub/ui/base-ui';import { McpIcon } from '@lobehub/ui/icons';@@ -209,38 +209,31 @@ const PluginTag = memo<PluginTagProps>(: undefined;const agentInstalled = !!agentConn;- // Check if it's a Composio server type- if (isComposioEnabledInEnv) {- const composioType = COMPOSIO_APP_TYPES.find((type) => type.identifier === identifier);- if (composioType) {- // Check if this Composio server is connected- const connectedServer = allComposioServers.find((s) => s.identifier === identifier);- return {- availableInWeb: true,- icon: composioType.icon,- isInstalled: !!connectedServer || agentInstalled,- label: composioType.label,- title: composioType.label,- type: 'composio' as const,- };- }+ const connector = resolveConnectorCatalogItem(identifier, {+ composio: isComposioEnabledInEnv,+ lobehub: isLobehubSkillEnabled,+ });+ if (connector?.type === 'lobehub') {+ const connectedServer = allLobehubSkillServers.find((s) => s.identifier === identifier);+ return {+ availableInWeb: true,+ icon: connector.provider.icon,+ isInstalled: !!connectedServer || agentInstalled,+ label: connector.provider.label,+ title: connector.provider.label,+ type: 'lobehub-skill' as const,+ };}-- // Check if it's a LobeHub Skill provider- if (isLobehubSkillEnabled) {- const lobehubSkillProvider = LOBEHUB_SKILL_PROVIDERS.find((p) => p.id === identifier);- if (lobehubSkillProvider) {- // Check if this LobehubSkill provider is connected- const connectedServer = allLobehubSkillServers.find((s) => s.identifier === identifier);- return {- availableInWeb: true,- icon: lobehubSkillProvider.icon,- isInstalled: !!connectedServer || agentInstalled,- label: lobehubSkillProvider.label,- title: lobehubSkillProvider.label,- type: 'lobehub-skill' as const,- };- }+ if (connector?.type === 'composio') {+ const connectedServer = allComposioServers.find((s) => s.identifier === identifier);+ return {+ availableInWeb: true,+ icon: connector.serverType.icon,+ isInstalled: !!connectedServer || agentInstalled,+ label: connector.serverType.label,+ title: connector.serverType.label,+ type: 'composio' as const,+ };}// Check if it's a custom connectordiff --git a/src/features/Settings/skill/features/SkillList.tsx b/src/features/Settings/skill/features/SkillList.tsxindex 66f37984867..5d139b822b6 100644--- a/src/features/Settings/skill/features/SkillList.tsx+++ b/src/features/Settings/skill/features/SkillList.tsx@@ -1,16 +1,13 @@'use client';+import type { ComposioAppType, LobehubSkillProviderType } from '@lobechat/const';import {- COMPOSIO_APP_TYPES,- type ComposioAppType,- getComposioAppByIdentifier,- getLobehubSkillProviderById,- LOBEHUB_SKILL_PROVIDERS,- type LobehubSkillProviderType,+ getConnectorCatalog,RECOMMENDED_SKILLS,RecommendedSkillType,+ resolveConnectorCatalogItem,} from '@lobechat/const';-import { type BuiltinSkill, type LobeBuiltinTool } from '@lobechat/types';+import type { BuiltinSkill, LobeBuiltinTool } from '@lobechat/types';import { Center, Empty } from '@lobehub/ui';import { SkillsIcon } from '@lobehub/ui/icons';import { createStaticStyles } from 'antd-style';@@ -191,8 +188,11 @@ const SkillList = memo<SkillListProps>(}const addedBuiltinIds = new Set<string>();- const addedLobehubIds = new Set<string>();- const addedComposioIds = new Set<string>();+ const addedConnectorIds = new Set<string>();+ const connectorAvailability = {+ composio: isComposioEnabled,+ lobehub: isLobehubSkillEnabled,+ };// If RECOMMENDED_SKILLS is configured, use it to build the listif (RECOMMENDED_SKILLS.length > 0) {@@ -203,17 +203,11 @@ const SkillList = memo<SkillListProps>(integrationItems.push({ builtinTool, type: 'builtin' });addedBuiltinIds.add(skill.id);}- } else if (skill.type === RecommendedSkillType.Lobehub && isLobehubSkillEnabled) {- const provider = getLobehubSkillProviderById(skill.id);- if (provider) {- integrationItems.push({ provider, type: 'lobehub' });- addedLobehubIds.add(skill.id);- }- } else if (skill.type === RecommendedSkillType.Composio && isComposioEnabled) {- const serverType = getComposioAppByIdentifier(skill.id);- if (serverType) {- integrationItems.push({ serverType, type: 'composio' });- addedComposioIds.add(skill.id);+ } else {+ const connector = resolveConnectorCatalogItem(skill.id, connectorAvailability);+ if (connector && !addedConnectorIds.has(skill.id)) {+ integrationItems.push(connector);+ addedConnectorIds.add(skill.id);}}}@@ -229,28 +223,15 @@ const SkillList = memo<SkillListProps>(}}- // Also add every other Lobehub skill provider so users can discover and- // connect integrations beyond the curated RECOMMENDED_SKILLS set β- // otherwise a provider like Vercel or Linear never appears until it's- // already connected, and a disconnected one has no way to be found.- if (isLobehubSkillEnabled) {- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- if (!addedLobehubIds.has(provider.id)) {- integrationItems.push({ provider, type: 'lobehub' });- addedLobehubIds.add(provider.id);- }- }- }-- // Also add every other Composio app so users can discover and connect- // integrations beyond the curated RECOMMENDED_SKILLS set β otherwise an- // app like Jira never appears until it's already connected.- if (isComposioEnabled) {- for (const serverType of COMPOSIO_APP_TYPES) {- if (!addedComposioIds.has(serverType.identifier)) {- integrationItems.push({ serverType, type: 'composio' });- addedComposioIds.add(serverType.identifier);- }+ // Add every remaining connector through the shared ownership resolver.+ // This keeps discovery complete without rendering one identifier through+ // both LobeHub and Composio authorization systems.+ for (const connector of getConnectorCatalog(connectorAvailability)) {+ const identifier =+ connector.type === 'lobehub' ? connector.provider.id : connector.serverType.identifier;+ if (!addedConnectorIds.has(identifier)) {+ integrationItems.push(connector);+ addedConnectorIds.add(identifier);}}} else {@@ -261,19 +242,7 @@ const SkillList = memo<SkillListProps>(}}- // Add lobehub skills- if (isLobehubSkillEnabled) {- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- integrationItems.push({ provider, type: 'lobehub' });- }- }-- // Add composio skills- if (isComposioEnabled) {- for (const serverType of COMPOSIO_APP_TYPES) {- integrationItems.push({ serverType, type: 'composio' });- }- }+ integrationItems.push(...getConnectorCatalog(connectorAvailability));// Filter integrations: show all builtin and lobehub skills, but only connected composiointegrationItems = integrationItems.filter((item) => {diff --git a/src/features/SkillStore/SkillList/LobeHub/index.tsx b/src/features/SkillStore/SkillList/LobeHub/index.tsxindex 331d5886e46..f54075b7184 100644--- a/src/features/SkillStore/SkillList/LobeHub/index.tsx+++ b/src/features/SkillStore/SkillList/LobeHub/index.tsx@@ -1,7 +1,8 @@'use client';-import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';-import { type BuiltinSkill, type LobeToolMeta } from '@lobechat/types';+import type { ComposioAppType, LobehubSkillProviderType } from '@lobechat/const';+import { getConnectorCatalog } from '@lobechat/const';+import type { BuiltinSkill, LobeToolMeta } from '@lobechat/types';import isEqual from 'fast-deep-equal';import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -75,8 +76,8 @@ export const LobeHubList = memo<LobeHubListProps>(({ keywords }) => {const filteredItems = useMemo(() => {const items: Array<- | { provider: (typeof LOBEHUB_SKILL_PROVIDERS)[number]; type: 'lobehub' }- | { serverType: (typeof COMPOSIO_APP_TYPES)[number]; type: 'composio' }+ | { provider: LobehubSkillProviderType; type: 'lobehub' }+ | { serverType: ComposioAppType; type: 'composio' }| { skill: BuiltinSkill; type: 'builtinAgentSkill' }| { tool: LobeToolMeta; type: 'builtin' }> = [];@@ -91,19 +92,9 @@ export const LobeHubList = memo<LobeHubListProps>(({ keywords }) => {items.push({ tool, type: 'builtin' });}- // Add LobeHub skills- if (isLobehubSkillEnabled) {- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- items.push({ provider, type: 'lobehub' });- }- }-- // Add Composio skills- if (isComposioEnabled) {- for (const serverType of COMPOSIO_APP_TYPES) {- items.push({ serverType, type: 'composio' });- }- }+ items.push(+ ...getConnectorCatalog({ composio: isComposioEnabled, lobehub: isLobehubSkillEnabled }),+ );// Filter by keywordsconst lowerKeywords = keywords.toLowerCase().trim();diff --git a/src/routes/(main)/group/features/Conversation/AgentWelcome/ToolAuthAlert.tsx b/src/routes/(main)/group/features/Conversation/AgentWelcome/ToolAuthAlert.tsxdeleted file mode 100644index 89be94e83c3..00000000000--- a/src/routes/(main)/group/features/Conversation/AgentWelcome/ToolAuthAlert.tsx+++ /dev/null@@ -1,2 +0,0 @@-// Re-export from chat version to avoid code duplication-export { default } from '@/routes/(main)/agent/features/Conversation/AgentWelcome/ToolAuthAlert';diff --git a/src/routes/(main)/group/features/Conversation/AgentWelcome/index.tsx b/src/routes/(main)/group/features/Conversation/AgentWelcome/index.tsxindex 402c47e0499..bfd7fb1c8e1 100644--- a/src/routes/(main)/group/features/Conversation/AgentWelcome/index.tsx+++ b/src/routes/(main)/group/features/Conversation/AgentWelcome/index.tsx@@ -7,6 +7,7 @@ import React, { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { useConversationStore } from '@/features/Conversation';+import ToolAuthAlert from '@/features/Conversation/AgentWelcome/ToolAuthAlert';import { contextSelectors } from '@/features/Conversation/store';import { useIsMobile } from '@/hooks/useIsMobile';import SupervisorAvatar from '@/routes/(main)/group/features/GroupAvatar';@@ -17,7 +18,6 @@ import { useUserStore } from '@/store/user';import { userGeneralSettingsSelectors } from '@/store/user/selectors';import OpeningQuestions from './OpeningQuestions';-import ToolAuthAlert from './ToolAuthAlert';const InboxWelcome = memo(() => {const { t } = useTranslation(['welcome', 'chat']);diff --git a/src/services/chat/index.ts b/src/services/chat/index.tsindex 19ba6a65c82..8e11377c6a2 100644--- a/src/services/chat/index.ts+++ b/src/services/chat/index.ts@@ -1,7 +1,6 @@import { AgentBuilderIdentifier } from '@lobechat/builtin-tool-agent-builder';import {- COMPOSIO_APP_TYPES,- LOBEHUB_SKILL_PROVIDERS,+ getConnectorCatalog,REQUEST_AGENT_ID_HEADER,REQUEST_TOPIC_ID_HEADER,REQUEST_TRIGGER_HEADER,@@ -221,13 +220,29 @@ class ChatService {const officialTools: OfficialToolItem[] = [];- // Get builtin tools (excluding Composio tools)+ const isComposioEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio,+ );+ const isLobehubSkillEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill,+ );+ const connectorCatalog = getConnectorCatalog({+ composio: isComposioEnabled,+ lobehub: isLobehubSkillEnabled,+ });+ const connectorIdentifiers = new Set(+ connectorCatalog.map((item) =>+ item.type === 'lobehub' ? item.provider.id : item.serverType.identifier,+ ),+ );++ // Get builtin tools (excluding connectors rendered through their canonical owner)const builtinTools = builtinToolSelectors.metaList(toolState);- const composioIdentifiers = new Set(COMPOSIO_APP_TYPES.map((t) => t.identifier));for (const tool of builtinTools) {- // Skip Composio tools in builtin list (they'll be shown separately)- if (composioIdentifiers.has(tool.identifier)) continue;+ if (connectorIdentifiers.has(tool.identifier)) continue;officialTools.push({description: tool.meta?.description,@@ -239,48 +254,35 @@ class ChatService {});}- // Get Composio tools (if enabled)- const isComposioEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio;-- if (isComposioEnabled) {- const allComposioServers = composioStoreSelectors.getServers(toolState);-- for (const composioType of COMPOSIO_APP_TYPES) {- const server = allComposioServers.find((s) => s.identifier === composioType.identifier);-+ const allComposioServers = composioStoreSelectors.getServers(toolState);+ const allLobehubSkillServers = lobehubSkillStoreSelectors.getServers(toolState);+ for (const connector of connectorCatalog) {+ if (connector.type === 'composio') {+ const { serverType } = connector;+ const server = allComposioServers.find(+ (item) => item.identifier === serverType.identifier,+ );officialTools.push({- description: `LobeHub Mcp Server: ${composioType.label}`,- enabled: enabledPlugins.includes(composioType.identifier),- identifier: composioType.identifier,+ description: `LobeHub Mcp Server: ${serverType.label}`,+ enabled: enabledPlugins.includes(serverType.identifier),+ identifier: serverType.identifier,installed: !!server,- name: composioType.label,+ name: serverType.label,type: 'composio',});+ continue;}- }-- // Get LobehubSkill providers (if enabled)- const isLobehubSkillEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill;- if (isLobehubSkillEnabled) {- const allLobehubSkillServers = lobehubSkillStoreSelectors.getServers(toolState);-- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- const server = allLobehubSkillServers.find((s) => s.identifier === provider.id);-- officialTools.push({- description: `LobeHub Skill Provider: ${provider.label}`,- enabled: enabledPlugins.includes(provider.id),- identifier: provider.id,- installed: !!server,- name: provider.label,- type: 'lobehub-skill',- });- }+ const { provider } = connector;+ const server = allLobehubSkillServers.find((item) => item.identifier === provider.id);+ officialTools.push({+ description: `LobeHub Skill Provider: ${provider.label}`,+ enabled: enabledPlugins.includes(provider.id),+ identifier: provider.id,+ installed: !!server,+ name: provider.label,+ type: 'lobehub-skill',+ });}agentBuilderContext = {diff --git a/src/services/chat/mecha/contextEngineering.ts b/src/services/chat/mecha/contextEngineering.tsindex f263aa441bd..bb55237b526 100644--- a/src/services/chat/mecha/contextEngineering.ts+++ b/src/services/chat/mecha/contextEngineering.ts@@ -18,8 +18,8 @@ import { WebOnboardingIdentifier } from '@lobechat/builtin-tool-web-onboarding';import {AGENT_PLAN_FILE_TYPE,COMPOSIO_APP_TYPES,+ getConnectorCatalog,isDesktop,- LOBEHUB_SKILL_PROVIDERS,} from '@lobechat/const';import type {AgentBuilderContext,@@ -258,13 +258,29 @@ export const contextEngineering = async ({const toolState = getToolStoreState();const officialTools: GroupOfficialToolItem[] = [];- // Get builtin tools (excluding Composio tools)+ const isComposioEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio,+ );+ const isLobehubSkillEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill,+ );+ const connectorCatalog = getConnectorCatalog({+ composio: isComposioEnabled,+ lobehub: isLobehubSkillEnabled,+ });+ const connectorIdentifiers = new Set(+ connectorCatalog.map((item) =>+ item.type === 'lobehub' ? item.provider.id : item.serverType.identifier,+ ),+ );++ // Get builtin tools (excluding connectors rendered through their canonical owner)const builtinTools = builtinToolSelectors.metaList(toolState);- const composioIdentifiers = new Set(COMPOSIO_APP_TYPES.map((t) => t.identifier));for (const tool of builtinTools) {- // Skip Composio tools in builtin list (they'll be shown separately)- if (composioIdentifiers.has(tool.identifier)) continue;+ if (connectorIdentifiers.has(tool.identifier)) continue;officialTools.push({description: tool.meta?.description,@@ -276,48 +292,35 @@ export const contextEngineering = async ({});}- // Get Composio tools (if enabled)- const isComposioEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio;-- if (isComposioEnabled) {- const allComposioServers = composioStoreSelectors.getServers(toolState);-- for (const composioType of COMPOSIO_APP_TYPES) {- const server = allComposioServers.find((s) => s.identifier === composioType.identifier);-+ const allComposioServers = composioStoreSelectors.getServers(toolState);+ const allLobehubSkillServers = lobehubSkillStoreSelectors.getServers(toolState);+ for (const connector of connectorCatalog) {+ if (connector.type === 'composio') {+ const { serverType } = connector;+ const server = allComposioServers.find(+ (item) => item.identifier === serverType.identifier,+ );officialTools.push({- description: `LobeHub Mcp Server: ${composioType.label}`,- enabled: enabledPlugins.includes(composioType.identifier),- identifier: composioType.identifier,+ description: `LobeHub Mcp Server: ${serverType.label}`,+ enabled: enabledPlugins.includes(serverType.identifier),+ identifier: serverType.identifier,installed: !!server,- name: composioType.label,+ name: serverType.label,type: 'composio',});+ continue;}- }- // Get LobehubSkill providers (if enabled)- const isLobehubSkillEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill;-- if (isLobehubSkillEnabled) {- const allLobehubSkillServers = lobehubSkillStoreSelectors.getServers(toolState);-- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- const server = allLobehubSkillServers.find((s) => s.identifier === provider.id);-- officialTools.push({- description: `LobeHub Skill Provider: ${provider.label}`,- enabled: enabledPlugins.includes(provider.id),- identifier: provider.id,- installed: !!server,- name: provider.label,- type: 'lobehub-skill',- });- }+ const { provider } = connector;+ const server = allLobehubSkillServers.find((item) => item.identifier === provider.id);+ officialTools.push({+ description: `LobeHub Skill Provider: ${provider.label}`,+ enabled: enabledPlugins.includes(provider.id),+ identifier: provider.id,+ installed: !!server,+ name: provider.label,+ type: 'lobehub-skill',+ });}groupAgentBuilderContext = {@@ -570,7 +573,23 @@ export const contextEngineering = async ({// Builtin tools (use allMetaList to include hidden tools like web-browsing, cloud-sandbox, etc.)// Exclude only truly internal tools (agent-management itself, agent-builder, page-agent)const allBuiltinTools = builtinToolSelectors.allMetaList(toolState);- const composioIdentifiers = new Set(COMPOSIO_APP_TYPES.map((t) => t.identifier));+ const isComposioEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio,+ );+ const isLobehubSkillEnabled = Boolean(+ typeof window !== 'undefined' &&+ window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill,+ );+ const connectorCatalog = getConnectorCatalog({+ composio: isComposioEnabled,+ lobehub: isLobehubSkillEnabled,+ });+ const connectorIdentifiers = new Set(+ connectorCatalog.map((item) =>+ item.type === 'lobehub' ? item.provider.id : item.serverType.identifier,+ ),+ );const INTERNAL_TOOLS = new Set(['lobe-agent-management', // Don't show agent-management in its own context'lobe-agent-builder', // Used for editing current agent, not for creating new agents@@ -579,8 +598,7 @@ export const contextEngineering = async ({]);for (const tool of allBuiltinTools) {- // Skip Composio tools in builtin list (they'll be shown separately)- if (composioIdentifiers.has(tool.identifier)) continue;+ if (connectorIdentifiers.has(tool.identifier)) continue;// Skip internal toolsif (INTERNAL_TOOLS.has(tool.identifier)) continue;@@ -592,36 +610,25 @@ export const contextEngineering = async ({});}- // Composio tools (if enabled)- const isComposioEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableComposio;-- if (isComposioEnabled) {- for (const composioType of COMPOSIO_APP_TYPES) {+ for (const connector of connectorCatalog) {+ if (connector.type === 'composio') {+ const { serverType } = connector;availablePlugins.push({- description: composioType.description,- identifier: composioType.identifier,- name: composioType.label,+ description: serverType.description,+ identifier: serverType.identifier,+ name: serverType.label,type: 'composio' as const,});+ continue;}- }-- // LobehubSkill providers (if enabled)- const isLobehubSkillEnabled =- typeof window !== 'undefined' &&- window.global_serverConfigStore?.getState()?.serverConfig?.enableLobehubSkill;- if (isLobehubSkillEnabled) {- for (const provider of LOBEHUB_SKILL_PROVIDERS) {- availablePlugins.push({- description: provider.description,- identifier: provider.id,- name: provider.label,- type: 'lobehub-skill' as const,- });- }+ const { provider } = connector;+ availablePlugins.push({+ description: provider.description,+ identifier: provider.id,+ name: provider.label,+ type: 'lobehub-skill' as const,+ });}agentManagementContext = {diff --git a/src/store/tool/selectors/tool.ts b/src/store/tool/selectors/tool.tsindex 0fd5b41381f..dbcd4c13710 100644--- a/src/store/tool/selectors/tool.ts+++ b/src/store/tool/selectors/tool.ts@@ -167,6 +167,16 @@ const availableToolsForDiscovery = (s: ToolStoreState): AvailableToolForDiscover// 3. Composio MCP servers (connected only)const composioItems = (s.composioServers || []).filter((server) => server.status === ComposioServerStatus.ACTIVE && server.tools?.length)+ // A connector identifier can have legacy Composio and current LobeHub+ // connections at the same time. Tool discovery is identifier-based, so the+ // canonical LobeHub connection must own the single visible entry.+ .filter(+ (server) =>+ !s.lobehubSkillServers?.some(+ (item) =>+ item.identifier === server.identifier && item.status === LobehubSkillStatus.CONNECTED,+ ),+ ).map((server) => {const config = getComposioAppByIdentifier(server.identifier);return {