@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
|
@@ -3,561 +3,312 @@ 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
|
-
* A2UiViewerExample
|
|
8
|
-
*
|
|
9
|
-
* Demonstrates the standalone A2UIViewer component from @a2ui/react.
|
|
10
|
-
* Unlike A2UIProvider + A2UIRenderer (which require context), A2UIViewer
|
|
11
|
-
* is a self-contained component that takes component definitions directly.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Standalone rendering — no A2UIProvider needed
|
|
15
|
-
* - Multiple pre-built A2UI scenes (recipe card, booking form, dashboard)
|
|
16
|
-
* - Shows how to use A2UIViewer for embedding A2UI in any React context
|
|
17
|
-
*
|
|
18
|
-
* No backend required — uses static ComponentInstance[] arrays.
|
|
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 { SegmentedControl, Text } from '@primer/react';
|
|
9
|
+
import { A2uiSurface } from '@a2ui/react/v0_9';
|
|
22
10
|
import { ThemedProvider } from './utils/themedProvider';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
initializeDefaultCatalog();
|
|
11
|
+
import { A2uiMarkdownProvider } from './utils/a2uiMarkdownProvider';
|
|
12
|
+
import { createSceneMessages, useA2uiProcessor } from './utils/a2ui';
|
|
26
13
|
const SCENES = [
|
|
27
|
-
// --- Recipe Card ---
|
|
28
14
|
{
|
|
15
|
+
id: 'recipe',
|
|
29
16
|
label: 'Recipe Card',
|
|
30
17
|
emoji: '🍲',
|
|
31
|
-
description: '
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
id: '
|
|
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
|
-
component: {
|
|
105
|
-
Row: {
|
|
106
|
-
children: { explicitList: ['prep-icon', 'prep-text'] },
|
|
107
|
-
gap: 'small',
|
|
108
|
-
alignment: 'center',
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: 'prep-icon',
|
|
114
|
-
component: { Icon: { name: { literalString: 'timer' } } },
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: 'prep-text',
|
|
118
|
-
component: {
|
|
119
|
-
Text: { text: { path: '/prepTime' }, usageHint: 'caption' },
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: 'cook-time',
|
|
124
|
-
component: {
|
|
125
|
-
Row: {
|
|
126
|
-
children: { explicitList: ['cook-icon', 'cook-text'] },
|
|
127
|
-
gap: 'small',
|
|
128
|
-
alignment: 'center',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: 'cook-icon',
|
|
134
|
-
component: { Icon: { name: { literalString: 'shoppingCart' } } },
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: 'cook-text',
|
|
138
|
-
component: {
|
|
139
|
-
Text: { text: { path: '/cookTime' }, usageHint: 'caption' },
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: 'servings',
|
|
144
|
-
component: {
|
|
145
|
-
Text: { text: { path: '/servings' }, usageHint: 'caption' },
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
data: {
|
|
150
|
-
image: 'https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=300&h=180&fit=crop',
|
|
151
|
-
title: 'Mediterranean Quinoa Bowl',
|
|
152
|
-
rating: 4.9,
|
|
153
|
-
reviewCount: '(1,247 reviews)',
|
|
154
|
-
prepTime: '15 min prep',
|
|
155
|
-
cookTime: '20 min cook',
|
|
156
|
-
servings: 'Serves 4',
|
|
157
|
-
},
|
|
18
|
+
description: 'Rich recipe card with image and metadata.',
|
|
19
|
+
messages: createSceneMessages({
|
|
20
|
+
surfaceId: 'viewer-recipe',
|
|
21
|
+
components: [
|
|
22
|
+
{ id: 'root', component: 'Card', child: 'main' },
|
|
23
|
+
{
|
|
24
|
+
id: 'main',
|
|
25
|
+
component: 'Column',
|
|
26
|
+
children: [
|
|
27
|
+
'recipe-image',
|
|
28
|
+
'title',
|
|
29
|
+
'rating-row',
|
|
30
|
+
'timing-row',
|
|
31
|
+
'servings',
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'recipe-image',
|
|
36
|
+
component: 'Image',
|
|
37
|
+
url: { path: '/image' },
|
|
38
|
+
fit: 'cover',
|
|
39
|
+
variant: 'largeFeature',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'title',
|
|
43
|
+
component: 'Text',
|
|
44
|
+
variant: 'h3',
|
|
45
|
+
text: { path: '/title' },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'rating-row',
|
|
49
|
+
component: 'Row',
|
|
50
|
+
align: 'center',
|
|
51
|
+
children: ['star', 'rating', 'reviews'],
|
|
52
|
+
},
|
|
53
|
+
{ id: 'star', component: 'Icon', name: 'star' },
|
|
54
|
+
{ id: 'rating', component: 'Text', text: { path: '/rating' } },
|
|
55
|
+
{
|
|
56
|
+
id: 'reviews',
|
|
57
|
+
component: 'Text',
|
|
58
|
+
variant: 'caption',
|
|
59
|
+
text: { path: '/reviewCount' },
|
|
60
|
+
},
|
|
61
|
+
{ id: 'timing-row', component: 'Row', children: ['prep', 'cook'] },
|
|
62
|
+
{
|
|
63
|
+
id: 'prep',
|
|
64
|
+
component: 'Text',
|
|
65
|
+
variant: 'caption',
|
|
66
|
+
text: { path: '/prepTime' },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'cook',
|
|
70
|
+
component: 'Text',
|
|
71
|
+
variant: 'caption',
|
|
72
|
+
text: { path: '/cookTime' },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'servings',
|
|
76
|
+
component: 'Text',
|
|
77
|
+
variant: 'caption',
|
|
78
|
+
text: { path: '/servings' },
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
value: {
|
|
82
|
+
image: 'https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=300&h=180&fit=crop',
|
|
83
|
+
title: 'Mediterranean Quinoa Bowl',
|
|
84
|
+
rating: '4.9',
|
|
85
|
+
reviewCount: '(1,247 reviews)',
|
|
86
|
+
prepTime: '15 min prep',
|
|
87
|
+
cookTime: '20 min cook',
|
|
88
|
+
servings: 'Serves 4',
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
158
91
|
},
|
|
159
|
-
// --- Booking Form ---
|
|
160
92
|
{
|
|
93
|
+
id: 'booking',
|
|
161
94
|
label: 'Booking Form',
|
|
162
95
|
emoji: '📅',
|
|
163
|
-
description: '
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
id: 'submit-button',
|
|
217
|
-
component: {
|
|
218
|
-
Button: {
|
|
219
|
-
child: 'submit-text',
|
|
220
|
-
action: {
|
|
96
|
+
description: 'Form controls and a submit action payload.',
|
|
97
|
+
messages: createSceneMessages({
|
|
98
|
+
surfaceId: 'viewer-booking',
|
|
99
|
+
components: [
|
|
100
|
+
{
|
|
101
|
+
id: 'root',
|
|
102
|
+
component: 'Column',
|
|
103
|
+
children: [
|
|
104
|
+
'title',
|
|
105
|
+
'party-size',
|
|
106
|
+
'date-time',
|
|
107
|
+
'dietary',
|
|
108
|
+
'submit-label',
|
|
109
|
+
'submit-button',
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 'title',
|
|
114
|
+
component: 'Text',
|
|
115
|
+
variant: 'h2',
|
|
116
|
+
text: { path: '/title' },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'party-size',
|
|
120
|
+
component: 'TextField',
|
|
121
|
+
label: 'Party Size',
|
|
122
|
+
value: { path: '/partySize' },
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'date-time',
|
|
126
|
+
component: 'DateTimeInput',
|
|
127
|
+
label: 'Date & Time',
|
|
128
|
+
value: { path: '/dateTime' },
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'dietary',
|
|
132
|
+
component: 'TextField',
|
|
133
|
+
label: 'Dietary Requirements',
|
|
134
|
+
value: { path: '/dietary' },
|
|
135
|
+
variant: 'longText',
|
|
136
|
+
},
|
|
137
|
+
{ id: 'submit-label', component: 'Text', text: 'Submit Reservation' },
|
|
138
|
+
{
|
|
139
|
+
id: 'submit-button',
|
|
140
|
+
component: 'Button',
|
|
141
|
+
variant: 'primary',
|
|
142
|
+
child: 'submit-label',
|
|
143
|
+
action: {
|
|
144
|
+
event: {
|
|
221
145
|
name: 'submit_booking',
|
|
222
|
-
context:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
id: 'submit-text',
|
|
233
|
-
component: { Text: { text: { literalString: 'Submit Reservation' } } },
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
data: {
|
|
237
|
-
title: 'Book a Table at The Fancy Place',
|
|
238
|
-
partySize: '2',
|
|
239
|
-
reservationTime: '',
|
|
240
|
-
dietary: '',
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
// --- Sales Dashboard ---
|
|
244
|
-
{
|
|
245
|
-
label: 'Sales Dashboard',
|
|
246
|
-
emoji: '📊',
|
|
247
|
-
description: 'A simple data dashboard with cards showing sales by category.',
|
|
248
|
-
root: 'root-column',
|
|
249
|
-
components: [
|
|
250
|
-
{
|
|
251
|
-
id: 'root-column',
|
|
252
|
-
component: {
|
|
253
|
-
Column: {
|
|
254
|
-
children: {
|
|
255
|
-
explicitList: ['dash-title', 'dash-row-1', 'dash-row-2'],
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
id: 'dash-title',
|
|
262
|
-
component: {
|
|
263
|
-
Text: {
|
|
264
|
-
text: { literalString: 'Sales by Category' },
|
|
265
|
-
usageHint: 'h2',
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
// Row 1
|
|
270
|
-
{
|
|
271
|
-
id: 'dash-row-1',
|
|
272
|
-
component: {
|
|
273
|
-
Row: {
|
|
274
|
-
children: { explicitList: ['card-apparel', 'card-electronics'] },
|
|
275
|
-
distribution: 'spaceEvenly',
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{ id: 'card-apparel', component: { Card: { child: 'apparel-col' } } },
|
|
280
|
-
{
|
|
281
|
-
id: 'apparel-col',
|
|
282
|
-
component: {
|
|
283
|
-
Column: {
|
|
284
|
-
children: { explicitList: ['apparel-label', 'apparel-value'] },
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
id: 'apparel-label',
|
|
290
|
-
component: {
|
|
291
|
-
Text: { text: { literalString: 'Apparel' }, usageHint: 'caption' },
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
id: 'apparel-value',
|
|
296
|
-
component: {
|
|
297
|
-
Text: { text: { literalString: '$41,200' }, usageHint: 'h3' },
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: 'card-electronics',
|
|
302
|
-
component: { Card: { child: 'electronics-col' } },
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: 'electronics-col',
|
|
306
|
-
component: {
|
|
307
|
-
Column: {
|
|
308
|
-
children: {
|
|
309
|
-
explicitList: ['electronics-label', 'electronics-value'],
|
|
146
|
+
context: {
|
|
147
|
+
partySize: { path: '/partySize' },
|
|
148
|
+
dateTime: { path: '/dateTime' },
|
|
149
|
+
dietary: { path: '/dietary' },
|
|
150
|
+
},
|
|
310
151
|
},
|
|
311
152
|
},
|
|
312
153
|
},
|
|
154
|
+
],
|
|
155
|
+
value: {
|
|
156
|
+
title: 'Book Your Table',
|
|
157
|
+
partySize: '4',
|
|
158
|
+
dateTime: '2026-05-15T19:30:00Z',
|
|
159
|
+
dietary: 'No peanuts',
|
|
313
160
|
},
|
|
314
|
-
|
|
315
|
-
id: 'electronics-label',
|
|
316
|
-
component: {
|
|
317
|
-
Text: {
|
|
318
|
-
text: { literalString: 'Electronics' },
|
|
319
|
-
usageHint: 'caption',
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
id: 'electronics-value',
|
|
325
|
-
component: {
|
|
326
|
-
Text: { text: { literalString: '$28,900' }, usageHint: 'h3' },
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
// Row 2
|
|
330
|
-
{
|
|
331
|
-
id: 'dash-row-2',
|
|
332
|
-
component: {
|
|
333
|
-
Row: {
|
|
334
|
-
children: { explicitList: ['card-home', 'card-health'] },
|
|
335
|
-
distribution: 'spaceEvenly',
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
{ id: 'card-home', component: { Card: { child: 'home-col' } } },
|
|
340
|
-
{
|
|
341
|
-
id: 'home-col',
|
|
342
|
-
component: {
|
|
343
|
-
Column: { children: { explicitList: ['home-label', 'home-value'] } },
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
id: 'home-label',
|
|
348
|
-
component: {
|
|
349
|
-
Text: { text: { literalString: 'Home Goods' }, usageHint: 'caption' },
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
id: 'home-value',
|
|
354
|
-
component: {
|
|
355
|
-
Text: { text: { literalString: '$15,600' }, usageHint: 'h3' },
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
{ id: 'card-health', component: { Card: { child: 'health-col' } } },
|
|
359
|
-
{
|
|
360
|
-
id: 'health-col',
|
|
361
|
-
component: {
|
|
362
|
-
Column: {
|
|
363
|
-
children: { explicitList: ['health-label', 'health-value'] },
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
id: 'health-label',
|
|
369
|
-
component: {
|
|
370
|
-
Text: {
|
|
371
|
-
text: { literalString: 'Health & Beauty' },
|
|
372
|
-
usageHint: 'caption',
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
id: 'health-value',
|
|
378
|
-
component: {
|
|
379
|
-
Text: { text: { literalString: '$10,300' }, usageHint: 'h3' },
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
],
|
|
161
|
+
}),
|
|
383
162
|
},
|
|
384
|
-
// --- Confirmation ---
|
|
385
163
|
{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
164
|
+
id: 'dashboard',
|
|
165
|
+
label: 'Sales Snapshot',
|
|
166
|
+
emoji: '📈',
|
|
167
|
+
description: 'Nested cards and list-like KPI tiles.',
|
|
168
|
+
messages: createSceneMessages({
|
|
169
|
+
surfaceId: 'viewer-dashboard',
|
|
170
|
+
components: [
|
|
171
|
+
{
|
|
172
|
+
id: 'root',
|
|
173
|
+
component: 'Column',
|
|
174
|
+
children: ['headline', 'subtitle', 'tiles'],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: 'headline',
|
|
178
|
+
component: 'Text',
|
|
179
|
+
variant: 'h2',
|
|
180
|
+
text: 'Sales by Category',
|
|
181
|
+
},
|
|
182
|
+
{ id: 'subtitle', component: 'Text', text: 'Q2 performance snapshot' },
|
|
183
|
+
{
|
|
184
|
+
id: 'tiles',
|
|
185
|
+
component: 'Column',
|
|
186
|
+
children: ['tile-1', 'tile-2', 'tile-3', 'tile-4'],
|
|
187
|
+
},
|
|
188
|
+
{ id: 'tile-1', component: 'Card', child: 'tile-1-row' },
|
|
189
|
+
{
|
|
190
|
+
id: 'tile-1-row',
|
|
191
|
+
component: 'Row',
|
|
192
|
+
justify: 'spaceBetween',
|
|
193
|
+
children: ['tile-1-label', 'tile-1-value'],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: 'tile-1-label',
|
|
197
|
+
component: 'Text',
|
|
198
|
+
variant: 'caption',
|
|
199
|
+
text: 'Apparel',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'tile-1-value',
|
|
203
|
+
component: 'Text',
|
|
204
|
+
variant: 'h3',
|
|
205
|
+
text: '$41,200',
|
|
206
|
+
},
|
|
207
|
+
{ id: 'tile-2', component: 'Card', child: 'tile-2-row' },
|
|
208
|
+
{
|
|
209
|
+
id: 'tile-2-row',
|
|
210
|
+
component: 'Row',
|
|
211
|
+
justify: 'spaceBetween',
|
|
212
|
+
children: ['tile-2-label', 'tile-2-value'],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: 'tile-2-label',
|
|
216
|
+
component: 'Text',
|
|
217
|
+
variant: 'caption',
|
|
218
|
+
text: 'Electronics',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 'tile-2-value',
|
|
222
|
+
component: 'Text',
|
|
223
|
+
variant: 'h3',
|
|
224
|
+
text: '$28,900',
|
|
225
|
+
},
|
|
226
|
+
{ id: 'tile-3', component: 'Card', child: 'tile-3-row' },
|
|
227
|
+
{
|
|
228
|
+
id: 'tile-3-row',
|
|
229
|
+
component: 'Row',
|
|
230
|
+
justify: 'spaceBetween',
|
|
231
|
+
children: ['tile-3-label', 'tile-3-value'],
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: 'tile-3-label',
|
|
235
|
+
component: 'Text',
|
|
236
|
+
variant: 'caption',
|
|
237
|
+
text: 'Home Goods',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
id: 'tile-3-value',
|
|
241
|
+
component: 'Text',
|
|
242
|
+
variant: 'h3',
|
|
243
|
+
text: '$15,600',
|
|
244
|
+
},
|
|
245
|
+
{ id: 'tile-4', component: 'Card', child: 'tile-4-row' },
|
|
246
|
+
{
|
|
247
|
+
id: 'tile-4-row',
|
|
248
|
+
component: 'Row',
|
|
249
|
+
justify: 'spaceBetween',
|
|
250
|
+
children: ['tile-4-label', 'tile-4-value'],
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
id: 'tile-4-label',
|
|
254
|
+
component: 'Text',
|
|
255
|
+
variant: 'caption',
|
|
256
|
+
text: 'Health & Beauty',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
id: 'tile-4-value',
|
|
260
|
+
component: 'Text',
|
|
261
|
+
variant: 'h3',
|
|
262
|
+
text: '$10,300',
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
}),
|
|
482
266
|
},
|
|
483
267
|
];
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
268
|
+
function ViewerContent({ onAction, }) {
|
|
269
|
+
const { surfaces, processMessages, resetSurfaces } = useA2uiProcessor(onAction);
|
|
270
|
+
const [selectedSceneId, setSelectedSceneId] = useState(SCENES[0].id);
|
|
271
|
+
const selectedScene = useMemo(() => SCENES.find(scene => scene.id === selectedSceneId) ?? SCENES[0], [selectedSceneId]);
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
resetSurfaces();
|
|
274
|
+
processMessages(selectedScene.messages);
|
|
275
|
+
}, [selectedScene, processMessages, resetSurfaces]);
|
|
276
|
+
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 3, p: 3 }, children: [_jsxs(Box, { sx: {
|
|
277
|
+
width: '100%',
|
|
278
|
+
border: '1px solid',
|
|
279
|
+
borderColor: 'border.default',
|
|
280
|
+
borderRadius: 2,
|
|
281
|
+
p: 3,
|
|
282
|
+
backgroundColor: 'canvas.subtle',
|
|
283
|
+
display: 'flex',
|
|
284
|
+
flexDirection: 'column',
|
|
285
|
+
gap: 3,
|
|
286
|
+
}, children: [_jsx(Text, { sx: { fontSize: 2, fontWeight: 'bold' }, children: "Select Scene" }), _jsx(SegmentedControl, { "aria-label": "A2UI viewer scene picker", fullWidth: true, children: SCENES.map(scene => (_jsx(SegmentedControl.Button, { selected: scene.id === selectedSceneId, onClick: () => setSelectedSceneId(scene.id), children: `${scene.emoji} ${scene.label}` }, scene.id))) }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: selectedScene.description })] }), _jsx(Box, { sx: { width: '100%', display: 'flex', flexDirection: 'column', gap: 3 }, children: surfaces.map(surface => (_jsx(Box, { sx: { width: '100%' }, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) })] }));
|
|
287
|
+
}
|
|
491
288
|
const A2UiViewerExample = () => {
|
|
492
|
-
const [sceneIdx, setSceneIdx] = useState(0);
|
|
493
289
|
const [lastAction, setLastAction] = useState(null);
|
|
494
|
-
const scene = SCENES[sceneIdx];
|
|
495
290
|
const handleAction = useCallback((action) => {
|
|
496
|
-
console.log('Viewer
|
|
291
|
+
console.log('A2UI Viewer Action:', action);
|
|
497
292
|
setLastAction(action);
|
|
498
293
|
}, []);
|
|
499
|
-
return (_jsx(ThemedProvider, { children: _jsxs(Box, { sx: {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
borderColor: 'border.default',
|
|
519
|
-
display: 'flex',
|
|
520
|
-
alignItems: 'center',
|
|
521
|
-
gap: 3,
|
|
522
|
-
}, children: [_jsx(Text, { sx: { fontWeight: 'bold', fontSize: '0.875rem' }, children: "Scene:" }), _jsx(SegmentedControl, { "aria-label": "Scene selector", onChange: setSceneIdx, children: SCENES.map((s, idx) => (_jsx(SegmentedControl.Button, { selected: idx === sceneIdx, children: `${s.emoji} ${s.label}` }, s.label))) })] }), _jsxs(Box, { sx: { flex: 1, display: 'flex', padding: 4, gap: 4 }, children: [_jsxs(Box, { sx: { flex: 1, display: 'flex', flexDirection: 'column', gap: 3 }, children: [_jsx(Text, { sx: { color: 'fg.muted', fontSize: '0.875rem' }, children: scene.description }), _jsx(Box, { sx: {
|
|
523
|
-
border: '1px solid',
|
|
524
|
-
borderColor: 'border.default',
|
|
525
|
-
borderRadius: 2,
|
|
526
|
-
padding: 3,
|
|
527
|
-
backgroundColor: 'canvas.default',
|
|
528
|
-
maxWidth: '500px',
|
|
529
|
-
}, children: _jsx(A2UIViewer, { root: scene.root, components: scene.components, data: scene.data, onAction: handleAction }) })] }), _jsxs(Box, { sx: {
|
|
530
|
-
width: '300px',
|
|
531
|
-
borderLeft: '1px solid',
|
|
532
|
-
borderColor: 'border.default',
|
|
533
|
-
paddingLeft: 3,
|
|
534
|
-
display: 'flex',
|
|
535
|
-
flexDirection: 'column',
|
|
536
|
-
gap: 2,
|
|
537
|
-
}, children: [_jsx(Text, { as: "h4", sx: { fontWeight: 'bold', fontSize: '0.875rem' }, children: "Last Action" }), lastAction ? (_jsx(Box, { as: "pre", sx: {
|
|
538
|
-
fontSize: '0.75rem',
|
|
539
|
-
backgroundColor: 'canvas.subtle',
|
|
540
|
-
padding: 2,
|
|
541
|
-
borderRadius: 2,
|
|
542
|
-
overflow: 'auto',
|
|
543
|
-
whiteSpace: 'pre-wrap',
|
|
544
|
-
wordBreak: 'break-word',
|
|
545
|
-
}, children: JSON.stringify(lastAction, null, 2) })) : (_jsx(Text, { sx: { color: 'fg.muted', fontSize: '0.8rem' }, children: "Interact with a button to see actions here." })), _jsxs(Box, { sx: { marginTop: 3 }, children: [_jsx(Text, { as: "h4", sx: {
|
|
546
|
-
fontWeight: 'bold',
|
|
547
|
-
fontSize: '0.875rem',
|
|
548
|
-
marginBottom: 2,
|
|
549
|
-
}, children: "Component Tree" }), _jsxs(Text, { sx: { color: 'fg.muted', fontSize: '0.75rem' }, children: [scene.components.length, " components, root: \"", scene.root, "\""] }), _jsxs(Box, { as: "ul", sx: {
|
|
550
|
-
fontSize: '0.7rem',
|
|
551
|
-
color: 'fg.muted',
|
|
552
|
-
paddingLeft: 3,
|
|
553
|
-
marginTop: 1,
|
|
554
|
-
}, children: [scene.components.slice(0, 10).map(c => (_jsx("li", { children: _jsxs(Text, { sx: { fontFamily: 'mono', fontSize: '0.7rem' }, children: [c.id, ": ", Object.keys(c.component)[0]] }) }, c.id))), scene.components.length > 10 && (_jsx("li", { children: _jsxs(Text, { sx: { fontSize: '0.7rem', fontStyle: 'italic' }, children: ["...and ", scene.components.length - 10, " more"] }) }))] })] }), _jsx(PrimerButton, { variant: "invisible", onClick: () => {
|
|
555
|
-
console.log('Scene JSON:', JSON.stringify({
|
|
556
|
-
root: scene.root,
|
|
557
|
-
components: scene.components,
|
|
558
|
-
data: scene.data,
|
|
559
|
-
}, null, 2));
|
|
560
|
-
alert('Scene JSON logged to console');
|
|
561
|
-
}, sx: { marginTop: 2, fontSize: '0.8rem' }, children: "Log Scene JSON" })] })] })] }) }));
|
|
294
|
+
return (_jsx(ThemedProvider, { children: _jsx(A2uiMarkdownProvider, { children: _jsxs(Box, { sx: { minHeight: '100vh', display: 'flex', flexDirection: 'column' }, children: [_jsxs(Box, { sx: {
|
|
295
|
+
px: 3,
|
|
296
|
+
py: 3,
|
|
297
|
+
borderBottom: '1px solid',
|
|
298
|
+
borderColor: 'border.default',
|
|
299
|
+
backgroundColor: 'canvas.subtle',
|
|
300
|
+
}, children: [_jsx(Text, { as: "h1", sx: { fontSize: 3, fontWeight: 'bold' }, children: "\uD83D\uDD0D A2UI Viewer" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Standalone viewer scenes powered by MessageProcessor and A2uiSurface." })] }), _jsx(ViewerContent, { onAction: handleAction }), _jsx(Box, { sx: {
|
|
301
|
+
borderTop: '1px solid',
|
|
302
|
+
borderColor: 'border.default',
|
|
303
|
+
p: 3,
|
|
304
|
+
fontFamily: 'mono',
|
|
305
|
+
fontSize: 0,
|
|
306
|
+
backgroundColor: 'canvas.subtle',
|
|
307
|
+
whiteSpace: 'pre-wrap',
|
|
308
|
+
maxHeight: 180,
|
|
309
|
+
overflow: 'auto',
|
|
310
|
+
}, children: lastAction
|
|
311
|
+
? JSON.stringify(lastAction, null, 2)
|
|
312
|
+
: 'No action triggered yet.' })] }) }) }));
|
|
562
313
|
};
|
|
563
314
|
export default A2UiViewerExample;
|