@datalayer/agent-runtimes 1.0.9 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (462) hide show
  1. package/README.md +82 -1
  2. package/lib/{AgentLexical.d.ts → AgentDocument.d.ts} +5 -5
  3. package/lib/{AgentLexical.js → AgentDocument.js} +156 -26
  4. package/lib/AgentNode.js +32 -31
  5. package/lib/AgentNotebook.js +172 -17
  6. package/lib/AppExamples2.css +47 -0
  7. package/lib/AppExamples2.d.ts +3 -0
  8. package/lib/AppExamples2.js +21 -0
  9. package/lib/{agent-lexical-main.js → agent-document-main.js} +2 -2
  10. package/lib/agents/AgentRuntimeChat.d.ts +73 -0
  11. package/lib/agents/AgentRuntimeChat.js +198 -0
  12. package/lib/api/index.d.ts +12 -0
  13. package/lib/api/index.js +46 -0
  14. package/lib/api/runtimes/checkpoints.d.ts +122 -0
  15. package/lib/api/runtimes/checkpoints.js +118 -0
  16. package/lib/api/runtimes/environments.d.ts +9 -0
  17. package/lib/api/runtimes/environments.js +29 -0
  18. package/lib/api/runtimes/healthz.d.ts +15 -0
  19. package/lib/api/runtimes/healthz.js +44 -0
  20. package/lib/api/runtimes/index.d.ts +12 -0
  21. package/lib/api/runtimes/index.js +16 -0
  22. package/lib/api/runtimes/runtimes.d.ts +138 -0
  23. package/lib/api/runtimes/runtimes.js +230 -0
  24. package/lib/api/runtimes/snapshots.d.ts +38 -0
  25. package/lib/api/runtimes/snapshots.js +82 -0
  26. package/lib/api/scheduler/index.d.ts +6 -0
  27. package/lib/api/scheduler/index.js +10 -0
  28. package/lib/api/scheduler/schedules.d.ts +85 -0
  29. package/lib/api/scheduler/schedules.js +78 -0
  30. package/lib/api/spacer/documents.d.ts +12 -0
  31. package/lib/api/spacer/documents.js +43 -0
  32. package/lib/api/spacer/healthz.d.ts +15 -0
  33. package/lib/api/spacer/healthz.js +44 -0
  34. package/lib/api/spacer/index.d.ts +15 -0
  35. package/lib/api/spacer/index.js +19 -0
  36. package/lib/api/spacer/items.d.ts +25 -0
  37. package/lib/api/spacer/items.js +55 -0
  38. package/lib/api/spacer/lexicals.d.ts +34 -0
  39. package/lib/api/spacer/lexicals.js +89 -0
  40. package/lib/api/spacer/notebooks.d.ts +34 -0
  41. package/lib/api/spacer/notebooks.js +89 -0
  42. package/lib/api/spacer/spaces.d.ts +84 -0
  43. package/lib/api/spacer/spaces.js +170 -0
  44. package/lib/api/spacer/users.d.ts +9 -0
  45. package/lib/api/spacer/users.js +29 -0
  46. package/lib/chat/Chat.d.ts +1 -1
  47. package/lib/chat/Chat.js +54 -54
  48. package/lib/chat/ChatFloating.d.ts +2 -2
  49. package/lib/chat/ChatFloating.js +136 -25
  50. package/lib/chat/ChatSidebar.js +20 -22
  51. package/lib/chat/base/ChatBase.js +468 -40
  52. package/lib/chat/display/EmptyState.js +21 -21
  53. package/lib/chat/document/EphemeralDocument.d.ts +23 -0
  54. package/lib/chat/document/EphemeralDocument.js +270 -0
  55. package/lib/chat/header/ChatHeaderBase.d.ts +12 -2
  56. package/lib/chat/header/ChatHeaderBase.js +78 -23
  57. package/lib/chat/index.d.ts +1 -0
  58. package/lib/chat/index.js +2 -0
  59. package/lib/chat/notebook/EphemeralNotebook.d.ts +24 -0
  60. package/lib/chat/notebook/EphemeralNotebook.js +252 -0
  61. package/lib/chat/prompt/InputFooter.js +4 -1
  62. package/lib/client/AgentRuntimesClient.d.ts +127 -0
  63. package/lib/client/AgentRuntimesClient.js +36 -0
  64. package/lib/client/AgentsMixin.d.ts +4 -4
  65. package/lib/client/AgentsMixin.js +35 -35
  66. package/lib/client/SdkAgentRuntimesClient.d.ts +1 -1
  67. package/lib/client/SdkAgentRuntimesClient.js +1 -1
  68. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  69. package/lib/client/mixins/RuntimesMixin.js +229 -0
  70. package/lib/client/mixins/SpacerMixin.d.ts +210 -0
  71. package/lib/client/mixins/SpacerMixin.js +615 -0
  72. package/lib/client/utils/spacerUtils.d.ts +18 -0
  73. package/lib/client/utils/spacerUtils.js +32 -0
  74. package/lib/collaboration/DatalayerCollaboration.d.ts +13 -0
  75. package/lib/collaboration/DatalayerCollaboration.js +28 -0
  76. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +58 -0
  77. package/lib/collaboration/DatalayerCollaborationProvider.js +148 -0
  78. package/lib/collaboration/index.d.ts +2 -0
  79. package/lib/collaboration/index.js +6 -0
  80. package/lib/components/AgentSummary.d.ts +19 -0
  81. package/lib/components/AgentSummary.js +89 -0
  82. package/lib/components/ToolApprovalCard.js +13 -3
  83. package/lib/components/a2ui/A2uiSurfaceComposed.d.ts +13 -0
  84. package/lib/components/a2ui/A2uiSurfaceComposed.js +110 -0
  85. package/lib/components/a2ui/index.d.ts +2 -0
  86. package/lib/components/a2ui/index.js +6 -0
  87. package/lib/components/a2ui/styles.d.ts +14 -0
  88. package/lib/components/a2ui/styles.js +142 -0
  89. package/lib/components/context/SpaceSelect.d.ts +2 -0
  90. package/lib/components/context/SpaceSelect.js +42 -0
  91. package/lib/components/flashes/FlashDisclaimer.d.ts +2 -0
  92. package/lib/components/flashes/FlashDisclaimer.js +17 -0
  93. package/lib/components/icons/ArtifactIcon.d.ts +10 -0
  94. package/lib/components/icons/ArtifactIcon.js +58 -0
  95. package/lib/components/icons/index.d.ts +1 -0
  96. package/lib/components/icons/index.js +5 -0
  97. package/lib/components/index.d.ts +5 -0
  98. package/lib/components/index.js +5 -0
  99. package/lib/components/nbgrader/NbGradesDetails.d.ts +5 -0
  100. package/lib/components/nbgrader/NbGradesDetails.js +19 -0
  101. package/lib/components/nbgrader/index.d.ts +1 -0
  102. package/lib/components/nbgrader/index.js +5 -0
  103. package/lib/components/progress/CreditsIndicator.d.ts +33 -0
  104. package/lib/components/progress/CreditsIndicator.js +23 -0
  105. package/lib/components/progress/index.d.ts +2 -0
  106. package/lib/components/progress/index.js +6 -0
  107. package/lib/components/runtimes/RuntimeCellVariables.d.ts +39 -0
  108. package/lib/components/runtimes/RuntimeCellVariables.js +172 -0
  109. package/lib/components/runtimes/RuntimeCellVariablesDialog.d.ts +37 -0
  110. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +101 -0
  111. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +57 -0
  112. package/lib/components/runtimes/RuntimeLauncherDialog.js +275 -0
  113. package/lib/components/runtimes/RuntimePickerBase.d.ts +69 -0
  114. package/lib/components/runtimes/RuntimePickerBase.js +122 -0
  115. package/lib/components/runtimes/RuntimePickerCell.d.ts +34 -0
  116. package/lib/components/runtimes/RuntimePickerCell.js +104 -0
  117. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +42 -0
  118. package/lib/components/runtimes/RuntimePickerNotebook.js +232 -0
  119. package/lib/components/runtimes/RuntimeReservationControl.d.ts +47 -0
  120. package/lib/components/runtimes/RuntimeReservationControl.js +42 -0
  121. package/lib/components/runtimes/RuntimeSimplePicker.d.ts +38 -0
  122. package/lib/components/runtimes/RuntimeSimplePicker.js +155 -0
  123. package/lib/components/runtimes/RuntimeTransfer.d.ts +16 -0
  124. package/lib/components/runtimes/RuntimeTransfer.js +5 -0
  125. package/lib/components/runtimes/RuntimeUtils.d.ts +17 -0
  126. package/lib/components/runtimes/RuntimeUtils.js +178 -0
  127. package/lib/components/runtimes/RuntimeVariables.d.ts +38 -0
  128. package/lib/components/runtimes/RuntimeVariables.js +75 -0
  129. package/lib/components/runtimes/index.d.ts +11 -0
  130. package/lib/components/runtimes/index.js +15 -0
  131. package/lib/components/scheduler/ScheduleMenu.d.ts +54 -0
  132. package/lib/components/scheduler/ScheduleMenu.js +154 -0
  133. package/lib/components/scheduler/index.d.ts +1 -0
  134. package/lib/components/scheduler/index.js +5 -0
  135. package/lib/components/snapshots/SandboxSnapshotMenu.d.ts +33 -0
  136. package/lib/components/snapshots/SandboxSnapshotMenu.js +169 -0
  137. package/lib/components/snapshots/index.d.ts +1 -0
  138. package/lib/components/snapshots/index.js +5 -0
  139. package/lib/components/snippets/SnippetDialog.d.ts +42 -0
  140. package/lib/components/snippets/SnippetDialog.js +42 -0
  141. package/lib/components/students/StudentItemStatus.d.ts +7 -0
  142. package/lib/components/students/StudentItemStatus.js +68 -0
  143. package/lib/components/students/index.d.ts +1 -0
  144. package/lib/components/students/index.js +5 -0
  145. package/lib/components/tokens/SpaceVariantToken.d.ts +5 -0
  146. package/lib/components/tokens/SpaceVariantToken.js +23 -0
  147. package/lib/components/tokens/index.d.ts +1 -0
  148. package/lib/components/tokens/index.js +5 -0
  149. package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +4 -0
  150. package/lib/components/toolbars/AssignmentEditorToolbar.js +18 -0
  151. package/lib/components/toolbars/DocumentEditorToolbar.d.ts +2 -0
  152. package/lib/components/toolbars/DocumentEditorToolbar.js +12 -0
  153. package/lib/components/toolbars/NotebookEditorToolbar.d.ts +29 -0
  154. package/lib/components/toolbars/NotebookEditorToolbar.js +30 -0
  155. package/lib/config/AgentConfiguration.d.ts +2 -2
  156. package/lib/config/index.d.ts +1 -1
  157. package/lib/context/ContextInspector.d.ts +1 -14
  158. package/lib/context/ContextInspector.js +3 -73
  159. package/lib/context/CostUsageChart.d.ts +4 -3
  160. package/lib/context/CostUsageChart.js +236 -35
  161. package/lib/context/MessageHistory.d.ts +30 -0
  162. package/lib/context/MessageHistory.js +129 -0
  163. package/lib/context/TokenUsageChart.d.ts +4 -3
  164. package/lib/context/TokenUsageChart.js +180 -30
  165. package/lib/context/TurnGraphChart.d.ts +1 -1
  166. package/lib/context/TurnGraphChart.js +6 -6
  167. package/lib/examples/A2UiAgentExample.d.ts +22 -0
  168. package/lib/examples/A2UiAgentExample.js +442 -0
  169. package/lib/examples/A2UiComponentsGalleryExample.d.ts +3 -0
  170. package/lib/examples/A2UiComponentsGalleryExample.js +863 -0
  171. package/lib/examples/A2UiContactCardExample.js +9 -5
  172. package/lib/examples/A2UiRestaurantExample.js +23 -8
  173. package/lib/examples/A2UiViewerExample.js +75 -3
  174. package/lib/examples/AgUiAgenticExample.d.ts +1 -12
  175. package/lib/examples/AgUiAgenticExample.js +52 -8
  176. package/lib/examples/AgUiBackendToolRenderingExample.d.ts +1 -16
  177. package/lib/examples/AgUiBackendToolRenderingExample.js +32 -17
  178. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -17
  179. package/lib/examples/AgUiHaikuGenUiExample.js +49 -33
  180. package/lib/examples/AgUiHumanInTheLoopExample.d.ts +1 -12
  181. package/lib/examples/AgUiHumanInTheLoopExample.js +21 -6
  182. package/lib/examples/AgUiSharedStateExample.d.ts +1 -14
  183. package/lib/examples/AgUiSharedStateExample.js +21 -6
  184. package/lib/examples/AgUiToolsBasedGenUiExample.d.ts +1 -14
  185. package/lib/examples/AgUiToolsBasedGenUiExample.js +21 -6
  186. package/lib/examples/AgentCheckpointsExample.d.ts +1 -1
  187. package/lib/examples/AgentCheckpointsExample.js +21 -22
  188. package/lib/examples/AgentCodemodeExample.js +3 -3
  189. package/lib/examples/AgentEvalsExample.js +8 -8
  190. package/lib/examples/AgentGuardrailsExample.js +22 -17
  191. package/lib/examples/AgentHooksExample.js +16 -57
  192. package/lib/examples/AgentInferenceProviderExample.js +8 -8
  193. package/lib/examples/AgentLoopExample.d.ts +10 -0
  194. package/lib/examples/AgentLoopExample.js +304 -0
  195. package/lib/examples/AgentMCPExample.js +9 -9
  196. package/lib/examples/AgentMemoryExample.js +6 -6
  197. package/lib/examples/AgentMonitoringExample.js +116 -46
  198. package/lib/examples/AgentNotificationsExample.js +6 -6
  199. package/lib/examples/AgentOtelExample.d.ts +3 -3
  200. package/lib/examples/AgentOtelExample.js +20 -15
  201. package/lib/examples/AgentOutputsExample.js +8 -8
  202. package/lib/examples/AgentParametersExample.js +24 -36
  203. package/lib/examples/AgentSandboxExample.js +7 -7
  204. package/lib/examples/AgentSkillsExample.js +9 -9
  205. package/lib/examples/AgentSubagentsExample.js +6 -6
  206. package/lib/examples/AgentToolApprovalsExample.js +37 -11
  207. package/lib/examples/AgentTriggersExample.js +12 -12
  208. package/lib/examples/AgentspecsExample.js +63 -41
  209. package/lib/examples/ChatCustomExample.js +23 -77
  210. package/lib/examples/ChatExample.js +15 -46
  211. package/lib/examples/LexicalAgentExample.js +43 -91
  212. package/lib/examples/LexicalAgentSidebarExample.js +45 -73
  213. package/lib/examples/NotebookAgentExample.js +52 -81
  214. package/lib/examples/NotebookAgentSidebarExample.js +43 -71
  215. package/lib/examples/NotebookCollaborationExample.js +11 -9
  216. package/lib/examples/NotebookExample.js +5 -2
  217. package/lib/examples/components/AuthRequiredView.js +1 -1
  218. package/lib/examples/components/ExampleErrorBoundary.d.ts +46 -0
  219. package/lib/examples/components/ExampleErrorBoundary.js +67 -0
  220. package/lib/examples/components/haiku/haiku-card.css +11 -0
  221. package/lib/examples/components/weather/weather-card.css +11 -0
  222. package/lib/examples/example-selector.js +3 -1
  223. package/lib/examples/hooks/useExampleAgentRuntime.d.ts +35 -0
  224. package/lib/examples/hooks/useExampleAgentRuntime.js +82 -0
  225. package/lib/examples/hooks/useSpecRenderToolResult.d.ts +30 -0
  226. package/lib/examples/hooks/useSpecRenderToolResult.js +61 -0
  227. package/lib/examples/index.d.ts +3 -1
  228. package/lib/examples/index.js +3 -1
  229. package/lib/examples/main.js +340 -93
  230. package/lib/examples/utils/a2ui.d.ts +2 -0
  231. package/lib/examples/utils/a2ui.js +97 -2
  232. package/lib/examples/utils/agentSummaryStore.d.ts +21 -0
  233. package/lib/examples/utils/agentSummaryStore.js +23 -0
  234. package/lib/examples/utils/notebooks/Empty.ipynb.json +30 -30
  235. package/lib/examples/utils/runtimeTargetStore.d.ts +9 -0
  236. package/lib/examples/utils/runtimeTargetStore.js +27 -0
  237. package/lib/examples/utils/teardownAgents.d.ts +13 -0
  238. package/lib/examples/utils/teardownAgents.js +78 -0
  239. package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +2 -0
  240. package/lib/examples/utils/useExampleAgentRuntimesUrl.js +26 -7
  241. package/lib/examples2/CellExample.d.ts +6 -0
  242. package/lib/examples2/CellExample.js +20 -0
  243. package/lib/examples2/DatalayerNotebookExample.d.ts +16 -0
  244. package/lib/examples2/DatalayerNotebookExample.js +109 -0
  245. package/lib/examples2/NativeNavigationExample.d.ts +8 -0
  246. package/lib/examples2/NativeNavigationExample.js +97 -0
  247. package/lib/examples2/NotebookExample.d.ts +6 -0
  248. package/lib/examples2/NotebookExample.js +19 -0
  249. package/lib/examples2/NotebookMutationsKernel.d.ts +2 -0
  250. package/lib/examples2/NotebookMutationsKernel.js +105 -0
  251. package/lib/examples2/NotebookMutationsServiceManager.d.ts +2 -0
  252. package/lib/examples2/NotebookMutationsServiceManager.js +109 -0
  253. package/lib/examples2/ReactRouterExample.d.ts +6 -0
  254. package/lib/examples2/ReactRouterExample.js +175 -0
  255. package/lib/examples2/example-selector.d.ts +22 -0
  256. package/lib/examples2/example-selector.js +45 -0
  257. package/lib/examples2/index.d.ts +2 -0
  258. package/lib/examples2/index.js +6 -0
  259. package/lib/examples2/lexical-theme.css +436 -0
  260. package/lib/examples2/main.d.ts +2 -0
  261. package/lib/examples2/main.js +330 -0
  262. package/lib/examples2/notebooks/IPyWidgetsExample.ipynb.json +101 -0
  263. package/lib/examples2/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
  264. package/lib/examples2/notebooks/Lite.ipynb.json +128 -0
  265. package/lib/examples2/notebooks/Matplotlib.ipynb.json +137 -0
  266. package/lib/examples2/notebooks/NotebookExample1.ipynb.json +126 -0
  267. package/lib/examples2/notebooks/NotebookExample2.ipynb.json +48 -0
  268. package/lib/examples2/notebooks/NotebookOutputs.ipynb.json +49 -0
  269. package/lib/examples2/notebooks/NotebookToCExample.ipynb.json +102 -0
  270. package/lib/examples2/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
  271. package/lib/examples2/notebooks/OutputIPyWidgetsExample.js +153 -0
  272. package/lib/examples2/notebooks/PyGWalker.ipynb.json +55 -0
  273. package/lib/hooks/index.d.ts +9 -1
  274. package/lib/hooks/index.js +13 -1
  275. package/lib/hooks/useAIAgentsWebSocket.d.ts +1 -1
  276. package/lib/hooks/useAIAgentsWebSocket.js +39 -3
  277. package/lib/hooks/useAgentRuntimes.d.ts +15 -3
  278. package/lib/hooks/useAgentRuntimes.js +188 -29
  279. package/lib/hooks/useAgentsCatalog.d.ts +3 -3
  280. package/lib/hooks/useAgentsCatalog.js +4 -4
  281. package/lib/hooks/useAgentsService.js +5 -5
  282. package/lib/hooks/useCellOutputshot.d.ts +4 -0
  283. package/lib/hooks/useCellOutputshot.js +25 -0
  284. package/lib/hooks/useCheckpoints.d.ts +8 -8
  285. package/lib/hooks/useCheckpoints.js +38 -28
  286. package/lib/hooks/useConfig.d.ts +1 -1
  287. package/lib/hooks/useMonitoring.d.ts +7 -5
  288. package/lib/hooks/useMonitoring.js +16 -10
  289. package/lib/hooks/useNotifications.d.ts +11 -11
  290. package/lib/hooks/useNotifications.js +1 -1
  291. package/lib/hooks/useProgressStore.d.ts +25 -0
  292. package/lib/hooks/useProgressStore.js +58 -0
  293. package/lib/hooks/useProgressTask.d.ts +9 -0
  294. package/lib/hooks/useProgressTask.js +41 -0
  295. package/lib/hooks/useProjects.d.ts +628 -0
  296. package/lib/hooks/useProjects.js +190 -0
  297. package/lib/hooks/useRuntimes.d.ts +5 -0
  298. package/lib/hooks/useRuntimes.js +34 -0
  299. package/lib/hooks/useToolApprovals.d.ts +14 -6
  300. package/lib/hooks/useToolApprovals.js +20 -1
  301. package/lib/index.d.ts +2 -1
  302. package/lib/index.js +1 -0
  303. package/lib/jupyter/exec/Python.d.ts +5 -0
  304. package/lib/jupyter/exec/Python.js +100 -0
  305. package/lib/jupyter/exec/Snippets.d.ts +105 -0
  306. package/lib/jupyter/exec/Snippets.js +101 -0
  307. package/lib/jupyter/exec/index.d.ts +2 -0
  308. package/lib/jupyter/exec/index.js +6 -0
  309. package/lib/jupyter/index.d.ts +2 -0
  310. package/lib/jupyter/index.js +6 -0
  311. package/lib/jupyter/kernelsHandler.d.ts +8 -0
  312. package/lib/jupyter/kernelsHandler.js +39 -0
  313. package/lib/mocks/models/CourseMock.d.ts +6 -0
  314. package/lib/mocks/models/CourseMock.js +29 -0
  315. package/lib/mocks/models/SpaceMock.d.ts +6 -0
  316. package/lib/mocks/models/SpaceMock.js +25 -0
  317. package/lib/models/Assignment.d.ts +7 -0
  318. package/lib/models/Assignment.js +5 -0
  319. package/lib/models/Cell.d.ts +8 -0
  320. package/lib/models/Cell.js +5 -0
  321. package/lib/models/CodeBlock.d.ts +10 -0
  322. package/lib/models/CodeBlock.js +5 -0
  323. package/lib/models/CodeSandboxSnapshot.d.ts +92 -0
  324. package/lib/models/CodeSandboxSnapshot.js +13 -0
  325. package/lib/models/CodeSandboxSnapshotDTO.d.ts +173 -0
  326. package/lib/models/CodeSandboxSnapshotDTO.js +139 -0
  327. package/lib/models/CodefeedBlocks.d.ts +7 -0
  328. package/lib/models/CodefeedBlocks.js +5 -0
  329. package/lib/models/Content.d.ts +5 -0
  330. package/lib/models/Content.js +5 -0
  331. package/lib/models/Course.d.ts +17 -0
  332. package/lib/models/Course.js +5 -0
  333. package/lib/models/Dataset.d.ts +16 -0
  334. package/lib/models/Dataset.js +5 -0
  335. package/lib/models/Document.d.ts +8 -0
  336. package/lib/models/Document.js +5 -0
  337. package/lib/models/Environment.d.ts +86 -0
  338. package/lib/models/Environment.js +5 -0
  339. package/lib/models/EnvironmentDTO.d.ts +125 -0
  340. package/lib/models/EnvironmentDTO.js +88 -0
  341. package/lib/models/Exercise.d.ts +16 -0
  342. package/lib/models/Exercise.js +5 -0
  343. package/lib/models/Item.d.ts +20 -0
  344. package/lib/models/Item.js +5 -0
  345. package/lib/models/ItemDTO.d.ts +74 -0
  346. package/lib/models/ItemDTO.js +186 -0
  347. package/lib/models/ItemType.d.ts +2 -0
  348. package/lib/models/ItemType.js +5 -0
  349. package/lib/models/Lesson.d.ts +5 -0
  350. package/lib/models/Lesson.js +5 -0
  351. package/lib/models/LexicalDTO.d.ts +155 -0
  352. package/lib/models/LexicalDTO.js +157 -0
  353. package/lib/models/Library.d.ts +10 -0
  354. package/lib/models/Library.js +5 -0
  355. package/lib/models/Notebook.d.ts +11 -0
  356. package/lib/models/Notebook.js +5 -0
  357. package/lib/models/NotebookDTO.d.ts +96 -0
  358. package/lib/models/NotebookDTO.js +153 -0
  359. package/lib/models/Page.d.ts +41 -0
  360. package/lib/models/Page.js +25 -0
  361. package/lib/models/PageTag.d.ts +19 -0
  362. package/lib/models/PageTag.js +94 -0
  363. package/lib/models/ProjectDTO.d.ts +89 -0
  364. package/lib/models/ProjectDTO.js +131 -0
  365. package/lib/models/Runtime.d.ts +160 -0
  366. package/lib/models/Runtime.js +18 -0
  367. package/lib/models/RuntimeDTO.d.ts +172 -0
  368. package/lib/models/RuntimeDTO.js +204 -0
  369. package/lib/models/Space.d.ts +35 -0
  370. package/lib/models/Space.js +66 -0
  371. package/lib/models/SpaceDTO.d.ts +334 -0
  372. package/lib/models/SpaceDTO.js +244 -0
  373. package/lib/models/SpaceItem.d.ts +10 -0
  374. package/lib/models/SpaceItem.js +5 -0
  375. package/lib/models/SpaceMember.d.ts +6 -0
  376. package/lib/models/SpaceMember.js +5 -0
  377. package/lib/models/StudentItem.d.ts +21 -0
  378. package/lib/models/StudentItem.js +5 -0
  379. package/lib/models/index.d.ts +32 -0
  380. package/lib/models/index.js +39 -0
  381. package/lib/protocols/AGUIAdapter.js +1 -1
  382. package/lib/runtimes/actions.d.ts +102 -0
  383. package/lib/runtimes/actions.js +249 -0
  384. package/lib/runtimes/apis.d.ts +273 -0
  385. package/lib/runtimes/apis.js +5 -0
  386. package/lib/runtimes/index.d.ts +5 -0
  387. package/lib/runtimes/index.js +9 -0
  388. package/lib/runtimes/settings.d.ts +15 -0
  389. package/lib/runtimes/settings.js +31 -0
  390. package/lib/runtimes/snapshots.d.ts +25 -0
  391. package/lib/runtimes/snapshots.js +150 -0
  392. package/lib/runtimes/utils.d.ts +7 -0
  393. package/lib/runtimes/utils.js +14 -0
  394. package/lib/services/DatalayerServiceManager.d.ts +23 -0
  395. package/lib/services/DatalayerServiceManager.js +90 -0
  396. package/lib/services/reconnectToRuntime.d.ts +32 -0
  397. package/lib/services/reconnectToRuntime.js +59 -0
  398. package/lib/services/sandboxServiceManagers.d.ts +31 -0
  399. package/lib/services/sandboxServiceManagers.js +57 -0
  400. package/lib/specs/agents/agents.d.ts +95 -50
  401. package/lib/specs/agents/agents.js +4037 -1669
  402. package/lib/specs/agents/index.d.ts +5 -5
  403. package/lib/specs/agents/index.js +9 -9
  404. package/lib/specs/index.d.ts +1 -0
  405. package/lib/specs/index.js +1 -0
  406. package/lib/specs/loops.d.ts +34 -0
  407. package/lib/specs/loops.js +188 -0
  408. package/lib/specs/mcpServers.d.ts +1 -0
  409. package/lib/specs/mcpServers.js +17 -0
  410. package/lib/specs/models.d.ts +4 -0
  411. package/lib/specs/models.js +30 -0
  412. package/lib/specs/skills.d.ts +1 -0
  413. package/lib/specs/skills.js +18 -0
  414. package/lib/specs/tools.d.ts +15 -0
  415. package/lib/specs/tools.js +285 -0
  416. package/lib/state/index.d.ts +4 -0
  417. package/lib/state/index.js +10 -0
  418. package/lib/state/substates/CellState.d.ts +12 -0
  419. package/lib/state/substates/CellState.js +22 -0
  420. package/lib/state/substates/DocumentState.d.ts +10 -0
  421. package/lib/state/substates/DocumentState.js +14 -0
  422. package/lib/state/substates/GradeState.d.ts +10 -0
  423. package/lib/state/substates/GradeState.js +14 -0
  424. package/lib/state/substates/JupyterLabState.d.ts +16 -0
  425. package/lib/state/substates/JupyterLabState.js +17 -0
  426. package/lib/state/substates/NbformatState.d.ts +13 -0
  427. package/lib/state/substates/NbformatState.js +16 -0
  428. package/lib/state/substates/RuntimesState.d.ts +87 -0
  429. package/lib/state/substates/RuntimesState.js +192 -0
  430. package/lib/state/substates/SpaceState.d.ts +11 -0
  431. package/lib/state/substates/SpaceState.js +16 -0
  432. package/lib/state/substates/index.d.ts +8 -0
  433. package/lib/state/substates/index.js +14 -0
  434. package/lib/stores/agentRuntimeStore.d.ts +25 -2
  435. package/lib/stores/agentRuntimeStore.js +114 -19
  436. package/lib/stories/Button.stories.d.ts +1 -1
  437. package/lib/stories/Header.stories.d.ts +3 -3
  438. package/lib/test-setup.js +10 -0
  439. package/lib/types/agents-lifecycle.d.ts +5 -5
  440. package/lib/types/agents.d.ts +6 -6
  441. package/lib/types/agentspecs.d.ts +8 -4
  442. package/lib/types/chat.d.ts +135 -3
  443. package/lib/types/config.d.ts +19 -1
  444. package/lib/types/index.d.ts +1 -0
  445. package/lib/types/index.js +1 -0
  446. package/lib/types/loops.d.ts +64 -0
  447. package/lib/types/loops.js +5 -0
  448. package/lib/types/teams.d.ts +2 -2
  449. package/lib/types/tools.d.ts +16 -0
  450. package/lib/utils/Cells.d.ts +2 -0
  451. package/lib/utils/Cells.js +28 -0
  452. package/package.json +24 -18
  453. package/scripts/codegen/generate_agents.py +96 -61
  454. package/scripts/codegen/generate_loops.py +443 -0
  455. package/scripts/codegen/generate_teams.py +4 -4
  456. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -3
  457. package/lib/examples/A2UiComponentGalleryExample.js +0 -361
  458. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  459. package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
  460. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  461. package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
  462. /package/lib/{agent-lexical-main.d.ts → agent-document-main.d.ts} +0 -0
