@datalayer/agent-runtimes 1.0.28 → 1.3.10

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 (776) hide show
  1. package/lib/AgentDocument.js +5 -22
  2. package/lib/AgentNode.d.ts +1 -1
  3. package/lib/AgentNode.js +193 -23
  4. package/lib/AgentNotebook.js +1 -1
  5. package/lib/App.d.ts +1 -1
  6. package/lib/AppExamples2.d.ts +1 -1
  7. package/lib/agent-node/AgentNodeGallery.d.ts +14 -1
  8. package/lib/agent-node/AgentNodeGallery.js +19 -15
  9. package/lib/agent-node/themeStore.js +7 -6
  10. package/lib/agents/AgentDetails.d.ts +8 -2
  11. package/lib/agents/AgentDetails.js +41 -11
  12. package/lib/agents/AgentRuntimeChat.d.ts +3 -3
  13. package/lib/agents/AgentRuntimeChat.js +15 -15
  14. package/lib/api/agents.d.ts +10 -10
  15. package/lib/api/agents.js +15 -15
  16. package/lib/api/checkpoints.d.ts +40 -0
  17. package/lib/api/checkpoints.js +75 -0
  18. package/lib/api/index.d.ts +1 -0
  19. package/lib/api/index.js +18 -5
  20. package/lib/api/notifications.d.ts +21 -6
  21. package/lib/api/notifications.js +32 -14
  22. package/lib/api/runtimes/environments.d.ts +385 -4
  23. package/lib/api/runtimes/environments.js +610 -9
  24. package/lib/api/runtimes/runtimes.d.ts +19 -19
  25. package/lib/api/runtimes/runtimes.js +47 -46
  26. package/lib/api/spacer/notebooks.js +1 -1
  27. package/lib/chat/Chat.d.ts +16 -4
  28. package/lib/chat/Chat.js +18 -5
  29. package/lib/chat/ChatFloating.d.ts +13 -2
  30. package/lib/chat/ChatFloating.js +192 -117
  31. package/lib/chat/ChatInline.d.ts +15 -0
  32. package/lib/chat/ChatInline.js +0 -18
  33. package/lib/chat/ChatPopupStandalone.d.ts +1 -1
  34. package/lib/chat/ChatSidebar.d.ts +14 -2
  35. package/lib/chat/ChatSidebar.js +1 -1
  36. package/lib/chat/ChatStandalone.d.ts +1 -1
  37. package/lib/chat/EphemeralSurfaceControl.d.ts +30 -0
  38. package/lib/chat/EphemeralSurfaceControl.js +55 -0
  39. package/lib/chat/base/ChatAvailability.d.ts +34 -0
  40. package/lib/chat/base/ChatAvailability.js +18 -0
  41. package/lib/chat/base/ChatBase.d.ts +2 -1
  42. package/lib/chat/base/ChatBase.js +657 -28
  43. package/lib/chat/display/EmptyState.d.ts +15 -1
  44. package/lib/chat/display/EmptyState.js +78 -12
  45. package/lib/chat/display/FloatingBrandButton.d.ts +1 -1
  46. package/lib/chat/display/PoweredByTag.d.ts +1 -1
  47. package/lib/chat/display/groupSuggestions.d.ts +21 -0
  48. package/lib/chat/display/groupSuggestions.js +18 -0
  49. package/lib/chat/document/EphemeralDocument.d.ts +70 -6
  50. package/lib/chat/document/EphemeralDocument.js +154 -52
  51. package/lib/chat/header/ChatHeader.d.ts +1 -1
  52. package/lib/chat/header/ChatHeaderBase.d.ts +10 -1
  53. package/lib/chat/header/ChatHeaderBase.js +67 -96
  54. package/lib/chat/index.d.ts +4 -1
  55. package/lib/chat/index.js +8 -1
  56. package/lib/chat/indicators/McpStatusIndicator.d.ts +1 -1
  57. package/lib/chat/indicators/SandboxStatusIndicator.d.ts +1 -1
  58. package/lib/chat/indicators/SandboxStatusIndicator.js +1 -1
  59. package/lib/chat/indicators/SkillsStatusIndicator.d.ts +1 -1
  60. package/lib/chat/messages/ChatMessageList.d.ts +22 -1
  61. package/lib/chat/messages/ChatMessageList.js +370 -166
  62. package/lib/chat/messages/ChatMessages.d.ts +1 -1
  63. package/lib/chat/messages/NotebookToolSurfaces.d.ts +68 -0
  64. package/lib/chat/messages/NotebookToolSurfaces.js +302 -0
  65. package/lib/chat/messages/TurnFooter.d.ts +42 -0
  66. package/lib/chat/messages/TurnFooter.js +75 -0
  67. package/lib/chat/messages/assistantMarkdown.d.ts +22 -0
  68. package/lib/chat/messages/assistantMarkdown.js +56 -0
  69. package/lib/chat/notebook/EphemeralNotebook.d.ts +67 -6
  70. package/lib/chat/notebook/EphemeralNotebook.js +194 -61
  71. package/lib/chat/parts/DynamicToolPart.d.ts +1 -1
  72. package/lib/chat/parts/MessagePart.d.ts +1 -1
  73. package/lib/chat/parts/ReasoningPart.d.ts +8 -1
  74. package/lib/chat/parts/TextPart.d.ts +1 -1
  75. package/lib/chat/parts/ToolPart.d.ts +8 -1
  76. package/lib/chat/prompt/FloatingCard.d.ts +26 -0
  77. package/lib/chat/prompt/FloatingCard.js +80 -0
  78. package/lib/chat/prompt/InputPrompt.d.ts +206 -53
  79. package/lib/chat/prompt/InputPrompt.js +161 -80
  80. package/lib/chat/prompt/InputPromptBase.d.ts +112 -0
  81. package/lib/chat/prompt/InputPromptBase.js +225 -0
  82. package/lib/chat/prompt/InputPromptLexical.d.ts +18 -1
  83. package/lib/chat/prompt/InputPromptLexical.js +227 -30
  84. package/lib/chat/prompt/InputPromptText.d.ts +10 -2
  85. package/lib/chat/prompt/InputPromptText.js +35 -3
  86. package/lib/chat/prompt/footer/BelowPromptFooter.d.ts +25 -0
  87. package/lib/chat/prompt/footer/BelowPromptFooter.js +12 -0
  88. package/lib/chat/prompt/footer/InPromptFooter.d.ts +35 -0
  89. package/lib/chat/prompt/footer/InPromptFooter.js +16 -0
  90. package/lib/chat/prompt/footer/index.d.ts +7 -0
  91. package/lib/chat/prompt/footer/index.js +11 -0
  92. package/lib/chat/prompt/header/BelowPromptHeader.d.ts +23 -0
  93. package/lib/chat/prompt/header/BelowPromptHeader.js +12 -0
  94. package/lib/chat/prompt/header/InPromptHeader.d.ts +31 -0
  95. package/lib/chat/prompt/header/InPromptHeader.js +14 -0
  96. package/lib/chat/prompt/header/index.d.ts +7 -0
  97. package/lib/chat/prompt/header/index.js +11 -0
  98. package/lib/chat/prompt/index.d.ts +8 -4
  99. package/lib/chat/prompt/index.js +15 -3
  100. package/lib/chat/prompt/menus/AgentsMenu.d.ts +14 -0
  101. package/lib/chat/prompt/menus/AgentsMenu.js +42 -0
  102. package/lib/chat/prompt/menus/InlineAgentsMenu.d.ts +22 -0
  103. package/lib/chat/prompt/menus/InlineAgentsMenu.js +24 -0
  104. package/lib/chat/prompt/menus/ModelSelector.d.ts +7 -0
  105. package/lib/chat/prompt/menus/ModelSelector.js +27 -0
  106. package/lib/chat/prompt/menus/SkillsMenu.d.ts +10 -0
  107. package/lib/chat/prompt/menus/SkillsMenu.js +75 -0
  108. package/lib/chat/prompt/menus/SuggestionsMenu.d.ts +13 -0
  109. package/lib/chat/prompt/menus/SuggestionsMenu.js +31 -0
  110. package/lib/chat/prompt/menus/ToolsMenu.d.ts +13 -0
  111. package/lib/chat/prompt/menus/ToolsMenu.js +103 -0
  112. package/lib/chat/prompt/menus/index.d.ts +15 -0
  113. package/lib/chat/prompt/menus/index.js +19 -0
  114. package/lib/chat/prompt/plugins/AgentMentionPlugin.d.ts +54 -0
  115. package/lib/chat/prompt/plugins/AgentMentionPlugin.js +370 -0
  116. package/lib/chat/prompt/plugins/CommandPlugin.d.ts +52 -0
  117. package/lib/chat/prompt/plugins/CommandPlugin.js +359 -0
  118. package/lib/chat/prompt/plugins/MentionChip.d.ts +15 -0
  119. package/lib/chat/prompt/plugins/MentionChip.js +24 -0
  120. package/lib/chat/prompt/plugins/MentionNode.d.ts +66 -0
  121. package/lib/chat/prompt/plugins/MentionNode.js +77 -0
  122. package/lib/chat/prompt/promptHistory.d.ts +52 -0
  123. package/lib/chat/prompt/promptHistory.js +123 -0
  124. package/lib/chat/prompt/stack.d.ts +81 -0
  125. package/lib/chat/prompt/stack.js +41 -0
  126. package/lib/chat/prompt/useTypingPlaceholder.d.ts +52 -0
  127. package/lib/chat/prompt/useTypingPlaceholder.js +180 -0
  128. package/lib/chat/tools/A2AAgentDialog.d.ts +60 -0
  129. package/lib/chat/tools/A2AAgentDialog.js +265 -0
  130. package/lib/chat/tools/ToolApprovalBanner.d.ts +1 -1
  131. package/lib/chat/tools/ToolApprovalDialog.d.ts +1 -1
  132. package/lib/chat/tools/ToolCallDisplay.d.ts +8 -1
  133. package/lib/chat/tools/index.d.ts +1 -0
  134. package/lib/chat/tools/index.js +1 -0
  135. package/lib/chat/usage/ContextPie.d.ts +17 -0
  136. package/lib/chat/usage/{TokenUsageBar.js → ContextPie.js} +20 -14
  137. package/lib/chat/useViewportDrag.d.ts +11 -0
  138. package/lib/chat/useViewportDrag.js +61 -0
  139. package/lib/chat/viewModes.d.ts +51 -0
  140. package/lib/chat/viewModes.js +57 -0
  141. package/lib/client/AgentRuntimesClient.d.ts +10 -9
  142. package/lib/client/AgentRuntimesClient.js +1 -1
  143. package/lib/client/AgentRuntimesClientContext.d.ts +1 -0
  144. package/lib/client/AgentsMixin.d.ts +12 -12
  145. package/lib/client/AgentsMixin.js +31 -31
  146. package/lib/client/IAgentRuntimesClient.d.ts +10 -10
  147. package/lib/client/SdkAgentRuntimesClient.d.ts +10 -10
  148. package/lib/client/SdkAgentRuntimesClient.js +10 -10
  149. package/lib/client/mixins/RuntimesMixin.d.ts +37 -10
  150. package/lib/client/mixins/RuntimesMixin.js +54 -21
  151. package/lib/components/a2ui/A2uiSurfaceComposed.d.ts +1 -1
  152. package/lib/components/agents/AgentSummary.d.ts +13 -0
  153. package/lib/components/agents/AgentSummary.js +21 -4
  154. package/lib/components/cards/NotificationEventCard.d.ts +1 -1
  155. package/lib/components/cards/OutputCard.d.ts +1 -1
  156. package/lib/components/cards/ToolApprovalCard.d.ts +2 -2
  157. package/lib/components/cards/ToolApprovalCard.js +1 -0
  158. package/lib/components/code-sandboxes/CodeSandboxCellVariables.d.ts +1 -0
  159. package/lib/components/code-sandboxes/CodeSandboxCellVariables.js +0 -4
  160. package/lib/components/code-sandboxes/CodeSandboxCellVariablesDialog.d.ts +1 -0
  161. package/lib/components/code-sandboxes/CodeSandboxCellVariablesDialog.js +0 -4
  162. package/lib/components/code-sandboxes/CodeSandboxEnvironmentSelect.d.ts +76 -0
  163. package/lib/components/code-sandboxes/CodeSandboxEnvironmentSelect.js +81 -0
  164. package/lib/components/code-sandboxes/CodeSandboxLauncher.d.ts +12 -0
  165. package/lib/components/code-sandboxes/CodeSandboxLauncher.js +132 -25
  166. package/lib/components/code-sandboxes/CodeSandboxNames.js +75 -29
  167. package/lib/components/code-sandboxes/CodeSandboxPicker.d.ts +14 -1
  168. package/lib/components/code-sandboxes/CodeSandboxPicker.js +226 -45
  169. package/lib/components/code-sandboxes/CodeSandboxPickerCell.d.ts +1 -0
  170. package/lib/components/code-sandboxes/CodeSandboxPickerCell.js +0 -4
  171. package/lib/components/code-sandboxes/CodeSandboxReservationControl.d.ts +1 -0
  172. package/lib/components/code-sandboxes/CodeSandboxReservationControl.js +5 -7
  173. package/lib/components/code-sandboxes/CodeSandboxTransfer.d.ts +5 -0
  174. package/lib/components/code-sandboxes/CodeSandboxUtils.d.ts +16 -1
  175. package/lib/components/code-sandboxes/CodeSandboxUtils.js +69 -12
  176. package/lib/components/code-sandboxes/NewCodeSandboxControls.d.ts +21 -15
  177. package/lib/components/code-sandboxes/NewCodeSandboxControls.js +28 -51
  178. package/lib/components/code-sandboxes/codeSandboxAllowance.d.ts +33 -0
  179. package/lib/components/code-sandboxes/codeSandboxAllowance.js +37 -0
  180. package/lib/components/code-sandboxes/codeSandboxEnvironments.d.ts +86 -0
  181. package/lib/components/code-sandboxes/codeSandboxEnvironments.js +147 -0
  182. package/lib/components/code-sandboxes/codeSandboxProviders.d.ts +29 -0
  183. package/lib/components/code-sandboxes/codeSandboxProviders.js +90 -0
  184. package/lib/components/code-sandboxes/index.d.ts +3 -0
  185. package/lib/components/code-sandboxes/index.js +3 -0
  186. package/lib/components/context/SpaceSelect.d.ts +1 -1
  187. package/lib/components/flashes/FlashDisclaimer.d.ts +1 -1
  188. package/lib/components/icons/ArtifactIcon.d.ts +1 -0
  189. package/lib/components/nbgrader/NbGradesDetails.d.ts +1 -1
  190. package/lib/components/progress/CreditsIndicator.d.ts +1 -0
  191. package/lib/components/progress/CreditsIndicator.js +0 -4
  192. package/lib/components/scheduler/ScheduleMenu.d.ts +1 -1
  193. package/lib/components/snapshots/SandboxSnapshotMenu.d.ts +3 -2
  194. package/lib/components/snapshots/SandboxSnapshotMenu.js +11 -15
  195. package/lib/components/snippets/SnippetDialog.d.ts +1 -0
  196. package/lib/components/snippets/SnippetDialog.js +0 -4
  197. package/lib/components/specs/SpecPayloadPreview.d.ts +34 -0
  198. package/lib/components/specs/SpecPayloadPreview.js +102 -0
  199. package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
  200. package/lib/context/ContextDistribution.d.ts +1 -1
  201. package/lib/context/ContextInspector.d.ts +2 -1
  202. package/lib/context/ContextPanel.d.ts +1 -1
  203. package/lib/context/ContextUsage.d.ts +1 -1
  204. package/lib/context/CostTracker.d.ts +1 -1
  205. package/lib/context/CostUsageChart.d.ts +1 -1
  206. package/lib/context/CostUsageChart.js +4 -4
  207. package/lib/context/MessageHistory.d.ts +3 -2
  208. package/lib/context/TokenUsageChart.d.ts +1 -1
  209. package/lib/context/TokenUsageChart.js +4 -4
  210. package/lib/examples/A2UiAgentExample.js +15 -6
  211. package/lib/examples/A2UiComponentsGalleryExample.d.ts +10 -0
  212. package/lib/examples/A2UiComponentsGalleryExample.js +24 -855
  213. package/lib/examples/A2UiContactCardExample.d.ts +10 -0
  214. package/lib/examples/A2UiContactCardExample.js +23 -170
  215. package/lib/examples/A2UiJupyterOutputExample.d.ts +3 -0
  216. package/lib/examples/A2UiJupyterOutputExample.js +792 -0
  217. package/lib/examples/A2UiRestaurantExample.d.ts +10 -0
  218. package/lib/examples/A2UiRestaurantExample.js +24 -179
  219. package/lib/examples/A2UiViewerExample.d.ts +10 -0
  220. package/lib/examples/A2UiViewerExample.js +24 -378
  221. package/lib/examples/AgUiAgenticExample.js +2 -4
  222. package/lib/examples/AgUiBackendToolRenderingExample.js +3 -5
  223. package/lib/examples/AgUiHaikuGenUiExample.js +2 -4
  224. package/lib/examples/AgUiHumanInTheLoopExample.js +2 -4
  225. package/lib/examples/AgUiSharedStateExample.js +2 -4
  226. package/lib/examples/AgUiToolsBasedGenUiExample.js +2 -4
  227. package/lib/examples/AgentA2AExample.d.ts +17 -0
  228. package/lib/examples/AgentA2AExample.js +56 -0
  229. package/lib/examples/AgentCheckpointsExample.d.ts +9 -10
  230. package/lib/examples/AgentCheckpointsExample.js +72 -54
  231. package/lib/examples/AgentCodeSandboxExample.d.ts +7 -7
  232. package/lib/examples/AgentCodeSandboxExample.js +93 -303
  233. package/lib/examples/AgentCodeSandboxesExample.d.ts +10 -0
  234. package/lib/examples/AgentCodeSandboxesExample.js +56 -162
  235. package/lib/examples/AgentCodemodeExample.d.ts +7 -2
  236. package/lib/examples/AgentCodemodeExample.js +60 -125
  237. package/lib/examples/AgentCompactionExample.js +19 -135
  238. package/lib/examples/AgentEvalsExample.js +34 -66
  239. package/lib/examples/AgentGuardrailsExample.js +64 -112
  240. package/lib/examples/AgentHooksExample.d.ts +11 -0
  241. package/lib/examples/AgentHooksExample.js +30 -67
  242. package/lib/examples/AgentInferenceProviderExample.js +8 -32
  243. package/lib/examples/AgentLoopExample.d.ts +4 -2
  244. package/lib/examples/AgentLoopExample.js +45 -93
  245. package/lib/examples/AgentMCPExample.js +30 -79
  246. package/lib/examples/AgentMemoryExample.js +21 -64
  247. package/lib/examples/AgentMonitoringExample.js +33 -94
  248. package/lib/examples/AgentNotificationsExample.js +56 -95
  249. package/lib/examples/AgentOtelExample.js +35 -88
  250. package/lib/examples/AgentOutputsExample.d.ts +2 -1
  251. package/lib/examples/AgentOutputsExample.js +16 -137
  252. package/lib/examples/AgentParametersExample.js +7 -17
  253. package/lib/examples/AgentSkillsExample.js +40 -154
  254. package/lib/examples/AgentSubagentsExample.d.ts +7 -6
  255. package/lib/examples/AgentSubagentsExample.js +80 -191
  256. package/lib/examples/AgentToolApprovalsExample.js +35 -91
  257. package/lib/examples/AgentTriggersExample.js +43 -59
  258. package/lib/examples/AgentspecsExample.js +7 -7
  259. package/lib/examples/CellExample.d.ts +1 -1
  260. package/lib/examples/ChatExample.d.ts +12 -5
  261. package/lib/examples/ChatExample.js +38 -13
  262. package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
  263. package/lib/examples/CopilotKitLexicalExample.js +4 -41
  264. package/lib/examples/CopilotKitNotebookExample.d.ts +10 -0
  265. package/lib/examples/CopilotKitNotebookExample.js +2 -14
  266. package/lib/examples/DecksAgent.d.ts +21 -0
  267. package/lib/examples/DecksAgent.js +23 -0
  268. package/lib/examples/DocumentPageAgent.d.ts +19 -0
  269. package/lib/examples/DocumentPageAgent.js +15 -0
  270. package/lib/examples/Lexical2Example.d.ts +2 -2
  271. package/lib/examples/Lexical2Example.js +17 -38
  272. package/lib/examples/LexicalAgentExample.d.ts +2 -1
  273. package/lib/examples/LexicalAgentExample.js +29 -102
  274. package/lib/examples/LexicalAgentSidebarExample.d.ts +16 -5
  275. package/lib/examples/LexicalAgentSidebarExample.js +99 -131
  276. package/lib/examples/LoopShellExample.d.ts +38 -0
  277. package/lib/examples/LoopShellExample.js +68 -0
  278. package/lib/examples/LoopWorkspaceEmbed.d.ts +50 -0
  279. package/lib/examples/LoopWorkspaceEmbed.js +73 -0
  280. package/lib/examples/LoopWorkspaceExample.d.ts +150 -0
  281. package/lib/examples/LoopWorkspaceExample.js +151 -0
  282. package/lib/examples/NotebookAgentExample.d.ts +13 -0
  283. package/lib/examples/NotebookAgentExample.js +36 -86
  284. package/lib/examples/NotebookAgentSidebarExample.d.ts +10 -4
  285. package/lib/examples/NotebookAgentSidebarExample.js +39 -83
  286. package/lib/examples/NotebookCollaborationExample.d.ts +1 -1
  287. package/lib/examples/NotebookCollaborationExample.js +108 -20
  288. package/lib/examples/NotebookExample.d.ts +1 -1
  289. package/lib/examples/NotebookExample.js +20 -10
  290. package/lib/examples/NotebookPageAgent.d.ts +23 -0
  291. package/lib/examples/NotebookPageAgent.js +17 -0
  292. package/lib/examples/components/ExampleWrapper.d.ts +5 -0
  293. package/lib/examples/components/ExampleWrapper.js +36 -28
  294. package/lib/examples/components/LexicalEditor.d.ts +1 -1
  295. package/lib/examples/components/LexicalEditor.js +4 -24
  296. package/lib/examples/components/haiku/HaikuDisplay.d.ts +1 -1
  297. package/lib/examples/components/haiku/InlineHaikuCard.d.ts +1 -1
  298. package/lib/examples/components/weather/InlineWeatherCard.d.ts +1 -1
  299. package/lib/examples/example-selector.js +26 -6
  300. package/lib/examples/hooks/useCreateAgentOnce.d.ts +41 -0
  301. package/lib/examples/hooks/useCreateAgentOnce.js +51 -0
  302. package/lib/examples/hooks/useExampleAgentProtocol.d.ts +35 -0
  303. package/lib/examples/hooks/useExampleAgentProtocol.js +63 -0
  304. package/lib/examples/hooks/useExampleAgentRuntime.d.ts +16 -16
  305. package/lib/examples/hooks/useExampleAgentRuntime.js +26 -25
  306. package/lib/examples/hooks/useExampleAgentRuntimes.js +45 -61
  307. package/lib/examples/hooks/useExampleJupyterAgent.d.ts +91 -0
  308. package/lib/examples/hooks/useExampleJupyterAgent.js +151 -0
  309. package/lib/examples/index.d.ts +4 -0
  310. package/lib/examples/index.js +6 -0
  311. package/lib/examples/lexical/editorConfig.d.ts +2 -75
  312. package/lib/examples/lexical/editorConfig.js +26 -48
  313. package/lib/examples/lexical/lexical-theme.css +65 -47
  314. package/lib/examples/main.js +450 -322
  315. package/lib/examples/scenes/A2UiComponentsGalleryScene.d.ts +3 -0
  316. package/lib/examples/scenes/A2UiComponentsGalleryScene.js +872 -0
  317. package/lib/examples/scenes/A2UiContactCardScene.d.ts +3 -0
  318. package/lib/examples/scenes/A2UiContactCardScene.js +188 -0
  319. package/lib/examples/scenes/A2UiRestaurantScene.d.ts +3 -0
  320. package/lib/examples/scenes/A2UiRestaurantScene.js +196 -0
  321. package/lib/examples/scenes/A2UiViewerScene.d.ts +3 -0
  322. package/lib/examples/scenes/A2UiViewerScene.js +395 -0
  323. package/lib/examples/utils/agentSummaryStore.d.ts +7 -1
  324. package/lib/examples/utils/agents/earthquake-detector.ipynb.json +1 -1
  325. package/lib/examples/utils/agents/earthquake-detector.lexical.json +1 -1
  326. package/lib/examples/utils/agents/sales-forecaster.ipynb.json +1 -1
  327. package/lib/examples/utils/agents/sales-forecaster.lexical.json +1 -1
  328. package/lib/examples/utils/agents/social-post-generator.ipynb.json +1 -1
  329. package/lib/examples/utils/agents/social-post-generator.lexical.json +1 -1
  330. package/lib/examples/utils/exampleSurfaces.d.ts +31 -0
  331. package/lib/examples/utils/exampleSurfaces.js +38 -0
  332. package/lib/examples/utils/jupyterSandboxUrl.d.ts +27 -0
  333. package/lib/examples/utils/jupyterSandboxUrl.js +55 -0
  334. package/lib/examples/utils/localUrl.d.ts +2 -0
  335. package/lib/examples/utils/localUrl.js +49 -0
  336. package/lib/examples/utils/notebookToolbarItems.d.ts +46 -0
  337. package/lib/examples/utils/notebookToolbarItems.js +129 -0
  338. package/lib/examples/utils/runtimeTargetStore.d.ts +40 -1
  339. package/lib/examples/utils/runtimeTargetStore.js +82 -1
  340. package/lib/examples/utils/themedProvider.d.ts +7 -0
  341. package/lib/examples/utils/themedProvider.js +57 -4
  342. package/lib/examples/utils/useExampleAgentRuntimesUrl.js +30 -5
  343. package/lib/examples/utils/waitForAgent.d.ts +23 -0
  344. package/lib/examples/utils/waitForAgent.js +24 -0
  345. package/lib/examples2/CellExample.d.ts +1 -1
  346. package/lib/examples2/DatalayerNotebookExample.d.ts +1 -1
  347. package/lib/examples2/NotebookExample.d.ts +1 -1
  348. package/lib/examples2/NotebookMutationsKernel.d.ts +1 -1
  349. package/lib/examples2/NotebookMutationsServiceManager.d.ts +1 -1
  350. package/lib/examples2/main.js +24 -4
  351. package/lib/extensions/A2UIExtension.d.ts +1 -1
  352. package/lib/hooks/index.d.ts +8 -5
  353. package/lib/hooks/index.js +20 -5
  354. package/lib/hooks/useAgentRuntimes.d.ts +49 -22
  355. package/lib/hooks/useAgentRuntimes.js +214 -90
  356. package/lib/hooks/useAgentsCatalog.js +32 -4
  357. package/lib/hooks/useBrowserAgent.d.ts +26 -0
  358. package/lib/hooks/useBrowserAgent.js +75 -0
  359. package/lib/hooks/useBrowserInference.d.ts +27 -0
  360. package/lib/hooks/useBrowserInference.js +67 -0
  361. package/lib/hooks/useCheckpoints.d.ts +8 -17
  362. package/lib/hooks/useCheckpoints.js +25 -59
  363. package/lib/hooks/useConfig.d.ts +1 -1
  364. package/lib/hooks/useConfig.js +5 -1
  365. package/lib/hooks/useContextSnapshot.d.ts +18 -7
  366. package/lib/hooks/useContextSnapshot.js +14 -10
  367. package/lib/hooks/useNotifications.d.ts +11 -11
  368. package/lib/hooks/useNotifications.js +1 -1
  369. package/lib/hooks/useProjects.d.ts +7 -19
  370. package/lib/hooks/useProjects.js +5 -5
  371. package/lib/hooks/useSkills.d.ts +0 -1
  372. package/lib/hooks/useSkills.js +6 -2
  373. package/lib/hooks/useToolApprovals.d.ts +8 -8
  374. package/lib/hooks/useToolApprovals.js +3 -3
  375. package/lib/identity/AgentIdentity.d.ts +9 -2
  376. package/lib/identity/index.d.ts +1 -1
  377. package/lib/identity/index.js +1 -1
  378. package/lib/identity/types.d.ts +1 -1
  379. package/lib/identity/types.js +1 -1
  380. package/lib/index.d.ts +1 -0
  381. package/lib/index.js +4 -0
  382. package/lib/jupyter/index.d.ts +2 -1
  383. package/lib/jupyter/index.js +2 -1
  384. package/lib/jupyter/serverExecution.d.ts +78 -0
  385. package/lib/jupyter/serverExecution.js +258 -0
  386. package/lib/jupyter/useResumeServerExecutions.d.ts +11 -0
  387. package/lib/jupyter/useResumeServerExecutions.js +64 -0
  388. package/lib/lexical/ChatInlinePlugin.d.ts +33 -0
  389. package/lib/lexical/ChatInlinePlugin.js +0 -36
  390. package/lib/loop/core/focusRequests.d.ts +10 -0
  391. package/lib/loop/core/focusRequests.js +46 -0
  392. package/lib/loop/core/index.d.ts +894 -0
  393. package/lib/loop/core/index.js +264 -0
  394. package/lib/loop/core/promptStore.d.ts +44 -0
  395. package/lib/loop/core/promptStore.js +63 -0
  396. package/lib/loop/core/surfaceRequests.d.ts +33 -0
  397. package/lib/loop/core/surfaceRequests.js +29 -0
  398. package/lib/loop/core/toolbar.d.ts +28 -0
  399. package/lib/loop/core/toolbar.js +59 -0
  400. package/lib/loop/embed/LoopEmbed.d.ts +57 -0
  401. package/lib/loop/embed/LoopEmbed.js +118 -0
  402. package/lib/loop/extensions.d.ts +10 -0
  403. package/lib/loop/extensions.js +49 -0
  404. package/lib/loop/index.d.ts +68 -0
  405. package/lib/loop/index.js +87 -0
  406. package/lib/loop/plugins/a2a-sidebar/A2ASidebar.d.ts +48 -0
  407. package/lib/loop/plugins/a2a-sidebar/A2ASidebar.js +190 -0
  408. package/lib/loop/plugins/a2a-sidebar/index.d.ts +5 -0
  409. package/lib/loop/plugins/a2a-sidebar/index.js +39 -0
  410. package/lib/loop/plugins/a2ui/A2uiView.d.ts +12 -0
  411. package/lib/loop/plugins/a2ui/A2uiView.js +97 -0
  412. package/lib/loop/plugins/a2ui/index.d.ts +3 -0
  413. package/lib/loop/plugins/a2ui/index.js +50 -0
  414. package/lib/loop/plugins/a2ui-scene/index.d.ts +36 -0
  415. package/lib/loop/plugins/a2ui-scene/index.js +28 -0
  416. package/lib/loop/plugins/agent-a2a/index.d.ts +3 -0
  417. package/lib/loop/plugins/agent-a2a/index.js +26 -0
  418. package/lib/loop/plugins/agent-a2ui/index.d.ts +3 -0
  419. package/lib/loop/plugins/agent-a2ui/index.js +42 -0
  420. package/lib/loop/plugins/agent-a2ui-jupyter-output/index.d.ts +3 -0
  421. package/lib/loop/plugins/agent-a2ui-jupyter-output/index.js +53 -0
  422. package/lib/loop/plugins/agent-capacity/index.d.ts +39 -0
  423. package/lib/loop/plugins/agent-capacity/index.js +52 -0
  424. package/lib/loop/plugins/agent-checkpoints/index.d.ts +3 -0
  425. package/lib/loop/plugins/agent-checkpoints/index.js +26 -0
  426. package/lib/loop/plugins/agent-code-sandbox/index.d.ts +3 -0
  427. package/lib/loop/plugins/agent-code-sandbox/index.js +24 -0
  428. package/lib/loop/plugins/agent-code-sandboxes/index.d.ts +13 -0
  429. package/lib/loop/plugins/agent-code-sandboxes/index.js +85 -0
  430. package/lib/loop/plugins/agent-codemode/index.d.ts +5 -0
  431. package/lib/loop/plugins/agent-codemode/index.js +41 -0
  432. package/lib/loop/plugins/agent-compaction/index.d.ts +10 -0
  433. package/lib/loop/plugins/agent-compaction/index.js +34 -0
  434. package/lib/loop/plugins/agent-evals/index.d.ts +3 -0
  435. package/lib/loop/plugins/agent-evals/index.js +25 -0
  436. package/lib/loop/plugins/agent-guardrails/index.d.ts +3 -0
  437. package/lib/loop/plugins/agent-guardrails/index.js +25 -0
  438. package/lib/loop/plugins/agent-hooks/index.d.ts +3 -0
  439. package/lib/loop/plugins/agent-hooks/index.js +28 -0
  440. package/lib/loop/plugins/agent-inference/index.d.ts +7 -0
  441. package/lib/loop/plugins/agent-inference/index.js +29 -0
  442. package/lib/loop/plugins/agent-mcp/index.d.ts +3 -0
  443. package/lib/loop/plugins/agent-mcp/index.js +25 -0
  444. package/lib/loop/plugins/agent-memory/index.d.ts +3 -0
  445. package/lib/loop/plugins/agent-memory/index.js +25 -0
  446. package/lib/loop/plugins/agent-monitoring/index.d.ts +3 -0
  447. package/lib/loop/plugins/agent-monitoring/index.js +25 -0
  448. package/lib/loop/plugins/agent-notifications/index.d.ts +3 -0
  449. package/lib/loop/plugins/agent-notifications/index.js +25 -0
  450. package/lib/loop/plugins/agent-otel/index.d.ts +3 -0
  451. package/lib/loop/plugins/agent-otel/index.js +25 -0
  452. package/lib/loop/plugins/agent-outputs/index.d.ts +3 -0
  453. package/lib/loop/plugins/agent-outputs/index.js +25 -0
  454. package/lib/loop/plugins/agent-parameters/index.d.ts +3 -0
  455. package/lib/loop/plugins/agent-parameters/index.js +25 -0
  456. package/lib/loop/plugins/agent-skills/index.d.ts +3 -0
  457. package/lib/loop/plugins/agent-skills/index.js +25 -0
  458. package/lib/loop/plugins/agent-subagents/index.d.ts +3 -0
  459. package/lib/loop/plugins/agent-subagents/index.js +25 -0
  460. package/lib/loop/plugins/agent-tool-approvals/index.d.ts +11 -0
  461. package/lib/loop/plugins/agent-tool-approvals/index.js +38 -0
  462. package/lib/loop/plugins/agent-triggers/index.d.ts +3 -0
  463. package/lib/loop/plugins/agent-triggers/index.js +26 -0
  464. package/lib/loop/plugins/agents/AgentSummaryPanel.d.ts +20 -0
  465. package/lib/loop/plugins/agents/AgentSummaryPanel.js +50 -0
  466. package/lib/loop/plugins/agents/AnonymousKeyBadge.d.ts +35 -0
  467. package/lib/loop/plugins/agents/AnonymousKeyBadge.js +53 -0
  468. package/lib/loop/plugins/agents/DatalayerAgentBridge.d.ts +24 -0
  469. package/lib/loop/plugins/agents/DatalayerAgentBridge.js +102 -0
  470. package/lib/loop/plugins/agents/DatalayerAgentMount.d.ts +18 -0
  471. package/lib/loop/plugins/agents/DatalayerAgentMount.js +12 -0
  472. package/lib/loop/plugins/agents/SandboxSelector.d.ts +18 -0
  473. package/lib/loop/plugins/agents/SandboxSelector.js +99 -0
  474. package/lib/loop/plugins/agents/SandboxStatusBridge.d.ts +19 -0
  475. package/lib/loop/plugins/agents/SandboxStatusBridge.js +23 -0
  476. package/lib/loop/plugins/agents/SandboxView.d.ts +11 -0
  477. package/lib/loop/plugins/agents/SandboxView.js +43 -0
  478. package/lib/loop/plugins/agents/TeamMemberPicker.d.ts +17 -0
  479. package/lib/loop/plugins/agents/TeamMemberPicker.js +60 -0
  480. package/lib/loop/plugins/agents/agentIcons.d.ts +23 -0
  481. package/lib/loop/plugins/agents/agentIcons.js +88 -0
  482. package/lib/loop/plugins/agents/browserService.d.ts +50 -0
  483. package/lib/loop/plugins/agents/browserService.js +233 -0
  484. package/lib/loop/plugins/agents/index.d.ts +13 -0
  485. package/lib/loop/plugins/agents/index.js +17 -0
  486. package/lib/loop/plugins/agents/plugin.d.ts +91 -0
  487. package/lib/loop/plugins/agents/plugin.js +201 -0
  488. package/lib/loop/plugins/agents/service.d.ts +99 -0
  489. package/lib/loop/plugins/agents/service.js +167 -0
  490. package/lib/loop/plugins/agents/specSubagents.d.ts +18 -0
  491. package/lib/loop/plugins/agents/specSubagents.js +33 -0
  492. package/lib/loop/plugins/agents/switchable.d.ts +107 -0
  493. package/lib/loop/plugins/agents/switchable.js +405 -0
  494. package/lib/loop/plugins/agents/team.d.ts +87 -0
  495. package/lib/loop/plugins/agents/team.js +143 -0
  496. package/lib/loop/plugins/agents/useSandboxService.d.ts +11 -0
  497. package/lib/loop/plugins/agents/useSandboxService.js +36 -0
  498. package/lib/loop/plugins/agents/useTeamSelection.d.ts +10 -0
  499. package/lib/loop/plugins/agents/useTeamSelection.js +27 -0
  500. package/lib/loop/plugins/agentspecs/AgentspecPicker.d.ts +15 -0
  501. package/lib/loop/plugins/agentspecs/AgentspecPicker.js +90 -0
  502. package/lib/loop/plugins/agentspecs/index.d.ts +6 -0
  503. package/lib/loop/plugins/agentspecs/index.js +63 -0
  504. package/lib/loop/plugins/chat/ChatView.d.ts +20 -0
  505. package/lib/loop/plugins/chat/ChatView.js +1670 -0
  506. package/lib/loop/plugins/chat/chatViewTools.d.ts +41 -0
  507. package/lib/loop/plugins/chat/chatViewTools.js +92 -0
  508. package/lib/loop/plugins/chat/index.d.ts +111 -0
  509. package/lib/loop/plugins/chat/index.js +143 -0
  510. package/lib/loop/plugins/chat/turnState.d.ts +41 -0
  511. package/lib/loop/plugins/chat/turnState.js +90 -0
  512. package/lib/loop/plugins/chat-extras/index.d.ts +14 -0
  513. package/lib/loop/plugins/chat-extras/index.js +51 -0
  514. package/lib/loop/plugins/chat-header/HeaderView.d.ts +13 -0
  515. package/lib/loop/plugins/chat-header/HeaderView.js +6 -0
  516. package/lib/loop/plugins/chat-header/index.d.ts +3 -0
  517. package/lib/loop/plugins/chat-header/index.js +21 -0
  518. package/lib/loop/plugins/chat-view/index.d.ts +10 -0
  519. package/lib/loop/plugins/chat-view/index.js +29 -0
  520. package/lib/loop/plugins/checkpoints-sidebar/CheckpointsSidebar.d.ts +27 -0
  521. package/lib/loop/plugins/checkpoints-sidebar/CheckpointsSidebar.js +174 -0
  522. package/lib/loop/plugins/checkpoints-sidebar/index.d.ts +5 -0
  523. package/lib/loop/plugins/checkpoints-sidebar/index.js +39 -0
  524. package/lib/loop/plugins/commands/index.d.ts +20 -0
  525. package/lib/loop/plugins/commands/index.js +148 -0
  526. package/lib/loop/plugins/decks/DeckSurface.d.ts +10 -0
  527. package/lib/loop/plugins/decks/DeckSurface.js +6 -0
  528. package/lib/loop/plugins/decks/DecksMenu.d.ts +11 -0
  529. package/lib/loop/plugins/decks/DecksMenu.js +42 -0
  530. package/lib/loop/plugins/decks/index.d.ts +19 -0
  531. package/lib/loop/plugins/decks/index.js +133 -0
  532. package/lib/loop/plugins/decks/surface.d.ts +7 -0
  533. package/lib/loop/plugins/decks/surface.js +11 -0
  534. package/lib/loop/plugins/document/DocumentView.d.ts +12 -0
  535. package/lib/loop/plugins/document/DocumentView.js +68 -0
  536. package/lib/loop/plugins/document/index.d.ts +3 -0
  537. package/lib/loop/plugins/document/index.js +86 -0
  538. package/lib/loop/plugins/document/openingDocument.d.ts +28 -0
  539. package/lib/loop/plugins/document/openingDocument.js +122 -0
  540. package/lib/loop/plugins/document-toolbar/SandboxStatusItem.d.ts +16 -0
  541. package/lib/loop/plugins/document-toolbar/SandboxStatusItem.js +31 -0
  542. package/lib/loop/plugins/document-toolbar/index.d.ts +4 -0
  543. package/lib/loop/plugins/document-toolbar/index.js +35 -0
  544. package/lib/loop/plugins/document-toolbar/names.d.ts +6 -0
  545. package/lib/loop/plugins/document-toolbar/names.js +10 -0
  546. package/lib/loop/plugins/document-toolbar/plugin.d.ts +2 -0
  547. package/lib/loop/plugins/document-toolbar/plugin.js +38 -0
  548. package/lib/loop/plugins/document-view/index.d.ts +10 -0
  549. package/lib/loop/plugins/document-view/index.js +28 -0
  550. package/lib/loop/plugins/graph/GraphToggle.d.ts +17 -0
  551. package/lib/loop/plugins/graph/GraphToggle.js +22 -0
  552. package/lib/loop/plugins/graph/GraphView.d.ts +16 -0
  553. package/lib/loop/plugins/graph/GraphView.js +6 -0
  554. package/lib/loop/plugins/graph/index.d.ts +5 -0
  555. package/lib/loop/plugins/graph/index.js +80 -0
  556. package/lib/loop/plugins/graph/viewType.d.ts +10 -0
  557. package/lib/loop/plugins/graph/viewType.js +14 -0
  558. package/lib/loop/plugins/input-prompt/ComposerView.d.ts +15 -0
  559. package/lib/loop/plugins/input-prompt/ComposerView.js +25 -0
  560. package/lib/loop/plugins/input-prompt/index.d.ts +25 -0
  561. package/lib/loop/plugins/input-prompt/index.js +26 -0
  562. package/lib/loop/plugins/models/index.d.ts +3 -0
  563. package/lib/loop/plugins/models/index.js +49 -0
  564. package/lib/loop/plugins/notebook/NotebookView.d.ts +9 -0
  565. package/lib/loop/plugins/notebook/NotebookView.js +189 -0
  566. package/lib/loop/plugins/notebook/index.d.ts +3 -0
  567. package/lib/loop/plugins/notebook/index.js +91 -0
  568. package/lib/loop/plugins/notebook/openingNotebook.d.ts +72 -0
  569. package/lib/loop/plugins/notebook/openingNotebook.js +90 -0
  570. package/lib/loop/plugins/notebook-toolbar/index.d.ts +4 -0
  571. package/lib/loop/plugins/notebook-toolbar/index.js +45 -0
  572. package/lib/loop/plugins/notebook-toolbar/items.d.ts +10 -0
  573. package/lib/loop/plugins/notebook-toolbar/items.js +45 -0
  574. package/lib/loop/plugins/notebook-toolbar/names.d.ts +9 -0
  575. package/lib/loop/plugins/notebook-toolbar/names.js +13 -0
  576. package/lib/loop/plugins/notebook-toolbar/plugin.d.ts +2 -0
  577. package/lib/loop/plugins/notebook-toolbar/plugin.js +24 -0
  578. package/lib/loop/plugins/notebook-view/index.d.ts +10 -0
  579. package/lib/loop/plugins/notebook-view/index.js +30 -0
  580. package/lib/loop/plugins/page-layout/TurnPanel.d.ts +25 -0
  581. package/lib/loop/plugins/page-layout/TurnPanel.js +126 -0
  582. package/lib/loop/plugins/page-layout/index.d.ts +35 -0
  583. package/lib/loop/plugins/page-layout/index.js +80 -0
  584. package/lib/loop/plugins/plugins-panel/index.d.ts +14 -0
  585. package/lib/loop/plugins/plugins-panel/index.js +74 -0
  586. package/lib/loop/plugins/prompt/NewChatAction.d.ts +19 -0
  587. package/lib/loop/plugins/prompt/NewChatAction.js +10 -0
  588. package/lib/loop/plugins/prompt/index.d.ts +11 -0
  589. package/lib/loop/plugins/prompt/index.js +73 -0
  590. package/lib/loop/plugins/shell/editorChoice.d.ts +31 -0
  591. package/lib/loop/plugins/shell/editorChoice.js +58 -0
  592. package/lib/loop/plugins/shell/index.d.ts +47 -0
  593. package/lib/loop/plugins/shell/index.js +142 -0
  594. package/lib/loop/plugins/shell/useEditorPreviews.d.ts +32 -0
  595. package/lib/loop/plugins/shell/useEditorPreviews.js +217 -0
  596. package/lib/loop/plugins/subagent-activity/SubagentPulse.d.ts +16 -0
  597. package/lib/loop/plugins/subagent-activity/SubagentPulse.js +45 -0
  598. package/lib/loop/plugins/subagent-activity/index.d.ts +12 -0
  599. package/lib/loop/plugins/subagent-activity/index.js +42 -0
  600. package/lib/loop/plugins/view-switch/index.d.ts +46 -0
  601. package/lib/loop/plugins/view-switch/index.js +68 -0
  602. package/lib/loop/plugins/window-frame/WindowFrame.d.ts +48 -0
  603. package/lib/loop/plugins/window-frame/WindowFrame.js +63 -0
  604. package/lib/loop/plugins/window-frame/index.d.ts +6 -0
  605. package/lib/loop/plugins/window-frame/index.js +79 -0
  606. package/lib/loop/plugins/window-frame/slots.d.ts +26 -0
  607. package/lib/loop/plugins/window-frame/slots.js +30 -0
  608. package/lib/loop/presets.d.ts +167 -0
  609. package/lib/loop/presets.js +139 -0
  610. package/lib/loop/shell/LoopWorkspace.d.ts +109 -0
  611. package/lib/loop/shell/LoopWorkspace.js +231 -0
  612. package/lib/loop/shell/PluginToggles.d.ts +21 -0
  613. package/lib/loop/shell/PluginToggles.js +41 -0
  614. package/lib/loop/shell/ViewSwitcher.d.ts +24 -0
  615. package/lib/loop/shell/ViewSwitcher.js +43 -0
  616. package/lib/loop/shell/WorkspaceFullScreenAction.d.ts +25 -0
  617. package/lib/loop/shell/WorkspaceFullScreenAction.js +24 -0
  618. package/lib/loop/shell/index.d.ts +10 -0
  619. package/lib/loop/shell/index.js +14 -0
  620. package/lib/loop/shell/useWorkspaceFullScreen.d.ts +93 -0
  621. package/lib/loop/shell/useWorkspaceFullScreen.js +167 -0
  622. package/lib/loop-example-main.d.ts +1 -0
  623. package/lib/loop-example-main.js +42 -0
  624. package/lib/loop-main.d.ts +1 -0
  625. package/lib/loop-main.js +138 -0
  626. package/lib/mcp/McpServerManager.d.ts +1 -1
  627. package/lib/models/CodeSandboxSnapshotDTO.d.ts +1 -1
  628. package/lib/models/CodeSandboxVariant.d.ts +53 -0
  629. package/lib/models/CodeSandboxVariant.js +77 -0
  630. package/lib/models/Content.d.ts +26 -0
  631. package/lib/models/Environment.d.ts +561 -5
  632. package/lib/models/Environment.js +12 -1
  633. package/lib/models/EnvironmentDTO.d.ts +24 -6
  634. package/lib/models/EnvironmentDTO.js +13 -2
  635. package/lib/models/Exercise.d.ts +0 -2
  636. package/lib/models/Library.d.ts +0 -2
  637. package/lib/models/Notebook.d.ts +0 -2
  638. package/lib/models/ProjectDTO.d.ts +2 -2
  639. package/lib/models/ProjectDTO.js +4 -4
  640. package/lib/models/Runtime.d.ts +11 -11
  641. package/lib/models/RuntimeDTO.d.ts +16 -7
  642. package/lib/models/RuntimeDTO.js +9 -9
  643. package/lib/models/Space.d.ts +10 -0
  644. package/lib/models/Space.js +1 -1
  645. package/lib/models/SpaceDTO.d.ts +1 -1
  646. package/lib/models/SpaceItem.d.ts +1 -2
  647. package/lib/models/environments.generated.d.ts +113 -0
  648. package/lib/models/environments.generated.js +13 -0
  649. package/lib/models/index.d.ts +1 -1
  650. package/lib/models/index.js +1 -1
  651. package/lib/protocols/A2AAdapter.d.ts +39 -6
  652. package/lib/protocols/A2AAdapter.js +180 -11
  653. package/lib/protocols/ACPAdapter.js +40 -37
  654. package/lib/protocols/AGUIAdapter.d.ts +14 -0
  655. package/lib/protocols/AGUIAdapter.js +34 -9
  656. package/lib/protocols/BrowserAgentAdapter.d.ts +117 -0
  657. package/lib/protocols/BrowserAgentAdapter.js +310 -0
  658. package/lib/protocols/VercelAIAdapter.d.ts +10 -0
  659. package/lib/protocols/VercelAIAdapter.js +27 -7
  660. package/lib/protocols/index.d.ts +1 -0
  661. package/lib/protocols/index.js +1 -0
  662. package/lib/runtimes/actions.d.ts +3 -3
  663. package/lib/runtimes/actions.js +41 -16
  664. package/lib/runtimes/apis.d.ts +13 -4
  665. package/lib/runtimes/browser/agent.d.ts +54 -0
  666. package/lib/runtimes/browser/agent.js +63 -0
  667. package/lib/runtimes/browser/anonymousToken.d.ts +121 -0
  668. package/lib/runtimes/browser/anonymousToken.js +300 -0
  669. package/lib/runtimes/browser/frontendTools.d.ts +61 -0
  670. package/lib/runtimes/browser/frontendTools.js +152 -0
  671. package/lib/runtimes/browser/index.d.ts +11 -0
  672. package/lib/runtimes/browser/index.js +20 -0
  673. package/lib/runtimes/browser/model.d.ts +52 -0
  674. package/lib/runtimes/browser/model.js +110 -0
  675. package/lib/runtimes/browser/protocol.d.ts +54 -0
  676. package/lib/runtimes/browser/protocol.js +35 -0
  677. package/lib/runtimes/browser/subagents.d.ts +131 -0
  678. package/lib/runtimes/browser/subagents.js +241 -0
  679. package/lib/runtimes/index.d.ts +3 -0
  680. package/lib/runtimes/index.js +3 -0
  681. package/lib/runtimes/lifecycle.d.ts +76 -0
  682. package/lib/runtimes/lifecycle.js +99 -0
  683. package/lib/runtimes/variants.d.ts +172 -0
  684. package/lib/runtimes/variants.js +187 -0
  685. package/lib/services/reconnectToRuntime.d.ts +2 -2
  686. package/lib/services/reconnectToRuntime.js +3 -3
  687. package/lib/services/sandboxServiceManagers.d.ts +2 -2
  688. package/lib/services/sandboxServiceManagers.js +11 -11
  689. package/lib/specs/agents/agents.d.ts +128 -112
  690. package/lib/specs/agents/agents.js +8024 -5052
  691. package/lib/specs/envvars.d.ts +1 -1
  692. package/lib/specs/envvars.js +3 -3
  693. package/lib/specs/evals.js +9 -0
  694. package/lib/specs/frontendTools.d.ts +3 -0
  695. package/lib/specs/frontendTools.js +46 -3
  696. package/lib/specs/mcpServers.d.ts +1 -0
  697. package/lib/specs/mcpServers.js +27 -4
  698. package/lib/specs/models.d.ts +18 -0
  699. package/lib/specs/models.js +154 -0
  700. package/lib/specs/outputs.d.ts +2 -0
  701. package/lib/specs/outputs.js +22 -0
  702. package/lib/specs/personas.js +1 -1
  703. package/lib/specs/teams/teams.d.ts +2 -0
  704. package/lib/specs/teams/teams.js +628 -111
  705. package/lib/state/index.d.ts +1 -1
  706. package/lib/state/index.js +1 -1
  707. package/lib/state/substates/RuntimesState.d.ts +5 -5
  708. package/lib/state/substates/RuntimesState.js +17 -14
  709. package/lib/state/substates/index.d.ts +1 -1
  710. package/lib/state/substates/index.js +1 -1
  711. package/lib/stores/agentRuntimeStore.d.ts +43 -1
  712. package/lib/stores/agentRuntimeStore.js +100 -11
  713. package/lib/stores/index.d.ts +1 -1
  714. package/lib/stores/index.js +1 -1
  715. package/lib/stories/Button.d.ts +1 -1
  716. package/lib/stories/Button.stories.d.ts +1 -1
  717. package/lib/stories/Header.d.ts +1 -1
  718. package/lib/stories/Header.stories.d.ts +1 -1
  719. package/lib/test-setup.js +66 -0
  720. package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +15 -0
  721. package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +43 -2
  722. package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +9 -0
  723. package/lib/tools/adapters/agent-runtimes/notebookHooks.js +12 -0
  724. package/lib/tools/adapters/commands/frontendCommandTools.d.ts +11 -0
  725. package/lib/tools/adapters/commands/frontendCommandTools.js +60 -0
  726. package/lib/tools/adapters/commands/index.d.ts +1 -0
  727. package/lib/{models/Dataset.js → tools/adapters/commands/index.js} +1 -1
  728. package/lib/tools/adapters/copilotkit/lexicalHooks.js +7 -3
  729. package/lib/tools/index.d.ts +1 -0
  730. package/lib/tools/index.js +1 -0
  731. package/lib/types/a2a.d.ts +15 -1
  732. package/lib/types/agents-lifecycle.d.ts +11 -6
  733. package/lib/types/agents.d.ts +31 -6
  734. package/lib/types/agentspecs.d.ts +120 -4
  735. package/lib/types/chat.d.ts +251 -3
  736. package/lib/types/checkpoints.d.ts +20 -0
  737. package/lib/types/config.d.ts +13 -1
  738. package/lib/types/connection.d.ts +1 -1
  739. package/lib/types/evals.d.ts +2 -0
  740. package/lib/types/messages.d.ts +60 -0
  741. package/lib/types/models.d.ts +26 -0
  742. package/lib/types/notifications.d.ts +15 -6
  743. package/lib/types/protocol.d.ts +7 -2
  744. package/lib/types/stream.d.ts +48 -3
  745. package/lib/types/stream.js +5 -0
  746. package/lib/types/teams.d.ts +102 -4
  747. package/lib/types/tool-approvals.d.ts +1 -1
  748. package/lib/types/tools.d.ts +8 -2
  749. package/lib/utils/utils.js +7 -1
  750. package/package.json +376 -361
  751. package/scripts/codegen/__pycache__/compose.cpython-313.pyc +0 -0
  752. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  753. package/scripts/codegen/compose.py +208 -0
  754. package/scripts/codegen/generate_agents.py +202 -31
  755. package/scripts/codegen/generate_evals.py +2 -0
  756. package/scripts/codegen/generate_frontend_tools.py +35 -6
  757. package/scripts/codegen/generate_models.py +40 -15
  758. package/scripts/codegen/generate_sandbox_agents.py +76 -62
  759. package/scripts/codegen/generate_teams.py +178 -4
  760. package/scripts/codegen/generate_tools.py +6 -4
  761. package/scripts/gen_workers.py +279 -111
  762. package/scripts/generate-environments-types.py +404 -0
  763. package/lib/chat/prompt/InputFooter.d.ts +0 -58
  764. package/lib/chat/prompt/InputFooter.js +0 -194
  765. package/lib/chat/prompt/InputPromptFooter.d.ts +0 -27
  766. package/lib/chat/prompt/InputPromptFooter.js +0 -15
  767. package/lib/chat/prompt/InputPromptHeader.d.ts +0 -15
  768. package/lib/chat/prompt/InputPromptHeader.js +0 -15
  769. package/lib/chat/usage/TokenUsageBar.d.ts +0 -8
  770. package/lib/hooks/useRuntimes.d.ts +0 -5
  771. package/lib/hooks/useRuntimes.js +0 -34
  772. package/lib/jupyter/kernelsHandler.d.ts +0 -8
  773. package/lib/jupyter/kernelsHandler.js +0 -39
  774. package/lib/models/Dataset.d.ts +0 -16
  775. package/lib/utils/Cells.d.ts +0 -2
  776. package/lib/utils/Cells.js +0 -28
