@datalayer/agent-runtimes 1.0.10 → 1.0.18

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 (452) 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 +429 -39
  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.js +28 -28
  65. package/lib/client/SdkAgentRuntimesClient.d.ts +1 -1
  66. package/lib/client/SdkAgentRuntimesClient.js +1 -1
  67. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  68. package/lib/client/mixins/RuntimesMixin.js +229 -0
  69. package/lib/client/mixins/SpacerMixin.d.ts +210 -0
  70. package/lib/client/mixins/SpacerMixin.js +615 -0
  71. package/lib/client/utils/spacerUtils.d.ts +18 -0
  72. package/lib/client/utils/spacerUtils.js +32 -0
  73. package/lib/collaboration/DatalayerCollaboration.d.ts +13 -0
  74. package/lib/collaboration/DatalayerCollaboration.js +28 -0
  75. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +58 -0
  76. package/lib/collaboration/DatalayerCollaborationProvider.js +148 -0
  77. package/lib/collaboration/index.d.ts +2 -0
  78. package/lib/collaboration/index.js +6 -0
  79. package/lib/components/AgentSummary.d.ts +19 -0
  80. package/lib/components/AgentSummary.js +89 -0
  81. package/lib/components/a2ui/A2uiSurfaceComposed.d.ts +13 -0
  82. package/lib/components/a2ui/A2uiSurfaceComposed.js +110 -0
  83. package/lib/components/a2ui/index.d.ts +2 -0
  84. package/lib/components/a2ui/index.js +6 -0
  85. package/lib/components/a2ui/styles.d.ts +14 -0
  86. package/lib/components/a2ui/styles.js +142 -0
  87. package/lib/components/context/SpaceSelect.d.ts +2 -0
  88. package/lib/components/context/SpaceSelect.js +42 -0
  89. package/lib/components/flashes/FlashDisclaimer.d.ts +2 -0
  90. package/lib/components/flashes/FlashDisclaimer.js +17 -0
  91. package/lib/components/icons/ArtifactIcon.d.ts +10 -0
  92. package/lib/components/icons/ArtifactIcon.js +58 -0
  93. package/lib/components/icons/index.d.ts +1 -0
  94. package/lib/components/icons/index.js +5 -0
  95. package/lib/components/index.d.ts +5 -0
  96. package/lib/components/index.js +5 -0
  97. package/lib/components/nbgrader/NbGradesDetails.d.ts +5 -0
  98. package/lib/components/nbgrader/NbGradesDetails.js +19 -0
  99. package/lib/components/nbgrader/index.d.ts +1 -0
  100. package/lib/components/nbgrader/index.js +5 -0
  101. package/lib/components/progress/CreditsIndicator.d.ts +33 -0
  102. package/lib/components/progress/CreditsIndicator.js +23 -0
  103. package/lib/components/progress/index.d.ts +2 -0
  104. package/lib/components/progress/index.js +6 -0
  105. package/lib/components/runtimes/RuntimeCellVariables.d.ts +39 -0
  106. package/lib/components/runtimes/RuntimeCellVariables.js +172 -0
  107. package/lib/components/runtimes/RuntimeCellVariablesDialog.d.ts +37 -0
  108. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +101 -0
  109. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +57 -0
  110. package/lib/components/runtimes/RuntimeLauncherDialog.js +275 -0
  111. package/lib/components/runtimes/RuntimePickerBase.d.ts +69 -0
  112. package/lib/components/runtimes/RuntimePickerBase.js +122 -0
  113. package/lib/components/runtimes/RuntimePickerCell.d.ts +34 -0
  114. package/lib/components/runtimes/RuntimePickerCell.js +104 -0
  115. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +42 -0
  116. package/lib/components/runtimes/RuntimePickerNotebook.js +232 -0
  117. package/lib/components/runtimes/RuntimeReservationControl.d.ts +47 -0
  118. package/lib/components/runtimes/RuntimeReservationControl.js +42 -0
  119. package/lib/components/runtimes/RuntimeSimplePicker.d.ts +38 -0
  120. package/lib/components/runtimes/RuntimeSimplePicker.js +155 -0
  121. package/lib/components/runtimes/RuntimeTransfer.d.ts +16 -0
  122. package/lib/components/runtimes/RuntimeTransfer.js +5 -0
  123. package/lib/components/runtimes/RuntimeUtils.d.ts +17 -0
  124. package/lib/components/runtimes/RuntimeUtils.js +178 -0
  125. package/lib/components/runtimes/RuntimeVariables.d.ts +38 -0
  126. package/lib/components/runtimes/RuntimeVariables.js +75 -0
  127. package/lib/components/runtimes/index.d.ts +11 -0
  128. package/lib/components/runtimes/index.js +15 -0
  129. package/lib/components/scheduler/ScheduleMenu.d.ts +54 -0
  130. package/lib/components/scheduler/ScheduleMenu.js +154 -0
  131. package/lib/components/scheduler/index.d.ts +1 -0
  132. package/lib/components/scheduler/index.js +5 -0
  133. package/lib/components/snapshots/SandboxSnapshotMenu.d.ts +33 -0
  134. package/lib/components/snapshots/SandboxSnapshotMenu.js +169 -0
  135. package/lib/components/snapshots/index.d.ts +1 -0
  136. package/lib/components/snapshots/index.js +5 -0
  137. package/lib/components/snippets/SnippetDialog.d.ts +42 -0
  138. package/lib/components/snippets/SnippetDialog.js +42 -0
  139. package/lib/components/students/StudentItemStatus.d.ts +7 -0
  140. package/lib/components/students/StudentItemStatus.js +68 -0
  141. package/lib/components/students/index.d.ts +1 -0
  142. package/lib/components/students/index.js +5 -0
  143. package/lib/components/tokens/SpaceVariantToken.d.ts +5 -0
  144. package/lib/components/tokens/SpaceVariantToken.js +23 -0
  145. package/lib/components/tokens/index.d.ts +1 -0
  146. package/lib/components/tokens/index.js +5 -0
  147. package/lib/components/toolbars/AssignmentEditorToolbar.d.ts +4 -0
  148. package/lib/components/toolbars/AssignmentEditorToolbar.js +18 -0
  149. package/lib/components/toolbars/DocumentEditorToolbar.d.ts +2 -0
  150. package/lib/components/toolbars/DocumentEditorToolbar.js +12 -0
  151. package/lib/components/toolbars/NotebookEditorToolbar.d.ts +29 -0
  152. package/lib/components/toolbars/NotebookEditorToolbar.js +30 -0
  153. package/lib/context/ContextInspector.d.ts +1 -14
  154. package/lib/context/ContextInspector.js +3 -73
  155. package/lib/context/CostUsageChart.d.ts +4 -3
  156. package/lib/context/CostUsageChart.js +236 -35
  157. package/lib/context/MessageHistory.d.ts +30 -0
  158. package/lib/context/MessageHistory.js +129 -0
  159. package/lib/context/TokenUsageChart.d.ts +4 -3
  160. package/lib/context/TokenUsageChart.js +180 -30
  161. package/lib/context/TurnGraphChart.d.ts +1 -1
  162. package/lib/context/TurnGraphChart.js +6 -6
  163. package/lib/examples/A2UiAgentExample.d.ts +22 -0
  164. package/lib/examples/A2UiAgentExample.js +442 -0
  165. package/lib/examples/A2UiComponentsGalleryExample.d.ts +3 -0
  166. package/lib/examples/A2UiComponentsGalleryExample.js +863 -0
  167. package/lib/examples/A2UiContactCardExample.js +9 -5
  168. package/lib/examples/A2UiRestaurantExample.js +23 -8
  169. package/lib/examples/A2UiViewerExample.js +75 -3
  170. package/lib/examples/AgUiAgenticExample.d.ts +1 -12
  171. package/lib/examples/AgUiAgenticExample.js +52 -8
  172. package/lib/examples/AgUiBackendToolRenderingExample.d.ts +1 -16
  173. package/lib/examples/AgUiBackendToolRenderingExample.js +32 -17
  174. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -17
  175. package/lib/examples/AgUiHaikuGenUiExample.js +49 -33
  176. package/lib/examples/AgUiHumanInTheLoopExample.d.ts +1 -12
  177. package/lib/examples/AgUiHumanInTheLoopExample.js +21 -6
  178. package/lib/examples/AgUiSharedStateExample.d.ts +1 -14
  179. package/lib/examples/AgUiSharedStateExample.js +21 -6
  180. package/lib/examples/AgUiToolsBasedGenUiExample.d.ts +1 -14
  181. package/lib/examples/AgUiToolsBasedGenUiExample.js +21 -6
  182. package/lib/examples/AgentCheckpointsExample.d.ts +1 -1
  183. package/lib/examples/AgentCheckpointsExample.js +9 -10
  184. package/lib/examples/AgentCodeSandboxesExample.d.ts +3 -0
  185. package/lib/examples/AgentCodeSandboxesExample.js +192 -0
  186. package/lib/examples/AgentCodemodeExample.js +3 -3
  187. package/lib/examples/AgentEvalsExample.js +5 -5
  188. package/lib/examples/AgentGuardrailsExample.js +17 -12
  189. package/lib/examples/AgentHooksExample.js +14 -55
  190. package/lib/examples/AgentInferenceProviderExample.js +4 -4
  191. package/lib/examples/AgentLoopExample.d.ts +10 -0
  192. package/lib/examples/AgentLoopExample.js +304 -0
  193. package/lib/examples/AgentMCPExample.js +7 -7
  194. package/lib/examples/AgentMemoryExample.js +4 -4
  195. package/lib/examples/AgentMonitoringExample.js +114 -44
  196. package/lib/examples/AgentNotificationsExample.js +4 -4
  197. package/lib/examples/AgentOtelExample.d.ts +3 -3
  198. package/lib/examples/AgentOtelExample.js +15 -10
  199. package/lib/examples/AgentOutputsExample.js +6 -6
  200. package/lib/examples/AgentParametersExample.js +21 -33
  201. package/lib/examples/AgentSandboxExample.js +5 -5
  202. package/lib/examples/AgentSkillsExample.js +7 -7
  203. package/lib/examples/AgentSubagentsExample.js +4 -4
  204. package/lib/examples/AgentToolApprovalsExample.js +5 -5
  205. package/lib/examples/AgentTriggersExample.js +9 -9
  206. package/lib/examples/AgentspecsExample.js +63 -41
  207. package/lib/examples/ChatCustomExample.js +23 -77
  208. package/lib/examples/ChatExample.js +13 -44
  209. package/lib/examples/LexicalAgentExample.js +43 -91
  210. package/lib/examples/LexicalAgentSidebarExample.js +45 -73
  211. package/lib/examples/NotebookAgentExample.js +52 -81
  212. package/lib/examples/NotebookAgentSidebarExample.js +43 -71
  213. package/lib/examples/NotebookCollaborationExample.js +11 -9
  214. package/lib/examples/NotebookExample.js +5 -2
  215. package/lib/examples/components/AuthRequiredView.js +1 -1
  216. package/lib/examples/components/ExampleErrorBoundary.d.ts +46 -0
  217. package/lib/examples/components/ExampleErrorBoundary.js +67 -0
  218. package/lib/examples/components/haiku/haiku-card.css +11 -0
  219. package/lib/examples/components/weather/weather-card.css +11 -0
  220. package/lib/examples/example-selector.js +4 -1
  221. package/lib/examples/hooks/useExampleAgentRuntime.d.ts +35 -0
  222. package/lib/examples/hooks/useExampleAgentRuntime.js +82 -0
  223. package/lib/examples/hooks/useSpecRenderToolResult.d.ts +30 -0
  224. package/lib/examples/hooks/useSpecRenderToolResult.js +61 -0
  225. package/lib/examples/index.d.ts +4 -1
  226. package/lib/examples/index.js +4 -1
  227. package/lib/examples/main.js +340 -93
  228. package/lib/examples/utils/a2ui.d.ts +2 -0
  229. package/lib/examples/utils/a2ui.js +97 -2
  230. package/lib/examples/utils/agentSummaryStore.d.ts +21 -0
  231. package/lib/examples/utils/agentSummaryStore.js +23 -0
  232. package/lib/examples/utils/notebooks/Empty.ipynb.json +30 -30
  233. package/lib/examples/utils/runtimeTargetStore.d.ts +9 -0
  234. package/lib/examples/utils/runtimeTargetStore.js +27 -0
  235. package/lib/examples/utils/teardownAgents.d.ts +13 -0
  236. package/lib/examples/utils/teardownAgents.js +78 -0
  237. package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +2 -0
  238. package/lib/examples/utils/useExampleAgentRuntimesUrl.js +26 -7
  239. package/lib/examples2/CellExample.d.ts +6 -0
  240. package/lib/examples2/CellExample.js +20 -0
  241. package/lib/examples2/DatalayerNotebookExample.d.ts +16 -0
  242. package/lib/examples2/DatalayerNotebookExample.js +109 -0
  243. package/lib/examples2/NativeNavigationExample.d.ts +8 -0
  244. package/lib/examples2/NativeNavigationExample.js +97 -0
  245. package/lib/examples2/NotebookExample.d.ts +6 -0
  246. package/lib/examples2/NotebookExample.js +19 -0
  247. package/lib/examples2/NotebookMutationsKernel.d.ts +2 -0
  248. package/lib/examples2/NotebookMutationsKernel.js +105 -0
  249. package/lib/examples2/NotebookMutationsServiceManager.d.ts +2 -0
  250. package/lib/examples2/NotebookMutationsServiceManager.js +109 -0
  251. package/lib/examples2/ReactRouterExample.d.ts +6 -0
  252. package/lib/examples2/ReactRouterExample.js +175 -0
  253. package/lib/examples2/example-selector.d.ts +22 -0
  254. package/lib/examples2/example-selector.js +45 -0
  255. package/lib/examples2/index.d.ts +2 -0
  256. package/lib/examples2/index.js +6 -0
  257. package/lib/examples2/lexical-theme.css +436 -0
  258. package/lib/examples2/main.d.ts +2 -0
  259. package/lib/examples2/main.js +330 -0
  260. package/lib/examples2/notebooks/IPyWidgetsExample.ipynb.json +101 -0
  261. package/lib/examples2/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
  262. package/lib/examples2/notebooks/Lite.ipynb.json +128 -0
  263. package/lib/examples2/notebooks/Matplotlib.ipynb.json +137 -0
  264. package/lib/examples2/notebooks/NotebookExample1.ipynb.json +126 -0
  265. package/lib/examples2/notebooks/NotebookExample2.ipynb.json +48 -0
  266. package/lib/examples2/notebooks/NotebookOutputs.ipynb.json +49 -0
  267. package/lib/examples2/notebooks/NotebookToCExample.ipynb.json +102 -0
  268. package/lib/examples2/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
  269. package/lib/examples2/notebooks/OutputIPyWidgetsExample.js +153 -0
  270. package/lib/examples2/notebooks/PyGWalker.ipynb.json +55 -0
  271. package/lib/hooks/index.d.ts +9 -1
  272. package/lib/hooks/index.js +13 -1
  273. package/lib/hooks/useAIAgentsWebSocket.d.ts +1 -1
  274. package/lib/hooks/useAIAgentsWebSocket.js +39 -3
  275. package/lib/hooks/useAgentRuntimes.d.ts +15 -3
  276. package/lib/hooks/useAgentRuntimes.js +186 -27
  277. package/lib/hooks/useAgentsService.js +5 -5
  278. package/lib/hooks/useCellOutputshot.d.ts +4 -0
  279. package/lib/hooks/useCellOutputshot.js +25 -0
  280. package/lib/hooks/useCheckpoints.d.ts +8 -8
  281. package/lib/hooks/useCheckpoints.js +36 -26
  282. package/lib/hooks/useConfig.d.ts +1 -1
  283. package/lib/hooks/useMonitoring.d.ts +7 -5
  284. package/lib/hooks/useMonitoring.js +16 -10
  285. package/lib/hooks/useNotifications.d.ts +11 -11
  286. package/lib/hooks/useNotifications.js +1 -1
  287. package/lib/hooks/useProgressStore.d.ts +25 -0
  288. package/lib/hooks/useProgressStore.js +58 -0
  289. package/lib/hooks/useProgressTask.d.ts +9 -0
  290. package/lib/hooks/useProgressTask.js +41 -0
  291. package/lib/hooks/useProjects.d.ts +628 -0
  292. package/lib/hooks/useProjects.js +190 -0
  293. package/lib/hooks/useRuntimes.d.ts +5 -0
  294. package/lib/hooks/useRuntimes.js +34 -0
  295. package/lib/hooks/useToolApprovals.d.ts +6 -6
  296. package/lib/index.d.ts +1 -0
  297. package/lib/index.js +1 -0
  298. package/lib/jupyter/exec/Python.d.ts +5 -0
  299. package/lib/jupyter/exec/Python.js +100 -0
  300. package/lib/jupyter/exec/Snippets.d.ts +105 -0
  301. package/lib/jupyter/exec/Snippets.js +101 -0
  302. package/lib/jupyter/exec/index.d.ts +2 -0
  303. package/lib/jupyter/exec/index.js +6 -0
  304. package/lib/jupyter/index.d.ts +2 -0
  305. package/lib/jupyter/index.js +6 -0
  306. package/lib/jupyter/kernelsHandler.d.ts +8 -0
  307. package/lib/jupyter/kernelsHandler.js +39 -0
  308. package/lib/mocks/models/CourseMock.d.ts +6 -0
  309. package/lib/mocks/models/CourseMock.js +29 -0
  310. package/lib/mocks/models/SpaceMock.d.ts +6 -0
  311. package/lib/mocks/models/SpaceMock.js +25 -0
  312. package/lib/models/Assignment.d.ts +7 -0
  313. package/lib/models/Assignment.js +5 -0
  314. package/lib/models/Cell.d.ts +8 -0
  315. package/lib/models/Cell.js +5 -0
  316. package/lib/models/CodeBlock.d.ts +10 -0
  317. package/lib/models/CodeBlock.js +5 -0
  318. package/lib/models/CodeSandboxSnapshot.d.ts +92 -0
  319. package/lib/models/CodeSandboxSnapshot.js +13 -0
  320. package/lib/models/CodeSandboxSnapshotDTO.d.ts +173 -0
  321. package/lib/models/CodeSandboxSnapshotDTO.js +139 -0
  322. package/lib/models/CodefeedBlocks.d.ts +7 -0
  323. package/lib/models/CodefeedBlocks.js +5 -0
  324. package/lib/models/Content.d.ts +5 -0
  325. package/lib/models/Content.js +5 -0
  326. package/lib/models/Course.d.ts +17 -0
  327. package/lib/models/Course.js +5 -0
  328. package/lib/models/Dataset.d.ts +16 -0
  329. package/lib/models/Dataset.js +5 -0
  330. package/lib/models/Document.d.ts +8 -0
  331. package/lib/models/Document.js +5 -0
  332. package/lib/models/Environment.d.ts +86 -0
  333. package/lib/models/Environment.js +5 -0
  334. package/lib/models/EnvironmentDTO.d.ts +125 -0
  335. package/lib/models/EnvironmentDTO.js +88 -0
  336. package/lib/models/Exercise.d.ts +16 -0
  337. package/lib/models/Exercise.js +5 -0
  338. package/lib/models/Item.d.ts +20 -0
  339. package/lib/models/Item.js +5 -0
  340. package/lib/models/ItemDTO.d.ts +74 -0
  341. package/lib/models/ItemDTO.js +186 -0
  342. package/lib/models/ItemType.d.ts +2 -0
  343. package/lib/models/ItemType.js +5 -0
  344. package/lib/models/Lesson.d.ts +5 -0
  345. package/lib/models/Lesson.js +5 -0
  346. package/lib/models/LexicalDTO.d.ts +155 -0
  347. package/lib/models/LexicalDTO.js +157 -0
  348. package/lib/models/Library.d.ts +10 -0
  349. package/lib/models/Library.js +5 -0
  350. package/lib/models/Notebook.d.ts +11 -0
  351. package/lib/models/Notebook.js +5 -0
  352. package/lib/models/NotebookDTO.d.ts +96 -0
  353. package/lib/models/NotebookDTO.js +153 -0
  354. package/lib/models/Page.d.ts +41 -0
  355. package/lib/models/Page.js +25 -0
  356. package/lib/models/PageTag.d.ts +19 -0
  357. package/lib/models/PageTag.js +94 -0
  358. package/lib/models/ProjectDTO.d.ts +89 -0
  359. package/lib/models/ProjectDTO.js +131 -0
  360. package/lib/models/Runtime.d.ts +160 -0
  361. package/lib/models/Runtime.js +18 -0
  362. package/lib/models/RuntimeDTO.d.ts +172 -0
  363. package/lib/models/RuntimeDTO.js +204 -0
  364. package/lib/models/Space.d.ts +35 -0
  365. package/lib/models/Space.js +66 -0
  366. package/lib/models/SpaceDTO.d.ts +334 -0
  367. package/lib/models/SpaceDTO.js +244 -0
  368. package/lib/models/SpaceItem.d.ts +10 -0
  369. package/lib/models/SpaceItem.js +5 -0
  370. package/lib/models/SpaceMember.d.ts +6 -0
  371. package/lib/models/SpaceMember.js +5 -0
  372. package/lib/models/StudentItem.d.ts +21 -0
  373. package/lib/models/StudentItem.js +5 -0
  374. package/lib/models/index.d.ts +32 -0
  375. package/lib/models/index.js +39 -0
  376. package/lib/protocols/AGUIAdapter.js +1 -1
  377. package/lib/runtimes/actions.d.ts +102 -0
  378. package/lib/runtimes/actions.js +249 -0
  379. package/lib/runtimes/apis.d.ts +273 -0
  380. package/lib/runtimes/apis.js +5 -0
  381. package/lib/runtimes/index.d.ts +5 -0
  382. package/lib/runtimes/index.js +9 -0
  383. package/lib/runtimes/settings.d.ts +15 -0
  384. package/lib/runtimes/settings.js +31 -0
  385. package/lib/runtimes/snapshots.d.ts +25 -0
  386. package/lib/runtimes/snapshots.js +150 -0
  387. package/lib/runtimes/utils.d.ts +7 -0
  388. package/lib/runtimes/utils.js +14 -0
  389. package/lib/services/DatalayerServiceManager.d.ts +23 -0
  390. package/lib/services/DatalayerServiceManager.js +90 -0
  391. package/lib/services/reconnectToRuntime.d.ts +32 -0
  392. package/lib/services/reconnectToRuntime.js +59 -0
  393. package/lib/services/sandboxServiceManagers.d.ts +31 -0
  394. package/lib/services/sandboxServiceManagers.js +57 -0
  395. package/lib/specs/agents/agents.d.ts +78 -26
  396. package/lib/specs/agents/agents.js +4434 -1639
  397. package/lib/specs/index.d.ts +1 -0
  398. package/lib/specs/index.js +1 -0
  399. package/lib/specs/loops.d.ts +34 -0
  400. package/lib/specs/loops.js +188 -0
  401. package/lib/specs/mcpServers.d.ts +1 -0
  402. package/lib/specs/mcpServers.js +17 -0
  403. package/lib/specs/models.d.ts +4 -0
  404. package/lib/specs/models.js +30 -0
  405. package/lib/specs/skills.d.ts +1 -0
  406. package/lib/specs/skills.js +18 -0
  407. package/lib/specs/tools.d.ts +15 -0
  408. package/lib/specs/tools.js +285 -0
  409. package/lib/state/index.d.ts +4 -0
  410. package/lib/state/index.js +10 -0
  411. package/lib/state/substates/CellState.d.ts +12 -0
  412. package/lib/state/substates/CellState.js +22 -0
  413. package/lib/state/substates/DocumentState.d.ts +10 -0
  414. package/lib/state/substates/DocumentState.js +14 -0
  415. package/lib/state/substates/GradeState.d.ts +10 -0
  416. package/lib/state/substates/GradeState.js +14 -0
  417. package/lib/state/substates/JupyterLabState.d.ts +16 -0
  418. package/lib/state/substates/JupyterLabState.js +17 -0
  419. package/lib/state/substates/NbformatState.d.ts +13 -0
  420. package/lib/state/substates/NbformatState.js +16 -0
  421. package/lib/state/substates/RuntimesState.d.ts +87 -0
  422. package/lib/state/substates/RuntimesState.js +192 -0
  423. package/lib/state/substates/SpaceState.d.ts +11 -0
  424. package/lib/state/substates/SpaceState.js +16 -0
  425. package/lib/state/substates/index.d.ts +8 -0
  426. package/lib/state/substates/index.js +14 -0
  427. package/lib/stores/agentRuntimeStore.d.ts +25 -2
  428. package/lib/stores/agentRuntimeStore.js +114 -19
  429. package/lib/stories/Button.stories.d.ts +1 -1
  430. package/lib/stories/Header.stories.d.ts +3 -3
  431. package/lib/test-setup.js +10 -0
  432. package/lib/types/agents-lifecycle.d.ts +5 -5
  433. package/lib/types/agents.d.ts +3 -3
  434. package/lib/types/agentspecs.d.ts +4 -2
  435. package/lib/types/chat.d.ts +135 -3
  436. package/lib/types/config.d.ts +19 -1
  437. package/lib/types/index.d.ts +1 -0
  438. package/lib/types/index.js +1 -0
  439. package/lib/types/loops.d.ts +64 -0
  440. package/lib/types/loops.js +5 -0
  441. package/lib/types/tools.d.ts +16 -0
  442. package/lib/utils/Cells.d.ts +2 -0
  443. package/lib/utils/Cells.js +28 -0
  444. package/package.json +24 -18
  445. package/scripts/codegen/__pycache__/generate_sandbox_agents.cpython-313.pyc +0 -0
  446. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  447. package/scripts/codegen/generate_agents.py +21 -4
  448. package/scripts/codegen/generate_loops.py +443 -0
  449. package/scripts/codegen/generate_sandbox_agents.py +145 -0
  450. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -3
  451. package/lib/examples/A2UiComponentGalleryExample.js +0 -361
  452. /package/lib/{agent-lexical-main.d.ts → agent-document-main.d.ts} +0 -0
