@datalayer/agent-runtimes 1.0.9 → 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 +468 -40
- 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.d.ts +4 -4
- package/lib/client/AgentsMixin.js +35 -35
- 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/ToolApprovalCard.js +13 -3
- 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/config/AgentConfiguration.d.ts +2 -2
- package/lib/config/index.d.ts +1 -1
- 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 +21 -22
- package/lib/examples/AgentCodemodeExample.js +3 -3
- package/lib/examples/AgentEvalsExample.js +8 -8
- package/lib/examples/AgentGuardrailsExample.js +22 -17
- package/lib/examples/AgentHooksExample.js +16 -57
- package/lib/examples/AgentInferenceProviderExample.js +8 -8
- package/lib/examples/AgentLoopExample.d.ts +10 -0
- package/lib/examples/AgentLoopExample.js +304 -0
- package/lib/examples/AgentMCPExample.js +9 -9
- package/lib/examples/AgentMemoryExample.js +6 -6
- package/lib/examples/AgentMonitoringExample.js +116 -46
- package/lib/examples/AgentNotificationsExample.js +6 -6
- package/lib/examples/AgentOtelExample.d.ts +3 -3
- package/lib/examples/AgentOtelExample.js +20 -15
- package/lib/examples/AgentOutputsExample.js +8 -8
- package/lib/examples/AgentParametersExample.js +24 -36
- package/lib/examples/AgentSandboxExample.js +7 -7
- package/lib/examples/AgentSkillsExample.js +9 -9
- package/lib/examples/AgentSubagentsExample.js +6 -6
- package/lib/examples/AgentToolApprovalsExample.js +37 -11
- package/lib/examples/AgentTriggersExample.js +12 -12
- package/lib/examples/AgentspecsExample.js +63 -41
- package/lib/examples/ChatCustomExample.js +23 -77
- package/lib/examples/ChatExample.js +15 -46
- 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 +188 -29
- package/lib/hooks/useAgentsCatalog.d.ts +3 -3
- package/lib/hooks/useAgentsCatalog.js +4 -4
- 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 +38 -28
- 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 +14 -6
- package/lib/hooks/useToolApprovals.js +20 -1
- package/lib/index.d.ts +2 -1
- 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 +95 -50
- package/lib/specs/agents/agents.js +4037 -1669
- package/lib/specs/agents/index.d.ts +5 -5
- package/lib/specs/agents/index.js +9 -9
- 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 +6 -6
- package/lib/types/agentspecs.d.ts +8 -4
- 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/teams.d.ts +2 -2
- 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/generate_agents.py +96 -61
- package/scripts/codegen/generate_loops.py +443 -0
- package/scripts/codegen/generate_teams.py +4 -4
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -3
- package/lib/examples/A2UiComponentGalleryExample.js +0 -361
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- /package/lib/{agent-lexical-main.d.ts → agent-document-main.d.ts} +0 -0
|
@@ -5,7 +5,85 @@
|
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { basicCatalog, } from '@a2ui/react/v0_9';
|
|
7
7
|
import { MessageProcessor, } from '@a2ui/web_core/v0_9';
|
|
8
|
+
import { themeConfigs, } from '@datalayer/primer-addons';
|
|
9
|
+
import { useExampleThemeStore } from './themeStore';
|
|
10
|
+
function resolveColorMode(mode) {
|
|
11
|
+
if (mode === 'dark') {
|
|
12
|
+
return 'dark';
|
|
13
|
+
}
|
|
14
|
+
if (mode === 'light') {
|
|
15
|
+
return 'light';
|
|
16
|
+
}
|
|
17
|
+
if (typeof window !== 'undefined') {
|
|
18
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
19
|
+
? 'dark'
|
|
20
|
+
: 'light';
|
|
21
|
+
}
|
|
22
|
+
return 'light';
|
|
23
|
+
}
|
|
24
|
+
function createA2uiTheme(themeVariant, colorMode) {
|
|
25
|
+
const cfg = themeConfigs[themeVariant];
|
|
26
|
+
const resolvedMode = resolveColorMode(colorMode);
|
|
27
|
+
const modeStyles = resolvedMode === 'dark' ? cfg.themeStyles.dark : cfg.themeStyles.light;
|
|
28
|
+
const vars = modeStyles;
|
|
29
|
+
// Primer buttons use a subtle resting shadow in light mode and none in dark.
|
|
30
|
+
const buttonShadow = resolvedMode === 'dark' ? 'none' : '0 1px 0 rgba(31, 35, 40, 0.04)';
|
|
31
|
+
return {
|
|
32
|
+
mode: resolvedMode,
|
|
33
|
+
// Use Primer's primary button color token so A2UI primary buttons match
|
|
34
|
+
// Primer semantics regardless of the selected brand palette.
|
|
35
|
+
'--a2ui-color-primary': vars['--button-primary-bgColor-rest'] ?? cfg.brandColor,
|
|
36
|
+
'--a2ui-color-primary-hover': vars['--button-primary-bgColor-hover'],
|
|
37
|
+
'--a2ui-color-on-primary': vars['--button-primary-fgColor-rest'],
|
|
38
|
+
'--a2ui-color-secondary': vars['--button-default-bgColor-rest'],
|
|
39
|
+
'--a2ui-color-secondary-hover': vars['--button-default-bgColor-hover'],
|
|
40
|
+
'--a2ui-color-on-secondary': vars['--button-default-fgColor-rest'],
|
|
41
|
+
'--a2ui-color-background': vars['--bgColor-default'],
|
|
42
|
+
'--a2ui-color-surface': vars['--bgColor-muted'],
|
|
43
|
+
'--a2ui-color-on-background': vars['--fgColor-default'],
|
|
44
|
+
'--a2ui-color-on-surface': vars['--fgColor-default'],
|
|
45
|
+
'--a2ui-color-input': vars['--bgColor-default'],
|
|
46
|
+
'--a2ui-color-on-input': vars['--fgColor-default'],
|
|
47
|
+
'--a2ui-color-border': vars['--borderColor-default'],
|
|
48
|
+
'--a2ui-color-border-hover': vars['--borderColor-emphasis'],
|
|
49
|
+
'--a2ui-text-caption-color': vars['--fgColor-muted'],
|
|
50
|
+
'--a2ui-border-radius': '12px',
|
|
51
|
+
'--a2ui-card-border-radius': '14px',
|
|
52
|
+
'--a2ui-card-box-shadow': resolvedMode === 'dark'
|
|
53
|
+
? '0 8px 24px rgba(1, 4, 9, 0.55)'
|
|
54
|
+
: '0 8px 20px rgba(31, 35, 40, 0.08)',
|
|
55
|
+
// Primer-style button tokens: compact padding, 6px radius, semibold label,
|
|
56
|
+
// hairline default border and a subtle resting shadow.
|
|
57
|
+
'--a2ui-button-padding': '5px 16px',
|
|
58
|
+
'--a2ui-button-margin': '0',
|
|
59
|
+
'--a2ui-button-border-radius': '6px',
|
|
60
|
+
'--a2ui-button-font-weight': '500',
|
|
61
|
+
'--a2ui-button-box-shadow': buttonShadow,
|
|
62
|
+
'--a2ui-button-background': vars['--button-default-bgColor-rest'],
|
|
63
|
+
'--a2ui-button-border': `1px solid ${vars['--button-default-borderColor-rest']}`,
|
|
64
|
+
'--a2ui-textfield-border': `1px solid ${vars['--control-borderColor-rest'] ?? vars['--borderColor-default']}`,
|
|
65
|
+
'--a2ui-textfield-background': vars['--control-bgColor-rest'] ?? vars['--bgColor-default'],
|
|
66
|
+
'--a2ui-textfield-color': vars['--fgColor-default'],
|
|
67
|
+
'--a2ui-textfield-label-color': vars['--fgColor-muted'],
|
|
68
|
+
'--a2ui-textfield-color-border-hover': vars['--control-borderColor-emphasis'] ?? vars['--borderColor-emphasis'],
|
|
69
|
+
'--a2ui-textfield-color-border-focus': vars['--button-primary-bgColor-rest'],
|
|
70
|
+
'--a2ui-textfield-color-error': vars['--fgColor-danger'],
|
|
71
|
+
'--a2ui-textfield-border-radius': '6px',
|
|
72
|
+
'--a2ui-textfield-padding': '5px 12px',
|
|
73
|
+
'--a2ui-control-height': '32px',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
8
76
|
export function useA2uiProcessor(onAction) {
|
|
77
|
+
const { colorMode, theme: themeVariant } = useExampleThemeStore();
|
|
78
|
+
const a2uiTheme = useMemo(() => createA2uiTheme(themeVariant, colorMode), [themeVariant, colorMode]);
|
|
79
|
+
// The A2UI basic catalog renders purely from inherited `--a2ui-*` CSS custom
|
|
80
|
+
// properties; it does not read `createSurface.theme`. Expose the computed
|
|
81
|
+
// theme as an inline style so callers can apply it to the surface container
|
|
82
|
+
// and have theme/color-mode changes cascade live to the rendered content.
|
|
83
|
+
const themeStyle = useMemo(() => {
|
|
84
|
+
const { mode, ...vars } = a2uiTheme;
|
|
85
|
+
return { colorScheme: mode, ...vars };
|
|
86
|
+
}, [a2uiTheme]);
|
|
9
87
|
const processor = useMemo(() => new MessageProcessor([basicCatalog], onAction), [onAction]);
|
|
10
88
|
const [surfaces, setSurfaces] = useState(() => Array.from(processor.model.surfacesMap.values()));
|
|
11
89
|
useEffect(() => {
|
|
@@ -21,8 +99,24 @@ export function useA2uiProcessor(onAction) {
|
|
|
21
99
|
};
|
|
22
100
|
}, [processor]);
|
|
23
101
|
const processMessages = useCallback((messages) => {
|
|
24
|
-
|
|
25
|
-
|
|
102
|
+
const themedMessages = messages.map(message => {
|
|
103
|
+
const msg = message;
|
|
104
|
+
if (!msg.createSurface) {
|
|
105
|
+
return message;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
...msg,
|
|
109
|
+
createSurface: {
|
|
110
|
+
...msg.createSurface,
|
|
111
|
+
theme: {
|
|
112
|
+
...a2uiTheme,
|
|
113
|
+
...(msg.createSurface.theme ?? {}),
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
processor.processMessages(themedMessages);
|
|
119
|
+
}, [processor, a2uiTheme]);
|
|
26
120
|
const resetSurfaces = useCallback(() => {
|
|
27
121
|
Array.from(processor.model.surfacesMap.keys()).forEach(id => {
|
|
28
122
|
processor.model.deleteSurface(id);
|
|
@@ -33,6 +127,7 @@ export function useA2uiProcessor(onAction) {
|
|
|
33
127
|
surfaces,
|
|
34
128
|
processMessages,
|
|
35
129
|
resetSurfaces,
|
|
130
|
+
themeStyle,
|
|
36
131
|
};
|
|
37
132
|
}
|
|
38
133
|
export function createSceneMessages(args) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type AgentSummaryLocation = 'local' | 'cloud';
|
|
2
|
+
export interface AgentSummary {
|
|
3
|
+
exampleId: string;
|
|
4
|
+
agentName: string;
|
|
5
|
+
agentId?: string;
|
|
6
|
+
specId?: string;
|
|
7
|
+
location: AgentSummaryLocation;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
status?: string;
|
|
10
|
+
isReady?: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
interface AgentSummaryState {
|
|
14
|
+
active: AgentSummary | null;
|
|
15
|
+
setActive: (summary: AgentSummary) => void;
|
|
16
|
+
clearActive: (exampleId?: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const agentSummaryStore: import("zustand").StoreApi<AgentSummaryState>;
|
|
19
|
+
export declare function useAgentSummaryStore(): AgentSummaryState;
|
|
20
|
+
export declare function useAgentSummaryStore<T>(selector: (state: AgentSummaryState) => T): T;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { createStore } from 'zustand/vanilla';
|
|
6
|
+
import { useStore } from 'zustand';
|
|
7
|
+
export const agentSummaryStore = createStore(set => ({
|
|
8
|
+
active: null,
|
|
9
|
+
setActive: (summary) => set({ active: summary }),
|
|
10
|
+
clearActive: (exampleId) => set(state => {
|
|
11
|
+
if (!state.active) {
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
14
|
+
if (!exampleId || state.active.exampleId === exampleId) {
|
|
15
|
+
return { active: null };
|
|
16
|
+
}
|
|
17
|
+
return state;
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
export function useAgentSummaryStore(selector) {
|
|
22
|
+
return useStore(agentSummaryStore, selector);
|
|
23
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "code",
|
|
5
|
+
"execution_count": null,
|
|
6
|
+
"id": "309d9aeb-4a19-400b-b5fe-ed20091b357b",
|
|
7
|
+
"metadata": {},
|
|
8
|
+
"outputs": [],
|
|
9
|
+
"source": []
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"metadata": {
|
|
13
|
+
"kernelspec": {
|
|
14
|
+
"display_name": "Python 3 (ipykernel)",
|
|
15
|
+
"language": "python",
|
|
16
|
+
"name": "python3"
|
|
17
|
+
},
|
|
18
|
+
"language_info": {
|
|
19
|
+
"codemirror_mode": {
|
|
20
|
+
"name": "ipython",
|
|
21
|
+
"version": 3
|
|
22
|
+
},
|
|
23
|
+
"file_extension": ".py",
|
|
24
|
+
"mimetype": "text/x-python",
|
|
25
|
+
"name": "python",
|
|
26
|
+
"nbconvert_exporter": "python",
|
|
27
|
+
"pygments_lexer": "ipython3",
|
|
28
|
+
"version": "3.11.4"
|
|
29
|
+
}
|
|
17
30
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"name": "ipython",
|
|
21
|
-
"version": 3
|
|
22
|
-
},
|
|
23
|
-
"file_extension": ".py",
|
|
24
|
-
"mimetype": "text/x-python",
|
|
25
|
-
"name": "python",
|
|
26
|
-
"nbconvert_exporter": "python",
|
|
27
|
-
"pygments_lexer": "ipython3",
|
|
28
|
-
"version": "3.11.4"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"nbformat": 4,
|
|
32
|
-
"nbformat_minor": 5
|
|
31
|
+
"nbformat": 4,
|
|
32
|
+
"nbformat_minor": 5
|
|
33
33
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ExampleRuntimeTarget = 'local' | 'cloud';
|
|
2
|
+
interface RuntimeTargetState {
|
|
3
|
+
target: ExampleRuntimeTarget;
|
|
4
|
+
setTarget: (target: ExampleRuntimeTarget) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const runtimeTargetStore: import("zustand").StoreApi<RuntimeTargetState>;
|
|
7
|
+
export declare function useRuntimeTargetStore(): RuntimeTargetState;
|
|
8
|
+
export declare function useRuntimeTargetStore<T>(selector: (state: RuntimeTargetState) => T): T;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { createStore } from 'zustand/vanilla';
|
|
6
|
+
import { useStore } from 'zustand';
|
|
7
|
+
const STORAGE_KEY = 'agent-runtimes.examples.runtime-target';
|
|
8
|
+
const readStoredTarget = () => {
|
|
9
|
+
if (typeof window === 'undefined') {
|
|
10
|
+
return 'local';
|
|
11
|
+
}
|
|
12
|
+
const value = window.localStorage.getItem(STORAGE_KEY);
|
|
13
|
+
return value === 'cloud' ? 'cloud' : 'local';
|
|
14
|
+
};
|
|
15
|
+
export const runtimeTargetStore = createStore(set => ({
|
|
16
|
+
target: readStoredTarget(),
|
|
17
|
+
setTarget: (target) => {
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
window.localStorage.setItem(STORAGE_KEY, target);
|
|
20
|
+
}
|
|
21
|
+
set({ target });
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
export function useRuntimeTargetStore(selector) {
|
|
26
|
+
return useStore(runtimeTargetStore, selector);
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tear down server-side agents created by examples and wipe in-process agent
|
|
3
|
+
* state so a fresh example / runtime target boots with a clean slate.
|
|
4
|
+
*
|
|
5
|
+
* Deletes agents cached in sessionStorage under `agent-runtimes:agentId:<base>`
|
|
6
|
+
* (all of them, or only the given `agentId` when provided), then resets the
|
|
7
|
+
* chat, conversation and runtime stores and drops the persisted slice.
|
|
8
|
+
*
|
|
9
|
+
* @param agentBaseUrl - Base URL of the agent-runtimes server the agents live on.
|
|
10
|
+
* @param token - Optional bearer token for authenticated deletes.
|
|
11
|
+
* @param agentId - Optional specific agent id to tear down (defaults to all cached).
|
|
12
|
+
*/
|
|
13
|
+
export declare function teardownExampleAgents(agentBaseUrl: string, token: string | undefined, agentId?: string): Promise<void>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { agentRuntimeStore, useChatStore, useConversationStore, } from '../../stores';
|
|
6
|
+
/**
|
|
7
|
+
* Tear down server-side agents created by examples and wipe in-process agent
|
|
8
|
+
* state so a fresh example / runtime target boots with a clean slate.
|
|
9
|
+
*
|
|
10
|
+
* Deletes agents cached in sessionStorage under `agent-runtimes:agentId:<base>`
|
|
11
|
+
* (all of them, or only the given `agentId` when provided), then resets the
|
|
12
|
+
* chat, conversation and runtime stores and drops the persisted slice.
|
|
13
|
+
*
|
|
14
|
+
* @param agentBaseUrl - Base URL of the agent-runtimes server the agents live on.
|
|
15
|
+
* @param token - Optional bearer token for authenticated deletes.
|
|
16
|
+
* @param agentId - Optional specific agent id to tear down (defaults to all cached).
|
|
17
|
+
*/
|
|
18
|
+
export async function teardownExampleAgents(agentBaseUrl, token, agentId) {
|
|
19
|
+
// Collect the cached agent-id keys to delete.
|
|
20
|
+
const agentIdKeys = [];
|
|
21
|
+
try {
|
|
22
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
23
|
+
const key = sessionStorage.key(i);
|
|
24
|
+
if (key && key.startsWith('agent-runtimes:agentId:')) {
|
|
25
|
+
if (!agentId || sessionStorage.getItem(key) === agentId) {
|
|
26
|
+
agentIdKeys.push(key);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// sessionStorage unavailable; skip agent deletion.
|
|
33
|
+
}
|
|
34
|
+
const idsToDelete = new Set();
|
|
35
|
+
if (agentId) {
|
|
36
|
+
idsToDelete.add(agentId);
|
|
37
|
+
}
|
|
38
|
+
for (const key of agentIdKeys) {
|
|
39
|
+
try {
|
|
40
|
+
const cached = sessionStorage.getItem(key);
|
|
41
|
+
if (cached)
|
|
42
|
+
idsToDelete.add(cached);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* ignore */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
await Promise.all([...idsToDelete].map(async (id) => {
|
|
49
|
+
try {
|
|
50
|
+
await fetch(`${agentBaseUrl}/api/v1/agents/${encodeURIComponent(id)}`, {
|
|
51
|
+
method: 'DELETE',
|
|
52
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Best-effort teardown: ignore network / 404 errors.
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
for (const key of agentIdKeys) {
|
|
60
|
+
try {
|
|
61
|
+
sessionStorage.removeItem(key);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
/* ignore */
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Wipe every piece of in-process agent state so the next boot is clean.
|
|
68
|
+
useChatStore.getState().reset();
|
|
69
|
+
useConversationStore.getState().clearAll();
|
|
70
|
+
agentRuntimeStore.getState().reset();
|
|
71
|
+
// Drop the persisted slice so nothing rehydrates a previous agent state.
|
|
72
|
+
try {
|
|
73
|
+
localStorage.removeItem('agent-runtimes-storage');
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Ignore storage failures (e.g. private mode).
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ExampleRuntimeTarget } from './runtimeTargetStore';
|
|
2
|
+
export declare function resolveExampleAgentRuntimesUrl(target: ExampleRuntimeTarget, override?: string): string;
|
|
1
3
|
/**
|
|
2
4
|
* Resolve the base URL used by examples to call the agent-runtimes service.
|
|
3
5
|
* Priority: explicit override -> dedicated env -> legacy base env -> localhost.
|
|
@@ -3,17 +3,36 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
|
+
import { useRuntimeTargetStore, } from './runtimeTargetStore';
|
|
7
|
+
const normalizeBaseUrl = (value) => {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const trimmed = value.trim();
|
|
12
|
+
if (!trimmed) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return trimmed.replace(/\/$/, '');
|
|
16
|
+
};
|
|
17
|
+
const LOCAL_DEFAULT = 'http://localhost:8765';
|
|
18
|
+
const CLOUD_DEFAULT = 'https://r1.datalayer.run';
|
|
19
|
+
export function resolveExampleAgentRuntimesUrl(target, override) {
|
|
20
|
+
if (override) {
|
|
21
|
+
return normalizeBaseUrl(override) ?? override;
|
|
22
|
+
}
|
|
23
|
+
const localUrl = normalizeBaseUrl(import.meta.env.VITE_BASE_URL) ?? LOCAL_DEFAULT;
|
|
24
|
+
const cloudUrl = normalizeBaseUrl(import.meta.env.VITE_DATALAYER_AGENT_RUNTIMES_URL) ??
|
|
25
|
+
normalizeBaseUrl(import.meta.env.VITE_DATALAYER_RUNTIMES_URL) ??
|
|
26
|
+
CLOUD_DEFAULT;
|
|
27
|
+
return target === 'cloud' ? cloudUrl : localUrl;
|
|
28
|
+
}
|
|
6
29
|
/**
|
|
7
30
|
* Resolve the base URL used by examples to call the agent-runtimes service.
|
|
8
31
|
* Priority: explicit override -> dedicated env -> legacy base env -> localhost.
|
|
9
32
|
*/
|
|
10
33
|
export function useExampleAgentRuntimesUrl(override) {
|
|
34
|
+
const target = useRuntimeTargetStore(state => state.target);
|
|
11
35
|
return useMemo(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return (import.meta.env.VITE_DATALAYER_AGENT_RUNTIMES_URL ||
|
|
16
|
-
import.meta.env.VITE_BASE_URL ||
|
|
17
|
-
'http://localhost:8765');
|
|
18
|
-
}, [override]);
|
|
36
|
+
return resolveExampleAgentRuntimesUrl(target, override);
|
|
37
|
+
}, [target, override]);
|
|
19
38
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { JupyterReactTheme, Cell, KernelIndicator, useJupyter, useKernelsStore, useCellsStore, } from '@datalayer/jupyter-react';
|
|
3
|
+
import { Button, Label } from '@primer/react';
|
|
4
|
+
import { Box } from '@datalayer/primer-addons';
|
|
5
|
+
const CELL_ID = 'cell-example-1';
|
|
6
|
+
const DEFAULT_SOURCE = `from IPython.display import display
|
|
7
|
+
|
|
8
|
+
for i in range(10):
|
|
9
|
+
display('I am a long string which is repeatedly added to the dom in separated divs: %d' % i)`;
|
|
10
|
+
const CellExampleContent = (props) => {
|
|
11
|
+
// const { serviceManager } = props;
|
|
12
|
+
const { defaultKernel } = useJupyter({ startDefaultKernel: true });
|
|
13
|
+
const cellsStore = useCellsStore();
|
|
14
|
+
const kernelsStore = useKernelsStore();
|
|
15
|
+
return (_jsxs(Box, { p: 4, children: [_jsx(Box, { as: "h1", children: "A Jupyter Cell" }), _jsxs(Box, { children: ["Source: ", cellsStore.getSource(CELL_ID)] }), _jsxs(Box, { children: ["Outputs Count: ", cellsStore.getOutputsCount(CELL_ID)] }), _jsxs(Box, { children: ["Kernel State:", ' ', _jsx(Label, { children: defaultKernel && kernelsStore.getExecutionState(defaultKernel.id) })] }), _jsxs(Box, { children: ["Kernel Phase:", ' ', _jsx(Label, { children: defaultKernel && kernelsStore.getExecutionPhase(defaultKernel.id) })] }), _jsxs(Box, { display: "flex", children: [_jsx(Box, { children: "Kernel Indicator:" }), _jsx(Box, { ml: 3, children: _jsx(KernelIndicator, { kernel: defaultKernel && defaultKernel.connection }) })] }), _jsx(Box, { children: _jsx(Button, { onClick: () => cellsStore.execute(CELL_ID), children: "Run cell" }) }), _jsx(Cell, { source: DEFAULT_SOURCE, id: CELL_ID, kernel: defaultKernel })] }));
|
|
16
|
+
};
|
|
17
|
+
export const CellExample = (props) => {
|
|
18
|
+
return (_jsx(JupyterReactTheme, { children: _jsx(CellExampleContent, { ...props }) }));
|
|
19
|
+
};
|
|
20
|
+
export default CellExample;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
+
/**
|
|
3
|
+
* Example demonstrating how to use Datalayer services with Notebook
|
|
4
|
+
*
|
|
5
|
+
* This example shows:
|
|
6
|
+
* 1. How to create and use DatalayerServiceManager for kernel management
|
|
7
|
+
* 2. How to create and use DatalayerCollaborationProvider for real-time collaboration
|
|
8
|
+
* 3. How to enable/disable Datalayer collaboration
|
|
9
|
+
* 4. How to pass these to the base Notebook component
|
|
10
|
+
* 5. Graceful fallback when Datalayer credentials are not available
|
|
11
|
+
*/
|
|
12
|
+
type IDatalayerNotebookExampleProps = {
|
|
13
|
+
serviceManager?: ServiceManager.IManager;
|
|
14
|
+
};
|
|
15
|
+
declare const DatalayerNotebookExample: (props: IDatalayerNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default DatalayerNotebookExample;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
7
|
+
import { Checkbox, FormControl, Heading } from '@primer/react';
|
|
8
|
+
import { Box } from '@datalayer/primer-addons';
|
|
9
|
+
import { loadJupyterConfig, JupyterReactTheme, Notebook, } from '@datalayer/jupyter-react';
|
|
10
|
+
import { DatalayerCollaborationProvider } from '../collaboration/DatalayerCollaborationProvider';
|
|
11
|
+
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
12
|
+
import { useCoreStore } from '../state';
|
|
13
|
+
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
14
|
+
// This corresponds to the notebook ID in the URL when you open an existing notbook in your library
|
|
15
|
+
const NOTEBOOK_ID = '01JZQRQ35GG871QQCZW9TB1A8J';
|
|
16
|
+
const DatalayerNotebookExample = (props) => {
|
|
17
|
+
// Load config on component mount
|
|
18
|
+
loadJupyterConfig();
|
|
19
|
+
const [nbformat] = useState(nbformatExample);
|
|
20
|
+
const [enableCollaboration, setEnableCollaboration] = useState(false);
|
|
21
|
+
const [readonly] = useState(false);
|
|
22
|
+
const [serviceManager, setServiceManager] = useState(props.serviceManager);
|
|
23
|
+
const { configuration } = useCoreStore();
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
// Create DatalayerServiceManager if not provided
|
|
26
|
+
const createManager = async () => {
|
|
27
|
+
if (props.serviceManager) {
|
|
28
|
+
// Use provided service manager (should be DatalayerServiceManager from main.tsx)
|
|
29
|
+
// Wait for it to be ready
|
|
30
|
+
await props.serviceManager.ready;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Create DatalayerServiceManager if we have credentials
|
|
34
|
+
if (configuration?.token && configuration?.datalayerUrl) {
|
|
35
|
+
try {
|
|
36
|
+
// Now we can pass undefined to use config/defaults
|
|
37
|
+
const manager = await createDatalayerServiceManager(configuration?.cpuEnvironment, configuration?.credits);
|
|
38
|
+
await manager.ready;
|
|
39
|
+
setServiceManager(manager);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to create DatalayerServiceManager:', error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.warn('Datalayer credentials not configured. Please set datalayerUrl and token.');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
createManager();
|
|
50
|
+
}, [props.serviceManager, configuration]);
|
|
51
|
+
// Create the collaboration provider when enabled
|
|
52
|
+
const collaborationProvider = useMemo(() => {
|
|
53
|
+
if (!enableCollaboration) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const datalayerUrl = configuration?.datalayerUrl;
|
|
57
|
+
const token = configuration?.token;
|
|
58
|
+
if (!datalayerUrl || !token) {
|
|
59
|
+
console.warn('Datalayer collaboration enabled but datalayerUrl or token not configured. ' +
|
|
60
|
+
'Please configure them in the Datalayer store or environment.');
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
// Create and return the Datalayer collaboration provider
|
|
64
|
+
return new DatalayerCollaborationProvider({
|
|
65
|
+
datalayerUrl,
|
|
66
|
+
token,
|
|
67
|
+
});
|
|
68
|
+
}, [enableCollaboration, configuration]);
|
|
69
|
+
return (_jsx(JupyterReactTheme, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Datalayer Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.datalayerUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure datalayerUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), enableCollaboration ? (_jsxs(Box, { sx: {
|
|
70
|
+
display: 'flex',
|
|
71
|
+
gap: 2,
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
}, children: [_jsxs(Box, { sx: {
|
|
74
|
+
flex: 1,
|
|
75
|
+
border: '1px solid',
|
|
76
|
+
borderColor: 'border.default',
|
|
77
|
+
borderRadius: 2,
|
|
78
|
+
}, children: [_jsx(Box, { sx: {
|
|
79
|
+
p: 2,
|
|
80
|
+
bg: 'canvas.subtle',
|
|
81
|
+
borderBottom: '1px solid',
|
|
82
|
+
borderColor: 'border.default',
|
|
83
|
+
fontWeight: 'bold',
|
|
84
|
+
}, children: "Collaborator 1" }), _jsx("iframe", { src: `${window.location.origin}/datalayer/notebook`, style: {
|
|
85
|
+
width: '100%',
|
|
86
|
+
height: 'calc(100vh - 280px)',
|
|
87
|
+
border: 'none',
|
|
88
|
+
}, title: "Collaborator 1" })] }), _jsxs(Box, { sx: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
border: '1px solid',
|
|
91
|
+
borderColor: 'border.default',
|
|
92
|
+
borderRadius: 2,
|
|
93
|
+
}, children: [_jsx(Box, { sx: {
|
|
94
|
+
p: 2,
|
|
95
|
+
bg: 'canvas.subtle',
|
|
96
|
+
borderBottom: '1px solid',
|
|
97
|
+
borderColor: 'border.default',
|
|
98
|
+
fontWeight: 'bold',
|
|
99
|
+
}, children: "Collaborator 2" }), _jsx("iframe", { src: `${window.location.origin}/datalayer/notebook`, style: {
|
|
100
|
+
width: '100%',
|
|
101
|
+
height: 'calc(100vh - 280px)',
|
|
102
|
+
border: 'none',
|
|
103
|
+
}, title: "Collaborator 2" })] })] })) : (_jsx(Box, { sx: {
|
|
104
|
+
border: '1px solid',
|
|
105
|
+
borderColor: 'border.default',
|
|
106
|
+
borderRadius: 2,
|
|
107
|
+
}, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (datalayerUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
|
|
108
|
+
};
|
|
109
|
+
export default DatalayerNotebookExample;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Native Navigation Example
|
|
4
|
+
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
5
|
+
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NativeNavigationExample: React.FC;
|
|
8
|
+
export default NativeNavigationExample;
|