@datalayer/agent-runtimes 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -1
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/App.js +1 -1
- package/lib/agent-node/themeStore.d.ts +3 -0
- package/lib/agent-node/themeStore.js +156 -0
- package/lib/agent-node-main.d.ts +1 -0
- package/lib/agent-node-main.js +14 -0
- package/lib/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -106
- package/lib/chat/Chat.js +20 -14
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +3 -3
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +83 -51
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1414 -174
- package/lib/chat/display/FloatingBrandButton.js +8 -1
- package/lib/chat/header/ChatHeader.d.ts +3 -1
- package/lib/chat/header/ChatHeader.js +15 -12
- package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
- package/lib/chat/header/ChatHeaderBase.js +41 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +91 -56
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +154 -114
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +21 -6
- package/lib/chat/prompt/InputFooter.js +76 -20
- package/lib/chat/prompt/InputPrompt.d.ts +5 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +0 -18
- package/lib/client/AgentsMixin.js +20 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +5 -1
- package/lib/config/AgentConfiguration.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -28
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +603 -169
- package/lib/examples/AgentEvalsExample.js +339 -53
- package/lib/examples/AgentGuardrailsExample.js +383 -66
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +122 -0
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +481 -0
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +78 -33
- package/lib/examples/AgentMonitoringExample.js +261 -200
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +114 -33
- package/lib/examples/AgentOtelExample.js +32 -42
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +433 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +248 -0
- package/lib/examples/AgentSandboxExample.d.ts +3 -3
- package/lib/examples/AgentSandboxExample.js +74 -45
- package/lib/examples/AgentSkillsExample.js +95 -103
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +49 -561
- package/lib/examples/AgentTriggersExample.js +823 -569
- package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +16 -28
- package/lib/examples/ChatExample.js +13 -29
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +66 -17
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ExampleWrapper.d.ts +9 -3
- package/lib/examples/components/ExampleWrapper.js +45 -9
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +4 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +108 -41
- package/lib/examples/index.d.ts +10 -6
- package/lib/examples/index.js +10 -6
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +257 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +153 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +70 -4
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +21 -4
- package/lib/specs/agents/agents.js +2879 -316
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.js +27 -20
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +20 -15
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +1 -1
- package/lib/specs/skills.js +23 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +208 -0
- package/lib/stores/agentRuntimeStore.js +650 -0
- package/lib/stores/conversationStore.js +2 -2
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +54 -1
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +325 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +19 -11
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +187 -45
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +35 -14
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/AgentspecExample.js +0 -705
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/// <reference types="vite/client" />
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
8
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
9
|
+
import { Box } from '@datalayer/primer-addons';
|
|
10
|
+
import { AuthRequiredView, ErrorView } from './components';
|
|
11
|
+
import { Heading, Label, Spinner, Text, Token as PrimerToken, } from '@primer/react';
|
|
12
|
+
import { GlobeIcon, CheckCircleIcon, ServerIcon, XCircleIcon, ToolsIcon, } from '@primer/octicons-react';
|
|
13
|
+
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
14
|
+
import { ThemedProvider } from './utils/themedProvider';
|
|
15
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
16
|
+
import { Chat } from '../chat';
|
|
17
|
+
import { useAIAgentsWebSocket } from '../hooks';
|
|
18
|
+
import { parseAgentStreamMessage } from '../types/stream';
|
|
19
|
+
import { MCP_STATUS_COLORS, MCP_STATUS_LABELS } from '../types/mcp';
|
|
20
|
+
import { MCP_SERVER_LIBRARY } from '../specs/mcpServers';
|
|
21
|
+
const queryClient = new QueryClient();
|
|
22
|
+
const AGENT_NAME = 'mcp-example-agent';
|
|
23
|
+
// Must match agentspecs/agentspecs/agents/example-mcp.yaml `id`.
|
|
24
|
+
const AGENT_SPEC_ID = 'example-mcp';
|
|
25
|
+
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
26
|
+
/* ── Aggregate MCP status helpers ─────────────────────── */
|
|
27
|
+
function deriveAggregate(servers) {
|
|
28
|
+
if (!servers || servers.length === 0)
|
|
29
|
+
return 'none';
|
|
30
|
+
if (servers.some(s => s.status === 'starting'))
|
|
31
|
+
return 'starting';
|
|
32
|
+
if (servers.some(s => s.status === 'failed'))
|
|
33
|
+
return 'failed';
|
|
34
|
+
if (servers.every(s => s.status === 'started'))
|
|
35
|
+
return 'started';
|
|
36
|
+
return 'not_started';
|
|
37
|
+
}
|
|
38
|
+
/* ── Tool card ────────────────────────────────────────── */
|
|
39
|
+
const McpToolCard = ({ tool }) => {
|
|
40
|
+
const schemaProps = tool.inputSchema
|
|
41
|
+
?.properties;
|
|
42
|
+
const paramNames = schemaProps ? Object.keys(schemaProps) : [];
|
|
43
|
+
return (_jsxs(Box, { sx: {
|
|
44
|
+
border: '1px solid',
|
|
45
|
+
borderColor: 'border.default',
|
|
46
|
+
borderRadius: 2,
|
|
47
|
+
p: 2,
|
|
48
|
+
mb: 2,
|
|
49
|
+
bg: 'canvas.default',
|
|
50
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 1 }, children: [_jsx(ToolsIcon, { size: 14 }), _jsx(Text, { sx: { fontWeight: 600, fontSize: 1 }, children: tool.name })] }), tool.description && (_jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mb: 1, mt: 0 }, children: tool.description })), _jsxs(Text, { sx: {
|
|
51
|
+
fontSize: 0,
|
|
52
|
+
fontFamily: 'mono',
|
|
53
|
+
color: 'fg.muted',
|
|
54
|
+
display: 'block',
|
|
55
|
+
}, children: ["server: ", tool.serverName] }), paramNames.length > 0 && (_jsx(Box, { sx: { mt: 1, display: 'flex', gap: 1, flexWrap: 'wrap' }, children: paramNames.map(p => (_jsx(PrimerToken, { text: p, size: "small" }, p))) }))] }));
|
|
56
|
+
};
|
|
57
|
+
/* ── Server status card ───────────────────────────────── */
|
|
58
|
+
const McpServerCard = ({ server }) => (_jsxs(Box, { sx: {
|
|
59
|
+
p: 2,
|
|
60
|
+
mb: 2,
|
|
61
|
+
border: '1px solid',
|
|
62
|
+
borderColor: 'border.default',
|
|
63
|
+
borderRadius: 2,
|
|
64
|
+
bg: 'canvas.default',
|
|
65
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, mb: 1 }, children: [server.emoji && _jsx(Text, { sx: { fontSize: 2 }, children: server.emoji }), _jsx(Text, { sx: { fontWeight: 600, fontSize: 1 }, children: server.name }), _jsx(Label, { size: "small", variant: server.status === 'started' ? 'success' : 'secondary', children: server.status })] }), server.description && (_jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 0, mb: 1 }, children: server.description })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [server.toolsCount, " tool", server.toolsCount !== 1 ? 's' : '', " available"] })] }));
|
|
66
|
+
const McpStatusPanel = ({ data }) => {
|
|
67
|
+
const servers = data?.servers ?? [];
|
|
68
|
+
const aggregate = deriveAggregate(servers);
|
|
69
|
+
if (!data) {
|
|
70
|
+
return (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Waiting for websocket snapshot..." }));
|
|
71
|
+
}
|
|
72
|
+
if (aggregate === 'none') {
|
|
73
|
+
return (_jsxs(Box, { sx: {
|
|
74
|
+
p: 2,
|
|
75
|
+
border: '1px solid',
|
|
76
|
+
borderColor: 'border.default',
|
|
77
|
+
borderRadius: 2,
|
|
78
|
+
display: 'flex',
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
gap: 2,
|
|
81
|
+
}, children: [_jsx(ServerIcon, { size: 16 }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: "No MCP server is defined for this agent." })] }));
|
|
82
|
+
}
|
|
83
|
+
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsxs(Box, { sx: {
|
|
84
|
+
display: 'flex',
|
|
85
|
+
alignItems: 'center',
|
|
86
|
+
gap: 2,
|
|
87
|
+
}, children: [_jsx(Box, { as: "span", sx: {
|
|
88
|
+
display: 'inline-block',
|
|
89
|
+
width: 10,
|
|
90
|
+
height: 10,
|
|
91
|
+
borderRadius: '50%',
|
|
92
|
+
bg: MCP_STATUS_COLORS[aggregate],
|
|
93
|
+
flexShrink: 0,
|
|
94
|
+
} }), _jsx(Text, { sx: { fontSize: 1 }, children: MCP_STATUS_LABELS[aggregate] })] }), servers.map(s => (_jsx(Box, { sx: {
|
|
95
|
+
p: 2,
|
|
96
|
+
border: '1px solid',
|
|
97
|
+
borderColor: 'border.default',
|
|
98
|
+
borderRadius: 2,
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
gap: 2,
|
|
102
|
+
}, children: _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [s.status === 'started' ? (_jsx(CheckCircleIcon, { size: 14, fill: "success.fg" })) : s.status === 'failed' ? (_jsx(XCircleIcon, { size: 14, fill: "danger.fg" })) : (_jsx(Box, { as: "span", sx: {
|
|
103
|
+
width: 8,
|
|
104
|
+
height: 8,
|
|
105
|
+
borderRadius: '50%',
|
|
106
|
+
bg: MCP_STATUS_COLORS[s.status] ??
|
|
107
|
+
MCP_STATUS_COLORS.not_started,
|
|
108
|
+
display: 'inline-block',
|
|
109
|
+
} })), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: s.id })] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [s.status, s.status === 'started' && s.tools_count !== undefined
|
|
110
|
+
? ` · ${s.tools_count} tool${s.tools_count !== 1 ? 's' : ''}`
|
|
111
|
+
: '', s.status === 'failed' && s.error ? ` — ${s.error}` : ''] })] }) }, s.id)))] }));
|
|
112
|
+
};
|
|
113
|
+
/* ── Main inner component ─────────────────────────────── */
|
|
114
|
+
const AgentMCPInner = ({ onLogout }) => {
|
|
115
|
+
const { token } = useSimpleAuthStore();
|
|
116
|
+
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
117
|
+
const [runtimeStatus, setRuntimeStatus] = useState('launching');
|
|
118
|
+
const [isReady, setIsReady] = useState(false);
|
|
119
|
+
const [hookError, setHookError] = useState(null);
|
|
120
|
+
const [agentId, setAgentId] = useState(agentName);
|
|
121
|
+
const [isReconnectedAgent, setIsReconnectedAgent] = useState(false);
|
|
122
|
+
// MCP server IDs from the agent creation spec (e.g. ["tavily"])
|
|
123
|
+
const [selectedServerIds, setSelectedServerIds] = useState([]);
|
|
124
|
+
// Per-agent tool definitions from WS fullContext.tools
|
|
125
|
+
const [agentTools, setAgentTools] = useState([]);
|
|
126
|
+
// WS-provided mcpStatus (global – used as fallback for indicator)
|
|
127
|
+
const [liveMcpStatus, setLiveMcpStatus] = useState(undefined);
|
|
128
|
+
// Pending approvals are now managed internally by ChatBase via the Zustand
|
|
129
|
+
// agent-runtime store — no local state needed.
|
|
130
|
+
const agentBaseUrl = DEFAULT_LOCAL_BASE_URL;
|
|
131
|
+
const chatAuthToken = token === null ? undefined : token;
|
|
132
|
+
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
133
|
+
...opts,
|
|
134
|
+
headers: {
|
|
135
|
+
'Content-Type': 'application/json',
|
|
136
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
137
|
+
...(opts.headers ?? {}),
|
|
138
|
+
},
|
|
139
|
+
}), [token]);
|
|
140
|
+
// ── Create agent ──────────────────────────────────────
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
let isCancelled = false;
|
|
143
|
+
const createAgent = async () => {
|
|
144
|
+
setRuntimeStatus('launching');
|
|
145
|
+
setIsReady(false);
|
|
146
|
+
setHookError(null);
|
|
147
|
+
setIsReconnectedAgent(false);
|
|
148
|
+
try {
|
|
149
|
+
const response = await authFetch(`${agentBaseUrl}/api/v1/agents`, {
|
|
150
|
+
method: 'POST',
|
|
151
|
+
body: JSON.stringify({
|
|
152
|
+
name: agentName,
|
|
153
|
+
description: 'MCP example agent – web crawling and research via Tavily',
|
|
154
|
+
agent_library: 'pydantic-ai',
|
|
155
|
+
transport: 'vercel-ai',
|
|
156
|
+
agent_spec_id: AGENT_SPEC_ID,
|
|
157
|
+
enable_codemode: false,
|
|
158
|
+
enable_skills: true,
|
|
159
|
+
tools: [],
|
|
160
|
+
}),
|
|
161
|
+
});
|
|
162
|
+
let resolvedAgentId = agentName;
|
|
163
|
+
let isAlreadyRunning = false;
|
|
164
|
+
if (response.ok) {
|
|
165
|
+
const data = await response.json();
|
|
166
|
+
resolvedAgentId = data?.id || agentName;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const contentType = response.headers.get('content-type') || '';
|
|
170
|
+
let detail = '';
|
|
171
|
+
if (contentType.includes('application/json')) {
|
|
172
|
+
const data = await response.json().catch(() => null);
|
|
173
|
+
detail =
|
|
174
|
+
(typeof data?.detail === 'string' && data.detail) ||
|
|
175
|
+
(typeof data?.message === 'string' && data.message) ||
|
|
176
|
+
'';
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
detail = await response.text();
|
|
180
|
+
}
|
|
181
|
+
if (response.status === 409 || /already exists/i.test(detail || '')) {
|
|
182
|
+
isAlreadyRunning = true;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw new Error(detail || `Failed to create agent: ${response.status}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (!isCancelled) {
|
|
189
|
+
setAgentId(resolvedAgentId);
|
|
190
|
+
setIsReconnectedAgent(isAlreadyRunning);
|
|
191
|
+
setIsReady(true);
|
|
192
|
+
setRuntimeStatus('ready');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (!isCancelled) {
|
|
197
|
+
setHookError(error instanceof Error ? error.message : 'Agent failed to start');
|
|
198
|
+
setRuntimeStatus('error');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
void createAgent();
|
|
203
|
+
return () => {
|
|
204
|
+
isCancelled = true;
|
|
205
|
+
};
|
|
206
|
+
}, [agentBaseUrl, agentName, authFetch]);
|
|
207
|
+
// ── WebSocket: receive MCP status + fullContext tools from agent.snapshot ─
|
|
208
|
+
const handleSnapshotMessage = useCallback((message) => {
|
|
209
|
+
try {
|
|
210
|
+
const stream = parseAgentStreamMessage(message?.raw ?? message);
|
|
211
|
+
if (!stream || stream.type !== 'agent.snapshot')
|
|
212
|
+
return;
|
|
213
|
+
const payload = stream.payload;
|
|
214
|
+
if (payload.mcpStatus !== undefined) {
|
|
215
|
+
setLiveMcpStatus(payload.mcpStatus ?? undefined);
|
|
216
|
+
}
|
|
217
|
+
// Extract per-agent tool definitions from fullContext.tools
|
|
218
|
+
const fc = payload.fullContext;
|
|
219
|
+
if (fc && Array.isArray(fc.tools) && fc.tools.length > 0) {
|
|
220
|
+
setAgentTools(fc.tools);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Ignore malformed payloads.
|
|
225
|
+
}
|
|
226
|
+
}, []);
|
|
227
|
+
useAIAgentsWebSocket({
|
|
228
|
+
enabled: isReady && Boolean(agentBaseUrl),
|
|
229
|
+
baseUrl: agentBaseUrl,
|
|
230
|
+
path: '/api/v1/tool-approvals/ws',
|
|
231
|
+
queryParams: { agent_id: agentId },
|
|
232
|
+
onMessage: handleSnapshotMessage,
|
|
233
|
+
reconnectDelayMs: attempt => Math.min(1000 * 2 ** Math.max(0, attempt - 1), 10000),
|
|
234
|
+
});
|
|
235
|
+
// ── Fetch creation spec to get selected MCP server IDs ──
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (!isReady)
|
|
238
|
+
return;
|
|
239
|
+
const fetchSpec = async () => {
|
|
240
|
+
try {
|
|
241
|
+
const res = await authFetch(`${agentBaseUrl}/api/v1/configure/agents/${agentId}/spec`);
|
|
242
|
+
if (!res.ok)
|
|
243
|
+
return;
|
|
244
|
+
const spec = await res.json();
|
|
245
|
+
const servers = (spec?.selected_mcp_servers ?? []);
|
|
246
|
+
setSelectedServerIds(servers.map(s => s.id));
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Non-fatal: sidebar info is informational
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
void fetchSpec();
|
|
253
|
+
}, [isReady, agentId, agentBaseUrl, authFetch]);
|
|
254
|
+
// ── Build McpServerInfo[] from selected servers + catalog + WS tools ──
|
|
255
|
+
const mcpServers = useMemo(() => {
|
|
256
|
+
if (selectedServerIds.length === 0)
|
|
257
|
+
return [];
|
|
258
|
+
return selectedServerIds.map(serverId => {
|
|
259
|
+
const catalogServer = MCP_SERVER_LIBRARY[serverId];
|
|
260
|
+
const serverName = catalogServer?.name ?? serverId;
|
|
261
|
+
// Live status from WS snapshot — the most reliable source of truth.
|
|
262
|
+
const liveServer = liveMcpStatus?.servers?.find(s => s.id === serverId);
|
|
263
|
+
// Match tools by prefix convention: "tavily__tavily_search" → server "tavily"
|
|
264
|
+
// (fallback when live data is not yet available)
|
|
265
|
+
const serverTools = agentTools
|
|
266
|
+
.filter(t => t.name.startsWith(`${serverId}__`))
|
|
267
|
+
.map(t => ({
|
|
268
|
+
name: t.name,
|
|
269
|
+
description: t.description,
|
|
270
|
+
serverId,
|
|
271
|
+
serverName,
|
|
272
|
+
inputSchema: t.parametersSchema,
|
|
273
|
+
}));
|
|
274
|
+
// Prefer live tools from WS snapshot; fall back to agentTools-derived tools.
|
|
275
|
+
const toolsFromLive = (liveServer?.tools ?? []).map(t => ({
|
|
276
|
+
name: t.name,
|
|
277
|
+
description: t.description ?? '',
|
|
278
|
+
serverId,
|
|
279
|
+
serverName,
|
|
280
|
+
inputSchema: undefined,
|
|
281
|
+
}));
|
|
282
|
+
const tools = toolsFromLive.length > 0 ? toolsFromLive : serverTools;
|
|
283
|
+
const status = liveServer?.status ?? (serverTools.length > 0 ? 'started' : 'starting');
|
|
284
|
+
const toolsCount = liveServer?.tools_count ?? tools.length;
|
|
285
|
+
return {
|
|
286
|
+
id: serverId,
|
|
287
|
+
name: serverName,
|
|
288
|
+
description: catalogServer?.description,
|
|
289
|
+
status,
|
|
290
|
+
toolsCount,
|
|
291
|
+
tools,
|
|
292
|
+
emoji: catalogServer?.emoji,
|
|
293
|
+
icon: catalogServer?.icon,
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}, [selectedServerIds, agentTools, liveMcpStatus]);
|
|
297
|
+
// ── Build synthetic McpToolsetsStatusResponse for the Chat MCP indicator ──
|
|
298
|
+
const mcpStatusData = useMemo(() => {
|
|
299
|
+
const derivedEnabledToolsByServer = {};
|
|
300
|
+
const derivedApprovedToolsByServer = {};
|
|
301
|
+
for (const s of mcpServers) {
|
|
302
|
+
if (s.tools.length > 0) {
|
|
303
|
+
derivedEnabledToolsByServer[s.id] = s.tools.map(t => t.name);
|
|
304
|
+
// Keep approval default explicit: enabled but not approved.
|
|
305
|
+
derivedApprovedToolsByServer[s.id] = [];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// If the WS-provided global mcpStatus has actual servers, prefer it
|
|
309
|
+
if (liveMcpStatus && liveMcpStatus.servers.length > 0) {
|
|
310
|
+
const live = liveMcpStatus;
|
|
311
|
+
const enabledToolsByServer = {
|
|
312
|
+
...(live.enabled_tools_by_server ?? {}),
|
|
313
|
+
};
|
|
314
|
+
for (const [serverId, tools] of Object.entries(derivedEnabledToolsByServer)) {
|
|
315
|
+
if (!enabledToolsByServer[serverId] ||
|
|
316
|
+
enabledToolsByServer[serverId].length === 0) {
|
|
317
|
+
enabledToolsByServer[serverId] = tools;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const approvedToolsByServer = {
|
|
321
|
+
...(live.approved_tools_by_server ?? {}),
|
|
322
|
+
};
|
|
323
|
+
for (const [serverId, tools] of Object.entries(derivedApprovedToolsByServer)) {
|
|
324
|
+
if (!approvedToolsByServer[serverId]) {
|
|
325
|
+
approvedToolsByServer[serverId] = tools;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
...live,
|
|
330
|
+
enabled_tools_by_server: enabledToolsByServer,
|
|
331
|
+
approved_tools_by_server: approvedToolsByServer,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// Otherwise build from our per-agent derived info
|
|
335
|
+
if (mcpServers.length === 0)
|
|
336
|
+
return undefined;
|
|
337
|
+
const servers = mcpServers.map(s => ({
|
|
338
|
+
id: s.id,
|
|
339
|
+
status: s.status,
|
|
340
|
+
tools_count: s.toolsCount,
|
|
341
|
+
tools: s.tools.map(t => ({
|
|
342
|
+
name: t.name,
|
|
343
|
+
description: t.description,
|
|
344
|
+
enabled: true,
|
|
345
|
+
})),
|
|
346
|
+
}));
|
|
347
|
+
const readyServers = servers
|
|
348
|
+
.filter(s => s.status === 'started')
|
|
349
|
+
.map(s => s.id);
|
|
350
|
+
// Build enabled_tools_by_server so the InputFooter ToolsMenu can render
|
|
351
|
+
// tools as enabled immediately on first open.
|
|
352
|
+
const enabledToolsByServer = derivedEnabledToolsByServer;
|
|
353
|
+
const approvedToolsByServer = derivedApprovedToolsByServer;
|
|
354
|
+
return {
|
|
355
|
+
initialized: true,
|
|
356
|
+
ready_count: readyServers.length,
|
|
357
|
+
failed_count: servers.filter(s => s.status === 'failed').length,
|
|
358
|
+
ready_servers: readyServers,
|
|
359
|
+
failed_servers: {},
|
|
360
|
+
servers,
|
|
361
|
+
enabled_tools_by_server: enabledToolsByServer,
|
|
362
|
+
approved_tools_by_server: approvedToolsByServer,
|
|
363
|
+
enabled_tools_count: mcpServers.reduce((sum, s) => sum + s.tools.length, 0),
|
|
364
|
+
};
|
|
365
|
+
}, [liveMcpStatus, mcpServers]);
|
|
366
|
+
const totalTools = mcpServers.reduce((sum, s) => sum + s.toolsCount, 0);
|
|
367
|
+
const aggregate = deriveAggregate(mcpStatusData?.servers ?? []);
|
|
368
|
+
if (!isReady && runtimeStatus !== 'error') {
|
|
369
|
+
return (_jsxs(Box, { sx: {
|
|
370
|
+
display: 'flex',
|
|
371
|
+
flexDirection: 'column',
|
|
372
|
+
alignItems: 'center',
|
|
373
|
+
justifyContent: 'center',
|
|
374
|
+
height: '100vh',
|
|
375
|
+
gap: 3,
|
|
376
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching MCP example agent..." })] }));
|
|
377
|
+
}
|
|
378
|
+
if (runtimeStatus === 'error' || hookError) {
|
|
379
|
+
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
380
|
+
}
|
|
381
|
+
return (_jsxs(Box, { sx: {
|
|
382
|
+
height: 'calc(100vh - 60px)',
|
|
383
|
+
display: 'flex',
|
|
384
|
+
flexDirection: 'column',
|
|
385
|
+
}, children: [isReconnectedAgent && (_jsx(Box, { sx: {
|
|
386
|
+
px: 3,
|
|
387
|
+
py: 1,
|
|
388
|
+
borderBottom: '1px solid',
|
|
389
|
+
borderColor: 'border.default',
|
|
390
|
+
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "MCP Demo Agent", brandIcon: _jsx(GlobeIcon, { size: 16 }), placeholder: "Ask the agent to search the web or explore GitHub...", showHeader: true, showNewChatButton: true, showClearButton: false, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, mcpStatusData: mcpStatusData, showToolApprovalBanner: true, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["MCP Tools: ", totalTools] }) }), suggestions: [
|
|
391
|
+
{
|
|
392
|
+
title: '🔍 Search the web',
|
|
393
|
+
message: 'Search the web for recent news about AI agents.',
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
title: '🐙 GitHub repos',
|
|
397
|
+
message: 'Find trending open-source Python projects on GitHub.',
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
title: '📚 Research topic',
|
|
401
|
+
message: 'Research best practices for building RAG applications.',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
title: '⚡ Compare frameworks',
|
|
405
|
+
message: 'Compare popular JavaScript frameworks in 2024.',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
title: '😄 Tell me a joke',
|
|
409
|
+
message: 'Use your jokes skill to tell me a random joke.',
|
|
410
|
+
},
|
|
411
|
+
], submitOnSuggestionClick: true }) }), _jsxs(Box, { sx: {
|
|
412
|
+
width: 320,
|
|
413
|
+
minWidth: 260,
|
|
414
|
+
borderLeft: '1px solid',
|
|
415
|
+
borderColor: 'border.default',
|
|
416
|
+
display: 'flex',
|
|
417
|
+
flexDirection: 'column',
|
|
418
|
+
minHeight: 0,
|
|
419
|
+
bg: 'canvas.subtle',
|
|
420
|
+
}, children: [_jsxs(Box, { sx: {
|
|
421
|
+
p: 2,
|
|
422
|
+
borderBottom: '1px solid',
|
|
423
|
+
borderColor: 'border.default',
|
|
424
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 1 }, children: _jsxs(Box, { sx: { display: 'inline-flex', alignItems: 'center', gap: 1 }, children: [_jsx(ServerIcon, { size: 16 }), "MCP Servers & Tools"] }) }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(Box, { as: "span", sx: {
|
|
425
|
+
display: 'inline-block',
|
|
426
|
+
width: 8,
|
|
427
|
+
height: 8,
|
|
428
|
+
borderRadius: '50%',
|
|
429
|
+
bg: MCP_STATUS_COLORS[aggregate],
|
|
430
|
+
flexShrink: 0,
|
|
431
|
+
} }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [MCP_STATUS_LABELS[aggregate], " \u00B7 ", totalTools, " tool", totalTools !== 1 ? 's' : ''] })] })] }), _jsxs(Box, { sx: { p: 2, overflow: 'auto', flex: 1 }, children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h5", sx: { fontSize: 1, mb: 2 }, children: "MCP Servers" }), _jsx(McpStatusPanel, { data: mcpStatusData })] }), mcpServers.length === 0 ? (_jsxs(Box, { sx: {
|
|
432
|
+
display: 'flex',
|
|
433
|
+
flexDirection: 'column',
|
|
434
|
+
alignItems: 'center',
|
|
435
|
+
gap: 2,
|
|
436
|
+
py: 4,
|
|
437
|
+
}, children: [_jsx(Spinner, { size: "medium" }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: "Waiting for MCP servers to start..." })] })) : (_jsxs(_Fragment, { children: [mcpServers.map(server => (_jsxs(Box, { children: [_jsx(McpServerCard, { server: server }), server.tools.length > 0 && (_jsx(Box, { sx: { pl: 2 }, children: server.tools.map(tool => (_jsx(McpToolCard, { tool: tool }, `${tool.serverId}-${tool.name}`))) }))] }, server.id))), _jsxs(Box, { sx: {
|
|
438
|
+
mt: 3,
|
|
439
|
+
p: 2,
|
|
440
|
+
borderRadius: 2,
|
|
441
|
+
bg: 'canvas.inset',
|
|
442
|
+
border: '1px solid',
|
|
443
|
+
borderColor: 'border.muted',
|
|
444
|
+
}, children: [_jsx(Heading, { as: "h5", sx: { fontSize: 0, mb: 1 }, children: "MCP (Model Context Protocol)" }), _jsxs(Box, { sx: { fontSize: 0, color: 'fg.muted' }, children: [_jsxs(Box, { sx: {
|
|
445
|
+
display: 'flex',
|
|
446
|
+
alignItems: 'center',
|
|
447
|
+
gap: 1,
|
|
448
|
+
mb: 1,
|
|
449
|
+
}, children: [_jsx(GlobeIcon, { size: 12 }), _jsxs(Text, { children: [_jsx("strong", { children: "Servers:" }), " Discover and start MCP servers that expose tools to the agent"] })] }), _jsxs(Box, { sx: {
|
|
450
|
+
display: 'flex',
|
|
451
|
+
alignItems: 'center',
|
|
452
|
+
gap: 1,
|
|
453
|
+
}, children: [_jsx(ToolsIcon, { size: 12 }), _jsxs(Text, { children: [_jsx("strong", { children: "Tools:" }), " Individual capabilities exposed by each server (search, fetch, etc.)"] })] })] })] })] }))] })] })] })] }));
|
|
454
|
+
};
|
|
455
|
+
const syncTokenToIamStore = (token) => {
|
|
456
|
+
import('@datalayer/core/lib/state').then(({ iamStore }) => {
|
|
457
|
+
iamStore.setState({ token });
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
const AgentMCPExample = () => {
|
|
461
|
+
const { token, clearAuth } = useSimpleAuthStore();
|
|
462
|
+
const hasSynced = useRef(false);
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
if (token && !hasSynced.current) {
|
|
465
|
+
hasSynced.current = true;
|
|
466
|
+
syncTokenToIamStore(token);
|
|
467
|
+
}
|
|
468
|
+
}, [token]);
|
|
469
|
+
const handleLogout = useCallback(() => {
|
|
470
|
+
clearAuth();
|
|
471
|
+
hasSynced.current = false;
|
|
472
|
+
import('@datalayer/core/lib/state').then(({ iamStore }) => {
|
|
473
|
+
iamStore.setState({ token: undefined });
|
|
474
|
+
});
|
|
475
|
+
}, [clearAuth]);
|
|
476
|
+
if (!token) {
|
|
477
|
+
return (_jsx(ThemedProvider, { children: _jsx(AuthRequiredView, {}) }));
|
|
478
|
+
}
|
|
479
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentMCPInner, { onLogout: handleLogout }) }) }));
|
|
480
|
+
};
|
|
481
|
+
export default AgentMCPExample;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* AgentMemoryExample
|
|
3
3
|
*
|
|
4
4
|
* Demonstrates the Mem0 memory backend for durable agents.
|
|
5
|
-
* Creates a
|
|
6
|
-
* Runtimes API, then deploys an agent with persistent memory on its sidecar.
|
|
5
|
+
* Creates a local agent-runtimes agent using the `example-memory` spec.
|
|
7
6
|
*
|
|
8
7
|
* The left panel shows a standard Chat. The right panel shows the
|
|
9
8
|
* agent's memory contents (fetched from the runtime sidecar) and lets
|