@@ -3,26 +3,57 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  * Copyright (c) 2025-2026 Datalayer, Inc.
4
4
  * Distributed under the terms of the Modified BSD License.
5
5
  */
6
+ import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
6
7
  /// <reference types="vite/client" />
7
8
  import { useCallback, useEffect, useMemo, useState } from 'react';
8
9
  import { createRoot } from 'react-dom/client';
9
10
  import { loadJupyterConfig, JupyterReactTheme, createServerSettings, setJupyterServerUrl, setJupyterServerToken, getJupyterServerUrl, getJupyterServerToken, } from '@datalayer/jupyter-react';
10
11
  import { ServiceManager } from '@jupyterlab/services';
11
12
  import { DatalayerThemeProvider, DatalayerLogoText, getLogoColors, themeConfigs, Box, } from '@datalayer/primer-addons';
13
+ import { AgentSummary } from '../components';
12
14
  import { HomeIcon, SignInIcon, SignOutIcon } from '@primer/octicons-react';
13
- import { Button } from '@primer/react';
15
+ import { Button, Spinner, Text } from '@primer/react';
14
16
  import { AppearanceControlsWithStore } from '@datalayer/primer-addons/lib/components/appearance';
15
- import { coreStore, iamStore, createDatalayerServiceManager, } from '@datalayer/core';
17
+ import { coreStore, iamStore } from '@datalayer/core';
18
+ import { DATALAYER_IAM_TOKEN_KEY, DATALAYER_IAM_USER_KEY, } from '../state/substates';
16
19
  import { SignInSimple } from '@datalayer/core/lib/views/iam';
