@datalayer/agent-runtimes 1.0.4 → 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 (267) hide show
  1. package/README.md +34 -0
  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 -106
  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 +1083 -157
  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 +108 -113
  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 +0 -18
  46. package/lib/client/AgentsMixin.js +6 -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 +5 -1
  54. package/lib/config/AgentConfiguration.js +3 -3
  55. package/lib/context/ContextDistribution.d.ts +3 -1
  56. package/lib/context/ContextDistribution.js +8 -27
  57. package/lib/context/ContextInspector.d.ts +3 -1
  58. package/lib/context/ContextInspector.js +19 -67
  59. package/lib/context/ContextPanel.d.ts +3 -1
  60. package/lib/context/ContextPanel.js +104 -64
  61. package/lib/context/ContextUsage.d.ts +3 -1
  62. package/lib/context/ContextUsage.js +3 -3
  63. package/lib/context/CostTracker.d.ts +9 -3
  64. package/lib/context/CostTracker.js +26 -47
  65. package/lib/context/CostUsageChart.d.ts +12 -0
  66. package/lib/context/CostUsageChart.js +378 -0
  67. package/lib/context/GraphFlowChart.d.ts +16 -0
  68. package/lib/context/GraphFlowChart.js +182 -0
  69. package/lib/context/TokenUsageChart.d.ts +8 -1
  70. package/lib/context/TokenUsageChart.js +349 -211
  71. package/lib/context/TurnGraphChart.d.ts +39 -0
  72. package/lib/context/TurnGraphChart.js +538 -0
  73. package/lib/context/otelWsPool.d.ts +20 -0
  74. package/lib/context/otelWsPool.js +69 -0
  75. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
  76. package/lib/examples/A2UiComponentGalleryExample.js +315 -522
  77. package/lib/examples/A2UiContactCardExample.d.ts +0 -18
  78. package/lib/examples/A2UiContactCardExample.js +154 -411
  79. package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
  80. package/lib/examples/A2UiRestaurantExample.js +114 -212
  81. package/lib/examples/A2UiViewerExample.d.ts +0 -18
  82. package/lib/examples/A2UiViewerExample.js +283 -532
  83. package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
  84. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
  85. package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
  86. package/lib/examples/AgentCheckpointsExample.js +13 -27
  87. package/lib/examples/AgentCodemodeExample.d.ts +4 -6
  88. package/lib/examples/AgentCodemodeExample.js +591 -169
  89. package/lib/examples/AgentEvalsExample.js +12 -16
  90. package/lib/examples/AgentGuardrailsExample.js +370 -64
  91. package/lib/examples/AgentHooksExample.d.ts +3 -0
  92. package/lib/examples/AgentHooksExample.js +104 -0
  93. package/lib/examples/AgentMCPExample.d.ts +3 -0
  94. package/lib/examples/AgentMCPExample.js +480 -0
  95. package/lib/examples/AgentMemoryExample.js +13 -17
  96. package/lib/examples/AgentMonitoringExample.js +260 -199
  97. package/lib/examples/AgentNotificationsExample.js +49 -17
  98. package/lib/examples/AgentOtelExample.js +2 -3
  99. package/lib/examples/AgentOutputsExample.d.ts +11 -6
  100. package/lib/examples/AgentOutputsExample.js +382 -81
  101. package/lib/examples/AgentParametersExample.d.ts +3 -0
  102. package/lib/examples/AgentParametersExample.js +246 -0
  103. package/lib/examples/AgentSandboxExample.d.ts +2 -2
  104. package/lib/examples/AgentSandboxExample.js +68 -40
  105. package/lib/examples/AgentSkillsExample.js +91 -99
  106. package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
  107. package/lib/examples/AgentSubagentsExample.d.ts +14 -0
  108. package/lib/examples/AgentSubagentsExample.js +228 -0
  109. package/lib/examples/AgentToolApprovalsExample.js +29 -557
  110. package/lib/examples/AgentTriggersExample.js +819 -565
  111. package/lib/examples/ChatCustomExample.js +11 -24
  112. package/lib/examples/ChatExample.js +7 -24
  113. package/lib/examples/CopilotKitLexicalExample.js +2 -1
  114. package/lib/examples/CopilotKitNotebookExample.js +2 -1
  115. package/lib/examples/HomeExample.d.ts +15 -0
  116. package/lib/examples/HomeExample.js +77 -0
  117. package/lib/examples/Lexical2Example.js +4 -2
  118. package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
  119. package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +65 -16
  120. package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
  121. package/lib/examples/LexicalAgentSidebarExample.js +261 -0
  122. package/lib/examples/NotebookAgentExample.d.ts +9 -0
  123. package/lib/examples/NotebookAgentExample.js +192 -0
  124. package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
  125. package/lib/examples/NotebookAgentSidebarExample.js +221 -0
  126. package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
  127. package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
  128. package/lib/examples/NotebookExample.d.ts +4 -7
  129. package/lib/examples/NotebookExample.js +14 -146
  130. package/lib/examples/components/AuthRequiredView.d.ts +6 -0
  131. package/lib/examples/components/AuthRequiredView.js +33 -0
  132. package/lib/examples/components/ExampleWrapper.d.ts +7 -0
  133. package/lib/examples/components/ExampleWrapper.js +25 -6
  134. package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
  135. package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
  136. package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
  137. package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
  138. package/lib/examples/components/index.d.ts +3 -0
  139. package/lib/examples/components/index.js +4 -0
  140. package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
  141. package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
  142. package/lib/examples/example-selector.d.ts +17 -4
  143. package/lib/examples/example-selector.js +107 -41
  144. package/lib/examples/index.d.ts +9 -6
  145. package/lib/examples/index.js +9 -6
  146. package/lib/examples/main.js +217 -27
  147. package/lib/examples/utils/a2ui.d.ts +18 -0
  148. package/lib/examples/utils/a2ui.js +69 -0
  149. package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
  150. package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
  151. package/lib/examples/utils/agentId.d.ts +18 -0
  152. package/lib/examples/utils/agentId.js +54 -0
  153. package/lib/examples/utils/agents/earthquake-detector.json +11 -11
  154. package/lib/examples/utils/agents/sales-forecaster.json +11 -11
  155. package/lib/examples/utils/agents/social-post-generator.json +11 -11
  156. package/lib/examples/utils/agents/stock-market.json +11 -11
  157. package/lib/examples/utils/examplesStore.js +82 -27
  158. package/lib/hooks/index.d.ts +8 -8
  159. package/lib/hooks/index.js +7 -7
  160. package/lib/hooks/useA2A.d.ts +2 -3
  161. package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
  162. package/lib/hooks/useAIAgentsWebSocket.js +118 -12
  163. package/lib/hooks/useAcp.d.ts +1 -2
  164. package/lib/hooks/useAgUi.d.ts +1 -1
  165. package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +39 -2
  166. package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
  167. package/lib/hooks/useAgentsCatalog.js +1 -1
  168. package/lib/hooks/useAgentsService.d.ts +2 -2
  169. package/lib/hooks/useAgentsService.js +7 -7
  170. package/lib/hooks/useCheckpoints.js +1 -1
  171. package/lib/hooks/useConfig.d.ts +4 -1
  172. package/lib/hooks/useConfig.js +10 -3
  173. package/lib/hooks/useContextSnapshot.d.ts +9 -4
  174. package/lib/hooks/useContextSnapshot.js +9 -37
  175. package/lib/hooks/useMonitoring.js +3 -0
  176. package/lib/hooks/useSandbox.d.ts +20 -8
  177. package/lib/hooks/useSandbox.js +105 -40
  178. package/lib/hooks/useSkills.d.ts +23 -5
  179. package/lib/hooks/useSkills.js +94 -39
  180. package/lib/hooks/useToolApprovals.d.ts +60 -36
  181. package/lib/hooks/useToolApprovals.js +318 -69
  182. package/lib/hooks/useVercelAI.d.ts +1 -1
  183. package/lib/index.d.ts +2 -1
  184. package/lib/index.js +1 -0
  185. package/lib/inference/index.d.ts +0 -1
  186. package/lib/middleware/index.d.ts +0 -1
  187. package/lib/protocols/AGUIAdapter.js +6 -0
  188. package/lib/protocols/VercelAIAdapter.d.ts +7 -0
  189. package/lib/protocols/VercelAIAdapter.js +59 -7
  190. package/lib/specs/agents/agents.d.ts +10 -0
  191. package/lib/specs/agents/agents.js +2139 -262
  192. package/lib/specs/agents/index.js +3 -1
  193. package/lib/specs/envvars.d.ts +1 -0
  194. package/lib/specs/envvars.js +38 -20
  195. package/lib/specs/evals.js +6 -6
  196. package/lib/specs/events.d.ts +3 -10
  197. package/lib/specs/events.js +127 -84
  198. package/lib/specs/frontendTools.js +2 -2
  199. package/lib/specs/guardrails.d.ts +0 -7
  200. package/lib/specs/guardrails.js +240 -159
  201. package/lib/specs/index.d.ts +1 -0
  202. package/lib/specs/index.js +1 -0
  203. package/lib/specs/mcpServers.js +35 -6
  204. package/lib/specs/memory.d.ts +0 -2
  205. package/lib/specs/memory.js +4 -17
  206. package/lib/specs/models.js +25 -5
  207. package/lib/specs/notifications.js +102 -18
  208. package/lib/specs/outputs.js +15 -9
  209. package/lib/specs/personas.d.ts +41 -0
  210. package/lib/specs/personas.js +168 -0
  211. package/lib/specs/skills.d.ts +2 -1
  212. package/lib/specs/skills.js +41 -23
  213. package/lib/specs/teams/index.js +3 -1
  214. package/lib/specs/teams/teams.js +468 -348
  215. package/lib/specs/tools.js +4 -4
  216. package/lib/specs/triggers.js +61 -11
  217. package/lib/stores/agentRuntimeStore.d.ts +204 -0
  218. package/lib/stores/agentRuntimeStore.js +636 -0
  219. package/lib/stores/index.d.ts +1 -1
  220. package/lib/stores/index.js +1 -1
  221. package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
  222. package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
  223. package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
  224. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
  225. package/lib/tools/index.d.ts +0 -2
  226. package/lib/tools/index.js +0 -1
  227. package/lib/types/agentspecs.d.ts +50 -1
  228. package/lib/types/chat.d.ts +309 -8
  229. package/lib/types/context.d.ts +27 -0
  230. package/lib/types/cost.d.ts +2 -2
  231. package/lib/types/index.d.ts +2 -0
  232. package/lib/types/index.js +2 -0
  233. package/lib/types/mcp.d.ts +8 -0
  234. package/lib/types/models.d.ts +2 -2
  235. package/lib/types/personas.d.ts +25 -0
  236. package/lib/types/personas.js +5 -0
  237. package/lib/types/skills.d.ts +43 -1
  238. package/lib/types/stream.d.ts +110 -0
  239. package/lib/types/stream.js +36 -0
  240. package/lib/utils/utils.d.ts +9 -5
  241. package/lib/utils/utils.js +9 -5
  242. package/package.json +13 -9
  243. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  244. package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
  245. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  246. package/scripts/codegen/generate_agents.py +102 -6
  247. package/scripts/codegen/generate_events.py +35 -13
  248. package/scripts/codegen/generate_personas.py +319 -0
  249. package/scripts/codegen/generate_skills.py +9 -9
  250. package/scripts/sync-jupyter.sh +26 -7
  251. package/lib/api/tool-approvals.d.ts +0 -62
  252. package/lib/api/tool-approvals.js +0 -145
  253. package/lib/examples/LexicalSidebarExample.js +0 -163
  254. package/lib/examples/NotebookSidebarExample.js +0 -119
  255. package/lib/examples/NotebookSimpleExample.d.ts +0 -6
  256. package/lib/examples/NotebookSimpleExample.js +0 -22
  257. package/lib/examples/ag-ui/index.d.ts +0 -10
  258. package/lib/examples/ag-ui/index.js +0 -16
  259. package/lib/hooks/useAgentsRegistry.d.ts +0 -10
  260. package/lib/hooks/useAgentsRegistry.js +0 -20
  261. package/lib/stores/agentsStore.d.ts +0 -123
  262. package/lib/stores/agentsStore.js +0 -270
  263. /package/lib/examples/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
  264. /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
  265. /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
  266. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
  267. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