package/README.md CHANGED
@@ -62,6 +62,87 @@ Agent Runtimes solves the complexity of deploying AI agents by providing:
62
62
  - 💾 **Persistence**: DBOS support for durable execution
63
63
  - 🔒 **Context Optimization**: LLM context management
64
64
 
65
+ ## Runtime, Snapshot, and Evals Workflows
66
+
67
+ The runtime-oriented examples and CLI workflows migrated from `datalayer-core` now live here.
68
+
69
+ ### Python Runtime Quickstart
70
+
71
+ ```python
72
+ from agent_runtimes.client import RuntimeClient
73
+
74
+ client = RuntimeClient()
75
+
76
+ # Execute code in a managed runtime
77
+ with client.create_runtime() as runtime:
78
+ response = runtime.execute("print('Hello from Datalayer!')")
79
+ print(response.stdout)
80
+ ```
81
+
82
+ ### Runtime and Snapshot CLI
83
+
84
+ ```bash
85
+ # List available runtimes
86
+ datalayer runtime list
87
+
88
+ # Create a new runtime
89
+ datalayer runtime create ai-env --given-name my-runtime-123
90
+
91
+ # Execute a script in a runtime
92
+ datalayer runtime exec my-script.py --agent <agent-id>
93
+
94
+ # Create a snapshot from a runtime but do not terminate the runtime
95
+ datalayer snapshots create <pod-name> my-snapshot 'AI work!' False
96
+ ```
97
+
98
+ ### Subscription and Credits CLI
99
+
100
+ ```bash
101
+ # End-user billing view
102
+ datalayer subscriptions show
103
+ datalayer subscriptions available
104
+ datalayer subscriptions move
105
+ datalayer subscriptions topups
106
+ datalayer subscriptions dry-run
107
+
108
+ # Organization and team credits visibility
109
+ datalayer usage org-overview --organization-uid <org_uid>
110
+ datalayer usage team-overview --team-uid <team_uid>
111
+
112
+ # Monitoring-driven credit management
113
+ datalayer usage org-monitor --organization-uid <org_uid> --window-hours 24
114
+ datalayer usage team-monitor --team-uid <team_uid> --window-hours 24
115
+
116
+ # Credits transfer operations (owners/admins)
117
+ datalayer usage org-allocate-team --organization-uid <org_uid> --team-uid <team_uid> --amount 50
118
+ datalayer usage org-revoke-team --organization-uid <org_uid> --team-uid <team_uid> --amount 20
119
+ datalayer usage team-allocate-member --team-uid <team_uid> --member-uid <member_uid> --amount 15
120
+ datalayer usage team-revoke-member --team-uid <team_uid> --member-uid <member_uid> --amount 5
121
+ ```
122
+
123
+ ### Evals CLI (Multi-Agentspec)
124
+
125
+ Use comma-separated agentspec ids to create one experiment per agentspec variant:
126
+
127
+ ```bash
128
+ # Creates one experiment per agentspec in the list
129
+ agent-runtimes evals experiments create my-exp \
130
+ --evalset-id <evalset_id> \
131
+ --agent-spec-ids example-evals,example-evals-nocodemode,example-custom
132
+ ```
133
+
134
+ Generate a comparison report:
135
+
136
+ ```bash
137
+ agent-runtimes evals report <evalset_id> --run-limit 50 --export
138
+ ```
139
+
140
+ How to interpret grouped comparisons in the report:
141
+
142
+ - `Within-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using the same agentspec id.
143
+ - `Cross-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using different agentspec ids.
144
+ - Pairwise sections compute all combinations for the selected experiments, not just two agentspecs.
145
+
65
146
  ## Examples