17
20
  import { UserBadge } from '@datalayer/core/lib/views/profile';
18
21
  import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
19
- import { agentRuntimeStore, useChatStore, useConversationStore, } from '../stores';
22
+ import { teardownExampleAgents } from './utils/teardownAgents';
20
23
  import { OAuthCallback } from '../identity';
21
24
  import { EXAMPLES, getExampleEntries, } from './example-selector';
25
+ import { runtimeTargetStore, useRuntimeTargetStore, } from './utils/runtimeTargetStore';
26
+ import { resolveExampleAgentRuntimesUrl } from './utils/useExampleAgentRuntimesUrl';
27
+ import { agentSummaryStore } from './utils/agentSummaryStore';
28
+ import { useAgentSummaryStore } from './utils/agentSummaryStore';
22
29
  import { useExampleThemeStore } from './utils/themeStore';
23
30
  import { ExampleWrapper } from './components/ExampleWrapper';
31
+ import { ExampleErrorBoundary } from './components/ExampleErrorBoundary';
24
32
  import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
25
33
  import '../../style/primer-primitives.css';
34
+ const DEFAULT_RUNTIMES_URL = 'https://r1.datalayer.run';
35
+ const resolveRuntimesUrl = (configured) => {
36
+ const envRuntimeUrl = import.meta.env.VITE_DATALAYER_RUNTIMES_URL;
37
+ const envBaseUrl = import.meta.env.VITE_DATALAYER_URL;
38
+ const candidate = configured || envRuntimeUrl || envBaseUrl;
39
+ if (!candidate) {
40
+ return DEFAULT_RUNTIMES_URL;
41
+ }
42
+ if (candidate.includes('prod1.datalayer.run')) {
43
+ return DEFAULT_RUNTIMES_URL;
44
+ }
45
+ return candidate.replace(/\/$/, '');
46
+ };
47
+ const toAgentRuntimesBaseUrl = (value) => {
48
+ if (!value) {
49
+ return undefined;
50
+ }
51
+ const normalized = value.trim().replace(/\/$/, '');
52
+ if (!normalized) {
53
+ return undefined;
54
+ }
55
+ return normalized;
56
+ };
26
57
  // Load configurations from DOM