@@ -30,16 +30,22 @@ import { DEFAULT_SERVICE_URLS } from '@datalayer/core/lib/api/constants';
30
30
  import { useChatStore } from '../../stores/chatStore';
31
31
  import { useConversationStore } from '../../stores/conversationStore';
32
32
  import { generateMessageId, createUserMessage, createAssistantMessage, } from '../../types/messages';
33
+ import { AgentDetails } from '../../agents/AgentDetails';
34
+ import { AI_MODEL_CATALOGUE } from '../../specs/models';
33
35
  import { internalQueryClient, isToolCallMessage, convertHistoryToDisplayItems, createProtocolAdapter, getApiBaseFromConfig, sanitizeAssistantContent, } from '../../utils';
34
36
  import { useConfig, useSkills, useSkillActions, useContextSnapshot, useSandbox, } from '../../hooks';
35
37
  import { useAgentRuntimeWebSocket } from '../../hooks/useAgentRuntimes';
36
38
  import { agentRuntimeStore, useAgentRuntimeStore, useAgentRuntimeWsState, } from '../../stores/agentRuntimeStore';
37
- import { ChatBaseHeader } from '../header/ChatHeaderBase';
39
+ import { ChatBaseHeader, } from '../header/ChatHeaderBase';
40
+ import { useChatAvailability } from './ChatAvailability';
38
41
  import { ChatEmptyState } from '../display/EmptyState';
