@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
|
@@ -9,8 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* Demonstrates notification channels for agents: in-app toasts, email digests,
|
|
10
10
|
* Slack webhook integrations, and notification preference management.
|
|
11
11
|
*
|
|
12
|
-
* - Creates a
|
|
13
|
-
* Runtimes API and deploys an agent on its sidecar
|
|
12
|
+
* - Creates a local agent-runtimes agent using the `example-notifications` spec
|
|
14
13
|
* - Shows a notification center alongside the chat where users can configure
|
|
15
14
|
* channels and review recent notifications
|
|
16
15
|
*/
|
|
@@ -18,31 +17,34 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
18
17
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
19
18
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
20
19
|
import { Text, Button, Spinner, Heading, Label, TextInput, Flash, Timeline, } from '@primer/react';
|
|
21
|
-
import { AlertIcon, BellIcon, MailIcon, CheckCircleIcon, MuteIcon,
|
|
20
|
+
import { AlertIcon, BellIcon, MailIcon, CheckCircleIcon, MuteIcon, } from '@primer/octicons-react';
|
|
22
21
|
import { Box } from '@datalayer/primer-addons';
|
|
23
|
-
import { ErrorView } from './components';
|
|
22
|
+
import { AuthRequiredView, ErrorView } from './components';
|
|
24
23
|
import { ThemedProvider } from './utils/themedProvider';
|
|
24
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
25
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
25
26
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
26
|
-
import { SignInSimple } from '@datalayer/core/lib/views/iam';
|
|
27
|
-
import { UserBadge } from '@datalayer/core/lib/views/profile';
|
|
28
27
|
import { Chat } from '../chat';
|
|
29
|
-
import { useAgents } from '../hooks/useAgents';
|
|
30
28
|
const queryClient = new QueryClient();
|
|
31
29
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
32
|
-
const AGENT_NAME = 'notification-
|
|
33
|
-
const AGENT_SPEC_ID = '
|
|
30
|
+
const AGENT_NAME = 'notification-example-agent';
|
|
31
|
+
const AGENT_SPEC_ID = 'example-notifications';
|
|
32
|
+
const alertVariant = (severity) => {
|
|
33
|
+
if (severity === 'critical')
|
|
34
|
+
return 'danger';
|
|
35
|
+
if (severity === 'warning')
|
|
36
|
+
return 'attention';
|
|
37
|
+
return 'secondary';
|
|
38
|
+
};
|
|
34
39
|
// ─── Inner component (rendered after auth) ─────────────────────────────────
|
|
35
40
|
const AgentNotificationsInner = ({ onLogout, }) => {
|
|
36
41
|
const { token } = useSimpleAuthStore();
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
description: 'Agent with multi-channel notification support',
|
|
44
|
-
},
|
|
45
|
-
});
|
|
42
|
+
const agentName = useRef(uniqueAgentId(AGENT_NAME)).current;
|
|
43
|
+
const agentBaseUrl = useExampleAgentRuntimesUrl();
|
|
44
|
+
const [runtimeStatus, setRuntimeStatus] = useState('launching');
|
|
45
|
+
const [isReady, setIsReady] = useState(false);
|
|
46
|
+
const [hookError, setHookError] = useState(null);
|
|
47
|
+
const [agentId, setAgentId] = useState(agentName);
|
|
46
48
|
const [notifications, setNotifications] = useState([]);
|
|
47
49
|
const [channels, setChannels] = useState([
|
|
48
50
|
{ channel: 'in-app', enabled: true },
|
|
@@ -52,9 +54,7 @@ const AgentNotificationsInner = ({ onLogout, }) => {
|
|
|
52
54
|
const [editTargets, setEditTargets] = useState({});
|
|
53
55
|
const [isSaving, setIsSaving] = useState(false);
|
|
54
56
|
const [flash, setFlash] = useState(null);
|
|
55
|
-
const
|
|
56
|
-
const agentId = runtime?.agentId || AGENT_NAME;
|
|
57
|
-
const podName = runtime?.podName || '(launching…)';
|
|
57
|
+
const podName = isReady ? `local:${agentId}` : '(launching…)';
|
|
58
58
|
// Authenticated fetch helper
|
|
59
59
|
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
60
60
|
...opts,
|
|
@@ -64,6 +64,65 @@ const AgentNotificationsInner = ({ onLogout, }) => {
|
|
|
64
64
|
...(opts.headers ?? {}),
|
|
65
65
|
},
|
|
66
66
|
}), [token]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
let isCancelled = false;
|
|
69
|
+
const createLocalAgent = async () => {
|
|
70
|
+
setRuntimeStatus('launching');
|
|
71
|
+
setIsReady(false);
|
|
72
|
+
setHookError(null);
|
|
73
|
+
try {
|
|
74
|
+
const response = await authFetch(`${agentBaseUrl}/api/v1/agents`, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
name: agentName,
|
|
78
|
+
description: 'Agent with multi-channel notification support',
|
|
79
|
+
agent_library: 'pydantic-ai',
|
|
80
|
+
transport: 'vercel-ai',
|
|
81
|
+
agent_spec_id: AGENT_SPEC_ID,
|
|
82
|
+
enable_skills: true,
|
|
83
|
+
tools: [],
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
let resolvedAgentId = agentName;
|
|
87
|
+
if (response.ok) {
|
|
88
|
+
const data = await response.json();
|
|
89
|
+
resolvedAgentId = data?.id || agentName;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const contentType = response.headers.get('content-type') || '';
|
|
93
|
+
let detail = '';
|
|
94
|
+
if (contentType.includes('application/json')) {
|
|
95
|
+
const data = await response.json().catch(() => null);
|
|
96
|
+
detail =
|
|
97
|
+
(typeof data?.detail === 'string' && data.detail) ||
|
|
98
|
+
(typeof data?.message === 'string' && data.message) ||
|
|
99
|
+
'';
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
detail = await response.text();
|
|
103
|
+
}
|
|
104
|
+
if (!(response.status === 409 || /already exists/i.test(detail))) {
|
|
105
|
+
throw new Error(detail || `Failed to create local agent: ${response.status}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!isCancelled) {
|
|
109
|
+
setAgentId(resolvedAgentId);
|
|
110
|
+
setIsReady(true);
|
|
111
|
+
setRuntimeStatus('ready');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!isCancelled) {
|
|
116
|
+
setHookError(error instanceof Error ? error.message : 'Agent failed to start');
|
|
117
|
+
setRuntimeStatus('error');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
void createLocalAgent();
|
|
122
|
+
return () => {
|
|
123
|
+
isCancelled = true;
|
|
124
|
+
};
|
|
125
|
+
}, [agentBaseUrl, agentName, authFetch]);
|
|
67
126
|
// ── Poll notifications ────────────────────────────────────────────────
|
|
68
127
|
useEffect(() => {
|
|
69
128
|
if (!isReady || !agentBaseUrl)
|
|
@@ -156,14 +215,18 @@ const AgentNotificationsInner = ({ onLogout, }) => {
|
|
|
156
215
|
justifyContent: 'center',
|
|
157
216
|
height: '100vh',
|
|
158
217
|
gap: 3,
|
|
159
|
-
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children:
|
|
160
|
-
? 'Launching runtime for notification agent…'
|
|
161
|
-
: 'Creating notification demo agent…' })] }));
|
|
218
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching local notification agent\u2026" })] }));
|
|
162
219
|
}
|
|
163
220
|
if (runtimeStatus === 'error' || hookError) {
|
|
164
221
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
165
222
|
}
|
|
166
223
|
const unreadCount = notifications.filter(n => !n.read).length;
|
|
224
|
+
const recentAlerts = notifications.slice(0, 10).map(n => ({
|
|
225
|
+
id: n.id,
|
|
226
|
+
title: n.title,
|
|
227
|
+
severity: n.read ? 'info' : 'warning',
|
|
228
|
+
timestamp: n.timestamp,
|
|
229
|
+
}));
|
|
167
230
|
const channelIcon = (ch) => {
|
|
168
231
|
switch (ch) {
|
|
169
232
|
case 'in-app':
|
|
@@ -187,7 +250,7 @@ const AgentNotificationsInner = ({ onLogout, }) => {
|
|
|
187
250
|
borderBottom: '1px solid',
|
|
188
251
|
borderColor: 'border.default',
|
|
189
252
|
flexShrink: 0,
|
|
190
|
-
}, children: [_jsx(BellIcon, { size: 16 }), _jsxs(Heading, { as: "h3", sx: { fontSize: 2, flex: 1 }, children: ["Notifications \u2014 ", podName] }), unreadCount > 0 && (_jsxs(Label, { variant: "accent", size: "small", children: [unreadCount, " unread"] }))
|
|
253
|
+
}, children: [_jsx(BellIcon, { size: 16 }), _jsxs(Heading, { as: "h3", sx: { fontSize: 2, flex: 1 }, children: ["Notifications \u2014 ", podName] }), unreadCount > 0 && (_jsxs(Label, { variant: "accent", size: "small", children: [unreadCount, " unread"] }))] }), _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, title: "Notification Agent", brandIcon: _jsx(BellIcon, { size: 16 }), placeholder: "Ask the agent to send you notifications\u2026", description: `${unreadCount} unread notification${unreadCount !== 1 ? 's' : ''}`, showHeader: true, autoFocus: true, height: "100%", runtimeId: podName, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
191
254
|
{
|
|
192
255
|
title: 'Alert me',
|
|
193
256
|
message: 'Notify me when KPIs drop below threshold',
|
|
@@ -226,7 +289,30 @@ const AgentNotificationsInner = ({ onLogout, }) => {
|
|
|
226
289
|
})), placeholder: ch.channel === 'email'
|
|
227
290
|
? 'user@example.com'
|
|
228
291
|
: 'https://hooks.slack.com/…', size: "small", sx: { width: '100%' } }))] }, ch.channel));
|
|
229
|
-
}), _jsx(Button, { size: "small", leadingVisual: BellIcon, onClick: handleTestNotification, sx: { width: '100%' }, children: "Send Test Notification" }), flash && (_jsx(Flash, { variant: flash.includes('sent') ? 'success' : 'danger', sx: { mt: 2, fontSize: 0 }, children: flash }))] }), _jsxs(Box, { sx: {
|
|
292
|
+
}), _jsx(Button, { size: "small", leadingVisual: BellIcon, onClick: handleTestNotification, sx: { width: '100%' }, children: "Send Test Notification" }), flash && (_jsx(Flash, { variant: flash.includes('sent') ? 'success' : 'danger', sx: { mt: 2, fontSize: 0 }, children: flash }))] }), _jsxs(Box, { sx: {
|
|
293
|
+
p: 3,
|
|
294
|
+
borderBottom: '1px solid',
|
|
295
|
+
borderColor: 'border.default',
|
|
296
|
+
}, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Recent Alerts" }), recentAlerts.length === 0 ? (_jsxs(Box, { sx: {
|
|
297
|
+
p: 2,
|
|
298
|
+
border: '1px solid',
|
|
299
|
+
borderColor: 'border.default',
|
|
300
|
+
borderRadius: 2,
|
|
301
|
+
display: 'flex',
|
|
302
|
+
alignItems: 'center',
|
|
303
|
+
gap: 2,
|
|
304
|
+
}, children: [_jsx(CheckCircleIcon, { size: 16 }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: "No active alerts." })] })) : (recentAlerts.map(alert => (_jsxs(Box, { sx: {
|
|
305
|
+
p: 2,
|
|
306
|
+
mb: 2,
|
|
307
|
+
border: '1px solid',
|
|
308
|
+
borderColor: 'border.default',
|
|
309
|
+
borderRadius: 2,
|
|
310
|
+
}, children: [_jsxs(Box, { sx: {
|
|
311
|
+
display: 'flex',
|
|
312
|
+
justifyContent: 'space-between',
|
|
313
|
+
alignItems: 'center',
|
|
314
|
+
mb: 1,
|
|
315
|
+
}, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: alert.title }), _jsx(Label, { size: "small", variant: alertVariant(alert.severity), children: alert.severity })] }), _jsx(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: new Date(alert.timestamp).toLocaleString() })] }, alert.id))))] }), _jsxs(Box, { sx: { p: 3, flex: 1, overflow: 'auto' }, children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mb: 2 }, children: "Recent Notifications" }), notifications.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "No notifications yet." })) : (_jsx(Timeline, { children: notifications.slice(0, 25).map(n => (_jsxs(Timeline.Item, { children: [_jsx(Timeline.Badge, { children: n.read ? _jsx(CheckCircleIcon, {}) : _jsx(BellIcon, {}) }), _jsxs(Timeline.Body, { children: [_jsx(Text, { sx: {
|
|
230
316
|
fontSize: 0,
|
|
231
317
|
fontWeight: n.read ? 'normal' : 'bold',
|
|
232
318
|
}, children: n.title }), _jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', mt: 1 }, children: n.body }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [new Date(n.timestamp).toLocaleString(), " via", ' ', _jsx(Label, { size: "small", variant: "secondary", children: n.channel })] })] })] }, n.id))) }))] })] })] })] }));
|
|
@@ -239,7 +325,7 @@ const syncTokenToIamStore = (token) => {
|
|
|
239
325
|
};
|
|
240
326
|
// ─── Main component with auth gate ─────────────────────────────────────────
|
|
241
327
|
const AgentNotificationsExample = () => {
|
|
242
|
-
const { token,
|
|
328
|
+
const { token, clearAuth } = useSimpleAuthStore();
|
|
243
329
|
const hasSynced = useRef(false);
|
|
244
330
|
useEffect(() => {
|
|
245
331
|
if (token && !hasSynced.current) {
|
|
@@ -247,11 +333,6 @@ const AgentNotificationsExample = () => {
|
|
|
247
333
|
syncTokenToIamStore(token);
|
|
248
334
|
}
|
|
249
335
|
}, [token]);
|
|
250
|
-
const handleSignIn = useCallback((newToken, handle) => {
|
|
251
|
-
setAuth(newToken, handle);
|
|
252
|
-
hasSynced.current = true;
|
|
253
|
-
syncTokenToIamStore(newToken);
|
|
254
|
-
}, [setAuth]);
|
|
255
336
|
const handleLogout = useCallback(() => {
|
|
256
337
|
clearAuth();
|
|
257
338
|
hasSynced.current = false;
|
|
@@ -260,7 +341,7 @@ const AgentNotificationsExample = () => {
|
|
|
260
341
|
});
|
|
261
342
|
}, [clearAuth]);
|
|
262
343
|
if (!token) {
|
|
263
|
-
return (_jsx(ThemedProvider, { children: _jsx(
|
|
344
|
+
return (_jsx(ThemedProvider, { children: _jsx(AuthRequiredView, {}) }));
|
|
264
345
|
}
|
|
265
346
|
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsx(AgentNotificationsInner, { onLogout: handleLogout }) }) }));
|
|
266
347
|
};
|
|
@@ -24,15 +24,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
24
24
|
*/
|
|
25
25
|
/// <reference types="vite/client" />
|
|
26
26
|
import { useState, useEffect, useCallback, useRef, useMemo, } from 'react';
|
|
27
|
-
import { Text, Button,
|
|
27
|
+
import { Text, Button, Spinner } from '@primer/react';
|
|
28
28
|
import { TelescopeIcon, PlugIcon, XIcon } from '@primer/octicons-react';
|
|
29
29
|
import { Box } from '@datalayer/primer-addons';
|
|
30
30
|
import { OtelHeader, DashboardView, SqlView, SystemView, useSimpleAuthStore, } from '@datalayer/core/lib/views/otel';
|
|
31
|
-
import { SignInSimple } from '@datalayer/core/lib/views/iam';
|
|
32
31
|
import { useCoreStore } from '@datalayer/core';
|
|
33
32
|
import { ThemedProvider } from './utils/themedProvider';
|
|
33
|
+
import { AuthRequiredView } from './components';
|
|
34
34
|
import { ChatSidebar } from '../chat';
|
|
35
|
-
import { DEFAULT_MODEL } from '../specs';
|
|
36
35
|
// ─── Environment / defaults ────────────────────────────────────────────────
|
|
37
36
|
const OTEL_BASE_URL_ENV = import.meta.env.VITE_OTEL_BASE_URL ?? '';
|
|
38
37
|
const DATALAYER_RUN_URL_ENV = import.meta.env.VITE_DATALAYER_RUN_URL ?? '';
|
|
@@ -43,69 +42,62 @@ const DATALAYER_RUN_URL_ENV = import.meta.env.VITE_DATALAYER_RUN_URL ?? '';
|
|
|
43
42
|
const AGENT_BASE_URL_ENV = import.meta.env.VITE_BASE_URL || '';
|
|
44
43
|
const DEFAULT_AGENT_PROTOCOL = 'vercel-ai';
|
|
45
44
|
const DEFAULT_AGENT_LIBRARY = 'pydantic-ai';
|
|
45
|
+
/** Spec id this example always launches. */
|
|
46
|
+
const AGENT_SPEC_ID = 'example-otel';
|
|
46
47
|
/**
|
|
47
48
|
* Small form for picking an agent spec and launching it.
|
|
48
49
|
* Renders as the `children` of the ChatSidebar so it appears above the chat.
|
|
49
50
|
*/
|
|
50
|
-
const
|
|
51
|
-
const [specs, setSpecs] = useState([]);
|
|
52
|
-
const [selectedSpecId, setSelectedSpecId] = useState('');
|
|
51
|
+
const AgentLaunchPanel = ({ baseUrl, onConnected, onDisconnected, isConnected, connectedAgentName, }) => {
|
|
53
52
|
const [loading, setLoading] = useState(false);
|
|
54
53
|
const [error, setError] = useState(null);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
const load = async () => {
|
|
58
|
-
try {
|
|
59
|
-
const res = await fetch(`${baseUrl}/api/v1/agents/library`);
|
|
60
|
-
if (!res.ok)
|
|
61
|
-
throw new Error(`HTTP ${res.status}`);
|
|
62
|
-
const data = await res.json();
|
|
63
|
-
setSpecs(data);
|
|
64
|
-
if (data.length > 0)
|
|
65
|
-
setSelectedSpecId(data[0].id);
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
setError('Could not load agent specs from the backend.');
|
|
69
|
-
console.warn('[AgentOtelExample] Failed to load library specs:', e);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
void load();
|
|
73
|
-
}, [baseUrl]);
|
|
54
|
+
const launchedRef = useRef(false);
|
|
74
55
|
const handleLaunch = useCallback(async () => {
|
|
75
|
-
if (!selectedSpecId)
|
|
76
|
-
return;
|
|
77
56
|
setLoading(true);
|
|
78
57
|
setError(null);
|
|
79
58
|
try {
|
|
80
|
-
const
|
|
81
|
-
const transport = spec?.transport ?? DEFAULT_AGENT_PROTOCOL;
|
|
59
|
+
const transport = DEFAULT_AGENT_PROTOCOL;
|
|
82
60
|
const res = await fetch(`${baseUrl}/api/v1/agents`, {
|
|
83
61
|
method: 'POST',
|
|
84
62
|
headers: { 'Content-Type': 'application/json' },
|
|
85
63
|
body: JSON.stringify({
|
|
86
|
-
name:
|
|
64
|
+
name: AGENT_SPEC_ID,
|
|
87
65
|
description: `Launched from AgentOtelExample`,
|
|
88
66
|
agent_library: DEFAULT_AGENT_LIBRARY,
|
|
89
67
|
transport,
|
|
90
|
-
|
|
91
|
-
system_prompt: 'You are a helpful AI assistant observing OTEL telemetry data.',
|
|
92
|
-
agent_spec_id: selectedSpecId,
|
|
68
|
+
agent_spec_id: AGENT_SPEC_ID,
|
|
93
69
|
}),
|
|
94
70
|
});
|
|
95
71
|
if (!res.ok) {
|
|
96
72
|
const err = await res.json().catch(() => ({ detail: 'Unknown error' }));
|
|
97
|
-
|
|
73
|
+
const detail = typeof err?.detail === 'string' ? err.detail : 'Unknown error';
|
|
74
|
+
// Reuse existing agent when backend reports duplicate creation.
|
|
75
|
+
if (res.status === 409 || /already exists/i.test(detail)) {
|
|
76
|
+
const idMatch = detail.match(/Agent with ID '([^']+)' already exists/i);
|
|
77
|
+
const existingId = idMatch?.[1] || AGENT_SPEC_ID;
|
|
78
|
+
onConnected(existingId, transport);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
throw new Error(detail || `Failed to create agent: ${res.status}`);
|
|
98
82
|
}
|
|
99
83
|
const data = await res.json();
|
|
100
84
|
onConnected(data.id, transport);
|
|
101
85
|
}
|
|
102
86
|
catch (e) {
|
|
103
87
|
setError(e instanceof Error ? e.message : 'Failed to launch agent');
|
|
88
|
+
console.warn('[AgentOtelExample] Failed to launch agent:', e);
|
|
104
89
|
}
|
|
105
90
|
finally {
|
|
106
91
|
setLoading(false);
|
|
107
92
|
}
|
|
108
|
-
}, [
|
|
93
|
+
}, [baseUrl, onConnected]);
|
|
94
|
+
// Auto-launch the example-otel agent on mount.
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (launchedRef.current || isConnected)
|
|
97
|
+
return;
|
|
98
|
+
launchedRef.current = true;
|
|
99
|
+
void handleLaunch();
|
|
100
|
+
}, [handleLaunch, isConnected]);
|
|
109
101
|
if (isConnected) {
|
|
110
102
|
return (_jsxs(Box, { sx: {
|
|
111
103
|
px: 3,
|
|
@@ -129,7 +121,7 @@ const AgentSelectorPanel = ({ baseUrl, onConnected, onDisconnected, isConnected,
|
|
|
129
121
|
gap: 2,
|
|
130
122
|
flexShrink: 0,
|
|
131
123
|
bg: 'canvas.subtle',
|
|
132
|
-
}, children: [_jsx(Text, { sx: { fontSize: 0, fontWeight: 'bold', color: 'fg.muted' }, children: "
|
|
124
|
+
}, children: [_jsx(Text, { sx: { fontSize: 0, fontWeight: 'bold', color: 'fg.muted' }, children: "AGENT" }), loading ? (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(Spinner, { size: "small" }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: ["Launching ", AGENT_SPEC_ID, "\u2026"] })] })) : error ? (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontSize: 1, color: 'danger.fg' }, children: error }), _jsx(Button, { variant: "primary", size: "small", onClick: handleLaunch, leadingVisual: PlugIcon, sx: { width: '100%' }, children: "Retry" })] })) : (_jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: ["Launching ", AGENT_SPEC_ID, "\u2026"] }))] }));
|
|
133
125
|
};
|
|
134
126
|
const TAB_SX = (active) => ({
|
|
135
127
|
px: 3,
|
|
@@ -142,7 +134,7 @@ const TAB_SX = (active) => ({
|
|
|
142
134
|
borderColor: active ? 'accent.fg' : 'transparent',
|
|
143
135
|
'&:hover': { color: 'fg.default' },
|
|
144
136
|
});
|
|
145
|
-
const AgentOtelExampleInner = ({ token
|
|
137
|
+
const AgentOtelExampleInner = ({ token }) => {
|
|
146
138
|
const { configuration } = useCoreStore();
|
|
147
139
|
const resolvedRunUrl = configuration?.otelRunUrl ||
|
|
148
140
|
configuration?.runUrl ||
|
|
@@ -220,7 +212,7 @@ const AgentOtelExampleInner = ({ token, onSignOut }) => {
|
|
|
220
212
|
overflow: 'hidden',
|
|
221
213
|
bg: 'canvas.default',
|
|
222
214
|
color: 'fg.default',
|
|
223
|
-
}, children: [_jsx(OtelHeader, { baseUrl: otelBaseUrl, token: token, onNavigate: handleNavigate,
|
|
215
|
+
}, children: [_jsx(OtelHeader, { baseUrl: otelBaseUrl, token: token, onNavigate: handleNavigate, showGenerateButtons: true, showAccountControls: false, trailing: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(TelescopeIcon, { size: 16 }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: otelBaseUrl })] }) }), _jsxs(Box, { sx: {
|
|
224
216
|
display: 'flex',
|
|
225
217
|
flex: 1,
|
|
226
218
|
minHeight: 0,
|
|
@@ -267,15 +259,13 @@ const AgentOtelExampleInner = ({ token, onSignOut }) => {
|
|
|
267
259
|
},
|
|
268
260
|
],
|
|
269
261
|
}
|
|
270
|
-
: { useStore: true }, children: _jsx(
|
|
262
|
+
: { useStore: true }, children: _jsx(AgentLaunchPanel, { baseUrl: agentBaseUrl, onConnected: handleAgentConnected, onDisconnected: handleAgentDisconnected, isConnected: !!connectedAgentId, connectedAgentName: connectedAgentId ?? undefined }) })] })] }));
|
|
271
263
|
};
|
|
272
264
|
/**
|
|
273
265
|
* AgentOtelExample – themed root with auth gate.
|
|
274
266
|
*/
|
|
275
267
|
const AgentOtelExample = () => {
|
|
276
268
|
const token = useSimpleAuthStore(s => s.token);
|
|
277
|
-
|
|
278
|
-
const clearAuth = useSimpleAuthStore(s => s.clearAuth);
|
|
279
|
-
return (_jsx(ThemedProvider, { children: !token ? (_jsx(SignInSimple, { onSignIn: setAuth, onApiKeySignIn: apiKey => setAuth(apiKey, 'api-key-user'), title: "Datalayer OTEL", description: "Sign in to access the observability dashboard.", leadingIcon: _jsx(TelescopeIcon, { size: 24 }) })) : (_jsx(AgentOtelExampleInner, { token: token, onSignOut: clearAuth })) }));
|
|
269
|
+
return (_jsx(ThemedProvider, { children: !token ? _jsx(AuthRequiredView, {}) : _jsx(AgentOtelExampleInner, { token: token }) }));
|
|
280
270
|
};
|
|
281
271
|
export default AgentOtelExample;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AgentOutputsExample
|
|
3
3
|
*
|
|
4
|
-
* Demonstrates rich output rendering for agent responses
|
|
5
|
-
*
|
|
4
|
+
* Demonstrates rich output rendering for agent responses. The agent (spec
|
|
5
|
+
* `example-outputs`) is prompted to return exactly one of four output types per
|
|
6
|
+
* response:
|
|
7
|
+
* - TABLE → GitHub-flavored Markdown table
|
|
8
|
+
* - JSON → ```json fenced block
|
|
9
|
+
* - CHART → ```json fenced block whose first line is `// chart` (ECharts)
|
|
10
|
+
* - FILE → fenced block whose info string is a file extension and
|
|
11
|
+
* whose first line is `# filename: <name.ext>`
|
|
6
12
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* output formats (table, JSON, chart, file)
|
|
13
|
+
* We subscribe to the chat store, detect the output type of the latest
|
|
14
|
+
* assistant message, auto-switch the sidebar tab, and render the payload
|
|
15
|
+
* inline in the sidebar.
|
|
11
16
|
*/
|
|
12
17
|
import React from 'react';
|
|
13
18
|
declare const AgentOutputsExample: React.FC;
|