@datalayer/agent-runtimes 1.0.10 → 1.0.18
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 +82 -1
- package/lib/{AgentLexical.d.ts → AgentDocument.d.ts} +5 -5
- package/lib/{AgentLexical.js → AgentDocument.js} +156 -26
- package/lib/AgentNode.js +32 -31
- package/lib/AgentNotebook.js +172 -17
- package/lib/AppExamples2.css +47 -0
- package/lib/AppExamples2.d.ts +3 -0
- package/lib/AppExamples2.js +21 -0
- package/lib/{agent-lexical-main.js → agent-document-main.js} +2 -2
- package/lib/agents/AgentRuntimeChat.d.ts +73 -0
- package/lib/agents/AgentRuntimeChat.js +198 -0
- package/lib/api/index.d.ts +12 -0
- package/lib/api/index.js +46 -0
- package/lib/api/runtimes/checkpoints.d.ts +122 -0
- package/lib/api/runtimes/checkpoints.js +118 -0
- package/lib/api/runtimes/environments.d.ts +9 -0
- package/lib/api/runtimes/environments.js +29 -0
- package/lib/api/runtimes/healthz.d.ts +15 -0
- package/lib/api/runtimes/healthz.js +44 -0
- package/lib/api/runtimes/index.d.ts +12 -0
- package/lib/api/runtimes/index.js +16 -0
- package/lib/api/runtimes/runtimes.d.ts +138 -0
- package/lib/api/runtimes/runtimes.js +230 -0
- package/lib/api/runtimes/snapshots.d.ts +38 -0
- package/lib/api/runtimes/snapshots.js +82 -0
- package/lib/api/scheduler/index.d.ts +6 -0
- package/lib/api/scheduler/index.js +10 -0
- package/lib/api/scheduler/schedules.d.ts +85 -0
- package/lib/api/scheduler/schedules.js +78 -0
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +15 -0
- package/lib/api/spacer/healthz.js +44 -0
- package/lib/api/spacer/index.d.ts +15 -0
- package/lib/api/spacer/index.js +19 -0
- package/lib/api/spacer/items.d.ts +25 -0
- package/lib/api/spacer/items.js +55 -0
- package/lib/api/spacer/lexicals.d.ts +34 -0
- package/lib/api/spacer/lexicals.js +89 -0
- package/lib/api/spacer/notebooks.d.ts +34 -0
- package/lib/api/spacer/notebooks.js +89 -0
- package/lib/api/spacer/spaces.d.ts +84 -0
- package/lib/api/spacer/spaces.js +170 -0
- package/lib/api/spacer/users.d.ts +9 -0
- package/lib/api/spacer/users.js +29 -0
- package/lib/chat/Chat.d.ts +1 -1
- package/lib/chat/Chat.js +54 -54
- package/lib/chat/ChatFloating.d.ts +2 -2
- package/lib/chat/ChatFloating.js +136 -25
- package/lib/chat/ChatSidebar.js +20 -22
- package/lib/chat/base/ChatBase.js +429 -39
- package/lib/chat/display/EmptyState.js +21 -21
- package/lib/chat/document/EphemeralDocument.d.ts +23 -0
- package/lib/chat/document/EphemeralDocument.js +270 -0
- package/lib/chat/header/ChatHeaderBase.d.ts +12 -2
- package/lib/chat/header/ChatHeaderBase.js +78 -23
- package/lib/chat/index.d.ts +1 -0
- package/lib/chat/index.js +2 -0
- package/lib/chat/notebook/EphemeralNotebook.d.ts +24 -0
- package/lib/chat/notebook/EphemeralNotebook.js +252 -0
- package/lib/chat/prompt/InputFooter.js +4 -1
- package/lib/client/AgentRuntimesClient.d.ts +127 -0
- package/lib/client/AgentRuntimesClient.js +36 -0
- package/lib/client/AgentsMixin.js +28 -28
- package/lib/client/SdkAgentRuntimesClient.d.ts +1 -1
- package/lib/client/SdkAgentRuntimesClient.js +1 -1
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +210 -0
- package/lib/client/mixins/SpacerMixin.js +615 -0
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +13 -0
- package/lib/collaboration/DatalayerCollaboration.js +28 -0
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +58 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +148 -0
- package/lib/collaboration/index.d.ts +2 -0
- package/lib/collaboration/index.js +6 -0
- package/lib/components/AgentSummary.d.ts +19 -0
- package/lib/components/AgentSummary.js +89 -0
- package/lib/components/a2ui/A2uiSurfaceComposed.d.ts +13 -0
- package/lib/components/a2ui/A2uiSurfaceComposed.js +110 -0
- package/lib/components/a2ui/index.d.ts +2 -0
- package/lib/components/a2ui/index.js +6 -0
- package/lib/components/a2ui/styles.d.ts +14 -0
- package/lib/components/a2ui/styles.js +142 -0
- package/lib/components/context/SpaceSelect.d.ts +2 -0
- package/lib/components/context/SpaceSelect.js +42 -0
- package/lib/components/flashes/FlashDisclaimer.d.ts +2 -0
- package/lib/components/flashes/FlashDisclaimer.js +17 -0
- package/lib/components/icons/ArtifactIcon.d.ts +10 -0
- package/lib/components/icons/ArtifactIcon.js +58 -0
- package/lib/components/icons/index.d.ts +1 -0
- package/lib/components/icons/index.js +5 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/nbgrader/NbGradesDetails.d.ts +5 -0
- package/lib/components/nbgrader/NbGradesDetails.js +19 -0
- package/lib/components/nbgrader/index.d.ts +1 -0
- package/lib/components/nbgrader/index.js +5 -0
- package/lib/components/progress/CreditsIndicator.d.ts +33 -0
- package/lib/components/progress/CreditsIndicator.js +23 -0
- package/lib/components/progress/index.d.ts +2 -0
- package/lib/components/progress/index.js +6 -0
- package/lib/components/runtimes/RuntimeCellVariables.d.ts +39 -0
- package/lib/components/runtimes/RuntimeCellVariables.js +172 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.d.ts +37 -0
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +101 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +57 -0
- package/lib/components/runtimes/RuntimeLauncherDialog.js +275 -0
- package/lib/components/runtimes/RuntimePickerBase.d.ts +69 -0
- package/lib/components/runtimes/RuntimePickerBase.js +122 -0
- package/lib/components/runtimes/RuntimePickerCell.d.ts +34 -0
- package/lib/components/runtimes/RuntimePickerCell.js +104 -0
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +42 -0
- package/lib/components/runtimes/RuntimePickerNotebook.js +232 -0
- package/lib/components/runtimes/RuntimeReservationControl.d.ts +47 -0
- package/lib/components/runtimes/RuntimeReservationControl.js +42 -0
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +38 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +155 -0
- package/lib/components/runtimes/RuntimeTransfer.d.ts +16 -0
- package/lib/components/runtimes/RuntimeTransfer.js +5 -0
- package/lib/components/runtimes/RuntimeUtils.d.ts +17 -0
- package/lib/components/runtimes/RuntimeUtils.js +178 -0
- package/lib/components/runtimes/RuntimeVariables.d.ts +38 -0
- package/lib/components/runtimes/RuntimeVariables.js +75 -0
- package/lib/components/runtimes/index.d.ts +11 -0
- package/lib/components/runtimes/index.js +15 -0
- package/lib/components/scheduler/ScheduleMenu.d.ts +54 -0
- package/lib/components/scheduler/ScheduleMenu.js +154 -0
- package/lib/components/scheduler/index.d.ts +1 -0
- package/lib/components/scheduler/index.js +5 -0
- package/lib/components/snapshots/SandboxSnapshotMenu.d.ts +33 -0
- package/lib/components/snapshots/SandboxSnapshotMenu.js +169 -0
- package/lib/components/snapshots/index.d.ts +1 -0
- package/lib/components/snapshots/index.js +5 -0
- package/lib/components/snippets/SnippetDialog.d.ts +42 -0
- package/lib/components/snippets/SnippetDialog.js +42 -0
- package/lib/components/students/StudentItemStatus.d.ts +7 -0
- package/lib/components/students/StudentItemStatus.js +68 -0
- package/lib/components/students/index.d.ts +1 -0
- package/lib/components/students/index.js +5 -0
- package/lib/components/tokens/SpaceVariantToken.d.ts +5 -0
- package/lib/components/tokens/SpaceVariantToken.js +23 -0
- package/lib/components/tokens/index.d.ts +1 -0
- package/lib/components/tokens/index.js +5 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +4 -0
- package/lib/components/toolbars/AssignmentEditorToolbar.js +18 -0
- package/lib/components/toolbars/DocumentEditorToolbar.d.ts +2 -0
- package/lib/components/toolbars/DocumentEditorToolbar.js +12 -0
- package/lib/components/toolbars/NotebookEditorToolbar.d.ts +29 -0
- package/lib/components/toolbars/NotebookEditorToolbar.js +30 -0
- package/lib/context/ContextInspector.d.ts +1 -14
- package/lib/context/ContextInspector.js +3 -73
- package/lib/context/CostUsageChart.d.ts +4 -3
- package/lib/context/CostUsageChart.js +236 -35
- package/lib/context/MessageHistory.d.ts +30 -0
- package/lib/context/MessageHistory.js +129 -0
- package/lib/context/TokenUsageChart.d.ts +4 -3
- package/lib/context/TokenUsageChart.js +180 -30
- package/lib/context/TurnGraphChart.d.ts +1 -1
- package/lib/context/TurnGraphChart.js +6 -6
- package/lib/examples/A2UiAgentExample.d.ts +22 -0
- package/lib/examples/A2UiAgentExample.js +442 -0
- package/lib/examples/A2UiComponentsGalleryExample.d.ts +3 -0
- package/lib/examples/A2UiComponentsGalleryExample.js +863 -0
- package/lib/examples/A2UiContactCardExample.js +9 -5
- package/lib/examples/A2UiRestaurantExample.js +23 -8
- package/lib/examples/A2UiViewerExample.js +75 -3
- package/lib/examples/AgUiAgenticExample.d.ts +1 -12
- package/lib/examples/AgUiAgenticExample.js +52 -8
- package/lib/examples/AgUiBackendToolRenderingExample.d.ts +1 -16
- package/lib/examples/AgUiBackendToolRenderingExample.js +32 -17
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -17
- package/lib/examples/AgUiHaikuGenUiExample.js +49 -33
- package/lib/examples/AgUiHumanInTheLoopExample.d.ts +1 -12
- package/lib/examples/AgUiHumanInTheLoopExample.js +21 -6
- package/lib/examples/AgUiSharedStateExample.d.ts +1 -14
- package/lib/examples/AgUiSharedStateExample.js +21 -6
- package/lib/examples/AgUiToolsBasedGenUiExample.d.ts +1 -14
- package/lib/examples/AgUiToolsBasedGenUiExample.js +21 -6
- package/lib/examples/AgentCheckpointsExample.d.ts +1 -1
- package/lib/examples/AgentCheckpointsExample.js +9 -10
- package/lib/examples/AgentCodeSandboxesExample.d.ts +3 -0
- package/lib/examples/AgentCodeSandboxesExample.js +192 -0
- package/lib/examples/AgentCodemodeExample.js +3 -3
- package/lib/examples/AgentEvalsExample.js +5 -5
- package/lib/examples/AgentGuardrailsExample.js +17 -12
- package/lib/examples/AgentHooksExample.js +14 -55
- package/lib/examples/AgentInferenceProviderExample.js +4 -4
- package/lib/examples/AgentLoopExample.d.ts +10 -0
- package/lib/examples/AgentLoopExample.js +304 -0
- package/lib/examples/AgentMCPExample.js +7 -7
- package/lib/examples/AgentMemoryExample.js +4 -4
- package/lib/examples/AgentMonitoringExample.js +114 -44
- package/lib/examples/AgentNotificationsExample.js +4 -4
- package/lib/examples/AgentOtelExample.d.ts +3 -3
- package/lib/examples/AgentOtelExample.js +15 -10
- package/lib/examples/AgentOutputsExample.js +6 -6
- package/lib/examples/AgentParametersExample.js +21 -33
- package/lib/examples/AgentSandboxExample.js +5 -5
- package/lib/examples/AgentSkillsExample.js +7 -7
- package/lib/examples/AgentSubagentsExample.js +4 -4
- package/lib/examples/AgentToolApprovalsExample.js +5 -5
- package/lib/examples/AgentTriggersExample.js +9 -9
- package/lib/examples/AgentspecsExample.js +63 -41
- package/lib/examples/ChatCustomExample.js +23 -77
- package/lib/examples/ChatExample.js +13 -44
- package/lib/examples/LexicalAgentExample.js +43 -91
- package/lib/examples/LexicalAgentSidebarExample.js +45 -73
- package/lib/examples/NotebookAgentExample.js +52 -81
- package/lib/examples/NotebookAgentSidebarExample.js +43 -71
- package/lib/examples/NotebookCollaborationExample.js +11 -9
- package/lib/examples/NotebookExample.js +5 -2
- package/lib/examples/components/AuthRequiredView.js +1 -1
- package/lib/examples/components/ExampleErrorBoundary.d.ts +46 -0
- package/lib/examples/components/ExampleErrorBoundary.js +67 -0
- package/lib/examples/components/haiku/haiku-card.css +11 -0
- package/lib/examples/components/weather/weather-card.css +11 -0
- package/lib/examples/example-selector.js +4 -1
- package/lib/examples/hooks/useExampleAgentRuntime.d.ts +35 -0
- package/lib/examples/hooks/useExampleAgentRuntime.js +82 -0
- package/lib/examples/hooks/useSpecRenderToolResult.d.ts +30 -0
- package/lib/examples/hooks/useSpecRenderToolResult.js +61 -0
- package/lib/examples/index.d.ts +4 -1
- package/lib/examples/index.js +4 -1
- package/lib/examples/main.js +340 -93
- package/lib/examples/utils/a2ui.d.ts +2 -0
- package/lib/examples/utils/a2ui.js +97 -2
- package/lib/examples/utils/agentSummaryStore.d.ts +21 -0
- package/lib/examples/utils/agentSummaryStore.js +23 -0
- package/lib/examples/utils/notebooks/Empty.ipynb.json +30 -30
- package/lib/examples/utils/runtimeTargetStore.d.ts +9 -0
- package/lib/examples/utils/runtimeTargetStore.js +27 -0
- package/lib/examples/utils/teardownAgents.d.ts +13 -0
- package/lib/examples/utils/teardownAgents.js +78 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +2 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +26 -7
- package/lib/examples2/CellExample.d.ts +6 -0
- package/lib/examples2/CellExample.js +20 -0
- package/lib/examples2/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples2/DatalayerNotebookExample.js +109 -0
- package/lib/examples2/NativeNavigationExample.d.ts +8 -0
- package/lib/examples2/NativeNavigationExample.js +97 -0
- package/lib/examples2/NotebookExample.d.ts +6 -0
- package/lib/examples2/NotebookExample.js +19 -0
- package/lib/examples2/NotebookMutationsKernel.d.ts +2 -0
- package/lib/examples2/NotebookMutationsKernel.js +105 -0
- package/lib/examples2/NotebookMutationsServiceManager.d.ts +2 -0
- package/lib/examples2/NotebookMutationsServiceManager.js +109 -0
- package/lib/examples2/ReactRouterExample.d.ts +6 -0
- package/lib/examples2/ReactRouterExample.js +175 -0
- package/lib/examples2/example-selector.d.ts +22 -0
- package/lib/examples2/example-selector.js +45 -0
- package/lib/examples2/index.d.ts +2 -0
- package/lib/examples2/index.js +6 -0
- package/lib/examples2/lexical-theme.css +436 -0
- package/lib/examples2/main.d.ts +2 -0
- package/lib/examples2/main.js +330 -0
- package/lib/examples2/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples2/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples2/notebooks/Lite.ipynb.json +128 -0
- package/lib/examples2/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples2/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples2/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples2/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples2/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples2/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples2/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples2/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/hooks/index.d.ts +9 -1
- package/lib/hooks/index.js +13 -1
- package/lib/hooks/useAIAgentsWebSocket.d.ts +1 -1
- package/lib/hooks/useAIAgentsWebSocket.js +39 -3
- package/lib/hooks/useAgentRuntimes.d.ts +15 -3
- package/lib/hooks/useAgentRuntimes.js +186 -27
- package/lib/hooks/useAgentsService.js +5 -5
- package/lib/hooks/useCellOutputshot.d.ts +4 -0
- package/lib/hooks/useCellOutputshot.js +25 -0
- package/lib/hooks/useCheckpoints.d.ts +8 -8
- package/lib/hooks/useCheckpoints.js +36 -26
- package/lib/hooks/useConfig.d.ts +1 -1
- package/lib/hooks/useMonitoring.d.ts +7 -5
- package/lib/hooks/useMonitoring.js +16 -10
- package/lib/hooks/useNotifications.d.ts +11 -11
- package/lib/hooks/useNotifications.js +1 -1
- package/lib/hooks/useProgressStore.d.ts +25 -0
- package/lib/hooks/useProgressStore.js +58 -0
- package/lib/hooks/useProgressTask.d.ts +9 -0
- package/lib/hooks/useProgressTask.js +41 -0
- package/lib/hooks/useProjects.d.ts +628 -0
- package/lib/hooks/useProjects.js +190 -0
- package/lib/hooks/useRuntimes.d.ts +5 -0
- package/lib/hooks/useRuntimes.js +34 -0
- package/lib/hooks/useToolApprovals.d.ts +6 -6
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/jupyter/exec/Python.d.ts +5 -0
- package/lib/jupyter/exec/Python.js +100 -0
- package/lib/jupyter/exec/Snippets.d.ts +105 -0
- package/lib/jupyter/exec/Snippets.js +101 -0
- package/lib/jupyter/exec/index.d.ts +2 -0
- package/lib/jupyter/exec/index.js +6 -0
- package/lib/jupyter/index.d.ts +2 -0
- package/lib/jupyter/index.js +6 -0
- package/lib/jupyter/kernelsHandler.d.ts +8 -0
- package/lib/jupyter/kernelsHandler.js +39 -0
- package/lib/mocks/models/CourseMock.d.ts +6 -0
- package/lib/mocks/models/CourseMock.js +29 -0
- package/lib/mocks/models/SpaceMock.d.ts +6 -0
- package/lib/mocks/models/SpaceMock.js +25 -0
- package/lib/models/Assignment.d.ts +7 -0
- package/lib/models/Assignment.js +5 -0
- package/lib/models/Cell.d.ts +8 -0
- package/lib/models/Cell.js +5 -0
- package/lib/models/CodeBlock.d.ts +10 -0
- package/lib/models/CodeBlock.js +5 -0
- package/lib/models/CodeSandboxSnapshot.d.ts +92 -0
- package/lib/models/CodeSandboxSnapshot.js +13 -0
- package/lib/models/CodeSandboxSnapshotDTO.d.ts +173 -0
- package/lib/models/CodeSandboxSnapshotDTO.js +139 -0
- package/lib/models/CodefeedBlocks.d.ts +7 -0
- package/lib/models/CodefeedBlocks.js +5 -0
- package/lib/models/Content.d.ts +5 -0
- package/lib/models/Content.js +5 -0
- package/lib/models/Course.d.ts +17 -0
- package/lib/models/Course.js +5 -0
- package/lib/models/Dataset.d.ts +16 -0
- package/lib/models/Dataset.js +5 -0
- package/lib/models/Document.d.ts +8 -0
- package/lib/models/Document.js +5 -0
- package/lib/models/Environment.d.ts +86 -0
- package/lib/models/Environment.js +5 -0
- package/lib/models/EnvironmentDTO.d.ts +125 -0
- package/lib/models/EnvironmentDTO.js +88 -0
- package/lib/models/Exercise.d.ts +16 -0
- package/lib/models/Exercise.js +5 -0
- package/lib/models/Item.d.ts +20 -0
- package/lib/models/Item.js +5 -0
- package/lib/models/ItemDTO.d.ts +74 -0
- package/lib/models/ItemDTO.js +186 -0
- package/lib/models/ItemType.d.ts +2 -0
- package/lib/models/ItemType.js +5 -0
- package/lib/models/Lesson.d.ts +5 -0
- package/lib/models/Lesson.js +5 -0
- package/lib/models/LexicalDTO.d.ts +155 -0
- package/lib/models/LexicalDTO.js +157 -0
- package/lib/models/Library.d.ts +10 -0
- package/lib/models/Library.js +5 -0
- package/lib/models/Notebook.d.ts +11 -0
- package/lib/models/Notebook.js +5 -0
- package/lib/models/NotebookDTO.d.ts +96 -0
- package/lib/models/NotebookDTO.js +153 -0
- package/lib/models/Page.d.ts +41 -0
- package/lib/models/Page.js +25 -0
- package/lib/models/PageTag.d.ts +19 -0
- package/lib/models/PageTag.js +94 -0
- package/lib/models/ProjectDTO.d.ts +89 -0
- package/lib/models/ProjectDTO.js +131 -0
- package/lib/models/Runtime.d.ts +160 -0
- package/lib/models/Runtime.js +18 -0
- package/lib/models/RuntimeDTO.d.ts +172 -0
- package/lib/models/RuntimeDTO.js +204 -0
- package/lib/models/Space.d.ts +35 -0
- package/lib/models/Space.js +66 -0
- package/lib/models/SpaceDTO.d.ts +334 -0
- package/lib/models/SpaceDTO.js +244 -0
- package/lib/models/SpaceItem.d.ts +10 -0
- package/lib/models/SpaceItem.js +5 -0
- package/lib/models/SpaceMember.d.ts +6 -0
- package/lib/models/SpaceMember.js +5 -0
- package/lib/models/StudentItem.d.ts +21 -0
- package/lib/models/StudentItem.js +5 -0
- package/lib/models/index.d.ts +32 -0
- package/lib/models/index.js +39 -0
- package/lib/protocols/AGUIAdapter.js +1 -1
- package/lib/runtimes/actions.d.ts +102 -0
- package/lib/runtimes/actions.js +249 -0
- package/lib/runtimes/apis.d.ts +273 -0
- package/lib/runtimes/apis.js +5 -0
- package/lib/runtimes/index.d.ts +5 -0
- package/lib/runtimes/index.js +9 -0
- package/lib/runtimes/settings.d.ts +15 -0
- package/lib/runtimes/settings.js +31 -0
- package/lib/runtimes/snapshots.d.ts +25 -0
- package/lib/runtimes/snapshots.js +150 -0
- package/lib/runtimes/utils.d.ts +7 -0
- package/lib/runtimes/utils.js +14 -0
- package/lib/services/DatalayerServiceManager.d.ts +23 -0
- package/lib/services/DatalayerServiceManager.js +90 -0
- package/lib/services/reconnectToRuntime.d.ts +32 -0
- package/lib/services/reconnectToRuntime.js +59 -0
- package/lib/services/sandboxServiceManagers.d.ts +31 -0
- package/lib/services/sandboxServiceManagers.js +57 -0
- package/lib/specs/agents/agents.d.ts +78 -26
- package/lib/specs/agents/agents.js +4434 -1639
- package/lib/specs/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- package/lib/specs/loops.d.ts +34 -0
- package/lib/specs/loops.js +188 -0
- package/lib/specs/mcpServers.d.ts +1 -0
- package/lib/specs/mcpServers.js +17 -0
- package/lib/specs/models.d.ts +4 -0
- package/lib/specs/models.js +30 -0
- package/lib/specs/skills.d.ts +1 -0
- package/lib/specs/skills.js +18 -0
- package/lib/specs/tools.d.ts +15 -0
- package/lib/specs/tools.js +285 -0
- package/lib/state/index.d.ts +4 -0
- package/lib/state/index.js +10 -0
- package/lib/state/substates/CellState.d.ts +12 -0
- package/lib/state/substates/CellState.js +22 -0
- package/lib/state/substates/DocumentState.d.ts +10 -0
- package/lib/state/substates/DocumentState.js +14 -0
- package/lib/state/substates/GradeState.d.ts +10 -0
- package/lib/state/substates/GradeState.js +14 -0
- package/lib/state/substates/JupyterLabState.d.ts +16 -0
- package/lib/state/substates/JupyterLabState.js +17 -0
- package/lib/state/substates/NbformatState.d.ts +13 -0
- package/lib/state/substates/NbformatState.js +16 -0
- package/lib/state/substates/RuntimesState.d.ts +87 -0
- package/lib/state/substates/RuntimesState.js +192 -0
- package/lib/state/substates/SpaceState.d.ts +11 -0
- package/lib/state/substates/SpaceState.js +16 -0
- package/lib/state/substates/index.d.ts +8 -0
- package/lib/state/substates/index.js +14 -0
- package/lib/stores/agentRuntimeStore.d.ts +25 -2
- package/lib/stores/agentRuntimeStore.js +114 -19
- package/lib/stories/Button.stories.d.ts +1 -1
- package/lib/stories/Header.stories.d.ts +3 -3
- package/lib/test-setup.js +10 -0
- package/lib/types/agents-lifecycle.d.ts +5 -5
- package/lib/types/agents.d.ts +3 -3
- package/lib/types/agentspecs.d.ts +4 -2
- package/lib/types/chat.d.ts +135 -3
- package/lib/types/config.d.ts +19 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/loops.d.ts +64 -0
- package/lib/types/loops.js +5 -0
- package/lib/types/tools.d.ts +16 -0
- package/lib/utils/Cells.d.ts +2 -0
- package/lib/utils/Cells.js +28 -0
- package/package.json +24 -18
- package/scripts/codegen/__pycache__/generate_sandbox_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +21 -4
- package/scripts/codegen/generate_loops.py +443 -0
- package/scripts/codegen/generate_sandbox_agents.py +145 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -3
- package/lib/examples/A2UiComponentGalleryExample.js +0 -361
- /package/lib/{agent-lexical-main.d.ts → agent-document-main.d.ts} +0 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A2UiAgentExample
|
|
8
|
+
*
|
|
9
|
+
* A comprehensive, real-world A2UI generative-UI example. The agent
|
|
10
|
+
* (agentspec: `example-a2ui-agent`) exposes a single backend tool,
|
|
11
|
+
* `render_a2ui_surface`, that turns a natural-language request into a
|
|
12
|
+
* validated A2UI v0.9 surface (createSurface + updateComponents +
|
|
13
|
+
* updateDataModel). The frontend renders the returned messages live:
|
|
14
|
+
*
|
|
15
|
+
* - INLINE in the chat as a compact confirmation card.
|
|
16
|
+
* - In the main canvas as a fully interactive A2UI surface (forms, cards,
|
|
17
|
+
* choice pickers, sliders, date pickers, ...).
|
|
18
|
+
*
|
|
19
|
+
* Submitting the rendered surface emits an A2UI client action which we display
|
|
20
|
+
* in a "Submitted values" panel, closing the generate → interact loop.
|
|
21
|
+
*
|
|
22
|
+
* This mirrors the working tool-based generative UI pattern (see
|
|
23
|
+
* AgUiHaikuGenUiExample) but renders A2UI surfaces instead of bespoke cards.
|
|
24
|
+
*/
|
|
25
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
26
|
+
import { Box, setupPrimerPortals } from '@datalayer/primer-addons';
|
|
27
|
+
import { Button, Spinner, Text } from '@primer/react';
|
|
28
|
+
import { basicCatalog } from '@a2ui/react/v0_9';
|
|
29
|
+
import { A2UI_RENDER_SCOPE_SX, A2uiSurfaceComposed } from '../components/a2ui';
|
|
30
|
+
import { ThemedProvider } from './utils/themedProvider';
|
|
31
|
+
import { A2uiMarkdownProvider } from './utils/a2uiMarkdownProvider';
|
|
32
|
+
import { useA2uiProcessor } from './utils/a2ui';
|
|
33
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
34
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
35
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
36
|
+
import { useSpecRenderToolResult, specRendererClassName, } from './hooks/useSpecRenderToolResult';
|
|
37
|
+
import { Chat } from '../chat';
|
|
38
|
+
setupPrimerPortals();
|
|
39
|
+
const AGENT_NAME = 'a2ui-agent';
|
|
40
|
+
const AGENTSPEC_ID = 'example-a2ui-agent';
|
|
41
|
+
const SUGGESTIONS = [
|
|
42
|
+
{
|
|
43
|
+
title: 'Support ticket intake',
|
|
44
|
+
message: 'Build a support ticket intake form with category, priority and a description.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'Trip booking',
|
|
48
|
+
message: 'Create a trip booking form with destination, dates, travelers and budget.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: 'Feedback survey',
|
|
52
|
+
message: 'Generate a customer feedback survey with a rating slider and comments.',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Product configurator',
|
|
56
|
+
message: 'Make a product configurator for a laptop with CPU, RAM and add-ons.',
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Whether a submitted form value should count as "not provided" for the
|
|
61
|
+
* purpose of required-field validation. Handles the value shapes the A2UI
|
|
62
|
+
* basic catalog emits: strings (text/email), arrays (choice), booleans
|
|
63
|
+
* (checkbox).
|
|
64
|
+
*/
|
|
65
|
+
function isEmptyValue(value) {
|
|
66
|
+
if (value === null || value === undefined) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === 'string') {
|
|
70
|
+
return value.trim() === '';
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
return value.length === 0;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === 'boolean') {
|
|
76
|
+
return value === false;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Basic email format check (matches the intent of the backend `email` field
|
|
82
|
+
* type). Intentionally permissive: requires `local@domain.tld` with no spaces.
|
|
83
|
+
*/
|
|
84
|
+
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
85
|
+
/**
|
|
86
|
+
* Validate a single submitted value against its backend-provided rule. Returns
|
|
87
|
+
* a human-readable error message, or `null` when the value is acceptable.
|
|
88
|
+
*/
|
|
89
|
+
function validateFieldValue(rule, value) {
|
|
90
|
+
const empty = isEmptyValue(value);
|
|
91
|
+
if (empty) {
|
|
92
|
+
// Optional fields left blank are fine; only required ones fail here.
|
|
93
|
+
return rule.required ? `${rule.label} is required.` : null;
|
|
94
|
+
}
|
|
95
|
+
if (rule.format === 'email' &&
|
|
96
|
+
typeof value === 'string' &&
|
|
97
|
+
!EMAIL_PATTERN.test(value.trim())) {
|
|
98
|
+
return `${rule.label} must be a valid email address.`;
|
|
99
|
+
}
|
|
100
|
+
if (rule.pattern && typeof value === 'string') {
|
|
101
|
+
let matches = true;
|
|
102
|
+
try {
|
|
103
|
+
matches = new RegExp(rule.pattern).test(value.trim());
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
matches = true; // Ignore malformed patterns rather than blocking.
|
|
107
|
+
}
|
|
108
|
+
if (!matches) {
|
|
109
|
+
return `${rule.label} is not in the expected format.`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (rule.minLength !== undefined &&
|
|
113
|
+
typeof value === 'string' &&
|
|
114
|
+
value.trim().length < rule.minLength) {
|
|
115
|
+
return `${rule.label} must be at least ${rule.minLength} characters.`;
|
|
116
|
+
}
|
|
117
|
+
if (rule.type === 'slider' && typeof value === 'number') {
|
|
118
|
+
if (rule.min !== undefined && value < rule.min) {
|
|
119
|
+
return `${rule.label} must be at least ${rule.min}.`;
|
|
120
|
+
}
|
|
121
|
+
if (rule.max !== undefined && value > rule.max) {
|
|
122
|
+
return `${rule.label} must be at most ${rule.max}.`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Normalize a backend tool result (object or JSON string) into A2UI messages,
|
|
129
|
+
* rewriting the catalog id to the frontend catalog so the renderer accepts it.
|
|
130
|
+
*/
|
|
131
|
+
function extractToolResult(result) {
|
|
132
|
+
if (!result) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
let obj = result;
|
|
136
|
+
if (typeof result === 'string') {
|
|
137
|
+
try {
|
|
138
|
+
obj = JSON.parse(result);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (typeof obj !== 'object' ||
|
|
145
|
+
obj === null ||
|
|
146
|
+
!Array.isArray(obj.messages)) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const parsed = obj;
|
|
150
|
+
const messages = (parsed.messages ?? []).map(message => {
|
|
151
|
+
const payload = message;
|
|
152
|
+
if (payload.createSurface &&
|
|
153
|
+
payload.createSurface.catalogId !== basicCatalog.id) {
|
|
154
|
+
return {
|
|
155
|
+
...payload,
|
|
156
|
+
createSurface: {
|
|
157
|
+
...payload.createSurface,
|
|
158
|
+
catalogId: basicCatalog.id,
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return message;
|
|
163
|
+
});
|
|
164
|
+
return { ...parsed, messages };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Renders a fully interactive A2UI surface *inline* in the chat transcript.
|
|
168
|
+
*
|
|
169
|
+
* Uses its own `useA2uiProcessor` instance (independent from the canvas
|
|
170
|
+
* processor) so the same generated surface can be filled in and submitted from
|
|
171
|
+
* both places. Messages are processed once on mount.
|
|
172
|
+
*/
|
|
173
|
+
const InlineA2uiSurface = ({ messages, onAction, validationError }) => {
|
|
174
|
+
const { surfaces, processMessages, resetSurfaces, themeStyle } = useA2uiProcessor(onAction);
|
|
175
|
+
const processedRef = useRef(false);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (processedRef.current) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
processedRef.current = true;
|
|
181
|
+
resetSurfaces();
|
|
182
|
+
processMessages(messages);
|
|
183
|
+
}, [messages, processMessages, resetSurfaces]);
|
|
184
|
+
if (surfaces.length === 0) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return (_jsxs(Box, { style: themeStyle, sx: {
|
|
188
|
+
...A2UI_RENDER_SCOPE_SX,
|
|
189
|
+
display: 'flex',
|
|
190
|
+
flexDirection: 'column',
|
|
191
|
+
gap: 2,
|
|
192
|
+
}, children: [validationError && (_jsx(Box, { role: "alert", sx: {
|
|
193
|
+
px: 3,
|
|
194
|
+
py: 2,
|
|
195
|
+
borderRadius: 2,
|
|
196
|
+
bg: 'danger.subtle',
|
|
197
|
+
border: '1px solid',
|
|
198
|
+
borderColor: 'danger.muted',
|
|
199
|
+
color: 'danger.fg',
|
|
200
|
+
fontSize: 1,
|
|
201
|
+
}, children: validationError })), surfaces.map(surface => (_jsx(Box, { sx: {
|
|
202
|
+
border: '1px solid',
|
|
203
|
+
borderColor: 'border.default',
|
|
204
|
+
borderRadius: 2,
|
|
205
|
+
p: 3,
|
|
206
|
+
bg: 'canvas.default',
|
|
207
|
+
}, children: _jsx(A2uiSurfaceComposed, { surface: surface }) }, surface.id)))] }));
|
|
208
|
+
};
|
|
209
|
+
const A2UiAgentExample = () => {
|
|
210
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
211
|
+
const agentName = useMemo(() => uniqueAgentId(AGENT_NAME), []);
|
|
212
|
+
const { agentId, error: chatError, status, isReady, } = useExampleAgentRuntime({
|
|
213
|
+
exampleId: 'A2UiAgentExample',
|
|
214
|
+
agentName,
|
|
215
|
+
specId: AGENTSPEC_ID,
|
|
216
|
+
agentConfig: {
|
|
217
|
+
protocol: 'ag-ui',
|
|
218
|
+
agentSpecId: AGENTSPEC_ID,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
const isCreatingChat = !isReady && status !== 'error';
|
|
222
|
+
const [surfaceTitle, setSurfaceTitle] = useState(null);
|
|
223
|
+
const [submissions, setSubmissions] = useState([]);
|
|
224
|
+
const [pendingPrompt, setPendingPrompt] = useState(undefined);
|
|
225
|
+
const [validationError, setValidationError] = useState(null);
|
|
226
|
+
const submissionSeq = useRef(0);
|
|
227
|
+
// Validation rules per surface id, populated from each tool result so the
|
|
228
|
+
// (stable) action handler can block submission of an invalid form.
|
|
229
|
+
const fieldRulesBySurfaceRef = useRef({});
|
|
230
|
+
// Keep the latest surface title in a ref so the (stable) action handler can
|
|
231
|
+
// reference it without being re-created on every render.
|
|
232
|
+
const surfaceTitleRef = useRef(null);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
surfaceTitleRef.current = surfaceTitle;
|
|
235
|
+
}, [surfaceTitle]);
|
|
236
|
+
// Handle A2UI actions emitted by the rendered surface (e.g. form submit).
|
|
237
|
+
const handleAction = useCallback((action) => {
|
|
238
|
+
if (action.name === 'submit_a2ui_form') {
|
|
239
|
+
const values = (action.context ?? {});
|
|
240
|
+
// Block submission when any field fails validation (required, email
|
|
241
|
+
// format, pattern, length, slider range).
|
|
242
|
+
const rules = fieldRulesBySurfaceRef.current[action.surfaceId] ?? [];
|
|
243
|
+
const errors = rules
|
|
244
|
+
.map(rule => validateFieldValue(rule, values[rule.id]))
|
|
245
|
+
.filter((message) => message !== null);
|
|
246
|
+
if (errors.length > 0) {
|
|
247
|
+
setValidationError({
|
|
248
|
+
surfaceId: action.surfaceId,
|
|
249
|
+
message: errors.join(' '),
|
|
250
|
+
});
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
setValidationError(null);
|
|
254
|
+
submissionSeq.current += 1;
|
|
255
|
+
const seq = submissionSeq.current;
|
|
256
|
+
setSubmissions(prev => [
|
|
257
|
+
{
|
|
258
|
+
id: seq,
|
|
259
|
+
values,
|
|
260
|
+
},
|
|
261
|
+
...prev,
|
|
262
|
+
]);
|
|
263
|
+
// Feed the submission back to the agent so it replies with a confirmation.
|
|
264
|
+
const title = surfaceTitleRef.current ?? 'the form';
|
|
265
|
+
const json = JSON.stringify(values, null, 2);
|
|
266
|
+
setPendingPrompt(`I just submitted "${title}" (submission #${seq}). Here are the values:\n\n\`\`\`json\n${json}\n\`\`\`\n\nPlease confirm you received them and briefly summarize what happens next.`);
|
|
267
|
+
}
|
|
268
|
+
}, []);
|
|
269
|
+
const { surfaces, processMessages, resetSurfaces, themeStyle } = useA2uiProcessor(handleAction);
|
|
270
|
+
// Stable ref so the memoized renderer can push surfaces without re-creating.
|
|
271
|
+
const showSurfaceRef = useRef(() => { });
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
showSurfaceRef.current = (messages) => {
|
|
274
|
+
resetSurfaces();
|
|
275
|
+
processMessages(messages);
|
|
276
|
+
};
|
|
277
|
+
}, [resetSurfaces, processMessages]);
|
|
278
|
+
const processedToolCallIds = useRef(new Set());
|
|
279
|
+
const renderers = useMemo(() => ({
|
|
280
|
+
'a2ui-surface': (context, binding) => {
|
|
281
|
+
const parsed = context.status === 'complete'
|
|
282
|
+
? extractToolResult(context.result)
|
|
283
|
+
: null;
|
|
284
|
+
if (context.status === 'complete' &&
|
|
285
|
+
parsed?.messages &&
|
|
286
|
+
parsed.messages.length > 0 &&
|
|
287
|
+
context.toolCallId &&
|
|
288
|
+
!processedToolCallIds.current.has(context.toolCallId)) {
|
|
289
|
+
processedToolCallIds.current.add(context.toolCallId);
|
|
290
|
+
showSurfaceRef.current(parsed.messages);
|
|
291
|
+
setSurfaceTitle(parsed.title ?? 'A2UI surface');
|
|
292
|
+
if (parsed.surfaceId) {
|
|
293
|
+
fieldRulesBySurfaceRef.current[parsed.surfaceId] =
|
|
294
|
+
parsed.fieldRules ?? [];
|
|
295
|
+
}
|
|
296
|
+
setValidationError(null);
|
|
297
|
+
}
|
|
298
|
+
return (_jsx("div", { className: specRendererClassName(binding), children: context.status === 'complete' &&
|
|
299
|
+
parsed?.messages &&
|
|
300
|
+
parsed.messages.length > 0 ? (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsxs(Box, { sx: {
|
|
301
|
+
display: 'flex',
|
|
302
|
+
alignItems: 'center',
|
|
303
|
+
gap: 2,
|
|
304
|
+
color: 'fg.muted',
|
|
305
|
+
}, children: [_jsx(Text, { sx: { fontSize: 2 }, children: "\uD83C\uDF9B\uFE0F" }), _jsx(Text, { sx: { fontWeight: 'bold', color: 'fg.default' }, children: parsed.title ?? 'A2UI surface' }), _jsx(Text, { sx: { fontSize: 0 }, children: "\u00B7 also in the canvas \u2192 fill it in and submit" })] }), _jsx(InlineA2uiSurface, { messages: parsed.messages, onAction: handleAction, validationError: validationError &&
|
|
306
|
+
parsed.surfaceId &&
|
|
307
|
+
validationError.surfaceId === parsed.surfaceId
|
|
308
|
+
? validationError.message
|
|
309
|
+
: null })] })) : (_jsxs(Box, { sx: {
|
|
310
|
+
border: '1px solid',
|
|
311
|
+
borderColor: 'border.default',
|
|
312
|
+
borderRadius: 2,
|
|
313
|
+
px: 3,
|
|
314
|
+
py: 2,
|
|
315
|
+
bg: 'canvas.subtle',
|
|
316
|
+
display: 'flex',
|
|
317
|
+
alignItems: 'center',
|
|
318
|
+
gap: 2,
|
|
319
|
+
}, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Rendering A2UI surface..." })] })) }));
|
|
320
|
+
},
|
|
321
|
+
}), [handleAction, validationError]);
|
|
322
|
+
const renderToolResult = useSpecRenderToolResult(AGENTSPEC_ID, renderers);
|
|
323
|
+
const clearCanvas = useCallback(() => {
|
|
324
|
+
resetSurfaces();
|
|
325
|
+
setSurfaceTitle(null);
|
|
326
|
+
setValidationError(null);
|
|
327
|
+
}, [resetSurfaces]);
|
|
328
|
+
return (_jsx(ThemedProvider, { children: _jsx(A2uiMarkdownProvider, { children: _jsxs(Box, { sx: {
|
|
329
|
+
minHeight: '100vh',
|
|
330
|
+
height: ['auto', 'auto', '100dvh'],
|
|
331
|
+
boxSizing: 'border-box',
|
|
332
|
+
overflow: ['visible', 'visible', 'hidden'],
|
|
333
|
+
display: 'grid',
|
|
334
|
+
gridTemplateColumns: [
|
|
335
|
+
'1fr',
|
|
336
|
+
'1fr',
|
|
337
|
+
'minmax(360px, 1fr) minmax(360px, 460px)',
|
|
338
|
+
],
|
|
339
|
+
gap: 3,
|
|
340
|
+
p: 3,
|
|
341
|
+
bg: 'canvas.default',
|
|
342
|
+
}, children: [_jsxs(Box, { sx: {
|
|
343
|
+
display: 'flex',
|
|
344
|
+
flexDirection: 'column',
|
|
345
|
+
gap: 3,
|
|
346
|
+
minHeight: 0,
|
|
347
|
+
overflowY: ['visible', 'visible', 'auto'],
|
|
348
|
+
}, children: [_jsxs(Box, { sx: {
|
|
349
|
+
border: '1px solid',
|
|
350
|
+
borderColor: 'border.default',
|
|
351
|
+
borderRadius: 2,
|
|
352
|
+
overflow: 'hidden',
|
|
353
|
+
}, children: [_jsxs(Box, { sx: {
|
|
354
|
+
px: 3,
|
|
355
|
+
py: 2,
|
|
356
|
+
borderBottom: '1px solid',
|
|
357
|
+
borderColor: 'border.default',
|
|
358
|
+
bg: 'canvas.subtle',
|
|
359
|
+
display: 'flex',
|
|
360
|
+
justifyContent: 'space-between',
|
|
361
|
+
alignItems: 'center',
|
|
362
|
+
}, children: [_jsxs(Box, { children: [_jsx(Text, { as: "h1", sx: { fontSize: 2, fontWeight: 'bold' }, children: "A2UI Agent" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Ask the agent to build a UI \u2014 it renders a live A2UI surface." })] }), surfaces.length > 0 && (_jsx(Button, { size: "small", variant: "invisible", onClick: clearCanvas, children: "Clear" }))] }), _jsx(Box, { style: themeStyle, sx: {
|
|
363
|
+
...A2UI_RENDER_SCOPE_SX,
|
|
364
|
+
p: 3,
|
|
365
|
+
display: 'flex',
|
|
366
|
+
flexDirection: 'column',
|
|
367
|
+
gap: 3,
|
|
368
|
+
}, children: surfaces.length === 0 ? (_jsxs(Box, { sx: {
|
|
369
|
+
textAlign: 'center',
|
|
370
|
+
py: 6,
|
|
371
|
+
px: 3,
|
|
372
|
+
color: 'fg.muted',
|
|
373
|
+
border: '2px dashed',
|
|
374
|
+
borderColor: 'border.muted',
|
|
375
|
+
borderRadius: 2,
|
|
376
|
+
}, children: [_jsx(Text, { sx: { fontSize: 4, display: 'block', mb: 2 }, children: "\uD83C\uDF9B\uFE0F" }), _jsxs(Text, { sx: { fontSize: 1, display: 'block' }, children: ["No surface yet. Try a suggestion in the chat, e.g.", ' ', _jsxs(Text, { as: "span", sx: { fontStyle: 'italic' }, children: ["\"", SUGGESTIONS[0].message, "\""] })] })] })) : (_jsxs(_Fragment, { children: [surfaceTitle && (_jsx(Text, { sx: { fontWeight: 'bold', color: 'fg.default' }, children: surfaceTitle })), validationError && (_jsx(Box, { role: "alert", sx: {
|
|
377
|
+
px: 3,
|
|
378
|
+
py: 2,
|
|
379
|
+
borderRadius: 2,
|
|
380
|
+
bg: 'danger.subtle',
|
|
381
|
+
border: '1px solid',
|
|
382
|
+
borderColor: 'danger.muted',
|
|
383
|
+
color: 'danger.fg',
|
|
384
|
+
fontSize: 1,
|
|
385
|
+
}, children: validationError.message })), surfaces.map(surface => (_jsx(Box, { sx: {
|
|
386
|
+
border: '1px solid',
|
|
387
|
+
borderColor: 'border.default',
|
|
388
|
+
borderRadius: 2,
|
|
389
|
+
p: 3,
|
|
390
|
+
bg: 'canvas.default',
|
|
391
|
+
}, children: _jsx(A2uiSurfaceComposed, { surface: surface }) }, surface.id)))] })) })] }), submissions.length > 0 && (_jsxs(Box, { sx: {
|
|
392
|
+
border: '1px solid',
|
|
393
|
+
borderColor: 'border.default',
|
|
394
|
+
borderRadius: 2,
|
|
395
|
+
overflow: 'hidden',
|
|
396
|
+
}, children: [_jsxs(Box, { sx: {
|
|
397
|
+
px: 3,
|
|
398
|
+
py: 2,
|
|
399
|
+
borderBottom: '1px solid',
|
|
400
|
+
borderColor: 'border.default',
|
|
401
|
+
bg: 'success.subtle',
|
|
402
|
+
display: 'flex',
|
|
403
|
+
justifyContent: 'space-between',
|
|
404
|
+
alignItems: 'center',
|
|
405
|
+
}, children: [_jsx(Text, { sx: { fontWeight: 'bold' }, children: "Submitted values" }), _jsx(Button, { size: "small", variant: "invisible", onClick: () => setSubmissions([]), children: "Clear" })] }), _jsx(Box, { sx: {
|
|
406
|
+
p: 3,
|
|
407
|
+
display: 'flex',
|
|
408
|
+
flexDirection: 'column',
|
|
409
|
+
gap: 2,
|
|
410
|
+
}, children: submissions.map(record => (_jsx(Box, { as: "pre", sx: {
|
|
411
|
+
m: 0,
|
|
412
|
+
p: 2,
|
|
413
|
+
borderRadius: 2,
|
|
414
|
+
bg: 'canvas.subtle',
|
|
415
|
+
border: '1px solid',
|
|
416
|
+
borderColor: 'border.default',
|
|
417
|
+
fontSize: 0,
|
|
418
|
+
overflow: 'auto',
|
|
419
|
+
whiteSpace: 'pre-wrap',
|
|
420
|
+
}, children: JSON.stringify(record.values, null, 2) }, record.id))) })] }))] }), _jsx(Box, { sx: {
|
|
421
|
+
position: ['static', 'static', 'sticky'],
|
|
422
|
+
top: [0, 0, 3],
|
|
423
|
+
alignSelf: ['auto', 'auto', 'start'],
|
|
424
|
+
border: '1px solid',
|
|
425
|
+
borderColor: 'border.default',
|
|
426
|
+
borderRadius: 2,
|
|
427
|
+
display: 'flex',
|
|
428
|
+
flexDirection: 'column',
|
|
429
|
+
height: ['auto', 'auto', 'calc(100vh - 48px)'],
|
|
430
|
+
minHeight: [420, 520, 0],
|
|
431
|
+
overflow: 'hidden',
|
|
432
|
+
bg: 'canvas.default',
|
|
433
|
+
}, children: isCreatingChat ? (_jsxs(Box, { sx: {
|
|
434
|
+
display: 'flex',
|
|
435
|
+
flexDirection: 'column',
|
|
436
|
+
alignItems: 'center',
|
|
437
|
+
justifyContent: 'center',
|
|
438
|
+
height: '100%',
|
|
439
|
+
gap: 3,
|
|
440
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Creating A2UI agent..." })] })) : chatError || !agentId ? (_jsx(Box, { sx: { p: 3 }, children: _jsxs(Text, { sx: { color: 'danger.fg' }, children: ["Failed to initialize chat:", ' ', chatError || 'No agent id returned'] }) })) : (_jsx(Chat, { protocol: "ag-ui", baseUrl: baseUrl, agentId: agentId, title: "A2UI Agent", description: "Generate interactive A2UI surfaces", placeholder: "Describe the UI you want...", showHeader: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, suggestions: SUGGESTIONS, submitOnSuggestionClick: true, pendingPrompt: pendingPrompt, renderToolResult: renderToolResult })) })] }) }) }));
|
|
441
|
+
};
|
|
442
|
+
export default A2UiAgentExample;
|