@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
|
@@ -5,22 +5,11 @@
|
|
|
5
5
|
* Human in the Loop example backend. This shows how to implement
|
|
6
6
|
* approval workflows where the human must approve generated plans.
|
|
7
7
|
*
|
|
8
|
-
* Backend:
|
|
8
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-human-in-the-loop)
|
|
9
9
|
*
|
|
10
10
|
* Pattern: Uses renderToolResult with respond callback for human-in-the-loop
|
|
11
11
|
* interactions, matching the CopilotKit useHumanInTheLoop pattern.
|
|
12
12
|
*/
|
|
13
13
|
import React from 'react';
|
|
14
|
-
/**
|
|
15
|
-
* AgUiHumanInTheLoopExample Component
|
|
16
|
-
*
|
|
17
|
-
* Demonstrates human-in-the-loop approval patterns with AG-UI.
|
|
18
|
-
* The agent generates task steps that require human approval before proceeding.
|
|
19
|
-
*
|
|
20
|
-
* Features demonstrated:
|
|
21
|
-
* - Tool call rendering with Reject/Confirm buttons
|
|
22
|
-
* - respond callback for sending user decisions back to the agent
|
|
23
|
-
* - UI state changes based on user actions
|
|
24
|
-
*/
|
|
25
14
|
declare const AgUiHumanInTheLoopExample: React.FC;
|
|
26
15
|
export default AgUiHumanInTheLoopExample;
|
|
@@ -10,19 +10,20 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
10
10
|
* Human in the Loop example backend. This shows how to implement
|
|
11
11
|
* approval workflows where the human must approve generated plans.
|
|
12
12
|
*
|
|
13
|
-
* Backend:
|
|
13
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-human-in-the-loop)
|
|
14
14
|
*
|
|
15
15
|
* Pattern: Uses renderToolResult with respond callback for human-in-the-loop
|
|
16
16
|
* interactions, matching the CopilotKit useHumanInTheLoop pattern.
|
|
17
17
|
*/
|
|
18
|
-
import { useState, useEffect } from 'react';
|
|
18
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
19
19
|
import { Text, Checkbox, FormControl, Label, ProgressBar, Button, } from '@primer/react';
|
|
20
20
|
import { Box } from '@datalayer/primer-addons';
|
|
21
21
|
import { ThemedProvider, useThemeBrandColor } from './utils/themedProvider';
|
|
22
22
|
import { ChatFloating } from '../chat';
|
|
23
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
24
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
25
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
23
26
|
import { TasklistIcon, CheckCircleFillIcon, XCircleFillIcon, } from '@primer/octicons-react';
|
|
24
|
-
// AG-UI endpoint for human in the loop example
|
|
25
|
-
const HUMAN_IN_THE_LOOP_ENDPOINT = 'http://localhost:8765/api/v1/examples/human_in_the_loop/';
|
|
26
27
|
/**
|
|
27
28
|
* StepsFeedback Component
|
|
28
29
|
*
|
|
@@ -177,8 +178,22 @@ const renderTaskStepsTool = (context) => {
|
|
|
177
178
|
* - respond callback for sending user decisions back to the agent
|
|
178
179
|
* - UI state changes based on user actions
|
|
179
180
|
*/
|
|
181
|
+
const AGENT_NAME = 'ag-ui-human-in-the-loop';
|
|
182
|
+
const AGENTSPEC_ID = 'example-human-in-the-loop';
|
|
180
183
|
const AgUiHumanInTheLoopExample = () => {
|
|
181
184
|
const brandColor = useThemeBrandColor();
|
|
185
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
186
|
+
const agentName = useMemo(() => uniqueAgentId(AGENT_NAME), []);
|
|
187
|
+
const { agentId } = useExampleAgentRuntime({
|
|
188
|
+
exampleId: 'AgUiHumanInTheLoopExample',
|
|
189
|
+
agentName,
|
|
190
|
+
specId: AGENTSPEC_ID,
|
|
191
|
+
agentConfig: {
|
|
192
|
+
protocol: 'ag-ui',
|
|
193
|
+
agentSpecId: AGENTSPEC_ID,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const humanInTheLoopEndpoint = agentId != null ? `${baseUrl}/api/v1/ag-ui/${agentId}/` : undefined;
|
|
182
197
|
return (_jsx(ThemedProvider, { children: _jsxs(Box, { sx: {
|
|
183
198
|
minHeight: '100vh',
|
|
184
199
|
backgroundColor: 'canvas.default',
|
|
@@ -207,7 +222,7 @@ const AgUiHumanInTheLoopExample = () => {
|
|
|
207
222
|
borderRadius: 2,
|
|
208
223
|
border: '1px solid',
|
|
209
224
|
borderColor: 'accent.muted',
|
|
210
|
-
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "Key Concept: respond() Callback" }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.default' }, children: ["The ", _jsx("code", { children: "renderToolResult" }), " function receives a", ' ', _jsx("code", { children: "respond" }), " callback when the tool status is \"executing\". Calling ", _jsxs("code", { children: ["respond(", '{ accepted: true, steps: [...] }', ")"] }), ' ', "sends the user's decision back to the agent, completing the human-in-the-loop interaction."] })] })] }), _jsx(ChatFloating, { protocol: "ag-ui", endpoint:
|
|
225
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "Key Concept: respond() Callback" }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.default' }, children: ["The ", _jsx("code", { children: "renderToolResult" }), " function receives a", ' ', _jsx("code", { children: "respond" }), " callback when the tool status is \"executing\". Calling ", _jsxs("code", { children: ["respond(", '{ accepted: true, steps: [...] }', ")"] }), ' ', "sends the user's decision back to the agent, completing the human-in-the-loop interaction."] })] })] }), humanInTheLoopEndpoint && (_jsx(ChatFloating, { protocol: "ag-ui", endpoint: humanInTheLoopEndpoint, title: "Task Planner", description: "I can help you plan tasks. I'll generate steps for your review.", position: "bottom-right", brandColor: brandColor, renderToolResult: renderTaskStepsTool, hideMessagesAfterToolUI: true, suggestions: [
|
|
211
226
|
{
|
|
212
227
|
title: 'Plan a trip',
|
|
213
228
|
message: 'Plan a weekend trip to Paris.',
|
|
@@ -216,6 +231,6 @@ const AgUiHumanInTheLoopExample = () => {
|
|
|
216
231
|
title: 'Organize party',
|
|
217
232
|
message: 'Plan a birthday party for next Saturday.',
|
|
218
233
|
},
|
|
219
|
-
] })] }) }));
|
|
234
|
+
] }))] }) }));
|
|
220
235
|
};
|
|
221
236
|
export default AgUiHumanInTheLoopExample;
|
|
@@ -5,21 +5,8 @@
|
|
|
5
5
|
* and the AI agent using AG-UI. This example shows a recipe builder where
|
|
6
6
|
* both the user and the AI can modify the shared state.
|
|
7
7
|
*
|
|
8
|
-
* Backend:
|
|
8
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-shared-state)
|
|
9
9
|
*/
|
|
10
10
|
import React from 'react';
|
|
11
|
-
/**
|
|
12
|
-
* AgUiSharedStateExample Component
|
|
13
|
-
*
|
|
14
|
-
* Demonstrates bidirectional shared state with AG-UI.
|
|
15
|
-
* Both the frontend and the AI agent can modify the recipe state,
|
|
16
|
-
* with changes synchronized via STATE_SNAPSHOT events.
|
|
17
|
-
*
|
|
18
|
-
* Features demonstrated:
|
|
19
|
-
* - Bidirectional state synchronization
|
|
20
|
-
* - StateDeps for passing state to agent
|
|
21
|
-
* - STATE_SNAPSHOT for receiving state from agent
|
|
22
|
-
* - Editable UI that updates shared state
|
|
23
|
-
*/
|
|
24
11
|
declare const AgUiSharedStateExample: React.FC;
|
|
25
12
|
export default AgUiSharedStateExample;
|
|
@@ -10,16 +10,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
* and the AI agent using AG-UI. This example shows a recipe builder where
|
|
11
11
|
* both the user and the AI can modify the shared state.
|
|
12
12
|
*
|
|
13
|
-
* Backend:
|
|
13
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-shared-state)
|
|
14
14
|
*/
|
|
15
|
-
import { useState, useCallback } from 'react';
|
|
15
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
16
16
|
import { Text, Button, TextInput, Label } from '@primer/react';
|
|
17
17
|
import { Box } from '@datalayer/primer-addons';
|
|
18
18
|
import { ThemedProvider, useThemeBrandColor } from './utils/themedProvider';
|
|
19
19
|
import { ChatFloating } from '../chat';
|
|
20
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
21
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
22
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
20
23
|
import { PlusIcon, XIcon, BeakerIcon, ClockIcon, PersonIcon, } from '@primer/octicons-react';
|
|
21
|
-
// AG-UI endpoint for shared state example
|
|
22
|
-
const SHARED_STATE_ENDPOINT = 'http://localhost:8765/api/v1/examples/shared_state/';
|
|
23
24
|
const DEFAULT_RECIPE = {
|
|
24
25
|
title: '',
|
|
25
26
|
description: '',
|
|
@@ -103,8 +104,22 @@ const RecipeDisplay = ({ recipe, onUpdate }) => {
|
|
|
103
104
|
* - STATE_SNAPSHOT for receiving state from agent
|
|
104
105
|
* - Editable UI that updates shared state
|
|
105
106
|
*/
|
|
107
|
+
const AGENT_NAME = 'ag-ui-shared-state';
|
|
108
|
+
const AGENTSPEC_ID = 'example-shared-state';
|
|
106
109
|
const AgUiSharedStateExample = () => {
|
|
107
110
|
const brandColor = useThemeBrandColor();
|
|
111
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
112
|
+
const agentName = useMemo(() => uniqueAgentId(AGENT_NAME), []);
|
|
113
|
+
const { agentId } = useExampleAgentRuntime({
|
|
114
|
+
exampleId: 'AgUiSharedStateExample',
|
|
115
|
+
agentName,
|
|
116
|
+
specId: AGENTSPEC_ID,
|
|
117
|
+
agentConfig: {
|
|
118
|
+
protocol: 'ag-ui',
|
|
119
|
+
agentSpecId: AGENTSPEC_ID,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const sharedStateEndpoint = agentId != null ? `${baseUrl}/api/v1/ag-ui/${agentId}/` : undefined;
|
|
108
123
|
const [recipe, setRecipe] = useState(DEFAULT_RECIPE);
|
|
109
124
|
// Handle state updates from AG-UI
|
|
110
125
|
const handleStateUpdate = useCallback((state) => {
|
|
@@ -169,7 +184,7 @@ const AgUiSharedStateExample = () => {
|
|
|
169
184
|
marginTop: 1,
|
|
170
185
|
fontSize: 1,
|
|
171
186
|
color: 'fg.muted',
|
|
172
|
-
}, children: [_jsx("li", { children: "\"Create a recipe for chocolate chip cookies\"" }), _jsx("li", { children: "\"Add butter and sugar to the ingredients\"" }), _jsx("li", { children: "\"Update the prep time to 20 minutes\"" }), _jsx("li", { children: "\"Suggest 3 more ingredients for my recipe\"" })] })] })] })] }), _jsx(ChatFloating, { protocol: "ag-ui", endpoint:
|
|
187
|
+
}, children: [_jsx("li", { children: "\"Create a recipe for chocolate chip cookies\"" }), _jsx("li", { children: "\"Add butter and sugar to the ingredients\"" }), _jsx("li", { children: "\"Update the prep time to 20 minutes\"" }), _jsx("li", { children: "\"Suggest 3 more ingredients for my recipe\"" })] })] })] })] }), sharedStateEndpoint && (_jsx(ChatFloating, { protocol: "ag-ui", endpoint: sharedStateEndpoint, title: "Recipe Assistant", description: "Let's build a recipe together! I can add ingredients, instructions, and more.", position: "bottom-right", brandColor: brandColor, onStateUpdate: handleStateUpdate, suggestions: [
|
|
173
188
|
{
|
|
174
189
|
title: 'Pasta recipe',
|
|
175
190
|
message: 'Help me create a simple pasta recipe.',
|
|
@@ -178,6 +193,6 @@ const AgUiSharedStateExample = () => {
|
|
|
178
193
|
title: 'Add ingredient',
|
|
179
194
|
message: 'Add tomatoes to the recipe.',
|
|
180
195
|
},
|
|
181
|
-
] })] }) }));
|
|
196
|
+
] }))] }) }));
|
|
182
197
|
};
|
|
183
198
|
export default AgUiSharedStateExample;
|
|
@@ -5,21 +5,8 @@
|
|
|
5
5
|
* that render UI components. Unlike frontend tools, these are backend
|
|
6
6
|
* tools that return structured data to be rendered on the frontend.
|
|
7
7
|
*
|
|
8
|
-
* Backend:
|
|
8
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-agentic-generative-ui)
|
|
9
9
|
*/
|
|
10
10
|
import React from 'react';
|
|
11
|
-
/**
|
|
12
|
-
* AgUiToolsBasedGenUiExample Component
|
|
13
|
-
*
|
|
14
|
-
* Demonstrates tool-based generative UI with AG-UI.
|
|
15
|
-
* The agent uses tools (create_plan, update_plan_step) that emit
|
|
16
|
-
* STATE_SNAPSHOT and STATE_DELTA events to update the UI.
|
|
17
|
-
*
|
|
18
|
-
* Features demonstrated:
|
|
19
|
-
* - STATE_SNAPSHOT events for full state updates
|
|
20
|
-
* - STATE_DELTA events with JSON Patch for incremental updates
|
|
21
|
-
* - Real-time UI updates as agent works
|
|
22
|
-
* - Interactive step selection with Confirm/Reject buttons
|
|
23
|
-
*/
|
|
24
11
|
declare const AgUiToolsBasedGenUiExample: React.FC;
|
|
25
12
|
export default AgUiToolsBasedGenUiExample;
|
|
@@ -10,16 +10,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
* that render UI components. Unlike frontend tools, these are backend
|
|
11
11
|
* tools that return structured data to be rendered on the frontend.
|
|
12
12
|
*
|
|
13
|
-
* Backend:
|
|
13
|
+
* Backend: managed AG-UI agent runtime (agentspec: example-agentic-generative-ui)
|
|
14
14
|
*/
|
|
15
|
-
import { useState, useCallback } from 'react';
|
|
15
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
16
16
|
import { Text, ProgressBar, Button } from '@primer/react';
|
|
17
17
|
import { Box } from '@datalayer/primer-addons';
|
|
18
18
|
import { ThemedProvider, useThemeBrandColor } from './utils/themedProvider';
|
|
19
19
|
import { ChatFloating } from '../chat';
|
|
20
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
21
|
+
import { uniqueAgentId } from './utils/agentId';
|
|
22
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
20
23
|
import { CheckCircleIcon, CircleIcon, DotFillIcon, CheckIcon, XIcon, } from '@primer/octicons-react';
|
|
21
|
-
// AG-UI endpoint for agentic generative UI example
|
|
22
|
-
const AGENTIC_GENERATIVE_UI_ENDPOINT = 'http://localhost:8765/api/v1/examples/agentic_generative_ui/';
|
|
23
24
|
/**
|
|
24
25
|
* PlanStepItem Component
|
|
25
26
|
* Renders a single plan step with status indicator and optional click handler
|
|
@@ -168,8 +169,22 @@ const PlanDisplay = ({ plan, isInteractive = true, onStepToggle, onConfirm, onRe
|
|
|
168
169
|
* - Real-time UI updates as agent works
|
|
169
170
|
* - Interactive step selection with Confirm/Reject buttons
|
|
170
171
|
*/
|
|
172
|
+
const AGENT_NAME = 'ag-ui-generative-ui';
|
|
173
|
+
const AGENTSPEC_ID = 'example-agentic-generative-ui';
|
|
171
174
|
const AgUiToolsBasedGenUiExample = () => {
|
|
172
175
|
const brandColor = useThemeBrandColor();
|
|
176
|
+
const baseUrl = useExampleAgentRuntimesUrl();
|
|
177
|
+
const agentName = useMemo(() => uniqueAgentId(AGENT_NAME), []);
|
|
178
|
+
const { agentId } = useExampleAgentRuntime({
|
|
179
|
+
exampleId: 'AgUiToolsBasedGenUiExample',
|
|
180
|
+
agentName,
|
|
181
|
+
specId: AGENTSPEC_ID,
|
|
182
|
+
agentConfig: {
|
|
183
|
+
protocol: 'ag-ui',
|
|
184
|
+
agentSpecId: AGENTSPEC_ID,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
const agenticGenerativeUiEndpoint = agentId != null ? `${baseUrl}/api/v1/ag-ui/${agentId}/` : undefined;
|
|
173
188
|
const [plan, setPlan] = useState(null);
|
|
174
189
|
const [decision, setDecision] = useState(null);
|
|
175
190
|
// Handle state updates from AG-UI events
|
|
@@ -244,7 +259,7 @@ const AgUiToolsBasedGenUiExample = () => {
|
|
|
244
259
|
marginTop: 1,
|
|
245
260
|
fontSize: 1,
|
|
246
261
|
color: 'fg.muted',
|
|
247
|
-
}, children: [_jsx("li", { children: "STATE_SNAPSHOT - Full state replacement" }), _jsx("li", { children: "STATE_DELTA - Incremental JSON Patch updates (RFC 6902)" }), _jsx("li", { children: "TOOL_CALL_START / TOOL_CALL_END - Tool execution tracking" })] })] })] })] }), _jsx(ChatFloating, { protocol: "ag-ui", endpoint:
|
|
262
|
+
}, children: [_jsx("li", { children: "STATE_SNAPSHOT - Full state replacement" }), _jsx("li", { children: "STATE_DELTA - Incremental JSON Patch updates (RFC 6902)" }), _jsx("li", { children: "TOOL_CALL_START / TOOL_CALL_END - Tool execution tracking" })] })] })] })] }), agenticGenerativeUiEndpoint && (_jsx(ChatFloating, { protocol: "ag-ui", endpoint: agenticGenerativeUiEndpoint, title: "Plan Generator", description: "I can create detailed plans and update them in real-time.", position: "bottom-right", brandColor: brandColor, onStateUpdate: handleStateUpdate, suggestions: [
|
|
248
263
|
{
|
|
249
264
|
title: 'Project plan',
|
|
250
265
|
message: 'Create a project plan for building a mobile app.',
|
|
@@ -253,6 +268,6 @@ const AgUiToolsBasedGenUiExample = () => {
|
|
|
253
268
|
title: 'Marketing strategy',
|
|
254
269
|
message: 'Generate a marketing strategy for a new product launch.',
|
|
255
270
|
},
|
|
256
|
-
] })] }) }));
|
|
271
|
+
] }))] }) }));
|
|
257
272
|
};
|
|
258
273
|
export default AgUiToolsBasedGenUiExample;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 3. Provides pause/resume/terminate lifecycle backed by CRIU
|
|
12
12
|
*
|
|
13
13
|
* Prerequisites:
|
|
14
|
-
* - Datalayer core configuration (
|
|
14
|
+
* - Datalayer core configuration (runtimesUrl, aiAgentsUrl)
|
|
15
15
|
* - Valid IAM token (set via SignInSimple or iamStore)
|
|
16
16
|
*/
|
|
17
17
|
import React from 'react';
|
|
@@ -16,7 +16,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
16
16
|
* 3. Provides pause/resume/terminate lifecycle backed by CRIU
|
|
17
17
|
*
|
|
18
18
|
* Prerequisites:
|
|
19
|
-
* - Datalayer core configuration (
|
|
19
|
+
* - Datalayer core configuration (runtimesUrl, aiAgentsUrl)
|
|
20
20
|
* - Valid IAM token (set via SignInSimple or iamStore)
|
|
21
21
|
*/
|
|
22
22
|
/// <reference types="vite/client" />
|
|
@@ -29,7 +29,7 @@ import { AuthRequiredView, ErrorView } from './components';
|
|
|
29
29
|
import { ThemedProvider } from './utils/themedProvider';
|
|
30
30
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
31
31
|
import { Chat } from '../chat';
|
|
32
|
-
import { useAgentRuntimes, useAgentRuntimesQuery, useRefreshAgentRuntimes,
|
|
32
|
+
import { useAgentsRuntimes, useAgentRuntimes, useAgentRuntimesQuery, useRefreshAgentRuntimes, } from '../hooks/useAgentRuntimes';
|
|
33
33
|
import { useAgentLifecycle } from '../hooks/useCheckpoints';
|
|
34
34
|
import { useDeletePausedAgentRuntime } from '../hooks/useCheckpoints';
|
|
35
35
|
import { AGENT_STATUS_COLORS } from '../types/agents';
|
|
@@ -106,10 +106,9 @@ const AgentCheckpointsInner = ({ onLogout, }) => {
|
|
|
106
106
|
});
|
|
107
107
|
// Agent runtimes from the focused hook
|
|
108
108
|
const { data: agentRuntimes } = useAgentRuntimesQuery();
|
|
109
|
+
const { terminateRuntimeByPod } = useAgentsRuntimes();
|
|
109
110
|
const refetchRuntimes = useRefreshAgentRuntimes();
|
|
110
|
-
const deleteRuntimeMutation = useDeleteAgentRuntime();
|
|
111
111
|
const deletePausedRuntimeMutation = useDeletePausedAgentRuntime();
|
|
112
|
-
const deleteRuntimeByPod = deleteRuntimeMutation.mutateAsync;
|
|
113
112
|
const deletePausedRuntimeByPod = deletePausedRuntimeMutation.mutateAsync;
|
|
114
113
|
const [isStarting, setIsStarting] = useState(false);
|
|
115
114
|
const [sidebarOpen, setSidebarOpen] = useState(true);
|
|
@@ -246,7 +245,7 @@ const AgentCheckpointsInner = ({ onLogout, }) => {
|
|
|
246
245
|
await deletePausedRuntimeByPod(agent.podName);
|
|
247
246
|
}
|
|
248
247
|
else {
|
|
249
|
-
await
|
|
248
|
+
await terminateRuntimeByPod(agent.podName);
|
|
250
249
|
}
|
|
251
250
|
// Ensure sidebar terminate resets to the home state like header terminate.
|
|
252
251
|
if (isCurrentRuntime || isLastKnownRuntime) {
|
|
@@ -262,7 +261,7 @@ const AgentCheckpointsInner = ({ onLogout, }) => {
|
|
|
262
261
|
}
|
|
263
262
|
}, [
|
|
264
263
|
deletePausedRuntimeByPod,
|
|
265
|
-
|
|
264
|
+
terminateRuntimeByPod,
|
|
266
265
|
refreshAgents,
|
|
267
266
|
refreshCheckpoints,
|
|
268
267
|
runningAgents,
|
|
@@ -286,7 +285,7 @@ const AgentCheckpointsInner = ({ onLogout, }) => {
|
|
|
286
285
|
}
|
|
287
286
|
// ── Running / Paused ─────────────────────────────────────────────────────
|
|
288
287
|
return (_jsxs(Box, { sx: {
|
|
289
|
-
height: '
|
|
288
|
+
height: '100%',
|
|
290
289
|
display: 'flex',
|
|
291
290
|
flexDirection: 'column',
|
|
292
291
|
}, children: [_jsxs(Box, { sx: {
|
|
@@ -436,7 +435,7 @@ const AgentCheckpointsInner = ({ onLogout, }) => {
|
|
|
436
435
|
gap: 3,
|
|
437
436
|
px: 3,
|
|
438
437
|
}, children: [_jsx(AgentIcon, { size: 48 }), _jsx(Heading, { as: "h2", sx: { fontSize: 3 }, children: "Checkpoint Agent" }), _jsxs(Text, { sx: { color: 'fg.muted', textAlign: 'center', maxWidth: 560 }, children: ["Launch a cloud agent runtime with pause/resume checkpointing. The agent will be deployed from the", ' ', _jsx("strong", { children: AGENTSPEC_ID }), " spec."] }), displayError && (_jsx(Flash, { variant: "danger", sx: { maxWidth: 560, width: '100%' }, children: displayError })), _jsx(Button, { variant: "primary", size: "large", leadingVisual: PlayIcon, onClick: handleLaunch, children: "Launch Agent" })] })) : (isReady || runtimeStatus === 'resumed') &&
|
|
439
|
-
runtimeStatus !== 'paused' ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, title: "Monitor Sales KPI Agent", brandIcon: _jsx(AgentIcon, { size: 16 }), placeholder: "Ask about sales KPIs\u2026", description: "Monitor Sales KPI agent with pause/resume checkpointing", showHeader:
|
|
438
|
+
runtimeStatus !== 'paused' ? (_jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, title: "Monitor Sales KPI Agent", brandIcon: _jsx(AgentIcon, { size: 16 }), placeholder: "Ask about sales KPIs\u2026", description: "Monitor Sales KPI agent with pause/resume checkpointing", showHeader: true, showTokenUsage: true, autoFocus: true, height: "100%", runtimeId: podName, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
440
439
|
{
|
|
441
440
|
title: 'KPIs',
|
|
442
441
|
message: "Show me today's sales KPI dashboard",
|
|
@@ -464,7 +463,7 @@ const AgentCheckpointsExample = () => {
|
|
|
464
463
|
useEffect(() => {
|
|
465
464
|
if (token && !hasSynced.current) {
|
|
466
465
|
hasSynced.current = true;
|
|
467
|
-
import('
|
|
466
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
468
467
|
iamStore.setState({ token });
|
|
469
468
|
});
|
|
470
469
|
}
|
|
@@ -474,7 +473,7 @@ const AgentCheckpointsExample = () => {
|
|
|
474
473
|
const handleLogout = useCallback(() => {
|
|
475
474
|
clearAuth();
|
|
476
475
|
hasSynced.current = false;
|
|
477
|
-
import('
|
|
476
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
478
477
|
iamStore.setState({ token: undefined });
|
|
479
478
|
});
|
|
480
479
|
}, [clearAuth]);
|
|
@@ -529,7 +529,7 @@ const AgentCodemodeInner = ({ onLogout, }) => {
|
|
|
529
529
|
return null;
|
|
530
530
|
}
|
|
531
531
|
return (_jsxs(Box, { sx: {
|
|
532
|
-
height: '
|
|
532
|
+
height: '100%',
|
|
533
533
|
display: 'flex',
|
|
534
534
|
flexDirection: 'column',
|
|
535
535
|
}, children: [_jsxs(Box, { sx: {
|
|
@@ -662,7 +662,7 @@ const AgentCodemodeInner = ({ onLogout, }) => {
|
|
|
662
662
|
})())] })] }));
|
|
663
663
|
};
|
|
664
664
|
const syncTokenToIamStore = (token) => {
|
|
665
|
-
import('
|
|
665
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
666
666
|
iamStore.setState({ token });
|
|
667
667
|
});
|
|
668
668
|
};
|
|
@@ -678,7 +678,7 @@ const AgentCodemodeExample = () => {
|
|
|
678
678
|
const handleLogout = useCallback(() => {
|
|
679
679
|
clearAuth();
|
|
680
680
|
hasSynced.current = false;
|
|
681
|
-
import('
|
|
681
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
682
682
|
iamStore.setState({ token: undefined });
|
|
683
683
|
});
|
|
684
684
|
}, [clearAuth]);
|
|
@@ -80,7 +80,7 @@ const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange })
|
|
|
80
80
|
const cloudRuntimeBaseUrl = useMemo(() => {
|
|
81
81
|
const envRuntimesUrl = normalizeHttpUrl(import.meta.env.VITE_DATALAYER_RUNTIMES_URL);
|
|
82
82
|
const envAgentRuntimesUrl = normalizeHttpUrl(import.meta.env.VITE_DATALAYER_AGENT_RUNTIMES_URL);
|
|
83
|
-
const configuredRuntimesUrl = normalizeHttpUrl(configuration?.
|
|
83
|
+
const configuredRuntimesUrl = normalizeHttpUrl(configuration?.runtimesUrl);
|
|
84
84
|
if (envRuntimesUrl && !isLocalhostUrl(envRuntimesUrl)) {
|
|
85
85
|
return envRuntimesUrl;
|
|
86
86
|
}
|
|
@@ -91,7 +91,7 @@ const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange })
|
|
|
91
91
|
return envAgentRuntimesUrl;
|
|
92
92
|
}
|
|
93
93
|
return 'https://r1.datalayer.run';
|
|
94
|
-
}, [configuration?.
|
|
94
|
+
}, [configuration?.runtimesUrl]);
|
|
95
95
|
const { runtime, status: runtimeStatus, isReady, error: hookError, runtimeCreationBaseUrl, } = useAgentRuntimes({
|
|
96
96
|
agentSpecId: AGENTSPEC_ID,
|
|
97
97
|
autoStart: executionTarget === 'cloud',
|
|
@@ -123,7 +123,7 @@ const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange })
|
|
|
123
123
|
? `local:${agentId}`
|
|
124
124
|
: runtime?.podName || '(launching…)';
|
|
125
125
|
const controlPlaneBaseUrl = import.meta.env.VITE_RUN_URL ||
|
|
126
|
-
configuration?.
|
|
126
|
+
configuration?.datalayerUrl ||
|
|
127
127
|
(cloudAgentBaseUrl ? new URL(cloudAgentBaseUrl).origin : '');
|
|
128
128
|
const isAgentReady = executionTarget === 'local' ? localStatus === 'ready' : isReady;
|
|
129
129
|
const agentStatus = executionTarget === 'local' ? localStatus : runtimeStatus;
|
|
@@ -466,7 +466,7 @@ const AgentEvalsInner = ({ onLogout, executionTarget, onExecutionTargetChange })
|
|
|
466
466
|
};
|
|
467
467
|
// ─── Sync token to core IAM store ──────────────────────────────────────────
|
|
468
468
|
const syncTokenToIamStore = (token) => {
|
|
469
|
-
import('
|
|
469
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
470
470
|
iamStore.setState({ token });
|
|
471
471
|
});
|
|
472
472
|
};
|
|
@@ -484,7 +484,7 @@ const AgentEvalsExample = () => {
|
|
|
484
484
|
const handleLogout = useCallback(() => {
|
|
485
485
|
clearAuth();
|
|
486
486
|
hasSynced.current = false;
|
|
487
|
-
import('
|
|
487
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
488
488
|
iamStore.setState({ token: undefined });
|
|
489
489
|
});
|
|
490
490
|
}, [clearAuth]);
|
|
@@ -21,7 +21,7 @@ import { Text, Button, Spinner, Heading, Label, Flash, ProgressBar, } from '@pri
|
|
|
21
21
|
import { ShieldCheckIcon, CheckIcon, XIcon, DotFillIcon, } from '@primer/octicons-react';
|
|
22
22
|
import { Box } from '@datalayer/primer-addons';
|
|
23
23
|
import { buildOtelWebSocketUrl } from '@datalayer/core/lib/otel';
|
|
24
|
-
import { useCoreStore } from '
|
|
24
|
+
import { useCoreStore } from '../state/substates';
|
|
25
25
|
import { AuthRequiredView, ErrorView } from './components';
|
|
26
26
|
import { ThemedProvider } from './utils/themedProvider';
|
|
27
27
|
import { uniqueAgentId } from './utils/agentId';
|
|
@@ -30,15 +30,18 @@ import { getAgentspecs } from '../specs/agents';
|
|
|
30
30
|
import { subscribeOtelWs } from '../context/otelWsPool';
|
|
31
31
|
import { toMetricValue } from '../hooks/useMonitoring';
|
|
32
32
|
import { useAIAgentsWebSocket } from '../hooks';
|
|
33
|
+
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
33
34
|
const queryClient = new QueryClient();
|
|
34
35
|
import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
|
|
35
36
|
import { Chat } from '../chat';
|
|
36
37
|
// ─── Constants ─────────────────────────────────────────────────────────────
|
|
37
38
|
const AGENT_NAME = 'guardrails-example-agent';
|
|
38
39
|
const AGENTSPEC_ID = 'example-guardrails';
|
|
39
|
-
const DEFAULT_LOCAL_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
|
|
40
40
|
const OTEL_BASE_URL_ENV = import.meta.env.VITE_OTEL_BASE_URL;
|
|
41
|
-
|
|
41
|
+
// Consume-side OTEL override (DATALAYER_OTEL_IN_URL). When set, telemetry is
|
|
42
|
+
// read from here instead of VITE_OTEL_BASE_URL (e.g. prod during local dev).
|
|
43
|
+
const OTEL_IN_BASE_URL_ENV = import.meta.env.VITE_OTEL_IN_BASE_URL;
|
|
44
|
+
const DATALAYER_URL_ENV = import.meta.env.VITE_DATALAYER_URL;
|
|
42
45
|
const OTEL_SERVICE_NAME = 'agent-runtimes';
|
|
43
46
|
const COST_RUN_METRIC = 'agent_runtimes.capability.cost.run.usd';
|
|
44
47
|
const COST_CUMULATIVE_METRIC = 'agent_runtimes.capability.cost.cumulative.usd';
|
|
@@ -217,11 +220,13 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
217
220
|
// Tool approval queue
|
|
218
221
|
const [approvals, setApprovals] = useState([]);
|
|
219
222
|
const [approvalLoading, setApprovalLoading] = useState(null);
|
|
220
|
-
const agentBaseUrl =
|
|
221
|
-
const otelBaseUrl = configuration?.
|
|
222
|
-
|
|
223
|
+
const agentBaseUrl = useExampleAgentRuntimesUrl();
|
|
224
|
+
const otelBaseUrl = configuration?.otelInUrl ||
|
|
225
|
+
OTEL_IN_BASE_URL_ENV ||
|
|
226
|
+
configuration?.otelUrl ||
|
|
227
|
+
configuration?.datalayerUrl ||
|
|
223
228
|
OTEL_BASE_URL_ENV ||
|
|
224
|
-
|
|
229
|
+
DATALAYER_URL_ENV ||
|
|
225
230
|
'https://prod1.datalayer.run';
|
|
226
231
|
const podName = agentId;
|
|
227
232
|
const chatAuthToken = token === null ? undefined : token;
|
|
@@ -420,7 +425,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
420
425
|
flexDirection: 'column',
|
|
421
426
|
alignItems: 'center',
|
|
422
427
|
justifyContent: 'center',
|
|
423
|
-
height: '
|
|
428
|
+
height: '100%',
|
|
424
429
|
gap: 3,
|
|
425
430
|
}, children: [_jsx(Spinner, { size: "large" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Launching guardrails example agent..." })] }));
|
|
426
431
|
}
|
|
@@ -453,7 +458,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
453
458
|
? 'attention.fg'
|
|
454
459
|
: 'success.fg';
|
|
455
460
|
return (_jsxs(Box, { sx: {
|
|
456
|
-
height: '
|
|
461
|
+
height: '100%',
|
|
457
462
|
display: 'flex',
|
|
458
463
|
flexDirection: 'column',
|
|
459
464
|
}, children: [_jsxs(Box, { sx: {
|
|
@@ -482,7 +487,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
482
487
|
? ` (over by $${overBudgetAmountUsd.toFixed(4)}).`
|
|
483
488
|
: '.', ' ', "Start a new run or increase the run budget before continuing."] }) })), approvals.map(req => (_jsx(Flash, { variant: "warning", sx: { mx: 3, mt: 2 }, children: _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsxs(Text, { sx: { flex: 1, fontSize: 1 }, children: [_jsx("strong", { children: req.tool_name }), " requests approval", req.tool_args
|
|
484
489
|
? ` — ${JSON.stringify(req.tool_args).slice(0, 120)}`
|
|
485
|
-
: ''] }), _jsx(Button, { size: "small", variant: "primary", leadingVisual: CheckIcon, onClick: () => handleApprove(req.id), disabled: approvalLoading === req.id, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", leadingVisual: XIcon, onClick: () => handleReject(req.id), disabled: approvalLoading === req.id, children: "Reject" })] }) }, req.id))), _jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Guardrails Agent", brandIcon: _jsx(ShieldCheckIcon, { size: 16 }), placeholder: "Ask something that triggers tools\u2026", description: "Cost guardrail with OTEL-backed gauge and hook-aware approvals (before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls)", showHeader:
|
|
490
|
+
: ''] }), _jsx(Button, { size: "small", variant: "primary", leadingVisual: CheckIcon, onClick: () => handleApprove(req.id), disabled: approvalLoading === req.id, children: "Approve" }), _jsx(Button, { size: "small", variant: "danger", leadingVisual: XIcon, onClick: () => handleReject(req.id), disabled: approvalLoading === req.id, children: "Reject" })] }) }, req.id))), _jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(Chat, { protocol: "vercel-ai", baseUrl: agentBaseUrl, agentId: agentId, authToken: chatAuthToken, title: "Guardrails Agent", brandIcon: _jsx(ShieldCheckIcon, { size: 16 }), placeholder: "Ask something that triggers tools\u2026", description: "Cost guardrail with OTEL-backed gauge and hook-aware approvals (before_tool_execute, after_tool_execute, on_tool_execute_error, deferred_tool_calls)", showHeader: true, showTokenUsage: true, errorBanner: overBudgetBanner, disableInputPrompt: isOverRunBudget, autoFocus: true, height: "100%", runtimeId: agentId, historyEndpoint: `${agentBaseUrl}/api/v1/history`, suggestions: [
|
|
486
491
|
{ title: 'Update CRM', message: 'Update the CRM records for Q3' },
|
|
487
492
|
{
|
|
488
493
|
title: 'Trigger before_tool_execute',
|
|
@@ -500,7 +505,7 @@ const AgentGuardrailsInner = ({ onLogout, }) => {
|
|
|
500
505
|
};
|
|
501
506
|
// ─── Sync token to core IAM store ──────────────────────────────────────────
|
|
502
507
|
const syncTokenToIamStore = (token) => {
|
|
503
|
-
import('
|
|
508
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
504
509
|
iamStore.setState({ token });
|
|
505
510
|
});
|
|
506
511
|
};
|
|
@@ -517,7 +522,7 @@ const AgentGuardrailsExample = () => {
|
|
|
517
522
|
const handleLogout = useCallback(() => {
|
|
518
523
|
clearAuth();
|
|
519
524
|
hasSynced.current = false;
|
|
520
|
-
import('
|
|
525
|
+
import('../state/substates').then(({ iamStore }) => {
|
|
521
526
|
iamStore.setState({ token: undefined });
|
|
522
527
|
});
|
|
523
528
|
}, [clearAuth]);
|
|
@@ -3,13 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
7
|
import { Text, Spinner } from '@primer/react';
|
|
8
8
|
import { SyncIcon } from '@primer/octicons-react';
|
|
9
9
|
import { Box, setupPrimerPortals } from '@datalayer/primer-addons';
|
|
10
10
|
import { ThemedProvider } from './utils/themedProvider';
|
|
11
11
|
import { uniqueAgentId } from './utils/agentId';
|
|
12
12
|
import { useExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
|
|
13
|
+
import { useExampleAgentRuntime } from './hooks/useExampleAgentRuntime';
|
|
13
14
|
import { ErrorView } from './components';
|
|
14
15
|
import { Chat } from '../chat';
|
|
15
16
|
setupPrimerPortals();
|
|
@@ -17,66 +18,24 @@ const AGENTSPEC_ID = 'example-hooks';
|
|
|
17
18
|
const AGENT_NAME = 'hooks-example-agent';
|
|
18
19
|
const AgentHooksExample = () => {
|
|
19
20
|
const baseUrl = useExampleAgentRuntimesUrl();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
body: JSON.stringify({
|
|
32
|
-
name,
|
|
33
|
-
agent_spec_id: AGENTSPEC_ID,
|
|
34
|
-
transport: 'vercel-ai',
|
|
35
|
-
}),
|
|
36
|
-
});
|
|
37
|
-
if (!response.ok) {
|
|
38
|
-
const data = await response
|
|
39
|
-
.json()
|
|
40
|
-
.catch(() => ({ detail: 'Unknown error' }));
|
|
41
|
-
throw new Error(data.detail || `Failed to create agent: ${response.status}`);
|
|
42
|
-
}
|
|
43
|
-
const data = await response.json();
|
|
44
|
-
if (!cancelled) {
|
|
45
|
-
setAgentId(data.id);
|
|
46
|
-
setIsCreating(false);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
if (!cancelled) {
|
|
51
|
-
setError(err instanceof Error ? err.message : 'Failed to create agent');
|
|
52
|
-
setIsCreating(false);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
createAgent();
|
|
57
|
-
return () => {
|
|
58
|
-
cancelled = true;
|
|
59
|
-
};
|
|
60
|
-
}, [baseUrl]);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return () => {
|
|
63
|
-
if (!agentId) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
void fetch(`${baseUrl}/api/v1/agents/${encodeURIComponent(agentId)}`, {
|
|
67
|
-
method: 'DELETE',
|
|
68
|
-
}).catch(() => {
|
|
69
|
-
// Ignore teardown failures in example mode.
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
}, [agentId, baseUrl]);
|
|
21
|
+
const agentName = useMemo(() => uniqueAgentId(AGENT_NAME), []);
|
|
22
|
+
const { agentId, error, status, isReady } = useExampleAgentRuntime({
|
|
23
|
+
exampleId: 'AgentHooksExample',
|
|
24
|
+
agentName,
|
|
25
|
+
specId: AGENTSPEC_ID,
|
|
26
|
+
agentConfig: {
|
|
27
|
+
protocol: 'vercel-ai',
|
|
28
|
+
agentSpecId: AGENTSPEC_ID,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const isCreating = !isReady && status !== 'error';
|
|
73
32
|
if (isCreating) {
|
|
74
33
|
return (_jsx(ThemedProvider, { children: _jsxs(Box, { sx: {
|
|
75
34
|
display: 'flex',
|
|
76
35
|
flexDirection: 'column',
|
|
77
36
|
alignItems: 'center',
|
|
78
37
|
justifyContent: 'center',
|
|
79
|
-
height: '
|
|
38
|
+
height: '100%',
|
|
80
39
|
gap: 3,
|
|
81
40
|
bg: 'canvas.default',
|
|
82
41
|
}, children: [_jsx(Spinner, { size: "large" }), _jsxs(Text, { sx: { color: 'fg.muted' }, children: ["Creating agent from ", AGENTSPEC_ID, "..."] })] }) }));
|