@datalayer/agent-runtimes 1.0.3 → 1.0.5

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 (275) hide show
  1. package/README.md +35 -119
  2. package/lib/App.js +1 -1
  3. package/lib/agents/AgentDetails.d.ts +22 -1
  4. package/lib/agents/AgentDetails.js +34 -47
  5. package/lib/api/index.d.ts +0 -1
  6. package/lib/api/index.js +4 -2
  7. package/lib/chat/Chat.d.ts +5 -104
  8. package/lib/chat/Chat.js +4 -4
  9. package/lib/chat/ChatFloating.d.ts +7 -140
  10. package/lib/chat/ChatFloating.js +2 -2
  11. package/lib/chat/ChatPopupStandalone.d.ts +8 -47
  12. package/lib/chat/ChatPopupStandalone.js +3 -3
  13. package/lib/chat/ChatSidebar.d.ts +4 -69
  14. package/lib/chat/ChatSidebar.js +2 -2
  15. package/lib/chat/ChatStandalone.d.ts +4 -54
  16. package/lib/chat/ChatStandalone.js +3 -3
  17. package/lib/chat/base/ChatBase.js +1118 -141
  18. package/lib/chat/header/ChatHeaderBase.d.ts +11 -6
  19. package/lib/chat/header/ChatHeaderBase.js +18 -16
  20. package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
  21. package/lib/chat/indicators/McpStatusIndicator.js +7 -32
  22. package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
  23. package/lib/chat/indicators/SandboxStatusIndicator.js +9 -9
  24. package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
  25. package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
  26. package/lib/chat/indicators/index.d.ts +1 -0
  27. package/lib/chat/indicators/index.js +1 -0
  28. package/lib/chat/messages/ChatMessageList.d.ts +1 -1
  29. package/lib/chat/messages/ChatMessageList.js +110 -102
  30. package/lib/chat/prompt/InputFooter.d.ts +19 -6
  31. package/lib/chat/prompt/InputFooter.js +71 -18
  32. package/lib/chat/prompt/InputPrompt.d.ts +3 -1
  33. package/lib/chat/prompt/InputPrompt.js +4 -4
  34. package/lib/chat/prompt/InputPromptFooter.js +1 -1
  35. package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
  36. package/lib/chat/prompt/InputPromptLexical.js +12 -5
  37. package/lib/chat/prompt/InputPromptText.d.ts +3 -1
  38. package/lib/chat/prompt/InputPromptText.js +2 -2
  39. package/lib/chat/tools/ToolApprovalBanner.js +1 -1
  40. package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
  41. package/lib/chat/tools/ToolCallDisplay.js +2 -2
  42. package/lib/chat/usage/TokenUsageBar.js +20 -2
  43. package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
  44. package/lib/client/AgentRuntimesClientContext.js +55 -0
  45. package/lib/client/AgentsMixin.d.ts +48 -19
  46. package/lib/client/AgentsMixin.js +115 -30
  47. package/lib/client/IAgentRuntimesClient.d.ts +215 -0
  48. package/lib/client/IAgentRuntimesClient.js +5 -0
  49. package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
  50. package/lib/client/SdkAgentRuntimesClient.js +134 -0
  51. package/lib/client/index.d.ts +4 -1
  52. package/lib/client/index.js +3 -1
  53. package/lib/components/NotificationEventCard.js +55 -26
  54. package/lib/components/OutputCard.js +21 -7
  55. package/lib/components/ToolApprovalCard.js +20 -2
  56. package/lib/config/AgentConfiguration.js +3 -3
  57. package/lib/context/ContextDistribution.d.ts +3 -1
  58. package/lib/context/ContextDistribution.js +8 -27
  59. package/lib/context/ContextInspector.d.ts +3 -1
  60. package/lib/context/ContextInspector.js +19 -67
  61. package/lib/context/ContextPanel.d.ts +3 -1
  62. package/lib/context/ContextPanel.js +104 -64
  63. package/lib/context/ContextUsage.d.ts +3 -1
  64. package/lib/context/ContextUsage.js +3 -3
  65. package/lib/context/CostTracker.d.ts +9 -3
  66. package/lib/context/CostTracker.js +26 -47
  67. package/lib/context/CostUsageChart.d.ts +12 -0
  68. package/lib/context/CostUsageChart.js +378 -0
  69. package/lib/context/GraphFlowChart.d.ts +16 -0
  70. package/lib/context/GraphFlowChart.js +182 -0
  71. package/lib/context/TokenUsageChart.d.ts +8 -1
  72. package/lib/context/TokenUsageChart.js +349 -211
  73. package/lib/context/TurnGraphChart.d.ts +39 -0
  74. package/lib/context/TurnGraphChart.js +538 -0
  75. package/lib/context/otelWsPool.d.ts +20 -0
  76. package/lib/context/otelWsPool.js +69 -0
  77. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
  78. package/lib/examples/A2UiComponentGalleryExample.js +315 -522
  79. package/lib/examples/A2UiContactCardExample.d.ts +0 -18
  80. package/lib/examples/A2UiContactCardExample.js +154 -411
  81. package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
  82. package/lib/examples/A2UiRestaurantExample.js +114 -212
  83. package/lib/examples/A2UiViewerExample.d.ts +0 -18
  84. package/lib/examples/A2UiViewerExample.js +283 -532
  85. package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
  86. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
  87. package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
  88. package/lib/examples/AgentCheckpointsExample.js +14 -34
  89. package/lib/examples/AgentCodemodeExample.d.ts +4 -6
  90. package/lib/examples/AgentCodemodeExample.js +591 -175
  91. package/lib/examples/AgentEvalsExample.js +13 -23
  92. package/lib/examples/AgentGuardrailsExample.js +371 -71
  93. package/lib/examples/AgentHooksExample.d.ts +3 -0
  94. package/lib/examples/AgentHooksExample.js +104 -0
  95. package/lib/examples/AgentMCPExample.d.ts +3 -0
  96. package/lib/examples/AgentMCPExample.js +480 -0
  97. package/lib/examples/AgentMemoryExample.js +14 -24
  98. package/lib/examples/AgentMonitoringExample.js +261 -206
  99. package/lib/examples/AgentNotificationsExample.js +50 -24
  100. package/lib/examples/AgentOtelExample.js +2 -3
  101. package/lib/examples/AgentOutputsExample.d.ts +11 -6
  102. package/lib/examples/AgentOutputsExample.js +383 -88
  103. package/lib/examples/AgentParametersExample.d.ts +3 -0
  104. package/lib/examples/AgentParametersExample.js +246 -0
  105. package/lib/examples/AgentSandboxExample.d.ts +2 -2
  106. package/lib/examples/AgentSandboxExample.js +69 -47
  107. package/lib/examples/AgentSkillsExample.js +92 -106
  108. package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
  109. package/lib/examples/AgentSubagentsExample.d.ts +14 -0
  110. package/lib/examples/AgentSubagentsExample.js +228 -0
  111. package/lib/examples/AgentToolApprovalsExample.js +30 -493
  112. package/lib/examples/AgentTriggersExample.js +1067 -246
  113. package/lib/examples/ChatCustomExample.js +11 -24
  114. package/lib/examples/ChatExample.js +9 -34
  115. package/lib/examples/CopilotKitLexicalExample.js +2 -1
  116. package/lib/examples/CopilotKitNotebookExample.js +2 -1
  117. package/lib/examples/HomeExample.d.ts +15 -0
  118. package/lib/examples/HomeExample.js +77 -0
  119. package/lib/examples/Lexical2Example.js +4 -2
  120. package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
  121. package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +65 -16
  122. package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
  123. package/lib/examples/LexicalAgentSidebarExample.js +261 -0
  124. package/lib/examples/NotebookAgentExample.d.ts +9 -0
  125. package/lib/examples/NotebookAgentExample.js +192 -0
  126. package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
  127. package/lib/examples/NotebookAgentSidebarExample.js +221 -0
  128. package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
  129. package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
  130. package/lib/examples/NotebookExample.d.ts +4 -7
  131. package/lib/examples/NotebookExample.js +14 -146
  132. package/lib/examples/components/AuthRequiredView.d.ts +6 -0
  133. package/lib/examples/components/AuthRequiredView.js +33 -0
  134. package/lib/examples/components/ErrorView.d.ts +14 -0
  135. package/lib/examples/components/ErrorView.js +20 -0
  136. package/lib/examples/components/ExampleWrapper.d.ts +7 -0
  137. package/lib/examples/components/ExampleWrapper.js +25 -6
  138. package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
  139. package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
  140. package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
  141. package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
  142. package/lib/examples/components/index.d.ts +5 -0
  143. package/lib/examples/components/index.js +5 -0
  144. package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
  145. package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
  146. package/lib/examples/example-selector.d.ts +17 -4
  147. package/lib/examples/example-selector.js +107 -41
  148. package/lib/examples/index.d.ts +9 -6
  149. package/lib/examples/index.js +9 -6
  150. package/lib/examples/main.d.ts +1 -0
  151. package/lib/examples/main.js +218 -27
  152. package/lib/examples/utils/a2ui.d.ts +18 -0
  153. package/lib/examples/utils/a2ui.js +69 -0
  154. package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
  155. package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
  156. package/lib/examples/utils/agentId.d.ts +18 -0
  157. package/lib/examples/utils/agentId.js +54 -0
  158. package/lib/examples/utils/agents/earthquake-detector.json +11 -11
  159. package/lib/examples/utils/agents/sales-forecaster.json +11 -11
  160. package/lib/examples/utils/agents/social-post-generator.json +11 -11
  161. package/lib/examples/utils/agents/stock-market.json +11 -11
  162. package/lib/examples/utils/examplesStore.js +82 -27
  163. package/lib/hooks/index.d.ts +8 -8
  164. package/lib/hooks/index.js +7 -7
  165. package/lib/hooks/useA2A.d.ts +2 -3
  166. package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
  167. package/lib/hooks/useAIAgentsWebSocket.js +118 -12
  168. package/lib/hooks/useAcp.d.ts +1 -2
  169. package/lib/hooks/useAgUi.d.ts +1 -1
  170. package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +39 -2
  171. package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
  172. package/lib/hooks/useAgentsCatalog.js +1 -1
  173. package/lib/hooks/useAgentsService.d.ts +2 -2
  174. package/lib/hooks/useAgentsService.js +7 -7
  175. package/lib/hooks/useCheckpoints.js +1 -1
  176. package/lib/hooks/useConfig.d.ts +4 -1
  177. package/lib/hooks/useConfig.js +10 -3
  178. package/lib/hooks/useContextSnapshot.d.ts +9 -4
  179. package/lib/hooks/useContextSnapshot.js +9 -37
  180. package/lib/hooks/useMonitoring.js +3 -0
  181. package/lib/hooks/useSandbox.d.ts +20 -8
  182. package/lib/hooks/useSandbox.js +105 -40
  183. package/lib/hooks/useSkills.d.ts +23 -5
  184. package/lib/hooks/useSkills.js +94 -39
  185. package/lib/hooks/useToolApprovals.d.ts +60 -36
  186. package/lib/hooks/useToolApprovals.js +318 -69
  187. package/lib/hooks/useVercelAI.d.ts +1 -1
  188. package/lib/index.d.ts +2 -1
  189. package/lib/index.js +1 -0
  190. package/lib/inference/index.d.ts +0 -1
  191. package/lib/middleware/index.d.ts +0 -1
  192. package/lib/protocols/AGUIAdapter.js +6 -0
  193. package/lib/protocols/VercelAIAdapter.d.ts +9 -0
  194. package/lib/protocols/VercelAIAdapter.js +144 -26
  195. package/lib/shims/json5.d.ts +4 -0
  196. package/lib/shims/json5.js +8 -0
  197. package/lib/specs/agents/agents.d.ts +10 -0
  198. package/lib/specs/agents/agents.js +752 -24
  199. package/lib/specs/envvars.d.ts +1 -0
  200. package/lib/specs/envvars.js +11 -0
  201. package/lib/specs/events.d.ts +1 -0
  202. package/lib/specs/events.js +1 -0
  203. package/lib/specs/index.d.ts +1 -0
  204. package/lib/specs/index.js +1 -0
  205. package/lib/specs/personas.d.ts +41 -0
  206. package/lib/specs/personas.js +168 -0
  207. package/lib/specs/skills.d.ts +2 -1
  208. package/lib/specs/skills.js +23 -5
  209. package/lib/specs/tools.js +3 -0
  210. package/lib/stores/agentRuntimeStore.d.ts +204 -0
  211. package/lib/stores/agentRuntimeStore.js +636 -0
  212. package/lib/stores/index.d.ts +1 -1
  213. package/lib/stores/index.js +1 -1
  214. package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
  215. package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
  216. package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
  217. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
  218. package/lib/tools/index.d.ts +0 -2
  219. package/lib/tools/index.js +0 -1
  220. package/lib/types/agentspecs.d.ts +50 -1
  221. package/lib/types/chat.d.ts +309 -8
  222. package/lib/types/context.d.ts +27 -0
  223. package/lib/types/cost.d.ts +2 -2
  224. package/lib/types/index.d.ts +2 -0
  225. package/lib/types/index.js +2 -0
  226. package/lib/types/mcp.d.ts +8 -0
  227. package/lib/types/models.d.ts +2 -2
  228. package/lib/types/personas.d.ts +25 -0
  229. package/lib/types/personas.js +5 -0
  230. package/lib/types/skills.d.ts +43 -1
  231. package/lib/types/stream.d.ts +110 -0
  232. package/lib/types/stream.js +36 -0
  233. package/lib/types/tools.d.ts +2 -0
  234. package/lib/utils/utils.d.ts +9 -5
  235. package/lib/utils/utils.js +9 -5
  236. package/package.json +13 -9
  237. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  238. package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
  239. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  240. package/scripts/codegen/generate_agents.py +106 -7
  241. package/scripts/codegen/generate_events.py +47 -17
  242. package/scripts/codegen/generate_personas.py +319 -0
  243. package/scripts/codegen/generate_skills.py +9 -9
  244. package/scripts/codegen/generate_tools.py +20 -0
  245. package/scripts/sync-jupyter.sh +26 -7
  246. package/style/primer-primitives.css +1 -6
  247. package/lib/api/tool-approvals.d.ts +0 -62
  248. package/lib/api/tool-approvals.js +0 -145
  249. package/lib/examples/LexicalSidebarExample.js +0 -163
  250. package/lib/examples/NotebookSidebarExample.js +0 -119
  251. package/lib/examples/NotebookSimpleExample.d.ts +0 -6
  252. package/lib/examples/NotebookSimpleExample.js +0 -22
  253. package/lib/examples/ag-ui/index.d.ts +0 -10
  254. package/lib/examples/ag-ui/index.js +0 -16
  255. package/lib/hooks/useAgentsRegistry.d.ts +0 -10
  256. package/lib/hooks/useAgentsRegistry.js +0 -20
  257. package/lib/stores/agentsStore.d.ts +0 -123
  258. package/lib/stores/agentsStore.js +0 -270
  259. package/scripts/codegen/__pycache__/generate_envvars.cpython-313.pyc +0 -0
  260. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  261. package/scripts/codegen/__pycache__/generate_guardrails.cpython-313.pyc +0 -0
  262. package/scripts/codegen/__pycache__/generate_mcp_servers.cpython-313.pyc +0 -0
  263. package/scripts/codegen/__pycache__/generate_memory.cpython-313.pyc +0 -0
  264. package/scripts/codegen/__pycache__/generate_models.cpython-313.pyc +0 -0
  265. package/scripts/codegen/__pycache__/generate_notifications.cpython-313.pyc +0 -0
  266. package/scripts/codegen/__pycache__/generate_outputs.cpython-313.pyc +0 -0
  267. package/scripts/codegen/__pycache__/generate_skills.cpython-313.pyc +0 -0
  268. package/scripts/codegen/__pycache__/generate_teams.cpython-313.pyc +0 -0
  269. package/scripts/codegen/__pycache__/generate_tools.cpython-313.pyc +0 -0
  270. package/scripts/codegen/__pycache__/generate_triggers.cpython-313.pyc +0 -0
  271. /package/lib/examples/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
  272. /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
  273. /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
  274. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
  275. /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;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export type ErrorViewProps = {
3
+ /** Primary error message. Falls back to "Agent failed to start". */
4
+ error?: string | null;
5
+ /** Optional secondary detail line shown below the primary message. */
6
+ detail?: string | null;
7
+ /** Called when the user clicks "Sign out". Button only appears for 401 errors. */
8
+ onLogout?: () => void;
9
+ };
10
+ /**
11
+ * Full-screen error view used by examples when agent creation fails.
12
+ * Automatically shows a "Sign out" button when the error contains "401".
13
+ */
14
+ export declare const ErrorView: React.FC<ErrorViewProps>;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Text, Button } from '@primer/react';
3
+ import { AlertIcon, SignOutIcon } from '@primer/octicons-react';
4
+ import { Box } from '@datalayer/primer-addons';
5
+ /**
6
+ * Full-screen error view used by examples when agent creation fails.
7
+ * Automatically shows a "Sign out" button when the error contains "401".
8
+ */
9
+ export const ErrorView = ({ error, detail, onLogout, }) => {
10
+ const message = error || 'Agent failed to start';
11
+ const is401 = String(message).includes('401') || String(detail || '').includes('401');
12
+ return (_jsxs(Box, { sx: {
13
+ display: 'flex',
14
+ flexDirection: 'column',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ height: '100vh',
18
+ gap: 3,
19
+ }, children: [_jsx(AlertIcon, { size: 48 }), _jsx(Text, { sx: { color: 'danger.fg', fontSize: 2 }, children: message }), detail && _jsx(Text, { sx: { color: 'fg.muted' }, children: detail }), is401 && onLogout && (_jsx(Button, { variant: "danger", leadingVisual: SignOutIcon, onClick: onLogout, children: "Sign out" }))] }));
20
+ };
@@ -5,6 +5,13 @@ import React from 'react';
5
5
  * Wraps every example in a fixed-height container that accounts for
