@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
@@ -43,18 +43,22 @@ def load_specs(specs_dir: Path) -> list[dict[str, Any]]:
43
43
 
44
44
 
45
45
  def _py_field(f: dict[str, Any]) -> str:
46
- """Format an EventField as a Python dict literal."""
46
+ """Format an EventField dict body.
47
+
48
+ Returns the lines inside ``EventField(\n **{\n ...\n }\n)``
49
+ so that the generated output matches ``ruff format`` exactly.
50
+ """
47
51
  parts = [
48
- f'"name": "{f["name"]}"',
49
- f'"label": "{f["label"]}"',
50
- f'"type": "{f["type"]}"',
51
- f'"required": {str(f["required"])}',
52
+ f' "name": "{f["name"]}"',
53
+ f' "label": "{f["label"]}"',
54
+ f' "type": "{f["type"]}"',
55
+ f' "required": {str(f["required"])}',
52
56
  ]
53
57
  if "description" in f:
54
- parts.append(f'"description": "{_esc_dq(f["description"])}"')
58
+ parts.append(f' "description": "{_esc_dq(f["description"])}"')
55
59
  if "placeholder" in f:
56
- parts.append(f'"placeholder": "{_esc_dq(f["placeholder"])}"')
57
- return "{" + ", ".join(parts) + "}"
60
+ parts.append(f' "placeholder": "{_esc_dq(f["placeholder"])}"')
61
+ return ",\n".join(parts)
58
62
 
59
63
 
60
64
  def _ts_field(f: dict[str, Any]) -> str:
@@ -90,7 +94,6 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
90
94
  "",
91
95
  "from agent_runtimes.types import EventField, EventSpec",
92
96
  "",
93
- "",
94
97
  "# " + "=" * 76,
95
98
  "# Event Definitions",
96
99
  "# " + "=" * 76,
@@ -118,10 +121,18 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
118
121
  ]
119
122
  )
120
123
  if fields:
121
- field_strs = [_py_field(f) for f in fields]
122
124
  lines.append(" fields=[")
123
- for fs in field_strs:
124
- lines.append(f" EventField(**{fs}),")
125
+ for f in fields:
126
+ field_body = _py_field(f)
127
+ lines.extend(
128
+ [
129
+ " EventField(",
130
+ " **{",
131
+ field_body + ",",
132
+ " }",
133
+ " ),",
134
+ ]
135
+ )
125
136
  lines.append(" ],")
126
137
  lines.extend([")", ""])
127
138
 
@@ -149,10 +160,17 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
149
160
  "# Event kind constants for programmatic use",
150
161
  ]
151
162
  )
163
+
164
+ spec_kinds = {spec.get("kind", spec["id"]) for spec in specs}
165
+
152
166
  for spec in specs:
153
167
  kind = spec.get("kind", spec["id"])
154
168
  const = kind.upper().replace("-", "_")
155
169
  lines.append(f'EVENT_KIND_{const} = "{kind}"')
