@datalayer/agent-runtimes 1.0.4 → 1.0.6

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 (299) hide show
  1. package/README.md +182 -1
  2. package/lib/AgentNode.d.ts +3 -0
  3. package/lib/AgentNode.js +676 -0
  4. package/lib/App.js +1 -1
  5. package/lib/agent-node/themeStore.d.ts +3 -0
  6. package/lib/agent-node/themeStore.js +156 -0
  7. package/lib/agent-node-main.d.ts +1 -0
  8. package/lib/agent-node-main.js +14 -0
  9. package/lib/agents/AgentDetails.d.ts +22 -1
  10. package/lib/agents/AgentDetails.js +34 -47
  11. package/lib/api/index.d.ts +0 -1
  12. package/lib/api/index.js +4 -2
  13. package/lib/chat/Chat.d.ts +5 -106
  14. package/lib/chat/Chat.js +20 -14
  15. package/lib/chat/ChatFloating.d.ts +7 -140
  16. package/lib/chat/ChatFloating.js +3 -3
  17. package/lib/chat/ChatPopupStandalone.d.ts +8 -47
  18. package/lib/chat/ChatPopupStandalone.js +3 -3
  19. package/lib/chat/ChatSidebar.d.ts +4 -69
  20. package/lib/chat/ChatSidebar.js +83 -51
  21. package/lib/chat/ChatStandalone.d.ts +4 -54
  22. package/lib/chat/ChatStandalone.js +3 -3
  23. package/lib/chat/base/ChatBase.js +1414 -174
  24. package/lib/chat/display/FloatingBrandButton.js +8 -1
  25. package/lib/chat/header/ChatHeader.d.ts +3 -1
  26. package/lib/chat/header/ChatHeader.js +15 -12
  27. package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
  28. package/lib/chat/header/ChatHeaderBase.js +41 -16
  29. package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
  30. package/lib/chat/indicators/McpStatusIndicator.js +7 -32
  31. package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
  32. package/lib/chat/indicators/SandboxStatusIndicator.js +91 -56
  33. package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
  34. package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
  35. package/lib/chat/indicators/index.d.ts +1 -0
  36. package/lib/chat/indicators/index.js +1 -0
  37. package/lib/chat/messages/ChatMessageList.d.ts +1 -1
  38. package/lib/chat/messages/ChatMessageList.js +154 -114
  39. package/lib/chat/messages/ChatMessages.js +6 -2
  40. package/lib/chat/prompt/InputFooter.d.ts +21 -6
  41. package/lib/chat/prompt/InputFooter.js +76 -20
  42. package/lib/chat/prompt/InputPrompt.d.ts +5 -1
  43. package/lib/chat/prompt/InputPrompt.js +4 -4
  44. package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
  45. package/lib/chat/prompt/InputPromptFooter.js +3 -3
  46. package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
  47. package/lib/chat/prompt/InputPromptLexical.js +12 -5
  48. package/lib/chat/prompt/InputPromptText.d.ts +3 -1
  49. package/lib/chat/prompt/InputPromptText.js +2 -2
  50. package/lib/chat/tools/ToolApprovalBanner.js +1 -1
  51. package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
  52. package/lib/chat/tools/ToolCallDisplay.js +2 -2
  53. package/lib/chat/usage/TokenUsageBar.js +20 -2
  54. package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
  55. package/lib/client/AgentRuntimesClientContext.js +55 -0
  56. package/lib/client/AgentsMixin.d.ts +0 -18
  57. package/lib/client/AgentsMixin.js +20 -30
  58. package/lib/client/IAgentRuntimesClient.d.ts +215 -0
  59. package/lib/client/IAgentRuntimesClient.js +5 -0
  60. package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
  61. package/lib/client/SdkAgentRuntimesClient.js +134 -0
  62. package/lib/client/index.d.ts +4 -1
  63. package/lib/client/index.js +3 -1
  64. package/lib/components/NotificationEventCard.js +5 -1
  65. package/lib/config/AgentConfiguration.d.ts +22 -0
  66. package/lib/config/AgentConfiguration.js +319 -64
  67. package/lib/context/ContextDistribution.d.ts +3 -1
  68. package/lib/context/ContextDistribution.js +8 -27
  69. package/lib/context/ContextInspector.d.ts +3 -1
  70. package/lib/context/ContextInspector.js +19 -67
  71. package/lib/context/ContextPanel.d.ts +3 -1
  72. package/lib/context/ContextPanel.js +104 -64
  73. package/lib/context/ContextUsage.d.ts +3 -1
  74. package/lib/context/ContextUsage.js +3 -3
  75. package/lib/context/CostTracker.d.ts +9 -3
  76. package/lib/context/CostTracker.js +26 -47
  77. package/lib/context/CostUsageChart.d.ts +12 -0
  78. package/lib/context/CostUsageChart.js +378 -0
  79. package/lib/context/GraphFlowChart.d.ts +16 -0
  80. package/lib/context/GraphFlowChart.js +182 -0
  81. package/lib/context/TokenUsageChart.d.ts +8 -1
  82. package/lib/context/TokenUsageChart.js +349 -211
  83. package/lib/context/TurnGraphChart.d.ts +39 -0
  84. package/lib/context/TurnGraphChart.js +538 -0
  85. package/lib/context/otelWsPool.d.ts +20 -0
  86. package/lib/context/otelWsPool.js +69 -0
  87. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
  88. package/lib/examples/A2UiComponentGalleryExample.js +315 -522
  89. package/lib/examples/A2UiContactCardExample.d.ts +0 -18
  90. package/lib/examples/A2UiContactCardExample.js +154 -411
  91. package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
  92. package/lib/examples/A2UiRestaurantExample.js +114 -212
  93. package/lib/examples/A2UiViewerExample.d.ts +0 -18
  94. package/lib/examples/A2UiViewerExample.js +283 -532
  95. package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
  96. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
  97. package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
  98. package/lib/examples/AgUiSharedStateExample.js +2 -1
  99. package/lib/examples/AgentCheckpointsExample.js +14 -28
  100. package/lib/examples/AgentCodemodeExample.d.ts +4 -6
  101. package/lib/examples/AgentCodemodeExample.js +603 -169
  102. package/lib/examples/AgentEvalsExample.js +339 -53
  103. package/lib/examples/AgentGuardrailsExample.js +383 -66
  104. package/lib/examples/AgentHooksExample.d.ts +3 -0
  105. package/lib/examples/AgentHooksExample.js +122 -0
  106. package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
  107. package/lib/examples/AgentInferenceProviderExample.js +329 -0
  108. package/lib/examples/AgentMCPExample.d.ts +3 -0
  109. package/lib/examples/AgentMCPExample.js +481 -0
  110. package/lib/examples/AgentMemoryExample.d.ts +1 -2
  111. package/lib/examples/AgentMemoryExample.js +78 -33
  112. package/lib/examples/AgentMonitoringExample.js +261 -200
  113. package/lib/examples/AgentNotificationsExample.d.ts +1 -2
  114. package/lib/examples/AgentNotificationsExample.js +114 -33
  115. package/lib/examples/AgentOtelExample.js +32 -42
  116. package/lib/examples/AgentOutputsExample.d.ts +11 -6
  117. package/lib/examples/AgentOutputsExample.js +433 -81
  118. package/lib/examples/AgentParametersExample.d.ts +3 -0
  119. package/lib/examples/AgentParametersExample.js +248 -0
  120. package/lib/examples/AgentSandboxExample.d.ts +3 -3
  121. package/lib/examples/AgentSandboxExample.js +74 -45
  122. package/lib/examples/AgentSkillsExample.js +95 -103
  123. package/lib/examples/AgentSubagentsExample.d.ts +14 -0
  124. package/lib/examples/AgentSubagentsExample.js +228 -0
  125. package/lib/examples/AgentToolApprovalsExample.js +49 -561
  126. package/lib/examples/AgentTriggersExample.js +823 -569
  127. package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
  128. package/lib/examples/AgentspecsExample.js +1096 -0
  129. package/lib/examples/ChatCustomExample.js +16 -28
  130. package/lib/examples/ChatExample.js +13 -29
  131. package/lib/examples/CopilotKitLexicalExample.js +2 -1
  132. package/lib/examples/CopilotKitNotebookExample.js +2 -1
  133. package/lib/examples/HomeExample.d.ts +15 -0
  134. package/lib/examples/HomeExample.js +77 -0
  135. package/lib/examples/Lexical2Example.js +4 -2
  136. package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
  137. package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +66 -17
  138. package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
  139. package/lib/examples/LexicalAgentSidebarExample.js +261 -0
  140. package/lib/examples/NotebookAgentExample.d.ts +9 -0
  141. package/lib/examples/NotebookAgentExample.js +192 -0
  142. package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
  143. package/lib/examples/NotebookAgentSidebarExample.js +221 -0
  144. package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
  145. package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
  146. package/lib/examples/NotebookExample.d.ts +4 -7
  147. package/lib/examples/NotebookExample.js +14 -146
  148. package/lib/examples/components/AuthRequiredView.d.ts +6 -0
  149. package/lib/examples/components/AuthRequiredView.js +33 -0
  150. package/lib/examples/components/ExampleWrapper.d.ts +9 -3
  151. package/lib/examples/components/ExampleWrapper.js +45 -9
  152. package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
  153. package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
  154. package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
  155. package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
  156. package/lib/examples/components/index.d.ts +3 -0
  157. package/lib/examples/components/index.js +4 -0
  158. package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
  159. package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
  160. package/lib/examples/example-selector.d.ts +17 -4
  161. package/lib/examples/example-selector.js +108 -41
  162. package/lib/examples/index.d.ts +10 -6
  163. package/lib/examples/index.js +10 -6
  164. package/lib/examples/lexical/initial-content.json +6 -6
  165. package/lib/examples/main.js +257 -27
  166. package/lib/examples/utils/a2ui.d.ts +18 -0
  167. package/lib/examples/utils/a2ui.js +69 -0
  168. package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
  169. package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
  170. package/lib/examples/utils/agentId.d.ts +18 -0
  171. package/lib/examples/utils/agentId.js +54 -0
  172. package/lib/examples/utils/agents/earthquake-detector.json +11 -11
  173. package/lib/examples/utils/agents/sales-forecaster.json +11 -11
  174. package/lib/examples/utils/agents/social-post-generator.json +11 -11
  175. package/lib/examples/utils/agents/stock-market.json +11 -11
  176. package/lib/examples/utils/examplesStore.js +82 -27
  177. package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
  178. package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
  179. package/lib/hooks/index.d.ts +8 -8
  180. package/lib/hooks/index.js +7 -7
  181. package/lib/hooks/useA2A.d.ts +2 -3
  182. package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
  183. package/lib/hooks/useAIAgentsWebSocket.js +153 -12
  184. package/lib/hooks/useAcp.d.ts +1 -2
  185. package/lib/hooks/useAgUi.d.ts +1 -1
  186. package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +70 -4
  187. package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
  188. package/lib/hooks/useAgentsCatalog.js +1 -1
  189. package/lib/hooks/useAgentsService.d.ts +2 -2
  190. package/lib/hooks/useAgentsService.js +7 -7
  191. package/lib/hooks/useCheckpoints.js +1 -1
  192. package/lib/hooks/useConfig.d.ts +4 -1
  193. package/lib/hooks/useConfig.js +10 -3
  194. package/lib/hooks/useContextSnapshot.d.ts +9 -4
  195. package/lib/hooks/useContextSnapshot.js +9 -37
  196. package/lib/hooks/useMonitoring.js +3 -0
  197. package/lib/hooks/useSandbox.d.ts +20 -8
  198. package/lib/hooks/useSandbox.js +105 -40
  199. package/lib/hooks/useSkills.d.ts +23 -5
  200. package/lib/hooks/useSkills.js +94 -39
  201. package/lib/hooks/useToolApprovals.d.ts +60 -36
  202. package/lib/hooks/useToolApprovals.js +318 -69
  203. package/lib/hooks/useVercelAI.d.ts +1 -1
  204. package/lib/index.d.ts +2 -1
  205. package/lib/index.js +1 -0
  206. package/lib/inference/index.d.ts +0 -1
  207. package/lib/middleware/index.d.ts +0 -1
  208. package/lib/protocols/AGUIAdapter.js +6 -0
  209. package/lib/protocols/VercelAIAdapter.d.ts +7 -0
  210. package/lib/protocols/VercelAIAdapter.js +59 -7
  211. package/lib/specs/agents/agents.d.ts +21 -4
  212. package/lib/specs/agents/agents.js +2879 -316
  213. package/lib/specs/agents/index.js +3 -1
  214. package/lib/specs/benchmarks.d.ts +20 -0
  215. package/lib/specs/benchmarks.js +205 -0
  216. package/lib/specs/envvars.js +27 -20
  217. package/lib/specs/evals.d.ts +10 -9
  218. package/lib/specs/evals.js +128 -88
  219. package/lib/specs/events.d.ts +3 -10
  220. package/lib/specs/events.js +127 -84
  221. package/lib/specs/frontendTools.js +2 -2
  222. package/lib/specs/guardrails.d.ts +0 -7
  223. package/lib/specs/guardrails.js +240 -159
  224. package/lib/specs/mcpServers.js +35 -6
  225. package/lib/specs/memory.d.ts +0 -2
  226. package/lib/specs/memory.js +4 -17
  227. package/lib/specs/models.d.ts +0 -2
  228. package/lib/specs/models.js +20 -15
  229. package/lib/specs/notifications.js +102 -18
  230. package/lib/specs/outputs.js +15 -9
  231. package/lib/specs/personas.d.ts +41 -0
  232. package/lib/specs/personas.js +168 -0
  233. package/lib/specs/skills.d.ts +1 -1
  234. package/lib/specs/skills.js +23 -23
  235. package/lib/specs/teams/index.js +3 -1
  236. package/lib/specs/teams/teams.js +468 -348
  237. package/lib/specs/tools.js +4 -4
  238. package/lib/specs/triggers.js +61 -11
  239. package/lib/stores/agentRuntimeStore.d.ts +208 -0
  240. package/lib/stores/agentRuntimeStore.js +650 -0
  241. package/lib/stores/conversationStore.js +2 -2
  242. package/lib/stores/index.d.ts +1 -1
  243. package/lib/stores/index.js +1 -1
  244. package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
  245. package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
  246. package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
  247. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
  248. package/lib/tools/index.d.ts +0 -2
  249. package/lib/tools/index.js +0 -1
  250. package/lib/types/agents-lifecycle.d.ts +18 -0
  251. package/lib/types/agents.d.ts +6 -0
  252. package/lib/types/agentspecs.d.ts +54 -1
  253. package/lib/types/benchmarks.d.ts +43 -0
  254. package/lib/types/benchmarks.js +5 -0
  255. package/lib/types/chat.d.ts +325 -8
  256. package/lib/types/context.d.ts +27 -0
  257. package/lib/types/cost.d.ts +2 -2
  258. package/lib/types/evals.d.ts +26 -17
  259. package/lib/types/index.d.ts +3 -0
  260. package/lib/types/index.js +3 -0
  261. package/lib/types/mcp.d.ts +8 -0
  262. package/lib/types/models.d.ts +2 -2
  263. package/lib/types/personas.d.ts +25 -0
  264. package/lib/types/personas.js +5 -0
  265. package/lib/types/skills.d.ts +43 -1
  266. package/lib/types/stream.d.ts +110 -0
  267. package/lib/types/stream.js +36 -0
  268. package/lib/utils/utils.d.ts +9 -5
  269. package/lib/utils/utils.js +9 -5
  270. package/package.json +19 -11
  271. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  272. package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
  273. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  274. package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
  275. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  276. package/scripts/codegen/generate_agents.py +187 -45
  277. package/scripts/codegen/generate_benchmarks.py +441 -0
  278. package/scripts/codegen/generate_evals.py +94 -16
  279. package/scripts/codegen/generate_events.py +35 -14
  280. package/scripts/codegen/generate_personas.py +319 -0
  281. package/scripts/codegen/generate_skills.py +9 -9
  282. package/scripts/sync-jupyter.sh +26 -7
  283. package/lib/api/tool-approvals.d.ts +0 -62
  284. package/lib/api/tool-approvals.js +0 -145
  285. package/lib/examples/AgentspecExample.js +0 -705
  286. package/lib/examples/LexicalSidebarExample.js +0 -163
  287. package/lib/examples/NotebookSidebarExample.js +0 -119
  288. package/lib/examples/NotebookSimpleExample.d.ts +0 -6
  289. package/lib/examples/NotebookSimpleExample.js +0 -22
  290. package/lib/examples/ag-ui/index.d.ts +0 -10
  291. package/lib/examples/ag-ui/index.js +0 -16
  292. package/lib/hooks/useAgentsRegistry.d.ts +0 -10
  293. package/lib/hooks/useAgentsRegistry.js +0 -20
  294. package/lib/stores/agentsStore.d.ts +0 -123
  295. package/lib/stores/agentsStore.js +0 -270
  296. /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
  297. /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
  298. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
  299. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