42
+ import { notebookToolSurfacesRenderer } from '../messages/NotebookToolSurfaces';
39
43
  import { FloatingBrandButton } from '../display/FloatingBrandButton';
40
44
  import { PoweredByTag } from '../display/PoweredByTag';
45
+ import { EphemeralSurfaceControl } from '../EphemeralSurfaceControl';
41
46
  import { ChatMessageList, } from '../messages/ChatMessageList';
42
- import { InputToolbar } from '../prompt/InputFooter';
47
+ import { InputPrompt } from '../prompt/InputPrompt';
48
+ import { isFloatingChatViewMode } from '../viewModes';
43
49
  import { ToolApprovalBanner, ToolApprovalDialog, } from '../tools';
44
50
  import { EphemeralNotebook } from '../notebook/EphemeralNotebook';
45
51
  // EphemeralDocument statically imports `@datalayer/jupyter-lexical` (which
@@ -492,11 +498,11 @@ export function ChatBase(props) {
492
498
  // ---------------------------------------------------------------------------
493
499
  // ChatBaseInner — contains all actual logic
494
500
  // ---------------------------------------------------------------------------
495
- function ChatBaseInner({ title, subtitle, showHeader = false, showTokenUsage = true, showLoadingIndicator = true, showErrors = true, showInput = true, showModelSelector = true, showToolsMenu = true, showSkillsMenu = true, disableInputPrompt = false, overlay, launching = false, launchingMessage, autoConnect = true, codemodeEnabled = false, onToggleCodemode, initialModel, availableModels, mcpServers, initialSkills: _initialSkills, className, loadingState, headerActions, kernelIndicatorState, kernelIndicatorPlacement = 'left', kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, themeVariant, colorMode, chatViewMode, onChatViewModeChange,
501
+ function ChatBaseInner({ title, subtitle, showHeader = false, showTokenUsage = true, showContextRing = false, showLoadingIndicator = true, showErrors = true, showInput = true, showModelSelector = true, showToolsMenu = true, showSkillsMenu = true, disableInputPrompt = false, promptVariant, mentionableAgents: mentionableAgentsProp, showAgentsMenu = true, agents: agentsProp, selectedAgentId, onSelectAgent, disabled: disabledProp, disableReason: disableReasonProp, overlay, launching = false, launchingMessage, autoConnect = true, codemodeEnabled = false, onToggleCodemode, initialModel, availableModels, mcpServers, initialSkills: _initialSkills, className, loadingState, headerActions, kernelIndicatorState, kernelIndicatorPlacement = 'left', kernel, kernelEnvironmentName, kernelCpu, kernelMemory, kernelGpu, themeVariant, colorMode, chatViewMode, onChatViewModeChange, disabledViewModes,
496
502
  // Mode selection
497
- useStore: useStoreMode = true, protocol: protocolRaw, onSendMessage, enableStreaming = false,
503
+ useStore: useStoreMode = true, protocol: protocolRaw, onSendMessage, onSendReady, onLoadingChange, onContextSnapshot, enableStreaming = false,
498
504
  // Extended props
499
- brandIcon, avatarConfig, headerButtons, showPoweredBy = false, poweredByProps, emptyState, renderToolResult, footerContent, showInformation = false, onInformationClick, headerContent, children, borderRadius, backgroundColor, border, boxShadow, compact = false, placeholder, description = 'Start a conversation with the AI agent.', onStateUpdate, onNewChat, onClear, onMessagesChange, autoFocus = false, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, focusTrigger, frontendTools: frontendToolsProp, enableEphemeralNotebook = false, initialEphemeralNotebookOpen = true, onEphemeralNotebookOpenChange, enableEphemeralDocument = false, initialEphemeralSurfaceMode, onEphemeralSurfaceModeChange, collapsed = false, onExpandFromCollapsed, ephemeralNotebookToolbar, ephemeralNotebookToolbarExtraItems, ephemeralDocumentToolbarExtraItems, ephemeralNotebookCollaborationProvider, ephemeralNotebookCollaborationDocumentId, ephemeralDocumentCollaboration, ephemeralRuntimeOverride,
505
+ brandIcon, avatarConfig, headerButtons, showPoweredBy = false, poweredByProps, emptyState, renderToolResult, renderHeader, showTurnFooter = true, notebookToolSurfacesId, footerContent, showInformation = false, onInformationClick, headerContent, children, borderRadius, backgroundColor, border, boxShadow, compact = false, placeholder, description = 'Start a conversation with the AI agent.', onStateUpdate, onNewChat, onClear, onMessagesChange, onItemsChange, onDisplayItemsChange, autoFocus = false, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, focusTrigger, frontendTools: frontendToolsProp, enableEphemeralNotebook = false, initialEphemeralNotebookOpen = true, onEphemeralNotebookOpenChange, enableEphemeralDocument = false, initialEphemeralSurfaceMode, onEphemeralSurfaceModeChange, collapsed = false, onExpandFromCollapsed, ephemeralNotebookToolbar, ephemeralNotebookToolbarExtraItems, ephemeralDocumentToolbarExtraItems, ephemeralNotebookCollaborationProvider, ephemeralNotebookCollaborationDocumentId, ephemeralDocumentCollaboration, ephemeralRuntimeOverride,
500
506
  // Tool invocation hooks
501
507
  onToolCallStart, onToolCallComplete,
502
508
  // Identity/Authorization props
@@ -510,12 +516,20 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
510
516
  useEffect(() => {
511
517
  setupPrimerPortals();
512
518
  }, []);
519
+ // Whether there is anything to talk to. The host usually knows — a browser
520
+ // sandbox has no agent beside it — and says so once for everything beneath
521
+ // it; an explicit prop still wins for one particular chat.
522
+ const ambientAvailability = useChatAvailability();
523
+ const disabled = disabledProp ?? ambientAvailability.disabled;
524
+ const disableReason = disableReasonProp ?? ambientAvailability.disableReason;
513
525
  const { theme } = useThemeStore();
514
526
  const assistantIconColor = getColorPalette(theme, 'dark').textLight;
515
527
  // ── Built-in pending approvals from the agent-runtime Zustand store ──
516
528
  // When the parent doesn't supply the `pendingApprovals` prop, derive them
517
529
  // from the shared store so the banner works out-of-the-box.
518
530
  const storeApprovals = useAgentRuntimeStore(s => s.approvals);
531
+ // Bumped when the transcript changed on the server outside a run.
532
+ const historyVersion = useAgentRuntimeStore(s => s.historyVersion);
519
533
  const storeMcpStatus = useAgentRuntimeStore(s => s.mcpStatus);
520
534
  const effectiveMcpStatusData = mcpStatusData ?? storeMcpStatus;
521
535
  const protocolConfig = typeof protocolRaw === 'object'
@@ -578,7 +592,40 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
578
592
  const notebookVisible = enableEphemeralNotebook && ephemeralSurfaceMode === 'notebook';
579
593
  const documentVisible = enableEphemeralDocument && ephemeralSurfaceMode === 'document';
580
594
  const surfaceVisible = notebookVisible || documentVisible;
581
- const surfaceCollapsed = surfaceVisible && collapsed && Boolean(onExpandFromCollapsed);
595
+ /*
596
+ * Collapsed means collapsed, whether or not there is a way back.
597
+ *
598
+ * Offering to reopen the conversation is what `onExpandFromCollapsed`
599
+ * decides, and the affordance below is guarded by it. Requiring it HERE
600
+ * meant a surface asked to collapse with nothing to expand into — a Code
601
+ * Sandbox, where nothing is listening — kept the conversation on screen
602
+ * instead.
603
+ */
604
+ const surfaceCollapsed = surfaceVisible && collapsed;
605
+ /*
606
+ * The switch between the notebook and the document, for a collapsed chat.
607
+ *
608
+ * It normally sits in the chat's header, which is exactly what a collapsed
609
+ * chat does not draw — so a page without a conversation opened whichever
610
+ * surface came first and could never leave it. On the surface's own toolbar
611
+ * it is reachable either way. "Chat only" is not among the choices here:
612
+ * closing the surface would leave nothing at all.
613
+ */
614
+ const collapsedSurfaceControl = surfaceCollapsed
615
+ ? {
616
+ key: 'ephemeral-surface',
617
+ type: 'custom',
618
+ // Last of the toolbar, away from what acts on the surface itself.
619
+ order: 900,
620
+ render: () => (_jsx(EphemeralSurfaceControl, { mode: ephemeralSurfaceMode, onChange: handleEphemeralSurfaceModeChange, enableNotebook: enableEphemeralNotebook, enableDocument: enableEphemeralDocument, enableChatOnly: false })),
621
+ }
622
+ : null;
623
+ const notebookToolbarItems = collapsedSurfaceControl
624
+ ? [...(ephemeralNotebookToolbarExtraItems ?? []), collapsedSurfaceControl]
625
+ : ephemeralNotebookToolbarExtraItems;
626
+ const documentToolbarItems = collapsedSurfaceControl
627
+ ? [...(ephemeralDocumentToolbarExtraItems ?? []), collapsedSurfaceControl]
628
+ : ephemeralDocumentToolbarExtraItems;
582
629
  // Track the ephemeral notebook's live kernel connection so the chat header
583
630
  // renders the same rich `KernelIndicator` details (kernel id, client id,
584
631
  // server/ws url, status) as the notebook editor. Without this the header
@@ -624,8 +671,9 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
624
671
  }, [documentVisible]);
625
672
  // When a companion surface is shown, the chat can be docked as a sidebar
626
673
  // (default) or floated over it, driven by the header view-mode toggle.
627
- const surfaceChatFloating = surfaceVisible &&
628
- (chatViewMode === 'floating' || chatViewMode === 'floating-small');
674
+ const surfaceChatFloating = surfaceVisible && isFloatingChatViewMode(chatViewMode);
675
+ // The two smaller floating modes share the compact card over a surface.
676
+ const compactFloating = chatViewMode === 'floating-small' || chatViewMode === 'floating-draggable';
629
677
  // Notebook frontend tools are always created (hooks must be unconditional)
630
678
  // but only merged into the tools sent to the agent while the notebook is
631
679
  // visible, so the agent can manipulate the live notebook cells. Document
@@ -1110,6 +1158,18 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1110
1158
  const isA2AProtocol = protocol?.type === 'a2a';
1111
1159
  // ---- Component state ----
1112
1160
  const [displayItems, setDisplayItems] = useState([]);
1161
+ /*
1162
+ * What the harness itself reported, for an agent with no server behind it.
1163
+ *
1164
+ * The last turn *and* the running session. Both, because the bar shows both
1165
+ * — "· 12k ▲ 900 ▼" is the conversation so far and "· turn 800 ▲ 120 ▼" is
1166
+ * what the last exchange cost — and a snapshot carrying only a total leaves
1167
+ * those two lines out entirely.
1168
+ */
1169
+ const [localUsage, setLocalUsage] = useState(null);
1170
+ /* Whether the (i) has been pressed. Its own state rather than a view mode:
1171
+ it is a detour from the conversation, not a place the chat lives. */
1172
+ const [showDetails, setShowDetails] = useState(false);
1113
1173
  const [isLoading, setIsLoading] = useState(false);
1114
1174
  const [liveKernelStatus, setLiveKernelStatus] = useState();
1115
1175
  const [isStreaming, setIsStreaming] = useState(false);
@@ -1231,8 +1291,247 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1231
1291
  });
1232
1292
  return set;
1233
1293
  }, [localSkillApproval, skillsQuery.data]);