@@ -0,0 +1,18 @@
1
+ import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
2
+ import { MessageProcessor, type A2uiClientAction, type A2uiMessage, type SurfaceModel } from '@a2ui/web_core/v0_9';
3
+ export type A2uiProcessor = MessageProcessor<ReactComponentImplementation>;
4
+ export type A2uiSurfaceModel = SurfaceModel<ReactComponentImplementation>;
5
+ export declare function useA2uiProcessor(onAction?: (action: A2uiClientAction) => void): {
6
+ processor: MessageProcessor<ReactComponentImplementation>;
7
+ surfaces: A2uiSurfaceModel[];
8
+ processMessages: (messages: A2uiMessage[]) => void;
9
+ resetSurfaces: () => void;
10
+ };
11
+ export declare function createSceneMessages(args: {
12
+ surfaceId: string;
13
+ components: Array<Record<string, unknown>>;
14
+ value?: Record<string, unknown>;
15
+ path?: string;
16
+ theme?: Record<string, unknown>;
17
+ sendDataModel?: boolean;
18
+ }): A2uiMessage[];
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ import { useCallback, useEffect, useMemo, useState } from 'react';
6
+ import { basicCatalog, } from '@a2ui/react/v0_9';
7
+ import { MessageProcessor, } from '@a2ui/web_core/v0_9';
8
+ export function useA2uiProcessor(onAction) {
9
+ const processor = useMemo(() => new MessageProcessor([basicCatalog], onAction), [onAction]);
10
+ const [surfaces, setSurfaces] = useState(() => Array.from(processor.model.surfacesMap.values()));
11
+ useEffect(() => {
12
+ const createdSub = processor.onSurfaceCreated(surface => {
13
+ setSurfaces(prev => [...prev, surface]);
14
+ });
15
+ const deletedSub = processor.onSurfaceDeleted(id => {
16
+ setSurfaces(prev => prev.filter(surface => surface.id !== id));
17
+ });
18
+ return () => {
19
+ createdSub.unsubscribe();
20
+ deletedSub.unsubscribe();
21
+ };
22
+ }, [processor]);
23
+ const processMessages = useCallback((messages) => {
24
+ processor.processMessages(messages);
25
+ }, [processor]);
26
+ const resetSurfaces = useCallback(() => {
27
+ Array.from(processor.model.surfacesMap.keys()).forEach(id => {
28
+ processor.model.deleteSurface(id);
29
+ });
30
+ }, [processor]);
31
+ return {
32
+ processor,
33
+ surfaces,
34
+ processMessages,
35
+ resetSurfaces,
36
+ };
37
+ }
38
+ export function createSceneMessages(args) {
39
+ const { surfaceId, components, value, path = '/', theme, sendDataModel = true, } = args;
40
+ const messages = [
41
+ {
42
+ version: 'v0.9',
43
+ createSurface: {
44
+ surfaceId,
45
+ catalogId: basicCatalog.id,
46
+ theme,
47
+ sendDataModel,
48
+ },
49
+ },
50
+ {
51
+ version: 'v0.9',
52
+ updateComponents: {
53
+ surfaceId,
54
+ components,
55
+ },
56
+ },
57
+ ];
58
+ if (value !== undefined) {
59
+ messages.push({
60
+ version: 'v0.9',
61
+ updateDataModel: {
62
+ surfaceId,
63
+ path,
64
+ value,
65
+ },
66
+ });
67
+ }
68
+ return messages;
69
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /**
3
+ * Provides the A2UI v0.9 markdown renderer to all child `A2uiSurface`
4
+ * instances. Without it, `Text` components fall back to the raw markdown
5
+ * string (e.g. `## Title` instead of a rendered `<h2>`).
6
+ */
7
+ export declare const A2uiMarkdownProvider: React.FC<React.PropsWithChildren>;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { MarkdownContext } from '@a2ui/react/v0_9';
3
+ import { renderMarkdown } from '@a2ui/markdown-it';
4
+ /**
5
+ * Provides the A2UI v0.9 markdown renderer to all child `A2uiSurface`
6
+ * instances. Without it, `Text` components fall back to the raw markdown
7
+ * string (e.g. `## Title` instead of a rendered `<h2>`).
8
+ */
9
+ export const A2uiMarkdownProvider = ({ children, }) => (_jsx(MarkdownContext.Provider, { value: renderMarkdown, children: children }));
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Build a unique agent ID by appending a random slug to a base name.
3
+ *
4
+ * The resulting id is cached in ``sessionStorage`` under a key derived from
5
+ * ``baseName``, so a browser refresh within the same tab reuses the same
6
+ * agent id. This is required for server-side per-agent state (enabled
7
+ * tools, approved tools, approved skills, codemode status…) to survive a
8
+ * page reload — those maps are keyed by ``agent_id`` in
9
+ * ``agent_runtimes.streams.loop``.
10
+ *
11
+ * A fresh tab (or a ``sessionStorage.clear()``) produces a new id, which
12
+ * preserves the original "clean telemetry per run" guarantee.
13
+ *
14
+ * @example
15
+ * uniqueAgentId('simple') // → "simple-a3f7b2" (cached)
16
+ * uniqueAgentId('codemode-demo') // → "codemode-demo-k9x2m1" (cached)
17
+ */
18
+ export declare function uniqueAgentId(baseName: string): string;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Generate a short random alphanumeric slug (e.g. "a3f7b2").
7
+ * Used to make agent IDs unique per session so that each fresh
8
+ * example run starts with clean OTEL / telemetry data.
9
+ */
10
+ function randomSlug(length = 6) {
11
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
12
+ let slug = '';
13
+ const array = new Uint8Array(length);
14
+ crypto.getRandomValues(array);
15
+ for (let i = 0; i < length; i++) {
16
+ slug += chars[array[i] % chars.length];
17
+ }
18
+ return slug;
19
+ }
20
+ /**
21
+ * Build a unique agent ID by appending a random slug to a base name.
22
+ *
23
+ * The resulting id is cached in ``sessionStorage`` under a key derived from
24
+ * ``baseName``, so a browser refresh within the same tab reuses the same
25
+ * agent id. This is required for server-side per-agent state (enabled
26
+ * tools, approved tools, approved skills, codemode status…) to survive a
27
+ * page reload — those maps are keyed by ``agent_id`` in
28
+ * ``agent_runtimes.streams.loop``.
29
+ *
30
+ * A fresh tab (or a ``sessionStorage.clear()``) produces a new id, which
31
+ * preserves the original "clean telemetry per run" guarantee.
32
+ *
33
+ * @example
34
+ * uniqueAgentId('simple') // → "simple-a3f7b2" (cached)
35
+ * uniqueAgentId('codemode-demo') // → "codemode-demo-k9x2m1" (cached)
36
+ */
37
+ export function uniqueAgentId(baseName) {
38
+ const storageKey = `agent-runtimes:agentId:${baseName}`;
39
+ try {
40
+ if (typeof sessionStorage !== 'undefined') {
41
+ const cached = sessionStorage.getItem(storageKey);
42
+ if (cached && cached.startsWith(`${baseName}-`)) {
43
+ return cached;
44
+ }
45
+ const fresh = `${baseName}-${randomSlug()}`;
46
+ sessionStorage.setItem(storageKey, fresh);
47
+ return fresh;
48
+ }
49
+ }
50
+ catch {
51
+ // sessionStorage unavailable (e.g. SSR, privacy mode); fall through.
52
+ }
53
+ return `${baseName}-${randomSlug()}`;
54
+ }
@@ -1,13 +1,13 @@
1
1
  {
2
- "id": "earthquake-detector",
3
- "title": "Earthquake Detector",
4
- "description": "Real-time seismic activity monitoring and earthquake alert system.",
5
- "image": "https://images.unsplash.com/photo-1589519160732-57fc498494f8?w=300&h=150&fit=crop",
6
- "author": "Eric Charles",
7
- "editTimestamp": "53 minutes ago",
8
- "status": "paused",
9
- "transport": "ag-ui",
10
- "avatarUrl": "https://avatars.githubusercontent.com/atom",
11
- "stars": 4,
12
- "notifications": 0
2
+ "id": "earthquake-detector",
3
+ "title": "Earthquake Detector",
4
+ "description": "Real-time seismic activity monitoring and earthquake alert system.",
5
+ "image": "https://images.unsplash.com/photo-1589519160732-57fc498494f8?w=300&h=150&fit=crop",
6
+ "author": "Eric Charles",
7
+ "editTimestamp": "53 minutes ago",
8
+ "status": "paused",
9
+ "transport": "ag-ui",
10
+ "avatarUrl": "https://avatars.githubusercontent.com/atom",
11
+ "stars": 4,
12
+ "notifications": 0
13
13
  }
@@ -1,13 +1,13 @@
1
1
  {
2
- "id": "sales-forecaster",
3
- "title": "Sales Forecaster",
4
- "description": "AI-powered sales prediction and revenue forecasting tool.",
5
- "image": "https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=300&h=150&fit=crop",
6
- "author": "Eric Charles",
7
- "editTimestamp": "1 hour ago",
8
- "status": "running",
9
- "transport": "vercel-ai",
10
- "avatarUrl": "https://avatars.githubusercontent.com/github",
11
- "stars": 5,
12
- "notifications": 2
2
+ "id": "sales-forecaster",
3
+ "title": "Sales Forecaster",
4
+ "description": "AI-powered sales prediction and revenue forecasting tool.",
5
+ "image": "https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=300&h=150&fit=crop",
6
+ "author": "Eric Charles",
7
+ "editTimestamp": "1 hour ago",
8
+ "status": "running",
9
+ "transport": "vercel-ai",
10
+ "avatarUrl": "https://avatars.githubusercontent.com/github",
11
+ "stars": 5,
12
+ "notifications": 2
13
13
  }
@@ -1,13 +1,13 @@
1
1
  {
2
- "id": "social-post-generator",
3
- "title": "Social Post Generator",
4
- "description": "A powerful agent template for automated social media post generation.",
5
- "image": "https://images.unsplash.com/photo-1611926653458-09294b3142bf?w=300&h=150&fit=crop",
6
- "author": "Eric Charles",
7
- "editTimestamp": "2 hours ago",
8
- "status": "paused",
9
- "transport": "ag-ui",
10
- "avatarUrl": "https://avatars.githubusercontent.com/primer",
11
- "stars": 3,
12
- "notifications": 1
2
+ "id": "social-post-generator",
3
+ "title": "Social Post Generator",
4
+ "description": "A powerful agent template for automated social media post generation.",
5
+ "image": "https://images.unsplash.com/photo-1611926653458-09294b3142bf?w=300&h=150&fit=crop",
6
+ "author": "Eric Charles",
7
+ "editTimestamp": "2 hours ago",
8
+ "status": "paused",
9
+ "transport": "ag-ui",
10
+ "avatarUrl": "https://avatars.githubusercontent.com/primer",
11
+ "stars": 3,
12
+ "notifications": 1
13
13
  }
@@ -1,13 +1,13 @@
1
1
  {
2
- "id": "stocks-watcher",
3
- "title": "Stocks Watcher",
4
- "description": "Intelligent stock market analysis and portfolio tracking agent.",
5
- "image": "https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=300&h=150&fit=crop",
6
- "author": "Gonzalo Peña-Castellanos",
7
- "editTimestamp": "3 days ago",
8
- "status": "paused",
9
- "transport": "acp",
10
- "avatarUrl": "https://avatars.githubusercontent.com/desktop",
11
- "stars": 1,
12
- "notifications": 0
2
+ "id": "stocks-watcher",
3
+ "title": "Stocks Watcher",
4
+ "description": "Intelligent stock market analysis and portfolio tracking agent.",
5
+ "image": "https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=300&h=150&fit=crop",
6
+ "author": "Gonzalo Peña-Castellanos",
7
+ "editTimestamp": "3 days ago",
8
+ "status": "paused",
9
+ "transport": "acp",
10
+ "avatarUrl": "https://avatars.githubusercontent.com/desktop",
11
+ "stars": 1,
12
+ "notifications": 0
13
13
  }
@@ -4,34 +4,89 @@
4
4
  */
5
5
  import { createStore } from 'zustand/vanilla';
6
6
  import { useStore } from 'zustand';
7
- // Import agent examples data files.
8
- import earthquakeDetectorData from './agents/earthquake-detector.json';
9
- import stocksWatcherData from './agents/stock-market.json';
10
- import salesForecasterData from './agents/sales-forecaster.json';
11
- import socialPostGeneratorData from './agents/social-post-generator.json';
12
- // Helper function to transform JSON data to Agent format
13
- const transformAgentData = (data, notebookSuffix, lexicalSuffix) => ({
14
- id: data.id,
15
- name: data.title,
16
- description: data.description,
17
- author: data.author,
18
- lastEdited: data.editTimestamp,
19
- screenshot: data.image,
20
- status: data.status,
21
- protocol: data.transport,
22
- avatarUrl: data.avatarUrl,
23
- notebookFile: `${notebookSuffix}.ipynb.json`,
24
- lexicalFile: `${lexicalSuffix}.lexical.json`,
25
- stars: data.stars || 0,
26
- notifications: data.notifications || 0,
7
+ import { listPersonas } from '../../specs/personas';
8
+ const DEFAULT_PRESENTATION = {
9
+ author: 'Datalayer',
10
+ lastEdited: 'just now',
11
+ screenshot: 'https://images.unsplash.com/photo-1531297484001-80022131f5a1?w=300&h=150&fit=crop',
12
+ status: 'paused',
13
+ protocol: 'vercel-ai',
14
+ avatarUrl: 'https://avatars.githubusercontent.com/datalayer',
15
+ notebookFile: '',
16
+ lexicalFile: '',
17
+ stars: 0,
18
+ notifications: 0,
19
+ };
20
+ const PERSONA_PRESENTATIONS = {
21
+ sentinel: {
22
+ author: 'Eric Charles',
23
+ lastEdited: '53 minutes ago',
24
+ screenshot: 'https://images.unsplash.com/photo-1589519160732-57fc498494f8?w=300&h=150&fit=crop',
25
+ status: 'paused',
26
+ protocol: 'ag-ui',
27
+ avatarUrl: 'https://avatars.githubusercontent.com/atom',
28
+ notebookFile: 'earthquake-detector.ipynb.json',
29
+ lexicalFile: 'earthquake-detector.lexical.json',
30
+ stars: 4,
31
+ },
32
+ trader: {
33
+ author: 'Gonzalo Peña-Castellanos',
34
+ lastEdited: '3 days ago',
35
+ screenshot: 'https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?w=300&h=150&fit=crop',
36
+ status: 'paused',
37
+ protocol: 'acp',
38
+ avatarUrl: 'https://avatars.githubusercontent.com/desktop',
39
+ notebookFile: 'stock-market.ipynb.json',
40
+ lexicalFile: 'stock-market.lexical.json',
41
+ stars: 1,
42
+ },
43
+ forecaster: {
44
+ author: 'Eric Charles',
45
+ lastEdited: '1 hour ago',
46
+ screenshot: 'https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=300&h=150&fit=crop',
47
+ status: 'running',
48
+ protocol: 'vercel-ai',
49
+ avatarUrl: 'https://avatars.githubusercontent.com/github',
50
+ notebookFile: 'sales-forecaster.ipynb.json',
51
+ lexicalFile: 'sales-forecaster.lexical.json',
52
+ stars: 5,
53
+ notifications: 2,
54
+ },
55
+ marketing: {
56
+ author: 'Eric Charles',
57
+ lastEdited: '2 hours ago',
58
+ screenshot: 'https://images.unsplash.com/photo-1611926653458-09294b3142bf?w=300&h=150&fit=crop',
59
+ status: 'paused',
60
+ protocol: 'ag-ui',
61
+ avatarUrl: 'https://avatars.githubusercontent.com/primer',
62
+ notebookFile: 'social-post-generator.ipynb.json',
63
+ lexicalFile: 'social-post-generator.lexical.json',
64
+ stars: 3,
65
+ notifications: 1,
66
+ },
67
+ };
68
+ // Build the agent list from the generated personas catalogue.
69
+ const initialAgents = listPersonas().map(persona => {
70
+ const presentation = {
71
+ ...DEFAULT_PRESENTATION,
72
+ ...(PERSONA_PRESENTATIONS[persona.id] ?? {}),
73
+ };
74
+ return {
75
+ id: persona.id,
76
+ name: persona.name,
77
+ description: persona.description,
78
+ author: presentation.author,
79
+ lastEdited: presentation.lastEdited,
80
+ screenshot: presentation.screenshot,
81
+ status: presentation.status,
82
+ protocol: presentation.protocol,
83
+ avatarUrl: presentation.avatarUrl,
84
+ notebookFile: presentation.notebookFile,
85
+ lexicalFile: presentation.lexicalFile,
86
+ stars: presentation.stars,
87
+ notifications: presentation.notifications,
88
+ };
27
89
  });
28
- // Initialize agents from the agents folder
29
- const initialAgents = [
30
- transformAgentData(earthquakeDetectorData, 'earthquake-detector', 'earthquake-detector'),
31
- transformAgentData(stocksWatcherData, 'stock-market', 'stock-market'),
32
- transformAgentData(salesForecasterData, 'sales-forecaster', 'sales-forecaster'),
33
- transformAgentData(socialPostGeneratorData, 'social-post-generator', 'social-post-generator'),
34
- ];
35
90
  export const agentsStore = createStore(set => ({
36
91
  agents: initialAgents,
37
92
  getAgentById: (id) => {
@@ -40,7 +40,7 @@ export { useFrontendTool, useBackendTool, useRegisteredTools, useTool, usePendin
40
40
  * ChatBase infrastructure hooks.
41
41
  */
42
42
  export { useConfig } from './useConfig';
43
- export { useSkills } from './useSkills';
43
+ export { useSkills, useSkillActions, useAgentRuntimeLoadedSkills as useAgentLoadedSkills, } from './useSkills';
44
44
  export { useContextSnapshot } from './useContextSnapshot';
45
45
  export { useSandbox } from './useSandbox';
46
46
  /**
@@ -66,19 +66,19 @@ export { useVercelAI } from './useVercelAI';
66
66
  /**
67
67
  * Unified hook for managing agents — both ephemeral and durable.
68
68
  */
69
- export { useAgents } from './useAgents';
69
+ export { useAgentRuntimes } from './useAgentRuntimes';
70
70
  /**
71
71
  * Runtime query and mutation hooks.
72
72
  */
73
- export { useAgentsRuntimes, useAgentRuntimes, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgents';
73
+ export { useAgentsRuntimes, useAgentRuntimesQuery, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgentRuntimes';
74
74
  /**
75
- * Agent catalog store, AI Agents REST API, and registry hooks.
75
+ * Agent-runtime WebSocket stream hook.
76
76
  */
77
- export { useAgentCatalogStore, type AgentCatalogStoreState, } from './useAgentsCatalog';
77
+ export { useAgentRuntimeWebSocket, type UseAgentRuntimeWebSocketOptions, } from './useAgentRuntimes';
78
78
  /**
79
- * Agent registry hook.
79
+ * Agent catalog store, AI Agents REST API, and registry hooks.
80
80
  */
81
- export { useAgentRegistry } from './useAgentsRegistry';
81
+ export { useAgentCatalogStore, type AgentCatalogStoreState, } from './useAgentsCatalog';
82
82
  /**
83
83
  * Agents Service REST API (deprecated).
84
84
  */
@@ -89,5 +89,5 @@ export { useAgentsService, useNotebookAgents } from './useAgentsService';
89
89
  export { useCheckpoints, useCheckpointsQuery, useRefreshCheckpoints, useDeletePausedAgentRuntime, useResumePausedAgentRuntime, usePauseAgent, useResumeAgent, useCheckpointAgent, useTerminateAgent, useAgentLifecycle, type CheckpointData, type PauseAgentParams, type ResumeAgentParams, type CheckpointAgentParams, type TerminateAgentParams, type AgentLifecycleOptions, type AgentLifecycleReturn, } from './useCheckpoints';
90
90
  export { useToolApprovals, useToolApprovalsQuery, usePendingApprovalCount, useApproveToolRequest, useRejectToolRequest, } from './useToolApprovals';
91
91
  export { useNotifications, useFilteredNotifications, useUnreadNotificationCount, useMarkNotificationRead, useMarkAllNotificationsRead, useAllAgentEvents, useAgentEvents, useAgentEvent, useCreateAgentEvent, useUpdateAgentEvent, useDeleteAgentEvent, useMarkEventRead, useMarkEventUnread, } from './useNotifications';
92
- export { useAIAgentsWebSocket, type UseAIAgentsWebSocketOptions, } from './useAIAgentsWebSocket';
92
+ export { useAIAgentsWebSocket, type UseAIAgentsWebSocketOptions, type UseAIAgentsWebSocketResult, type AIAgentsWebSocketCloseInfo, type AIAgentsWebSocketConnectionState, } from './useAIAgentsWebSocket';
93
93
  export { useOtelTotalTokens, fetchOtelTotalTokens, fetchOtelMetricTotal, fetchOtelMetricRows, toMetricValue, } from './useMonitoring';
@@ -47,7 +47,7 @@ export { useFrontendTool, useBackendTool, useRegisteredTools, useTool, usePendin
47
47
  * ChatBase infrastructure hooks.
48
48
  */
49
49
  export { useConfig } from './useConfig';
50
- export { useSkills } from './useSkills';
50
+ export { useSkills, useSkillActions, useAgentRuntimeLoadedSkills as useAgentLoadedSkills, } from './useSkills';
51
51
  export { useContextSnapshot } from './useContextSnapshot';
52
52
  export { useSandbox } from './useSandbox';
53
53
  // =============================================================================
@@ -79,19 +79,19 @@ export { useVercelAI } from './useVercelAI';
79
79
  /**
80
80
  * Unified hook for managing agents — both ephemeral and durable.
81
81
  */
82
- export { useAgents } from './useAgents';
82
+ export { useAgentRuntimes } from './useAgentRuntimes';
83
83
  /**
84
84
  * Runtime query and mutation hooks.
85
85
  */
86
- export { useAgentsRuntimes, useAgentRuntimes, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgents';
86
+ export { useAgentsRuntimes, useAgentRuntimesQuery, useAgentRuntimeByPodName, useCreateAgentRuntime, useDeleteAgentRuntime, useRefreshAgentRuntimes, agentQueryKeys, AGENT_QUERY_OPTIONS, useAgentLifecycleStore, getAgentLifecycleKey, } from './useAgentRuntimes';
87
87
  /**
88
- * Agent catalog store, AI Agents REST API, and registry hooks.
88
+ * Agent-runtime WebSocket stream hook.
89
89
  */
90
- export { useAgentCatalogStore, } from './useAgentsCatalog';
90
+ export { useAgentRuntimeWebSocket, } from './useAgentRuntimes';
91
91
  /**
92
- * Agent registry hook.
92
+ * Agent catalog store, AI Agents REST API, and registry hooks.
93
93
  */
94
- export { useAgentRegistry } from './useAgentsRegistry';
94
+ export { useAgentCatalogStore, } from './useAgentsCatalog';
95
95
  /**
96
96
  * Agents Service REST API (deprecated).
97
97
  */
@@ -1,5 +1,4 @@
1
- import type { AgentCard, Task, TaskState } from '@a2a-js/sdk';
2
- export type { AgentCard, Task, TaskState };
1
+ import type { AgentCard, Task } from '@a2a-js/sdk';
3
2
  export interface Message {
4
3
  role: 'user' | 'assistant' | 'system';
5
4
  content: string;
@@ -9,7 +8,7 @@ export interface Message {
9
8
  }
10
9
  export interface UseA2AOptions {
11
10
  /**
12
- * Base URL for the A2A endpoint (e.g., 'http://localhost:8000')
11
+ * Base URL for the A2A endpoint (e.g., `http://localhost:8000`).
13
12
  */
14
13
  baseUrl?: string;
15
14
  /**
@@ -1,15 +1,54 @@
1
1
  /** A message pushed by the server. */
2
2
  interface WSMessage {
3
- channel: string;
4
- event: string;
5
- data: Record<string, unknown>;
3
+ channel?: string;
4
+ event?: string;
5
+ data?: Record<string, unknown>;
6
+ type?: string;
7
+ payload?: unknown;
8
+ raw: unknown;
6
9
  }
10
+ export interface AIAgentsWebSocketCloseInfo {
11
+ code: number;
12
+ reason: string;
13
+ wasClean: boolean;
14
+ detail: string;
15
+ }
16
+ export type AIAgentsWebSocketConnectionState = 'connecting' | 'connected' | 'closed';
7
17
  /** Options for the WebSocket hook. */
8
18
  export interface UseAIAgentsWebSocketOptions {
19
+ /** Enable/disable the socket lifecycle. */
20
+ enabled?: boolean;
21
+ /** Override the service base URL (defaults to aiagentsRunUrl). */
22
+ baseUrl?: string;
23
+ /** WebSocket path (or full http/https URL) for the stream endpoint. */
24
+ path?: string;
25
+ /** Query string parameters to append to the WebSocket URL. */
26
+ queryParams?: Record<string, string | number | boolean | null | undefined>;
27
+ /** Auto-reconnect on unexpected disconnects. */
28
+ autoReconnect?: boolean;
29
+ /** Max reconnect attempts before giving up (unbounded by default). */
30
+ maxReconnectAttempts?: number;
31
+ /** Reconnect delay strategy (ms) or static delay in ms. */
32
+ reconnectDelayMs?: number | ((attempt: number) => number);
9
33
  /** Additional channels to subscribe to beyond the auto-subscribed user channel. */
10
34
  channels?: string[];
35
+ /** Called when the socket opens. */
36
+ onOpen?: () => void;
11
37
  /** Called for every incoming message (optional). */
12
38
  onMessage?: (msg: WSMessage) => void;
39
+ /** Called when the socket closes. */
40
+ onClose?: (info: AIAgentsWebSocketCloseInfo) => void;
41
+ }
42
+ export interface UseAIAgentsWebSocketResult {
43
+ connectionState: AIAgentsWebSocketConnectionState;
44
+ lastClose: AIAgentsWebSocketCloseInfo | null;
45
+ reconnectAttempt: number;
46
+ /**
47
+ * Send a JSON payload on the underlying WebSocket.
48
+ * Returns `true` when the message was sent, `false` when the socket
49
+ * isn't open (the caller can retry once `connectionState === 'connected'`).
50
+ */
51
+ send: (payload: unknown) => boolean;
13
52
  }
14
53
  /**
15
54
  * Connect to the AI Agents generic WebSocket.
@@ -25,5 +64,5 @@ export interface UseAIAgentsWebSocketOptions {
25
64
  * useAIAgentsWebSocket({ channels: [`agent:${agentId}`] });
26
65
  * ```
27
66
  */
28
- export declare function useAIAgentsWebSocket(options?: UseAIAgentsWebSocketOptions): void;
67
+ export declare function useAIAgentsWebSocket(options?: UseAIAgentsWebSocketOptions): UseAIAgentsWebSocketResult;
29
68
  export {};