66
147
 
67
148
  The examples demonstrate how to use the Agent Runtimes functionality in various scenarios and frameworks.
@@ -173,7 +254,7 @@ and propagates those values to the Vite HTML placeholders.
173
254
  Override any URL on the command line:
174
255
 
175
256
  ```bash
176
- make examples:prod DATALAYER_RUN_URL=https://prod2.datalayer.run
257
+ make examples:prod DATALAYER_URL=https://prod2.datalayer.run
177
258
  ```
178
259
 
179
260
  ### Running against a local `plane local` stack
@@ -1,12 +1,12 @@
1
1
  /**
2
- * AgentLexical
2
+ * AgentDocument
3
3
  *
4
- * Standalone Lexical editor + chat interface served at /static/agent-lexical.html.
4
+ * Standalone Lexical editor + chat interface served at /static/agent-document.html.
5
5
  * Connects to the agent-runtimes AG-UI endpoint and provides a Lexical
6
6
  * rich-text editor alongside the Chat component with lexical tools registered.
7
7
  *
8
8
  * The page is opened by codeai with a URL like:
9
- * http://127.0.0.1:<port>/static/agent-lexical.html?agentId=<id>
9
+ * http://127.0.0.1:<port>/static/agent-document.html?agentId=<id>
10
10
  *
11
11
  * Query parameters:
12
12
  * - agentId: the agent identifier (required, set by codeai)
@@ -18,5 +18,5 @@ import React from 'react';
18
18
  import '@datalayer/jupyter-lexical/style/index.css';
19
19
  import './examples/lexical/lexical-theme.css';
20
20
  import '../style/primer-primitives.css';
21
- export declare const AgentLexical: React.FC;
22
- export default AgentLexical;
21
+ export declare const AgentDocument: React.FC;
22
+ export default AgentDocument;
@@ -4,14 +4,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
4
4
  * Distributed under the terms of the Modified BSD License.
5
5
  */
