🤯 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
✨ feat(agent-share): let visitors activate granted MCP servers and plugins (#21293)
YuTengjing5f87b08cb965
diff --git a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.discoverableConnectors.test.ts b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.discoverableConnectors.test.tsindex 8797de35b4f..53e73d4ba58 100644--- a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.discoverableConnectors.test.ts+++ b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.discoverableConnectors.test.ts@@ -28,6 +28,12 @@ vi.mock('@/server/services/connector/refresh', () => ({vi.mock('@/server/services/deviceGateway', () => ({deviceGateway: { isConfigured: false, queryDeviceList: vi.fn().mockResolvedValue([]) },}));+// Pin the gatekeeper so the share assertions do not depend on the developer's+// encryption key: without it discovery falls back to resolving undecrypted.+const gateKeeper = vi.hoisted(() => ({ decrypt: () => {} }));+vi.mock('@/server/modules/KeyVaultsEncrypt', () => ({+ KeyVaultsGateKeeper: { initWithEnvKey: vi.fn().mockResolvedValue(gateKeeper) },+}));const YINGMI = 'yingmi';@@ -61,19 +67,22 @@ interface RunOptions {shareGate?: unknown;}+const connectorModel = {+ resolveAll: vi.fn(),+ resolveByIdentifiers: vi.fn(),+};+const run = (options: RunOptions = {}) => {- const candidates = new Set([...(options.plugins ?? []), ...(options.selectedToolIds ?? [])]);+ connectorModel.resolveAll.mockReset().mockResolvedValue([customConnector]);+ connectorModel.resolveByIdentifiers+ .mockReset()+ .mockImplementation(async (ids: string[]) => (ids.includes(YINGMI) ? [customConnector] : []));return discoverTools({agentDocumentsService: { hasDocuments: vi.fn().mockResolvedValue(false) },composioService: { getComposioManifests: vi.fn().mockResolvedValue([]) },- connectorModel: {- resolveAll: vi.fn().mockResolvedValue([customConnector]),- resolveByIdentifiers: vi.fn(async (ids: string[]) =>- ids.includes(YINGMI) && candidates.has(YINGMI) ? [customConnector] : [],- ),- },+ connectorModel,connectorToolModel: {queryAllByConnectorIds: vi.fn().mockResolvedValue(connectorTools),queryByConnector: vi.fn().mockResolvedValue([]),@@ -190,16 +199,46 @@ describe('discoverTools — unpinned custom MCP connectors', () => {expect(connectors.map((c) => c.identifier)).toContain(YINGMI);});- it('does not decrypt unpinned connectors for a share visitor run', async () => {- const result = await run({- shareGate: {- agentId: 'agent-1',- shareConfig: { toolGrants: [] },- shareId: 'share-1',- visitorUserId: 'visitor-1',- },+ describe('share visitor run', () => {+ const shareGateFor = (toolGrants: { apis?: string[]; identifier: string }[]) => ({+ agentId: 'agent-1',+ shareConfig: { toolGrants },+ shareId: 'share-1',+ visitorUserId: 'visitor-1',});- expect(result.toolManifestMap[YINGMI]).toBeUndefined();+ it('does not resolve or decrypt an ungranted unpinned connector', async () => {+ vi.mocked(scheduleStaleConnectorToolsRefresh).mockClear();++ const result = await run({+ shareGate: shareGateFor([{ identifier: 'lobe-calculator' }, { identifier: 'other-mcp' }]),+ });++ expect(result.toolManifestMap[YINGMI]).toBeUndefined();+ expect(connectorModel.resolveAll).not.toHaveBeenCalled();+ for (const [ids] of connectorModel.resolveByIdentifiers.mock.calls) {+ expect(ids).not.toContain(YINGMI);+ }+ const [connectors] = vi.mocked(scheduleStaleConnectorToolsRefresh).mock.calls[0];+ expect(connectors.map((c) => c.identifier)).not.toContain(YINGMI);+ });++ it('makes a granted unpinned connector activatable without enabling it', async () => {+ const result = await run({ shareGate: shareGateFor([{ identifier: YINGMI }]) });++ // Resolved by identifier only — never the creator's whole connector list.+ expect(connectorModel.resolveAll).not.toHaveBeenCalled();+ expect(connectorModel.resolveByIdentifiers).toHaveBeenCalledWith(+ [YINGMI],+ 'agent-1',+ gateKeeper,+ );+ expect(result.toolManifestMap[YINGMI]).toBeDefined();+ expect(result.toolSourceMap[YINGMI]).toBe('mcp');+ expect(result.toolsResult.enabledToolIds).not.toContain(YINGMI);+ expect(availableToolIds(result.toolManifestMap, result.toolsResult.enabledToolIds)).toContain(+ YINGMI,+ );+ });});});diff --git a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.tsindex 3880054686a..fc5ba03e83d 100644--- a/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts+++ b/apps/server/src/services/aiAgent/pipeline/__tests__/toolDiscovery.shareGate.test.ts@@ -16,6 +16,8 @@ const {mockCreateServerAgentToolsEngine,mockFindByIds,mockGetAgentConfig,+ mockGetComposioManifests,+ mockGetLobehubSkillManifests,mockGetUserSettings,mockMessageCreate,mockPluginQuery,@@ -29,6 +31,8 @@ const {}),mockFindByIds: vi.fn(),mockGetAgentConfig: vi.fn(),+ mockGetComposioManifests: vi.fn().mockResolvedValue([]),+ mockGetLobehubSkillManifests: vi.fn().mockResolvedValue([]),mockGetUserSettings: vi.fn(),mockMessageCreate: vi.fn(),// Installed MCP plugin rows; empty unless a test seeds one.@@ -150,7 +154,7 @@ vi.mock('@/server/services/agentRuntime', () => ({vi.mock('@/server/services/market', () => ({MarketService: vi.fn().mockImplementation(function () {return {- getLobehubSkillManifests: vi.fn().mockResolvedValue([]),+ getLobehubSkillManifests: mockGetLobehubSkillManifests,};}),}));@@ -158,7 +162,7 @@ vi.mock('@/server/services/market', () => ({vi.mock('@/server/services/composio', () => ({ComposioService: vi.fn().mockImplementation(function () {return {- getComposioManifests: vi.fn().mockResolvedValue([]),+ getComposioManifests: mockGetComposioManifests,};}),}));@@ -416,4 +420,71 @@ describe('discoverTools - share gate blocks ungranted connectors early', () => {expect(mockCreateOperation.mock.calls[0][0].toolSet.manifestMap['installed-mcp']).toBeDefined();});+ describe('unpinned connection sources', () => {+ const visitorTurn = (toolGrants: { identifier: string }[]) =>+ service.execAgent({+ agentId: 'agent-1',+ prompt: 'Hello',+ shareGate: {+ agentId: 'agent-1',+ shareConfig: { toolGrants },+ shareId: 'share-1',+ visitorUserId: 'visitor-1',+ },+ });+ const manifestOf = (identifier: string) => ({+ api: [{ description: 'Run', name: 'run', parameters: {} }],+ identifier,+ meta: { title: identifier },+ type: 'builtin',+ });++ it('lists LobeHub Skill tools only for granted providers', async () => {+ await visitorTurn([{ identifier: 'lobe-calculator' }, { identifier: 'linear' }]);++ expect(mockGetLobehubSkillManifests).toHaveBeenCalledWith(+ expect.objectContaining({ providerIds: ['linear'] }),+ );+ });++ it('does not ask the Market about the creator connections without an extension grant', async () => {+ await visitorTurn([{ identifier: 'lobe-calculator' }]);++ expect(mockGetLobehubSkillManifests).not.toHaveBeenCalled();+ expect(mockGetComposioManifests).not.toHaveBeenCalled();+ });++ it('reads only granted Composio connections into the activatable pool', async () => {+ mockGetComposioManifests.mockResolvedValue([manifestOf('gmail')]);++ await visitorTurn([{ identifier: 'gmail' }, { identifier: 'lobe-calculator' }]);++ expect(mockGetComposioManifests).toHaveBeenCalledWith(expect.anything(), {+ identifiers: ['gmail'],+ });+ const { manifestMap, sourceMap } = mockCreateOperation.mock.calls[0][0].toolSet;+ expect(manifestMap.gmail).toBeDefined();+ expect(sourceMap.gmail).toBe('composio');+ });++ it('does not read a granted connection the owner disabled on the Agent', async () => {+ mockGetAgentConfig.mockResolvedValue({+ chatConfig: {},+ id: 'agent-1',+ model: 'gpt-4',+ plugins: [{ identifier: 'gmail', mode: 'disabled' }],+ provider: 'openai',+ systemRole: '',+ });++ await visitorTurn([{ identifier: 'gmail' }, { identifier: 'linear' }]);++ expect(mockGetComposioManifests).toHaveBeenCalledWith(expect.anything(), {+ identifiers: ['linear'],+ });+ expect(mockGetLobehubSkillManifests).toHaveBeenCalledWith(+ expect.objectContaining({ providerIds: ['linear'] }),+ );+ });+ });});diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.tsindex f4c03597b9a..238b7cd9256 100644--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/index.ts@@ -37,7 +37,11 @@ import { resolveUnsupportedMessageApis } from '@/server/services/bot/platforms/mimport { deviceGateway } from '@/server/services/deviceGateway';import { buildAllowedBuiltinTools } from '../../deviceToolRegistry';-import { filterPluginsByShareGate, getShareGrantActivatedPluginIds } from '../../shareGate';+import {+ filterPluginsByShareGate,+ getShareGrantActivatedPluginIds,+ getShareGrantedExtensionIds,+} from '../../shareGate';import type { ExecRunContext } from '../../types';import {buildOwnershipNote,@@ -179,6 +183,17 @@ export const discoverTools = async (if (shareGate) {agentPlugins = filterPluginsByShareGate(agentPlugins, shareGate);}+ // The unpinned sources the activator may discover (connectors, Composio,+ // LobeHub Skills, installed plugins) need the same early cut for a share+ // run: only granted identifiers are read. A grant the owner later disabled+ // on the Agent is dropped here too, not only after discovery.+ const shareGrantedExtensionIds = shareGate+ ? new Set(+ [...getShareGrantedExtensionIds(shareGate)].filter(+ (identifier) => !disabledPluginIds.includes(identifier),+ ),+ )+ : undefined;// Model metadata is needed both for tool support checks and agent-management context.const builtinModels = await loadModels();@@ -198,6 +213,7 @@ export const discoverTools = async (requestedDeviceId,resolvedAgentId,shareGate,+ shareGrantedExtensionIds,topicId: ctx.topicId,});@@ -218,9 +234,13 @@ export const discoverTools = async (// `rules` allowlist — because `createEnableChecker`'s explicit-activation// bypass (auto activator) short-circuits before rules are consulted, so a// present-but-rule-disabled manifest could still be auto-activated.+ // A share run keeps only granted plugins, so an ungranted one never reaches+ // the connector permission lookup or the activator pool below.const disabledPluginIdSet = new Set(disabledPluginIds);const installedPlugins = (await toolReads.installedPlugins).filter(- (p) => !disabledPluginIdSet.has(p.identifier),+ (p) =>+ !disabledPluginIdSet.has(p.identifier) &&+ (!shareGrantedExtensionIds || shareGrantedExtensionIds.has(p.identifier)),);log('execAgent: got %d installed plugins (%d disabled excluded)',diff --git a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/reads.ts b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/reads.tsindex aba3f87c86c..165f7d09659 100644--- a/apps/server/src/services/aiAgent/pipeline/toolDiscovery/reads.ts+++ b/apps/server/src/services/aiAgent/pipeline/toolDiscovery/reads.ts@@ -48,6 +48,12 @@ export interface ToolReadsContext {requestedDeviceId?: string;resolvedAgentId: string;shareGate: ExecRunContext['shareGate'];+ /**+ * The extension identifiers a share run may discover (connectors, Composio,+ * LobeHub Skills); only these are resolved, so an ungranted one never has+ * its credentials decrypted or its provider called. `undefined` = no gate.+ */+ shareGrantedExtensionIds?: Set<string>;topicId: string;}@@ -147,10 +153,9 @@ const readConnectors = async (deps: ToolDiscoveryDeps, ctx: ToolReadsContext) =>* "Not found" and the model's direct call is rejected as an unknown name.* Like installed plugins they are discoverable but never enabled.*- * Share runs skip it: the early allowlist in `discoverTools` exists so- * ungranted creator connectors never get their credentials decrypted for a- * visitor turn. Degrades to nothing on failure — widening discovery must not- * fail the run.+ * A share run resolves only the connectors the share grants, by identifier:+ * `resolveAll` would decrypt every creator connector for a visitor turn.+ * Degrades to nothing on failure — widening discovery must not fail the run.*/const readDiscoverableConnectors = async (deps: ToolDiscoveryDeps,@@ -162,12 +167,24 @@ const readDiscoverableConnectors = async (tools: UserConnectorToolItem[];}> => {const none = { connectorsMcp: [], manifests: [], tools: [] };- if (ctx.shareGate || ctx.exclusivePluginIds || ctx.isGoalTurn) return none;+ if (ctx.exclusivePluginIds || ctx.isGoalTurn) return none;try {const candidates = new Set(ctx.candidateIds);- const connectorsMcp = (- await deps.connectorModel.resolveAll(ctx.resolvedAgentId, gateKeeper)- ).filter(+ let resolved: DecryptedConnector[];+ if (ctx.shareGrantedExtensionIds) {+ const grantedUnpinnedIds = [...ctx.shareGrantedExtensionIds].filter(+ (identifier) => !candidates.has(identifier),+ );+ if (grantedUnpinnedIds.length === 0) return none;+ resolved = await deps.connectorModel.resolveByIdentifiers(+ grantedUnpinnedIds,+ ctx.resolvedAgentId,+ gateKeeper,+ );+ } else {+ resolved = await deps.connectorModel.resolveAll(ctx.resolvedAgentId, gateKeeper);+ }+ const connectorsMcp = resolved.filter((c) => !candidates.has(c.identifier) && (c.mcpServerUrl || c.mcpConnectionType === 'stdio'),);if (connectorsMcp.length === 0) return none;@@ -186,7 +203,14 @@ const readDiscoverableConnectors = async (}};-const readLobehubSkillManifests = async (deps: ToolDiscoveryDeps): Promise<LobeToolManifest[]> => {+const readLobehubSkillManifests = async (+ deps: ToolDiscoveryDeps,+ ctx: ToolReadsContext,+): Promise<LobeToolManifest[]> => {+ // A share run lists tools only for granted providers; with none granted+ // the Market is not asked about the creator's connections at all.+ const providerIds = ctx.shareGrantedExtensionIds ? [...ctx.shareGrantedExtensionIds] : undefined;+ if (providerIds?.length === 0) return [];try {const marketService = await deps.getMarketService();return await traceDiscoveryStage('lobehub_skills', async (span) => {@@ -198,6 +222,7 @@ const readLobehubSkillManifests = async (deps: ToolDiscoveryDeps): Promise<LobeTonError: () => {failureCount += 1;},+ providerIds,});span.setAttribute('lobehub.tool_discovery.manifest_count', manifests.length);markDegradedStage(span, failureCount, 'skill discovery requests');@@ -346,9 +371,17 @@ export const startToolReads = (deps: ToolDiscoveryDeps, ctx: ToolReadsContext) =),attachedFileTypes: started(readAttachedFileTypes(deps, ctx)),oversizedFiles: started(readHasOversizedFiles(deps, ctx).catch(() => false)), // non-critical+ // A share run reads only the granted Composio connections, and skips the+ // read when nothing is granted.composioManifests: started(- traceDiscoveryStage('composio', () =>- deps.composioService.getComposioManifests(ctx.resolvedAgentId),+ (ctx.shareGrantedExtensionIds?.size === 0+ ? Promise.resolve<LobeToolManifest[]>([])+ : traceDiscoveryStage('composio', () =>+ deps.composioService.getComposioManifests(+ ctx.resolvedAgentId,+ ctx.shareGrantedExtensionIds && { identifiers: [...ctx.shareGrantedExtensionIds] },+ ),+ )).catch((error) => {log('execAgent: failed to fetch composio manifests: %O', error);return [] as LobeToolManifest[];@@ -359,7 +392,7 @@ export const startToolReads = (deps: ToolDiscoveryDeps, ctx: ToolReadsContext) =installedPlugins: started(traceDiscoveryStage('installed_plugins', () => deps.pluginModel.query()),),- lobehubSkillManifests: started(readLobehubSkillManifests(deps)),+ lobehubSkillManifests: started(readLobehubSkillManifests(deps, ctx)),});export type ToolReads = ReturnType<typeof startToolReads>;diff --git a/apps/server/src/services/aiAgent/shareGate/grants.ts b/apps/server/src/services/aiAgent/shareGate/grants.tsindex f75eec9f88c..a8c97b18de2 100644--- a/apps/server/src/services/aiAgent/shareGate/grants.ts+++ b/apps/server/src/services/aiAgent/shareGate/grants.ts@@ -9,6 +9,7 @@ import {type ShareToolGrant,} from '@lobechat/const';+import { isGovernedByBuiltinAllowlist } from './allowlist';import type { AgentShareGate, ShareDataToolPermissions } from './types';/**@@ -57,6 +58,22 @@ export const getShareGrantActivatedPluginIds = (gate: AgentShareGate): string[]return hasShareToolGrant(grants, AgentDocumentsIdentifier) ? [AgentDocumentsIdentifier] : [];};+/**+ * The non-builtin identifiers (MCP servers, Composio and LobeHub Skills+ * connections, installed plugins) a share grants, at any API scope.+ *+ * Tool discovery reads these sources for the creator's whole account, and+ * reading one can decrypt its credentials or call its provider. A share run+ * must only touch what the creator granted, so discovery narrows each source+ * to this set before reading it — not just at the final tool-set gate.+ */+export const getShareGrantedExtensionIds = (gate: AgentShareGate): Set<string> =>+ new Set(+ [...resolveShareToolGrants(gate.shareConfig.toolGrants).keys()].filter(+ (identifier) => !isGovernedByBuiltinAllowlist(identifier),+ ),+ );+/*** Whether the share grants `lobe-cloud-sandbox` (at any API scope). Drives* `resolveExecutionPlan`'s `sandboxFallback`: a visitor can never reach thediff --git a/apps/server/src/services/aiAgent/shareGate/index.ts b/apps/server/src/services/aiAgent/shareGate/index.tsindex 165827da2d4..e5e2f1bb0f6 100644--- a/apps/server/src/services/aiAgent/shareGate/index.ts+++ b/apps/server/src/services/aiAgent/shareGate/index.ts@@ -4,6 +4,7 @@ export {filterPluginsByShareGate,filterSkillsByShareGate,getShareGrantActivatedPluginIds,+ getShareGrantedExtensionIds,shareGateGrantsCloudSandbox,} from './grants';export { applyShareGateToToolSet } from './toolSet';diff --git a/apps/server/src/services/composio/index.test.ts b/apps/server/src/services/composio/index.test.tsindex 2a246df1d5d..0c01cb15b7d 100644--- a/apps/server/src/services/composio/index.test.ts+++ b/apps/server/src/services/composio/index.test.ts@@ -106,6 +106,39 @@ describe('ComposioService.getComposioManifests', () => {expect(mocks.pluginQuery).toHaveBeenCalledTimes(1); // called, but yields nothing new});+ it('reads only the requested identifiers', async () => {+ mocks.connectorQueryByIdentifiers.mockResolvedValue([activeConnectorRow()]);+ mocks.connectorToolQueryAll.mockResolvedValue([+ { description: 'Send', toolName: 'GMAIL_SEND_EMAIL', userConnectorId: 'conn-gmail' },+ ]);+ mocks.pluginQuery.mockResolvedValue([+ {+ customParams: { composio: { status: 'ACTIVE' } },+ identifier: 'slack',+ manifest: { api: [{ name: 'SLACK_POST' }] },+ },+ ]);++ const manifests = await service().getComposioManifests('agent-1', {+ identifiers: ['gmail', 'not-composio'],+ });++ expect(mocks.connectorQuery).not.toHaveBeenCalled();+ expect(mocks.connectorQueryByIdentifiers).toHaveBeenCalledWith(['gmail'], 'agent-1');+ expect(manifests.map((m) => m.identifier)).toEqual(['gmail']);+ });++ it('reads nothing when no requested identifier is a Composio app', async () => {+ const manifests = await service().getComposioManifests('agent-1', {+ identifiers: ['deepwiki'],+ });++ expect(manifests).toEqual([]);+ expect(mocks.connectorQuery).not.toHaveBeenCalled();+ expect(mocks.connectorQueryByIdentifiers).not.toHaveBeenCalled();+ expect(mocks.pluginQuery).not.toHaveBeenCalled();+ });+it('falls back to plugin table for identifiers without a connector projection', async () => {mocks.connectorQuery.mockResolvedValue([]);mocks.pluginQuery.mockResolvedValue([diff --git a/apps/server/src/services/composio/index.ts b/apps/server/src/services/composio/index.tsindex e58650da064..275e7a1886f 100644--- a/apps/server/src/services/composio/index.ts+++ b/apps/server/src/services/composio/index.ts@@ -255,9 +255,19 @@ export class ComposioService {return undefined;}- async getComposioManifests(agentId?: string): Promise<LobeToolManifest[]> {+ /**+ * @param options.identifiers Read only these identifiers instead of every+ * connection, so a share run never resolves a connection the owner did not+ * grant.+ */+ async getComposioManifests(+ agentId?: string,+ options?: { identifiers?: string[] },+ ): Promise<LobeToolManifest[]> {const manifests: LobeToolManifest[] = [];const coveredIdentifiers = new Set<string>();+ const identifiers = options?.identifiers?.filter((id) => VALID_COMPOSIO_IDENTIFIERS.has(id));+ if (identifiers?.length === 0) return manifests;// 1. Connector-based (new path): rows whose metadata.composio marks them as// Composio connectors and are ACTIVE. Tool defs come from@@ -266,7 +276,9 @@ export class ComposioService {// Composio connector shadows the base one for the same identifier.if (this.connectorModel && this.connectorToolModel) {try {- const connectors = await this.connectorModel.resolveAll(agentId);+ const connectors = identifiers+ ? await this.connectorModel.resolveByIdentifiers(identifiers, agentId)+ : await this.connectorModel.resolveAll(agentId);const composioConnectors = connectors.filter((c) =>VALID_COMPOSIO_IDENTIFIERS.has(c.identifier) &&@@ -331,7 +343,8 @@ export class ComposioService {(plugin) =>VALID_COMPOSIO_IDENTIFIERS.has(plugin.identifier) &&plugin.customParams?.composio?.status === 'ACTIVE' &&- !coveredIdentifiers.has(plugin.identifier),+ !coveredIdentifiers.has(plugin.identifier) &&+ (!identifiers || identifiers.includes(plugin.identifier)),);for (const plugin of composioPlugins) {diff --git a/apps/server/src/services/market/index.test.ts b/apps/server/src/services/market/index.test.tsindex 7cf85e5e19c..1c620356bb2 100644--- a/apps/server/src/services/market/index.test.ts+++ b/apps/server/src/services/market/index.test.ts@@ -676,6 +676,26 @@ describe('MarketService', () => {expect(manifests[0].identifier).toBe('linear');});+ it('lists tools only for the requested providers', async () => {+ const service = new MarketService();+ (service as any).market.connect.listConnections = vi.fn().mockResolvedValue({+ connections: [+ { icon: '🐦', providerId: 'twitter', providerName: 'Twitter' },+ { icon: '📋', providerId: 'linear', providerName: 'Linear' },+ ],+ });+ const listTools = vi.fn().mockResolvedValue({+ tools: [{ description: 'Create', inputSchema: {}, name: 'create' }],+ });+ (service as any).market.skills.listTools = listTools;++ const manifests = await service.getLobehubSkillManifests({ providerIds: ['linear'] });++ expect(manifests.map((m) => m.identifier)).toEqual(['linear']);+ expect(listTools).toHaveBeenCalledTimes(1);+ expect(listTools.mock.calls[0][0]).toBe('linear');+ });+it('should use the static Notion provider label for manifests', async () => {const service = new MarketService();(service as any).market.connect.listConnections = vi.fn().mockResolvedValue({diff --git a/apps/server/src/services/market/index.ts b/apps/server/src/services/market/index.tsindex 3cebf083e01..61655aaf8ee 100644--- a/apps/server/src/services/market/index.ts+++ b/apps/server/src/services/market/index.ts@@ -826,16 +826,23 @@ export class MarketService {* provider whose tools could not be listed (with its `providerId`), or the* connection lookup itself (without one). Lets callers tell degraded* discovery apart from a user with no connected skills.+ * @param options.providerIds - Only build manifests for these providers. The+ * tool list of any other connection is never requested.* @returns Array of tool manifests for connected skills*/async getLobehubSkillManifests(options?: {onError?: (error: unknown, providerId?: string) => void;+ providerIds?: string[];}): Promise<LobeToolManifest[]> {try {// 1. Get user's connected skills- const { connections } = await this.market.connect.listConnections({+ const { connections: allConnections } = await this.market.connect.listConnections({signal: AbortSignal.timeout(LOBEHUB_SKILL_DISCOVERY_TIMEOUT_MS),});+ const providerIds = options?.providerIds && new Set(options.providerIds);+ const connections = providerIds+ ? allConnections?.filter((connection) => providerIds.has((connection as any).providerId))+ : allConnections;if (!connections || connections.length === 0) {log('getLobehubSkillManifests: no connected skills found');return [];diff --git a/locales/en-US/agent.json b/locales/en-US/agent.jsonindex 64218ef7396..49fb1f117a0 100644--- a/locales/en-US/agent.json+++ b/locales/en-US/agent.json@@ -500,6 +500,7 @@"share.settings.tools.needsMemoryPermission": "Also turn on “Allow reading my memory” above, or this tool stays inert for visitors.","share.settings.tools.notAvailableToVisitors": "This tool can never be used in a shared run — visitor runs are blocked from your knowledge base and Agent files.","share.settings.tools.onDemandDesc": "Not enabled on this Agent. Once granted, the model turns it on in a visitor run only when needed.",+ "share.settings.tools.ownerCredentials": "Visitors use MCP servers, connections and plugins with your accounts and credentials.","share.settings.tools.showOnDemand": "Show on-demand tools","share.settings.tools.title": "Tools visitors can use","share.settings.updateError": "Could not save the change. Please try again.",diff --git a/locales/zh-CN/agent.json b/locales/zh-CN/agent.jsonindex 080aa176031..715658397a3 100644--- a/locales/zh-CN/agent.json+++ b/locales/zh-CN/agent.json@@ -500,6 +500,7 @@"share.settings.tools.needsMemoryPermission": "还需要打开上面的「允许读取我的记忆」,否则该工具对访客不起作用。","share.settings.tools.notAvailableToVisitors": "该工具无法在分享运行中使用:访客运行被禁止访问你的知识库和助手文件。","share.settings.tools.onDemandDesc": "助手未启用的工具。开放后,模型会在访客对话需要时再启用。",+ "share.settings.tools.ownerCredentials": "访客使用 MCP、连接和插件时,会以你的账号和凭证运行。","share.settings.tools.showOnDemand": "显示按需启用的工具","share.settings.tools.title": "访客可用的工具","share.settings.updateError": "保存失败,请重试。",diff --git a/packages/locales/src/default/agent.ts b/packages/locales/src/default/agent.tsindex c46c54ba34e..e99a6e522f2 100644--- a/packages/locales/src/default/agent.ts+++ b/packages/locales/src/default/agent.ts@@ -634,6 +634,8 @@ export default {'This tool can never be used in a shared run — visitor runs are blocked from your knowledge base and Agent files.','share.settings.tools.onDemandDesc':'Not enabled on this Agent. Once granted, the model turns it on in a visitor run only when needed.',+ 'share.settings.tools.ownerCredentials':+ 'Visitors use MCP servers, connections and plugins with your accounts and credentials.','share.settings.tools.showOnDemand': 'Show on-demand tools','share.settings.tools.title': 'Tools visitors can use','share.settings.updateError': 'Could not save the change. Please try again.',