170
+
171
+ # Backward-compat constants used by older runtime code paths.
172
+ if "agent-assigned" not in spec_kinds:
173
+ lines.append('EVENT_KIND_AGENT_ASSIGNED = "agent-assigned"')
156
174
  lines.extend(
157
175
  [
158
176
  "",
@@ -162,8 +180,8 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
162
180
  " spec = EVENT_CATALOG.get(event_id)",
163
181
  " if spec is not None:",
164
182
  " return spec",
165
- " base, _, ver = event_id.rpartition(':')",
166
- " if base and '.' in ver:",
183
+ ' base, _, ver = event_id.rpartition(":")',
184
+ ' if base and "." in ver:',
167
185
  " return EVENT_CATALOG.get(base)",
168
186
  " return None",
169
187
  "",
@@ -233,11 +251,14 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
233
251
  lines.extend(["};", ""])
234
252
 
235
253
  # Event kind constants
254
+ spec_kinds = {spec.get("kind", spec["id"]) for spec in specs}
236
255
  lines.append("// Event kind constants for programmatic use")
237
256
  for spec in specs:
238
257
  kind = spec.get("kind", spec["id"])
239
258
  const = kind.upper().replace("-", "_")
240
259
  lines.append(f"export const EVENT_KIND_{const} = '{kind}';")
260
+ if "agent-assigned" not in spec_kinds:
261
+ lines.append("export const EVENT_KIND_AGENT_ASSIGNED = 'agent-assigned';")
241
262
  lines.append("")
242
263
 
243
264
  lines.extend(
@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env python3
2
+ # Copyright (c) 2025-2026 Datalayer, Inc.
3
+ # Distributed under the terms of the Modified BSD License.
4
+
5
+ """
6
+ Generate Python and TypeScript code from YAML persona specifications.
7
+
8
+ Usage:
9
+ python generate_personas.py \\
10
+ --specs-dir agentspecs/agentspecs/personas \\
11
+ --python-output agent_runtimes/specs/personas.py \\
12
+ --typescript-output src/specs/personas.ts
13
+ """
14
+
15
+ import argparse
16
+ import sys
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ import yaml
21
+ from versioning import ensure_spec_version, version_suffix
22
+
23
+
24
+ def _make_const_name(persona_id: str) -> str:
25
+ """Convert a persona ID to a constant name (e.g., 'tutor' -> 'TUTOR_PERSONA')."""
26
+ return f"{persona_id.upper().replace('-', '_')}_PERSONA"
27
+
28
+
29
+ def _make_enum_name(persona_id: str) -> str:
30
+ """Convert a persona ID to an enum member name (e.g., 'tutor' -> 'TUTOR')."""
31
+ return persona_id.upper().replace("-", "_")
32
+
33
+
34
+ def _fmt_str_list_py(items: list[str]) -> str:
35
+ if not items:
36
+ return "[]"
37
+ return "[" + ", ".join(f'"{item}"' for item in items) + "]"
38
+
39
+
40
+ def _fmt_str_list_ts(items: list[str]) -> str:
41
+ if not items:
42
+ return "[]"
43
+ return "[" + ", ".join(f"'{item}'" for item in items) + "]"
44
+
45
+
46
+ def _clean(text: str) -> str:
47
+ return text.replace("\n", " ").replace(" ", " ").strip()
48
+
49
+
50
+ def load_persona_specs(specs_dir: Path) -> list[dict[str, Any]]:
51
+ """Load all persona YAML specifications from a directory."""
52
+ specs = []
53
+ for yaml_file in sorted(specs_dir.glob("*.yaml")):
54
+ with open(yaml_file) as f:
55
+ spec = yaml.safe_load(f)
56
+ ensure_spec_version(spec)
57
+ specs.append(spec)
58
+ return specs
59
+
60
+
61
+ def generate_python_code(specs: list[dict[str, Any]]) -> str:
62
+ """Generate Python code from persona specifications."""
63
+ lines = [
64
+ "# Copyright (c) 2025-2026 Datalayer, Inc.",
65
+ "# Distributed under the terms of the Modified BSD License.",
66
+ '"""',
67
+ "Persona Catalog.",
68
+ "",
69
+ "Predefined Persona configurations built on top of agent specs.",
70
+ "",
71
+ "This file is AUTO-GENERATED from YAML specifications.",
72
+ "DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
73
+ '"""',
74
+ "",
75
+ "from enum import Enum",
76
+ "from typing import Optional",
77
+ "",
78
+ "from agent_runtimes.types import PersonaSpec",
79
+ "",
80
+ "# " + "=" * 76,
81
+ "# Personas Enum",
82
+ "# " + "=" * 76,
83
+ "",
84
+ "",
85
+ "class Personas(str, Enum):",
86
+ ' """Enumeration of available personas."""',
87
+ "",
88
+ ]
89
+
90
+ for spec in specs:
91
+ lines.append(f' {_make_enum_name(spec["id"])} = "{spec["id"]}"')
92
+
93
+ lines.extend(
94
+ [
95
+ "",
96
+ "",
97
+ "# " + "=" * 76,
98
+ "# Persona Definitions",
99
+ "# " + "=" * 76,
100
+ "",
101
+ ]
102
+ )
103
+
104
+ for spec in specs:
105
+ version = spec["version"]
106
+ const_name = _make_const_name(spec["id"]) + version_suffix(version)
107
+ description = _clean(spec.get("description", "")).replace('"', '\\"')
108
+ tags = _fmt_str_list_py(spec.get("tags", []) or [])
109
+ icon = spec.get("icon")
110
+ emoji = spec.get("emoji")
111
+ agent = spec.get("agent")
112
+
113
+ body = [
114
+ f"{const_name} = PersonaSpec(",
115
+ f' id="{spec["id"]}",',
116
+ f' version="{version}",',
117
+ f' name="{spec["name"]}",',
118
+ f' description="{description}",',
119
+ f" tags={tags},",
120
+ ]
121
+ if icon is not None:
122
+ body.append(f' icon="{icon}",')
123
+ if emoji is not None:
124
+ body.append(f' emoji="{emoji}",')
125
+ if agent is not None:
126
+ body.append(f' agent="{agent}",')
127
+ body.append(")")
128
+ body.append("")
129
+ lines.extend(body)
130
+
131
+ lines.extend(
132
+ [
133
+ "",
134
+ "# " + "=" * 76,
135
+ "# Persona Catalog",
136
+ "# " + "=" * 76,
137
+ "",
138
+ "PERSONA_CATALOGUE: dict[str, PersonaSpec] = {",
139
+ ]
140
+ )
141
+
142
+ for spec in specs:
143
+ const_name = _make_const_name(spec["id"]) + version_suffix(spec["version"])
144
+ lines.append(f' "{spec["id"]}": {const_name},')
145
+
146
+ lines.extend(
147
+ [
148
+ "}",
149
+ "",
150
+ "",
151
+ "def get_persona(persona_id: str) -> Optional[PersonaSpec]:",
152
+ ' """Get a persona specification by ID (accepts bare or versioned refs)."""',
153
+ " persona = PERSONA_CATALOGUE.get(persona_id)",
154
+ " if persona is not None:",
155
+ " return persona",
156
+ ' base, _, ver = persona_id.rpartition(":")',
157
+ ' if base and "." in ver:',
158
+ " return PERSONA_CATALOGUE.get(base)",
159
+ " return None",
160
+ "",
161
+ "",
162
+ "def list_personas() -> list[PersonaSpec]:",
163
+ ' """List all available personas."""',
164
+ " return list(PERSONA_CATALOGUE.values())",
165
+ "",
166
+ ]
167
+ )
168
+
169
+ return "\n".join(lines)
170
+
171
+
172
+ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
173
+ """Generate TypeScript code from persona specifications."""
174
+ lines = [
175
+ "/*",
176
+ " * Copyright (c) 2025-2026 Datalayer, Inc.",
177
+ " * Distributed under the terms of the Modified BSD License.",
178
+ " */",
179
+ "",
180
+ "/**",
181
+ " * Persona Catalog",
182
+ " *",
183
+ " * Predefined Persona configurations built on top of agent specs.",
184
+ " *",
185
+ " * This file is AUTO-GENERATED from YAML specifications.",
186
+ " * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
187
+ " */",
188
+ "",
189
+ "import type { PersonaSpec } from '../types';",
190
+ "",
191
+ "// " + "=" * 76,
192
+ "// Personas Enum",
193
+ "// " + "=" * 76,
194
+ "",
195
+ "export const Personas = {",
196
+ ]
197
+
198
+ for spec in specs:
199
+ lines.append(f" {_make_enum_name(spec['id'])}: '{spec['id']}',")
200
+
201
+ lines.extend(
202
+ [
203
+ "} as const;",
204
+ "",
205
+ "export type PersonaId = (typeof Personas)[keyof typeof Personas];",
206
+ "",
207
+ "// " + "=" * 76,
208
+ "// Persona Definitions",
209
+ "// " + "=" * 76,
210
+ "",
211
+ ]
212
+ )
213
+
214
+ for spec in specs:
215
+ version = spec["version"]
216
+ const_name = _make_const_name(spec["id"]) + version_suffix(version)
217
+ description = _clean(spec.get("description", "")).replace("'", "\\'")
218
+ name = spec["name"].replace("'", "\\'")
219
+ tags = _fmt_str_list_ts(spec.get("tags", []) or [])
220
+ icon = spec.get("icon")
221
+ emoji = spec.get("emoji")
222
+ agent = spec.get("agent")
223
+
224
+ block = [
225
+ f"export const {const_name}: PersonaSpec = {{",
226
+ f" id: '{spec['id']}',",
227
+ f" version: '{version}',",
228
+ f" name: '{name}',",
229
+ f" description: '{description}',",
230
+ f" tags: {tags},",
231
+ ]
232
+ if icon is not None:
233
+ block.append(f" icon: '{icon}',")
234
+ if emoji is not None:
235
+ block.append(f" emoji: '{emoji}',")
236
+ if agent is not None:
237
+ block.append(f" agent: '{agent}',")
238
+ block.append("};")
239
+ block.append("")
240
+ lines.extend(block)
241
+
242
+ lines.extend(
243
+ [
244
+ "// " + "=" * 76,
245
+ "// Persona Catalog",
246
+ "// " + "=" * 76,
247
+ "",
248
+ "export const PERSONA_CATALOGUE: Record<string, PersonaSpec> = {",
249
+ ]
250
+ )
251
+
252
+ for spec in specs:
253
+ const_name = _make_const_name(spec["id"]) + version_suffix(spec["version"])
254
+ lines.append(f" '{spec['id']}': {const_name},")
255
+
256
+ lines.extend(
257
+ [
258
+ "};",
259
+ "",
260
+ "function resolvePersonaId(personaId: string): string {",
261
+ " if (personaId in PERSONA_CATALOGUE) return personaId;",
262
+ " const idx = personaId.lastIndexOf(':');",
263
+ " if (idx > 0) {",
264
+ " const base = personaId.slice(0, idx);",
265
+ " if (base in PERSONA_CATALOGUE) return base;",
266
+ " }",
267
+ " return personaId;",
268
+ "}",
269
+ "",
270
+ "/** Get a persona specification by ID. */",
271
+ "export function getPersona(personaId: string): PersonaSpec | undefined {",
272
+ " return PERSONA_CATALOGUE[resolvePersonaId(personaId)];",
273
+ "}",
274
+ "",
275
+ "/** List all available personas. */",
276
+ "export function listPersonas(): PersonaSpec[] {",
277
+ " return Object.values(PERSONA_CATALOGUE);",
278
+ "}",
279
+ "",
280
+ ]
281
+ )
282
+
283
+ return "\n".join(lines)
284
+
285
+
286
+ def main():
287
+ parser = argparse.ArgumentParser(
288
+ description="Generate Python and TypeScript code from YAML persona specifications"
289
+ )
290
+ parser.add_argument("--specs-dir", type=Path, required=True)
291
+ parser.add_argument("--python-output", type=Path, required=True)
292
+ parser.add_argument("--typescript-output", type=Path, required=True)
293
+ args = parser.parse_args()
294
+
295
+ if not args.specs_dir.exists():
296
+ print(f"Error: Specs directory does not exist: {args.specs_dir}")
297
+ sys.exit(1)
298
+
299
+ print(f"Loading persona specs from {args.specs_dir}...")
300
+ specs = load_persona_specs(args.specs_dir)
301
+ print(f"Loaded {len(specs)} persona specifications")
302
+
303
+ print("Generating Python code...")
304
+ python_code = generate_python_code(specs)
305
+ args.python_output.parent.mkdir(parents=True, exist_ok=True)
306
+ args.python_output.write_text(python_code)
307
+ print(f"✓ Generated {args.python_output}")
308
+
309
+ print("Generating TypeScript code...")
310
+ typescript_code = generate_typescript_code(specs)
311
+ args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
312
+ args.typescript_output.write_text(typescript_code)
313
+ print(f"✓ Generated {args.typescript_output}")
314
+
315
+ print(f"\n✓ Successfully generated code from {len(specs)} persona specs")
316
+
317
+
318
+ if __name__ == "__main__":
319
+ main()
@@ -130,7 +130,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
130
130
  "# Skill Catalog",
131
131
  "# " + "=" * 76,
132
132
  "",
133
- "SKILL_CATALOG: Dict[str, SkillSpec] = {",
133
+ "SKILLS_CATALOG: Dict[str, SkillSpec] = {",
134
134
  ]
135
135
  )
136
136
 
@@ -172,12 +172,12 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
172
172
  " Returns:",
173
173
  " The SkillSpec, or None if not found.",
174
174
  ' """',
175
- " spec = SKILL_CATALOG.get(skill_id)",
175
+ " spec = SKILLS_CATALOG.get(skill_id)",
176
176
  " if spec is not None:",
177
177
  " return spec",
178
178
  " base, _, ver = skill_id.rpartition(':')",
179
179
  " if base and '.' in ver:",
180
- " return SKILL_CATALOG.get(base)",
180
+ " return SKILLS_CATALOG.get(base)",
181
181
  " return None",
182
182
  "",
183
183
  "",
@@ -188,7 +188,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
188
188
  " Returns:",
189
189
  " List of all SkillSpec configurations.",
190
190
  ' """',
191
- " return list(SKILL_CATALOG.values())",
191
+ " return list(SKILLS_CATALOG.values())",
192
192
  "",
193
193
  ]