1294
+ /*
1295
+ * What the Tools menu lists.
1296
+ *
1297
+ * The server's builtin tools when there are any, and otherwise the tools
1298
+ * this page gave the agent. An in-page agent has no config endpoint to ask
1299
+ * — that is the whole point of it — so the menu was empty for the one kind
1300
+ * of agent whose tools the browser already knows in full.
1301
+ */
1302
+ const builtinTools = useMemo(() => {
1303
+ /*
1304
+ * Both lists, not one or the other.
1305
+ *
1306
+ * The server's builtin tools and the ones this page handed the agent are
1307
+ * both things it can call, and a menu naming only the first was wrong for
1308
+ * every agent given frontend tools — which is every notebook agent, whose
1309
+ * ability to run a cell lives entirely on this side.
1310
+ *
1311
+ * Server first, because that is the order they were introduced in and a
1312
+ * list that reorders itself as a request lands is one nobody can scan.
1313
+ * De-duplicated by name: a tool implemented on both sides is one tool.
1314
+ */
1315
+ const fromConfig = configQuery.data?.builtinTools ?? [];
1316
+ /*
1317
+ * Including the tools this chat does *not* run.
1318
+ *
1319
+ * An in-page agent's tools are handed to the harness rather than to the
1320
+ * chat — the SDK owns the loop and calls them directly, and giving them
1321
+ * to both would run each one twice — so `frontendTools` is empty for
1322
+ * exactly the agent whose tools live entirely in the page. The menu was
1323
+ * therefore emptiest where the tools were most real.
1324
+ *
1325
+ * Executing a tool and listing it are different jobs. The protocol config
1326
+ * names what the agent can call, which is the question this menu asks.
1327
+ */
1328
+ const inProtocol = protocol?.options
1329
+ ?.frontendTools ?? [];
1330
+ const seen = new Set(fromConfig.map(tool => tool.name));
1331
+ const fromPage = [...(frontendTools ?? []), ...inProtocol]
1332
+ .filter(tool => {
1333
+ if (seen.has(tool.name)) {
1334
+ return false;
1335
+ }
1336
+ seen.add(tool.name);
1337
+ return true;
1338
+ })
1339
+ .map(tool => ({ id: tool.name, name: tool.name }));
1340
+ return [...fromConfig, ...fromPage];
1341
+ }, [configQuery.data?.builtinTools, frontendTools, protocol?.options]);
1342
+ /*
1343
+ * Who is answering, as one row when that is all there is.
1344
+ *
1345
+ * A host with a team passes its own list. Everything else gets the agent
1346
+ * this chat is actually talking to — which the control states rather than
1347
+ * switches, and which nothing else on screen said. It used to be omitted
1348
+ * entirely, so the chip and the footer menu were both simply absent.
1349
+ */
1350
+ const footerAgents = useMemo(() => agentsProp ??
1351
+ (activeAgentId
1352
+ ? [
1353
+ {
1354
+ id: activeAgentId,
1355
+ name: title || activeAgentId,
1356
+ /*
1357
+ What this agent is for, beside its name.
1358
+
1359
+ The menu renders a description when there is one and a bare
1360
+ name when there is not, and a single-agent list built from the
1361
+ id alone therefore opened onto one word. `subtitle` is what a
1362
+ host writes to say what its chat does, which is the same
1363
+ sentence a person clicking the agent control is asking for.
1364
+ */
1365
+ description: subtitle || description,
1366
+ },
1367
+ ]
1368
+ : []), [agentsProp, activeAgentId, title, subtitle, description]);
1369
+ /*
1370
+ * The models on offer.
1371
+ *
1372
+ * An in-page agent has no config endpoint, and asking one for a catalogue is
1373
+ * asking a page about itself. It does know the model it was built with — the
1374
+ * protocol carries it — so the control names that rather than disappearing.
1375
+ */
1376
+ const browserModel = typeof protocol?.options?.model ===
1377
+ 'string'
1378
+ ? (protocol?.options).model
1379
+ : undefined;
1380
+ const offeredModels = useMemo(() => {
1381
+ const fromConfig = availableModels || configQuery.data?.models;
1382
+ if (fromConfig?.length) {
1383
+ return fromConfig;
1384
+ }
1385
+ /*
1386
+ * The catalogue, filtered to what is worth offering.
1387
+ *
1388
+ * A server tells the chat which models it can reach and that answer wins.
1389
+ * Without one — an in-page agent, or a server that has not answered yet —
1390
+ * this used to offer the single model the protocol was built with, which
1391
+ * is a menu with nothing to choose.
1392
+ *
1393
+ * `available` is the filter, not the whole catalogue: twenty-six models,
1394
+ * most of them superseded, is a list nobody reads. The specs say which
1395
+ * four are current.
1396
+ */
1397
+ const catalogued = Object.values(AI_MODEL_CATALOGUE)
1398
+ .filter(model => model.available)
1399
+ .map(model => ({
1400
+ id: model.id,
1401
+ name: model.name,
1402
+ provider: model.provider,
1403
+ }));
1404
+ if (catalogued.length > 0) {
1405
+ return catalogued;
1406
+ }
1407
+ return browserModel
1408
+ ? [{ id: browserModel, name: browserModel, provider: 'inference' }]
1409
+ : [];
1410
+ }, [availableModels, configQuery.data?.models, browserModel]);
1411
+ /*
1412
+ * Who `@` may address.
1413
+ *
1414
+ * The same people the footer offers, unless a host supplies its own list.
1415
+ * It used to be the host's or nothing, so a chat that had not been told
1416
+ * about mentions had no menu at all — and the menu is also how a person
1417
+ * *discovers* that agents can be addressed.
1418
+ *
1419
+ * The one being addressed is listed and disabled rather than dropped: a
1420
+ * menu of one that hides its only row is a menu that looks broken, and
1421
+ * "you are already talking to this one" is a useful thing to be told.
1422
+ */
1423
+ const mentionableAgents = useMemo(() => mentionableAgentsProp ??
1424
+ footerAgents.map(agent => ({
1425
+ name: agent.name,
1426
+ description: agent.description,
1427
+ icon: agent.icon,
1428
+ disabled: agent.id === (selectedAgentId ?? footerAgents[0]?.id),
1429
+ disabledReason: `You are already talking to ${agent.name}`,
1430
+ })), [mentionableAgentsProp, footerAgents, selectedAgentId]);
1234
1431
  const contextSnapshotQuery = useContextSnapshot(configQueriesEnabled && showTokenUsage, protocol?.configEndpoint, protocol?.agentId, protocol?.authToken);