@@ -0,0 +1,221 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ /**
7
+ * Agent Runtime Notebook Example - Next generation chat with Jupyter Notebook.
8
+ *
9
+ * This example demonstrates using the chat component with:
10
+ * - Jupyter Notebook integration
11
+ * - Frontend tool execution for notebook operations
12
+ * - AG-UI protocol support
13
+ * - HITL (Human-in-the-loop) tool approval
14
+ *
15
+ * To run this example:
16
+ * 1. Start the agent-runtimes server: `npm run start:ag-ui`
17
+ * 2. Create a .env file with VITE_BASE_URL if not using defaults
18
+ *
19
+ * @module examples/NotebookAgentSidebarExample
20
+ */
21
+ import { useEffect, useMemo, useState } from 'react';
22
+ import { Box } from '@datalayer/primer-addons';
23
+ import { Notebook, useJupyter } from '@datalayer/jupyter-react';
24
+ import { useNotebookTools } from '../tools/adapters/agent-runtimes/notebookHooks';
25
+ import { ThemedJupyterProvider } from './utils/themedProvider';
26
+ import { ChatSidebar } from '../chat';
27
+ import { DEFAULT_MODEL } from '../specs';
28
+ import MatplotlibNotebook from './utils/notebooks/Matplotlib.ipynb.json';
29
+ // Fixed notebook ID
30
+ const NOTEBOOK_ID = 'chat-notebook-example';
31
+ // Use the imported Matplotlib notebook
32
+ const NOTEBOOK_CONTENT = MatplotlibNotebook;
33
+ // Default configuration
34
+ const DEFAULT_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
35
+ const DEFAULT_AGENT_ID = import.meta.env.VITE_AGENT_ID || 'notebook-sidebar-agent-runtime-example';
36
+ const VERCEL_AI_ENDPOINT = `${DEFAULT_BASE_URL}/api/v1/vercel-ai/${DEFAULT_AGENT_ID}`;
37
+ function getJupyterSandboxUrl(serviceManager) {
38
+ const envUrl = import.meta.env.VITE_JUPYTER_SANDBOX_URL;
39
+ if (envUrl) {
40
+ return envUrl;
41
+ }
42
+ const baseUrl = serviceManager?.serverSettings?.baseUrl?.replace(/\/$/, '');
43
+ if (!baseUrl) {
44
+ return undefined;
45
+ }
46
+ if (baseUrl.includes('token=')) {
47
+ return baseUrl;
48
+ }
49
+ const token = serviceManager?.serverSettings?.token;
50
+ if (!token) {
51
+ return baseUrl;
52
+ }
53
+ const separator = baseUrl.includes('?') ? '&' : '?';
54
+ return `${baseUrl}${separator}token=${encodeURIComponent(token)}`;
55
+ }
56
+ function useEnsureAgent(agentId, baseUrl, jupyterSandboxUrl) {
57
+ const [isReady, setIsReady] = useState(false);
58
+ const [error, setError] = useState(null);
59
+ useEffect(() => {
60
+ let mounted = true;
61
+ async function ensureAgent() {
62
+ try {
63
+ if (!jupyterSandboxUrl) {
64
+ if (mounted) {
65
+ setError('Could not detect Jupyter server URL from Notebook service manager.');
66
+ setIsReady(false);
67
+ }
68
+ return;
69
+ }
70
+ const response = await fetch(`${baseUrl}/api/v1/agents`, {
71
+ method: 'POST',
72
+ headers: {
73
+ 'Content-Type': 'application/json',
74
+ },
75
+ body: JSON.stringify({
76
+ name: agentId,
77
+ description: 'Demo agent for notebook sidebar example',
78
+ agent_library: 'pydantic-ai',
79
+ transport: 'vercel-ai',
80
+ model: DEFAULT_MODEL,
81
+ system_prompt: 'You are a helpful AI assistant that helps users work with Jupyter notebooks. For notebook operations, always use the notebook frontend tools (runCell, readAllCells, readCell, insertCell, updateCell, deleteCells) so actions happen in the live notebook UI. Use executeCode only for temporary inspection code that should not modify notebook cells.',
82
+ enable_codemode: false,
83
+ sandbox_variant: 'jupyter',
84
+ jupyter_sandbox: jupyterSandboxUrl,
85
+ }),
86
+ });
87
+ if (mounted) {
88
+ if (response.ok) {
89
+ console.warn(`[NotebookAgentSidebarExample] Created agent: ${agentId}`);
90
+ setError(null);
91
+ setIsReady(true);
92
+ }
93
+ else if (response.status === 409 || response.status === 400) {
94
+ console.warn(`[NotebookAgentSidebarExample] Reusing existing agent: ${agentId}`);
95
+ setError(null);
96
+ setIsReady(true);
97
+ }
98
+ else {
99
+ const errorData = await response.json().catch(() => ({}));
100
+ setError(errorData.detail || `Failed to create agent: ${response.status}`);
101
+ setIsReady(false);
102
+ }
103
+ }
104
+ }
105
+ catch (err) {
106
+ if (mounted) {
107
+ console.error('[NotebookAgentSidebarExample] Error creating agent:', err);
108
+ setError(err instanceof Error ? err.message : 'Failed to connect to server');
109
+ setIsReady(false);
110
+ }
111
+ }
112
+ }
113
+ void ensureAgent();
114
+ return () => {
115
+ mounted = false;
116
+ };
117
+ }, [agentId, baseUrl, jupyterSandboxUrl]);
118
+ return { isReady, error };
119
+ }
120
+ function NotebookUI({ serviceManager }) {
121
+ if (!serviceManager) {
122
+ return (_jsx(Box, { sx: {
123
+ display: 'flex',
124
+ alignItems: 'center',
125
+ justifyContent: 'center',
126
+ height: '100%',
127
+ color: 'fg.muted',
128
+ }, children: "Loading Simple services..." }));
129
+ }
130
+ return (_jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "100%", cellSidebarMargin: 120, startDefaultKernel: true }));
131
+ }
132
+ export function AgentRuntimeNotebookExampleInner({ serviceManager, }) {
133
+ const jupyterSandboxUrl = useMemo(() => getJupyterSandboxUrl(serviceManager), [serviceManager]);
134
+ const { isReady, error } = useEnsureAgent(DEFAULT_AGENT_ID, DEFAULT_BASE_URL, jupyterSandboxUrl);
135
+ // Get notebook tools for ChatSidebar
136
+ const tools = useNotebookTools(NOTEBOOK_ID);
137
+ // Build Vercel AI protocol config
138
+ const protocolConfig = useMemo(() => {
139
+ return {
140
+ type: 'vercel-ai',
141
+ endpoint: VERCEL_AI_ENDPOINT,
142
+ agentId: DEFAULT_AGENT_ID,
143
+ enableConfigQuery: true,
144
+ configEndpoint: `${DEFAULT_BASE_URL}/api/v1/configure`,
145
+ };
146
+ }, []);
147
+ return (_jsx(_Fragment, { children: _jsxs(Box, { sx: {
148
+ height: 'calc(100vh - 70px)',
149
+ width: '100vw',
150
+ display: 'flex',
151
+ overflow: 'hidden',
152
+ }, children: [_jsxs(Box, { sx: {
153
+ flex: 1,
154
+ display: 'flex',
155
+ flexDirection: 'column',
156
+ overflow: 'hidden',
157
+ }, children: [_jsxs(Box, { sx: {
158
+ p: 3,
159
+ borderBottom: '1px solid',
160
+ borderColor: 'border.default',
161
+ bg: 'canvas.subtle',
162
+ }, children: [_jsx("h1", { style: { margin: 0, fontSize: '1.5rem' }, children: "Agent Runtime Notebook Sidebar Example" }), _jsx("p", { style: { margin: '8px 0 0', color: 'var(--fgColor-muted)' }, children: "Next generation chat with Jupyter Notebook integration" })] }), _jsx(Box, { sx: {
163
+ flex: 1,
164
+ display: 'flex',
165
+ overflow: 'hidden',
166
+ bg: 'canvas.default',
167
+ p: 3,
168
+ }, children: _jsx(Box, { sx: {
169
+ flex: 1,
170
+ border: '1px solid',
171
+ borderColor: 'border.default',
172
+ borderRadius: 2,
173
+ overflow: 'hidden',
174
+ }, children: _jsx(NotebookUI, { serviceManager: serviceManager }) }) })] }), isReady && (_jsx(ChatSidebar, { title: "AI Assistant", protocol: protocolConfig, position: "right", width: 400, showNewChatButton: true, showClearButton: true, showSettingsButton: true, defaultOpen: true, panelProps: {
175
+ protocol: protocolConfig,
176
+ frontendTools: tools,
177
+ useStore: false,
178
+ showModelSelector: true,
179
+ showToolsMenu: true,
180
+ showSkillsMenu: true,
181
+ suggestions: [
182
+ {
183
+ title: '📓 Explain notebook',
184
+ message: 'Can you explain what this notebook does?',
185
+ },
186
+ {
187
+ title: '🔧 Fix errors',
188
+ message: 'Can you help me fix any errors in the notebook?',
189
+ },
190
+ {
191
+ title: '📊 Add visualization',
192
+ message: 'Can you add a visualization to the notebook?',
193
+ },
194
+ {
195
+ title: '✨ Improve code',
196
+ message: 'Can you suggest improvements for the code?',
197
+ },
198
+ ],
199
+ } })), error && (_jsxs(Box, { sx: {
200
+ position: 'fixed',
201
+ bottom: 20,
202
+ right: 20,
203
+ padding: 3,
204
+ backgroundColor: 'danger.subtle',
205
+ color: 'danger.fg',
206
+ borderRadius: 2,
207
+ maxWidth: 320,
208
+ zIndex: 999,
209
+ }, children: [_jsx("strong", { children: "Error:" }), " ", error] }))] }) }));
210
+ }
211
+ /**
212
+ * Main example component with Simple wrapper
213
+ */
214
+ export function AgentRuntimeNotebookAgentSidebarExample() {
215
+ return (_jsx(ThemedJupyterProvider, { children: _jsx(SimpleWrapper, {}) }));
216
+ }
217
+ function SimpleWrapper() {
218
+ const { serviceManager } = useJupyter();
219
+ return _jsx(AgentRuntimeNotebookExampleInner, { serviceManager: serviceManager });
220
+ }
221
+ export default AgentRuntimeNotebookAgentSidebarExample;
@@ -3,14 +3,14 @@ import { ServiceManager } from '@jupyterlab/services';
3
3
  * Example demonstrating how to use Datalayer services with Notebook
