diff --git a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx index f9a9aee91a..404963505e 100644 --- a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx +++ b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx @@ -29,7 +29,7 @@ jest.mock('react-hook-form', () => ({ jest.mock('~/Providers', () => ({ useAgentPanelContext: () => ({ - agentsConfig: { capabilities: ['execute_code'] }, + agentsConfig: { capabilities: ['execute_code', 'tools'] }, regularTools: [{ pluginKey: 'dalle', name: 'DALL-E', description: 'Images' }], mcpServersMap: new Map(), actions: [], diff --git a/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts b/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts index 05c123a9e9..91db59db56 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/__tests__/catalog.spec.ts @@ -12,6 +12,11 @@ const emptyInputs: BuildCatalogInputs = { permissions: { mcp: true, skills: true }, }; +const toolInputs: BuildCatalogInputs = { + ...emptyInputs, + agentsConfig: { capabilities: [AgentCapabilities.tools] }, +}; + describe('buildCatalog', () => { test('returns empty when nothing is enabled', () => { expect(buildCatalog(emptyInputs)).toEqual([]); @@ -103,18 +108,26 @@ describe('buildCatalog', () => { expect(skill?.name).toBe('Reviewer'); }); - test('emits tool items', () => { + test('emits tool items when the tools capability is enabled', () => { const items = buildCatalog({ - ...emptyInputs, + ...toolInputs, regularTools: [makePlugin({ pluginKey: 'dalle', name: 'DALL-E', description: 'Images' })], }); const tool = items.find((i) => i.kind === 'tool'); expect(tool?.id).toBe('dalle'); }); - test('marks an auth-requiring, unauthenticated tool as needs_setup', () => { + test('hides tool items when the admin disabled the tools capability', () => { const items = buildCatalog({ ...emptyInputs, + regularTools: [makePlugin({ pluginKey: 'dalle', name: 'DALL-E', description: 'Images' })], + }); + expect(items.find((i) => i.kind === 'tool')).toBeUndefined(); + }); + + test('marks an auth-requiring, unauthenticated tool as needs_setup', () => { + const items = buildCatalog({ + ...toolInputs, regularTools: [ makePlugin({ pluginKey: 'serpapi', @@ -131,7 +144,7 @@ describe('buildCatalog', () => { test('leaves status undefined for an authenticated auth-requiring tool', () => { const items = buildCatalog({ - ...emptyInputs, + ...toolInputs, regularTools: [ makePlugin({ pluginKey: 'serpapi', @@ -148,7 +161,7 @@ describe('buildCatalog', () => { test('leaves status undefined for a tool with no authConfig', () => { const items = buildCatalog({ - ...emptyInputs, + ...toolInputs, regularTools: [makePlugin({ pluginKey: 'dalle', name: 'DALL-E', description: 'Images' })], }); const tool = items.find((i) => i.kind === 'tool'); @@ -211,7 +224,7 @@ describe('buildCatalog', () => { map.set('srv', { serverName: 'srv', isConfigured: true, tools: [] }); const items = buildCatalog({ ...emptyInputs, - agentsConfig: { capabilities: [AgentCapabilities.execute_code] }, + agentsConfig: { capabilities: [AgentCapabilities.execute_code, AgentCapabilities.tools] }, regularTools: [makePlugin({ pluginKey: 't1', name: 'T1', description: '' })], mcpServersMap: map, skills: [makeSkill({ _id: 's1', name: 'S1', description: '' })], diff --git a/client/src/components/SidePanel/Agents/Tools/items/catalog.ts b/client/src/components/SidePanel/Agents/Tools/items/catalog.ts index 950e842a95..e471828146 100644 --- a/client/src/components/SidePanel/Agents/Tools/items/catalog.ts +++ b/client/src/components/SidePanel/Agents/Tools/items/catalog.ts @@ -148,16 +148,18 @@ export function buildCatalog(inputs: BuildCatalogInputs): AgentItem[] { } } - for (const plugin of inputs.regularTools) { - items.push({ - kind: 'tool', - id: plugin.pluginKey, - name: plugin.name ?? plugin.pluginKey, - description: plugin.description ?? '', - iconKey: 'tool', - plugin, - status: pluginNeedsAuth(plugin) ? 'needs_setup' : undefined, - }); + if (enabled.has(AgentCapabilities.tools)) { + for (const plugin of inputs.regularTools) { + items.push({ + kind: 'tool', + id: plugin.pluginKey, + name: plugin.name ?? plugin.pluginKey, + description: plugin.description ?? '', + iconKey: 'tool', + plugin, + status: pluginNeedsAuth(plugin) ? 'needs_setup' : undefined, + }); + } } if (inputs.permissions.skills) {