6
6
  * the 60 px header bar. Examples inside can use `100vh` or `100%`
7
7
  * freely — the wrapper clips and scrolls as needed.
8
+ *
9
+ * Also clears the shared chat + conversation stores synchronously as the
10
+ * new example mounts, so switching examples never leaks messages from the
11
+ * previously-mounted chat (``handleExampleChange`` in ``main.tsx`` already
12
+ * resets these, but a last-millisecond WebSocket callback from the old
13
+ * example can repopulate them between reset and the new mount — this
14
+ * ``useLayoutEffect`` closes that race).
8
15
  */
9
16
  export declare const ExampleWrapper: React.FC<{
10
17
  children: React.ReactNode;
@@ -1,16 +1,35 @@
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
12
  * Wraps every example in a fixed-height container that accounts for
7
13
  * the 60 px header bar. Examples inside can use `100vh` or `100%`
8
14
  * freely — the wrapper clips and scrolls as needed.
15
+ *
16
+ * Also clears the shared chat + conversation stores synchronously as the
17
+ * new example mounts, so switching examples never leaks messages from the
18
+ * previously-mounted chat (``handleExampleChange`` in ``main.tsx`` already
19
+ * resets these, but a last-millisecond WebSocket callback from the old
20
+ * example can repopulate them between reset and the new mount — this
21
+ * ``useLayoutEffect`` closes that race).
9
22
  */
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 }));
23
+ export const ExampleWrapper = ({ children, }) => {
24
+ useLayoutEffect(() => {
25
+ useChatStore.getState().reset();
26
+ useConversationStore.getState().clearAll();
27
+ }, []);
28
+ return (_jsx(Box, { sx: {
29
+ height: 'calc(100vh - 60px)',
30
+ width: '100%',
31
+ overflow: 'auto',
32
+ position: 'relative',
33
+ }, children: children }));
34
+ };
16
35
  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,3 +1,6 @@
1
+ export { ErrorView } from './ErrorView';
2
+ export type { ErrorViewProps } from './ErrorView';
3
+ export { AuthRequiredView } from './AuthRequiredView';
1
4
  export { MockFileBrowser } from './MockFileBrowser';
2
5
  export type { MockFileBrowserProps } from './MockFileBrowser';
3
6
  export { MainContent } from './MainContent';
@@ -15,3 +18,5 @@ export type { TimeTravelProps } from './TimeTravel';
15
18
  export { LexicalEditor } from './LexicalEditor';
16
19
  export type { LexicalEditorProps } from './LexicalEditor';
17
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';