@datalayer/agent-runtimes 1.0.10 → 1.0.17
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/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 +3 -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 +3 -1
- package/lib/examples/index.js +3 -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 +70 -26
- package/lib/specs/agents/agents.js +3994 -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 +3 -1
- 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__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +21 -4
- package/scripts/codegen/generate_loops.py +443 -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
package/lib/examples/index.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
export { default as AgentspecsExample } from './AgentspecsExample';
|
|
6
|
-
export { default as
|
|
6
|
+
export { default as A2UiComponentsGalleryExample } from './A2UiComponentsGalleryExample';
|
|
7
7
|
export { default as A2UiContactCardExample } from './A2UiContactCardExample';
|
|
8
8
|
export { default as A2UiRestaurantExample } from './A2UiRestaurantExample';
|
|
9
|
+
export { default as A2UiAgentExample } from './A2UiAgentExample';
|
|
9
10
|
export { default as A2UiViewerExample } from './A2UiViewerExample';
|
|
10
11
|
export { default as AgUiAgenticExample } from './AgUiAgenticExample';
|
|
11
12
|
export { default as AgUiBackendToolRenderingExample } from './AgUiBackendToolRenderingExample';
|
|
@@ -25,6 +26,7 @@ export { default as AgentEvalsExample } from './AgentEvalsExample';
|
|
|
25
26
|
export { default as AgentGuardrailsExample } from './AgentGuardrailsExample';
|
|
26
27
|
export { default as AgentHooksExample } from './AgentHooksExample';
|
|
27
28
|
export { default as AgentInferenceProviderExample } from './AgentInferenceProviderExample';
|
|
29
|
+
export { default as AgentLoopExample } from './AgentLoopExample';
|
|
28
30
|
export { default as AgentToolApprovalsExample } from './AgentToolApprovalsExample';
|
|
29
31
|
export { default as AgentMemoryExample } from './AgentMemoryExample';
|
|
30
32
|
export { default as AgentOtelExample } from './AgentOtelExample';
|
package/lib/examples/main.js
CHANGED
|
@@ -3,26 +3,57 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
+
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
6
7
|
/// <reference types="vite/client" />
|
|
7
8
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
9
|
import { createRoot } from 'react-dom/client';
|
|
9
10
|
import { loadJupyterConfig, JupyterReactTheme, createServerSettings, setJupyterServerUrl, setJupyterServerToken, getJupyterServerUrl, getJupyterServerToken, } from '@datalayer/jupyter-react';
|
|
10
11
|
import { ServiceManager } from '@jupyterlab/services';
|
|
11
12
|
import { DatalayerThemeProvider, DatalayerLogoText, getLogoColors, themeConfigs, Box, } from '@datalayer/primer-addons';
|
|
13
|
+
import { AgentSummary } from '../components';
|
|
12
14
|
import { HomeIcon, SignInIcon, SignOutIcon } from '@primer/octicons-react';
|
|
13
|
-
import { Button } from '@primer/react';
|
|
15
|
+
import { Button, Spinner, Text } from '@primer/react';
|
|
14
16
|
import { AppearanceControlsWithStore } from '@datalayer/primer-addons/lib/components/appearance';
|
|
15
|
-
import { coreStore, iamStore
|
|
17
|
+
import { coreStore, iamStore } from '@datalayer/core';
|
|
18
|
+
import { DATALAYER_IAM_TOKEN_KEY, DATALAYER_IAM_USER_KEY, } from '../state/substates';
|
|
16
19
|
import { SignInSimple } from '@datalayer/core/lib/views/iam';
|
|
17
20
|
import { UserBadge } from '@datalayer/core/lib/views/profile';
|
|
18
21
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
19
|
-
import {
|
|
22
|
+
import { teardownExampleAgents } from './utils/teardownAgents';
|
|
20
23
|
import { OAuthCallback } from '../identity';
|
|
21
24
|
import { EXAMPLES, getExampleEntries, } from './example-selector';
|
|
25
|
+
import { runtimeTargetStore, useRuntimeTargetStore, } from './utils/runtimeTargetStore';
|
|
26
|
+
import { resolveExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
27
|
+
import { agentSummaryStore } from './utils/agentSummaryStore';
|
|
28
|
+
import { useAgentSummaryStore } from './utils/agentSummaryStore';
|
|
22
29
|
import { useExampleThemeStore } from './utils/themeStore';
|
|
23
30
|
import { ExampleWrapper } from './components/ExampleWrapper';
|
|
31
|
+
import { ExampleErrorBoundary } from './components/ExampleErrorBoundary';
|
|
24
32
|
import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
|
|
25
33
|
import '../../style/primer-primitives.css';
|
|
34
|
+
const DEFAULT_RUNTIMES_URL = 'https://r1.datalayer.run';
|
|
35
|
+
const resolveRuntimesUrl = (configured) => {
|
|
36
|
+
const envRuntimeUrl = import.meta.env.VITE_DATALAYER_RUNTIMES_URL;
|
|
37
|
+
const envBaseUrl = import.meta.env.VITE_DATALAYER_URL;
|
|
38
|
+
const candidate = configured || envRuntimeUrl || envBaseUrl;
|
|
39
|
+
if (!candidate) {
|
|
40
|
+
return DEFAULT_RUNTIMES_URL;
|
|
41
|
+
}
|
|
42
|
+
if (candidate.includes('prod1.datalayer.run')) {
|
|
43
|
+
return DEFAULT_RUNTIMES_URL;
|
|
44
|
+
}
|
|
45
|
+
return candidate.replace(/\/$/, '');
|
|
46
|
+
};
|
|
47
|
+
const toAgentRuntimesBaseUrl = (value) => {
|
|
48
|
+
if (!value) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const normalized = value.trim().replace(/\/$/, '');
|
|
52
|
+
if (!normalized) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return normalized;
|
|
56
|
+
};
|
|
26
57
|
// Load configurations from DOM
|
|
27
58
|
const loadConfigurations = () => {
|
|
28
59
|
// Load Datalayer configuration
|
|
@@ -38,7 +69,8 @@ const loadConfigurations = () => {
|
|
|
38
69
|
datalayerConfig.token = envToken;
|
|
39
70
|
}
|
|
40
71
|
}
|
|
41
|
-
if (datalayerConfig.
|
|
72
|
+
if (datalayerConfig.datalayerUrl) {
|
|
73
|
+
datalayerConfig.runtimesUrl = resolveRuntimesUrl(datalayerConfig.runtimesUrl);
|
|
42
74
|
coreStore.getState().setConfiguration(datalayerConfig);
|
|
43
75
|
// Also set the token in the IAM store for API authentication
|
|
44
76
|
if (datalayerConfig.token) {
|
|
@@ -115,6 +147,150 @@ const isOAuthCallback = () => {
|
|
|
115
147
|
const hasError = params.has('error');
|
|
116
148
|
return (hasCode && hasState) || hasError;
|
|
117
149
|
};
|
|
150
|
+
const isIAMSocialCallback = () => {
|
|
151
|
+
const path = window.location.pathname;
|
|
152
|
+
const params = new URLSearchParams(window.location.search);
|
|
153
|
+
const isCallbackPath = /\/iam\/oauth2\/[^/]+\/callback$/.test(path);
|
|
154
|
+
return isCallbackPath && (params.has('token') || params.has('error'));
|
|
155
|
+
};
|
|
156
|
+
const resolveNavigationTarget = (params) => {
|
|
157
|
+
const candidate = params.get('navigate_to') ||
|
|
158
|
+
params.get('navigation') ||
|
|
159
|
+
params.get('post_auth_redirect') ||
|
|
160
|
+
params.get('redirect_url');
|
|
161
|
+
if (!candidate) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const normalized = String(candidate).trim();
|
|
165
|
+
if (!normalized.startsWith('/') || normalized.startsWith('//')) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
if (/^\/iam\/oauth2\/[^/]+\/callback$/.test(normalized)) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return normalized;
|
|
172
|
+
};
|
|
173
|
+
const parseUserFromCallback = (encodedUser) => {
|
|
174
|
+
if (!encodedUser) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const attempts = [encodedUser];
|
|
178
|
+
try {
|
|
179
|
+
attempts.push(decodeURIComponent(encodedUser));
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// ignore decode failure
|
|
183
|
+
}
|
|
184
|
+
if (attempts.length > 1) {
|
|
185
|
+
try {
|
|
186
|
+
attempts.push(decodeURIComponent(attempts[1]));
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// ignore double decode failure
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const candidate of attempts) {
|
|
193
|
+
try {
|
|
194
|
+
const parsed = JSON.parse(candidate);
|
|
195
|
+
if (parsed && typeof parsed === 'object') {
|
|
196
|
+
return parsed;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// keep trying
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return undefined;
|
|
204
|
+
};
|
|
205
|
+
const AgentRuntimesIAMCallback = () => {
|
|
206
|
+
const [status, setStatus] = useState('processing');
|
|
207
|
+
const [message, setMessage] = useState('Finalizing social sign-in...');
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
const params = new URLSearchParams(window.location.search);
|
|
210
|
+
const provider = window.location.pathname.match(/\/iam\/oauth2\/([^/]+)\/callback$/)?.[1] || '';
|
|
211
|
+
const token = params.get('token') || '';
|
|
212
|
+
const error = params.get('error') || '';
|
|
213
|
+
if (error) {
|
|
214
|
+
setStatus('error');
|
|
215
|
+
setMessage(error);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (!token) {
|
|
219
|
+
setStatus('error');
|
|
220
|
+
setMessage('Missing token in OAuth callback.');
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const callbackUser = parseUserFromCallback(params.get('user'));
|
|
224
|
+
const handle = String(callbackUser?.handle_s ||
|
|
225
|
+
callbackUser?.handle ||
|
|
226
|
+
callbackUser?.email_s ||
|
|
227
|
+
callbackUser?.email ||
|
|
228
|
+
'user').trim() || 'user';
|
|
229
|
+
const storedUser = {
|
|
230
|
+
uid: String(callbackUser?.uid || ''),
|
|
231
|
+
handle,
|
|
232
|
+
firstName: String(callbackUser?.first_name_t || callbackUser?.firstName || ''),
|
|
233
|
+
lastName: String(callbackUser?.last_name_t || callbackUser?.lastName || ''),
|
|
234
|
+
email: String(callbackUser?.email_s || callbackUser?.email || ''),
|
|
235
|
+
displayName: String(callbackUser?.display_name_t || callbackUser?.displayName || '').trim() || handle,
|
|
236
|
+
avatarUrl: String(callbackUser?.avatar_url_s || callbackUser?.avatarUrl || ''),
|
|
237
|
+
roles: Array.isArray(callbackUser?.roles_ss)
|
|
238
|
+
? callbackUser?.roles_ss
|
|
239
|
+
: [],
|
|
240
|
+
setRoles: () => { },
|
|
241
|
+
iamProviders: [],
|
|
242
|
+
settings: {},
|
|
243
|
+
unsubscribedFromOutbounds: false,
|
|
244
|
+
onboarding: {
|
|
245
|
+
clients: {
|
|
246
|
+
Platform: 0,
|
|
247
|
+
JupyterLab: 0,
|
|
248
|
+
CLI: 0,
|
|
249
|
+
VSCode: 0,
|
|
250
|
+
},
|
|
251
|
+
position: 'top',
|
|
252
|
+
tours: {},
|
|
253
|
+
},
|
|
254
|
+
events: [],
|
|
255
|
+
initials: handle.slice(0, 2).toUpperCase(),
|
|
256
|
+
id: String(callbackUser?.uid || ''),
|
|
257
|
+
};
|
|
258
|
+
window.localStorage.setItem(DATALAYER_IAM_TOKEN_KEY, token);
|
|
259
|
+
window.localStorage.setItem(DATALAYER_IAM_USER_KEY, JSON.stringify(storedUser));
|
|
260
|
+
useSimpleAuthStore.getState().setAuth(token, handle);
|
|
261
|
+
iamStore.getState().setLogin(storedUser, token);
|
|
262
|
+
const providerAccessToken = provider
|
|
263
|
+
? params.get(`${provider}_access_token`)
|
|
264
|
+
: null;
|
|
265
|
+
if (providerAccessToken &&
|
|
266
|
+
(provider === 'github' ||
|
|
267
|
+
provider === 'google' ||
|
|
268
|
+
provider === 'linkedin' ||
|
|
269
|
+
provider === 'okta' ||
|
|
270
|
+
provider === 'bluesky')) {
|
|
271
|
+
iamStore
|
|
272
|
+
.getState()
|
|
273
|
+
.setIAMProviderAccessToken(provider, providerAccessToken);
|
|
274
|
+
}
|
|
275
|
+
const target = resolveNavigationTarget(params);
|
|
276
|
+
if (target) {
|
|
277
|
+
window.location.replace(target);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
window.localStorage.setItem('selectedExample', 'HomeExample');
|
|
281
|
+
window.location.replace('/');
|
|
282
|
+
}, []);
|
|
283
|
+
return (_jsx(JupyterReactTheme, { children: _jsx(Box, { sx: {
|
|
284
|
+
display: 'flex',
|
|
285
|
+
alignItems: 'center',
|
|
286
|
+
justifyContent: 'center',
|
|
287
|
+
minHeight: '100vh',
|
|
288
|
+
p: 3,
|
|
289
|
+
}, children: _jsxs(Box, { sx: { textAlign: 'center' }, children: [status === 'processing' ? _jsx(Spinner, { size: "large" }) : null, _jsx(Text, { as: "p", sx: {
|
|
290
|
+
mt: 3,
|
|
291
|
+
color: status === 'error' ? 'danger.fg' : 'fg.default',
|
|
292
|
+
}, children: message })] }) }) }));
|
|
293
|
+
};
|
|
118
294
|
// Get the default example name from localStorage
|
|
119
295
|
const getDefaultExampleName = () => {
|
|
120
296
|
const stored = localStorage.getItem('selectedExample');
|
|
@@ -166,12 +342,12 @@ const NotebookOnlyApp = () => {
|
|
|
166
342
|
const initializeApp = async () => {
|
|
167
343
|
try {
|
|
168
344
|
const { configuration } = coreStore.getState();
|
|
169
|
-
// Always try to create collaboration provider if we have token and
|
|
170
|
-
if (configuration?.token && configuration?.
|
|
345
|
+
// Always try to create collaboration provider if we have token and datalayerUrl
|
|
346
|
+
if (configuration?.token && configuration?.datalayerUrl) {
|
|
171
347
|
try {
|
|
172
|
-
const { DatalayerCollaborationProvider } = await import('
|
|
348
|
+
const { DatalayerCollaborationProvider } = await import('../collaboration/DatalayerCollaborationProvider');
|
|
173
349
|
const provider = new DatalayerCollaborationProvider({
|
|
174
|
-
|
|
350
|
+
datalayerUrl: configuration.datalayerUrl,
|
|
175
351
|
token: configuration.token,
|
|
176
352
|
});
|
|
177
353
|
setCollaborationProvider(provider);
|
|
@@ -181,7 +357,8 @@ const NotebookOnlyApp = () => {
|
|
|
181
357
|
}
|
|
182
358
|
}
|
|
183
359
|
// Create service manager
|
|
184
|
-
if (
|
|
360
|
+
if (runtimeTargetStore.getState().target === 'cloud' &&
|
|
361
|
+
configuration?.token) {
|
|
185
362
|
try {
|
|
186
363
|
const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100);
|
|
187
364
|
await manager.ready;
|
|
@@ -238,6 +415,8 @@ export const ExampleApp = () => {
|
|
|
238
415
|
const [selectedExample, setSelectedExample] = useState(getDefaultExampleName());
|
|
239
416
|
const [searchQuery, setSearchQuery] = useState(getInitialSearchQuery());
|
|
240
417
|
const [isChangingExample, setIsChangingExample] = useState(false);
|
|
418
|
+
const runtimeTarget = useRuntimeTargetStore(state => state.target);
|
|
419
|
+
const setRuntimeTarget = useRuntimeTargetStore(state => state.setTarget);
|
|
241
420
|
const filteredExampleEntries = useMemo(() => {
|
|
242
421
|
const normalized = searchQuery.trim().toLowerCase();
|
|
243
422
|
const all = getExampleEntriesList();
|
|
@@ -274,38 +453,58 @@ export const ExampleApp = () => {
|
|
|
274
453
|
setIsChangingExample(false);
|
|
275
454
|
}
|
|
276
455
|
};
|
|
456
|
+
const createLocalServiceManager = async () => {
|
|
457
|
+
const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
|
|
458
|
+
const manager = new ServiceManager({ serverSettings });
|
|
459
|
+
await manager.ready;
|
|
460
|
+
return manager;
|
|
461
|
+
};
|
|
462
|
+
const createCloudServiceManager = async () => {
|
|
463
|
+
const { configuration } = coreStore.getState();
|
|
464
|
+
if (!configuration?.token) {
|
|
465
|
+
throw new Error('Cloud runtime requires authentication. Please sign in.');
|
|
466
|
+
}
|
|
467
|
+
const activeSummary = agentSummaryStore.getState().active;
|
|
468
|
+
const selectedEntry = getExampleEntriesList().find(entry => entry.id === selectedExample);
|
|
469
|
+
const resolvedSpecId = activeSummary?.exampleId === selectedExample
|
|
470
|
+
? activeSummary.specId
|
|
471
|
+
: undefined;
|
|
472
|
+
const runtimeDescriptor = resolvedSpecId || selectedEntry?.title || selectedExample;
|
|
473
|
+
const contextualRuntimeName = `Agent Runtime - ${runtimeDescriptor}`;
|
|
474
|
+
const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100, contextualRuntimeName);
|
|
475
|
+
await manager.ready;
|
|
476
|
+
return manager;
|
|
477
|
+
};
|
|
277
478
|
useEffect(() => {
|
|
278
479
|
// Load configurations
|
|
279
480
|
loadConfigurations();
|
|
280
481
|
// Create service manager and load example - must be sequential
|
|
281
482
|
const initializeApp = async () => {
|
|
282
483
|
try {
|
|
283
|
-
const
|
|
284
|
-
//
|
|
285
|
-
|
|
484
|
+
const runtimeTarget = runtimeTargetStore.getState().target;
|
|
485
|
+
// Only create a cloud Datalayer runtime when the user picked "cloud".
|
|
486
|
+
// In "local" mode we must never hit the cloud runtimes API.
|
|
487
|
+
if (runtimeTarget === 'cloud') {
|
|
286
488
|
try {
|
|
287
|
-
const manager = await
|
|
288
|
-
await manager.ready;
|
|
489
|
+
const manager = await createCloudServiceManager();
|
|
289
490
|
setServiceManager(manager);
|
|
290
491
|
// Load initial example
|
|
291
492
|
await loadExample(selectedExample, manager);
|
|
292
493
|
}
|
|
293
494
|
catch (error) {
|
|
294
495
|
console.error('Failed to create DatalayerServiceManager:', error);
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
await
|
|
496
|
+
// Surface the failure in the UI, then fall back to local so the
|
|
497
|
+
// app stays usable.
|
|
498
|
+
setError(`Cloud runtime unavailable, using local instead: ${error instanceof Error ? error.message : String(error)}`);
|
|
499
|
+
const manager = await createLocalServiceManager();
|
|
299
500
|
setServiceManager(manager);
|
|
300
501
|
// Load initial example
|
|
301
502
|
await loadExample(selectedExample, manager);
|
|
302
503
|
}
|
|
303
504
|
}
|
|
304
505
|
else {
|
|
305
|
-
//
|
|
306
|
-
const
|
|
307
|
-
const manager = new ServiceManager({ serverSettings });
|
|
308
|
-
await manager.ready;
|
|
506
|
+
// Local runtime target (or no token): use the local Jupyter server.
|
|
507
|
+
const manager = await createLocalServiceManager();
|
|
309
508
|
setServiceManager(manager);
|
|
310
509
|
// Load initial example
|
|
311
510
|
await loadExample(selectedExample, manager);
|
|
@@ -333,70 +532,51 @@ export const ExampleApp = () => {
|
|
|
333
532
|
await new Promise(resolve => {
|
|
334
533
|
requestAnimationFrame(() => resolve());
|
|
335
534
|
});
|
|
336
|
-
// 2) Tear down any server-side agents created by the previous example
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
// Delete those agents on the server and drop the cached ids so the
|
|
340
|
-
// next example (and a future re-entry into this one) boots fresh.
|
|
341
|
-
const agentBaseUrl = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
535
|
+
// 2) Tear down any server-side agents created by the previous example and
|
|
536
|
+
// wipe in-process agent state so the next example boots fresh.
|
|
537
|
+
const agentBaseUrl = resolveExampleAgentRuntimesUrl(runtimeTargetStore.getState().target);
|
|
342
538
|
const token = useSimpleAuthStore.getState().token;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (let i = 0; i < sessionStorage.length; i++) {
|
|
346
|
-
const key = sessionStorage.key(i);
|
|
347
|
-
if (key && key.startsWith('agent-runtimes:agentId:')) {
|
|
348
|
-
agentIdKeys.push(key);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
catch {
|
|
353
|
-
// sessionStorage unavailable; skip teardown.
|
|
354
|
-
}
|
|
355
|
-
await Promise.all(agentIdKeys.map(async (key) => {
|
|
356
|
-
let agentId = null;
|
|
357
|
-
try {
|
|
358
|
-
agentId = sessionStorage.getItem(key);
|
|
359
|
-
}
|
|
360
|
-
catch {
|
|
361
|
-
/* ignore */
|
|
362
|
-
}
|
|
363
|
-
if (!agentId)
|
|
364
|
-
return;
|
|
365
|
-
try {
|
|
366
|
-
await fetch(`${agentBaseUrl}/api/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
367
|
-
method: 'DELETE',
|
|
368
|
-
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
catch {
|
|
372
|
-
// Best-effort teardown: ignore network / 404 errors.
|
|
373
|
-
}
|
|
374
|
-
try {
|
|
375
|
-
sessionStorage.removeItem(key);
|
|
376
|
-
}
|
|
377
|
-
catch {
|
|
378
|
-
/* ignore */
|
|
379
|
-
}
|
|
380
|
-
}));
|
|
381
|
-
// 3) Wipe every piece of in-process agent state so the next example boots
|
|
382
|
-
// with a clean slate (no leftover messages, threads, pending tool
|
|
383
|
-
// calls, code sandbox snapshots, monitoring caches, or sockets).
|
|
384
|
-
useChatStore.getState().reset();
|
|
385
|
-
useConversationStore.getState().clearAll();
|
|
386
|
-
agentRuntimeStore.getState().reset();
|
|
387
|
-
// 4) Drop the persisted slice from localStorage so a fresh example never
|
|
388
|
-
// rehydrates a previous example's agents / monitoring cache.
|
|
389
|
-
try {
|
|
390
|
-
localStorage.removeItem('agent-runtimes-storage');
|
|
391
|
-
}
|
|
392
|
-
catch {
|
|
393
|
-
// Ignore storage failures (e.g. private mode).
|
|
394
|
-
}
|
|
395
|
-
// 5) Load and mount the new example.
|
|
539
|
+
await teardownExampleAgents(agentBaseUrl, token ?? undefined);
|
|
540
|
+
// 3) Load and mount the new example.
|
|
396
541
|
setSelectedExample(newExample);
|
|
397
542
|
localStorage.setItem('selectedExample', newExample);
|
|
398
543
|
await loadExample(newExample, serviceManager);
|
|
399
544
|
};
|
|
545
|
+
const handleRuntimeTargetChange = async (newTarget) => {
|
|
546
|
+
if (newTarget === runtimeTarget || !serviceManager)
|
|
547
|
+
return;
|
|
548
|
+
let nextManager;
|
|
549
|
+
try {
|
|
550
|
+
nextManager =
|
|
551
|
+
newTarget === 'cloud'
|
|
552
|
+
? await createCloudServiceManager()
|
|
553
|
+
: await createLocalServiceManager();
|
|
554
|
+
}
|
|
555
|
+
catch (switchError) {
|
|
556
|
+
setError(`Failed to switch to ${newTarget}: ${switchError instanceof Error
|
|
557
|
+
? switchError.message
|
|
558
|
+
: String(switchError)}`);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
// 1) Unmount the current example FIRST so its cleanup hooks run against the
|
|
562
|
+
// still-valid OLD runtime (AG-UI disconnect, abort fetches, sandboxes).
|
|
563
|
+
setIsChangingExample(true);
|
|
564
|
+
setExampleComponent(null);
|
|
565
|
+
await new Promise(resolve => {
|
|
566
|
+
requestAnimationFrame(() => resolve());
|
|
567
|
+
});
|
|
568
|
+
// 2) Tear down the agents created on the OLD target, then wipe state so a
|
|
569
|
+
// brand-new runtime is launched for the new target.
|
|
570
|
+
const oldAgentBaseUrl = resolveExampleAgentRuntimesUrl(runtimeTarget);
|
|
571
|
+
const token = useSimpleAuthStore.getState().token;
|
|
572
|
+
await teardownExampleAgents(oldAgentBaseUrl, token ?? undefined);
|
|
573
|
+
// 3) Switch the target and re-mount the example (its key includes the
|
|
574
|
+
// target, so this launches/connects a fresh runtime).
|
|
575
|
+
setRuntimeTarget(newTarget);
|
|
576
|
+
setServiceManager(nextManager);
|
|
577
|
+
setError(null);
|
|
578
|
+
await loadExample(selectedExample, nextManager);
|
|
579
|
+
};
|
|
400
580
|
if (loading) {
|
|
401
581
|
return (_jsxs("div", { style: { padding: '20px', textAlign: 'center' }, children: [_jsxs("h2", { children: ["Loading Example: ", selectedExample] }), _jsx("p", { children: "Please wait..." })] }));
|
|
402
582
|
}
|
|
@@ -418,24 +598,51 @@ export const ExampleApp = () => {
|
|
|
418
598
|
exampleProps.onSelectExample = (name) => {
|
|
419
599
|
void handleExampleChange(name);
|
|
420
600
|
};
|
|
421
|
-
return (_jsx(ExampleAppThemed, { selectedExample: selectedExample, isChangingExample: isChangingExample, error: error, ExampleComponent: ExampleComponent, exampleProps: exampleProps, onExampleChange: handleExampleChange, availableExamples: getExampleEntriesList() }));
|
|
601
|
+
return (_jsx(ExampleAppThemed, { selectedExample: selectedExample, isChangingExample: isChangingExample, error: error, ExampleComponent: ExampleComponent, exampleProps: exampleProps, serviceManager: serviceManager, onExampleChange: handleExampleChange, onRuntimeTargetChange: handleRuntimeTargetChange, availableExamples: getExampleEntriesList() }));
|
|
422
602
|
};
|
|
423
603
|
/**
|
|
424
604
|
* Inner shell that reads from the theme store and wires
|
|
425
605
|
* DatalayerThemeProvider + the header bar with selectors.
|
|
426
606
|
*/
|
|
427
|
-
const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, onExampleChange, availableExamples, }) => {
|
|
607
|
+
const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, serviceManager, onExampleChange, onRuntimeTargetChange, availableExamples, }) => {
|
|
428
608
|
const { colorMode, theme: themeVariant } = useExampleThemeStore();
|
|
609
|
+
const runtimeTarget = useRuntimeTargetStore(state => state.target);
|
|
610
|
+
const agentSummary = useAgentSummaryStore(state => state.active);
|
|
429
611
|
const cfg = themeConfigs[themeVariant];
|
|
430
612
|
const logoColors = getLogoColors(themeVariant, colorMode);
|
|
431
613
|
const { token, setAuth, clearAuth } = useSimpleAuthStore();
|
|
432
614
|
const [showSignIn, setShowSignIn] = useState(false);
|
|
433
615
|
const shouldShowAuthScreen = showSignIn && !token;
|
|
434
616
|
const syncTokenToIamStore = useCallback((newToken) => {
|
|
435
|
-
import('
|
|
617
|
+
import('../state/substates').then(({ iamStore: coreIamStore }) => {
|
|
436
618
|
coreIamStore.setState({ token: newToken });
|
|
437
619
|
});
|
|
438
620
|
}, []);
|
|
621
|
+
useEffect(() => {
|
|
622
|
+
const baseUrl = toAgentRuntimesBaseUrl(serviceManager?.serverSettings.baseUrl) ||
|
|
623
|
+
resolveExampleAgentRuntimesUrl(runtimeTarget);
|
|
624
|
+
// Seed a base summary for the selected example. Do NOT clobber a richer
|
|
625
|
+
// summary that the mounted example already published (spec id, agent id,
|
|
626
|
+
// readiness) for the same example + target — otherwise fast-settling local
|
|
627
|
+
// agents lose their spec/agent id in the indicator.
|
|
628
|
+
const current = agentSummaryStore.getState().active;
|
|
629
|
+
const alreadyEnriched = current != null &&
|
|
630
|
+
current.exampleId === selectedExample &&
|
|
631
|
+
current.location === runtimeTarget &&
|
|
632
|
+
(current.specId != null ||
|
|
633
|
+
current.agentId != null ||
|
|
634
|
+
current.isReady !== undefined);
|
|
635
|
+
if (alreadyEnriched) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
agentSummaryStore.getState().setActive({
|
|
639
|
+
exampleId: selectedExample,
|
|
640
|
+
agentName: selectedExample,
|
|
641
|
+
location: runtimeTarget,
|
|
642
|
+
baseUrl,
|
|
643
|
+
status: isChangingExample ? 'switching' : 'selected',
|
|
644
|
+
});
|
|
645
|
+
}, [selectedExample, runtimeTarget, isChangingExample, serviceManager]);
|
|
439
646
|
useEffect(() => {
|
|
440
647
|
// Keep iamStore aligned with persisted auth token on app load/refresh.
|
|
441
648
|
syncTokenToIamStore(token || undefined);
|
|
@@ -515,7 +722,7 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
515
722
|
const rest = availableExamples.filter(e => e.id !== 'HomeExample');
|
|
516
723
|
// Classify each example into a named group.
|
|
517
724
|
const groupOf = (id) => {
|
|
518
|
-
if (id === 'AgentspecsExample')
|
|
725
|
+
if (id === 'AgentspecsExample' || id === 'AgentLoopExample')
|
|
519
726
|
return 'Personas';
|
|
520
727
|
if (id.startsWith('A2Ui'))
|
|
521
728
|
return 'A2UI';
|
|
@@ -548,12 +755,33 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
548
755
|
const grouped = new Map();
|
|
549
756
|
for (const ex of rest) {
|
|
550
757
|
const g = groupOf(ex.id);
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
758
|
+
const group = grouped.get(g);
|
|
759
|
+
if (group) {
|
|
760
|
+
group.push(ex);
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
grouped.set(g, [ex]);
|
|
764
|
+
}
|
|
554
765
|
}
|
|
555
|
-
for (const list of grouped.
|
|
556
|
-
|
|
766
|
+
for (const [groupName, list] of grouped.entries()) {
|
|
767
|
+
if (groupName === 'Personas') {
|
|
768
|
+
const personaOrder = (id) => {
|
|
769
|
+
if (id === 'AgentspecsExample')
|
|
770
|
+
return 0;
|
|
771
|
+
if (id === 'AgentLoopExample')
|
|
772
|
+
return 1;
|
|
773
|
+
return 2;
|
|
774
|
+
};
|
|
775
|
+
list.sort((a, b) => {
|
|
776
|
+
const orderDelta = personaOrder(a.id) - personaOrder(b.id);
|
|
777
|
+
if (orderDelta !== 0)
|
|
778
|
+
return orderDelta;
|
|
779
|
+
return a.title.localeCompare(b.title);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
list.sort((a, b) => a.title.localeCompare(b.title));
|
|
784
|
+
}
|
|
557
785
|
}
|
|
558
786
|
const nodes = [];
|
|
559
787
|
if (home) {
|
|
@@ -570,7 +798,23 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
570
798
|
}
|
|
571
799
|
}
|
|
572
800
|
return _jsx(_Fragment, { children: nodes });
|
|
573
|
-
})() }),
|
|
801
|
+
})() }), _jsxs(Box, { as: "select", value: runtimeTarget, onChange: (e) => void onRuntimeTargetChange(e.target.value), disabled: isChangingExample, "aria-label": "Runtime target", title: "Runtime target", sx: {
|
|
802
|
+
px: 2,
|
|
803
|
+
py: '6px',
|
|
804
|
+
fontSize: 1,
|
|
805
|
+
fontFamily: 'mono',
|
|
806
|
+
border: '1px solid',
|
|
807
|
+
borderColor: 'border.default',
|
|
808
|
+
borderRadius: 2,
|
|
809
|
+
bg: 'canvas.default',
|
|
810
|
+
color: 'fg.default',
|
|
811
|
+
cursor: isChangingExample ? 'not-allowed' : 'pointer',
|
|
812
|
+
minWidth: '120px',
|
|
813
|
+
outline: 'none',
|
|
814
|
+
'&:focus-visible': {
|
|
815
|
+
boxShadow: '0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))',
|
|
816
|
+
},
|
|
817
|
+
}, children: [_jsx("option", { value: "local", children: "Local" }), _jsx("option", { value: "cloud", children: "Cloud" })] }), _jsx(AgentSummary, { summary: agentSummary }), isChangingExample && (_jsx(Box, { as: "span", sx: { color: 'fg.muted', fontSize: 0 }, children: "Loading\u2026" })), error && (_jsxs(Box, { as: "span", sx: { color: 'danger.fg', fontSize: 0 }, children: ["Error: ", error] }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 3 }, children: [_jsx(AppearanceControlsWithStore, { useStore: useExampleThemeStore }), _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: token ? (_jsxs(_Fragment, { children: [_jsx(UserBadge, { token: token, variant: "small", onTokenExpired: () => {
|
|
574
818
|
handleHeaderLogout();
|
|
575
819
|
setShowSignIn(true);
|
|
576
820
|
} }), _jsx(Button, { size: "small", variant: "invisible", onClick: handleHeaderLogout, leadingVisual: SignOutIcon, sx: { color: 'fg.muted' }, children: "Sign out" })] })) : (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowSignIn(true), leadingVisual: SignInIcon, sx: { color: 'fg.muted' }, children: "Sign in" })) }), _jsx(Box, { as: "a", href: "https://datalayer.ai", target: "_blank", rel: "noopener noreferrer", "aria-label": "Open Datalayer website", sx: { display: 'inline-flex', alignItems: 'center' }, children: _jsx(DatalayerLogoText, { size: 24, variant: themeVariant, colorMode: colorMode, primaryColor: logoColors.primary, secondaryColor: logoColors.secondary, textColor: logoColors.textColor, primaryGradient: logoColors.primaryGradient, secondaryGradient: logoColors.secondaryGradient, gradient: true }) })] })] }), _jsx(Box, { sx: {
|
|
@@ -583,14 +827,17 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
|
|
|
583
827
|
bg: 'canvas.backdrop',
|
|
584
828
|
p: 3,
|
|
585
829
|
overflow: 'auto',
|
|
586
|
-
}, children: _jsx(Box, { sx: { maxWidth: 640, mx: 'auto' }, children: _jsx(SignInSimple, { onSignIn: handleHeaderSignIn, onApiKeySignIn: apiKey => handleHeaderSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }) }) })) : isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }, selectedExample) }, selectedExample)) : null })] }) }));
|
|
830
|
+
}, children: _jsx(Box, { sx: { maxWidth: 640, mx: 'auto' }, children: _jsx(SignInSimple, { onSignIn: handleHeaderSignIn, onApiKeySignIn: apiKey => handleHeaderSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }) }) })) : isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleErrorBoundary, { children: _jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }, `${selectedExample}:${runtimeTarget}`) }, `${selectedExample}:${runtimeTarget}`) }, `${selectedExample}:${runtimeTarget}`)) : null })] }) }));
|
|
587
831
|
};
|
|
588
832
|
// Mount the app - check route to determine which app to render
|
|
589
833
|
const root = document.getElementById('root');
|
|
590
834
|
if (root) {
|
|
591
835
|
const appRoot = window.__agentRuntimesExamplesRoot ??
|
|
592
836
|
(window.__agentRuntimesExamplesRoot = createRoot(root));
|
|
593
|
-
if (
|
|
837
|
+
if (isIAMSocialCallback()) {
|
|
838
|
+
appRoot.render(_jsx(AgentRuntimesIAMCallback, {}));
|
|
839
|
+
}
|
|
840
|
+
else if (isOAuthCallback()) {
|
|
594
841
|
// Handle OAuth callback - render OAuthCallback component
|
|
595
842
|
appRoot.render(_jsx(JupyterReactTheme, { children: _jsx(OAuthCallback, { autoClose: true, autoCloseDelay: 1000 }) }));
|
|
596
843
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
1
2
|
import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
|
|
2
3
|
import { MessageProcessor, type A2uiClientAction, type A2uiMessage, type SurfaceModel } from '@a2ui/web_core/v0_9';
|
|
3
4
|
export type A2uiProcessor = MessageProcessor<ReactComponentImplementation>;
|
|
@@ -7,6 +8,7 @@ export declare function useA2uiProcessor(onAction?: (action: A2uiClientAction) =
|
|
|
7
8
|
surfaces: A2uiSurfaceModel[];
|
|
8
9
|
processMessages: (messages: A2uiMessage[]) => void;
|
|
9
10
|
resetSurfaces: () => void;
|
|
11
|
+
themeStyle: CSSProperties;
|
|
10
12
|
};
|
|
11
13
|
export declare function createSceneMessages(args: {
|
|
12
14
|
surfaceId: string;
|