1235
- const agentUsage = externalContextSnapshot ?? contextSnapshotQuery.data;
1432
+ /*
1433
+ * The window, from whoever can account for it.
1434
+ *
1435
+ * A host's own snapshot first, then the server's, then what the harness
1436
+ * reported as it finished. The last is a partial picture — it knows the
1437
+ * turn's tokens and the model's window, not how they divide between the
1438
+ * system prompt, the tools and the history — so the fields it cannot
1439
+ * honestly fill are left at zero rather than guessed at.
1440
+ */
1441
+ const localSnapshot = useMemo(() => {
1442
+ /*
1443
+ * Only for a harness that has no server keeping the account.
1444
+ *
1445
+ * `enableConfigQuery` is what says a runtime is reporting its own context
1446
+ * over the socket; where one is, this must not shadow it with a partial
1447
+ * picture assembled from turn totals.
1448
+ */
1449
+ if (protocol?.enableConfigQuery) {
1450
+ return undefined;
1451
+ }
1452
+ /* A conservative window. The harness reports what a turn cost, not what
1453
+ the model can hold, and 200k is the smaller of the sizes the models
1454
+ this reaches actually offer — so the bar reads as fuller than the truth
1455
+ rather than emptier, which is the safer way to be wrong about a
1456
+ limit. */
1457
+ const contextWindow = 200_000;
1458
+ return {
1459
+ totalTokens: localUsage?.totalTokens ?? 0,
1460
+ contextWindow,
1461
+ sumResponseInputTokens: localUsage?.sessionInput ?? 0,
1462
+ sumResponseOutputTokens: localUsage?.sessionOutput ?? 0,
1463
+ systemPromptTokens: 0,
1464
+ userMessageTokens: 0,
1465
+ assistantMessageTokens: 0,
1466
+ toolTokens: 0,
1467
+ toolCallTokens: 0,
1468
+ toolReturnTokens: 0,
1469
+ historyToolCallTokens: 0,
1470
+ historyToolReturnTokens: 0,
1471
+ currentToolCallTokens: 0,
1472
+ currentToolReturnTokens: 0,
1473
+ turnUsage: {
1474
+ inputTokens: localUsage?.turnInput ?? 0,
1475
+ outputTokens: localUsage?.turnOutput ?? 0,
1476
+ // Not counted by the harness, and left at zero rather than invented:
1477
+ // the bar reads these only for the numbers it prints beside the ring.
1478
+ requests: 0,
1479
+ toolCalls: 0,
1480
+ toolNames: [],
1481
+ durationSeconds: 0,
1482
+ },
1483
+ sessionUsage: {
1484
+ inputTokens: localUsage?.sessionInput ?? 0,
1485
+ outputTokens: localUsage?.sessionOutput ?? 0,
1486
+ requests: 0,
1487
+ toolCalls: 0,
1488
+ turns: 0,
1489
+ durationSeconds: 0,
1490
+ },
1491
+ };
1492
+ }, [localUsage, protocol?.enableConfigQuery]);
1493
+ /*
1494
+ * Nothing carried over from the agent before this one.
1495
+ *
1496
+ * The runtime store keeps one snapshot, not one per agent, so after a
1497
+ * switch it still holds whatever the previous agent last reported — and the
1498
+ * bar went on showing that conversation's numbers under a new agent's name
1499
+ * until the new one answered. `localUsage` had the same problem from the
1500
+ * other direction: it accumulates a session, and a session belongs to an
1501
+ * agent.
1502
+ *
1503
+ * So the local tally is cleared on a switch, and the store's snapshot is
1504
+ * ignored until it is replaced by a different object — which is the only
1505
+ * signal available that it is the new agent's and not the old one's.
1506
+ */
1507
+ const seenAgent = useRef(activeAgentId);
1508
+ const snapshotAtSwitch = useRef(null);
1509
+ const storeSnapshot = contextSnapshotQuery.data;
1510
+ const storeSnapshotRef = useRef(storeSnapshot);
1511
+ storeSnapshotRef.current = storeSnapshot;
1512
+ useEffect(() => {
1513
+ if (seenAgent.current === activeAgentId) {
1514
+ return;
1515
+ }
1516
+ seenAgent.current = activeAgentId;
1517
+ setLocalUsage(null);
1518
+ snapshotAtSwitch.current = storeSnapshotRef.current ?? null;
1519
+ }, [activeAgentId]);
1520
+ const freshStoreSnapshot = storeSnapshot && storeSnapshot !== snapshotAtSwitch.current
1521
+ ? storeSnapshot
1522
+ : undefined;
1523
+ const agentUsage = externalContextSnapshot ?? freshStoreSnapshot ?? localSnapshot;
1524
+ /*
1525
+ * Handed on to a host that draws its own prompt.
1526
+ *
1527
+ * The loop workspace is one: it renders the composer itself, so the usage
1528
+ * bar beside it can only show what this component passes out. Without this
1529
+ * an in-page agent — whose only account of the window is the totals the
1530
+ * harness reports here — left that bar permanently empty.
1531
+ */
1532
+ useEffect(() => {
1533
+ onContextSnapshot?.(agentUsage);
1534
+ }, [agentUsage, onContextSnapshot]);
1236
1535
  const sandboxStatusQuery = useSandbox(configQueriesEnabled && showHeader, protocol?.configEndpoint, protocol?.authToken, protocol?.agentId);
