@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/README.md
CHANGED
|
@@ -62,6 +62,87 @@ Agent Runtimes solves the complexity of deploying AI agents by providing:
|
|
|
62
62
|
- 💾 **Persistence**: DBOS support for durable execution
|
|
63
63
|
- 🔒 **Context Optimization**: LLM context management
|
|
64
64
|
|
|
65
|
+
## Runtime, Snapshot, and Evals Workflows
|
|
66
|
+
|
|
67
|
+
The runtime-oriented examples and CLI workflows migrated from `datalayer-core` now live here.
|
|
68
|
+
|
|
69
|
+
### Python Runtime Quickstart
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agent_runtimes.client import RuntimeClient
|
|
73
|
+
|
|
74
|
+
client = RuntimeClient()
|
|
75
|
+
|
|
76
|
+
# Execute code in a managed runtime
|
|
77
|
+
with client.create_runtime() as runtime:
|
|
78
|
+
response = runtime.execute("print('Hello from Datalayer!')")
|
|
79
|
+
print(response.stdout)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Runtime and Snapshot CLI
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# List available runtimes
|
|
86
|
+
datalayer runtime list
|
|
87
|
+
|
|
88
|
+
# Create a new runtime
|
|
89
|
+
datalayer runtime create ai-env --given-name my-runtime-123
|
|
90
|
+
|
|
91
|
+
# Execute a script in a runtime
|
|
92
|
+
datalayer runtime exec my-script.py --agent <agent-id>
|
|
93
|
+
|
|
94
|
+
# Create a snapshot from a runtime but do not terminate the runtime
|
|
95
|
+
datalayer snapshots create <pod-name> my-snapshot 'AI work!' False
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Subscription and Credits CLI
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# End-user billing view
|
|
102
|
+
datalayer subscriptions show
|
|
103
|
+
datalayer subscriptions available
|
|
104
|
+
datalayer subscriptions move
|
|
105
|
+
datalayer subscriptions topups
|
|
106
|
+
datalayer subscriptions dry-run
|
|
107
|
+
|
|
108
|
+
# Organization and team credits visibility
|
|
109
|
+
datalayer usage org-overview --organization-uid <org_uid>
|
|
110
|
+
datalayer usage team-overview --team-uid <team_uid>
|
|
111
|
+
|
|
112
|
+
# Monitoring-driven credit management
|
|
113
|
+
datalayer usage org-monitor --organization-uid <org_uid> --window-hours 24
|
|
114
|
+
datalayer usage team-monitor --team-uid <team_uid> --window-hours 24
|
|
115
|
+
|
|
116
|
+
# Credits transfer operations (owners/admins)
|
|
117
|
+
datalayer usage org-allocate-team --organization-uid <org_uid> --team-uid <team_uid> --amount 50
|
|
118
|
+
datalayer usage org-revoke-team --organization-uid <org_uid> --team-uid <team_uid> --amount 20
|
|
119
|
+
datalayer usage team-allocate-member --team-uid <team_uid> --member-uid <member_uid> --amount 15
|
|
120
|
+
datalayer usage team-revoke-member --team-uid <team_uid> --member-uid <member_uid> --amount 5
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Evals CLI (Multi-Agentspec)
|
|
124
|
+
|
|
125
|
+
Use comma-separated agentspec ids to create one experiment per agentspec variant:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Creates one experiment per agentspec in the list
|
|
129
|
+
agent-runtimes evals experiments create my-exp \
|
|
130
|
+
--evalset-id <evalset_id> \
|
|
131
|
+
--agent-spec-ids example-evals,example-evals-nocodemode,example-custom
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Generate a comparison report:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
agent-runtimes evals report <evalset_id> --run-limit 50 --export
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
How to interpret grouped comparisons in the report:
|
|
141
|
+
|
|
142
|
+
- `Within-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using the same agentspec id.
|
|
143
|
+
- `Cross-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using different agentspec ids.
|
|
144
|
+
- Pairwise sections compute all combinations for the selected experiments, not just two agentspecs.
|
|
145
|
+
|
|
65
146
|
## Examples
|
|
66
147
|
|
|
67
148
|
The examples demonstrate how to use the Agent Runtimes functionality in various scenarios and frameworks.
|
|
@@ -173,7 +254,7 @@ and propagates those values to the Vite HTML placeholders.
|
|
|
173
254
|
Override any URL on the command line:
|
|
174
255
|
|
|
175
256
|
```bash
|
|
176
|
-
make examples:prod
|
|
257
|
+
make examples:prod DATALAYER_URL=https://prod2.datalayer.run
|
|
177
258
|
```
|
|
178
259
|
|
|
179
260
|
### Running against a local `plane local` stack
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* AgentDocument
|
|
3
3
|
*
|
|
4
|
-
* Standalone Lexical editor + chat interface served at /static/agent-
|
|
4
|
+
* Standalone Lexical editor + chat interface served at /static/agent-document.html.
|
|
5
5
|
* Connects to the agent-runtimes AG-UI endpoint and provides a Lexical
|
|
6
6
|
* rich-text editor alongside the Chat component with lexical tools registered.
|
|
7
7
|
*
|
|
8
8
|
* The page is opened by codeai with a URL like:
|
|
9
|
-
* http://127.0.0.1:<port>/static/agent-
|
|
9
|
+
* http://127.0.0.1:<port>/static/agent-document.html?agentId=<id>
|
|
10
10
|
*
|
|
11
11
|
* Query parameters:
|
|
12
12
|
* - agentId: the agent identifier (required, set by codeai)
|
|
@@ -18,5 +18,5 @@ import React from 'react';
|
|
|
18
18
|
import '@datalayer/jupyter-lexical/style/index.css';
|
|
19
19
|
import './examples/lexical/lexical-theme.css';
|
|
20
20
|
import '../style/primer-primitives.css';
|
|
21
|
-
export declare const
|
|
22
|
-
export default
|
|
21
|
+
export declare const AgentDocument: React.FC;
|
|
22
|
+
export default AgentDocument;
|
|
@@ -4,14 +4,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* AgentDocument
|
|
8
8
|
*
|
|
9
|
-
* Standalone Lexical editor + chat interface served at /static/agent-
|
|
9
|
+
* Standalone Lexical editor + chat interface served at /static/agent-document.html.
|
|
10
10
|
* Connects to the agent-runtimes AG-UI endpoint and provides a Lexical
|
|
11
11
|
* rich-text editor alongside the Chat component with lexical tools registered.
|
|
12
12
|
*
|
|
13
13
|
* The page is opened by codeai with a URL like:
|
|
14
|
-
* http://127.0.0.1:<port>/static/agent-
|
|
14
|
+
* http://127.0.0.1:<port>/static/agent-document.html?agentId=<id>
|
|
15
15
|
*
|
|
16
16
|
* Query parameters:
|
|
17
17
|
* - agentId: the agent identifier (required, set by codeai)
|
|
@@ -37,10 +37,10 @@ import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
|
37
37
|
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
38
38
|
import { Text, Spinner } from '@primer/react';
|
|
39
39
|
import { AlertIcon } from '@primer/octicons-react';
|
|
40
|
-
import { Box, DatalayerThemeProvider, setupPrimerPortals, } from '@datalayer/primer-addons';
|
|
41
|
-
import { JupyterReactTheme,
|
|
40
|
+
import { AppearanceControlsWithStore, Box, createThemeStore, DatalayerThemeProvider, setupPrimerPortals, themeConfigs, useSystemColorMode, } from '@datalayer/primer-addons';
|
|
41
|
+
import { JupyterReactTheme, disposeServiceManager, loadJupyterConfig, getJupyterServerUrl, getJupyterServerToken, setJupyterServerUrl, setJupyterServerToken, useJupyter, } from '@datalayer/jupyter-react';
|
|
42
42
|
import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, ExcalidrawPlugin, CollapsiblePlugin, AutoLinkPlugin, AutoEmbedPlugin, LexicalConfigProvider, LexicalStatePlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, TableCellResizerPlugin, TablePlugin, } from '@datalayer/jupyter-lexical';
|
|
43
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
43
|
+
import { ServiceManager, ServerConnection } from '@jupyterlab/services';
|
|
44
44
|
import { Chat } from './chat';
|
|
45
45
|
import { ChatInlinePlugin } from './lexical/ChatInlinePlugin';
|
|
46
46
|
import { useChatInlineToolbarItems } from './lexical/useChatInlineToolbarItems';
|
|
@@ -52,13 +52,42 @@ import './examples/lexical/lexical-theme.css';
|
|
|
52
52
|
import '../style/primer-primitives.css';
|
|
53
53
|
setupPrimerPortals();
|
|
54
54
|
const BASE_URL = window.location.origin;
|
|
55
|
-
const
|
|
55
|
+
const DOCUMENT_ID = 'agent-document';
|
|
56
|
+
const DOCUMENT_THEME_STORAGE_KEY = 'agent-runtimes-agent-document-theme';
|
|
57
|
+
const useAgentDocumentThemeStore = createThemeStore(DOCUMENT_THEME_STORAGE_KEY, {
|
|
58
|
+
colorMode: 'auto',
|
|
59
|
+
theme: 'earth',
|
|
60
|
+
});
|
|
56
61
|
function getQueryParam(name) {
|
|
57
62
|
return new URLSearchParams(window.location.search).get(name);
|
|
58
63
|
}
|
|
59
64
|
function getAgentId() {
|
|
60
65
|
return getQueryParam('agentId') || 'default';
|
|
61
66
|
}
|
|
67
|
+
function getKernelId() {
|
|
68
|
+
const kernelId = getQueryParam('kernelId') || getQueryParam('kernel_id');
|
|
69
|
+
return kernelId || undefined;
|
|
70
|
+
}
|
|
71
|
+
async function fetchStartupKernelId() {
|
|
72
|
+
try {
|
|
73
|
+
const resp = await fetch(`${BASE_URL}/health/startup`);
|
|
74
|
+
if (!resp.ok) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
const payload = await resp.json();
|
|
78
|
+
const sandbox = payload?.sandbox;
|
|
79
|
+
if (sandbox?.variant !== 'jupyter') {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const kernelId = sandbox?.kernel_id;
|
|
83
|
+
return typeof kernelId === 'string' && kernelId.length > 0
|
|
84
|
+
? kernelId
|
|
85
|
+
: undefined;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
62
91
|
/**
|
|
63
92
|
* Initialise Jupyter configuration.
|
|
64
93
|
*
|
|
@@ -69,24 +98,52 @@ function getAgentId() {
|
|
|
69
98
|
function initJupyterConfig() {
|
|
70
99
|
loadJupyterConfig();
|
|
71
100
|
const qBaseUrl = getQueryParam('jupyterBaseUrl');
|
|
72
|
-
const qToken = getQueryParam('jupyterToken');
|
|
101
|
+
const qToken = getQueryParam('jupyterToken') || getQueryParam('token');
|
|
73
102
|
if (qBaseUrl)
|
|
74
103
|
setJupyterServerUrl(qBaseUrl);
|
|
75
104
|
if (qToken)
|
|
76
105
|
setJupyterServerToken(qToken);
|
|
106
|
+
let resolvedBaseUrl = qBaseUrl || getJupyterServerUrl();
|
|
107
|
+
let resolvedToken = qToken || getJupyterServerToken();
|
|
77
108
|
const el = document.getElementById('jupyter-config-data');
|
|
78
109
|
if (el?.textContent) {
|
|
79
110
|
try {
|
|
80
111
|
const cfg = JSON.parse(el.textContent);
|
|
81
|
-
if (!qBaseUrl && cfg.baseUrl)
|
|
112
|
+
if (!qBaseUrl && cfg.baseUrl) {
|
|
82
113
|
setJupyterServerUrl(cfg.baseUrl);
|
|
83
|
-
|
|
114
|
+
resolvedBaseUrl = cfg.baseUrl;
|
|
115
|
+
}
|
|
116
|
+
if (!qToken && cfg.token) {
|
|
84
117
|
setJupyterServerToken(cfg.token);
|
|
118
|
+
resolvedToken = cfg.token;
|
|
119
|
+
}
|
|
85
120
|
}
|
|
86
121
|
catch {
|
|
87
122
|
// ignore
|
|
88
123
|
}
|
|
89
124
|
}
|
|
125
|
+
return {
|
|
126
|
+
baseUrl: resolvedBaseUrl,
|
|
127
|
+
token: resolvedToken,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function buildServerSettings(baseUrl, token) {
|
|
131
|
+
const wsUrl = baseUrl.replace(/^http/, 'ws');
|
|
132
|
+
const authenticatedFetch = (input, init) => {
|
|
133
|
+
if (!token) {
|
|
134
|
+
return fetch(input, init);
|
|
135
|
+
}
|
|
136
|
+
const headers = new Headers(init?.headers || undefined);
|
|
137
|
+
headers.set('Authorization', `token ${token}`);
|
|
138
|
+
return fetch(input, { ...init, headers });
|
|
139
|
+
};
|
|
140
|
+
return ServerConnection.makeSettings({
|
|
141
|
+
baseUrl,
|
|
142
|
+
wsUrl,
|
|
143
|
+
token,
|
|
144
|
+
appendToken: !!token,
|
|
145
|
+
fetch: authenticatedFetch,
|
|
146
|
+
});
|
|
90
147
|
}
|
|
91
148
|
// ─── Lexical plugins ────────────────────────────────────────────────────────
|
|
92
149
|
/**
|
|
@@ -128,8 +185,18 @@ function CodeHighlightPlugin() {
|
|
|
128
185
|
}, [editor]);
|
|
129
186
|
return null;
|
|
130
187
|
}
|
|
131
|
-
function KernelPluginsInner() {
|
|
132
|
-
const { defaultKernel } = useJupyter(
|
|
188
|
+
function KernelPluginsInner({ serviceManager, kernelId, onKernelReady, }) {
|
|
189
|
+
const { defaultKernel } = useJupyter({
|
|
190
|
+
serviceManager,
|
|
191
|
+
useRunningKernelId: kernelId,
|
|
192
|
+
startDefaultKernel: !kernelId,
|
|
193
|
+
});
|
|
194
|
+
// Lift the live kernel connection of the document's sandbox up so the chat
|
|
195
|
+
// header's kernel indicator reflects it. `defaultKernel` is created
|
|
196
|
+
// asynchronously and can change on restart.
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
onKernelReady?.(defaultKernel?.connection ?? null);
|
|
199
|
+
}, [defaultKernel, onKernelReady]);
|
|
133
200
|
return (_jsxs(_Fragment, { children: [_jsx(ComponentPickerMenuPlugin, { kernel: defaultKernel }), _jsx(JupyterInputOutputPlugin, { kernel: defaultKernel })] }));
|
|
134
201
|
}
|
|
135
202
|
/**
|
|
@@ -137,13 +204,13 @@ function KernelPluginsInner() {
|
|
|
137
204
|
* Must be rendered inside LexicalConfigProvider context.
|
|
138
205
|
*/
|
|
139
206
|
function LexicalToolsPlugin({ onToolsReady, }) {
|
|
140
|
-
const tools = useLexicalTools(
|
|
207
|
+
const tools = useLexicalTools(DOCUMENT_ID);
|
|
141
208
|
useEffect(() => {
|
|
142
209
|
onToolsReady(tools);
|
|
143
210
|
}, [tools, onToolsReady]);
|
|
144
211
|
return null;
|
|
145
212
|
}
|
|
146
|
-
const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, onToolsReady, }) {
|
|
213
|
+
const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, kernelId, colormode, backgroundColor, onToolsReady, onKernelReady, }) {
|
|
147
214
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
148
215
|
const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
149
216
|
const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } = useChatInlineToolbarItems();
|
|
@@ -164,19 +231,19 @@ const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, onToolsR
|
|
|
164
231
|
overflow: 'auto',
|
|
165
232
|
borderRight: '1px solid',
|
|
166
233
|
borderColor: 'border.default',
|
|
167
|
-
}, children: _jsx(Box, { sx: { padding: 3 }, children: _jsxs(LexicalConfigProvider, { lexicalId:
|
|
234
|
+
}, children: _jsx(Box, { sx: { padding: 3 }, children: _jsxs(LexicalConfigProvider, { lexicalId: DOCUMENT_ID, serviceManager: serviceManager, children: [_jsx(LexicalToolsPlugin, { onToolsReady: onToolsReady }), _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, {}), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { colormode: colormode, backgroundColor: backgroundColor, children: _jsx(KernelPluginsInner, { serviceManager: serviceManager, kernelId: kernelId, onKernelReady: onKernelReady }) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: toolbarItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
|
|
168
235
|
type: 'ag-ui',
|
|
169
236
|
endpoint: agUiEndpoint,
|
|
170
237
|
}, isOpen: isAiOpen, onClose: closeAi, pendingPrompt: pendingPrompt, onPendingPromptConsumed: clearPendingPrompt })] }) })] }) }) }));
|
|
171
238
|
});
|
|
172
|
-
const ChatPanel = ({ agentId, tools }) => {
|
|
239
|
+
const ChatPanel = ({ agentId, tools, kernel }) => {
|
|
173
240
|
return (_jsx(Box, { sx: {
|
|
174
241
|
width: '420px',
|
|
175
242
|
minWidth: '320px',
|
|
176
243
|
display: 'flex',
|
|
177
244
|
flexDirection: 'column',
|
|
178
245
|
overflow: 'hidden',
|
|
179
|
-
}, children: _jsx(Chat, { protocol: "ag-ui", baseUrl: BASE_URL, agentId: agentId, title: "Agent
|
|
246
|
+
}, children: _jsx(Chat, { protocol: "ag-ui", baseUrl: BASE_URL, agentId: agentId, title: "Agent Document", placeholder: "Ask about the document...", description: "Chat with the agent to manipulate the document", showHeader: true, height: "100%", showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, disableInternalJupyterTheme: true, frontendTools: tools, autoFocus: true, runtimeId: agentId, kernel: kernel, historyEndpoint: `${BASE_URL}/api/v1/history`, suggestions: [
|
|
180
247
|
{
|
|
181
248
|
title: 'Insert heading',
|
|
182
249
|
message: 'Insert a heading that says "Welcome"',
|
|
@@ -192,18 +259,33 @@ const ChatPanel = ({ agentId, tools }) => {
|
|
|
192
259
|
], submitOnSuggestionClick: true }) }));
|
|
193
260
|
};
|
|
194
261
|
// ─── Main component ─────────────────────────────────────────────────────────
|
|
195
|
-
export const
|
|
262
|
+
export const AgentDocument = () => {
|
|
196
263
|
const [agentId] = useState(getAgentId);
|
|
264
|
+
const [kernelId, setKernelId] = useState(getKernelId);
|
|
265
|
+
const [kernelResolved, setKernelResolved] = useState(() => Boolean(getKernelId()));
|
|
197
266
|
const [isReady, setIsReady] = useState(false);
|
|
198
267
|
const [error, setError] = useState(null);
|
|
199
268
|
const [serviceManager, setServiceManager] = useState(null);
|
|
200
269
|
const [tools, setTools] = useState([]);
|
|
270
|
+
const [documentKernel, setDocumentKernel] = useState(null);
|
|
271
|
+
const { colorMode, theme } = useAgentDocumentThemeStore();
|
|
272
|
+
const themeConfig = themeConfigs[theme];
|
|
273
|
+
const systemMode = useSystemColorMode();
|
|
274
|
+
const resolvedMode = colorMode === 'auto' ? systemMode : colorMode;
|
|
275
|
+
const modeStyles = resolvedMode === 'dark'
|
|
276
|
+
? themeConfig.themeStyles.dark
|
|
277
|
+
: themeConfig.themeStyles.light;
|
|
278
|
+
const themeBackground = modeStyles.backgroundColor ?? '';
|
|
201
279
|
const handleToolsReady = useCallback((newTools) => {
|
|
202
280
|
setTools(newTools);
|
|
203
281
|
}, []);
|
|
282
|
+
const handleKernelReady = useCallback((kernel) => {
|
|
283
|
+
setDocumentKernel(prev => (prev?.id === kernel?.id ? prev : kernel));
|
|
284
|
+
}, []);
|
|
204
285
|
// Verify the agent exists AND initialise the Jupyter service manager
|
|
205
286
|
useEffect(() => {
|
|
206
287
|
let cancelled = false;
|
|
288
|
+
let managerForCleanup = null;
|
|
207
289
|
const init = async () => {
|
|
208
290
|
try {
|
|
209
291
|
// 1. Ensure agent exists — create if missing
|
|
@@ -214,7 +296,7 @@ export const AgentLexical = () => {
|
|
|
214
296
|
headers: { 'Content-Type': 'application/json' },
|
|
215
297
|
body: JSON.stringify({
|
|
216
298
|
name: agentId,
|
|
217
|
-
description: 'Agent created by Agent
|
|
299
|
+
description: 'Agent created by Agent Document page',
|
|
218
300
|
agent_library: 'pydantic-ai',
|
|
219
301
|
transport: 'ag-ui',
|
|
220
302
|
model: DEFAULT_MODEL,
|
|
@@ -227,14 +309,19 @@ export const AgentLexical = () => {
|
|
|
227
309
|
}
|
|
228
310
|
}
|
|
229
311
|
// 2. Initialise Jupyter
|
|
230
|
-
initJupyterConfig();
|
|
231
|
-
const serverSettings =
|
|
312
|
+
const jupyterConfig = initJupyterConfig();
|
|
313
|
+
const serverSettings = buildServerSettings(jupyterConfig.baseUrl, jupyterConfig.token);
|
|
232
314
|
const manager = new ServiceManager({ serverSettings });
|
|
315
|
+
managerForCleanup = manager;
|
|
233
316
|
await manager.ready;
|
|
234
317
|
if (!cancelled) {
|
|
235
318
|
setServiceManager(manager);
|
|
236
319
|
setIsReady(true);
|
|
237
320
|
}
|
|
321
|
+
else {
|
|
322
|
+
disposeServiceManager(manager);
|
|
323
|
+
managerForCleanup = null;
|
|
324
|
+
}
|
|
238
325
|
}
|
|
239
326
|
catch (err) {
|
|
240
327
|
if (!cancelled) {
|
|
@@ -245,11 +332,39 @@ export const AgentLexical = () => {
|
|
|
245
332
|
init();
|
|
246
333
|
return () => {
|
|
247
334
|
cancelled = true;
|
|
335
|
+
if (managerForCleanup) {
|
|
336
|
+
disposeServiceManager(managerForCleanup);
|
|
337
|
+
managerForCleanup = null;
|
|
338
|
+
}
|
|
248
339
|
};
|
|
249
340
|
}, [agentId]);
|
|
341
|
+
// If kernelId is not provided via URL, reuse the startup sandbox kernel when
|
|
342
|
+
// available so lexical cells run in the same code sandbox as the agent.
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
if (kernelId) {
|
|
345
|
+
setKernelResolved(true);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let cancelled = false;
|
|
349
|
+
void (async () => {
|
|
350
|
+
const startupKernelId = await fetchStartupKernelId();
|
|
351
|
+
if (cancelled) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (startupKernelId) {
|
|
355
|
+
setKernelId(startupKernelId);
|
|
356
|
+
}
|
|
357
|
+
// Mark resolution complete even when no sandbox kernel exists so the
|
|
358
|
+
// editor can fall back to a default kernel instead of hanging.
|
|
359
|
+
setKernelResolved(true);
|
|
360
|
+
})();
|
|
361
|
+
return () => {
|
|
362
|
+
cancelled = true;
|
|
363
|
+
};
|
|
364
|
+
}, [kernelId]);
|
|
250
365
|
// Loading
|
|
251
366
|
if (!isReady && !error) {
|
|
252
|
-
return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
|
|
367
|
+
return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
|
|
253
368
|
display: 'flex',
|
|
254
369
|
flexDirection: 'column',
|
|
255
370
|
alignItems: 'center',
|
|
@@ -261,7 +376,7 @@ export const AgentLexical = () => {
|
|
|
261
376
|
}
|
|
262
377
|
// Error
|
|
263
378
|
if (error) {
|
|
264
|
-
return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
|
|
379
|
+
return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
|
|
265
380
|
display: 'flex',
|
|
266
381
|
flexDirection: 'column',
|
|
267
382
|
alignItems: 'center',
|
|
@@ -272,12 +387,27 @@ export const AgentLexical = () => {
|
|
|
272
387
|
}, children: [_jsx(AlertIcon, { size: 48 }), _jsx(Text, { sx: { color: 'danger.fg', fontSize: 2 }, children: "Failed to connect" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: error })] }) }));
|
|
273
388
|
}
|
|
274
389
|
// Ready — lexical editor + chat side-by-side
|
|
275
|
-
return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
|
|
390
|
+
return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
|
|
276
391
|
display: 'flex',
|
|
392
|
+
flexDirection: 'column',
|
|
277
393
|
height: '100vh',
|
|
278
394
|
width: '100vw',
|
|
279
395
|
overflow: 'hidden',
|
|
280
396
|
bg: 'canvas.default',
|
|
281
|
-
}, children: [
|
|
397
|
+
}, children: [_jsx(Box, { sx: {
|
|
398
|
+
display: 'flex',
|
|
399
|
+
justifyContent: 'flex-end',
|
|
400
|
+
alignItems: 'center',
|
|
401
|
+
px: 3,
|
|
402
|
+
py: 2,
|
|
403
|
+
borderBottom: '1px solid',
|
|
404
|
+
borderColor: 'border.default',
|
|
405
|
+
flexShrink: 0,
|
|
406
|
+
}, children: _jsx(AppearanceControlsWithStore, { useStore: useAgentDocumentThemeStore }) }), _jsxs(Box, { sx: {
|
|
407
|
+
display: 'flex',
|
|
408
|
+
flex: 1,
|
|
409
|
+
minHeight: 0,
|
|
410
|
+
overflow: 'hidden',
|
|
411
|
+
}, children: [serviceManager && kernelResolved && (_jsx(LexicalPanel, { serviceManager: serviceManager, kernelId: kernelId, colormode: resolvedMode, backgroundColor: themeBackground, onToolsReady: handleToolsReady, onKernelReady: handleKernelReady })), _jsx(ChatPanel, { agentId: agentId, tools: tools, kernel: documentKernel })] })] }) }));
|
|
282
412
|
};
|
|
283
|
-
export default
|
|
413
|
+
export default AgentDocument;
|
package/lib/AgentNode.js
CHANGED
|
@@ -13,7 +13,7 @@ import { SignInSimple } from '@datalayer/core/lib/views/iam';
|
|
|
13
13
|
import { UserBadge } from '@datalayer/core/lib/views/profile';
|
|
14
14
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
15
15
|
import { useIAMStore } from '@datalayer/core/lib/state';
|
|
16
|
-
import {
|
|
16
|
+
import { BillingEntitySelect, } from '@datalayer/core/lib/components/billing';
|
|
17
17
|
import { ShareAccessComponent } from '@datalayer/core/lib/components/sharing';
|
|
18
18
|
import { useAgentNodeThemeStore } from './agent-node/themeStore';
|
|
19
19
|
import { Chat } from './chat';
|
|
@@ -129,7 +129,7 @@ export function AgentNode() {
|
|
|
129
129
|
const [step, setStep] = useState('auth');
|
|
130
130
|
const [disableAutoBootstrap, setDisableAutoBootstrap] = useState(false);
|
|
131
131
|
const [configuration, setConfiguration] = useState(DEFAULT_CONFIGURATION);
|
|
132
|
-
const [,
|
|
132
|
+
const [, setSelectedBillingEntity] = useState(undefined);
|
|
133
133
|
const [isSaving, setIsSaving] = useState(false);
|
|
134
134
|
const [error, setError] = useState(null);
|
|
135
135
|
const [inferenceProvider, setInferenceProvider] = useState('datalayer');
|
|
@@ -158,9 +158,9 @@ export function AgentNode() {
|
|
|
158
158
|
};
|
|
159
159
|
}, []);
|
|
160
160
|
const pushCredentials = useCallback((authToken, payloadToken = authToken) => {
|
|
161
|
-
const
|
|
161
|
+
const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
|
|
162
162
|
'https://prod1.datalayer.run';
|
|
163
|
-
const
|
|
163
|
+
const runtimesUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || datalayerUrl;
|
|
164
164
|
const headers = {
|
|
165
165
|
'Content-Type': 'application/json',
|
|
166
166
|
};
|
|
@@ -172,14 +172,14 @@ export function AgentNode() {
|
|
|
172
172
|
headers,
|
|
173
173
|
body: JSON.stringify({
|
|
174
174
|
token: payloadToken || null,
|
|
175
|
-
runtimes_url: payloadToken ?
|
|
175
|
+
runtimes_url: payloadToken ? runtimesUrl : null,
|
|
176
176
|
}),
|
|
177
177
|
});
|
|
178
178
|
}, []);
|
|
179
|
-
// Refs kept in sync with state so the
|
|
179
|
+
// Refs kept in sync with state so the BillingEntitySelect callbacks
|
|
180
180
|
// (passed via stable identities) can read the latest values without
|
|
181
181
|
// being re-created on every render — re-created callbacks made
|
|
182
|
-
//
|
|
182
|
+
// BillingEntitySelect re-fire onAccountsResolved and trigger an
|
|
183
183
|
// infinite setState loop.
|
|
184
184
|
const configurationRef = useRef(configuration);
|
|
185
185
|
useEffect(() => {
|
|
@@ -189,19 +189,19 @@ export function AgentNode() {
|
|
|
189
189
|
useEffect(() => {
|
|
190
190
|
iamUserRef.current = iamUser;
|
|
191
191
|
}, [iamUser]);
|
|
192
|
-
const
|
|
193
|
-
setConfiguration(prev => ({ ...prev,
|
|
192
|
+
const handleBillingEntityChange = useCallback((uid) => {
|
|
193
|
+
setConfiguration(prev => ({ ...prev, billing_entity_uid: uid }));
|
|
194
194
|
}, []);
|
|
195
195
|
const handleSelectedAccountChange = useCallback((account) => {
|
|
196
|
-
|
|
196
|
+
setSelectedBillingEntity(account);
|
|
197
197
|
setConfiguration(prev => ({
|
|
198
198
|
...prev,
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
billing_entity_type: account?.accountType,
|
|
200
|
+
billing_entity_handle: account?.accountHandle,
|
|
201
201
|
}));
|
|
202
202
|
}, []);
|
|
203
203
|
const handleAccountsResolved = useCallback((_state) => {
|
|
204
|
-
//
|
|
204
|
+
// BillingEntitySelect persists the chosen account in a cookie and
|
|
205
205
|
// falls back to the personal account when none is stored, so the node
|
|
206
206
|
// no longer needs to force an organization default here.
|
|
207
207
|
}, []);
|
|
@@ -343,25 +343,26 @@ export function AgentNode() {
|
|
|
343
343
|
}, [token, pushCredentials]);
|
|
344
344
|
useEffect(() => {
|
|
345
345
|
import('@datalayer/core/lib/state').then(({ iamStore, coreStore }) => {
|
|
346
|
-
const
|
|
346
|
+
const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
|
|
347
347
|
'https://prod1.datalayer.run';
|
|
348
|
-
const
|
|
349
|
-
const
|
|
348
|
+
const runtimesUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || datalayerUrl;
|
|
349
|
+
const aiInferenceUrl = import.meta.env?.VITE_DATALAYER_AI_INFERENCE_URL ||
|
|
350
|
+
datalayerUrl;
|
|
350
351
|
// Seed all per-service URLs to match the main UI login behavior.
|
|
351
352
|
const coreApi = coreStore.getState();
|
|
352
353
|
const prevCfg = coreApi.configuration ?? {};
|
|
353
354
|
const urls = {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
355
|
+
iamUrl: datalayerUrl,
|
|
356
|
+
runtimesUrl,
|
|
357
|
+
spacerUrl: datalayerUrl,
|
|
358
|
+
libraryUrl: datalayerUrl,
|
|
359
|
+
aiAgentsUrl: datalayerUrl,
|
|
360
|
+
aiInferenceUrl: aiInferenceUrl,
|
|
361
|
+
mcpServersUrl: datalayerUrl,
|
|
362
|
+
otelUrl: datalayerUrl,
|
|
363
|
+
growthUrl: datalayerUrl,
|
|
364
|
+
successUrl: datalayerUrl,
|
|
365
|
+
supportUrl: datalayerUrl,
|
|
365
366
|
};
|
|
366
367
|
if (typeof coreApi.setConfiguration === 'function') {
|
|
367
368
|
coreApi.setConfiguration({ ...prevCfg, ...urls });
|
|
@@ -372,7 +373,7 @@ export function AgentNode() {
|
|
|
372
373
|
}));
|
|
373
374
|
}
|
|
374
375
|
const api = iamStore.getState();
|
|
375
|
-
iamStore.setState({ token: tokenForCore,
|
|
376
|
+
iamStore.setState({ token: tokenForCore, iamUrl: datalayerUrl });
|
|
376
377
|
if (tokenForCore && typeof api.refreshUserByToken === 'function') {
|
|
377
378
|
void Promise.resolve(api.refreshUserByToken(tokenForCore)).then(() => {
|
|
378
379
|
queryClient.invalidateQueries({ queryKey: ['organizations'] });
|
|
@@ -406,10 +407,10 @@ export function AgentNode() {
|
|
|
406
407
|
// API keys are exchanged for a session token before login so billing and
|
|
407
408
|
// plans endpoints (/api/iam/v1/plans/*) resolve the correct paid plan.
|
|
408
409
|
const handleApiKeySignIn = async (apiKey) => {
|
|
409
|
-
const
|
|
410
|
+
const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
|
|
410
411
|
'https://prod1.datalayer.run';
|
|
411
412
|
try {
|
|
412
|
-
const resp = await fetch(`${
|
|
413
|
+
const resp = await fetch(`${datalayerUrl}/api/iam/v1/login`, {
|
|
413
414
|
method: 'POST',
|
|
414
415
|
headers: { 'Content-Type': 'application/json' },
|
|
415
416
|
body: JSON.stringify({ token: apiKey }),
|
|
@@ -662,7 +663,7 @@ export function AgentNode() {
|
|
|
662
663
|
display: 'flex',
|
|
663
664
|
flexDirection: 'column',
|
|
664
665
|
gap: 1,
|
|
665
|
-
}, children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Bedrock Anthropic model" }), inferenceModels.length === 0 ? (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "No model list available." })) : (_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { children: inferenceDefaultModel || inferenceModels[0] }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsx(ActionList, { selectionVariant: "single", children: inferenceModels.map(model => (_jsx(ActionList.Item, { selected: inferenceDefaultModel === model, inactiveText: "Selection is locked", children: model }, model))) }) })] }))] }))] }), iamUser ? (_jsx(
|
|
666
|
+
}, children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Bedrock Anthropic model" }), inferenceModels.length === 0 ? (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "No model list available." })) : (_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { children: inferenceDefaultModel || inferenceModels[0] }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsx(ActionList, { selectionVariant: "single", children: inferenceModels.map(model => (_jsx(ActionList.Item, { selected: inferenceDefaultModel === model, inactiveText: "Selection is locked", children: model }, model))) }) })] }))] }))] }), iamUser ? (_jsx(BillingEntitySelect, { value: configuration.billing_entity_uid || '', onChange: handleBillingEntityChange, onSelectedAccountChange: handleSelectedAccountChange, onAccountsResolved: handleAccountsResolved })) : (_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Run this agent under" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Loading billing entitys..." })] }))] }), _jsxs(Box, { sx: {
|
|
666
667
|
display: 'flex',
|
|
667
668
|
flexDirection: 'column',
|
|
668
669
|
gap: 2,
|