@datalayer/agent-runtimes 1.0.4 → 1.0.5
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 +34 -0
- package/lib/App.js +1 -1
- 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 +4 -4
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +2 -2
- 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 +2 -2
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1083 -157
- package/lib/chat/header/ChatHeaderBase.d.ts +11 -6
- package/lib/chat/header/ChatHeaderBase.js +18 -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 +9 -9
- 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 +108 -113
- package/lib/chat/prompt/InputFooter.d.ts +19 -6
- package/lib/chat/prompt/InputFooter.js +71 -18
- package/lib/chat/prompt/InputPrompt.d.ts +3 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.js +1 -1
- 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 +6 -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.js +3 -3
- 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/AgentCheckpointsExample.js +13 -27
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +591 -169
- package/lib/examples/AgentEvalsExample.js +12 -16
- package/lib/examples/AgentGuardrailsExample.js +370 -64
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +104 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +480 -0
- package/lib/examples/AgentMemoryExample.js +13 -17
- package/lib/examples/AgentMonitoringExample.js +260 -199
- package/lib/examples/AgentNotificationsExample.js +49 -17
- package/lib/examples/AgentOtelExample.js +2 -3
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +382 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +246 -0
- package/lib/examples/AgentSandboxExample.d.ts +2 -2
- package/lib/examples/AgentSandboxExample.js +68 -40
- package/lib/examples/AgentSkillsExample.js +91 -99
- package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +29 -557
- package/lib/examples/AgentTriggersExample.js +819 -565
- package/lib/examples/ChatCustomExample.js +11 -24
- package/lib/examples/ChatExample.js +7 -24
- 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} +65 -16
- 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 +7 -0
- package/lib/examples/components/ExampleWrapper.js +25 -6
- 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 +107 -41
- package/lib/examples/index.d.ts +9 -6
- package/lib/examples/index.js +9 -6
- package/lib/examples/main.js +217 -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/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 +118 -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} +39 -2
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
- 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 +10 -0
- package/lib/specs/agents/agents.js +2139 -262
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/envvars.d.ts +1 -0
- package/lib/specs/envvars.js +38 -20
- package/lib/specs/evals.js +6 -6
- 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/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- 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.js +25 -5
- 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 +2 -1
- package/lib/specs/skills.js +41 -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 +204 -0
- package/lib/stores/agentRuntimeStore.js +636 -0
- 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/agentspecs.d.ts +50 -1
- package/lib/types/chat.d.ts +309 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -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 +13 -9
- package/scripts/codegen/__pycache__/generate_agents.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 +102 -6
- package/scripts/codegen/generate_events.py +35 -13
- 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/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/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
- /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
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A2UiContactCardExample
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates a rich contact card UI rendered via A2UI protocol.
|
|
5
|
-
* Uses static A2UI JSON messages (no backend required) featuring:
|
|
6
|
-
* - Data-bound contact information (name, title, email, phone, etc.)
|
|
7
|
-
* - Avatar image with cover fit
|
|
8
|
-
* - Icon + text info rows (calendar, location, email, phone)
|
|
9
|
-
* - Interactive buttons with actions (Follow, Message)
|
|
10
|
-
* - Card and Column layout composition
|
|
11
|
-
* - Divider for visual separation
|
|
12
|
-
*
|
|
13
|
-
* Based on the contact_lookup sample from the A2UI repository.
|
|
14
|
-
*/
|
|
15
1
|
import React from 'react';
|
|
16
|
-
/**
|
|
17
|
-
* A2UiContactCardExample — Rich contact card with data binding & actions.
|
|
18
|
-
* No backend required — uses static A2UI JSON messages rendered client-side.
|
|
19
|
-
*/
|
|
20
2
|
declare const A2UiContactCardExample: React.FC;
|
|
21
3
|
export default A2UiContactCardExample;
|
|
@@ -3,430 +3,173 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
* A2UiContactCardExample
|
|
8
|
-
*
|
|
9
|
-
* Demonstrates a rich contact card UI rendered via A2UI protocol.
|
|
10
|
-
* Uses static A2UI JSON messages (no backend required) featuring:
|
|
11
|
-
* - Data-bound contact information (name, title, email, phone, etc.)
|
|
12
|
-
* - Avatar image with cover fit
|
|
13
|
-
* - Icon + text info rows (calendar, location, email, phone)
|
|
14
|
-
* - Interactive buttons with actions (Follow, Message)
|
|
15
|
-
* - Card and Column layout composition
|
|
16
|
-
* - Divider for visual separation
|
|
17
|
-
*
|
|
18
|
-
* Based on the contact_lookup sample from the A2UI repository.
|
|
19
|
-
*/
|
|
20
|
-
import { useState, useCallback } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
21
7
|
import { Box } from '@datalayer/primer-addons';
|
|
8
|
+
import { Button, Text } from '@primer/react';
|
|
9
|
+
import { A2uiSurface } from '@a2ui/react/v0_9';
|
|
22
10
|
import { ThemedProvider } from './utils/themedProvider';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
team: 'Platform',
|
|
31
|
-
location: 'San Francisco, CA',
|
|
32
|
-
email: 'alice@example.com',
|
|
33
|
-
mobile: '+1 (415) 555-0101',
|
|
34
|
-
calendar: 'Available',
|
|
35
|
-
imageUrl: 'https://api.dicebear.com/9.x/avataaars/svg?seed=Alice',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'Bob Martinez',
|
|
39
|
-
title: 'Product Manager',
|
|
40
|
-
team: 'Growth',
|
|
41
|
-
location: 'New York, NY',
|
|
42
|
-
email: 'bob@example.com',
|
|
43
|
-
mobile: '+1 (212) 555-0202',
|
|
44
|
-
calendar: 'In a meeting',
|
|
45
|
-
imageUrl: 'https://api.dicebear.com/9.x/avataaars/svg?seed=Bob',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'Casey Smith',
|
|
49
|
-
title: 'Digital Marketing Specialist',
|
|
50
|
-
team: 'Marketing',
|
|
51
|
-
location: 'London, UK',
|
|
52
|
-
email: 'casey@example.com',
|
|
53
|
-
mobile: '+44 20 7946 0958',
|
|
54
|
-
calendar: 'Out of office',
|
|
55
|
-
imageUrl: 'https://api.dicebear.com/9.x/avataaars/svg?seed=Casey',
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
// ---------------------------------------------------------------------------
|
|
59
|
-
// A2UI message builders
|
|
60
|
-
// ---------------------------------------------------------------------------
|
|
61
|
-
function contactCardMessages(contact) {
|
|
62
|
-
return [
|
|
63
|
-
// Begin rendering
|
|
64
|
-
{ beginRendering: { surfaceId: 'contact-card', root: 'main_card' } },
|
|
65
|
-
// Surface update - component tree
|
|
11
|
+
import { A2uiMarkdownProvider } from './utils/a2uiMarkdownProvider';
|
|
12
|
+
import { createSceneMessages, useA2uiProcessor } from './utils/a2ui';
|
|
13
|
+
const CONTACT_SURFACE_ID = 'contact-card-v09';
|
|
14
|
+
const CONTACT_CARD_MESSAGES = createSceneMessages({
|
|
15
|
+
surfaceId: CONTACT_SURFACE_ID,
|
|
16
|
+
components: [
|
|
17
|
+
{ id: 'root', component: 'Card', child: 'main-column' },
|
|
66
18
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
explicitList: ['calendar_icon', 'calendar_text_column'],
|
|
144
|
-
},
|
|
145
|
-
distribution: 'start',
|
|
146
|
-
alignment: 'start',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
// Location row
|
|
151
|
-
{
|
|
152
|
-
id: 'location_icon',
|
|
153
|
-
component: { Icon: { name: { literalString: 'location_on' } } },
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
id: 'location_primary_text',
|
|
157
|
-
component: {
|
|
158
|
-
Text: { usageHint: 'h5', text: { path: '/location' } },
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
id: 'location_secondary_text',
|
|
163
|
-
component: { Text: { text: { literalString: 'Location' } } },
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: 'location_text_column',
|
|
167
|
-
component: {
|
|
168
|
-
Column: {
|
|
169
|
-
children: {
|
|
170
|
-
explicitList: [
|
|
171
|
-
'location_primary_text',
|
|
172
|
-
'location_secondary_text',
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
distribution: 'start',
|
|
176
|
-
alignment: 'start',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: 'info_row_2',
|
|
182
|
-
component: {
|
|
183
|
-
Row: {
|
|
184
|
-
children: {
|
|
185
|
-
explicitList: ['location_icon', 'location_text_column'],
|
|
186
|
-
},
|
|
187
|
-
distribution: 'start',
|
|
188
|
-
alignment: 'start',
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
// Email row
|
|
193
|
-
{
|
|
194
|
-
id: 'mail_icon',
|
|
195
|
-
component: { Icon: { name: { literalString: 'mail' } } },
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: 'mail_primary_text',
|
|
199
|
-
component: { Text: { usageHint: 'h5', text: { path: '/email' } } },
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
id: 'mail_secondary_text',
|
|
203
|
-
component: { Text: { text: { literalString: 'Email' } } },
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
id: 'mail_text_column',
|
|
207
|
-
component: {
|
|
208
|
-
Column: {
|
|
209
|
-
children: {
|
|
210
|
-
explicitList: ['mail_primary_text', 'mail_secondary_text'],
|
|
211
|
-
},
|
|
212
|
-
distribution: 'start',
|
|
213
|
-
alignment: 'start',
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: 'info_row_3',
|
|
219
|
-
component: {
|
|
220
|
-
Row: {
|
|
221
|
-
children: { explicitList: ['mail_icon', 'mail_text_column'] },
|
|
222
|
-
distribution: 'start',
|
|
223
|
-
alignment: 'start',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
// Divider
|
|
228
|
-
{ id: 'div', component: { Divider: {} } },
|
|
229
|
-
// Phone row
|
|
230
|
-
{
|
|
231
|
-
id: 'call_icon',
|
|
232
|
-
component: { Icon: { name: { literalString: 'call' } } },
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
id: 'call_primary_text',
|
|
236
|
-
component: { Text: { usageHint: 'h5', text: { path: '/mobile' } } },
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
id: 'call_secondary_text',
|
|
240
|
-
component: { Text: { text: { literalString: 'Mobile' } } },
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: 'call_text_column',
|
|
244
|
-
component: {
|
|
245
|
-
Column: {
|
|
246
|
-
children: {
|
|
247
|
-
explicitList: ['call_primary_text', 'call_secondary_text'],
|
|
248
|
-
},
|
|
249
|
-
distribution: 'start',
|
|
250
|
-
alignment: 'start',
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
id: 'info_row_4',
|
|
256
|
-
component: {
|
|
257
|
-
Row: {
|
|
258
|
-
children: { explicitList: ['call_icon', 'call_text_column'] },
|
|
259
|
-
distribution: 'start',
|
|
260
|
-
alignment: 'start',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
// Info column
|
|
265
|
-
{
|
|
266
|
-
id: 'info_rows_column',
|
|
267
|
-
weight: 1,
|
|
268
|
-
component: {
|
|
269
|
-
Column: {
|
|
270
|
-
children: {
|
|
271
|
-
explicitList: [
|
|
272
|
-
'info_row_1',
|
|
273
|
-
'info_row_2',
|
|
274
|
-
'info_row_3',
|
|
275
|
-
'info_row_4',
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
alignment: 'stretch',
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
// Action buttons
|
|
283
|
-
{
|
|
284
|
-
id: 'button_1_text',
|
|
285
|
-
component: { Text: { text: { literalString: 'Follow' } } },
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
id: 'button_1',
|
|
289
|
-
component: {
|
|
290
|
-
Button: {
|
|
291
|
-
child: 'button_1_text',
|
|
292
|
-
primary: true,
|
|
293
|
-
action: {
|
|
294
|
-
name: 'follow_contact',
|
|
295
|
-
context: [{ key: 'contactName', value: { path: '/name' } }],
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: 'button_2_text',
|
|
302
|
-
component: { Text: { text: { literalString: 'Message' } } },
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: 'button_2',
|
|
306
|
-
component: {
|
|
307
|
-
Button: {
|
|
308
|
-
child: 'button_2_text',
|
|
309
|
-
primary: false,
|
|
310
|
-
action: {
|
|
311
|
-
name: 'send_message',
|
|
312
|
-
context: [{ key: 'contactName', value: { path: '/name' } }],
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
id: 'action_buttons_row',
|
|
319
|
-
component: {
|
|
320
|
-
Row: {
|
|
321
|
-
children: { explicitList: ['button_1', 'button_2'] },
|
|
322
|
-
distribution: 'center',
|
|
323
|
-
alignment: 'center',
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
// Main layout
|
|
328
|
-
{
|
|
329
|
-
id: 'main_column',
|
|
330
|
-
component: {
|
|
331
|
-
Column: {
|
|
332
|
-
children: {
|
|
333
|
-
explicitList: [
|
|
334
|
-
'profile_image',
|
|
335
|
-
'description_column',
|
|
336
|
-
'div',
|
|
337
|
-
'info_rows_column',
|
|
338
|
-
'action_buttons_row',
|
|
339
|
-
],
|
|
340
|
-
},
|
|
341
|
-
alignment: 'stretch',
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
{ id: 'main_card', component: { Card: { child: 'main_column' } } },
|
|
346
|
-
],
|
|
19
|
+
id: 'main-column',
|
|
20
|
+
component: 'Column',
|
|
21
|
+
align: 'center',
|
|
22
|
+
children: [
|
|
23
|
+
'avatar-image',
|
|
24
|
+
'name',
|
|
25
|
+
'title',
|
|
26
|
+
'divider',
|
|
27
|
+
'contact-info',
|
|
28
|
+
'actions',
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'avatar-image',
|
|
33
|
+
component: 'Image',
|
|
34
|
+
url: { path: '/avatar' },
|
|
35
|
+
fit: 'cover',
|
|
36
|
+
variant: 'avatar',
|
|
37
|
+
},
|
|
38
|
+
{ id: 'name', component: 'Text', text: { path: '/name' }, variant: 'h2' },
|
|
39
|
+
{
|
|
40
|
+
id: 'title',
|
|
41
|
+
component: 'Text',
|
|
42
|
+
text: { path: '/title' },
|
|
43
|
+
variant: 'body',
|
|
44
|
+
},
|
|
45
|
+
{ id: 'divider', component: 'Divider' },
|
|
46
|
+
{
|
|
47
|
+
id: 'contact-info',
|
|
48
|
+
component: 'Column',
|
|
49
|
+
children: ['phone-row', 'email-row', 'location-row'],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'phone-row',
|
|
53
|
+
component: 'Row',
|
|
54
|
+
align: 'center',
|
|
55
|
+
children: ['phone-icon', 'phone-text'],
|
|
56
|
+
},
|
|
57
|
+
{ id: 'phone-icon', component: 'Icon', name: 'phone' },
|
|
58
|
+
{ id: 'phone-text', component: 'Text', text: { path: '/phone' } },
|
|
59
|
+
{
|
|
60
|
+
id: 'email-row',
|
|
61
|
+
component: 'Row',
|
|
62
|
+
align: 'center',
|
|
63
|
+
children: ['email-icon', 'email-text'],
|
|
64
|
+
},
|
|
65
|
+
{ id: 'email-icon', component: 'Icon', name: 'mail' },
|
|
66
|
+
{ id: 'email-text', component: 'Text', text: { path: '/email' } },
|
|
67
|
+
{
|
|
68
|
+
id: 'location-row',
|
|
69
|
+
component: 'Row',
|
|
70
|
+
align: 'center',
|
|
71
|
+
children: ['location-icon', 'location-text'],
|
|
72
|
+
},
|
|
73
|
+
{ id: 'location-icon', component: 'Icon', name: 'locationOn' },
|
|
74
|
+
{ id: 'location-text', component: 'Text', text: { path: '/location' } },
|
|
75
|
+
{
|
|
76
|
+
id: 'actions',
|
|
77
|
+
component: 'Row',
|
|
78
|
+
justify: 'center',
|
|
79
|
+
children: ['follow-button', 'message-button'],
|
|
80
|
+
},
|
|
81
|
+
{ id: 'follow-button-label', component: 'Text', text: 'Follow' },
|
|
82
|
+
{
|
|
83
|
+
id: 'follow-button',
|
|
84
|
+
component: 'Button',
|
|
85
|
+
variant: 'primary',
|
|
86
|
+
child: 'follow-button-label',
|
|
87
|
+
action: {
|
|
88
|
+
event: {
|
|
89
|
+
name: 'follow_contact',
|
|
90
|
+
context: {
|
|
91
|
+
contactId: { path: '/contactId' },
|
|
92
|
+
name: { path: '/name' },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
347
95
|
},
|
|
348
96
|
},
|
|
349
|
-
|
|
97
|
+
{ id: 'message-button-label', component: 'Text', text: 'Message' },
|
|
350
98
|
{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
{ key: 'imageUrl', valueString: contact.imageUrl },
|
|
363
|
-
],
|
|
99
|
+
id: 'message-button',
|
|
100
|
+
component: 'Button',
|
|
101
|
+
child: 'message-button-label',
|
|
102
|
+
action: {
|
|
103
|
+
event: {
|
|
104
|
+
name: 'message_contact',
|
|
105
|
+
context: {
|
|
106
|
+
email: { path: '/email' },
|
|
107
|
+
name: { path: '/name' },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
364
110
|
},
|
|
365
111
|
},
|
|
366
|
-
]
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
alignItems: 'flex-start',
|
|
394
|
-
}, children: [_jsx(Text, { sx: { fontWeight: 'bold', fontSize: '0.875rem' }, children: contact.name }), _jsx(Text, { sx: {
|
|
395
|
-
fontSize: '0.75rem',
|
|
396
|
-
color: selectedIdx === idx ? 'fg.onEmphasis' : 'fg.muted',
|
|
397
|
-
}, children: contact.title })] }) }, contact.email)))] }), _jsx(Box, { sx: {
|
|
398
|
-
flex: 1,
|
|
399
|
-
display: 'flex',
|
|
400
|
-
alignItems: 'center',
|
|
401
|
-
justifyContent: 'center',
|
|
402
|
-
padding: 4,
|
|
403
|
-
}, children: selectedIdx === null ? (_jsxs(Box, { sx: { textAlign: 'center' }, children: [_jsx(Text, { sx: { fontSize: '3rem' }, children: "\uD83D\uDC64" }), _jsx(Text, { as: "p", sx: { color: 'fg.muted', marginTop: 2 }, children: "Select a contact from the sidebar" })] })) : (_jsx(Box, { sx: { maxWidth: '420px', width: '100%' }, children: surfaceEntries.map(([surfaceId]) => (_jsx(A2UIRenderer, { surfaceId: surfaceId }, surfaceId))) })) })] }));
|
|
112
|
+
],
|
|
113
|
+
value: {
|
|
114
|
+
contactId: 'contact_001',
|
|
115
|
+
avatar: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=100&h=100&fit=crop',
|
|
116
|
+
name: 'David Park',
|
|
117
|
+
title: 'Engineering Manager',
|
|
118
|
+
phone: '+1 (555) 234-5678',
|
|
119
|
+
email: 'david.park@company.com',
|
|
120
|
+
location: 'San Francisco, CA',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
function ContactCardContent({ onAction, }) {
|
|
124
|
+
const { surfaces, processMessages, resetSurfaces } = useA2uiProcessor(onAction);
|
|
125
|
+
const loadCard = useCallback(() => {
|
|
126
|
+
resetSurfaces();
|
|
127
|
+
processMessages(CONTACT_CARD_MESSAGES);
|
|
128
|
+
}, [processMessages, resetSurfaces]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
loadCard();
|
|
131
|
+
}, [loadCard]);
|
|
132
|
+
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 3, px: 3, pb: 3 }, children: [_jsxs(Box, { sx: { display: 'flex', gap: 2 }, children: [_jsx(Button, { size: "small", variant: "primary", onClick: loadCard, children: "Reload Card" }), _jsx(Button, { size: "small", variant: "invisible", onClick: resetSurfaces, children: "Clear" })] }), _jsx(Box, { sx: { display: 'grid', gap: 3 }, children: surfaces.map(surface => (_jsx(Box, { sx: {
|
|
133
|
+
border: '1px solid',
|
|
134
|
+
borderColor: 'border.default',
|
|
135
|
+
borderRadius: 2,
|
|
136
|
+
p: 3,
|
|
137
|
+
backgroundColor: 'canvas.subtle',
|
|
138
|
+
}, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) })] }));
|
|
404
139
|
}
|
|
405
|
-
/**
|
|
406
|
-
* A2UiContactCardExample — Rich contact card with data binding & actions.
|
|
407
|
-
* No backend required — uses static A2UI JSON messages rendered client-side.
|
|
408
|
-
*/
|
|
409
140
|
const A2UiContactCardExample = () => {
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
141
|
+
const [lastAction, setLastAction] = useState(null);
|
|
142
|
+
const handleAction = useCallback((action) => {
|
|
143
|
+
console.log('A2UI Contact Card Action:', action);
|
|
144
|
+
setLastAction(action);
|
|
413
145
|
}, []);
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
146
|
+
const actionPreview = useMemo(() => {
|
|
147
|
+
if (!lastAction) {
|
|
148
|
+
return 'Trigger an action from the card to inspect the event payload.';
|
|
149
|
+
}
|
|
150
|
+
return JSON.stringify(lastAction, null, 2);
|
|
151
|
+
}, [lastAction]);
|
|
152
|
+
return (_jsx(ThemedProvider, { children: _jsx(A2uiMarkdownProvider, { children: _jsxs(Box, { sx: { minHeight: '100vh', display: 'flex', flexDirection: 'column' }, children: [_jsxs(Box, { sx: {
|
|
153
|
+
px: 3,
|
|
154
|
+
py: 3,
|
|
421
155
|
borderBottom: '1px solid',
|
|
422
156
|
borderColor: 'border.default',
|
|
423
157
|
backgroundColor: 'canvas.subtle',
|
|
424
|
-
}, children: [_jsx(Text, { as: "h1", sx: {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
158
|
+
}, children: [_jsx(Text, { as: "h1", sx: { fontSize: 3, fontWeight: 'bold' }, children: "\uD83D\uDC64 A2UI Contact Card" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Uses MessageProcessor + A2uiSurface with native A2UI protocol messages." })] }), _jsxs(Box, { sx: {
|
|
159
|
+
display: 'grid',
|
|
160
|
+
gridTemplateColumns: ['1fr', '2fr 1fr'],
|
|
161
|
+
gap: 3,
|
|
162
|
+
p: 3,
|
|
163
|
+
}, children: [_jsx(ContactCardContent, { onAction: handleAction }), _jsx(Box, { sx: {
|
|
164
|
+
border: '1px solid',
|
|
165
|
+
borderColor: 'border.default',
|
|
166
|
+
borderRadius: 2,
|
|
167
|
+
p: 3,
|
|
168
|
+
backgroundColor: 'canvas.subtle',
|
|
169
|
+
fontFamily: 'mono',
|
|
170
|
+
fontSize: 0,
|
|
171
|
+
whiteSpace: 'pre-wrap',
|
|
172
|
+
overflow: 'auto',
|
|
173
|
+
}, children: actionPreview })] })] }) }) }));
|
|
431
174
|
};
|
|
432
175
|
export default A2UiContactCardExample;
|
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A2UiRestaurantExample
|
|
3
|
-
*
|
|
4
|
-
* Demonstrates A2UI (Agent-to-UI) protocol integration with a pydantic-ai
|
|
5
|
-
* restaurant finder agent using the official @a2ui/react renderer.
|
|
6
|
-
*
|
|
7
|
-
* The agent generates A2UI JSON messages that are rendered into
|
|
8
|
-
* interactive React components via A2UIProvider + A2UIRenderer.
|
|
9
|
-
*
|
|
10
|
-
* Features:
|
|
11
|
-
* - A2UI protocol message processing via @a2ui/react
|
|
12
|
-
* - Dynamic UI generation from agent responses
|
|
13
|
-
* - Restaurant search and booking interface
|
|
14
|
-
* - Action handling for interactive components (buttons, forms)
|
|
15
|
-
* - Dark/light theme support
|
|
16
|
-
*
|
|
17
|
-
* Backend: /api/v1/a2ui/restaurant/
|
|
18
|
-
*/
|
|
19
1
|
import React from 'react';
|
|
20
|
-
/**
|
|
21
|
-
* A2UiRestaurantExample - Main example component
|
|
22
|
-
*
|
|
23
|
-
* Demonstrates A2UI protocol integration with pydantic-ai.
|
|
24
|
-
* The agent generates A2UI JSON messages for restaurant search,
|
|
25
|
-
* display, and booking functionality.
|
|
26
|
-
*
|
|
27
|
-
* Uses @a2ui/react's two-context architecture:
|
|
28
|
-
* - A2UIProvider wraps the app, receives an onAction callback
|
|
29
|
-
* - useA2UIActions() provides processMessages/clearSurfaces/getSurfaces
|
|
30
|
-
* - A2UIRenderer renders surfaces by ID
|
|
31
|
-
*/
|
|
32
2
|
declare const A2UiRestaurantExample: React.FC;
|
|
33
3
|
export default A2UiRestaurantExample;
|