@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
@@ -1,5 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Text, LabelGroup, Label, Truncate } from '@primer/react';
2
+ import { Text, LabelGroup, Label, Truncate, ThemeProvider, } from '@primer/react';
3
3
  import { Box } from '@datalayer/primer-addons';
4
4
  import { AiAgentIcon } from '@datalayer/icons-react';
5
5
  // ---------------------------------------------------------------------------
@@ -18,24 +18,24 @@ export function ChatEmptyState({ emptyState, brandIcon, description, suggestions
18
18
  onSuggestionFill?.(suggestion.message);
19
19
  }
20
20
  };
21
- return (_jsxs(Box, { sx: {
22
- display: 'flex',
23
- flexDirection: 'column',
24
- alignItems: 'center',
25
- justifyContent: 'center',
26
- height: '100%',
27
- p: 4,
28
- color: 'fg.muted',
29
- textAlign: 'center',
30
- gap: 2,
31
- }, children: [emptyState?.icon || brandIcon || _jsx(AiAgentIcon, { colored: true, size: 48 }), _jsx(Text, { sx: { fontSize: 2 }, children: emptyState?.title || 'Start a conversation' }), (emptyState?.subtitle || description) && (_jsx(Text, { sx: { fontSize: 1 }, children: emptyState?.subtitle || description })), suggestions && suggestions.length > 0 && (_jsx(LabelGroup, { sx: { mt: 2, justifyContent: 'center' }, children: suggestions.map((suggestion, index) => (_jsx(Label, { variant: "accent", title: suggestion.title, sx: {
32
- cursor: 'pointer',
33
- display: 'inline-flex',
34
- alignItems: 'center',
35
- '&:hover': {
36
- bg: 'accent.emphasis',
37
- color: 'var(--button-primary-fgColor-rest)',
38
- borderColor: 'accent.emphasis',
39
- },
40
- }, onClick: () => handleSuggestionClick(suggestion), children: _jsx(Box, { sx: { width: 140, maxWidth: 140, minWidth: 140 }, children: _jsx(Truncate, { title: suggestion.title, maxWidth: "100%", children: suggestion.title }) }) }, index))) }))] }));
21
+ return (_jsx(ThemeProvider, { children: _jsxs(Box, { sx: {
22
+ display: 'flex',
23
+ flexDirection: 'column',
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ height: '100%',
27
+ p: 4,
28
+ color: 'fg.muted',
29
+ textAlign: 'center',
30
+ gap: 2,
31
+ }, children: [emptyState?.icon || brandIcon || _jsx(AiAgentIcon, { colored: true, size: 48 }), _jsx(Text, { sx: { fontSize: 2 }, children: emptyState?.title || 'Start a conversation' }), (emptyState?.subtitle || description) && (_jsx(Text, { sx: { fontSize: 1 }, children: emptyState?.subtitle || description })), suggestions && suggestions.length > 0 && (_jsx(LabelGroup, { sx: { mt: 2, justifyContent: 'center' }, children: suggestions.map((suggestion, index) => (_jsx(Label, { variant: "accent", title: suggestion.title, sx: {
32
+ cursor: 'pointer',
33
+ display: 'inline-flex',
34
+ alignItems: 'center',
35
+ '&:hover': {
36
+ bg: 'accent.emphasis',
37
+ color: 'var(--button-primary-fgColor-rest)',
38
+ borderColor: 'accent.emphasis',
39
+ },
40
+ }, onClick: () => handleSuggestionClick(suggestion), children: _jsx(Box, { sx: { width: 140, maxWidth: 140, minWidth: 140 }, children: _jsx(Truncate, { title: suggestion.title, maxWidth: "100%", children: suggestion.title }) }) }, index))) }))] }) }));
41
41
  }