6
6
  /**
7
- * AgentLexical
7
+ * AgentDocument
8
8
  *
9
- * Standalone Lexical editor + chat interface served at /static/agent-lexical.html.
9
+ * Standalone Lexical editor + chat interface served at /static/agent-document.html.
10
10
  * Connects to the agent-runtimes AG-UI endpoint and provides a Lexical
11
11
  * rich-text editor alongside the Chat component with lexical tools registered.
12
12
  *
13
13
  * The page is opened by codeai with a URL like:
14
- * http://127.0.0.1:<port>/static/agent-lexical.html?agentId=<id>
14
+ * http://127.0.0.1:<port>/static/agent-document.html?agentId=<id>
15
15
  *
16
16
  * Query parameters:
17
17
  * - agentId: the agent identifier (required, set by codeai)
@@ -37,10 +37,10 @@ import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
37
37
  import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
38
38
  import { Text, Spinner } from '@primer/react';
39
39
  import { AlertIcon } from '@primer/octicons-react';
40
- import { Box, DatalayerThemeProvider, setupPrimerPortals, } from '@datalayer/primer-addons';
41
- import { JupyterReactTheme, loadJupyterConfig, createServerSettings, getJupyterServerUrl, getJupyterServerToken, setJupyterServerUrl, setJupyterServerToken, useJupyter, } from '@datalayer/jupyter-react';
40
+ import { AppearanceControlsWithStore, Box, createThemeStore, DatalayerThemeProvider, setupPrimerPortals, themeConfigs, useSystemColorMode, } from '@datalayer/primer-addons';
41
+ import { JupyterReactTheme, disposeServiceManager, loadJupyterConfig, getJupyterServerUrl, getJupyterServerToken, setJupyterServerUrl, setJupyterServerToken, useJupyter, } from '@datalayer/jupyter-react';
42
42
  import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, ExcalidrawPlugin, CollapsiblePlugin, AutoLinkPlugin, AutoEmbedPlugin, LexicalConfigProvider, LexicalStatePlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, TableCellResizerPlugin, TablePlugin, } from '@datalayer/jupyter-lexical';
43
- import { ServiceManager } from '@jupyterlab/services';
43
+ import { ServiceManager, ServerConnection } from '@jupyterlab/services';
44
44
  import { Chat } from './chat';
45
45
  import { ChatInlinePlugin } from './lexical/ChatInlinePlugin';
46
46
  import { useChatInlineToolbarItems } from './lexical/useChatInlineToolbarItems';
@@ -52,13 +52,42 @@ import './examples/lexical/lexical-theme.css';
52
52
  import '../style/primer-primitives.css';
53
53
  setupPrimerPortals();
54
54
  const BASE_URL = window.location.origin;
55
- const LEXICAL_ID = 'agent-lexical';
55
+ const DOCUMENT_ID = 'agent-document';
56
+ const DOCUMENT_THEME_STORAGE_KEY = 'agent-runtimes-agent-document-theme';
57
+ const useAgentDocumentThemeStore = createThemeStore(DOCUMENT_THEME_STORAGE_KEY, {
58
+ colorMode: 'auto',
59
+ theme: 'earth',
60
+ });
56
61
  function getQueryParam(name) {
57
62
  return new URLSearchParams(window.location.search).get(name);
58
63
  }
59
64
  function getAgentId() {
60
65
  return getQueryParam('agentId') || 'default';
61
66
  }
67
+ function getKernelId() {
68
+ const kernelId = getQueryParam('kernelId') || getQueryParam('kernel_id');
69
+ return kernelId || undefined;
70
+ }
71
+ async function fetchStartupKernelId() {
72
+ try {
73
+ const resp = await fetch(`${BASE_URL}/health/startup`);
74
+ if (!resp.ok) {
75
+ return undefined;
76
+ }
77
+ const payload = await resp.json();
78
+ const sandbox = payload?.sandbox;
79
+ if (sandbox?.variant !== 'jupyter') {
80
+ return undefined;
81
+ }
82
+ const kernelId = sandbox?.kernel_id;
83
+ return typeof kernelId === 'string' && kernelId.length > 0
84
+ ? kernelId
85
+ : undefined;
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ }
62
91
  /**
63
92
  * Initialise Jupyter configuration.
64
93
  *
@@ -69,24 +98,52 @@ function getAgentId() {
69
98
  function initJupyterConfig() {
70
99
  loadJupyterConfig();
71
100
  const qBaseUrl = getQueryParam('jupyterBaseUrl');
72
- const qToken = getQueryParam('jupyterToken');
101
+ const qToken = getQueryParam('jupyterToken') || getQueryParam('token');
73
102
  if (qBaseUrl)
74
103
  setJupyterServerUrl(qBaseUrl);
75
104
  if (qToken)
76
105
  setJupyterServerToken(qToken);
106
+ let resolvedBaseUrl = qBaseUrl || getJupyterServerUrl();
107
+ let resolvedToken = qToken || getJupyterServerToken();
77
108
  const el = document.getElementById('jupyter-config-data');
78
109
  if (el?.textContent) {
79
110
  try {
80
111
  const cfg = JSON.parse(el.textContent);
81
- if (!qBaseUrl && cfg.baseUrl)
112
+ if (!qBaseUrl && cfg.baseUrl) {
82
113
  setJupyterServerUrl(cfg.baseUrl);
83
- if (!qToken && cfg.token)
114
+ resolvedBaseUrl = cfg.baseUrl;
115
+ }
116
+ if (!qToken && cfg.token) {
84
117
  setJupyterServerToken(cfg.token);
118
+ resolvedToken = cfg.token;
119
+ }
85
120
  }
86
121
  catch {
87
122
  // ignore
88
123
  }
89
124
  }
125
+ return {
126
+ baseUrl: resolvedBaseUrl,
127
+ token: resolvedToken,
128
+ };
129
+ }
130
+ function buildServerSettings(baseUrl, token) {
131
+ const wsUrl = baseUrl.replace(/^http/, 'ws');
132
+ const authenticatedFetch = (input, init) => {
133
+ if (!token) {
134
+ return fetch(input, init);
135
+ }
136
+ const headers = new Headers(init?.headers || undefined);
137
+ headers.set('Authorization', `token ${token}`);
138
+ return fetch(input, { ...init, headers });
139
+ };
140
+ return ServerConnection.makeSettings({
141
+ baseUrl,
142
+ wsUrl,
143
+ token,
144
+ appendToken: !!token,
145
+ fetch: authenticatedFetch,
146
+ });
90
147
  }
91
148
  // ─── Lexical plugins ────────────────────────────────────────────────────────
92
149
  /**
@@ -128,8 +185,18 @@ function CodeHighlightPlugin() {
128
185
  }, [editor]);
129
186
  return null;
130
187
  }
131
- function KernelPluginsInner() {
132
- const { defaultKernel } = useJupyter();
188
+ function KernelPluginsInner({ serviceManager, kernelId, onKernelReady, }) {
189
+ const { defaultKernel } = useJupyter({
190
+ serviceManager,
191
+ useRunningKernelId: kernelId,
192
+ startDefaultKernel: !kernelId,
193
+ });
194
+ // Lift the live kernel connection of the document's sandbox up so the chat
195
+ // header's kernel indicator reflects it. `defaultKernel` is created
196
+ // asynchronously and can change on restart.
197
+ useEffect(() => {
198
+ onKernelReady?.(defaultKernel?.connection ?? null);
199
+ }, [defaultKernel, onKernelReady]);
133
200
  return (_jsxs(_Fragment, { children: [_jsx(ComponentPickerMenuPlugin, { kernel: defaultKernel }), _jsx(JupyterInputOutputPlugin, { kernel: defaultKernel })] }));
134
201
  }
135
202
  /**
@@ -137,13 +204,13 @@ function KernelPluginsInner() {
137
204
  * Must be rendered inside LexicalConfigProvider context.
138
205
  */