27
58
  const loadConfigurations = () => {
28
59
  // Load Datalayer configuration
@@ -38,7 +69,8 @@ const loadConfigurations = () => {
38
69
  datalayerConfig.token = envToken;
39
70
  }
40
71
  }
41
- if (datalayerConfig.runUrl) {
72
+ if (datalayerConfig.datalayerUrl) {
73
+ datalayerConfig.runtimesUrl = resolveRuntimesUrl(datalayerConfig.runtimesUrl);
42
74
  coreStore.getState().setConfiguration(datalayerConfig);
43
75
  // Also set the token in the IAM store for API authentication
44
76
  if (datalayerConfig.token) {
@@ -115,6 +147,150 @@ const isOAuthCallback = () => {
115
147
  const hasError = params.has('error');
116
148
  return (hasCode && hasState) || hasError;
117
149
  };
150
+ const isIAMSocialCallback = () => {
151
+ const path = window.location.pathname;
152
+ const params = new URLSearchParams(window.location.search);
153
+ const isCallbackPath = /\/iam\/oauth2\/[^/]+\/callback$/.test(path);
154
+ return isCallbackPath && (params.has('token') || params.has('error'));
155
+ };
156
+ const resolveNavigationTarget = (params) => {
157
+ const candidate = params.get('navigate_to') ||
158
+ params.get('navigation') ||
159
+ params.get('post_auth_redirect') ||
160
+ params.get('redirect_url');
161
+ if (!candidate) {
162
+ return undefined;
163
+ }
164
+ const normalized = String(candidate).trim();
165
+ if (!normalized.startsWith('/') || normalized.startsWith('//')) {
166
+ return undefined;
167
+ }
168
+ if (/^\/iam\/oauth2\/[^/]+\/callback$/.test(normalized)) {
169
+ return undefined;
170
+ }
171
+ return normalized;
172
+ };
173
+ const parseUserFromCallback = (encodedUser) => {
174
+ if (!encodedUser) {
175
+ return undefined;
176
+ }
177
+ const attempts = [encodedUser];
178
+ try {
179
+ attempts.push(decodeURIComponent(encodedUser));
180
+ }
181
+ catch {
182
+ // ignore decode failure
183
+ }
184
+ if (attempts.length > 1) {
185
+ try {
186
+ attempts.push(decodeURIComponent(attempts[1]));
187
+ }
188
+ catch {
189
+ // ignore double decode failure
190
+ }
191
+ }
192
+ for (const candidate of attempts) {
193
+ try {
194
+ const parsed = JSON.parse(candidate);
195
+ if (parsed && typeof parsed === 'object') {
196
+ return parsed;
197
+ }
198
+ }
199
+ catch {
200
+ // keep trying
201
+ }
202
+ }
203
+ return undefined;
204
+ };
205
+ const AgentRuntimesIAMCallback = () => {
206
+ const [status, setStatus] = useState('processing');
207
+ const [message, setMessage] = useState('Finalizing social sign-in...');
208
+ useEffect(() => {
209
+ const params = new URLSearchParams(window.location.search);
210
+ const provider = window.location.pathname.match(/\/iam\/oauth2\/([^/]+)\/callback$/)?.[1] || '';
211
+ const token = params.get('token') || '';
212
+ const error = params.get('error') || '';
213
+ if (error) {
214
+ setStatus('error');
215
+ setMessage(error);
216
+ return;
217
+ }
218
+ if (!token) {
219
+ setStatus('error');
220
+ setMessage('Missing token in OAuth callback.');
221
+ return;
222
+ }
223
+ const callbackUser = parseUserFromCallback(params.get('user'));
224
+ const handle = String(callbackUser?.handle_s ||
225
+ callbackUser?.handle ||
226
+ callbackUser?.email_s ||
227
+ callbackUser?.email ||
228
+ 'user').trim() || 'user';
229
+ const storedUser = {
230
+ uid: String(callbackUser?.uid || ''),
231
+ handle,
232
+ firstName: String(callbackUser?.first_name_t || callbackUser?.firstName || ''),
233
+ lastName: String(callbackUser?.last_name_t || callbackUser?.lastName || ''),
234
+ email: String(callbackUser?.email_s || callbackUser?.email || ''),
235
+ displayName: String(callbackUser?.display_name_t || callbackUser?.displayName || '').trim() || handle,
236
+ avatarUrl: String(callbackUser?.avatar_url_s || callbackUser?.avatarUrl || ''),
237
+ roles: Array.isArray(callbackUser?.roles_ss)
238
+ ? callbackUser?.roles_ss
239
+ : [],
240
+ setRoles: () => { },
241
+ iamProviders: [],
242
+ settings: {},
243
+ unsubscribedFromOutbounds: false,
244
+ onboarding: {
245
+ clients: {
246
+ Platform: 0,
247
+ JupyterLab: 0,
248
+ CLI: 0,
249
+ VSCode: 0,
250
+ },
251
+ position: 'top',
252
+ tours: {},
253
+ },
254
+ events: [],
255
+ initials: handle.slice(0, 2).toUpperCase(),
256
+ id: String(callbackUser?.uid || ''),
257
+ };
258
+ window.localStorage.setItem(DATALAYER_IAM_TOKEN_KEY, token);
259
+ window.localStorage.setItem(DATALAYER_IAM_USER_KEY, JSON.stringify(storedUser));
260
+ useSimpleAuthStore.getState().setAuth(token, handle);
261
+ iamStore.getState().setLogin(storedUser, token);
262
+ const providerAccessToken = provider
263
+ ? params.get(`${provider}_access_token`)
264
+ : null;
265
+ if (providerAccessToken &&
266
+ (provider === 'github' ||
267
+ provider === 'google' ||
268
+ provider === 'linkedin' ||
269
+ provider === 'okta' ||
270
+ provider === 'bluesky')) {
271
+ iamStore
272
+ .getState()
273
+ .setIAMProviderAccessToken(provider, providerAccessToken);
274
+ }
275
+ const target = resolveNavigationTarget(params);
276
+ if (target) {
277
+ window.location.replace(target);
278
+ return;
279
+ }
280
+ window.localStorage.setItem('selectedExample', 'HomeExample');
281
+ window.location.replace('/');
282
+ }, []);
283
+ return (_jsx(JupyterReactTheme, { children: _jsx(Box, { sx: {
284
+ display: 'flex',
285
+ alignItems: 'center',
286
+ justifyContent: 'center',
287
+ minHeight: '100vh',
288
+ p: 3,
289
+ }, children: _jsxs(Box, { sx: { textAlign: 'center' }, children: [status === 'processing' ? _jsx(Spinner, { size: "large" }) : null, _jsx(Text, { as: "p", sx: {
290
+ mt: 3,
291
+ color: status === 'error' ? 'danger.fg' : 'fg.default',
292
+ }, children: message })] }) }) }));
293
+ };
118
294
  // Get the default example name from localStorage
119
295
  const getDefaultExampleName = () => {
120
296
  const stored = localStorage.getItem('selectedExample');
@@ -166,12 +342,12 @@ const NotebookOnlyApp = () => {
166
342
  const initializeApp = async () => {
167
343
  try {
168
344
  const { configuration } = coreStore.getState();
169
- // Always try to create collaboration provider if we have token and runUrl
170
- if (configuration?.token && configuration?.runUrl) {
345
+ // Always try to create collaboration provider if we have token and datalayerUrl
346
+ if (configuration?.token && configuration?.datalayerUrl) {
171
347
  try {
172
- const { DatalayerCollaborationProvider } = await import('@datalayer/core/lib/collaboration/DatalayerCollaborationProvider');
348
+ const { DatalayerCollaborationProvider } = await import('../collaboration/DatalayerCollaborationProvider');
173
349
  const provider = new DatalayerCollaborationProvider({
174
- runUrl: configuration.runUrl,
350
+ datalayerUrl: configuration.datalayerUrl,
175
351
  token: configuration.token,
176
352
  });
177
353
  setCollaborationProvider(provider);
@@ -181,7 +357,8 @@ const NotebookOnlyApp = () => {
181
357
  }
182
358
  }
183
359
  // Create service manager
184
- if (configuration?.token) {
360
+ if (runtimeTargetStore.getState().target === 'cloud' &&
361
+ configuration?.token) {
185
362
  try {
186
363
  const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100);
187
364
  await manager.ready;
@@ -238,6 +415,8 @@ export const ExampleApp = () => {
238
415
  const [selectedExample, setSelectedExample] = useState(getDefaultExampleName());
239
416
  const [searchQuery, setSearchQuery] = useState(getInitialSearchQuery());
240
417
  const [isChangingExample, setIsChangingExample] = useState(false);
418
+ const runtimeTarget = useRuntimeTargetStore(state => state.target);
419
+ const setRuntimeTarget = useRuntimeTargetStore(state => state.setTarget);
241
420
  const filteredExampleEntries = useMemo(() => {
242
421
  const normalized = searchQuery.trim().toLowerCase();
243
422
  const all = getExampleEntriesList();
@@ -274,38 +453,58 @@ export const ExampleApp = () => {
274
453
  setIsChangingExample(false);
275
454
  }
276
455
  };
456
+ const createLocalServiceManager = async () => {
457
+ const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
458
+ const manager = new ServiceManager({ serverSettings });
459
+ await manager.ready;
460
+ return manager;
461
+ };
462
+ const createCloudServiceManager = async () => {
463
+ const { configuration } = coreStore.getState();
464
+ if (!configuration?.token) {
465
+ throw new Error('Cloud runtime requires authentication. Please sign in.');
466
+ }
467
+ const activeSummary = agentSummaryStore.getState().active;
468
+ const selectedEntry = getExampleEntriesList().find(entry => entry.id === selectedExample);
469
+ const resolvedSpecId = activeSummary?.exampleId === selectedExample
470
+ ? activeSummary.specId
471
+ : undefined;
472
+ const runtimeDescriptor = resolvedSpecId || selectedEntry?.title || selectedExample;
473
+ const contextualRuntimeName = `Agent Runtime - ${runtimeDescriptor}`;
474
+ const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100, contextualRuntimeName);
475
+ await manager.ready;
476
+ return manager;
477
+ };
277
478
  useEffect(() => {
278
479
  // Load configurations
279
480
  loadConfigurations();
280
481
  // Create service manager and load example - must be sequential
281
482
  const initializeApp = async () => {
282
483
  try {
283
- const { configuration } = coreStore.getState();
284
- // Try to use DatalayerServiceManager if we have a token
285
- if (configuration?.token) {
484
+ const runtimeTarget = runtimeTargetStore.getState().target;
485
+ // Only create a cloud Datalayer runtime when the user picked "cloud".
486
+ // In "local" mode we must never hit the cloud runtimes API.
487
+ if (runtimeTarget === 'cloud') {
286
488
  try {
287
- const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100);
288
- await manager.ready;
489
+ const manager = await createCloudServiceManager();
289
490
  setServiceManager(manager);
290
491
  // Load initial example
291
492
  await loadExample(selectedExample, manager);
292
493
  }
293
494
  catch (error) {
294
495
  console.error('Failed to create DatalayerServiceManager:', error);
295
- // Fall back to regular ServiceManager
296
- const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
297
- const manager = new ServiceManager({ serverSettings });
298
- await manager.ready;
496
+ // Surface the failure in the UI, then fall back to local so the
497
+ // app stays usable.
498
+ setError(`Cloud runtime unavailable, using local instead: ${error instanceof Error ? error.message : String(error)}`);
499
+ const manager = await createLocalServiceManager();
299
500
  setServiceManager(manager);
300
501
  // Load initial example
301
502
  await loadExample(selectedExample, manager);
302
503
  }
303
504
  }
304
505
  else {
305
- // Use regular ServiceManager (no Datalayer token)
306
- const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
307
- const manager = new ServiceManager({ serverSettings });
308
- await manager.ready;
506
+ // Local runtime target (or no token): use the local Jupyter server.
507
+ const manager = await createLocalServiceManager();
309
508
  setServiceManager(manager);
310
509
  // Load initial example
311
510
  await loadExample(selectedExample, manager);
@@ -333,70 +532,51 @@ export const ExampleApp = () => {
333
532
  await new Promise(resolve => {
334
533
  requestAnimationFrame(() => resolve());
335
534
  });
336
- // 2) Tear down any server-side agents created by the previous example.
337
- // Each example caches its agent id in sessionStorage via
338
- // `uniqueAgentId(baseName)` under key `agent-runtimes:agentId:<base>`.
339
- // Delete those agents on the server and drop the cached ids so the
340
- // next example (and a future re-entry into this one) boots fresh.
341
- const agentBaseUrl = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
535
+ // 2) Tear down any server-side agents created by the previous example and
536
+ // wipe in-process agent state so the next example boots fresh.
537
+ const agentBaseUrl = resolveExampleAgentRuntimesUrl(runtimeTargetStore.getState().target);
342
538
  const token = useSimpleAuthStore.getState().token;
343
- const agentIdKeys = [];
344
- try {
345
- for (let i = 0; i < sessionStorage.length; i++) {
346
- const key = sessionStorage.key(i);
347
- if (key && key.startsWith('agent-runtimes:agentId:')) {
348
- agentIdKeys.push(key);
349
- }
350
- }
351
- }
352
- catch {
353
- // sessionStorage unavailable; skip teardown.
354
- }
355
- await Promise.all(agentIdKeys.map(async (key) => {
356
- let agentId = null;
357
- try {
358
- agentId = sessionStorage.getItem(key);
359
- }
360
- catch {
361
- /* ignore */
362
- }
363
- if (!agentId)
364
- return;
365
- try {
366
- await fetch(`${agentBaseUrl}/api/v1/agents/${encodeURIComponent(agentId)}`, {
367
- method: 'DELETE',
368
- headers: token ? { Authorization: `Bearer ${token}` } : {},
369
- });
370
- }
371
- catch {
372
- // Best-effort teardown: ignore network / 404 errors.
373
- }
374
- try {
375
- sessionStorage.removeItem(key);
376
- }
377
- catch {
378
- /* ignore */
379
- }
380
- }));
381
- // 3) Wipe every piece of in-process agent state so the next example boots
382
- // with a clean slate (no leftover messages, threads, pending tool
383
- // calls, code sandbox snapshots, monitoring caches, or sockets).
384
- useChatStore.getState().reset();
385
- useConversationStore.getState().clearAll();
386
- agentRuntimeStore.getState().reset();
387
- // 4) Drop the persisted slice from localStorage so a fresh example never
388
- // rehydrates a previous example's agents / monitoring cache.
389
- try {
390
- localStorage.removeItem('agent-runtimes-storage');
391
- }
392
- catch {
393
- // Ignore storage failures (e.g. private mode).
394
- }
395
- // 5) Load and mount the new example.
539
+ await teardownExampleAgents(agentBaseUrl, token ?? undefined);
540
+ // 3) Load and mount the new example.
396
541
  setSelectedExample(newExample);
397
542
  localStorage.setItem('selectedExample', newExample);
398
543
  await loadExample(newExample, serviceManager);
399
544
  };
545
+ const handleRuntimeTargetChange = async (newTarget) => {
546
+ if (newTarget === runtimeTarget || !serviceManager)
547
+ return;
548
+ let nextManager;
549
+ try {
550
+ nextManager =
551
+ newTarget === 'cloud'
552
+ ? await createCloudServiceManager()
553
+ : await createLocalServiceManager();
554
+ }
555
+ catch (switchError) {
556
+ setError(`Failed to switch to ${newTarget}: ${switchError instanceof Error
557
+ ? switchError.message
558
+ : String(switchError)}`);
559
+ return;
560
+ }
561
+ // 1) Unmount the current example FIRST so its cleanup hooks run against the
562
+ // still-valid OLD runtime (AG-UI disconnect, abort fetches, sandboxes).
563
+ setIsChangingExample(true);
564
+ setExampleComponent(null);
565
+ await new Promise(resolve => {
566
+ requestAnimationFrame(() => resolve());
567
+ });
568
+ // 2) Tear down the agents created on the OLD target, then wipe state so a
569
+ // brand-new runtime is launched for the new target.
570
+ const oldAgentBaseUrl = resolveExampleAgentRuntimesUrl(runtimeTarget);
571
+ const token = useSimpleAuthStore.getState().token;
572
+ await teardownExampleAgents(oldAgentBaseUrl, token ?? undefined);
573
+ // 3) Switch the target and re-mount the example (its key includes the
574
+ // target, so this launches/connects a fresh runtime).
575
+ setRuntimeTarget(newTarget);
576
+ setServiceManager(nextManager);
577
+ setError(null);
578
+ await loadExample(selectedExample, nextManager);
579
+ };
400
580
  if (loading) {
401
581
  return (_jsxs("div", { style: { padding: '20px', textAlign: 'center' }, children: [_jsxs("h2", { children: ["Loading Example: ", selectedExample] }), _jsx("p", { children: "Please wait..." })] }));
402
582
  }
@@ -418,24 +598,51 @@ export const ExampleApp = () => {
418
598
  exampleProps.onSelectExample = (name) => {
419
599
  void handleExampleChange(name);
420
600
  };
421
- return (_jsx(ExampleAppThemed, { selectedExample: selectedExample, isChangingExample: isChangingExample, error: error, ExampleComponent: ExampleComponent, exampleProps: exampleProps, onExampleChange: handleExampleChange, availableExamples: getExampleEntriesList() }));
601
+ return (_jsx(ExampleAppThemed, { selectedExample: selectedExample, isChangingExample: isChangingExample, error: error, ExampleComponent: ExampleComponent, exampleProps: exampleProps, serviceManager: serviceManager, onExampleChange: handleExampleChange, onRuntimeTargetChange: handleRuntimeTargetChange, availableExamples: getExampleEntriesList() }));
422
602
  };
423
603
  /**
424
604
  * Inner shell that reads from the theme store and wires
425
605
  * DatalayerThemeProvider + the header bar with selectors.
426
606
  */
427
- const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, onExampleChange, availableExamples, }) => {
607
+ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleComponent, exampleProps, serviceManager, onExampleChange, onRuntimeTargetChange, availableExamples, }) => {
428
608
  const { colorMode, theme: themeVariant } = useExampleThemeStore();
609
+ const runtimeTarget = useRuntimeTargetStore(state => state.target);
610
+ const agentSummary = useAgentSummaryStore(state => state.active);
429
611
  const cfg = themeConfigs[themeVariant];
430
612
  const logoColors = getLogoColors(themeVariant, colorMode);
431
613
  const { token, setAuth, clearAuth } = useSimpleAuthStore();
432
614
  const [showSignIn, setShowSignIn] = useState(false);
433
615
  const shouldShowAuthScreen = showSignIn && !token;
434
616
  const syncTokenToIamStore = useCallback((newToken) => {
435
- import('@datalayer/core/lib/state').then(({ iamStore: coreIamStore }) => {
617
+ import('../state/substates').then(({ iamStore: coreIamStore }) => {
436
618
  coreIamStore.setState({ token: newToken });
437
619
  });
438
620
  }, []);
621
+ useEffect(() => {
622
+ const baseUrl = toAgentRuntimesBaseUrl(serviceManager?.serverSettings.baseUrl) ||
623
+ resolveExampleAgentRuntimesUrl(runtimeTarget);
624
+ // Seed a base summary for the selected example. Do NOT clobber a richer
625
+ // summary that the mounted example already published (spec id, agent id,
626
+ // readiness) for the same example + target — otherwise fast-settling local
627
+ // agents lose their spec/agent id in the indicator.
628
+ const current = agentSummaryStore.getState().active;
629
+ const alreadyEnriched = current != null &&
630
+ current.exampleId === selectedExample &&
631
+ current.location === runtimeTarget &&
632
+ (current.specId != null ||
633
+ current.agentId != null ||
634
+ current.isReady !== undefined);
635
+ if (alreadyEnriched) {
636
+ return;
637
+ }
638
+ agentSummaryStore.getState().setActive({
639
+ exampleId: selectedExample,
640
+ agentName: selectedExample,
641
+ location: runtimeTarget,
642
+ baseUrl,
643
+ status: isChangingExample ? 'switching' : 'selected',
644
+ });
645
+ }, [selectedExample, runtimeTarget, isChangingExample, serviceManager]);
439
646
  useEffect(() => {
440
647
  // Keep iamStore aligned with persisted auth token on app load/refresh.
441
648
  syncTokenToIamStore(token || undefined);
@@ -515,7 +722,7 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
515
722
  const rest = availableExamples.filter(e => e.id !== 'HomeExample');
516
723
  // Classify each example into a named group.
517
724
  const groupOf = (id) => {
518
- if (id === 'AgentspecsExample')
725
+ if (id === 'AgentspecsExample' || id === 'AgentLoopExample')
519
726
  return 'Personas';
520
727
  if (id.startsWith('A2Ui'))
521
728
  return 'A2UI';
@@ -548,12 +755,33 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
548
755
  const grouped = new Map();
549
756
  for (const ex of rest) {
550
757
  const g = groupOf(ex.id);
551
- if (!grouped.has(g))
552
- grouped.set(g, []);
553
- grouped.get(g).push(ex);
758
+ const group = grouped.get(g);
759
+ if (group) {
760
+ group.push(ex);
761
+ }
762
+ else {
763
+ grouped.set(g, [ex]);
764
+ }
554
765
  }
555
- for (const list of grouped.values()) {
556
- list.sort((a, b) => a.title.localeCompare(b.title));
766
+ for (const [groupName, list] of grouped.entries()) {
767
+ if (groupName === 'Personas') {
768
+ const personaOrder = (id) => {
769
+ if (id === 'AgentspecsExample')
770
+ return 0;
771
+ if (id === 'AgentLoopExample')
772
+ return 1;
773
+ return 2;
774
+ };
775
+ list.sort((a, b) => {
776
+ const orderDelta = personaOrder(a.id) - personaOrder(b.id);
777
+ if (orderDelta !== 0)
778
+ return orderDelta;
779
+ return a.title.localeCompare(b.title);
780
+ });
781
+ }
782
+ else {
783
+ list.sort((a, b) => a.title.localeCompare(b.title));
784
+ }
557
785
  }
558
786
  const nodes = [];
559
787
  if (home) {
@@ -570,7 +798,23 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
570
798
  }
571
799
  }
572
800
  return _jsx(_Fragment, { children: nodes });
573
- })() }), isChangingExample && (_jsx(Box, { as: "span", sx: { color: 'fg.muted', fontSize: 0 }, children: "Loading\u2026" })), error && (_jsxs(Box, { as: "span", sx: { color: 'danger.fg', fontSize: 0 }, children: ["Error: ", error] }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 3 }, children: [_jsx(AppearanceControlsWithStore, { useStore: useExampleThemeStore }), _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: token ? (_jsxs(_Fragment, { children: [_jsx(UserBadge, { token: token, variant: "small", onTokenExpired: () => {
801
+ })() }), _jsxs(Box, { as: "select", value: runtimeTarget, onChange: (e) => void onRuntimeTargetChange(e.target.value), disabled: isChangingExample, "aria-label": "Runtime target", title: "Runtime target", sx: {
802
+ px: 2,
803
+ py: '6px',
804
+ fontSize: 1,
805
+ fontFamily: 'mono',
806
+ border: '1px solid',
807
+ borderColor: 'border.default',
808
+ borderRadius: 2,
809
+ bg: 'canvas.default',
810
+ color: 'fg.default',
811
+ cursor: isChangingExample ? 'not-allowed' : 'pointer',
812
+ minWidth: '120px',
813
+ outline: 'none',
814
+ '&:focus-visible': {
815
+ boxShadow: '0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))',
816
+ },
817
+ }, children: [_jsx("option", { value: "local", children: "Local" }), _jsx("option", { value: "cloud", children: "Cloud" })] }), _jsx(AgentSummary, { summary: agentSummary }), isChangingExample && (_jsx(Box, { as: "span", sx: { color: 'fg.muted', fontSize: 0 }, children: "Loading\u2026" })), error && (_jsxs(Box, { as: "span", sx: { color: 'danger.fg', fontSize: 0 }, children: ["Error: ", error] }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 3 }, children: [_jsx(AppearanceControlsWithStore, { useStore: useExampleThemeStore }), _jsx(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: token ? (_jsxs(_Fragment, { children: [_jsx(UserBadge, { token: token, variant: "small", onTokenExpired: () => {
574
818
  handleHeaderLogout();
575
819
  setShowSignIn(true);
576
820
  } }), _jsx(Button, { size: "small", variant: "invisible", onClick: handleHeaderLogout, leadingVisual: SignOutIcon, sx: { color: 'fg.muted' }, children: "Sign out" })] })) : (_jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowSignIn(true), leadingVisual: SignInIcon, sx: { color: 'fg.muted' }, children: "Sign in" })) }), _jsx(Box, { as: "a", href: "https://datalayer.ai", target: "_blank", rel: "noopener noreferrer", "aria-label": "Open Datalayer website", sx: { display: 'inline-flex', alignItems: 'center' }, children: _jsx(DatalayerLogoText, { size: 24, variant: themeVariant, colorMode: colorMode, primaryColor: logoColors.primary, secondaryColor: logoColors.secondary, textColor: logoColors.textColor, primaryGradient: logoColors.primaryGradient, secondaryGradient: logoColors.secondaryGradient, gradient: true }) })] })] }), _jsx(Box, { sx: {
@@ -583,14 +827,17 @@ const ExampleAppThemed = ({ selectedExample, isChangingExample, error, ExampleCo
583
827
  bg: 'canvas.backdrop',
584
828
  p: 3,
585
829
  overflow: 'auto',
586
- }, children: _jsx(Box, { sx: { maxWidth: 640, mx: 'auto' }, children: _jsx(SignInSimple, { onSignIn: handleHeaderSignIn, onApiKeySignIn: apiKey => handleHeaderSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }) }) })) : isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }, selectedExample) }, selectedExample)) : null })] }) }));
830
+ }, children: _jsx(Box, { sx: { maxWidth: 640, mx: 'auto' }, children: _jsx(SignInSimple, { onSignIn: handleHeaderSignIn, onApiKeySignIn: apiKey => handleHeaderSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }) }) })) : isChangingExample ? (_jsxs(Box, { sx: { p: 5, textAlign: 'center', color: 'fg.muted' }, children: [_jsxs("h3", { children: ["Loading ", selectedExample, "\u2026"] }), _jsx("p", { children: "Please wait while the example loads." })] })) : ExampleComponent ? (_jsx(ExampleErrorBoundary, { children: _jsx(ExampleWrapper, { children: _jsx(ExampleComponent, { ...exampleProps }, `${selectedExample}:${runtimeTarget}`) }, `${selectedExample}:${runtimeTarget}`) }, `${selectedExample}:${runtimeTarget}`)) : null })] }) }));
587
831
  };