1237
1536
  // ---- Refs ----
1238
1537
  const adapterRef = useRef(null);
@@ -1266,6 +1565,36 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1266
1565
  const onToolCallCompleteRef = useRef(onToolCallComplete);
1267
1566
  onToolCallCompleteRef.current = onToolCallComplete;
1268
1567
  const handleRespondRef = useRef(null);
1568
+ // A decision made outside the chat — a host page's own approval banner —
1569
+ // is answered exactly as the tool card's buttons answer it: through the
1570
+ // run's continuation, addressed to the tool call the approval belongs to.
1571
+ useEffect(() => {
1572
+ let lastSeq = agentRuntimeStore.getState().toolDecisionRequest?.seq ?? 0;
1573
+ return agentRuntimeStore.subscribe(state => state.toolDecisionRequest, request => {
1574
+ if (!request || request.seq === lastSeq)
1575
+ return;
1576
+ lastSeq = request.seq;
1577
+ const respond = handleRespondRef.current;
1578
+ if (!respond)
1579
+ return;
1580
+ const normalize = (name) => (name ?? '').toLowerCase().replace(/[-_]/g, '');
1581
+ const calls = Array.from(toolCallsRef.current.values());
1582
+ // By the approval id the tool result carries, else by the tool
1583
+ // name of a call still waiting — the same two matches the card makes.
1584
+ const call = calls.find(entry => entry.result
1585
+ ?.approvalId === request.approvalId) ??
1586
+ calls.find(entry => normalize(entry.toolName) === normalize(request.toolName) &&
1587
+ (entry.status === 'executing' || entry.status === 'inProgress'));
1588
+ if (!call)
1589
+ return;
1590
+ void respond(call.toolCallId, {
1591
+ type: 'tool-approval-decision',
1592
+ approved: request.approved,
1593
+ approvalId: request.approvalId,
1594
+ toolName: call.toolName,
1595
+ });
1596
+ });
1597
+ }, []);
1269
1598
  const applyServerApprovalDecision = useCallback((approval, approved, note) => {
1270
1599
  if (!approval?.id) {
1271
1600
  return false;
@@ -1394,8 +1723,17 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1394
1723
  }, [adjustTextareaHeight]);
1395
1724
  // ---- Initialize model and tools when config is available ----
1396
1725
  useEffect(() => {
1397
- if ((configQuery.data || availableModels) && !selectedModel) {
1398
- const modelsList = availableModels || configQuery.data?.models || [];
1726
+ /*
1727
+ * `offeredModels`, not the two sources it is built from.
1728
+ *
1729
+ * It also carries the model an in-page agent was built with, for the case
1730
+ * where there is no config endpoint to ask — and this gate read the raw
1731
+ * sources, so that model was offered by the menu and never selected. The
1732
+ * menu draws nothing without a selection, so a browser agent had a model
1733
+ * list of one and no model control at all.
1734
+ */
1735
+ if (offeredModels.length > 0 && !selectedModel) {
1736
+ const modelsList = offeredModels;
1399
1737
  const preferredModel = initialModel || configQuery.data?.defaultModel;
1400
1738
  if (preferredModel) {
1401
1739
  const modelExists = modelsList.some(m => m.id === preferredModel);
@@ -1439,6 +1777,7 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1439
1777
  }
1440
1778
  }, [
1441
1779
  configQuery.data,
1780
+ offeredModels,
1442
1781
  selectedModel,
1443
1782
  initialModel,
1444
1783
  availableModels,
@@ -1729,6 +2068,10 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1729
2068
  }, [useStoreMode, runtimeId]);
1730
2069
  // ---- Conversation history loading ----
1731
2070
  const prevHistoryScopeRef = useRef(undefined);
2071
+ const historyVersionRef = useRef(0);
2072
+ // Set when the next load must come from a fresh snapshot, not the one in
2073
+ // the store: what the store holds is the transcript before the change.
2074
+ const freshSnapshotRef = useRef(false);
1732
2075
  useEffect(() => {
1733
2076
  if (historyScopeId !== prevHistoryScopeRef.current) {
1734
2077
  if (historyScopeId) {
@@ -1742,6 +2085,18 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1742
2085
  }
1743
2086
  if (!historyScopeId)
1744
2087
  return;
2088
+ if (historyVersion !== historyVersionRef.current) {
2089
+ historyVersionRef.current = historyVersion;
2090
+ if (historyVersion > 0) {
2091
+ // The transcript changed on the server outside a run — a rewind to a
2092
+ // checkpoint. Forget what is shown and load what the agent now has.
2093
+ useConversationStore.getState().clearMessages(historyScopeId);
2094
+ setDisplayItems([]);
2095
+ toolCallsRef.current.clear();
2096
+ historyRetryAttemptsRef.current.set(historyScopeId, 0);
2097
+ freshSnapshotRef.current = true;
2098
+ }
2099
+ }
1745
2100
  const store = useConversationStore.getState();
1746
2101
  const currentlyFetching = store.isFetching(historyScopeId);
1747
2102
  const storedMessages = store.getMessages(historyScopeId);
@@ -1770,7 +2125,10 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1770
2125
  store.markFetched(historyScopeId);
1771
2126
  setHistoryLoaded(true);
1772
2127
  };
1773
- const existingMessages = fullContextToMessages();
2128
+ const existingMessages = freshSnapshotRef.current
2129
+ ? []
2130
+ : fullContextToMessages();
2131
+ freshSnapshotRef.current = false;
1774
2132
  if (existingMessages.length > 0) {
1775
2133
  applyMessages(existingMessages);
1776
2134
  return;
@@ -1859,6 +2217,7 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1859
2217
  wsState,
1860
2218
  activeAgentId,
1861
2219
  historyRefreshTick,
2220
+ historyVersion,
1862
2221
  ]);
1863
2222
  // Keep in-memory store in sync with displayItems
1864
2223
  useEffect(() => {
@@ -1882,6 +2241,15 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1882
2241
  onMessagesChange?.(messages);
1883
2242
  }
1884
2243
  }, [displayItems, messages, onMessagesChange]);
2244
+ // Every change, streaming included — for a caller following the reply as
2245
+ // it arrives rather than counting messages. See `onItemsChange`.
2246
+ useEffect(() => {
2247
+ onItemsChange?.(displayItems.filter((item) => !isToolCallMessage(item)));
2248
+ }, [displayItems, onItemsChange]);
2249
+ // And everything, tool calls included — see `onDisplayItemsChange`.
2250
+ useEffect(() => {
2251
+ onDisplayItemsChange?.(displayItems);
2252
+ }, [displayItems, onDisplayItemsChange]);
1885
2253
  const padding = compact ? 2 : 3;
1886
2254
  // Derive approval config from protocol for built-in tool approval support
1887
2255
  const approvalConfig = useMemo(() => {
@@ -1912,12 +2280,42 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
1912
2280
  // surface and launching overlay still render; we simply do not connect.
1913
2281
  if (!autoConnect)
1914
2282
  return;
2283
+ // Nor when there is nothing to connect to. A browser sandbox has no agent
2284
+ // behind it, and dialling one would only produce errors the person cannot
2285
+ // act on — the header already says why the chat is off.
2286
+ if (disabled)
2287
+ return;
1915
2288
  const adapter = createProtocolAdapter(protocol);
1916
2289
  if (!adapter)
1917
2290
  return;
1918
2291
  adapterRef.current = adapter;
1919
2292
  setAdapterReady(true);
1920
2293
  unsubscribeRef.current = adapter.subscribe((event) => {
2294
+ /*
2295
+ * Nothing more from a turn the reader has stopped.
2296
+ *
2297
+ * Stopping aborts the request and asks the backend to cancel, and
2298
+ * neither is instant: an SSE stream already in flight keeps delivering,
2299
+ * and a model mid-sentence keeps being paid for tokens that are on the
2300
+ * wire. Until this guard, every one of those still ran through the
2301
+ * handler below — so the transcript went on typing itself for as long
2302
+ * as the turn had left, which is the whole of the "I pressed stop and
2303
+ * it kept going" report. `stoppedRef` was already set here and only two
2304
+ * places downstream ever read it.
2305
+ *
2306
+ * `state-update` and `error` are still let through: they carry the
2307
+ * connection's own condition rather than the turn's output, and a chat
2308
+ * that stops listening to those after a stop is a chat that cannot tell
2309
+ * you it has since disconnected. `done` too — it is what closes the
2310
+ * turn out; suppressing it would leave the session believing a stopped
2311
+ * turn is still running.
2312
+ */
2313
+ if (stoppedRef.current &&
2314
+ event.type !== 'state-update' &&
2315
+ event.type !== 'error' &&
2316
+ event.type !== 'done') {
2317
+ return;
2318
+ }
1921
2319
  switch (event.type) {
1922
2320
  case 'message':
1923
2321
  if (event.usage) {
@@ -2206,6 +2604,34 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2206
2604
  }
2207
2605
  break;
2208
2606
  case 'done':
2607
+ /*
2608
+ * What the turn cost, when nobody else is counting.
2609
+ *
2610
+ * A server-side agent reports its context through
2611
+ * `/configure/context`, and that answer wins. An in-page agent has
2612
+ * no server to ask — so the usage the harness reports here was the
2613
+ * only account of the window there was, and it was being dropped.
2614
+ * The bar and its ring simply never appeared for a browser agent.
2615
+ */
2616
+ {
2617
+ const turnInput = event.usage?.promptTokens ?? 0;
2618
+ const turnOutput = event.usage?.completionTokens ?? 0;
2619
+ // The parts sum to the total when the harness did not send one:
2620
+ // keying on `totalTokens` alone dropped turns whose provider
2621
+ // counted input and output but never totalled them.
2622
+ const total = event.usage?.totalTokens ?? turnInput + turnOutput;
2623
+ if (total > 0) {
2624
+ setLocalUsage(previous => ({
2625
+ turnInput,
2626
+ turnOutput,
2627
+ // Added up, not replaced: the session is every turn so far,
2628
+ // and the harness reports one turn at a time.
2629
+ sessionInput: (previous?.sessionInput ?? 0) + turnInput,
2630
+ sessionOutput: (previous?.sessionOutput ?? 0) + turnOutput,
2631
+ totalTokens: total,
2632
+ }));
2633
+ }
2634
+ }
2209
2635
  // The adapter signals the entire multi-turn conversation
2210
2636
  // (including all continuations) has finished.
2211
2637
  if (suppressAssistantTextForToolOnlyRef.current &&
@@ -2584,13 +3010,27 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2584
3010
  setIsLoading(false);
2585
3011
  setIsStreaming(false);
2586
3012
  agentRuntimeStore.getState().requestRefresh(activeAgentId);
3013
+ // The boxes under the delegation cards read the runtime store, not the
3014
+ // tool calls above; without this they keep their dots until the server's
3015
+ // own stop event arrives — if it ever does.
3016
+ agentRuntimeStore.getState().stopSubagentActivity();
2587
3017
  suppressAssistantTextForToolOnlyRef.current = false;
2588
3018
  currentAssistantMessageRef.current = null;
2589
3019
  // Also interrupt any code running in the sandbox (best-effort).
2590
3020
  sandboxStatusQuery.interrupt();
2591
- // Interrupt the connected notebook kernel as well (best-effort),
2592
- // matching the toolbar's stop/interrupt behavior.
2593
- if (kernel && kernel.status === 'busy') {
3021
+ /*
3022
+ * Interrupt the connected notebook kernel too, whatever it claims to be
3023
+ * doing.
3024
+ *
3025
+ * This used to fire only when `kernel.status === 'busy'`, and that status
3026
+ * is a value pushed from the server: a cell submitted a moment ago is
3027
+ * running while the client still reads `idle`, which is precisely the
3028
+ * window somebody hits Stop in. The check therefore skipped the interrupt
3029
+ * exactly when it was wanted. Interrupting an idle kernel costs nothing —
3030
+ * there is no execution to raise `KeyboardInterrupt` in — so the test was
3031
+ * only ever able to do harm.
3032
+ */
3033
+ if (kernel) {
2594
3034
  void kernel.interrupt().catch(() => { });
2595
3035
  }
2596
3036
  }, [
@@ -2615,6 +3055,39 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2615
3055
  onNewChat?.();
2616
3056
  headerButtons?.onNewChat?.();
2617
3057
  }, [clearStoreMessages, onNewChat, headerButtons, useStoreMode, runtimeId]);
3058
+ // Hand the send function to a host that owns the input box (the LOOP
3059
+ // workspace). Withdrawn on unmount so nothing holds a stale sender.
3060
+ useEffect(() => {
3061
+ if (!onSendReady)
3062
+ return undefined;
3063
+ if (!adapterReady && !onSendMessage) {
3064
+ onSendReady(null);
3065
+ return undefined;
3066
+ }
3067
+ onSendReady({
3068
+ send: (message) => {
3069
+ void handleSend(message);
3070
+ },
3071
+ stop: handleStop,
3072
+ // The same reset the header's + performs, for a host whose controls
3073
+ // live outside this component — the LOOP prompt's + reaches it here.
3074
+ newChat: handleNewChat,
3075
+ });
3076
+ return () => {
3077
+ onSendReady(null);
3078
+ };
3079
+ }, [
3080
+ onSendReady,
3081
+ adapterReady,
3082
+ onSendMessage,
3083
+ handleSend,
3084
+ handleStop,
3085
+ handleNewChat,
3086
+ ]);
3087
+ // Streaming state, for a host that draws the prompt.
3088
+ useEffect(() => {
3089
+ onLoadingChange?.(isLoading);
3090
+ }, [onLoadingChange, isLoading]);
2618
3091
  // ---- handleClear ----
2619
3092
  const handleClear = useCallback(() => {
2620
3093
  if (window.confirm('Clear all messages?')) {
@@ -2628,6 +3101,18 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2628
3101
  headerButtons?.onClear?.();
2629
3102
  }
2630
3103
  }, [clearStoreMessages, onClear, headerButtons, useStoreMode, runtimeId]);
3104
+ // ---- Turn removal (the TurnFooter's remove action) ----
3105
+ const handleRemoveItems = useCallback((ids) => {
3106
+ const drop = new Set(ids);
3107
+ setDisplayItems(prev => prev.filter(item => !drop.has(item.id)));
3108
+ // The tool-call registry mirrors the transcript; a removed turn's calls
3109
+ // must not linger there or a late protocol event would resurrect them.
3110
+ for (const [toolCallId, toolCall] of toolCallsRef.current.entries()) {
3111
+ if (drop.has(toolCall.id)) {
3112
+ toolCallsRef.current.delete(toolCallId);
3113
+ }
3114
+ }
3115
+ }, []);
2631
3116
  // ---- HITL respond handler (passed to MessageList) ----
2632
3117
  const handleRespond = useCallback(async (toolCallId, result) => {
2633
3118
  const existingToolCall = toolCallsRef.current.get(toolCallId);
@@ -2812,7 +3297,7 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2812
3297
  // Decision dispatch happens here; continuation is resumed on server echo.
2813
3298
  await onRejectApproval?.(approvalId, note);
2814
3299
  }, [onRejectApproval]);
2815
- // ---- Compute data for InputToolbar ----
3300
+ // ---- Compute data for the prompt ----
2816
3301
  // Merge real-time WebSocket MCP status into the cached config data so the
2817
3302
  // dropdown reflects live availability even when the config query was cached
2818
3303
  // before the MCP servers finished starting.
@@ -2875,6 +3360,17 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2875
3360
  return merged;
2876
3361
  }, [configMcpServers, effectiveMcpStatusData, mcpServers]);
2877
3362
  // ---- Not ready ----
3363
+ /*
3364
+ * The transcript's tool renderer: the host's own, or — when a notebook was
3365
+ * named — the built-in surfaces that show what each cell tool did. Baked
3366
+ * in here rather than in any workspace, so every chat with a headless
3367
+ * notebook gets the same transcript. Above the early return below, as
3368
+ * every hook must be.
3369
+ */
3370
+ const effectiveRenderToolResult = useMemo(() => renderToolResult ??
3371
+ (notebookToolSurfacesId
3372
+ ? notebookToolSurfacesRenderer(notebookToolSurfacesId)
3373
+ : undefined), [renderToolResult, notebookToolSurfacesId]);
2878
3374
  if (!ready) {
2879
3375
  return (_jsx(Box, { className: className, sx: {
2880
3376
  display: 'flex',
@@ -2896,8 +3392,21 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2896
3392
  const indicatorApiBase = protocol?.configEndpoint
2897
3393
  ? protocol.configEndpoint.replace(/\/api\/v1\/(config|configure)\/?$/, '')
2898
3394
  : undefined;
3395
+ /*
3396
+ * Whether the composer may be typed in.
3397
+ *
3398
+ * It waits for the config query because that is the round trip proving the
3399
+ * agent is reachable. The condition has to mirror `configQueriesEnabled`
3400
+ * exactly, though: a protocol that never runs the query has nothing to wait
3401
+ * for, and waiting anyway leaves the input `readOnly` for good — selectable,
3402
+ * focusable, and silently ignoring every keystroke.
3403
+ *
3404
+ * `=== false` was too narrow for that. A config that simply omits the flag —
3405
+ * an in-page agent has no endpoint to ask — is equally never going to
3406
+ * produce data.
3407
+ */
2899
3408
  const connectionConfirmed = !protocol ||
2900
- protocol.enableConfigQuery === false ||
3409
+ !protocol.enableConfigQuery ||
2901
3410
  !!configQuery.data ||
2902
3411
  !!skillsQuery.data;
2903
3412
  const resolvedDescription = description || configQuery.data?.welcomeMessage || '';
@@ -2906,26 +3415,112 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2906
3415
  ? suggestions
2907
3416
  : Array.isArray(serverSuggestions) && serverSuggestions.length > 0
2908
3417
  ? serverSuggestions
2909
- .map(item => String(item || '').trim())
2910
- .filter(Boolean)
2911
- .map(item => ({ title: item, message: item }))
3418
+ /*
3419
+ Either shape. A running agent may be older than the catalogue it
3420
+ was built from, where a suggestion was a bare string —
3421
+ `String(item)` on the mapping form yields "[object Object]",
3422
+ which is a chip that sends nonsense rather than one that is
3423
+ absent.
3424
+ */
3425
+ .map(item => {
3426
+ if (typeof item === 'string') {
3427
+ const text = item.trim();
3428
+ return { title: text, message: text };
3429
+ }
3430
+ const text = (item?.text ?? '').trim();
3431
+ // The summary is the label when the spec gave one.
3432
+ const summary = (item?.summary ?? '').trim();
3433
+ return { title: summary || text, message: text };
3434
+ })
3435
+ .filter(item => item.message)
2912
3436
  : undefined;
2913
3437
  const messagesContent = children ? (children) : (_jsx(Box, { sx: {
2914
3438
  display: 'flex',
2915
3439
  flexDirection: 'column',
2916
3440
  minHeight: 0,
3441
+ /*
3442
+ A reading column, not a full-bleed sheet.
3443
+
3444
+ The transcript keeps a book-page width and centres itself; on a
3445
+ narrow chat column the cap never binds and nothing changes. The
3446
+ rows inside carry their own horizontal padding, which becomes the
3447
+ margin once the cap does bind.
3448
+ */
3449
+ width: '100%',
3450
+ maxWidth: 920,
3451
+ mx: 'auto',
2917
3452
  bg: 'canvas.default',
2918
- }, children: _jsx(ChatMessageList, { displayItems: displayItems, isLoading: isLoading, isStreaming: isStreaming, showLoadingIndicator: showLoadingIndicator, hideMessagesAfterToolUI: hideMessagesAfterToolUI, avatarConfig: defaultAvatarConfig, padding: padding, renderToolResult: renderToolResult, approvalConfig: approvalConfig, messagesEndRef: messagesEndRef, onRespond: handleRespond, emptyContent: launching ? null : (_jsx(ChatEmptyState, { emptyState: emptyState, brandIcon: brandIcon, description: resolvedDescription, suggestions: resolvedSuggestions, submitOnSuggestionClick: submitOnSuggestionClick, onSuggestionSubmit: handleSuggestionSubmit, onSuggestionFill: handleSuggestionFill })) }) }));
2919
- const inputToolbar = showInput ? (_jsx(InputToolbar, { input: input, setInput: setInput, isLoading: isLoading, kernelStatus: liveKernelStatus, connectionConfirmed: connectionConfirmed, placeholder: placeholder, autoFocus: autoFocus, focusTrigger: focusTrigger, padding: padding, onSend: () => handleSend(), onStop: handleStop, disableInputPrompt: disableInputPrompt || !!overlay || launching, showTokenUsage: showTokenUsage, agentUsage: agentUsage, showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, codemodeEnabled: codemodeEnabled, onToggleCodemode: onToggleCodemode, isA2AProtocol: isA2AProtocol, hasConfigData: !!configQuery.data, hasSkillsData: !!skillsQuery.data, models: availableModels || configQuery.data?.models || [], selectedModel: selectedModel, onModelSelect: setSelectedModel, availableTools: configQuery.data?.builtinTools || [], mcpServers: filteredMcpServers, enabledMcpTools: enabledMcpTools, enabledMcpToolCount: getEnabledMcpToolNames().length, onToggleMcpTool: toggleMcpTool, onToggleAllMcpServerTools: toggleAllMcpServerTools, approvedMcpTools: approvedMcpTools, onToggleMcpToolApproval: toggleMcpToolApproval, skills: skillsQuery.data?.skills || [], skillsLoading: !!skillsQuery.isLoading, enabledSkills: enabledSkills, onToggleSkill: toggleSkill, onToggleAllSkills: toggleAllSkills, approvedSkills: approvedSkills, onToggleSkillApproval: toggleSkillApproval, apiBase: indicatorApiBase, authToken: protocol?.authToken, mcpStatusData: effectiveMcpStatusData })) : null;
3453
+ }, children: _jsx(ChatMessageList, { displayItems: displayItems, isLoading: isLoading, isStreaming: isStreaming, showLoadingIndicator: showLoadingIndicator, hideMessagesAfterToolUI: hideMessagesAfterToolUI, avatarConfig: defaultAvatarConfig, padding: padding, renderToolResult: effectiveRenderToolResult, approvalConfig: approvalConfig, messagesEndRef: messagesEndRef, onRespond: handleRespond, showTurnFooters: showTurnFooter, agentUsage: agentUsage, onRemoveItems: handleRemoveItems, emptyContent: launching ? null : (_jsx(ChatEmptyState, { emptyState: emptyState, brandIcon: brandIcon, description: resolvedDescription, suggestions: resolvedSuggestions, submitOnSuggestionClick: submitOnSuggestionClick, onSuggestionSubmit: handleSuggestionSubmit, onSuggestionFill: handleSuggestionFill })) }) }));
3454
+ const inputToolbar = showInput ? (_jsx(InputPrompt, { input: input, setInput: setInput, isLoading: isLoading, kernelStatus: liveKernelStatus, connectionConfirmed: connectionConfirmed, placeholder: placeholder,
3455
+ /*
3456
+ The same openers the empty state offers, typed into the box they would
3457
+ be typed into.
3458
+
3459
+ `message` rather than `title`: the animation is meant to look like
3460
+ somebody typing, and what they would have typed is the message the
3461
+ chip sends, not the label on it.
3462
+ */
3463
+ typingSuggestions: resolvedSuggestions?.map(item => item.message || item.title), autoFocus: autoFocus, focusTrigger: focusTrigger, padding: padding, onSend: () => handleSend(), onStop: handleStop, disableInputPrompt: disableInputPrompt || disabled || !!overlay || launching, promptVariant: promptVariant, mentionableAgents: mentionableAgents,
3464
+ // The runtime's memory of what was sent to this agent, for the arrow
3465
+ // keys — part of the same initial state as the models and tools.
3466
+ promptHistory: configQuery.data?.promptHistory, showTokenUsage: showTokenUsage, showContextRing: showContextRing, agentUsage: agentUsage, showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, codemodeEnabled: codemodeEnabled, onToggleCodemode: onToggleCodemode, isA2AProtocol: isA2AProtocol, showAgentsMenu: showAgentsMenu, agents: footerAgents, selectedAgentId: selectedAgentId ?? footerAgents[0]?.id, onSelectAgent: onSelectAgent, hasConfigData: !!configQuery.data, hasSkillsData: !!skillsQuery.data,
3467
+ // So the bar can tell "not here yet" from "not coming": a chat whose
3468
+ // agent has no config endpoint waits for ever otherwise.
3469
+ configLoading: configQuery.isLoading, models: offeredModels, selectedModel: selectedModel, onModelSelect: setSelectedModel, availableTools: builtinTools, mcpServers: filteredMcpServers, enabledMcpTools: enabledMcpTools, enabledMcpToolCount: getEnabledMcpToolNames().length, onToggleMcpTool: toggleMcpTool, onToggleAllMcpServerTools: toggleAllMcpServerTools, approvedMcpTools: approvedMcpTools, onToggleMcpToolApproval: toggleMcpToolApproval, skills: skillsQuery.data?.skills || [], skillsLoading: !!skillsQuery.isLoading, enabledSkills: enabledSkills, onToggleSkill: toggleSkill, onToggleAllSkills: toggleAllSkills, approvedSkills: approvedSkills, onToggleSkillApproval: toggleSkillApproval, apiBase: indicatorApiBase, authToken: protocol?.authToken, mcpStatusData: effectiveMcpStatusData })) : null;
2920
3470
  // Shared header element. It is rendered either at the top of the chat (when
2921
3471
  // no ephemeral notebook is shown) or INSIDE the chat body column (when the
2922
3472
  // notebook is visible) so the header always follows the chat body across all
2923
3473
  // view modes (docked sidebar, floating popup, floating-small).
2924
- const chatHeaderElement = showHeader ? (_jsx(ChatBaseHeader, { title: title, subtitle: subtitle, brandIcon: brandIcon, headerContent: headerContent, headerActions: headerActions, showInformation: showInformation, onInformationClick: onInformationClick, padding: padding, kernelIndicatorState: kernelIndicatorState, kernelIndicatorPlacement: kernelIndicatorPlacement, runtimeStatus: sandboxStatusData ?? sandboxStatusQuery.data, kernel: notebookVisible
3474
+ //
3475
+ // Assembled as a props object first: `renderHeader` lets a host take these
3476
+ // exact props — kernel indicator, runtime status, actions, all of it — and
3477
+ // draw the bar itself. The loop's chat-header plugin is that host: the
3478
+ // header then *arrives as a plugin* without this component re-deriving any
3479
+ // of what only it knows.
3480
+ const chatHeaderProps = {
3481
+ title,
3482
+ subtitle,
3483
+ disableReason: disabled ? disableReason : undefined,
3484
+ brandIcon,
3485
+ headerContent,
3486
+ headerActions,
3487
+ showInformation,
3488
+ /*
3489
+ A default, so the button does something.
3490
+
3491
+ `showInformation` drew an (i) and then forwarded a click to whatever
3492
+ the host supplied — and a host that supplied nothing got a button that
3493
+ did nothing at all, which is worse than no button. `Chat` still passes
3494
+ its own handler and keeps its own pane; everything else gets this one.
3495
+ */
3496
+ onInformationClick: onInformationClick ?? (() => setShowDetails(true)),
3497
+ padding,
3498
+ kernelIndicatorState,
3499
+ kernelIndicatorPlacement,
3500
+ runtimeStatus: sandboxStatusData ?? sandboxStatusQuery.data,
3501
+ kernel: notebookVisible
2925
3502
  ? (notebookKernel ?? kernel)
2926
3503
  : documentVisible
2927
3504
  ? (documentKernel ?? kernel)
2928
- : kernel, kernelEnvironmentName: kernelEnvironmentName, kernelCpu: kernelCpu, kernelMemory: kernelMemory, kernelGpu: kernelGpu, headerButtons: headerButtons, messageCount: messages.length, onNewChat: handleNewChat, onClear: handleClear, chatViewMode: chatViewMode, onChatViewModeChange: onChatViewModeChange, showEphemeralSurfaceControl: enableEphemeralNotebook || enableEphemeralDocument, enableEphemeralNotebookOption: enableEphemeralNotebook, enableEphemeralDocumentOption: enableEphemeralDocument, ephemeralSurfaceMode: ephemeralSurfaceMode, onEphemeralSurfaceModeChange: handleEphemeralSurfaceModeChange })) : null;
3505
+ : kernel,
3506
+ kernelEnvironmentName,
3507
+ kernelCpu,
3508
+ kernelMemory,
3509
+ kernelGpu,
3510
+ headerButtons,
3511
+ messageCount: messages.length,
3512
+ onNewChat: handleNewChat,
3513
+ onClear: handleClear,
3514
+ chatViewMode,
3515
+ onChatViewModeChange,
3516
+ disabledViewModes,
3517
+ showEphemeralSurfaceControl: enableEphemeralNotebook || enableEphemeralDocument,
3518
+ enableEphemeralNotebookOption: enableEphemeralNotebook,
3519
+ enableEphemeralDocumentOption: enableEphemeralDocument,
3520
+ ephemeralSurfaceMode,
3521
+ onEphemeralSurfaceModeChange: handleEphemeralSurfaceModeChange,
3522
+ };
3523
+ const chatHeaderElement = showHeader ? (renderHeader ? (renderHeader(chatHeaderProps)) : (_jsx(ChatBaseHeader, { ...chatHeaderProps }))) : null;
2929
3524
  // ========================================================================
2930
3525
  // Render
2931
3526
  // ========================================================================
@@ -2936,12 +3531,46 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2936
3531
  height: '100%',
2937
3532
  maxHeight: '100%',
2938
3533
  minHeight: 0,
3534
+ /*
3535
+ As wide as the host, always.
3536
+
3537
+ The root set its height and said nothing about width, so mounted in
3538
+ a flex row — which is how the LOOP chat mounts it — it was a
3539
+ shrink-to-fit item: as wide as its widest line and no wider,
3540
+ anchored to the left of a row it should have filled, and re-sizing
3541
+ with every streamed chunk. That is what made the person's own
3542
+ bubble drift while the agent answered. A chat fills the column it
3543
+ is given; the column decides the width, not the transcript.
3544
+ */
3545
+ flex: '1 1 auto',
3546
+ width: '100%',
3547
+ minWidth: 0,
2939
3548
  bg: backgroundColor || 'canvas.default',
2940
3549
  borderRadius,
2941
3550
  border,
2942
3551
  boxShadow,
2943
3552
  overflow: 'hidden',
2944
- }, children: [!surfaceVisible && chatHeaderElement, showToolApprovalBanner &&
3553
+ }, children: [!surfaceVisible && chatHeaderElement, showDetails && (
3554
+ /*
3555
+ A column, not a row.
3556
+
3557
+ This is a flex container holding one child, and `AgentDetails` sets a
3558
+ height but no width — so in a row it was a flex item with `flex-basis:
3559
+ auto` and no grow, which is to say it was as wide as its longest line
3560
+ of text and no wider. On the LOOP workspace, where the chat column is
3561
+ already narrow, that read as the panel occupying half the space it was
3562
+ given, with the rest of the surface blank beside it.
3563
+
3564
+ Turning the axis makes width the *cross* axis, and a flex item
3565
+ stretches across that by default. `Chat.tsx` mounts the same component
3566
+ the same way and has always looked right for exactly this reason.
3567
+ */
3568
+ _jsx(Box, { sx: {
3569
+ flex: '1 1 auto',
3570
+ minHeight: 0,
3571
+ display: 'flex',
3572
+ flexDirection: 'column',
3573
+ }, children: _jsx(AgentDetails, { name: title || 'AI Agent', icon: brandIcon, protocol: protocol?.type ?? 'unknown', url: protocol?.endpoint || '', messageCount: displayItems.length, agentId: activeAgentId, apiBase: protocol?.configEndpoint, onBack: () => setShowDetails(false) }) })), showToolApprovalBanner &&
2945
3574
  pendingApprovals &&
2946
3575
  pendingApprovals.length > 0 && (_jsx(ToolApprovalBannerSection, { pendingApprovals: pendingApprovals, onApprove: handleBannerApprove, onReject: handleBannerReject })), showErrors && error && (_jsxs(Box, { sx: {
2947
3576
  display: 'flex',
@@ -2972,13 +3601,13 @@ showToolApprovalBanner = true, pendingApprovals: pendingApprovalsProp, onApprove
2972
3601
  borderRight: '1px solid',
2973
3602
  borderColor: 'border.default',
2974
3603
  }),
2975
- }, children: launching || overlay ? (_jsx(CompanionSurfaceSkeleton, { mode: notebookVisible ? 'notebook' : 'document' })) : notebookVisible ? (_jsx(EphemeralNotebook, { notebookId: ephemeralNotebookId, runtimePodName: runtimeId || activeAgentId, runtimeOverride: ephemeralRuntimeOverride, themeVariant: themeVariant, colorMode: colorMode, nbformat: persistedEphemeralNbformat ?? undefined, onNbformatChange: handleEphemeralNotebookChange, toolbarComponent: ephemeralNotebookToolbar, toolbarExtraItems: ephemeralNotebookToolbarExtraItems, collaborationProvider: ephemeralNotebookCollaborationProvider })) : (_jsx(React.Suspense, { fallback: null, children: _jsx(EphemeralDocument, { documentId: ephemeralDocumentId, runtimePodName: runtimeId || activeAgentId, runtimeOverride: ephemeralRuntimeOverride, themeVariant: themeVariant, colorMode: colorMode, content: persistedEphemeralDocument ?? undefined, onContentChange: handleEphemeralDocumentChange, onToolsReady: handleDocumentToolsReady, onKernelChange: handleDocumentKernelChange, collaboration: ephemeralDocumentCollaboration, toolbarExtraItems: ephemeralDocumentToolbarExtraItems }) })) }), !surfaceCollapsed && (_jsxs(Box, { sx: surfaceChatFloating
3604
+ }, children: launching || overlay ? (_jsx(CompanionSurfaceSkeleton, { mode: notebookVisible ? 'notebook' : 'document' })) : notebookVisible ? (_jsx(EphemeralNotebook, { notebookId: ephemeralNotebookId, runtimeName: runtimeId || activeAgentId, runtimeOverride: ephemeralRuntimeOverride, themeVariant: themeVariant, colorMode: colorMode, nbformat: persistedEphemeralNbformat ?? undefined, onNbformatChange: handleEphemeralNotebookChange, toolbarComponent: ephemeralNotebookToolbar, toolbarExtraItems: notebookToolbarItems, collaborationProvider: ephemeralNotebookCollaborationProvider })) : (_jsx(React.Suspense, { fallback: null, children: _jsx(EphemeralDocument, { documentId: ephemeralDocumentId, runtimeName: runtimeId || activeAgentId, runtimeOverride: ephemeralRuntimeOverride, themeVariant: themeVariant, colorMode: colorMode, content: persistedEphemeralDocument ?? undefined, onContentChange: handleEphemeralDocumentChange, onToolsReady: handleDocumentToolsReady, onKernelChange: handleDocumentKernelChange, collaboration: ephemeralDocumentCollaboration, toolbarExtraItems: documentToolbarItems }) })) }), !surfaceCollapsed && (_jsxs(Box, { sx: surfaceChatFloating
2976
3605
  ? {
2977
3606
  position: 'absolute',
2978
3607
  right: 16,
2979
- width: chatViewMode === 'floating-small' ? 360 : 440,
3608
+ width: compactFloating ? 360 : 440,
2980
3609
  maxWidth: 'calc(100% - 32px)',
2981
- ...(chatViewMode === 'floating-small'
3610
+ ...(compactFloating
2982
3611
  ? { bottom: 16, height: '62%' }
2983
3612
  : { top: 16, bottom: 16 }),
2984
3613
  display: 'flex',