139
206
  function LexicalToolsPlugin({ onToolsReady, }) {
140
- const tools = useLexicalTools(LEXICAL_ID);
207
+ const tools = useLexicalTools(DOCUMENT_ID);
141
208
  useEffect(() => {
142
209
  onToolsReady(tools);
143
210
  }, [tools, onToolsReady]);
144
211
  return null;
145
212
  }
146
- const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, onToolsReady, }) {
213
+ const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, kernelId, colormode, backgroundColor, onToolsReady, onKernelReady, }) {
147
214
  const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
148
215
  const [_isLinkEditMode, setIsLinkEditMode] = useState(false);
149
216
  const { toolbarItems, isAiOpen, pendingPrompt, clearPendingPrompt, closeAi } = useChatInlineToolbarItems();
@@ -164,19 +231,19 @@ const LexicalPanel = React.memo(function LexicalPanel({ serviceManager, onToolsR
164
231
  overflow: 'auto',
165
232
  borderRight: '1px solid',
166
233
  borderColor: 'border.default',
167
- }, children: _jsx(Box, { sx: { padding: 3 }, children: _jsxs(LexicalConfigProvider, { lexicalId: LEXICAL_ID, serviceManager: serviceManager, children: [_jsx(LexicalToolsPlugin, { onToolsReady: onToolsReady }), _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, {}), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { children: _jsx(KernelPluginsInner, {}) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: toolbarItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
234
+ }, children: _jsx(Box, { sx: { padding: 3 }, children: _jsxs(LexicalConfigProvider, { lexicalId: DOCUMENT_ID, serviceManager: serviceManager, children: [_jsx(LexicalToolsPlugin, { onToolsReady: onToolsReady }), _jsx(LexicalComposer, { initialConfig: editorConfig, children: _jsxs("div", { className: "lexical-editor-inner", ref: onRef, children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "lexical-editor-content", "aria-label": "Lexical Editor" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: handleChange }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), _jsx(ListPlugin, {}), _jsx(CheckListPlugin, {}), _jsx(LinkPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), _jsx(MarkdownShortcutPlugin, { transformers: TRANSFORMERS }), _jsx(LoadContentPlugin, {}), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(ExcalidrawPlugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(JupyterReactTheme, { colormode: colormode, backgroundColor: backgroundColor, children: _jsx(KernelPluginsInner, { serviceManager: serviceManager, kernelId: kernelId, onKernelReady: onKernelReady }) }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode, extraItems: toolbarItems }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(ChatInlinePlugin, { protocol: {
168
235
  type: 'ag-ui',
169
236
  endpoint: agUiEndpoint,
170
237
  }, isOpen: isAiOpen, onClose: closeAi, pendingPrompt: pendingPrompt, onPendingPromptConsumed: clearPendingPrompt })] }) })] }) }) }));
171
238
  });