588
832
  // Mount the app - check route to determine which app to render
589
833
  const root = document.getElementById('root');
590
834
  if (root) {
591
835
  const appRoot = window.__agentRuntimesExamplesRoot ??
592
836
  (window.__agentRuntimesExamplesRoot = createRoot(root));
593
- if (isOAuthCallback()) {
837
+ if (isIAMSocialCallback()) {
838
+ appRoot.render(_jsx(AgentRuntimesIAMCallback, {}));
839
+ }
840
+ else if (isOAuthCallback()) {
594
841
  // Handle OAuth callback - render OAuthCallback component
595
842
  appRoot.render(_jsx(JupyterReactTheme, { children: _jsx(OAuthCallback, { autoClose: true, autoCloseDelay: 1000 }) }));
596
843
  }
@@ -1,3 +1,4 @@
1
+ import type { CSSProperties } from 'react';
1
2
  import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
2
3
  import { MessageProcessor, type A2uiClientAction, type A2uiMessage, type SurfaceModel } from '@a2ui/web_core/v0_9';
3
4
  export type A2uiProcessor = MessageProcessor<ReactComponentImplementation>;
@@ -7,6 +8,7 @@ export declare function useA2uiProcessor(onAction?: (action: A2uiClientAction) =
7
8
  surfaces: A2uiSurfaceModel[];
8
9
  processMessages: (messages: A2uiMessage[]) => void;
9
10
  resetSurfaces: () => void;
11
+ themeStyle: CSSProperties;
10
12
  };
11
13
  export declare function createSceneMessages(args: {
12
14
  surfaceId: string;