@@ -0,0 +1,23 @@
1
+ import type { FrontendToolDefinition } from '../../types/tools';
2
+ import '@datalayer/jupyter-react/lib/css/PrismCss';
3
+ import '@datalayer/jupyter-lexical/style/index.css';
4
+ export interface EphemeralDocumentProps {
5
+ /**
6
+ * Document identifier. Must match the id passed to `useLexicalTools` so the
7
+ * agent's lexical frontend tools operate on this document instance.
8
+ */
9
+ documentId: string;
10
+ /** Preferred runtime pod name to bind the document kernel to. */
11
+ runtimePodName?: string;
12
+ /** Optional persisted Lexical editor state (JSON string) to restore. */
13
+ content?: string;
14
+ /** Callback fired when the document's editor state changes. */
15
+ onContentChange?: (content: string) => void;
16
+ /** Reports the lexical frontend tools so the parent can pass them to the agent. */
17
+ onToolsReady?: (tools: FrontendToolDefinition[]) => void;
18
+ }
19
+ /**
20
+ * Renders an in-memory Lexical document backed by a sandbox kernel.
21
+ */
22
+ export declare function EphemeralDocument({ documentId, runtimePodName, content, onContentChange, onToolsReady, }: EphemeralDocumentProps): import("react/jsx-runtime").JSX.Element;
23
+ export default EphemeralDocument;
@@ -0,0 +1,270 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ /**
7
+ * EphemeralDocument — an in-memory Lexical rich-text document rendered next to
8
+ * the chat.
9
+ *
10
+ * This is the document analogue of {@link EphemeralNotebook}. The Lexical
11
+ * editor state lives purely in memory and is mirrored into the agent-runtime
12
+ * Zustand store (`ephemeralDocumentModels`) so the document survives navigating
13
+ * away from and back to the same runtime page. While mounted, its lexical
14
+ * frontend tools are reported upward via `onToolsReady` so the agent can drive
15
+ * the document blocks (insert / update / delete / read).
16
+ *
17
+ * IMPORTANT: this module statically imports `@datalayer/jupyter-lexical`, which
18
+ * initialises Lumino-backed nodes on load. It is therefore lazy-loaded by
19
+ * `ChatBase` (via `React.lazy`) so notebook-only chats never pull in lexical.
20
+ *
21
+ * @module chat/document/EphemeralDocument
22
+ */
23
+ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
24
+ import { $getRoot, $createParagraphNode, } from 'lexical';
25
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
26
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
27
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
28
+ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
29
+ import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
30
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
31
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
32
+ import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
33
+ import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
34
+ import { TRANSFORMERS } from '@lexical/markdown';
35
+ import { registerCodeHighlighting } from '@lexical/code';
36
+ import { ListPlugin } from '@lexical/react/LexicalListPlugin';
37
+ import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
38
+ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
39
+ import { ServerConnection, ServiceManager } from '@jupyterlab/services';
40
+ import { Box, DatalayerThemeProvider, getThemeConfig, useSystemColorMode, useThemeStore, } from '@datalayer/primer-addons';
41
+ import { JupyterReactTheme, Kernel, disposeServiceManager, } from '@datalayer/jupyter-react';
42
+ import { ComponentPickerMenuPlugin, JupyterCellPlugin, JupyterInputOutputPlugin, DraggableBlockPlugin, ImagesPlugin, ExcalidrawPlugin, TablePlugin, TableCellResizerPlugin, TableActionMenuPlugin, TableHoverActionsV2Plugin, CollapsiblePlugin, HorizontalRulePlugin, EquationsPlugin, YouTubePlugin, AutoLinkPlugin, AutoEmbedPlugin, LexicalConfigProvider, LexicalStatePlugin, FloatingTextFormatToolbarPlugin, CodeActionMenuPlugin, ListMaxIndentLevelPlugin, ToolbarPlugin, ToolbarContext, CommentsProvider, commentTheme, } from '@datalayer/jupyter-lexical';
43
+ import { editorConfig } from '../../examples/lexical/editorConfig';
44
+ import { useLexicalTools } from '../../tools/adapters/agent-runtimes/lexicalHooks';
45
+ import { useAgentsRuntimes } from '../../hooks/useAgentRuntimes';
46
+ import { registerSandboxServiceManager } from '../../services/sandboxServiceManagers';
47
+ import { useProgressTask } from '../../hooks/useProgressTask';
48
+ import '@datalayer/jupyter-react/lib/css/PrismCss';
49
+ import '@datalayer/jupyter-lexical/style/index.css';
50
+ /**
51
+ * Lexical plugin that loads the initial (restored) editor state exactly once.
52
+ */
53
+ function LoadContentPlugin({ content }) {
54
+ const [editor] = useLexicalComposerContext();
55
+ const isFirstRender = useRef(true);
56
+ useEffect(() => {
57
+ if (!isFirstRender.current) {
58
+ return;
59
+ }
60
+ isFirstRender.current = false;
61
+ if (!content) {
62
+ editor.update(() => {
63
+ const root = $getRoot();
64
+ if (root.getChildrenSize() === 0) {
65
+ root.append($createParagraphNode());
66
+ }
67
+ }, { tag: 'history-merge' });
68
+ return;
69
+ }
70
+ try {
71
+ const parsed = JSON.parse(content);
72
+ if (parsed && typeof parsed === 'object' && parsed.root) {
73
+ const editorState = editor.parseEditorState(content);
74
+ editor.setEditorState(editorState, { tag: 'history-merge' });
75
+ }
76
+ else {
77
+ throw new Error('Invalid Lexical editor state format');
78
+ }
79
+ }
80
+ catch {
81
+ editor.update(() => {
82
+ const root = $getRoot();
83
+ root.clear();
84
+ root.append($createParagraphNode());
85
+ }, { tag: 'history-merge' });
86
+ }
87
+ }, [content, editor]);
88
+ return null;
89
+ }
90
+ /** Registers code syntax highlighting for code blocks. */
91
+ function CodeHighlightPlugin() {
92
+ const [editor] = useLexicalComposerContext();
93
+ useEffect(() => registerCodeHighlighting(editor), [editor]);
94
+ return null;
95
+ }
96
+ /**
97
+ * Top document toolbar mirroring the notebook/document editor toolbar. Reads
98
+ * the active editor from the Lexical composer context and drives the shared
99
+ * {@link ToolbarPlugin} (block type, formatting, insert menu, …).
100
+ */
101
+ function DocumentToolbar({ setIsLinkEditMode, }) {
102
+ const [editor] = useLexicalComposerContext();
103
+ const [activeEditor, setActiveEditor] = useState(editor);
104
+ return (_jsx(ToolbarPlugin, { editor: editor, activeEditor: activeEditor, setActiveEditor: setActiveEditor, setIsLinkEditMode: setIsLinkEditMode }));
105
+ }
106
+ /**
107
+ * Renders an in-memory Lexical document backed by a sandbox kernel.
108
+ */
109
+ export function EphemeralDocument({ documentId, runtimePodName, content, onContentChange, onToolsReady, }) {
110
+ // Capture the restore seed ONCE per documentId so parent re-renders don't
111
+ // remount the composer (which reads `initialConfig` a single time).
112
+ const initialContentRef = useRef(content);
113
+ const initialDocumentIdRef = useRef(documentId);
114
+ if (initialDocumentIdRef.current !== documentId) {
115
+ initialDocumentIdRef.current = documentId;
116
+ initialContentRef.current = content;
117
+ }
118
+ const initialContent = initialContentRef.current;
119
+ // Hash of the last content we persisted, so onChange only writes on change.
120
+ const lastSavedHashRef = useRef(initialContent ?? '');
121
+ // Lexical frontend tools scoped to this document. Reported upward so the
122
+ // agent can drive the document while it is visible.
123
+ const lexicalTools = useLexicalTools(documentId);
124
+ useEffect(() => {
125
+ onToolsReady?.(lexicalTools);
126
+ }, [lexicalTools, onToolsReady]);
127
+ // Resolve the runtime sandbox strictly by its assigned pod name. There is
128
+ // deliberately NO local fallback kernel: the ephemeral document executes on
129
+ // exactly the runtime assigned to this agent, or shows a waiting state.
130
+ const { runtimes } = useAgentsRuntimes();
131
+ const selectedRuntime = useMemo(() => {
132
+ const preferredPod = String(runtimePodName || '').trim();
133
+ if (!preferredPod) {
134
+ return undefined;
135
+ }
136
+ return runtimes.find(rt => String(rt?.pod_name || '') === preferredPod);
137
+ }, [runtimePodName, runtimes]);
138
+ const [runtimeServiceManager, setRuntimeServiceManager] = useState(null);
139
+ // Kernel started inside the agent runtime sandbox and threaded into the
140
+ // Jupyter cell plugins, mirroring how the document editor wires its kernel.
141
+ const [documentKernel, setDocumentKernel] = useState(undefined);
142
+ useEffect(() => {
143
+ let cancelled = false;
144
+ let manager = null;
145
+ let unregisterManager = null;
146
+ const connectRuntime = async () => {
147
+ const baseUrl = String(selectedRuntime?.url || '').trim();
148
+ if (!baseUrl) {
149
+ if (!cancelled) {
150
+ setRuntimeServiceManager(null);
151
+ setDocumentKernel(undefined);
152
+ }
153
+ return;
154
+ }
155
+ try {
156
+ const token = String(selectedRuntime?.token || '').trim();
157
+ const serverSettings = ServerConnection.makeSettings({
158
+ baseUrl,
159
+ wsUrl: baseUrl.replace(/^http/, 'ws'),
160
+ token,
161
+ appendToken: true,
162
+ });
163
+ manager = new ServiceManager({ serverSettings });
164
+ // Central sandbox registry: runtime terminate/pause disposes this
165
+ // manager immediately so its pollers cannot hit the dead pod ingress.
166
+ unregisterManager = registerSandboxServiceManager(String(selectedRuntime?.pod_name || ''), manager);
167
+ await manager.ready;
168
+ const kernelConnection = await manager.kernels.startNew();
169
+ if (!cancelled) {
170
+ const kernel = new Kernel({
171
+ kernelName: kernelConnection.model.name,
172
+ kernelSpecName: kernelConnection.model.name,
173
+ kernelModel: kernelConnection.model,
174
+ kernelManager: manager.kernels,
175
+ kernelspecsManager: manager.kernelspecs,
176
+ sessionManager: manager.sessions,
177
+ });
178
+ setRuntimeServiceManager(manager);
179
+ setDocumentKernel(kernel);
180
+ }
181
+ }
182
+ catch {
183
+ if (!cancelled) {
184
+ setRuntimeServiceManager(null);
185
+ setDocumentKernel(undefined);
186
+ }
187
+ }
188
+ };
189
+ connectRuntime();
190
+ return () => {
191
+ cancelled = true;
192
+ unregisterManager?.();
193
+ if (manager) {
194
+ disposeServiceManager(manager);
195
+ }
196
+ };
197
+ }, [selectedRuntime?.pod_name, selectedRuntime?.url, selectedRuntime?.token]);
198
+ const activeServiceManager = runtimeServiceManager;
199
+ const isRuntimeStarting = Boolean(String(runtimePodName || '').trim() && !activeServiceManager);
200
+ useProgressTask(`ephemeral-document-start-${documentId}`, isRuntimeStarting);
201
+ // Build the initial config once per documentId, without the demo content so
202
+ // the document starts empty and is either restored or filled by the agent.
203
+ const initialConfig = useMemo(() => {
204
+ // Drop the demo `editorState` and the examples `lexicalTheme`. Use the
205
+ // shared `commentTheme` (same as the document editor) so the Jupyter cell
206
+ // and rich-text nodes get the class names styled by jupyter-lexical CSS.
207
+ const { editorState: _ignored, theme: _theme, ...rest } = editorConfig;
208
+ return {
209
+ ...rest,
210
+ theme: commentTheme,
211
+ namespace: `ephemeral-document-${documentId}`,
212
+ };
213
+ }, [documentId]);
214
+ const handleChange = useCallback((editorState) => {
215
+ if (!onContentChange) {
216
+ return;
217
+ }
218
+ const json = JSON.stringify(editorState.toJSON());
219
+ if (json === lastSavedHashRef.current) {
220
+ return;
221
+ }
222
+ lastSavedHashRef.current = json;
223
+ onContentChange(json);
224
+ }, [onContentChange]);
225
+ const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
226
+ const [, setIsLinkEditMode] = useState(false);
227
+ const onAnchorRef = (elem) => {
228
+ if (elem !== null) {
229
+ setFloatingAnchorElem(elem);
230
+ }
231
+ };
232
+ // Resolve the active theme/color-mode exactly like the notebook editor so
233
+ // the document honours dark / branded themes instead of always rendering
234
+ // light.
235
+ const { colorMode, theme: themeVariant } = useThemeStore();
236
+ const systemMode = useSystemColorMode();
237
+ const themeConfig = getThemeConfig(themeVariant);
238
+ const resolvedMode = colorMode === 'auto' ? systemMode : colorMode;
239
+ const modeStyles = resolvedMode === 'dark'
240
+ ? themeConfig.themeStyles.dark
241
+ : themeConfig.themeStyles.light;
242
+ const themeBackground = modeStyles.backgroundColor ?? '';
243
+ return (_jsx(Box, { sx: {
244
+ flex: 1,
245
+ minHeight: 0,
246
+ height: '100%',
247
+ position: 'relative',
248
+ overflow: 'hidden',
249
+ bg: 'canvas.default',
250
+ }, children: activeServiceManager ? (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: themeConfig.primerTheme, themeStyles: themeConfig.themeStyles, children: _jsx(JupyterReactTheme, { colormode: resolvedMode, backgroundColor: themeBackground, children: _jsx(Box, { sx: {
251
+ position: 'absolute',
252
+ inset: 0,
253
+ display: 'flex',
254
+ flexDirection: 'column',
255
+ overflow: 'auto',
256
+ overscrollBehaviorY: 'contain',
257
+ padding: 2,
258
+ '& .editor-shell': {
259
+ backgroundColor: themeBackground,
260
+ borderRadius: 2,
261
+ },
262
+ '& .editor-container': { backgroundColor: themeBackground },
263
+ '& .editor-inner': { backgroundColor: themeBackground },
264
+ '& .editor-input': { backgroundColor: themeBackground },
265
+ '& [role="toolbar"][aria-label="Editor toolbar"]': {
266
+ backgroundColor: themeBackground,
267
+ },
268
+ }, children: _jsx(LexicalConfigProvider, { lexicalId: documentId, serviceManager: activeServiceManager, children: _jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(CommentsProvider, { children: _jsx(ToolbarContext, { children: _jsxs("div", { className: "editor-shell", children: [_jsx(DocumentToolbar, { setIsLinkEditMode: setIsLinkEditMode }), _jsx("div", { className: "editor-container", children: _jsxs("div", { className: "editor-inner", children: [_jsx(LexicalStatePlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx("div", { className: "editor-scroller", children: _jsx("div", { className: "editor", ref: onAnchorRef, children: _jsx(ContentEditable, { className: "editor-input", "aria-label": "Ephemeral document 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, { content: initialContent }), _jsx(CodeHighlightPlugin, {}), _jsx(ImagesPlugin, { captionsEnabled: false }), _jsx(ExcalidrawPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizerPlugin, {}), _jsx(TableActionMenuPlugin, {}), _jsx(TableHoverActionsV2Plugin, {}), _jsx(CollapsiblePlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(EquationsPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(JupyterCellPlugin, {}), _jsx(ComponentPickerMenuPlugin, { kernel: documentKernel }), _jsx(JupyterInputOutputPlugin, { kernel: documentKernel }), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem })] }))] }) })] }) }) }) }) }) }) }) })) : null }));
269
+ }
270
+ export default EphemeralDocument;
@@ -10,7 +10,7 @@
10
10
  import { type ReactNode } from 'react';
11
11
  import { type ExecutionState } from '@datalayer/jupyter-react';
12
12
  import type { IKernelConnection } from '@jupyterlab/services/lib/kernel/kernel';
13
- import type { ChatViewMode, HeaderButtonsConfig } from '../../types/chat';
13
+ import type { ChatViewMode, EphemeralSurfaceMode, HeaderButtonsConfig } from '../../types/chat';
14
14
  import type { SandboxStatusData } from '../../types/context';
15
15
  import type { SandboxWsStatus } from '../../types/sandbox';
16
16
  type RuntimeStatus = SandboxStatusData | SandboxWsStatus;
@@ -58,6 +58,16 @@ export interface ChatBaseHeaderProps {
58
58
  chatViewMode?: ChatViewMode;
59
59
  /** Callback when view mode changes */
60
60
  onChatViewModeChange?: (mode: ChatViewMode) => void;
61
+ /** Show the companion-surface segmented control (None / Notebook / Document). */
62
+ showEphemeralSurfaceControl?: boolean;
63
+ /** Whether the Notebook option is available in the surface control. */
64
+ enableEphemeralNotebookOption?: boolean;
65
+ /** Whether the Document option is available in the surface control. */
66
+ enableEphemeralDocumentOption?: boolean;
67
+ /** Current companion-surface mode. */
68
+ ephemeralSurfaceMode?: EphemeralSurfaceMode;
69
+ /** Callback fired when the user changes the companion-surface mode. */
70
+ onEphemeralSurfaceModeChange?: (mode: EphemeralSurfaceMode) => void;
61
71
  }
62
- export declare function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, headerActions, showInformation, onInformationClick, padding, kernelIndicatorState, runtimeStatus, kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, headerButtons, messageCount, onNewChat, onClear, chatViewMode, onChatViewModeChange, }: ChatBaseHeaderProps): import("react/jsx-runtime").JSX.Element;
72
+ export declare function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, headerActions, showInformation, onInformationClick, padding, kernelIndicatorState, runtimeStatus, kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, headerButtons, messageCount, onNewChat, onClear, chatViewMode, onChatViewModeChange, showEphemeralSurfaceControl, enableEphemeralNotebookOption, enableEphemeralDocumentOption, ephemeralSurfaceMode, onEphemeralSurfaceModeChange, }: ChatBaseHeaderProps): import("react/jsx-runtime").JSX.Element;
63
73
  export {};
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Heading, IconButton, Text, Truncate } from '@primer/react';
2
+ import { Heading, IconButton, Text, Tooltip, Truncate } from '@primer/react';
3
3
  import { Box } from '@datalayer/primer-addons';
4
4
  import { KernelIndicator } from '@datalayer/jupyter-react';
5
- import { PlusIcon, TrashIcon, GearIcon, CommentDiscussionIcon, DeviceMobileIcon, SidebarExpandIcon, InfoIcon, } from '@primer/octicons-react';
5
+ import { PlusIcon, TrashIcon, GearIcon, CommentDiscussionIcon, DeviceMobileIcon, SidebarExpandIcon, InfoIcon, RowsIcon, FileIcon, CircleSlashIcon, } from '@primer/octicons-react';
6
6
  import { AiAgentIcon } from '@datalayer/icons-react';
7
7
  export function toRuntimeExecutionState(runtimeStatus) {
8
8
  if (!runtimeStatus) {
@@ -29,7 +29,7 @@ export function toRuntimeExecutionState(runtimeStatus) {
29
29
  // ---------------------------------------------------------------------------
30
30
  // Component
31
31
  // ---------------------------------------------------------------------------
32
- export function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, headerActions, showInformation, onInformationClick, padding, kernelIndicatorState, runtimeStatus, kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, headerButtons, messageCount, onNewChat, onClear, chatViewMode, onChatViewModeChange, }) {
32
+ export function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, headerActions, showInformation, onInformationClick, padding, kernelIndicatorState, runtimeStatus, kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, headerButtons, messageCount, onNewChat, onClear, chatViewMode, onChatViewModeChange, showEphemeralSurfaceControl = false, enableEphemeralNotebookOption = false, enableEphemeralDocumentOption = false, ephemeralSurfaceMode = 'none', onEphemeralSurfaceModeChange, }) {
33
33
  const effectiveIndicatorState = kernelIndicatorState ?? toRuntimeExecutionState(runtimeStatus);
34
34
  return (_jsx(Box, { sx: {
35
35
  display: 'flex',
@@ -47,7 +47,7 @@ export function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, head
47
47
  gap: 2,
48
48
  minWidth: 0,
49
49
  flex: '1 1 auto',
50
- }, children: [brandIcon || _jsx(AiAgentIcon, { colored: true, size: 20 }), (title || subtitle) && (_jsxs(Box, { sx: {
50
+ }, children: [brandIcon || _jsx(AiAgentIcon, { colored: true, size: 20 }), kernel ? (_jsx(KernelIndicator, { kernel: kernel, environmentName: kernelEnvironmentName, cpu: kernelCpu, memory: kernelMemory, gpu: kernelGpu, position: "s", bordered: false })) : (_jsx(KernelIndicator, { state: effectiveIndicatorState ?? 'undefined', environmentName: kernelEnvironmentName, cpu: kernelCpu, memory: kernelMemory, gpu: kernelGpu, position: "s", bordered: false })), (title || subtitle) && (_jsxs(Box, { sx: {
51
51
  display: 'flex',
52
52
  flexDirection: 'column',
53
53
  minWidth: 0,
@@ -62,7 +62,60 @@ export function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, head
62
62
  color: 'fg.muted',
63
63
  minWidth: 0,
64
64
  maxWidth: '100%',
65
- }, children: _jsx(Truncate, { title: subtitle, maxWidth: "40ch", children: subtitle }) }))] })), headerContent, showInformation && (_jsx(IconButton, { icon: InfoIcon, "aria-label": "Information", variant: "invisible", size: "small", onClick: onInformationClick }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flexShrink: 0 }, children: [kernel ? (_jsx(KernelIndicator, { kernel: kernel, environmentName: kernelEnvironmentName, cpu: kernelCpu, memory: kernelMemory, gpu: kernelGpu, position: "sw", bordered: false })) : (_jsx(KernelIndicator, { state: effectiveIndicatorState ?? 'undefined', environmentName: kernelEnvironmentName, cpu: kernelCpu, memory: kernelMemory, gpu: kernelGpu, position: "sw", bordered: false })), headerButtons?.showNewChat && (_jsx(IconButton, { icon: PlusIcon, "aria-label": "New chat", variant: "invisible", size: "small", onClick: onNewChat })), headerButtons?.showClear && messageCount > 0 && (_jsx(IconButton, { icon: TrashIcon, "aria-label": "Clear messages", variant: "invisible", size: "small", onClick: onClear })), headerButtons?.showSettings && (_jsx(IconButton, { icon: GearIcon, "aria-label": "Settings", variant: "invisible", size: "small", onClick: headerButtons.onSettings })), chatViewMode && onChatViewModeChange && (_jsx(Box, { sx: {
65
+ }, children: _jsx(Truncate, { title: subtitle, maxWidth: "40ch", children: subtitle }) }))] })), headerContent, showInformation && (_jsx(IconButton, { icon: InfoIcon, "aria-label": "Information", variant: "invisible", size: "small", onClick: onInformationClick }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flexShrink: 0 }, children: [headerButtons?.showNewChat && (_jsx(IconButton, { icon: PlusIcon, "aria-label": "New chat", variant: "invisible", size: "small", onClick: onNewChat })), headerButtons?.showClear && messageCount > 0 && (_jsx(IconButton, { icon: TrashIcon, "aria-label": "Clear messages", variant: "invisible", size: "small", onClick: onClear })), headerButtons?.showSettings && (_jsx(IconButton, { icon: GearIcon, "aria-label": "Settings", variant: "invisible", size: "small", onClick: headerButtons.onSettings })), showEphemeralSurfaceControl && (_jsx(Box, { sx: {
66
+ display: 'inline-flex',
67
+ alignItems: 'center',
68
+ bg: 'neutral.muted',
69
+ borderRadius: '6px',
70
+ p: '2px',
71
+ gap: '1px',
72
+ }, children: [
73
+ {
74
+ mode: 'none',
75
+ icon: CircleSlashIcon,
76
+ label: 'Chat only',
77
+ enabled: true,
78
+ },
79
+ {
80
+ mode: 'notebook',
81
+ icon: RowsIcon,
82
+ label: 'Notebook',
83
+ enabled: enableEphemeralNotebookOption,
84
+ },
85
+ {
86
+ mode: 'document',
87
+ icon: FileIcon,
88
+ label: 'Document',
89
+ enabled: enableEphemeralDocumentOption,
90
+ },
91
+ ]
92
+ .filter(({ enabled }) => enabled)
93
+ .map(({ mode, icon: ModeIcon, label }) => (_jsx(Tooltip, { text: label, direction: "n", children: _jsx(Box, { as: "button", "aria-label": label, onClick: () => onEphemeralSurfaceModeChange?.(mode), sx: {
94
+ display: 'inline-flex',
95
+ alignItems: 'center',
96
+ justifyContent: 'center',
97
+ width: 26,
98
+ height: 24,
99
+ borderRadius: '4px',
100
+ border: 'none',
101
+ cursor: 'pointer',
102
+ bg: ephemeralSurfaceMode === mode
103
+ ? 'canvas.default'
104
+ : 'transparent',
105
+ boxShadow: ephemeralSurfaceMode === mode
106
+ ? 'shadow.small'
107
+ : 'none',
108
+ color: ephemeralSurfaceMode === mode
109
+ ? 'fg.default'
110
+ : 'fg.muted',
111
+ transition: 'all 0.15s ease',
112
+ '&:hover': {
113
+ color: 'fg.default',
114
+ bg: ephemeralSurfaceMode === mode
115
+ ? 'canvas.default'
116
+ : 'neutral.subtle',
117
+ },
118
+ }, children: _jsx(ModeIcon, { size: 14 }) }) }, mode))) })), chatViewMode && onChatViewModeChange && (_jsx(Box, { sx: {
66
119
  display: 'inline-flex',
67
120
  alignItems: 'center',
68
121
  bg: 'neutral.muted',
@@ -85,24 +138,26 @@ export function ChatBaseHeader({ title, subtitle, brandIcon, headerContent, head
85
138
  icon: SidebarExpandIcon,
86
139
  label: 'Sidebar panel',
87
140
  },
88
- ].map(({ mode, icon: ModeIcon, label }) => (_jsx(Box, { as: "button", "aria-label": label, title: label, onClick: () => onChatViewModeChange(mode), sx: {
89
- display: 'inline-flex',
90
- alignItems: 'center',
91
- justifyContent: 'center',
92
- width: 26,
93
- height: 24,
94
- borderRadius: '4px',
95
- border: 'none',
96
- cursor: 'pointer',
97
- bg: chatViewMode === mode ? 'canvas.default' : 'transparent',
98
- boxShadow: chatViewMode === mode ? 'shadow.small' : 'none',
99
- color: chatViewMode === mode ? 'fg.default' : 'fg.muted',
100
- transition: 'all 0.15s ease',
101
- '&:hover': {
102
- color: 'fg.default',
141
+ ].map(({ mode, icon: ModeIcon, label }) => (_jsx(Tooltip, { text: label, direction: "n", children: _jsx(Box, { as: "button", "aria-label": label, onClick: () => onChatViewModeChange(mode), sx: {
142
+ display: 'inline-flex',
143
+ alignItems: 'center',
144
+ justifyContent: 'center',
145
+ width: 26,
146
+ height: 24,
147
+ borderRadius: '4px',
148
+ border: 'none',
149
+ cursor: 'pointer',
103
150
  bg: chatViewMode === mode
104
151
  ? 'canvas.default'
105
- : 'neutral.subtle',
106
- },
107
- }, children: _jsx(ModeIcon, { size: 14 }) }, mode))) })), headerActions] })] }) }));
152
+ : 'transparent',
153
+ boxShadow: chatViewMode === mode ? 'shadow.small' : 'none',
154
+ color: chatViewMode === mode ? 'fg.default' : 'fg.muted',
155
+ transition: 'all 0.15s ease',
156
+ '&:hover': {
157
+ color: 'fg.default',
158
+ bg: chatViewMode === mode
159
+ ? 'canvas.default'
160
+ : 'neutral.subtle',
161
+ },
162
+ }, children: _jsx(ModeIcon, { size: 14 }) }) }, mode))) })), headerActions] })] }) }));
108
163
  }
@@ -64,3 +64,4 @@ export { ToolApprovalBanner, type ToolApprovalBannerProps, type PendingApproval,
64
64
  export { Chat, type ChatProps } from './Chat';
65
65
  export { ChatFloating, type ChatFloatingProps } from './ChatFloating';
66
66
  export { ChatInline, type ChatInlineProps, type ChatInlineProtocolConfig, } from './ChatInline';
67
+ export { AgentRuntimeChat, type AgentRuntimeChatProps, } from '../agents/AgentRuntimeChat';
package/lib/chat/index.js CHANGED
@@ -72,3 +72,5 @@ export { ToolApprovalBanner, } from './tools/ToolApprovalBanner';
72
72
  export { Chat } from './Chat';
73
73
  export { ChatFloating } from './ChatFloating';
74
74
  export { ChatInline, } from './ChatInline';
75
+ // Generic full-page chat surface for a live agent runtime (with launching state)
76
+ export { AgentRuntimeChat, } from '../agents/AgentRuntimeChat';
@@ -0,0 +1,24 @@
1
+ import type { INotebookContent } from '@jupyterlab/nbformat';
2
+ import type { EphemeralNotebookToolbarComponent } from '../../types/chat';
3
+ export interface EphemeralNotebookProps {
4
+ /**
5
+ * Notebook identifier. Must match the id passed to `useNotebookTools` so the
6
+ * agent's notebook frontend tools operate on this notebook instance.
7
+ */
8
+ notebookId: string;
9
+ /** Preferred runtime pod name to bind the notebook kernel to. */
10
+ runtimePodName?: string;
11
+ /** Left margin reserved for the cell sidebar (default 120). */
12
+ cellSidebarMargin?: number;
13
+ /** Optional persisted notebook model to restore when mounting. */
14
+ nbformat?: INotebookContent;
15
+ /** Callback fired when the notebook model changes. */
16
+ onNbformatChange?: (content: INotebookContent) => void;
17
+ /** Optional toolbar component override. */
18
+ toolbarComponent?: EphemeralNotebookToolbarComponent;
19
+ }
20
+ /**
21
+ * Renders an in-memory notebook backed by a sandbox kernel.
22
+ */
23
+ export declare function EphemeralNotebook({ notebookId, runtimePodName, cellSidebarMargin, nbformat, onNbformatChange, toolbarComponent, }: EphemeralNotebookProps): import("react/jsx-runtime").JSX.Element;
24
+ export default EphemeralNotebook;