@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
|
@@ -9,12 +9,12 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
9
9
|
import { Button, Box, Heading, SegmentedControl, Spinner, Text, } from '@primer/react';
|
|
10
10
|
import { ThemedProvider } from './utils/themedProvider';
|
|
11
11
|
import { uniqueAgentId } from './utils/agentId';
|
|
12
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
12
13
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
13
14
|
import { Chat } from '../chat';
|
|
14
15
|
import { useAIAgentsWebSocket } from '../hooks';
|
|
15
16
|
const AGENTSPEC_ID = 'example-inference';
|
|
16
17
|
const AGENT_NAME = 'inference-provider-example-agent';
|
|
17
|
-
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
18
18
|
const queryClient = new QueryClient();
|
|
19
19
|
const nowIso = () => new Date().toISOString();
|
|
20
20
|
const toErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
@@ -51,14 +51,14 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
51
51
|
const [expandedEventIds, setExpandedEventIds] = useState(() => new Set());
|
|
52
52
|
const currentAgentRef = useRef(null);
|
|
53
53
|
const requestEpochRef = useRef(0);
|
|
54
|
-
const baseUrl =
|
|
54
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
55
55
|
const inferenceUrl = useMemo(() => {
|
|
56
56
|
if (provider === 'local') {
|
|
57
57
|
return 'local inference';
|
|
58
58
|
}
|
|
59
59
|
const env = import.meta.env ?? {};
|
|
60
60
|
return (env.VITE_DATALAYER_AI_INFERENCE_URL ||
|
|
61
|
-
env.
|
|
61
|
+
env.VITE_DATALAYER_URL ||
|
|
62
62
|
'https://prod1.datalayer.run');
|
|
63
63
|
}, [provider]);
|
|
64
64
|
const authFetch = useCallback((url, init = {}) => {
|
|
@@ -248,7 +248,7 @@ const AgentInferenceProviderExampleInner = () => {
|
|
|
248
248
|
borderRadius: 2,
|
|
249
249
|
overflow: 'hidden',
|
|
250
250
|
bg: 'canvas.default',
|
|
251
|
-
}, children: agentId && !isLaunching ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, authToken: token ?? undefined, title: "Agent Inference Provider Example", subtitle: `Spec: ${AGENTSPEC_ID}`, placeholder: "Ask the inference provider something...", showHeader: true, showNewChatButton: true, showClearButton:
|
|
251
|
+
}, children: agentId && !isLaunching ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: baseUrl, agentId: agentId, authToken: token ?? undefined, title: "Agent Inference Provider Example", subtitle: `Spec: ${AGENTSPEC_ID}`, placeholder: "Ask the inference provider something...", showHeader: true, showNewChatButton: true, showClearButton: true, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${baseUrl}/api/v1/history`, onMessageSent: content => {
|
|
252
252
|
appendProviderEvent('provider.request', `Sent message via ${provider}`, {
|
|
253
253
|
provider,
|
|
254
254
|
agentId,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
+
interface AgentLoopExampleInnerProps {
|
|
3
|
+
serviceManager?: ServiceManager.IManager;
|
|
4
|
+
}
|
|
5
|
+
export declare function AgentLoopExampleInner({ serviceManager, }: AgentLoopExampleInnerProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* Main example component with Jupyter provider wrapper.
|
|
8
|
+
*/
|
|
9
|
+
export declare function AgentLoopExample(): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default AgentLoopExample;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AgentLoopExample - Define and launch an agent execution *loop*.
|
|
8
|
+
*
|
|
9
|
+
* This example demonstrates the "loop" paradigm (observe → think → act →
|
|
10
|
+
* evaluate) instead of one-shot prompting. It is fully driven by the generic
|
|
11
|
+
* loop specifications defined in agentspecs (`src/specs/loops.ts`):
|
|
12
|
+
*
|
|
13
|
+
* - Pick any loop spec (Data Analysis, Plan/Execute/Critic, OODA,
|
|
14
|
+
* Human-in-the-Loop). The list is read from the loop catalogue, so adding a
|
|
15
|
+
* new YAML loop spec automatically makes it available here.
|
|
16
|
+
* - The agent's system prompt is composed generically from the selected loop's
|
|
17
|
+
* objective, phases, constraints, termination policy and human settings — no
|
|
18
|
+
* loop-specific code.
|
|
19
|
+
* - The agent then runs the loop against a live Jupyter notebook, where the
|
|
20
|
+
* loop state (dataframes, charts, intermediate results) lives outside the
|
|
21
|
+
* model so each iteration stays small and focused.
|
|
22
|
+
*
|
|
23
|
+
* To run this example:
|
|
24
|
+
* 1. Start the agent-runtimes server.
|
|
25
|
+
* 2. Select this example from the header dropdown (Agent group).
|
|
26
|
+
*
|
|
27
|
+
* @module examples/AgentLoopExample
|
|
28
|
+
*/
|
|
29
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
30
|
+
import { Box } from '@datalayer/primer-addons';
|
|
31
|
+
import { Notebook, useJupyter } from '@datalayer/jupyter-react';
|
|
32
|
+
import { useNotebookTools } from '../tools/adapters/agent-runtimes/notebookHooks';
|
|
33
|
+
import { ThemedJupyterProvider } from './utils/themedProvider';
|
|
34
|
+
import { ChatSidebar } from '../chat';
|
|
35
|
+
import { DEFAULT_MODEL, listLoops, getLoop, DEFAULT_LOOP } from '../specs';
|
|
36
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
37
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
38
|
+
import MatplotlibNotebook from './utils/notebooks/Matplotlib.ipynb.json';
|
|
39
|
+
// Fixed notebook ID
|
|
40
|
+
const NOTEBOOK_ID = 'agent-loop-example';
|
|
41
|
+
// Use the imported Matplotlib notebook as the working surface for the loop.
|
|
42
|
+
const NOTEBOOK_CONTENT = MatplotlibNotebook;
|
|
43
|
+
// Default configuration
|
|
44
|
+
const DEFAULT_AGENT_ID = import.meta.env.VITE_AGENT_ID || 'loop-agent-runtime-example';
|
|
45
|
+
/**
|
|
46
|
+
* Compose an agent system prompt generically from a loop specification.
|
|
47
|
+
*
|
|
48
|
+
* This is intentionally spec-driven: every field comes from the loop YAML, so
|
|
49
|
+
* the same code drives any loop (data analysis, plan/execute/critic, OODA, ...).
|
|
50
|
+
*/
|
|
51
|
+
function buildLoopSystemPrompt(loop) {
|
|
52
|
+
const lines = [];
|
|
53
|
+
lines.push(`You are an agent that operates as a control LOOP rather than answering in a single prompt.`);
|
|
54
|
+
lines.push(`Loop: ${loop.name} (${loop.strategy}).`);
|
|
55
|
+
if (loop.objective) {
|
|
56
|
+
lines.push(`Objective: ${loop.objective}`);
|
|
57
|
+
}
|
|
58
|
+
if (loop.phases?.length) {
|
|
59
|
+
lines.push(`Each iteration, execute these phases in order: ${loop.phases.join(' → ')}. ` +
|
|
60
|
+
`Decide the single best next action each iteration; do not try to solve everything at once.`);
|
|
61
|
+
}
|
|
62
|
+
if (loop.constraints?.length) {
|
|
63
|
+
lines.push(`Constraints you must respect:\n${loop.constraints
|
|
64
|
+
.map(c => `- ${c}`)
|
|
65
|
+
.join('\n')}`);
|
|
66
|
+
}
|
|
67
|
+
if (loop.termination) {
|
|
68
|
+
const t = loop.termination;
|
|
69
|
+
lines.push(`Termination: stop after at most ${t.maxIterations} iterations, or when the goal is reached.`);
|
|
70
|
+
if (t.successCriteria?.length) {
|
|
71
|
+
lines.push(`Success criteria:\n${t.successCriteria.map(s => `- ${s}`).join('\n')}`);
|
|
72
|
+
}
|
|
73
|
+
if (t.onBlocked) {
|
|
74
|
+
lines.push(`If blocked: ${t.onBlocked}.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (loop.human && loop.human.mode !== 'none') {
|
|
78
|
+
lines.push(`Human-in-the-loop: mode "${loop.human.mode}"` +
|
|
79
|
+
(loop.human.approvalRequired
|
|
80
|
+
? `; request explicit approval before: ${loop.human.approvalFor.join(', ') || 'sensitive actions'}.`
|
|
81
|
+
: '.'));
|
|
82
|
+
}
|
|
83
|
+
lines.push(`Keep loop state (dataframes, charts, intermediate results) in the notebook/runtime, not in the prompt. ` +
|
|
84
|
+
`For notebook operations, always use the notebook frontend tools (runCell, readAllCells, readCell, insertCell, updateCell, deleteCells) so actions happen in the live notebook UI. ` +
|
|
85
|
+
`Use executeCode only for temporary inspection code that should not modify notebook cells.`);
|
|
86
|
+
return lines.join('\n\n');
|
|
87
|
+
}
|
|
88
|
+
function getJupyterSandboxUrl(serviceManager) {
|
|
89
|
+
const envUrl = import.meta.env.VITE_JUPYTER_SANDBOX_URL;
|
|
90
|
+
if (envUrl) {
|
|
91
|
+
return envUrl;
|
|
92
|
+
}
|
|
93
|
+
const baseUrl = serviceManager?.serverSettings?.baseUrl?.replace(/\/$/, '');
|
|
94
|
+
if (!baseUrl) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
if (baseUrl.includes('token=')) {
|
|
98
|
+
return baseUrl;
|
|
99
|
+
}
|
|
100
|
+
const token = serviceManager?.serverSettings?.token;
|
|
101
|
+
if (!token) {
|
|
102
|
+
return baseUrl;
|
|
103
|
+
}
|
|
104
|
+
const separator = baseUrl.includes('?') ? '&' : '?';
|
|
105
|
+
return `${baseUrl}${separator}token=${encodeURIComponent(token)}`;
|
|
106
|
+
}
|
|
107
|
+
function NotebookUI({ serviceManager }) {
|
|
108
|
+
if (!serviceManager) {
|
|
109
|
+
return (_jsx(Box, { sx: {
|
|
110
|
+
display: 'flex',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center',
|
|
113
|
+
height: '100%',
|
|
114
|
+
color: 'fg.muted',
|
|
115
|
+
}, children: "Loading Simple services..." }));
|
|
116
|
+
}
|
|
117
|
+
return (_jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "100%", cellSidebarMargin: 120, startDefaultKernel: true }));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A compact, read-only summary of the selected loop specification.
|
|
121
|
+
*/
|
|
122
|
+
function LoopSummary({ loop }) {
|
|
123
|
+
return (_jsxs(Box, { sx: {
|
|
124
|
+
mt: 2,
|
|
125
|
+
p: 2,
|
|
126
|
+
border: '1px solid',
|
|
127
|
+
borderColor: 'border.default',
|
|
128
|
+
borderRadius: 2,
|
|
129
|
+
bg: 'canvas.default',
|
|
130
|
+
fontSize: 0,
|
|
131
|
+
}, children: [_jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 2, mb: 1 }, children: loop.phases.map((phase, index) => (_jsxs(Box, { sx: {
|
|
132
|
+
display: 'flex',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
gap: 1,
|
|
135
|
+
px: 2,
|
|
136
|
+
py: '2px',
|
|
137
|
+
borderRadius: 6,
|
|
138
|
+
bg: 'accent.subtle',
|
|
139
|
+
color: 'accent.fg',
|
|
140
|
+
fontWeight: 'bold',
|
|
141
|
+
}, children: [index + 1, ". ", phase] }, phase))) }), loop.objective && (_jsxs(Box, { sx: { color: 'fg.muted' }, children: [_jsx("strong", { children: "Objective:" }), " ", loop.objective] })), loop.termination && (_jsxs(Box, { sx: { color: 'fg.muted', mt: 1 }, children: [_jsx("strong", { children: "Max iterations:" }), " ", loop.termination.maxIterations, " \u00B7", ' ', _jsx("strong", { children: "On blocked:" }), " ", loop.termination.onBlocked] }))] }));
|
|
142
|
+
}
|
|
143
|
+
export function AgentLoopExampleInner({ serviceManager, }) {
|
|
144
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
145
|
+
const vercelAiEndpoint = `${baseUrl}/api/v1/vercel-ai/${DEFAULT_AGENT_ID}`;
|
|
146
|
+
const [createRequested, setCreateRequested] = useState(false);
|
|
147
|
+
// All available loops come from the generated loop catalogue.
|
|
148
|
+
const loops = useMemo(() => listLoops(), []);
|
|
149
|
+
const [selectedLoopId, setSelectedLoopId] = useState(DEFAULT_LOOP);
|
|
150
|
+
const selectedLoop = useMemo(() => getLoop(selectedLoopId) ?? loops[0], [selectedLoopId, loops]);
|
|
151
|
+
const jupyterSandboxUrl = useMemo(() => getJupyterSandboxUrl(serviceManager), [serviceManager]);
|
|
152
|
+
const systemPrompt = useMemo(() => buildLoopSystemPrompt(selectedLoop), [selectedLoop]);
|
|
153
|
+
const { agentId, isReady, status, error, createAgent } = useExampleAgentRuntime({
|
|
154
|
+
exampleId: 'AgentLoopExample',
|
|
155
|
+
agentName: DEFAULT_AGENT_ID,
|
|
156
|
+
autoCreateAgent: false,
|
|
157
|
+
agentConfig: {
|
|
158
|
+
name: DEFAULT_AGENT_ID,
|
|
159
|
+
description: `Loop agent (${selectedLoop.name}) for AgentLoopExample`,
|
|
160
|
+
protocol: 'vercel-ai',
|
|
161
|
+
model: DEFAULT_MODEL,
|
|
162
|
+
systemPrompt,
|
|
163
|
+
enableCodemode: false,
|
|
164
|
+
sandboxVariant: 'jupyter',
|
|
165
|
+
jupyterSandbox: jupyterSandboxUrl,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
// Launch the loop agent once the sandbox is ready, using the loop that was
|
|
169
|
+
// selected at launch time.
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
if (!jupyterSandboxUrl || createRequested || agentId) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
setCreateRequested(true);
|
|
175
|
+
void createAgent({
|
|
176
|
+
name: DEFAULT_AGENT_ID,
|
|
177
|
+
description: `Loop agent (${selectedLoop.name}) for AgentLoopExample`,
|
|
178
|
+
protocol: 'vercel-ai',
|
|
179
|
+
model: DEFAULT_MODEL,
|
|
180
|
+
systemPrompt,
|
|
181
|
+
enableCodemode: false,
|
|
182
|
+
sandboxVariant: 'jupyter',
|
|
183
|
+
jupyterSandbox: jupyterSandboxUrl,
|
|
184
|
+
}).catch(() => {
|
|
185
|
+
setCreateRequested(false);
|
|
186
|
+
});
|
|
187
|
+
}, [
|
|
188
|
+
jupyterSandboxUrl,
|
|
189
|
+
createRequested,
|
|
190
|
+
agentId,
|
|
191
|
+
createAgent,
|
|
192
|
+
selectedLoop.name,
|
|
193
|
+
systemPrompt,
|
|
194
|
+
]);
|
|
195
|
+
const effectiveReady = isReady || status === 'ready';
|
|
196
|
+
const isLoopSelectorDisabled = createRequested;
|
|
197
|
+
// Get notebook tools for ChatSidebar
|
|
198
|
+
const tools = useNotebookTools(NOTEBOOK_ID);
|
|
199
|
+
// Build Vercel AI protocol config
|
|
200
|
+
const protocolConfig = useMemo(() => {
|
|
201
|
+
return {
|
|
202
|
+
type: 'vercel-ai',
|
|
203
|
+
endpoint: vercelAiEndpoint,
|
|
204
|
+
agentId: DEFAULT_AGENT_ID,
|
|
205
|
+
enableConfigQuery: true,
|
|
206
|
+
configEndpoint: `${baseUrl}/api/v1/configure`,
|
|
207
|
+
};
|
|
208
|
+
}, [baseUrl, vercelAiEndpoint]);
|
|
209
|
+
// Chat suggestions derived from the selected loop.
|
|
210
|
+
const suggestions = useMemo(() => [
|
|
211
|
+
{
|
|
212
|
+
title: `${selectedLoop.emoji} Run the loop`,
|
|
213
|
+
message: selectedLoop.objective
|
|
214
|
+
? `Run the ${selectedLoop.name}. ${selectedLoop.objective}`
|
|
215
|
+
: `Run the ${selectedLoop.name} against the data in this notebook.`,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
title: '🔁 Next iteration',
|
|
219
|
+
message: 'Observe the current notebook state, then decide and execute the single best next step.',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
title: '🎯 Check the goal',
|
|
223
|
+
message: 'Evaluate the latest result against the objective and success criteria. Are we done? If not, what is missing?',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
title: '📊 Summarize findings',
|
|
227
|
+
message: 'Summarize the key findings and produce a final, decision-oriented report.',
|
|
228
|
+
},
|
|
229
|
+
], [selectedLoop]);
|
|
230
|
+
return (_jsx(_Fragment, { children: _jsxs(Box, { sx: {
|
|
231
|
+
height: 'calc(100vh - 70px)',
|
|
232
|
+
width: '100vw',
|
|
233
|
+
display: 'flex',
|
|
234
|
+
overflow: 'hidden',
|
|
235
|
+
}, children: [_jsxs(Box, { sx: {
|
|
236
|
+
flex: 1,
|
|
237
|
+
display: 'flex',
|
|
238
|
+
flexDirection: 'column',
|
|
239
|
+
overflow: 'hidden',
|
|
240
|
+
}, children: [_jsxs(Box, { sx: {
|
|
241
|
+
p: 3,
|
|
242
|
+
borderBottom: '1px solid',
|
|
243
|
+
borderColor: 'border.default',
|
|
244
|
+
bg: 'canvas.subtle',
|
|
245
|
+
}, children: [_jsxs(Box, { sx: {
|
|
246
|
+
display: 'flex',
|
|
247
|
+
alignItems: 'center',
|
|
248
|
+
justifyContent: 'space-between',
|
|
249
|
+
gap: 3,
|
|
250
|
+
flexWrap: 'wrap',
|
|
251
|
+
}, children: [_jsxs(Box, { children: [_jsxs("h1", { style: { margin: 0, fontSize: '1.5rem' }, children: [selectedLoop.emoji, " Agent Loop Example"] }), _jsx("p", { style: { margin: '8px 0 0', color: 'var(--fgColor-muted)' }, children: "Define and launch an agent execution loop \u2014 observe, think, act, evaluate \u2014 over a live notebook." })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, title: isLoopSelectorDisabled
|
|
252
|
+
? 'Loop selector is temporarily disabled while launching the agent'
|
|
253
|
+
: 'Choose a loop', children: [_jsx(Box, { as: "label", sx: { fontSize: 1, fontWeight: 'bold' }, children: "Loop" }), _jsx(Box, { as: "select", value: selectedLoopId, onChange: (e) => setSelectedLoopId(e.target.value), disabled: isLoopSelectorDisabled, "aria-label": "Loop specification", sx: {
|
|
254
|
+
px: 2,
|
|
255
|
+
py: '6px',
|
|
256
|
+
fontSize: 1,
|
|
257
|
+
borderRadius: 2,
|
|
258
|
+
border: '1px solid',
|
|
259
|
+
borderColor: 'border.default',
|
|
260
|
+
bg: 'canvas.default',
|
|
261
|
+
color: 'fg.default',
|
|
262
|
+
}, children: loops.map(loop => (_jsxs("option", { value: loop.id, children: [loop.emoji, " ", loop.name] }, loop.id))) })] })] }), _jsx(LoopSummary, { loop: selectedLoop })] }), _jsx(Box, { sx: {
|
|
263
|
+
flex: 1,
|
|
264
|
+
display: 'flex',
|
|
265
|
+
overflow: 'hidden',
|
|
266
|
+
bg: 'canvas.default',
|
|
267
|
+
p: 3,
|
|
268
|
+
}, children: _jsx(Box, { sx: {
|
|
269
|
+
flex: 1,
|
|
270
|
+
border: '1px solid',
|
|
271
|
+
borderColor: 'border.default',
|
|
272
|
+
borderRadius: 2,
|
|
273
|
+
overflow: 'hidden',
|
|
274
|
+
}, children: _jsx(NotebookUI, { serviceManager: serviceManager }) }) })] }), effectiveReady && (_jsx(ChatSidebar, { title: `${selectedLoop.emoji} ${selectedLoop.name}`, protocol: protocolConfig, position: "right", width: 400, clickOutsideToClose: false, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
|
|
275
|
+
protocol: protocolConfig,
|
|
276
|
+
frontendTools: tools,
|
|
277
|
+
useStore: false,
|
|
278
|
+
showModelSelector: true,
|
|
279
|
+
showToolsMenu: true,
|
|
280
|
+
showSkillsMenu: true,
|
|
281
|
+
suggestions,
|
|
282
|
+
} })), error && (_jsxs(Box, { sx: {
|
|
283
|
+
position: 'fixed',
|
|
284
|
+
bottom: 20,
|
|
285
|
+
right: 20,
|
|
286
|
+
padding: 3,
|
|
287
|
+
backgroundColor: 'danger.subtle',
|
|
288
|
+
color: 'danger.fg',
|
|
289
|
+
borderRadius: 2,
|
|
290
|
+
maxWidth: 320,
|
|
291
|
+
zIndex: 999,
|
|
292
|
+
}, children: [_jsx("strong", { children: "Error:" }), " ", error] }))] }) }));
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Main example component with Jupyter provider wrapper.
|
|
296
|
+
*/
|
|
297
|
+
export function AgentLoopExample() {
|
|
298
|
+
return (_jsx(ThemedJupyterProvider, { children: _jsx(SimpleWrapper, {}) }));
|
|
299
|
+
}
|
|
300
|
+
function SimpleWrapper() {
|
|
301
|
+
const { serviceManager } = useJupyter();
|
|
302
|
+
return _jsx(AgentLoopExampleInner, { serviceManager: serviceManager });
|
|
303
|
+
}
|
|
304
|
+
export default AgentLoopExample;
|
|
@@ -15,6 +15,7 @@ import { ThemedProvider } from './utils/themedProvider';
|
|
|
15
15
|
import { uniqueAgentId } from './utils/agentId';
|
|
16
16
|
import { Chat } from '../chat';
|
|
17
17
|
import { useAIAgentsWebSocket } from '../hooks';
|
|
18
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
18
19
|
import { parseAgentStreamMessage } from '../types/stream';
|
|
19
20
|
import { MCP_STATUS_COLORS, MCP_STATUS_LABELS } from '../types/mcp';
|
|
20
21
|
import { MCP_SERVER_LIBRARY } from '../specs/mcpServers';
|
|
@@ -22,7 +23,6 @@ const queryClient = new QueryClient();
|
|
|
22
23
|
const AGENT_NAME = 'mcp-example-agent';
|
|
23
24
|
// Must match agentspecs/agentspecs/agents/example-mcp.yaml `id`.
|
|
24
25
|
const AGENTSPEC_ID = 'example-mcp';
|
|
25
|
-
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
26
26
|
/* ── Aggregate MCP status helpers ─────────────────────── */
|
|
27
27
|
function deriveAggregate(servers) {
|
|
28
28
|
if (!servers || servers.length === 0)
|
|
@@ -127,7 +127,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
127
127
|
const [liveMcpStatus, setLiveMcpStatus] = useState(undefined);
|
|
128
128
|
// Pending approvals are now managed internally by ChatBase via the Zustand
|
|
129
129
|
// agent-runtime store — no local state needed.
|
|
130
|
-
const agentBaseUrl =
|
|
130
|
+
const agentBaseUrl = useExampleAgentRuntimesUrl();
|
|
131
131
|
const chatAuthToken = token === null ? undefined : token;
|
|
132
132
|
const authFetch = useCallback((url, opts = {}) => fetch(url, {
|
|
133
133
|
...opts,
|
|
@@ -371,7 +371,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
371
371
|
flexDirection: 'column',
|
|
372
372
|
alignItems: 'center',
|
|
373
373
|
justifyContent: 'center',
|
|
374
|
-
height: '
|
|
374
|
+
height: '100%',
|
|
375
375
|
gap: 3,
|
|
376
376
|
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching MCP example agent..." })] }));
|
|
377
377
|
}
|
|
@@ -379,7 +379,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
379
379
|
return _jsx(ErrorView, { error: hookError, onLogout: onLogout });
|
|
380
380
|
}
|
|
381
381
|
return (_jsxs(Box, { sx: {
|
|
382
|
-
height: '
|
|
382
|
+
height: '100%',
|
|
383
383
|
display: 'flex',
|
|
384
384
|
flexDirection: 'column',
|
|
385
385
|
}, children: [isReconnectedAgent && (_jsx(Box, { sx: {
|
|
@@ -387,7 +387,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
387
387
|
py: 1,
|
|
388
388
|
borderBottom: '1px solid',
|
|
389
389
|
borderColor: 'border.default',
|
|
390
|
-
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "MCP Demo Agent", brandIcon: _jsx(GlobeIcon, { size: 16 }), placeholder: "Ask the agent to search the web or explore GitHub...", showHeader: true, showNewChatButton: true, showClearButton:
|
|
390
|
+
}, children: _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "Agent already running - reconnected." }) })), _jsxs(Box, { sx: { flex: 1, minHeight: 0, display: 'flex' }, children: [_jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "MCP Demo Agent", brandIcon: _jsx(GlobeIcon, { size: 16 }), placeholder: "Ask the agent to search the web or explore GitHub...", showHeader: true, showNewChatButton: true, showClearButton: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, mcpStatusData: mcpStatusData, showToolApprovalBanner: true, headerActions: _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: _jsxs(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: ["MCP Tools: ", totalTools] }) }), suggestions: [
|
|
391
391
|
{
|
|
392
392
|
title: '🔍 Search the web',
|
|
393
393
|
message: 'Search the web for recent news about AI agents.',
|
|
@@ -453,7 +453,7 @@ const AgentMCPInner = ({ onLogout }) => {
|
|
|
453
453
|
}, children: [_jsx(ToolsIcon, { size: 12 }), _jsxs(Text, { children: [_jsx("strong", { children: "Tools:" }), " Individual capabilities exposed by each server (search, fetch, etc.)"] })] })] })] })] }))] })] })] })] }));
|
|
454
454
|
};
|
|
455
455
|
const syncTokenToIamStore = (token) => {
|
|
456
|
-
import('
|
|
456
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
457
457
|
iamStore.setState({ token });
|
|
458
458
|
});
|
|
459
459
|
};
|
|
@@ -469,7 +469,7 @@ const AgentMCPExample = () => {
|
|
|
469
469
|
const handleLogout = useCallback(() => {
|
|
470
470
|
clearAuth();
|
|
471
471
|
hasSynced.current = false;
|
|
472
|
-
import('
|
|
472
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
473
473
|
iamStore.setState({ token: undefined });
|
|
474
474
|
});
|
|
475
475
|
}, [clearAuth]);
|
|
@@ -162,7 +162,7 @@ const AgentMemoryInner = ({ onLogout }) => {
|
|
|
162
162
|
flexDirection: 'column',
|
|
163
163
|
alignItems: 'center',
|
|
164
164
|
justifyContent: 'center',
|
|
165
|
-
height: '
|
|
165
|
+
height: '100%',
|
|
166
166
|
gap: 3,
|
|
167
167
|
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching local memory-enabled agent\u2026" })] }));
|
|
168
168
|
}
|
|
@@ -171,7 +171,7 @@ const AgentMemoryInner = ({ onLogout }) => {
|
|
|
171
171
|
}
|
|
172
172
|
// ── Main layout ──────────────────────────────────────────────────────────
|
|
173
173
|
return (_jsxs(Box, { sx: {
|
|
174
|
-
height: '
|
|
174
|
+
height: '100%',
|
|
175
175
|
display: 'flex',
|
|
176
176
|
flexDirection: 'column',
|
|
177
177
|
}, children: [_jsxs(Box, { sx: {
|
|
@@ -244,7 +244,7 @@ const AgentMemoryInner = ({ onLogout }) => {
|
|
|
244
244
|
};
|
|
245
245
|
// ─── Sync token to core IAM store ──────────────────────────────────────────
|
|
246
246
|
const syncTokenToIamStore = (token) => {
|
|
247
|
-
import('
|
|
247
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
248
248
|
iamStore.setState({ token });
|
|
249
249
|
});
|
|
250
250
|
};
|
|
@@ -261,7 +261,7 @@ const AgentMemoryExample = () => {
|
|
|
261
261
|
const handleLogout = useCallback(() => {
|
|
262
262
|
clearAuth();
|
|
263
263
|
hasSynced.current = false;
|
|
264
|
-
import('
|
|
264
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
265
265
|
iamStore.setState({ token: undefined });
|
|
266
266
|
});
|
|
267
267
|
}, [clearAuth]);
|