194
194
  )
@@ -294,7 +294,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
294
294
  "// Skill Catalog",
295
295
  "// " + "=" * 76,
296
296
  "",
297
- "export const SKILL_CATALOG: Record<string, SkillSpec> = {",
297
+ "export const SKILLS_CATALOG: Record<string, SkillSpec> = {",
298
298
  ]
299
299
  )
300
300
 
@@ -311,21 +311,21 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
311
311
  "};",
312
312
  "",
313
313
  "export function getSkillSpecs(): SkillSpec[] {",
314
- " return Object.values(SKILL_CATALOG);",
314
+ " return Object.values(SKILLS_CATALOG);",
315
315
  "}",
316
316
  "",
317
317
  "function resolveSkillId(skillId: string): string {",
318
- " if (skillId in SKILL_CATALOG) return skillId;",
318
+ " if (skillId in SKILLS_CATALOG) return skillId;",
319
319
  " const idx = skillId.lastIndexOf(':');",
320
320
  " if (idx > 0) {",
321
321
  " const base = skillId.slice(0, idx);",
322
- " if (base in SKILL_CATALOG) return base;",
322
+ " if (base in SKILLS_CATALOG) return base;",
323
323
  " }",
324
324
  " return skillId;",
325
325
  "}",
326
326
  "",