172
- const ChatPanel = ({ agentId, tools }) => {
239
+ const ChatPanel = ({ agentId, tools, kernel }) => {
173
240
  return (_jsx(Box, { sx: {
174
241
  width: '420px',
175
242
  minWidth: '320px',
176
243
  display: 'flex',
177
244
  flexDirection: 'column',
178
245
  overflow: 'hidden',
179
- }, children: _jsx(Chat, { protocol: "ag-ui", baseUrl: BASE_URL, agentId: agentId, title: "Agent Lexical", placeholder: "Ask about the document...", description: "Chat with the agent to manipulate the document", showHeader: true, height: "100vh", showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, frontendTools: tools, autoFocus: true, runtimeId: agentId, historyEndpoint: `${BASE_URL}/api/v1/history`, suggestions: [
246
+ }, children: _jsx(Chat, { protocol: "ag-ui", baseUrl: BASE_URL, agentId: agentId, title: "Agent Document", placeholder: "Ask about the document...", description: "Chat with the agent to manipulate the document", showHeader: true, height: "100%", showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, showTokenUsage: true, showInformation: true, disableInternalJupyterTheme: true, frontendTools: tools, autoFocus: true, runtimeId: agentId, kernel: kernel, historyEndpoint: `${BASE_URL}/api/v1/history`, suggestions: [
180
247
  {
181
248
  title: 'Insert heading',
182
249
  message: 'Insert a heading that says "Welcome"',
@@ -192,18 +259,33 @@ const ChatPanel = ({ agentId, tools }) => {
192
259
  ], submitOnSuggestionClick: true }) }));
193
260
  };
194
261
  // ─── Main component ─────────────────────────────────────────────────────────
195
- export const AgentLexical = () => {
262
+ export const AgentDocument = () => {
196
263
  const [agentId] = useState(getAgentId);
264
+ const [kernelId, setKernelId] = useState(getKernelId);
265
+ const [kernelResolved, setKernelResolved] = useState(() => Boolean(getKernelId()));
197
266
  const [isReady, setIsReady] = useState(false);
198
267
  const [error, setError] = useState(null);
199
268
  const [serviceManager, setServiceManager] = useState(null);
200
269
  const [tools, setTools] = useState([]);
270
+ const [documentKernel, setDocumentKernel] = useState(null);
271
+ const { colorMode, theme } = useAgentDocumentThemeStore();
272
+ const themeConfig = themeConfigs[theme];
273
+ const systemMode = useSystemColorMode();
274
+ const resolvedMode = colorMode === 'auto' ? systemMode : colorMode;
275
+ const modeStyles = resolvedMode === 'dark'
276
+ ? themeConfig.themeStyles.dark
277
+ : themeConfig.themeStyles.light;
278
+ const themeBackground = modeStyles.backgroundColor ?? '';
201
279
  const handleToolsReady = useCallback((newTools) => {
202
280
  setTools(newTools);
203
281
  }, []);
282
+ const handleKernelReady = useCallback((kernel) => {
283
+ setDocumentKernel(prev => (prev?.id === kernel?.id ? prev : kernel));
284
+ }, []);
204
285
  // Verify the agent exists AND initialise the Jupyter service manager
205
286
  useEffect(() => {
206
287
  let cancelled = false;
288
+ let managerForCleanup = null;
207
289
  const init = async () => {
208
290
  try {
209
291
  // 1. Ensure agent exists — create if missing
@@ -214,7 +296,7 @@ export const AgentLexical = () => {
214
296
  headers: { 'Content-Type': 'application/json' },
215
297
  body: JSON.stringify({
216
298
  name: agentId,
217
- description: 'Agent created by Agent Lexical page',
299
+ description: 'Agent created by Agent Document page',
218
300
  agent_library: 'pydantic-ai',
219
301
  transport: 'ag-ui',
220
302
  model: DEFAULT_MODEL,
@@ -227,14 +309,19 @@ export const AgentLexical = () => {
227
309
  }
228
310
  }
229
311
  // 2. Initialise Jupyter
230
- initJupyterConfig();
231
- const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
312
+ const jupyterConfig = initJupyterConfig();
313
+ const serverSettings = buildServerSettings(jupyterConfig.baseUrl, jupyterConfig.token);
232
314
  const manager = new ServiceManager({ serverSettings });
315
+ managerForCleanup = manager;
233
316
  await manager.ready;
234
317
  if (!cancelled) {
235
318
  setServiceManager(manager);
236
319
  setIsReady(true);
237
320
  }
321
+ else {
322
+ disposeServiceManager(manager);
323
+ managerForCleanup = null;
324
+ }
238
325
  }
239
326
  catch (err) {
240
327
  if (!cancelled) {
@@ -245,11 +332,39 @@ export const AgentLexical = () => {
245
332
  init();
246
333
  return () => {
247
334
  cancelled = true;
335
+ if (managerForCleanup) {
336
+ disposeServiceManager(managerForCleanup);
337
+ managerForCleanup = null;
338
+ }
248
339
  };
249
340
  }, [agentId]);
341
+ // If kernelId is not provided via URL, reuse the startup sandbox kernel when
342
+ // available so lexical cells run in the same code sandbox as the agent.
343
+ useEffect(() => {
344
+ if (kernelId) {
345
+ setKernelResolved(true);
346
+ return;
347
+ }
348
+ let cancelled = false;
349
+ void (async () => {
350
+ const startupKernelId = await fetchStartupKernelId();
351
+ if (cancelled) {
352
+ return;
353
+ }
354
+ if (startupKernelId) {
355
+ setKernelId(startupKernelId);
356
+ }
357
+ // Mark resolution complete even when no sandbox kernel exists so the
358
+ // editor can fall back to a default kernel instead of hanging.
359
+ setKernelResolved(true);
360
+ })();
361
+ return () => {
362
+ cancelled = true;
363
+ };
364
+ }, [kernelId]);
250
365
  // Loading
251
366
  if (!isReady && !error) {
252
- return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
367
+ return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
253
368
  display: 'flex',
254
369
  flexDirection: 'column',
255
370
  alignItems: 'center',
@@ -261,7 +376,7 @@ export const AgentLexical = () => {
261
376
  }
262
377
  // Error
263
378
  if (error) {
264
- return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
379
+ return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
265
380
  display: 'flex',
266
381
  flexDirection: 'column',
267
382
  alignItems: 'center',
@@ -272,12 +387,27 @@ export const AgentLexical = () => {
272
387
  }, children: [_jsx(AlertIcon, { size: 48 }), _jsx(Text, { sx: { color: 'danger.fg', fontSize: 2 }, children: "Failed to connect" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: error })] }) }));
273
388
  }
274
389
  // Ready — lexical editor + chat side-by-side
275
- return (_jsx(DatalayerThemeProvider, { children: _jsxs(Box, { sx: {
390
+ return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsxs(Box, { sx: {
276
391
  display: 'flex',
392
+ flexDirection: 'column',
277
393
  height: '100vh',
278
394
  width: '100vw',
279
395
  overflow: 'hidden',
280
396
  bg: 'canvas.default',
281
- }, children: [serviceManager && (_jsx(LexicalPanel, { serviceManager: serviceManager, onToolsReady: handleToolsReady })), _jsx(ChatPanel, { agentId: agentId, tools: tools })] }) }));
397
+ }, children: [_jsx(Box, { sx: {
398
+ display: 'flex',
399
+ justifyContent: 'flex-end',
400
+ alignItems: 'center',
401
+ px: 3,
402
+ py: 2,
403
+ borderBottom: '1px solid',
404
+ borderColor: 'border.default',
405
+ flexShrink: 0,
406
+ }, children: _jsx(AppearanceControlsWithStore, { useStore: useAgentDocumentThemeStore }) }), _jsxs(Box, { sx: {
407
+ display: 'flex',
408
+ flex: 1,
409
+ minHeight: 0,
410
+ overflow: 'hidden',
411
+ }, children: [serviceManager && kernelResolved && (_jsx(LexicalPanel, { serviceManager: serviceManager, kernelId: kernelId, colormode: resolvedMode, backgroundColor: themeBackground, onToolsReady: handleToolsReady, onKernelReady: handleKernelReady })), _jsx(ChatPanel, { agentId: agentId, tools: tools, kernel: documentKernel })] })] }) }));
282
412
  };
283
- export default AgentLexical;
413
+ export default AgentDocument;
package/lib/AgentNode.js CHANGED
@@ -13,7 +13,7 @@ import { SignInSimple } from '@datalayer/core/lib/views/iam';
13
13
  import { UserBadge } from '@datalayer/core/lib/views/profile';
14
14
  import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
15
15
  import { useIAMStore } from '@datalayer/core/lib/state';
16
- import { BillableAccountSelect, } from '@datalayer/core/lib/components/billing';
16
+ import { BillingEntitySelect, } from '@datalayer/core/lib/components/billing';
17
17
  import { ShareAccessComponent } from '@datalayer/core/lib/components/sharing';
18
18
  import { useAgentNodeThemeStore } from './agent-node/themeStore';
19
19
  import { Chat } from './chat';
@@ -129,7 +129,7 @@ export function AgentNode() {
129
129
  const [step, setStep] = useState('auth');
130
130
  const [disableAutoBootstrap, setDisableAutoBootstrap] = useState(false);
131
131
  const [configuration, setConfiguration] = useState(DEFAULT_CONFIGURATION);
132
- const [, setSelectedBillableAccount] = useState(undefined);
132
+ const [, setSelectedBillingEntity] = useState(undefined);
133
133
  const [isSaving, setIsSaving] = useState(false);
134
134
  const [error, setError] = useState(null);
135
135
  const [inferenceProvider, setInferenceProvider] = useState('datalayer');
@@ -158,9 +158,9 @@ export function AgentNode() {
158
158
  };
159
159
  }, []);
160
160
  const pushCredentials = useCallback((authToken, payloadToken = authToken) => {
161
- const runUrl = import.meta.env?.VITE_DATALAYER_RUN_URL ||
161
+ const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
162
162
  'https://prod1.datalayer.run';
163
- const runtimesRunUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || runUrl;
163
+ const runtimesUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || datalayerUrl;
164
164
  const headers = {
165
165
  'Content-Type': 'application/json',
166
166
  };
@@ -172,14 +172,14 @@ export function AgentNode() {
172
172
  headers,
173
173
  body: JSON.stringify({
174
174
  token: payloadToken || null,
175
- runtimes_url: payloadToken ? runtimesRunUrl : null,
175
+ runtimes_url: payloadToken ? runtimesUrl : null,
176
176
  }),
177
177
  });
178
178
  }, []);
179
- // Refs kept in sync with state so the BillableAccountSelect callbacks
179
+ // Refs kept in sync with state so the BillingEntitySelect callbacks
180
180
  // (passed via stable identities) can read the latest values without
181
181
  // being re-created on every render — re-created callbacks made
182
- // BillableAccountSelect re-fire onAccountsResolved and trigger an
182
+ // BillingEntitySelect re-fire onAccountsResolved and trigger an
183
183
  // infinite setState loop.
184
184
  const configurationRef = useRef(configuration);
185
185
  useEffect(() => {
@@ -189,19 +189,19 @@ export function AgentNode() {
189
189
  useEffect(() => {
190
190
  iamUserRef.current = iamUser;
191
191
  }, [iamUser]);
192
- const handleBillableAccountChange = useCallback((uid) => {
193
- setConfiguration(prev => ({ ...prev, billable_account_uid: uid }));
192
+ const handleBillingEntityChange = useCallback((uid) => {
193
+ setConfiguration(prev => ({ ...prev, billing_entity_uid: uid }));
194
194
  }, []);
195
195
  const handleSelectedAccountChange = useCallback((account) => {
196
- setSelectedBillableAccount(account);
196
+ setSelectedBillingEntity(account);
197
197
  setConfiguration(prev => ({
198
198
  ...prev,
199
- billable_account_type: account?.accountType,
200
- billable_account_handle: account?.accountHandle,
199
+ billing_entity_type: account?.accountType,
200
+ billing_entity_handle: account?.accountHandle,
201
201
  }));
202
202
  }, []);
203
203
  const handleAccountsResolved = useCallback((_state) => {
204
- // BillableAccountSelect persists the chosen account in a cookie and
204
+ // BillingEntitySelect persists the chosen account in a cookie and
205
205
  // falls back to the personal account when none is stored, so the node
206
206
  // no longer needs to force an organization default here.
207
207
  }, []);
@@ -343,25 +343,26 @@ export function AgentNode() {
343
343
  }, [token, pushCredentials]);
344
344
  useEffect(() => {
345
345
  import('@datalayer/core/lib/state').then(({ iamStore, coreStore }) => {
346
- const runUrl = import.meta.env?.VITE_DATALAYER_RUN_URL ||
346
+ const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
347
347
  'https://prod1.datalayer.run';
348
- const runtimesRunUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || runUrl;
349
- const aiInferenceRunUrl = import.meta.env?.VITE_DATALAYER_AI_INFERENCE_URL || runUrl;
348
+ const runtimesUrl = import.meta.env?.VITE_DATALAYER_RUNTIMES_URL || datalayerUrl;
349
+ const aiInferenceUrl = import.meta.env?.VITE_DATALAYER_AI_INFERENCE_URL ||
350
+ datalayerUrl;
350
351
  // Seed all per-service URLs to match the main UI login behavior.
351
352
  const coreApi = coreStore.getState();
352
353
  const prevCfg = coreApi.configuration ?? {};
353
354
  const urls = {
354
- iamRunUrl: runUrl,
355
- runtimesRunUrl,
356
- spacerRunUrl: runUrl,
357
- libraryRunUrl: runUrl,
358
- aiagentsRunUrl: runUrl,
359
- aiinferenceRunUrl: aiInferenceRunUrl,
360
- mcpserversRunUrl: runUrl,
361
- otelRunUrl: runUrl,
362
- growthRunUrl: runUrl,
363
- successRunUrl: runUrl,
364
- supportRunUrl: runUrl,
355
+ iamUrl: datalayerUrl,
356
+ runtimesUrl,
357
+ spacerUrl: datalayerUrl,
358
+ libraryUrl: datalayerUrl,
359
+ aiAgentsUrl: datalayerUrl,
360
+ aiInferenceUrl: aiInferenceUrl,
361
+ mcpServersUrl: datalayerUrl,
362
+ otelUrl: datalayerUrl,
363
+ growthUrl: datalayerUrl,
364
+ successUrl: datalayerUrl,
365
+ supportUrl: datalayerUrl,
365
366
  };
366
367
  if (typeof coreApi.setConfiguration === 'function') {
367
368
  coreApi.setConfiguration({ ...prevCfg, ...urls });
@@ -372,7 +373,7 @@ export function AgentNode() {
372
373
  }));
373
374
  }
374
375
  const api = iamStore.getState();
375
- iamStore.setState({ token: tokenForCore, iamRunUrl: runUrl });
376
+ iamStore.setState({ token: tokenForCore, iamUrl: datalayerUrl });
376
377
  if (tokenForCore && typeof api.refreshUserByToken === 'function') {
377
378
  void Promise.resolve(api.refreshUserByToken(tokenForCore)).then(() => {
378
379
  queryClient.invalidateQueries({ queryKey: ['organizations'] });
@@ -406,10 +407,10 @@ export function AgentNode() {
406
407
  // API keys are exchanged for a session token before login so billing and
407
408
  // plans endpoints (/api/iam/v1/plans/*) resolve the correct paid plan.
408
409
  const handleApiKeySignIn = async (apiKey) => {
409
- const runUrl = import.meta.env?.VITE_DATALAYER_RUN_URL ||
410
+ const datalayerUrl = import.meta.env?.VITE_DATALAYER_URL ||
410
411
  'https://prod1.datalayer.run';
411
412
  try {
412
- const resp = await fetch(`${runUrl}/api/iam/v1/login`, {
413
+ const resp = await fetch(`${datalayerUrl}/api/iam/v1/login`, {
413
414
  method: 'POST',
414
415
  headers: { 'Content-Type': 'application/json' },
415
416
  body: JSON.stringify({ token: apiKey }),
@@ -662,7 +663,7 @@ export function AgentNode() {
662
663
  display: 'flex',
663
664
  flexDirection: 'column',
664
665
  gap: 1,
665
- }, children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Bedrock Anthropic model" }), inferenceModels.length === 0 ? (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "No model list available." })) : (_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { children: inferenceDefaultModel || inferenceModels[0] }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsx(ActionList, { selectionVariant: "single", children: inferenceModels.map(model => (_jsx(ActionList.Item, { selected: inferenceDefaultModel === model, inactiveText: "Selection is locked", children: model }, model))) }) })] }))] }))] }), iamUser ? (_jsx(BillableAccountSelect, { value: configuration.billable_account_uid || '', onChange: handleBillableAccountChange, onSelectedAccountChange: handleSelectedAccountChange, onAccountsResolved: handleAccountsResolved })) : (_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Run this agent under" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Loading billable accounts..." })] }))] }), _jsxs(Box, { sx: {
666
+ }, children: [_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Bedrock Anthropic model" }), inferenceModels.length === 0 ? (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "No model list available." })) : (_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Button, { children: inferenceDefaultModel || inferenceModels[0] }), _jsx(ActionMenu.Overlay, { width: "large", children: _jsx(ActionList, { selectionVariant: "single", children: inferenceModels.map(model => (_jsx(ActionList.Item, { selected: inferenceDefaultModel === model, inactiveText: "Selection is locked", children: model }, model))) }) })] }))] }))] }), iamUser ? (_jsx(BillingEntitySelect, { value: configuration.billing_entity_uid || '', onChange: handleBillingEntityChange, onSelectedAccountChange: handleSelectedAccountChange, onAccountsResolved: handleAccountsResolved })) : (_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Run this agent under" }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "Loading billing entitys..." })] }))] }), _jsxs(Box, { sx: {
666
667
  display: 'flex',
667
668
  flexDirection: 'column',
668
669
  gap: 2,