4
4
  *
5
5
  * This example shows:
6
- * 1. How to create and use DatalayerServiceManager for kernel management
6
+ * 1. How to create and use DatalayerServiceManager for runtime management
7
7
  * 2. How to create and use DatalayerCollaborationProvider for real-time collaboration
8
8
  * 3. How to enable/disable Datalayer collaboration
9
9
  * 4. How to pass these to the base Notebook component
10
10
  * 5. Graceful fallback when Datalayer credentials are not available
11
11
  */
12
- type IDatalayerNotebookExampleProps = {
12
+ type INotebookCollaborationExampleProps = {
13
13
  serviceManager?: ServiceManager.IManager;
14
14
  };
15
- declare const DatalayerNotebookExample: (props: IDatalayerNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
16
- export default DatalayerNotebookExample;
15
+ declare const NotebookCollaborationExample: (props: INotebookCollaborationExampleProps) => import("react/jsx-runtime").JSX.Element;
16
+ export default NotebookCollaborationExample;
@@ -12,7 +12,7 @@ import { ThemedJupyterProvider } from './utils/themedProvider';
12
12
  import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
13
13
  // This corresponds to the notebook ID in the URL when you open an existing notbook in your library
14
14
  const NOTEBOOK_ID = '01JZQRQ35GG871QQCZW9TB1A8J';
15
- const DatalayerNotebookExample = (props) => {
15
+ const NotebookCollaborationExample = (props) => {
16
16
  // Load config on component mount
17
17
  loadJupyterConfig();
18
18
  const [nbformat] = useState(nbformatExample);
@@ -65,7 +65,7 @@ const DatalayerNotebookExample = (props) => {
65
65
  token,
66
66
  });
67
67
  }, [enableCollaboration, configuration]);
68
- return (_jsx(ThemedJupyterProvider, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Datalayer Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.runUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure runUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), enableCollaboration ? (_jsxs(Box, { sx: {
68
+ return (_jsx(ThemedJupyterProvider, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Notebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.runUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure runUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), enableCollaboration ? (_jsxs(Box, { sx: {
69
69
  display: 'flex',
70
70
  gap: 2,
71
71
  flexDirection: 'row',
@@ -97,4 +97,4 @@ const DatalayerNotebookExample = (props) => {
97
97
  borderRadius: 2,
98
98
  }, children: serviceManager ? (_jsx(Notebook, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) })), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (runUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
99
99
  };
100
- export default DatalayerNotebookExample;
100
+ export default NotebookCollaborationExample;
@@ -1,9 +1,6 @@
1
1
  import { ServiceManager } from '@jupyterlab/services';
2
- /**
3
- * Main Agent Runtime notebook example component
4
- */
5
- interface AgentRuntimeNotebookExampleProps {
2
+ type IJupyterNotebookExampleProps = {
6
3
  serviceManager?: ServiceManager.IManager;
7
- }
8
- declare function AgentRuntimeNotebookExample({ serviceManager, }: AgentRuntimeNotebookExampleProps): JSX.Element;
9
- export default AgentRuntimeNotebookExample;
4
+ };
5
+ export declare const JupyterNotebookExample: (props: IJupyterNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default JupyterNotebookExample;
@@ -1,154 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright (c) 2025-2026 Datalayer, Inc.
4
4
  * Distributed under the terms of the Modified BSD License.
5
5
  */
6
- /**
7
- * Agent Runtime Notebook Example with Agent-Runtimes Integration
8
- *
9
- * This example demonstrates using the agent-runtimes ChatFloating component
10
- * with notebook tools for AI-assisted notebook editing.
11
- *
12
- * To run this example:
13
- * 1. Start the agent-runtimes server: `npm run start:server`
14
- * 2. Start the frontend: `npm run dev`
6
+ /*
7
+ * Copyright (c) 2021-2023 Datalayer, Inc.
15
8
  *
16
- * @module examples/NotebookExample
9
+ * MIT License
17
10
  */
18
- import React, { useEffect, useState } from 'react';
11
+ import { useMemo } from 'react';
19
12
  import { Box } from '@datalayer/primer-addons';
20
- import { Notebook } from '@datalayer/jupyter-react';
13
+ import { Notebook, NotebookToolbar, CellSidebarExtension, CellSidebarButton, } from '@datalayer/jupyter-react';
21
14
  import { ThemedJupyterProvider } from './utils/themedProvider';
22
- // Agent-runtimes imports
23
- import { ChatFloating } from '../chat';
24
- import { useNotebookTools } from '../tools/adapters/agent-runtimes/notebookHooks';
25
- // Import Matplotlib notebook
26
- import MatplotlibNotebook from './utils/notebooks/Matplotlib.ipynb.json';
27
- import { DEFAULT_MODEL } from '../specs';
28
- // Fixed notebook ID
29
- const NOTEBOOK_ID = 'agui-notebook-example';
30
- // Use the imported Matplotlib notebook
31
- const NOTEBOOK_CONTENT = MatplotlibNotebook;
32
- // Base URL for agent-runtimes server
33
- const BASE_URL = 'http://localhost:8765';
34
- const AGENT_ID = 'notebook-agent-runtime-example';
35
- // Vercel AI endpoint
36
- const VERCEL_AI_ENDPOINT = `${BASE_URL}/api/v1/vercel-ai/${AGENT_ID}`;
37
- /**
38
- * Hook to ensure the demo-agent exists on the server.
39
- * Creates it if it doesn't exist.
40
- */
41
- function useEnsureAgent(agentId, baseUrl) {
42
- const [isReady, setIsReady] = useState(false);
43
- const [error, setError] = useState(null);
44
- useEffect(() => {
45
- let mounted = true;
46
- async function ensureAgent() {
47
- try {
48
- // Try to create the agent (will fail if already exists, which is fine)
49
- const response = await fetch(`${baseUrl}/api/v1/agents`, {
50
- method: 'POST',
51
- headers: {
52
- 'Content-Type': 'application/json',
53
- },
54
- body: JSON.stringify({
55
- name: agentId,
56
- description: 'Demo agent for notebook example',
57
- agent_library: 'pydantic-ai',
58
- transport: 'vercel-ai',
59
- model: DEFAULT_MODEL,
60
- system_prompt: 'You are a helpful AI assistant that helps users work with Jupyter notebooks. You can help with code, explanations, and data analysis.',
61
- }),
62
- });
63
- if (mounted) {
64
- if (response.ok) {
65
- console.log(`[AgentRuntimeExample] Created agent: ${agentId}`);
66
- setIsReady(true);
67
- }
68
- else if (response.status === 400) {
69
- // Agent already exists, which is fine
70
- console.log(`[AgentRuntimeExample] Agent already exists: ${agentId}`);
71
- setIsReady(true);
72
- }
73
- else {
74
- const errorData = await response.json().catch(() => ({}));
75
- setError(errorData.detail || `Failed to create agent: ${response.status}`);
76
- }
77
- }
78
- }
79
- catch (err) {
80
- if (mounted) {
81
- console.error('[AgentRuntimeExample] Error creating agent:', err);
82
- setError(err instanceof Error ? err.message : 'Failed to connect to server');
83
- }
84
- }
85
- }
86
- ensureAgent();
87
- return () => {
88
- mounted = false;
89
- };
90
- }, [agentId, baseUrl]);
91
- return { isReady, error };
92
- }
93
- const NotebookUI = React.memo(function NotebookUI({ serviceManager, }) {
94
- return (_jsxs(Box, { sx: {
95
- flex: 1,
96
- display: 'flex',
97
- flexDirection: 'column',
98
- overflow: 'auto',
99
- padding: 3,
100
- }, children: [_jsxs(Box, { sx: {
101
- marginBottom: 3,
102
- paddingBottom: 3,
103
- borderBottom: '1px solid',
104
- borderColor: 'border.default',
105
- }, children: [_jsx(Box, { as: "h1", sx: { margin: 0 }, children: "Agent Runtime Notebook Example" }), _jsx("p", { children: "Platform-agnostic tool usage with agent-runtimes integration. Use the AI copilot to manipulate the notebook." })] }), _jsx(Box, { sx: {
106
- border: '1px solid',
107
- borderColor: 'border.default',
108
- borderRadius: 2,
109
- padding: 3,
110
- backgroundColor: 'canvas.default',
111
- }, children: serviceManager ? (_jsx(ThemedJupyterProvider, { children: _jsx(Notebook, { nbformat: NOTEBOOK_CONTENT, id: NOTEBOOK_ID, serviceManager: serviceManager, height: "calc(100vh - 300px)", cellSidebarMargin: 120, startDefaultKernel: true }) })) : (_jsx(Box, { sx: { padding: 3 }, children: _jsx("p", { children: "Loading service manager..." }) })) })] }));
112
- });
113
- function NotebookWithChat({ serviceManager, }) {
114
- // Ensure the agent exists before rendering chat
115
- const { isReady, error } = useEnsureAgent(AGENT_ID, BASE_URL);
116
- // Get notebook tools for ChatFloating
117
- const frontendTools = useNotebookTools(NOTEBOOK_ID);
118
- return (_jsxs(Box, { sx: {
119
- height: '100vh',
120
- width: '100vw',
121
- display: 'flex',
122
- overflow: 'hidden',
123
- }, children: [_jsx(NotebookUI, { serviceManager: serviceManager }), error && (_jsxs(Box, { sx: {
124
- position: 'fixed',
125
- bottom: 20,
126
- right: 20,
127
- padding: 3,
128
- backgroundColor: 'danger.subtle',
129
- color: 'danger.fg',
130
- borderRadius: 2,
131
- maxWidth: 300,
132
- }, children: [_jsx("strong", { children: "Error:" }), " ", error] })), isReady && (_jsx(ChatFloating, { protocol: "vercel-ai", endpoint: VERCEL_AI_ENDPOINT, title: "Notebook AI Agent Runtime", description: "Hi! I can help you edit notebook cells. Try: 'Add a new code cell', 'Run cell 1', or 'Delete the last cell'", defaultOpen: true, defaultViewMode: "panel", position: "bottom-right", frontendTools: frontendTools, useStore: false, showModelSelector: true, showToolsMenu: true, showSkillsMenu: true, suggestions: [
133
- {
134
- title: 'Add a cell',
135
- message: 'Insert a random cell to the notebook',
136
- },
137
- {
138
- title: 'Run the first cell',
139
- message: 'Run the first cell in the notebook',
140
- },
141
- {
142
- title: 'Show cells',
143
- message: 'Show the notebook cells content and compute the number of cells',
144
- },
145
- {
146
- title: 'Analyze Titanic',
147
- message: 'Analyze the Titanic dataset and provide insights about the passengers and survival rates',
148
- },
149
- ] }))] }));
150
- }
151
- function AgentRuntimeNotebookExample({ serviceManager, }) {
152
- return _jsx(NotebookWithChat, { serviceManager: serviceManager });
153
- }
154
- export default AgentRuntimeNotebookExample;
15
+ import nbformatExample from './utils/notebooks/NotebookExample1.ipynb.json';
16
+ const NOTEBOOK_ID = 'notebook-example-1';
17
+ export const JupyterNotebookExample = (props) => {
18
+ const { serviceManager } = props;
19
+ const extensions = useMemo(() => [new CellSidebarExtension({ factory: CellSidebarButton })], []);
20
+ return (_jsxs(_Fragment, { children: [_jsx(Box, { as: "h1", children: "Jupyter Notebook Example" }), serviceManager && (_jsx(ThemedJupyterProvider, { children: _jsx(Notebook, { id: NOTEBOOK_ID, nbformat: nbformatExample, serviceManager: serviceManager, startDefaultKernel: true, extensions: extensions, Toolbar: NotebookToolbar }) }))] }));
21
+ };
22
+ export default JupyterNotebookExample;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * Full-page auth gate content for examples that require a token.
4
+ */
5
+ export declare const AuthRequiredView: React.FC;
6
+ export default AuthRequiredView;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useCallback } from 'react';
7
+ import { Box } from '@datalayer/primer-addons';
8
+ import { HomeIcon } from '@primer/octicons-react';
9
+ import { SignInSimple } from '@datalayer/core/lib/views/iam';
10
+ import { useSimpleAuthStore } from '@datalayer/core/lib/views/otel';
11
+ /**
12
+ * Full-page auth gate content for examples that require a token.
13
+ */
14
+ export const AuthRequiredView = () => {
15
+ const setAuth = useSimpleAuthStore(s => s.setAuth);
16
+ const syncTokenToIamStore = useCallback((token) => {
17
+ import('@datalayer/core/lib/state').then(({ iamStore }) => {
18
+ iamStore.setState({ token });
19
+ });
20
+ }, []);
21
+ const handleSignIn = useCallback((newToken, handle) => {
22
+ setAuth(newToken, handle);
23
+ syncTokenToIamStore(newToken);
24
+ }, [setAuth, syncTokenToIamStore]);
25
+ return (_jsx(Box, { sx: {
26
+ height: '100%',
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ justifyContent: 'center',
30
+ p: 3,
31
+ }, children: _jsx(Box, { sx: { width: '100%', maxWidth: 640 }, children: _jsx(SignInSimple, { onSignIn: handleSignIn, onApiKeySignIn: apiKey => handleSignIn(apiKey, 'api-key-user'), title: "Agent Runtimes Examples", description: "Sign in to run authenticated examples and tools.", leadingIcon: _jsx(HomeIcon, { size: 24 }) }) }) }));
32
+ };
33
+ export default AuthRequiredView;
@@ -2,9 +2,15 @@ import React from 'react';
2
2
  /**
3
3
  * ExampleWrapper
4
4
  *
5
- * Wraps every example in a fixed-height container that accounts for
6
- * the 60 px header bar. Examples inside can use `100vh` or `100%`
7
- * freely the wrapper clips and scrolls as needed.
5
+ * Provides every example with a definite-height, scroll-clipped container
6
+ * that fills the parent content area exactly. Examples mounted inside
7
+ * should treat this as their viewport: use `height: '100%'` on their
8
+ * root, then own their internal flex/grid layout (and place any internal
9
+ * scrollers on dedicated panels with `minHeight: 0` + `overflow: 'auto'`).
10
+ *
11
+ * Also clears the shared chat + conversation stores synchronously as the
12
+ * new example mounts, so switching examples never leaks messages from the
13
+ * previously-mounted chat.
8
14
  */
9
15
  export declare const ExampleWrapper: React.FC<{
10
16
  children: React.ReactNode;
@@ -1,16 +1,52 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useLayoutEffect } from 'react';
2
7
  import { Box } from '@datalayer/primer-addons';
8
+ import { useChatStore, useConversationStore } from '../../stores';
3
9
  /**
4
10
  * ExampleWrapper
5
11
  *
6
- * Wraps every example in a fixed-height container that accounts for
7
- * the 60 px header bar. Examples inside can use `100vh` or `100%`
8
- * freely the wrapper clips and scrolls as needed.
12
+ * Provides every example with a definite-height, scroll-clipped container
13
+ * that fills the parent content area exactly. Examples mounted inside
14
+ * should treat this as their viewport: use `height: '100%'` on their
15
+ * root, then own their internal flex/grid layout (and place any internal
16
+ * scrollers on dedicated panels with `minHeight: 0` + `overflow: 'auto'`).
17
+ *
18
+ * Also clears the shared chat + conversation stores synchronously as the
19
+ * new example mounts, so switching examples never leaks messages from the
20
+ * previously-mounted chat.
9
21
  */
10
- export const ExampleWrapper = ({ children, }) => (_jsx(Box, { sx: {
11
- height: 'calc(100vh - 60px)',
12
- width: '100%',
13
- overflow: 'auto',
14
- position: 'relative',
15
- }, children: children }));
22
+ export const ExampleWrapper = ({ children, }) => {
23
+ useLayoutEffect(() => {
24
+ useChatStore.getState().reset();
25
+ useConversationStore.getState().clearAll();
26
+ }, []);
27
+ return (_jsx(Box, { sx: {
28
+ position: 'relative',
29
+ height: '100%',
30
+ width: '100%',
31
+ minHeight: 0,
32
+ overflow: 'hidden',
33
+ display: 'flex',
34
+ flexDirection: 'column',
35
+ // Generic constraint: every example's root child fills the wrapper
36
+ // exactly and cannot exceed it. This neutralises stray `100vh`/
37
+ // `calc(100vh - Npx)` heights inside individual examples so the
38
+ // chat footer (or any bottom UI) always remains in the viewport.
39
+ '& > *': {
40
+ flex: '1 1 0',
41
+ minHeight: 0,
42
+ maxHeight: '100%',
43
+ width: '100%',
44
+ // Default scroll behaviour for plain content pages. Examples
45
+ // that manage their own internal scrollers can override this
46
+ // by setting `overflow: 'hidden'` (or another value) on their
47
+ // root element \u2014 the child rule wins on specificity.
48
+ overflow: 'auto',
49
+ },
50
+ }, children: children }));
51
+ };
16
52
  export default ExampleWrapper;
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  * This component displays a collection of haikus in a carousel format
10
10
  * for the main view area. Inspired by the AG-UI Dojo implementation.
11
11
  *
12
- * @module examples/ag-ui/haiku/HaikuDisplay
12
+ * @module examples/components/haiku/HaikuDisplay
13
13
  */
14
14
  import { useState } from 'react';
15
15
  import { IconButton, Text } from '@primer/react';
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  * Inspired by the AG-UI Dojo implementation, this component renders haiku
10
10
  * poetry with gradient backgrounds and Japanese/English text.
11
11
  *
12
- * @module examples/ag-ui/haiku/InlineHaikuCard
12
+ * @module examples/components/haiku/InlineHaikuCard
13
13
  */
14
14
  import { Spinner } from '@primer/react';
15
15
  /**
@@ -5,7 +5,7 @@
5
5
  * tool-based generative UI where the backend generates haiku content
6
6
  * that is rendered both inline in chat and in a main display area.
7
7
  *
8
- * @module examples/ag-ui/haiku
8
+ * @module examples/components/haiku
9
9
  */
10
10
  export { InlineHaikuCard, type InlineHaikuCardProps, type HaikuResult, } from './InlineHaikuCard';
11
11
  export { HaikuDisplay, type HaikuDisplayProps } from './HaikuDisplay';
@@ -9,7 +9,7 @@
9
9
  * tool-based generative UI where the backend generates haiku content
10
10
  * that is rendered both inline in chat and in a main display area.
11
11
  *
12
- * @module examples/ag-ui/haiku
12
+ * @module examples/components/haiku
13
13
  */
14
14
  export { InlineHaikuCard, } from './InlineHaikuCard';
15
15
  export { HaikuDisplay } from './HaikuDisplay';
@@ -1,5 +1,6 @@
1
1
  export { ErrorView } from './ErrorView';
2
2
  export type { ErrorViewProps } from './ErrorView';
3
+ export { AuthRequiredView } from './AuthRequiredView';
3
4
  export { MockFileBrowser } from './MockFileBrowser';
4
5
  export type { MockFileBrowserProps } from './MockFileBrowser';
5
6
  export { MainContent } from './MainContent';
@@ -17,3 +18,5 @@ export type { TimeTravelProps } from './TimeTravel';
17
18
  export { LexicalEditor } from './LexicalEditor';
18
19
  export type { LexicalEditorProps } from './LexicalEditor';
19
20
  export { ExampleWrapper } from './ExampleWrapper';
21
+ export { InlineWeatherCard, type InlineWeatherCardProps, type WeatherResult, } from './weather';
22
+ export { InlineHaikuCard, HaikuDisplay, type InlineHaikuCardProps, type HaikuDisplayProps, type HaikuResult, } from './haiku';
@@ -4,6 +4,7 @@
4
4
  */
5
5
  // Example/layout components
6
6
  export { ErrorView } from './ErrorView';
7
+ export { AuthRequiredView } from './AuthRequiredView';
7
8
  export { MockFileBrowser } from './MockFileBrowser';
8
9
  export { MainContent } from './MainContent';
9
10
  export { SessionTabs } from './SessionTabs';
@@ -13,3 +14,6 @@ export { FooterMetrics } from './FooterMetrics';
13
14
  export { TimeTravel } from './TimeTravel';
14
15
  export { LexicalEditor } from './LexicalEditor';
15
16
  export { ExampleWrapper } from './ExampleWrapper';
17
+ // AG-UI example components
18
+ export { InlineWeatherCard, } from './weather';
19
+ export { InlineHaikuCard, HaikuDisplay, } from './haiku';