327
327
  "export function getSkillSpec(skillId: string): SkillSpec | undefined {",
328
- " return SKILL_CATALOG[resolveSkillId(skillId)];",
328
+ " return SKILLS_CATALOG[resolveSkillId(skillId)];",
329
329
  "}",
330
330
  "",
331
331
  ]
@@ -20,12 +20,29 @@ NC='\033[0m' # No Color
20
20
 
21
21
  # Get the script directory and project root
22
22
  SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
23
- CORE_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
24
- JUPYTER_UI_ROOT="$( cd "$CORE_ROOT/../jupyter-ui" && pwd )"
23
+ AGENT_RUNTIMES_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
24
+ DATALAYER_CORE_ROOT="$( cd "$AGENT_RUNTIMES_ROOT/../core" && pwd )"
25
+ JUPYTER_UI_ROOT="$( cd "$AGENT_RUNTIMES_ROOT/../jupyter-ui" && pwd )"
25
26
 
26
27
  # Function to perform the sync
27
28
  sync_packages() {
28
- echo -e "${BLUE}🔄 Syncing jupyter-ui packages to @datalayer/agent-runtimes...${NC}"
29
+ echo -e "${BLUE}🔄 Syncing local packages to @datalayer/agent-runtimes...${NC}"
30
+
31
+ # Build and sync @datalayer/core
32
+ echo -e "${BLUE}📦 Building @datalayer/core...${NC}"
33
+ cd "$DATALAYER_CORE_ROOT"
34
+ npm run build:lib
35
+
36
+ echo -e "${BLUE}📋 Copying core to agent-runtimes/node_modules...${NC}"
37
+ cd "$AGENT_RUNTIMES_ROOT"
38
+ rm -rf node_modules/@datalayer/core/lib
39
+ mkdir -p node_modules/@datalayer/core/lib
40
+ cp -r "$DATALAYER_CORE_ROOT/lib/." node_modules/@datalayer/core/lib/
41
+ if [ -d "$DATALAYER_CORE_ROOT/style" ]; then
42
+ rm -rf node_modules/@datalayer/core/style
43
+ cp -r "$DATALAYER_CORE_ROOT/style" node_modules/@datalayer/core/
44
+ fi
45
+ cp "$DATALAYER_CORE_ROOT/package.json" node_modules/@datalayer/core/
29
46
 
30
47
  # Build jupyter-react FIRST (lexical depends on it)
31
48
  echo -e "${BLUE}📦 Building @datalayer/jupyter-react...${NC}"
@@ -49,9 +66,9 @@ sync_packages() {
49
66
  fi
50
67
  echo -e "${YELLOW}[DEBUG] lib directory verified!${NC}"
51
68
 
52
- # Copy react to core's node_modules for patch-package
53
- echo -e "${BLUE}📋 Copying react to core/node_modules...${NC}"
54
- cd "$CORE_ROOT"
69
+ # Copy react to agent-runtimes' node_modules for patch-package
70
+ echo -e "${BLUE}📋 Copying react to agent-runtimes/node_modules...${NC}"
71
+ cd "$AGENT_RUNTIMES_ROOT"
55
72
  # Only replace lib/ directory, preserving LICENSE, README.md, etc.
56
73
  rm -rf node_modules/@datalayer/jupyter-react/lib
57
74
  mkdir -p node_modules/@datalayer/jupyter-react/lib
@@ -73,7 +90,7 @@ sync_packages() {
73
90
 
74
91
  # Copy lexical to node_modules
75
92
  echo -e "${BLUE}📋 Copying lexical to node_modules...${NC}"
76
- cd "$CORE_ROOT"
93
+ cd "$AGENT_RUNTIMES_ROOT"
77
94
  # Only replace lib/ directory, preserving LICENSE, README.md, etc.
78
95
  rm -rf node_modules/@datalayer/jupyter-lexical/lib
79
96
  mkdir -p node_modules/@datalayer/jupyter-lexical/lib
@@ -103,6 +120,7 @@ if [[ "$1" == "--watch" ]]; then
103
120
 
104
121
  echo -e "${BLUE}👁️ Watch mode enabled. Monitoring jupyter-ui packages for changes...${NC}"
105
122
  echo -e "${YELLOW}📁 Watching:${NC}"
123
+ echo -e "${YELLOW} - $DATALAYER_CORE_ROOT/src${NC}"
106
124
  echo -e "${YELLOW} - $JUPYTER_UI_ROOT/packages/lexical/src${NC}"
107
125
  echo -e "${YELLOW} - $JUPYTER_UI_ROOT/packages/react/src${NC}"
108
126
  echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
@@ -118,6 +136,7 @@ if [[ "$1" == "--watch" ]]; then
118
136
  # -l 1: latency 1 second (debounce rapid changes)
119
137
  fswatch -r -l 1 \
120
138
  -e ".*" -i "\\.tsx?$" -i "\\.jsx?$" -i "\\.css$" \
139
+ "$DATALAYER_CORE_ROOT/src" \
121
140
  "$JUPYTER_UI_ROOT/packages/lexical/src" \
122
141
  "$JUPYTER_UI_ROOT/packages/react/src" | while read -r file; do
123
142
  echo -e "\n${YELLOW}📝 Change detected in: $(basename "$file")${NC}"
@@ -1,62 +0,0 @@
1
- import type { ToolApproval, ToolApprovalFilters } from '../types';
2
- /**
3
- * List tool approvals with optional filters.
4
- * @param token - Authentication token
5
- * @param filters - Optional filters (agentId, status, toolName, limit, offset)
6
- * @param baseUrl - Base URL
7
- * @returns Promise resolving to list of tool approvals
8
- */
9
- export declare const getToolApprovals: (token: string, filters?: ToolApprovalFilters, baseUrl?: string) => Promise<ToolApproval[]>;
10
- /**
11
- * Get a specific tool approval by ID.
12
- * @param token - Authentication token
13
- * @param id - Tool approval ID
14
- * @param baseUrl - Base URL
15
- */
16
- export declare const getToolApproval: (token: string, id: string, baseUrl?: string) => Promise<ToolApproval>;
17
- /**
18
- * Approve a pending tool request.
19
- * @param token - Authentication token
20
- * @param id - Tool approval ID
21
- * @param note - Optional note explaining the approval
22
- * @param baseUrl - Base URL
23
- */
24
- export declare const approveToolRequest: (token: string, id: string, note?: string, baseUrl?: string) => Promise<void>;
25
- /**
26
- * Reject a pending tool request.
27
- * @param token - Authentication token
28
- * @param id - Tool approval ID
29
- * @param note - Optional note explaining the rejection
30
- * @param baseUrl - Base URL
31
- */
32
- export declare const rejectToolRequest: (token: string, id: string, note?: string, baseUrl?: string) => Promise<void>;
33
- /**
34
- * Mark a tool approval as read.
35
- * @param token - Authentication token
36
- * @param id - Tool approval ID
37
- * @param baseUrl - Base URL
38
- */
39
- export declare const markToolApprovalRead: (token: string, id: string, baseUrl?: string) => Promise<void>;
40
- /**
41
- * Mark a tool approval as unread.
42
- * @param token - Authentication token
43
- * @param id - Tool approval ID
44
- * @param baseUrl - Base URL
45
- */
46
- export declare const markToolApprovalUnread: (token: string, id: string, baseUrl?: string) => Promise<void>;
47
- /**
48
- * Delete a tool approval.
49
- * @param token - Authentication token
50
- * @param id - Tool approval ID
51
- * @param baseUrl - Base URL
52
- */
53
- export declare const deleteToolApproval: (token: string, id: string, baseUrl?: string) => Promise<void>;
54
- /**
55
- * Get count of pending tool approvals.
56
- * @param token - Authentication token
57
- * @param baseUrl - Base URL
58
- * @returns Promise resolving to pending count
59
- */
60
- export declare const getPendingApprovalCount: (token: string, baseUrl?: string) => Promise<{
61
- count: number;
62
- }>;