@datalayer/agent-runtimes 1.0.2 → 1.0.3

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 (615) hide show
  1. package/README.md +1 -1
  2. package/lib/Agent.js +2 -2
  3. package/lib/AgentLexical.d.ts +1 -12
  4. package/lib/AgentLexical.js +3 -14
  5. package/lib/AgentNotebook.js +3 -3
  6. package/lib/App.js +2 -2
  7. package/lib/{components/chat/components → agents}/AgentDetails.d.ts +13 -2
  8. package/lib/{components/chat/components → agents}/AgentDetails.js +6 -12
  9. package/lib/api/agents.d.ts +47 -0
  10. package/lib/api/agents.js +106 -0
  11. package/lib/api/context.d.ts +17 -0
  12. package/lib/api/context.js +45 -0
  13. package/lib/api/evals.d.ts +27 -0
  14. package/lib/api/evals.js +63 -0
  15. package/lib/api/events.d.ts +17 -0
  16. package/lib/api/events.js +93 -0
  17. package/lib/{components/chat → api}/handler.js +1 -1
  18. package/lib/api/index.d.ts +15 -0
  19. package/lib/api/index.js +20 -0
  20. package/lib/api/notifications.d.ts +39 -0
  21. package/lib/api/notifications.js +103 -0
  22. package/lib/api/output.d.ts +28 -0
  23. package/lib/api/output.js +64 -0
  24. package/lib/api/tool-approvals.d.ts +62 -0
  25. package/lib/api/tool-approvals.js +145 -0
  26. package/lib/{components/chat/components → chat}/Chat.d.ts +24 -15
  27. package/lib/{components/chat/components → chat}/Chat.js +16 -16
  28. package/lib/{components/chat/components → chat}/ChatFloating.d.ts +17 -9
  29. package/lib/{components/chat/components → chat}/ChatFloating.js +17 -9
  30. package/lib/{components/chat/components → chat}/ChatInline.d.ts +2 -2
  31. package/lib/{components/chat/components → chat}/ChatInline.js +8 -6
  32. package/lib/{components/chat/components → chat}/ChatPopupStandalone.d.ts +3 -4
  33. package/lib/{components/chat/components → chat}/ChatPopupStandalone.js +6 -6
  34. package/lib/{components/chat/components → chat}/ChatSidebar.d.ts +14 -5
  35. package/lib/{components/chat/components → chat}/ChatSidebar.js +48 -26
  36. package/lib/{components/chat/components → chat}/ChatStandalone.d.ts +3 -4
  37. package/lib/{components/chat/components → chat}/ChatStandalone.js +5 -5
  38. package/lib/chat/base/ChatBase.d.ts +6 -0
  39. package/lib/chat/base/ChatBase.js +1287 -0
  40. package/lib/chat/display/EmptyState.d.ts +27 -0
  41. package/lib/chat/display/EmptyState.js +41 -0
  42. package/lib/{components/chat/components/elements → chat/display}/FloatingBrandButton.d.ts +1 -1
  43. package/lib/{components/chat/components/elements → chat/display}/FloatingBrandButton.js +1 -1
  44. package/lib/{components/chat/components/elements → chat/display}/PoweredByTag.d.ts +1 -1
  45. package/lib/{components/chat/components/elements → chat/header}/ChatHeader.d.ts +1 -4
  46. package/lib/{components/chat/components/elements → chat/header}/ChatHeader.js +1 -1
  47. package/lib/chat/header/ChatHeaderBase.d.ts +38 -0
  48. package/lib/chat/header/ChatHeaderBase.js +83 -0
  49. package/lib/chat/index.d.ts +66 -0
  50. package/lib/chat/index.js +74 -0
  51. package/lib/chat/indicators/McpStatusIndicator.d.ts +9 -0
  52. package/lib/chat/indicators/McpStatusIndicator.js +128 -0
  53. package/lib/chat/indicators/SandboxStatusIndicator.d.ts +10 -0
  54. package/lib/chat/indicators/SandboxStatusIndicator.js +175 -0
  55. package/lib/chat/indicators/index.d.ts +17 -0
  56. package/lib/chat/indicators/index.js +19 -0
  57. package/lib/chat/messages/ChatMessageList.d.ts +49 -0
  58. package/lib/chat/messages/ChatMessageList.js +319 -0
  59. package/lib/{components/chat/components/elements → chat/messages}/ChatMessages.d.ts +2 -2
  60. package/lib/{components/chat/components/elements → chat/messages}/ChatMessages.js +6 -4
  61. package/lib/{components/chat/components → chat}/parts/DynamicToolPart.d.ts +1 -1
  62. package/lib/{components/chat/components/elements → chat/parts}/MessagePart.d.ts +1 -1
  63. package/lib/{components/chat/components/elements → chat/parts}/MessagePart.js +4 -4
  64. package/lib/{components/chat/components → chat}/parts/ReasoningPart.js +1 -1
  65. package/lib/{components/chat/components → chat}/parts/TextPart.d.ts +1 -1
  66. package/lib/{components/chat/components → chat}/parts/ToolPart.js +1 -1
  67. package/lib/{components/chat/components → chat}/parts/index.d.ts +2 -1
  68. package/lib/{components/chat/components → chat}/parts/index.js +2 -1
  69. package/lib/chat/prompt/InputFooter.d.ts +43 -0
  70. package/lib/chat/prompt/InputFooter.js +135 -0
  71. package/lib/chat/prompt/InputPrompt.d.ts +60 -0
  72. package/lib/chat/prompt/InputPrompt.js +83 -0
  73. package/lib/chat/prompt/InputPromptFooter.d.ts +25 -0
  74. package/lib/chat/prompt/InputPromptFooter.js +15 -0
  75. package/lib/chat/prompt/InputPromptHeader.d.ts +15 -0
  76. package/lib/chat/prompt/InputPromptHeader.js +15 -0
  77. package/lib/chat/prompt/InputPromptLexical.d.ts +16 -0
  78. package/lib/chat/prompt/InputPromptLexical.js +122 -0
  79. package/lib/chat/prompt/InputPromptText.d.ts +24 -0
  80. package/lib/chat/prompt/InputPromptText.js +66 -0
  81. package/lib/chat/prompt/index.d.ts +11 -0
  82. package/lib/chat/prompt/index.js +15 -0
  83. package/lib/{components/chat/components → chat}/styles/streamdownStyles.d.ts +1 -1
  84. package/lib/chat/tools/ToolApprovalBanner.d.ts +31 -0
  85. package/lib/chat/tools/ToolApprovalBanner.js +62 -0
  86. package/lib/{components/chat/components/elements → chat/tools}/ToolApprovalDialog.js +1 -1
  87. package/lib/{components/chat/components/display → chat/tools}/ToolCallDisplay.d.ts +13 -4
  88. package/lib/{components/chat/components/display → chat/tools}/ToolCallDisplay.js +18 -8
  89. package/lib/chat/tools/index.d.ts +8 -0
  90. package/lib/{components/chat/components/display → chat/tools}/index.js +3 -1
  91. package/lib/chat/usage/TokenUsageBar.d.ts +8 -0
  92. package/lib/chat/usage/TokenUsageBar.js +213 -0
  93. package/lib/client/AgentsMixin.d.ts +169 -0
  94. package/lib/client/AgentsMixin.js +279 -0
  95. package/lib/client/index.d.ts +6 -0
  96. package/lib/client/index.js +10 -0
  97. package/lib/components/NotificationEventCard.d.ts +8 -0
  98. package/lib/components/NotificationEventCard.js +152 -0
  99. package/lib/components/OutputCard.d.ts +8 -0
  100. package/lib/components/OutputCard.js +80 -0
  101. package/lib/components/ToolApprovalCard.d.ts +33 -0
  102. package/lib/components/ToolApprovalCard.js +60 -0
  103. package/lib/components/index.d.ts +3 -7
  104. package/lib/components/index.js +3 -4
  105. package/lib/{components → config}/AgentConfiguration.d.ts +43 -21
  106. package/lib/{components → config}/AgentConfiguration.js +48 -28
  107. package/lib/config/index.d.ts +2 -0
  108. package/lib/config/index.js +1 -0
  109. package/lib/{components/chat/components → context}/ContextInspector.js +38 -8
  110. package/lib/{components/chat/components → context}/ContextPanel.js +27 -6
  111. package/lib/context/CostTracker.d.ts +37 -0
  112. package/lib/context/CostTracker.js +124 -0
  113. package/lib/context/TokenUsageChart.d.ts +10 -0
  114. package/lib/context/TokenUsageChart.js +288 -0
  115. package/lib/examples/A2UiComponentGalleryExample.d.ts +20 -0
  116. package/lib/examples/A2UiComponentGalleryExample.js +568 -0
  117. package/lib/examples/A2UiContactCardExample.d.ts +21 -0
  118. package/lib/examples/A2UiContactCardExample.js +432 -0
  119. package/lib/examples/A2UiRestaurantExample.d.ts +11 -3
  120. package/lib/examples/A2UiRestaurantExample.js +63 -98
  121. package/lib/examples/A2UiViewerExample.d.ts +21 -0
  122. package/lib/examples/A2UiViewerExample.js +563 -0
  123. package/lib/examples/AgUiAgenticExample.js +3 -3
  124. package/lib/examples/AgUiBackendToolRenderingExample.js +3 -3
  125. package/lib/examples/{AgUiHaikuGenUIExample.d.ts → AgUiHaikuGenUiExample.d.ts} +4 -4
  126. package/lib/examples/{AgUiHaikuGenUIExample.js → AgUiHaikuGenUiExample.js} +7 -7
  127. package/lib/examples/AgUiHumanInTheLoopExample.js +3 -3
  128. package/lib/examples/AgUiSharedStateExample.js +3 -3
  129. package/lib/examples/{AgUiToolsBasedGenUIExample.d.ts → AgUiToolsBasedGenUiExample.d.ts} +4 -4
  130. package/lib/examples/{AgUiToolsBasedGenUIExample.js → AgUiToolsBasedGenUiExample.js} +7 -7
  131. package/lib/examples/AgentCheckpointsExample.d.ts +19 -0
  132. package/lib/examples/AgentCheckpointsExample.js +506 -0
  133. package/lib/examples/AgentCodemodeExample.d.ts +14 -0
  134. package/lib/examples/AgentCodemodeExample.js +262 -0
  135. package/lib/examples/AgentEvalsExample.d.ts +14 -0
  136. package/lib/examples/AgentEvalsExample.js +216 -0
  137. package/lib/examples/AgentGuardrailsExample.d.ts +14 -0
  138. package/lib/examples/AgentGuardrailsExample.js +218 -0
  139. package/lib/examples/AgentMemoryExample.d.ts +14 -0
  140. package/lib/examples/AgentMemoryExample.js +234 -0
  141. package/lib/examples/AgentMonitoringExample.d.ts +13 -0
  142. package/lib/examples/AgentMonitoringExample.js +311 -0
  143. package/lib/examples/AgentNotificationsExample.d.ts +14 -0
  144. package/lib/examples/AgentNotificationsExample.js +273 -0
  145. package/lib/examples/AgentOtelExample.d.ts +25 -0
  146. package/lib/examples/AgentOtelExample.js +281 -0
  147. package/lib/examples/AgentOutputsExample.d.ts +14 -0
  148. package/lib/examples/AgentOutputsExample.js +211 -0
  149. package/lib/examples/AgentSandboxExample.d.ts +17 -0
  150. package/lib/examples/AgentSandboxExample.js +496 -0
  151. package/lib/examples/AgentSkillsExample.d.ts +3 -0
  152. package/lib/examples/AgentSkillsExample.js +290 -0
  153. package/lib/examples/AgentToolApprovalsExample.d.ts +3 -0
  154. package/lib/examples/AgentToolApprovalsExample.js +672 -0
  155. package/lib/examples/AgentTriggersExample.d.ts +14 -0
  156. package/lib/examples/AgentTriggersExample.js +523 -0
  157. package/lib/examples/{AgentRuntimeFormExample.d.ts → AgentspecExample.d.ts} +3 -4
  158. package/lib/examples/{AgentRuntimeFormExample.js → AgentspecExample.js} +92 -34
  159. package/lib/examples/{JupyterCellExample.js → CellSimpleExample.js} +1 -1
  160. package/lib/examples/{AgentRuntimeCustomExample.js → ChatCustomExample.js} +3 -3
  161. package/lib/examples/{AgentRuntimeChatExample.js → ChatExample.js} +4 -4
  162. package/lib/examples/{AgentRuntimeStandaloneExample.js → ChatStandaloneExample.js} +2 -2
  163. package/lib/examples/CopilotKitLexicalExample.d.ts +3 -14
  164. package/lib/examples/CopilotKitLexicalExample.js +4 -15
  165. package/lib/examples/CopilotKitNotebookExample.js +4 -6
  166. package/lib/examples/DatalayerNotebookExample.js +2 -2
  167. package/lib/examples/{AgentRuntimeLexical2Example.d.ts → Lexical2Example.d.ts} +2 -13
  168. package/lib/examples/{AgentRuntimeLexical2Example.js → Lexical2Example.js} +8 -17
  169. package/lib/examples/{AgentRuntimeLexicalExample.d.ts → LexicalExample.d.ts} +1 -12
  170. package/lib/examples/{AgentRuntimeLexicalExample.js → LexicalExample.js} +28 -27
  171. package/lib/examples/{AgentRuntimeLexicalSidebarExample.d.ts → LexicalSidebarExample.d.ts} +2 -13
  172. package/lib/examples/{AgentRuntimeLexicalSidebarExample.js → LexicalSidebarExample.js} +6 -18
  173. package/lib/examples/{AgentRuntimeNotebookExample.js → NotebookExample.js} +14 -10
  174. package/lib/examples/{AgentRuntimeNotebookSidebarExample.js → NotebookSidebarExample.js} +5 -8
  175. package/lib/examples/{JupyterNotebookExample.js → NotebookSimpleExample.js} +2 -2
  176. package/lib/examples/ag-ui/weather/InlineWeatherCard.js +1 -1
  177. package/lib/examples/components/ExampleWrapper.d.ts +12 -0
  178. package/lib/examples/components/ExampleWrapper.js +16 -0
  179. package/lib/examples/components/Header.d.ts +2 -2
  180. package/lib/examples/components/HeaderControls.js +1 -1
  181. package/lib/examples/components/LexicalEditor.d.ts +1 -12
  182. package/lib/examples/components/LexicalEditor.js +1 -12
  183. package/lib/examples/components/MainContent.d.ts +4 -11
  184. package/lib/examples/components/MainContent.js +6 -60
  185. package/lib/examples/components/index.d.ts +1 -0
  186. package/lib/examples/components/index.js +1 -0
  187. package/lib/examples/example-selector.d.ts +1 -1
  188. package/lib/examples/example-selector.js +35 -22
  189. package/lib/examples/index.d.ts +26 -13
  190. package/lib/examples/index.js +26 -12
  191. package/lib/examples/main.d.ts +6 -0
  192. package/lib/examples/main.js +20 -43
  193. package/lib/examples/utils/examplesStore.d.ts +4 -0
  194. package/lib/examples/{stores → utils}/examplesStore.js +1 -1
  195. package/lib/examples/utils/notebooks/Empty.ipynb.json +33 -0
  196. package/lib/examples/utils/notebooks/NotebookExample2.ipynb.json +48 -0
  197. package/lib/examples/utils/themeStore.d.ts +8 -0
  198. package/lib/examples/utils/themeStore.js +14 -0
  199. package/lib/extensions/A2UIExtension.d.ts +65 -0
  200. package/lib/extensions/A2UIExtension.js +202 -0
  201. package/lib/{components/chat/extensions → extensions}/ExtensionRegistry.d.ts +2 -3
  202. package/lib/{components/chat/extensions → extensions}/ExtensionRegistry.js +0 -2
  203. package/lib/{components/chat/extensions → extensions}/MCPUIExtension.d.ts +2 -2
  204. package/lib/{components/chat/extensions → extensions}/MCPUIExtension.js +1 -1
  205. package/lib/extensions/index.d.ts +9 -0
  206. package/lib/{components/chat/extensions → extensions}/index.js +2 -2
  207. package/lib/hooks/index.d.ts +33 -16
  208. package/lib/hooks/index.js +33 -16
  209. package/lib/hooks/useAIAgentsWebSocket.d.ts +29 -0
  210. package/lib/hooks/useAIAgentsWebSocket.js +136 -0
  211. package/lib/hooks/{useAGUI.d.ts → useAgUi.d.ts} +2 -2
  212. package/lib/hooks/{useAGUI.js → useAgUi.js} +2 -2
  213. package/lib/hooks/useAgents.d.ts +150 -11
  214. package/lib/hooks/useAgents.js +623 -61
  215. package/lib/hooks/{useAgentStore.d.ts → useAgentsCatalog.d.ts} +3 -8
  216. package/lib/hooks/{useAgentStore.js → useAgentsCatalog.js} +9 -3
  217. package/lib/hooks/useAgentsRegistry.d.ts +10 -0
  218. package/lib/hooks/useAgentsRegistry.js +20 -0
  219. package/lib/hooks/useAgentsService.d.ts +22 -0
  220. package/lib/hooks/useAgentsService.js +146 -0
  221. package/lib/hooks/useChat.d.ts +2 -2
  222. package/lib/hooks/useChat.js +14 -8
  223. package/lib/hooks/useCheckpoints.d.ts +176 -0
  224. package/lib/hooks/useCheckpoints.js +466 -0
  225. package/lib/hooks/useConfig.d.ts +11 -0
  226. package/lib/hooks/useConfig.js +46 -0
  227. package/lib/hooks/useContextSnapshot.d.ts +11 -0
  228. package/lib/hooks/useContextSnapshot.js +44 -0
  229. package/lib/hooks/useMonitoring.d.ts +24 -0
  230. package/lib/hooks/useMonitoring.js +111 -0
  231. package/lib/hooks/useNotifications.d.ts +67 -0
  232. package/lib/hooks/useNotifications.js +208 -0
  233. package/lib/hooks/useSandbox.d.ts +12 -0
  234. package/lib/hooks/useSandbox.js +49 -0
  235. package/lib/hooks/useSkills.d.ts +13 -0
  236. package/lib/hooks/useSkills.js +46 -0
  237. package/lib/hooks/useToolApprovals.d.ts +45 -0
  238. package/lib/hooks/useToolApprovals.js +126 -0
  239. package/lib/hooks/useTools.d.ts +4 -4
  240. package/lib/hooks/useTools.js +2 -2
  241. package/lib/hooks/{useVercelChat.d.ts → useVercelAI.d.ts} +3 -3
  242. package/lib/hooks/{useVercelChat.js → useVercelAI.js} +2 -2
  243. package/lib/{components/chat/components → identity}/AgentIdentity.d.ts +1 -1
  244. package/lib/{components/chat/components → identity}/AgentIdentity.js +4 -3
  245. package/lib/identity/index.d.ts +1 -0
  246. package/lib/identity/index.js +2 -0
  247. package/lib/index.d.ts +4 -3
  248. package/lib/index.js +3 -2
  249. package/lib/{components/chat/inference → inference}/BaseInferenceProvider.d.ts +3 -3
  250. package/lib/{components/chat/inference → inference}/DatalayerInferenceProvider.d.ts +3 -3
  251. package/lib/{components/chat/inference → inference}/DatalayerInferenceProvider.js +1 -1
  252. package/lib/{components/chat/inference → inference}/SelfHostedInferenceProvider.d.ts +2 -2
  253. package/lib/{components/chat/inference → inference}/SelfHostedInferenceProvider.js +1 -1
  254. package/lib/{components/chat/inference → inference}/index.d.ts +1 -1
  255. package/lib/{components/chat/inference → inference}/index.js +1 -1
  256. package/lib/lexical/ChatInlinePlugin.d.ts +1 -1
  257. package/lib/lexical/ChatInlinePlugin.js +1 -1
  258. package/lib/{components → mcp}/McpServerManager.d.ts +1 -2
  259. package/lib/mcp/index.d.ts +1 -0
  260. package/lib/{specs/agents/codeai → mcp}/index.js +1 -1
  261. package/lib/{components/chat/middleware → middleware}/MiddlewarePipeline.d.ts +3 -3
  262. package/lib/{components/chat/middleware → middleware}/index.d.ts +1 -1
  263. package/lib/{components/chat/middleware → middleware}/index.js +1 -1
  264. package/lib/{components/chat/protocols → protocols}/A2AAdapter.d.ts +6 -6
  265. package/lib/{components/chat/protocols → protocols}/A2AAdapter.js +3 -3
  266. package/lib/{components/chat/protocols → protocols}/ACPAdapter.d.ts +6 -6
  267. package/lib/{components/chat/protocols → protocols}/ACPAdapter.js +4 -4
  268. package/lib/{components/chat/protocols → protocols}/AGUIAdapter.d.ts +14 -6
  269. package/lib/{components/chat/protocols → protocols}/AGUIAdapter.js +72 -10
  270. package/lib/{components/chat/protocols → protocols}/BaseProtocolAdapter.d.ts +6 -6
  271. package/lib/{components/chat/protocols → protocols}/BaseProtocolAdapter.js +1 -1
  272. package/lib/{components/chat/protocols → protocols}/VercelAIAdapter.d.ts +31 -7
  273. package/lib/protocols/VercelAIAdapter.js +682 -0
  274. package/lib/{components/chat/protocols → protocols}/index.d.ts +1 -2
  275. package/lib/{components/chat/protocols → protocols}/index.js +1 -1
  276. package/lib/specs/agents/agents.d.ts +54 -0
  277. package/lib/specs/agents/{mocks/agents.js → agents.js} +1144 -799
  278. package/lib/specs/agents/index.js +14 -9
  279. package/lib/specs/envvars.d.ts +11 -19
  280. package/lib/specs/envvars.js +42 -21
  281. package/lib/specs/evals.d.ts +20 -0
  282. package/lib/specs/evals.js +133 -0
  283. package/lib/specs/events.d.ts +18 -0
  284. package/lib/specs/events.js +182 -0
  285. package/lib/specs/frontendTools.d.ts +14 -0
  286. package/lib/specs/frontendTools.js +53 -0
  287. package/lib/specs/guardrails.d.ts +22 -0
  288. package/lib/specs/guardrails.js +391 -0
  289. package/lib/specs/index.d.ts +15 -2
  290. package/lib/specs/index.js +15 -2
  291. package/lib/specs/mcpServers.d.ts +13 -11
  292. package/lib/specs/mcpServers.js +82 -28
  293. package/lib/specs/memory.d.ts +34 -0
  294. package/lib/specs/memory.js +99 -0
  295. package/lib/specs/models.d.ts +21 -34
  296. package/lib/specs/models.js +61 -41
  297. package/lib/specs/notifications.d.ts +17 -0
  298. package/lib/specs/notifications.js +187 -0
  299. package/lib/specs/outputs.d.ts +19 -0
  300. package/lib/specs/outputs.js +112 -0
  301. package/lib/specs/skills.d.ts +7 -16
  302. package/lib/specs/skills.js +89 -12
  303. package/lib/specs/teams/index.d.ts +17 -0
  304. package/lib/specs/teams/index.js +37 -0
  305. package/lib/specs/teams/teams.d.ts +27 -0
  306. package/lib/specs/teams/teams.js +1120 -0
  307. package/lib/specs/tools.d.ts +15 -0
  308. package/lib/specs/tools.js +83 -0
  309. package/lib/specs/triggers.d.ts +15 -0
  310. package/lib/specs/triggers.js +117 -0
  311. package/lib/stores/agentsStore.d.ts +123 -0
  312. package/lib/stores/agentsStore.js +270 -0
  313. package/lib/{components/chat/store → stores}/chatStore.d.ts +3 -2
  314. package/lib/{components/chat/store → stores}/chatStore.js +2 -2
  315. package/lib/{components/chat/store → stores}/conversationStore.d.ts +1 -1
  316. package/lib/{components/chat/store → stores}/conversationStore.js +1 -1
  317. package/lib/{components/chat/store → stores}/index.d.ts +3 -2
  318. package/lib/{components/chat/store → stores}/index.js +3 -2
  319. package/lib/{components/chat/tools → tools}/ToolExecutor.d.ts +2 -2
  320. package/lib/{components/chat/tools → tools}/ToolExecutor.js +1 -1
  321. package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +1 -1
  322. package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +14 -10
  323. package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +31 -21
  324. package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +1 -1
  325. package/lib/tools/index.d.ts +3 -0
  326. package/lib/tools/index.js +3 -7
  327. package/lib/types/a2a.d.ts +39 -0
  328. package/lib/types/acp.d.ts +21 -0
  329. package/lib/types/ag-ui.d.ts +25 -0
  330. package/lib/types/agents-lifecycle.d.ts +36 -0
  331. package/lib/types/agents.d.ts +80 -0
  332. package/lib/types/agents.js +22 -0
  333. package/lib/types/agentspecs.d.ts +90 -0
  334. package/lib/{components/chat/components/base/ChatBase.d.ts → types/chat.d.ts} +59 -99
  335. package/lib/types/checkpoints.d.ts +32 -0
  336. package/lib/types/checkpoints.js +5 -0
  337. package/lib/types/config.d.ts +67 -0
  338. package/lib/{runtime/types.js → types/config.js} +2 -2
  339. package/lib/types/connection.d.ts +31 -0
  340. package/lib/types/connection.js +5 -0
  341. package/lib/types/context.d.ts +67 -0
  342. package/lib/types/context.js +5 -0
  343. package/lib/types/cost.d.ts +42 -0
  344. package/lib/types/cost.js +5 -0
  345. package/lib/types/envvars.d.ts +21 -0
  346. package/lib/types/envvars.js +5 -0
  347. package/lib/types/evals.d.ts +66 -0
  348. package/lib/types/evals.js +5 -0
  349. package/lib/types/events.d.ts +49 -0
  350. package/lib/types/events.js +5 -0
  351. package/lib/types/eventspecs.d.ts +39 -0
  352. package/lib/types/eventspecs.js +5 -0
  353. package/lib/types/examples.d.ts +31 -0
  354. package/lib/types/examples.js +5 -0
  355. package/lib/{components/chat/types → types}/execution.d.ts +10 -1
  356. package/lib/{components/chat/types/extension.d.ts → types/extensions.d.ts} +3 -3
  357. package/lib/types/guardrails.d.ts +106 -0
  358. package/lib/types/guardrails.js +5 -0
  359. package/lib/types/index.d.ts +36 -2
  360. package/lib/types/index.js +35 -2
  361. package/lib/{components/chat/types → types}/inference.d.ts +3 -3
  362. package/lib/types/inference.js +5 -0
  363. package/lib/types/mcp.d.ts +117 -0
  364. package/lib/types/mcp.js +27 -0
  365. package/lib/types/memory.d.ts +23 -0
  366. package/lib/types/memory.js +5 -0
  367. package/lib/{components/chat/types/message.d.ts → types/messages.d.ts} +20 -1
  368. package/lib/{components/chat/types → types}/middleware.d.ts +3 -3
  369. package/lib/types/models.d.ts +63 -0
  370. package/lib/types/models.js +5 -0
  371. package/lib/types/notifications.d.ts +85 -0
  372. package/lib/types/notifications.js +5 -0
  373. package/lib/types/outputs.d.ts +51 -0
  374. package/lib/types/outputs.js +5 -0
  375. package/lib/{components/chat/types → types}/protocol.d.ts +37 -99
  376. package/lib/types/protocol.js +5 -0
  377. package/lib/types/sandbox.d.ts +27 -0
  378. package/lib/types/sandbox.js +24 -0
  379. package/lib/types/skills.d.ts +74 -0
  380. package/lib/types/skills.js +5 -0
  381. package/lib/types/teams.d.ts +133 -0
  382. package/lib/types/teams.js +5 -0
  383. package/lib/types/tool-approvals.d.ts +39 -0
  384. package/lib/types/tool-approvals.js +5 -0
  385. package/lib/{components/chat/types/tool.d.ts → types/tools.d.ts} +59 -4
  386. package/lib/types/triggers.d.ts +48 -0
  387. package/lib/types/triggers.js +5 -0
  388. package/lib/types/usage.d.ts +36 -0
  389. package/lib/types/usage.js +5 -0
  390. package/lib/utils/index.d.ts +1 -0
  391. package/lib/utils/index.js +5 -0
  392. package/lib/utils/utils.d.ts +60 -0
  393. package/lib/utils/utils.js +205 -0
  394. package/package.json +13 -14
  395. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  396. package/scripts/codegen/__pycache__/generate_envvars.cpython-313.pyc +0 -0
  397. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  398. package/scripts/codegen/__pycache__/generate_guardrails.cpython-313.pyc +0 -0
  399. package/scripts/codegen/__pycache__/generate_mcp_servers.cpython-313.pyc +0 -0
  400. package/scripts/codegen/__pycache__/generate_memory.cpython-313.pyc +0 -0
  401. package/scripts/codegen/__pycache__/generate_models.cpython-313.pyc +0 -0
  402. package/scripts/codegen/__pycache__/generate_notifications.cpython-313.pyc +0 -0
  403. package/scripts/codegen/__pycache__/generate_outputs.cpython-313.pyc +0 -0
  404. package/scripts/codegen/__pycache__/generate_skills.cpython-313.pyc +0 -0
  405. package/scripts/codegen/__pycache__/generate_teams.cpython-313.pyc +0 -0
  406. package/scripts/codegen/__pycache__/generate_tools.cpython-313.pyc +0 -0
  407. package/scripts/codegen/__pycache__/generate_triggers.cpython-313.pyc +0 -0
  408. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  409. package/scripts/codegen/generate_agents.py +373 -60
  410. package/scripts/codegen/generate_envvars.py +36 -35
  411. package/scripts/codegen/generate_evals.py +279 -0
  412. package/scripts/codegen/generate_events.py +312 -0
  413. package/scripts/codegen/generate_frontend_tools.py +266 -0
  414. package/scripts/codegen/generate_guardrails.py +475 -0
  415. package/scripts/codegen/generate_mcp_servers.py +36 -9
  416. package/scripts/codegen/generate_memory.py +468 -0
  417. package/scripts/codegen/generate_models.py +22 -46
  418. package/scripts/codegen/generate_notifications.py +309 -0
  419. package/scripts/codegen/generate_outputs.py +267 -0
  420. package/scripts/codegen/generate_skills.py +108 -51
  421. package/scripts/codegen/generate_teams.py +922 -0
  422. package/scripts/codegen/generate_tools.py +326 -0
  423. package/scripts/codegen/generate_triggers.py +295 -0
  424. package/scripts/codegen/versioning.py +53 -0
  425. package/lib/components/chat/components/base/ChatBase.js +0 -2242
  426. package/lib/components/chat/components/base/InputPrompt.d.ts +0 -42
  427. package/lib/components/chat/components/base/InputPrompt.js +0 -131
  428. package/lib/components/chat/components/display/index.d.ts +0 -6
  429. package/lib/components/chat/components/index.d.ts +0 -26
  430. package/lib/components/chat/components/index.js +0 -39
  431. package/lib/components/chat/extensions/A2UIExtension.d.ts +0 -87
  432. package/lib/components/chat/extensions/A2UIExtension.js +0 -312
  433. package/lib/components/chat/extensions/index.d.ts +0 -10
  434. package/lib/components/chat/index.d.ts +0 -61
  435. package/lib/components/chat/index.js +0 -76
  436. package/lib/components/chat/protocols/VercelAIAdapter.js +0 -315
  437. package/lib/components/chat/tools/index.d.ts +0 -8
  438. package/lib/components/chat/tools/index.js +0 -11
  439. package/lib/components/chat/types/index.d.ts +0 -12
  440. package/lib/components/chat/types/index.js +0 -17
  441. package/lib/components/sparklines/Sparklines.d.ts +0 -16
  442. package/lib/components/sparklines/Sparklines.js +0 -65
  443. package/lib/components/sparklines/SparklinesLine.d.ts +0 -8
  444. package/lib/components/sparklines/SparklinesLine.js +0 -37
  445. package/lib/components/sparklines/dataProcessing.d.ts +0 -25
  446. package/lib/components/sparklines/dataProcessing.js +0 -35
  447. package/lib/components/sparklines/index.d.ts +0 -4
  448. package/lib/components/sparklines/index.js +0 -7
  449. package/lib/components/sparklines/types.d.ts +0 -36
  450. package/lib/examples/stores/examplesStore.d.ts +0 -5
  451. package/lib/examples/stores/notebooks/Empty.ipynb.json +0 -33
  452. package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +0 -48
  453. package/lib/examples/stores/themeStore.d.ts +0 -33
  454. package/lib/examples/stores/themeStore.js +0 -38
  455. package/lib/hooks/useAgentRuntimes.d.ts +0 -350
  456. package/lib/hooks/useAgentRuntimes.js +0 -78
  457. package/lib/hooks/useKeyboardShortcuts.d.ts +0 -47
  458. package/lib/hooks/useKeyboardShortcuts.js +0 -153
  459. package/lib/hooks/useMobile.d.ts +0 -1
  460. package/lib/hooks/useMobile.js +0 -19
  461. package/lib/hooks/useNotebookAIAgent.d.ts +0 -8
  462. package/lib/hooks/useNotebookAIAgent.js +0 -73
  463. package/lib/renderers/a2ui/components/A2UIRenderer.d.ts +0 -7
  464. package/lib/renderers/a2ui/components/A2UIRenderer.js +0 -102
  465. package/lib/renderers/a2ui/components/SurfaceRenderer.d.ts +0 -7
  466. package/lib/renderers/a2ui/components/SurfaceRenderer.js +0 -101
  467. package/lib/renderers/a2ui/components/content/AudioPlayer.d.ts +0 -9
  468. package/lib/renderers/a2ui/components/content/AudioPlayer.js +0 -38
  469. package/lib/renderers/a2ui/components/content/Divider.d.ts +0 -9
  470. package/lib/renderers/a2ui/components/content/Divider.js +0 -35
  471. package/lib/renderers/a2ui/components/content/Icon.d.ts +0 -9
  472. package/lib/renderers/a2ui/components/content/Icon.js +0 -110
  473. package/lib/renderers/a2ui/components/content/Image.d.ts +0 -9
  474. package/lib/renderers/a2ui/components/content/Image.js +0 -61
  475. package/lib/renderers/a2ui/components/content/Text.d.ts +0 -9
  476. package/lib/renderers/a2ui/components/content/Text.js +0 -64
  477. package/lib/renderers/a2ui/components/content/Video.d.ts +0 -9
  478. package/lib/renderers/a2ui/components/content/Video.js +0 -37
  479. package/lib/renderers/a2ui/components/content/index.d.ts +0 -6
  480. package/lib/renderers/a2ui/components/content/index.js +0 -25
  481. package/lib/renderers/a2ui/components/index.d.ts +0 -5
  482. package/lib/renderers/a2ui/components/index.js +0 -24
  483. package/lib/renderers/a2ui/components/interactive/Button.d.ts +0 -11
  484. package/lib/renderers/a2ui/components/interactive/Button.js +0 -71
  485. package/lib/renderers/a2ui/components/interactive/CheckBox.d.ts +0 -9
  486. package/lib/renderers/a2ui/components/interactive/CheckBox.js +0 -48
  487. package/lib/renderers/a2ui/components/interactive/DateTimeInput.d.ts +0 -9
  488. package/lib/renderers/a2ui/components/interactive/DateTimeInput.js +0 -62
  489. package/lib/renderers/a2ui/components/interactive/MultipleChoice.d.ts +0 -9
  490. package/lib/renderers/a2ui/components/interactive/MultipleChoice.js +0 -73
  491. package/lib/renderers/a2ui/components/interactive/Slider.d.ts +0 -9
  492. package/lib/renderers/a2ui/components/interactive/Slider.js +0 -53
  493. package/lib/renderers/a2ui/components/interactive/TextField.d.ts +0 -9
  494. package/lib/renderers/a2ui/components/interactive/TextField.js +0 -72
  495. package/lib/renderers/a2ui/components/interactive/index.d.ts +0 -6
  496. package/lib/renderers/a2ui/components/interactive/index.js +0 -25
  497. package/lib/renderers/a2ui/components/layout/Card.d.ts +0 -11
  498. package/lib/renderers/a2ui/components/layout/Card.js +0 -30
  499. package/lib/renderers/a2ui/components/layout/Column.d.ts +0 -11
  500. package/lib/renderers/a2ui/components/layout/Column.js +0 -65
  501. package/lib/renderers/a2ui/components/layout/List.d.ts +0 -11
  502. package/lib/renderers/a2ui/components/layout/List.js +0 -55
  503. package/lib/renderers/a2ui/components/layout/Modal.d.ts +0 -11
  504. package/lib/renderers/a2ui/components/layout/Modal.js +0 -58
  505. package/lib/renderers/a2ui/components/layout/Row.d.ts +0 -11
  506. package/lib/renderers/a2ui/components/layout/Row.js +0 -65
  507. package/lib/renderers/a2ui/components/layout/Tabs.d.ts +0 -11
  508. package/lib/renderers/a2ui/components/layout/Tabs.js +0 -48
  509. package/lib/renderers/a2ui/components/layout/index.d.ts +0 -6
  510. package/lib/renderers/a2ui/components/layout/index.js +0 -25
  511. package/lib/renderers/a2ui/context/A2UIContext.d.ts +0 -17
  512. package/lib/renderers/a2ui/context/A2UIContext.js +0 -54
  513. package/lib/renderers/a2ui/context/ThemeContext.d.ts +0 -20
  514. package/lib/renderers/a2ui/context/ThemeContext.js +0 -333
  515. package/lib/renderers/a2ui/hooks/useA2UI.d.ts +0 -36
  516. package/lib/renderers/a2ui/hooks/useA2UI.js +0 -62
  517. package/lib/renderers/a2ui/hooks/useDataBinding.d.ts +0 -8
  518. package/lib/renderers/a2ui/hooks/useDataBinding.js +0 -83
  519. package/lib/renderers/a2ui/index.d.ts +0 -9
  520. package/lib/renderers/a2ui/index.js +0 -28
  521. package/lib/renderers/a2ui/lib/utils.d.ts +0 -11
  522. package/lib/renderers/a2ui/lib/utils.js +0 -38
  523. package/lib/renderers/a2ui/types/index.d.ts +0 -17
  524. package/lib/runtime/index.d.ts +0 -38
  525. package/lib/runtime/index.js +0 -40
  526. package/lib/runtime/runtimeStore.d.ts +0 -76
  527. package/lib/runtime/runtimeStore.js +0 -184
  528. package/lib/runtime/types.d.ts +0 -84
  529. package/lib/runtime/useAgentConnection.d.ts +0 -45
  530. package/lib/runtime/useAgentConnection.js +0 -112
  531. package/lib/runtime/useAgentRuntime.d.ts +0 -93
  532. package/lib/runtime/useAgentRuntime.js +0 -125
  533. package/lib/specs/agents/codeai/agents.d.ts +0 -28
  534. package/lib/specs/agents/codeai/agents.js +0 -179
  535. package/lib/specs/agents/codeai/index.d.ts +0 -1
  536. package/lib/specs/agents/codemode-paper/agents.d.ts +0 -31
  537. package/lib/specs/agents/codemode-paper/agents.js +0 -378
  538. package/lib/specs/agents/codemode-paper/index.d.ts +0 -1
  539. package/lib/specs/agents/codemode-paper/index.js +0 -5
  540. package/lib/specs/agents/datalayer-ai/agents.d.ts +0 -31
  541. package/lib/specs/agents/datalayer-ai/agents.js +0 -352
  542. package/lib/specs/agents/datalayer-ai/index.d.ts +0 -1
  543. package/lib/specs/agents/datalayer-ai/index.js +0 -5
  544. package/lib/specs/agents/mocks/agents.d.ts +0 -43
  545. package/lib/specs/agents/mocks/index.d.ts +0 -1
  546. package/lib/specs/agents/mocks/index.js +0 -5
  547. package/lib/state/index.d.ts +0 -1
  548. package/lib/state/index.js +0 -5
  549. package/lib/state/substates/AIAgentState.d.ts +0 -80
  550. package/lib/state/substates/AIAgentState.js +0 -108
  551. package/lib/state/substates/index.d.ts +0 -1
  552. package/lib/state/substates/index.js +0 -5
  553. package/lib/types/AIAgent.d.ts +0 -17
  554. package/lib/types/Types.d.ts +0 -217
  555. /package/lib/{components/chat → api}/handler.d.ts +0 -0
  556. /package/lib/{renderers/index.d.ts → api/utils.d.ts} +0 -0
  557. /package/lib/{renderers/index.js → api/utils.js} +0 -0
  558. /package/lib/{components/chat/components/elements → chat/display}/PoweredByTag.js +0 -0
  559. /package/lib/{components/chat/components → chat}/parts/DynamicToolPart.js +0 -0
  560. /package/lib/{components/chat/components → chat}/parts/ReasoningPart.d.ts +0 -0
  561. /package/lib/{components/chat/components → chat}/parts/TextPart.js +0 -0
  562. /package/lib/{components/chat/components → chat}/parts/ToolPart.d.ts +0 -0
  563. /package/lib/{components/chat/components → chat}/styles/streamdownStyles.js +0 -0
  564. /package/lib/{components/chat/components/elements → chat/tools}/ToolApprovalDialog.d.ts +0 -0
  565. /package/lib/{components/chat/components → context}/ContextDistribution.d.ts +0 -0
  566. /package/lib/{components/chat/components → context}/ContextDistribution.js +0 -0
  567. /package/lib/{components/chat/components → context}/ContextInspector.d.ts +0 -0
  568. /package/lib/{components/chat/components → context}/ContextPanel.d.ts +0 -0
  569. /package/lib/{components/chat/components → context}/ContextUsage.d.ts +0 -0
  570. /package/lib/{components/chat/components → context}/ContextUsage.js +0 -0
  571. /package/lib/examples/{JupyterCellExample.d.ts → CellSimpleExample.d.ts} +0 -0
  572. /package/lib/examples/{AgentRuntimeCustomExample.d.ts → ChatCustomExample.d.ts} +0 -0
  573. /package/lib/examples/{AgentRuntimeChatExample.d.ts → ChatExample.d.ts} +0 -0
  574. /package/lib/examples/{AgentRuntimeStandaloneExample.d.ts → ChatStandaloneExample.d.ts} +0 -0
  575. /package/lib/examples/{AgentRuntimeNotebookExample.d.ts → NotebookExample.d.ts} +0 -0
  576. /package/lib/examples/{AgentRuntimeNotebookSidebarExample.d.ts → NotebookSidebarExample.d.ts} +0 -0
  577. /package/lib/examples/{JupyterNotebookExample.d.ts → NotebookSimpleExample.d.ts} +0 -0
  578. /package/lib/examples/{stores → utils}/agents/earthquake-detector.ipynb.json +0 -0
  579. /package/lib/examples/{stores → utils}/agents/earthquake-detector.json +0 -0
  580. /package/lib/examples/{stores → utils}/agents/earthquake-detector.lexical.json +0 -0
  581. /package/lib/examples/{stores → utils}/agents/sales-forecaster.ipynb.json +0 -0
  582. /package/lib/examples/{stores → utils}/agents/sales-forecaster.json +0 -0
  583. /package/lib/examples/{stores → utils}/agents/sales-forecaster.lexical.json +0 -0
  584. /package/lib/examples/{stores → utils}/agents/social-post-generator.ipynb.json +0 -0
  585. /package/lib/examples/{stores → utils}/agents/social-post-generator.json +0 -0
  586. /package/lib/examples/{stores → utils}/agents/social-post-generator.lexical.json +0 -0
  587. /package/lib/examples/{stores → utils}/agents/stock-market.ipynb.json +0 -0
  588. /package/lib/examples/{stores → utils}/agents/stock-market.json +0 -0
  589. /package/lib/examples/{stores → utils}/agents/stock-market.lexical.json +0 -0
  590. /package/lib/examples/{stores → utils}/notebooks/IPyWidgetsExample.ipynb.json +0 -0
  591. /package/lib/examples/{stores → utils}/notebooks/IPyWidgetsExampleWithState.ipynb.json +0 -0
  592. /package/lib/examples/{stores → utils}/notebooks/Lite.ipynb.json +0 -0
  593. /package/lib/examples/{stores → utils}/notebooks/Matplotlib.ipynb.json +0 -0
  594. /package/lib/examples/{stores → utils}/notebooks/NotebookExample1.ipynb.json +0 -0
  595. /package/lib/examples/{stores → utils}/notebooks/NotebookOutputs.ipynb.json +0 -0
  596. /package/lib/examples/{stores → utils}/notebooks/NotebookToCExample.ipynb.json +0 -0
  597. /package/lib/examples/{stores → utils}/notebooks/OutputIPyWidgetsExample.d.ts +0 -0
  598. /package/lib/examples/{stores → utils}/notebooks/OutputIPyWidgetsExample.js +0 -0
  599. /package/lib/examples/{stores → utils}/notebooks/PyGWalker.ipynb.json +0 -0
  600. /package/lib/examples/{stores → utils}/themedProvider.d.ts +0 -0
  601. /package/lib/examples/{stores → utils}/themedProvider.js +0 -0
  602. /package/lib/{components/chat/inference → inference}/BaseInferenceProvider.js +0 -0
  603. /package/lib/{components → mcp}/McpServerManager.js +0 -0
  604. /package/lib/{components/chat/middleware → middleware}/MiddlewarePipeline.js +0 -0
  605. /package/lib/{components/chat/types/inference.js → types/a2a.js} +0 -0
  606. /package/lib/{components/chat/types/protocol.js → types/acp.js} +0 -0
  607. /package/lib/{components/sparklines/types.js → types/ag-ui.js} +0 -0
  608. /package/lib/{renderers/a2ui/types/index.js → types/agents-lifecycle.js} +0 -0
  609. /package/lib/types/{AIAgent.js → agentspecs.js} +0 -0
  610. /package/lib/types/{Types.js → chat.js} +0 -0
  611. /package/lib/{components/chat/types → types}/execution.js +0 -0
  612. /package/lib/{components/chat/types/extension.js → types/extensions.js} +0 -0
  613. /package/lib/{components/chat/types/message.js → types/messages.js} +0 -0
  614. /package/lib/{components/chat/types → types}/middleware.js +0 -0
  615. /package/lib/{components/chat/types/tool.js → types/tools.js} +0 -0
@@ -0,0 +1,922 @@
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 team specifications.
7
+
8
+ Usage:
9
+ python generate_teams.py \\
10
+ --specs-dir agentspecs/agentspecs/teams \\
11
+ --python-output agent_runtimes/specs/teams.py \\
12
+ --typescript-output src/specs/teams.ts
13
+ """
14
+
15
+ import argparse
16
+ import json
17
+ import sys
18
+ from pathlib import Path
19
+ from typing import Any, Dict, List
20
+
21
+ import yaml
22
+ from versioning import ensure_spec_version, version_suffix
23
+
24
+
25
+ def _make_const_name(team_id: str) -> str:
26
+ """Convert a team ID to a constant name (e.g., 'analyze-campaign-performance' -> 'ANALYZE_CAMPAIGN_PERFORMANCE_TEAM_SPEC')."""
27
+ return f"{team_id.upper().replace('-', '_')}_TEAM_SPEC"
28
+
29
+
30
+ def _fmt_list(items: list[str]) -> str:
31
+ """Format a list of strings with double quotes for ruff compliance."""
32
+ if not items:
33
+ return "[]"
34
+ return "[" + ", ".join(f'"{item}"' for item in items) + "]"
35
+
36
+
37
+ def _fmt_py_literal(value: Any) -> str:
38
+ """Format a Python literal value."""
39
+ if value is None:
40
+ return "None"
41
+ if isinstance(value, bool):
42
+ return str(value)
43
+ if isinstance(value, str):
44
+ # Escape backslashes and quotes
45
+ escaped = (
46
+ value.replace("\\", "\\\\").replace('"', '\\"').replace("\n", " ").strip()
47
+ )
48
+ return f'"{escaped}"'
49
+ if isinstance(value, (int, float)):
50
+ return str(value)
51
+ if isinstance(value, list):
52
+ items = [_fmt_py_literal(i) for i in value]
53
+ return "[" + ", ".join(items) + "]"
54
+ if isinstance(value, dict):
55
+ items = [f'"{k}": {_fmt_py_literal(v)}' for k, v in value.items()]
56
+ return "{" + ", ".join(items) + "}"
57
+ return repr(value)
58
+
59
+
60
+ def _fmt_ts_literal(value: Any) -> str:
61
+ """Format a TypeScript literal value."""
62
+ if value is None:
63
+ return "undefined"
64
+ if isinstance(value, bool):
65
+ return "true" if value else "false"
66
+ if isinstance(value, str):
67
+ return json.dumps(value)
68
+ if isinstance(value, (int, float)):
69
+ return str(value)
70
+ if isinstance(value, list):
71
+ return json.dumps(value, indent=2)
72
+ if isinstance(value, dict):
73
+ return json.dumps(value, indent=2)
74
+ return json.dumps(value)
75
+
76
+
77
+ def load_yaml_specs(specs_dir: Path) -> List[tuple[str, Dict[str, Any]]]:
78
+ """Load all team YAML specifications from a directory.
79
+
80
+ Supports both flat (single directory) and subfolder structures.
81
+ Returns a list of (subfolder_name, spec_dict) tuples.
82
+ """
83
+ specs = []
84
+
85
+ # Load specs from root of the directory
86
+ for yaml_file in sorted(specs_dir.glob("*.yaml")):
87
+ with open(yaml_file) as f:
88
+ spec = yaml.safe_load(f)
89
+ if spec:
90
+ ensure_spec_version(spec)
91
+ specs.append(("", spec))
92
+
93
+ # Load specs from subdirectories (one level deep)
94
+ for subdir in sorted(specs_dir.iterdir()):
95
+ if subdir.is_dir() and not subdir.name.startswith("."):
96
+ for yaml_file in sorted(subdir.glob("*.yaml")):
97
+ with open(yaml_file) as f:
98
+ spec = yaml.safe_load(f)
99
+ if spec:
100
+ ensure_spec_version(spec)
101
+ specs.append((subdir.name, spec))
102
+
103
+ return specs
104
+
105
+
106
+ def _generate_team_agent_py(agent: Dict[str, Any]) -> str:
107
+ """Generate Python code for a TeamAgentSpec."""
108
+ lines = []
109
+ lines.append("TeamAgentSpec(")
110
+ lines.append(f' id="{agent.get("id", "")}",')
111
+ lines.append(f' name="{agent.get("name", "")}",')
112
+ lines.append(f' role="{agent.get("role", "")}",')
113
+ goal = agent.get("goal", "").replace('"', '\\"').replace("\n", " ").strip()
114
+ lines.append(f' goal="{goal}",')
115
+ lines.append(f' model="{agent.get("model", "")}",')
116
+ lines.append(f' mcp_server="{agent.get("mcp_server", "")}",')
117
+ tools = agent.get("tools", [])
118
+ lines.append(f" tools={_fmt_list(tools)},")
119
+ trigger = agent.get("trigger", "").replace('"', '\\"')
120
+ lines.append(f' trigger="{trigger}",')
121
+ lines.append(f' approval="{agent.get("approval", "auto")}",')
122
+ lines.append(" )")
123
+ return "\n".join(lines)
124
+
125
+
126
+ def _generate_team_agent_ts(agent: Dict[str, Any]) -> str:
127
+ """Generate TypeScript code for a TeamAgentSpec."""
128
+ goal = agent.get("goal", "").replace("`", "\\`").replace("\n", " ").strip()
129
+ tools = json.dumps(agent.get("tools", []))
130
+ trigger = agent.get("trigger", "").replace("'", "\\'")
131
+ return f""" {{
132
+ id: '{agent.get("id", "")}',
133
+ name: '{agent.get("name", "")}',
134
+ role: '{agent.get("role", "")}',
135
+ goal: `{goal}`,
136
+ model: '{agent.get("model", "")}',
137
+ mcpServer: '{agent.get("mcp_server", "")}',
138
+ tools: {tools},
139
+ trigger: '{trigger}',
140
+ approval: '{agent.get("approval", "auto")}',
141
+ }}"""
142
+
143
+
144
+ def generate_python_code(specs: List[tuple[str, Dict[str, Any]]]) -> str:
145
+ """Generate Python code from team specifications."""
146
+ code = '''# Copyright (c) 2025-2026 Datalayer, Inc.
147
+ # Distributed under the terms of the Modified BSD License.
148
+
149
+ """
150
+ Team Specifications.
151
+
152
+ THIS FILE IS AUTO-GENERATED from YAML team specifications.
153
+ DO NOT EDIT MANUALLY - run 'make specs' to regenerate.
154
+ """
155
+
156
+ from typing import Dict, Optional
157
+
158
+ from agent_runtimes.types import (
159
+ TeamAgentSpec,
160
+ TeamHealthMonitoring,
161
+ TeamOutputSpec,
162
+ TeamReactionRule,
163
+ TeamSpec,
164
+ TeamSupervisorSpec,
165
+ TeamValidationSpec,
166
+ )
167
+
168
+
169
+ # ============================================================================
170
+ # Team Definitions
171
+ # ============================================================================
172
+
173
+ '''
174
+
175
+ team_ids = [] # (full_id, const_name, folder)
176
+
177
+ # Organize by folder
178
+ folders = {}
179
+ for folder, spec in specs:
180
+ if folder not in folders:
181
+ folders[folder] = []
182
+ folders[folder].append(spec)
183
+
184
+ sorted_folders = sorted(folders.keys())
185
+
186
+ for folder in sorted_folders:
187
+ folder_specs = folders[folder]
188
+ if folder:
189
+ code += f"# {'=' * 76}\n"
190
+ code += f"# {folder.replace('-', ' ').title()}\n"
191
+ code += f"# {'=' * 76}\n\n"
192
+
193
+ for spec in folder_specs:
194
+ team_id = spec["id"]
195
+ version = spec["version"]
196
+ if folder:
197
+ full_team_id = f"{folder}/{team_id}"
198
+ const_name = _make_const_name(f"{folder}_{team_id}") + version_suffix(
199
+ version
200
+ )
201
+ else:
202
+ full_team_id = team_id
203
+ const_name = _make_const_name(team_id) + version_suffix(version)
204
+
205
+ team_ids.append((full_team_id, const_name, folder))
206
+
207
+ description = (
208
+ spec.get("description", "")
209
+ .replace("\n", " ")
210
+ .replace(" ", " ")
211
+ .replace('"', '\\"')
212
+ .strip()
213
+ )
214
+ tags = _fmt_list(spec.get("tags", []))
215
+
216
+ # Supervisor
217
+ supervisor = spec.get("supervisor")
218
+ if supervisor and isinstance(supervisor, dict):
219
+ sup_name = supervisor.get("name", "").replace('"', '\\"')
220
+ sup_model = supervisor.get("model", "")
221
+ supervisor_code = (
222
+ f'TeamSupervisorSpec(name="{sup_name}", model="{sup_model}")'
223
+ )
224
+ else:
225
+ supervisor_code = "None"
226
+
227
+ # Validation
228
+ validation = spec.get("validation")
229
+ if validation and isinstance(validation, dict):
230
+ timeout = validation.get("timeout")
231
+ retry = validation.get("retry_on_failure", False)
232
+ max_retries = validation.get("max_retries", 0)
233
+ timeout_str = f'"{timeout}"' if timeout else "None"
234
+ validation_code = f"TeamValidationSpec(timeout={timeout_str}, retry_on_failure={retry}, max_retries={max_retries})"
235
+ else:
236
+ validation_code = "None"
237
+
238
+ # Team agents
239
+ agents = spec.get("agents", [])
240
+ if agents:
241
+ agents_code = "[\n"
242
+ for agent in agents:
243
+ agents_code += f" {_generate_team_agent_py(agent)},\n"
244
+ agents_code += " ]"
245
+ else:
246
+ agents_code = "[]"
247
+
248
+ routing = (
249
+ spec.get("routing_instructions", "")
250
+ .replace("\n", " ")
251
+ .replace(" ", " ")
252
+ .replace('"', '\\"')
253
+ .strip()
254
+ )
255
+
256
+ # Reaction rules
257
+ reaction_rules = spec.get("reaction_rules", [])
258
+ if reaction_rules:
259
+ rr_items = []
260
+ for rr in reaction_rules:
261
+ rr_items.append(
262
+ f'TeamReactionRule(id="{rr.get("id", "")}", '
263
+ f'trigger="{rr.get("trigger", "")}", '
264
+ f'action="{rr.get("action", "")}", '
265
+ f"auto={rr.get('auto', True)}, "
266
+ f"max_retries={rr.get('max_retries', 0)}, "
267
+ f"escalate_after_retries={rr.get('escalate_after_retries', 0)}, "
268
+ f'priority="{rr.get("priority", "medium")}")'
269
+ )
270
+ reaction_rules_code = (
271
+ "[\n " + ",\n ".join(rr_items) + ",\n ]"
272
+ )
273
+ else:
274
+ reaction_rules_code = "None"
275
+
276
+ # Health monitoring
277
+ health_monitoring = spec.get("health_monitoring")
278
+ if health_monitoring and isinstance(health_monitoring, dict):
279
+ hm = health_monitoring
280
+ health_monitoring_code = (
281
+ f"TeamHealthMonitoring("
282
+ f'heartbeat_interval="{hm.get("heartbeat_interval", "30s")}", '
283
+ f'stale_threshold="{hm.get("stale_threshold", "120s")}", '
284
+ f'unresponsive_threshold="{hm.get("unresponsive_threshold", "300s")}", '
285
+ f'stuck_threshold="{hm.get("stuck_threshold", "600s")}", '
286
+ f"max_restart_attempts={hm.get('max_restart_attempts', 3)})"
287
+ )
288
+ else:
289
+ health_monitoring_code = "None"
290
+
291
+ # Notifications
292
+ notifications = spec.get("notifications")
293
+ if notifications and isinstance(notifications, dict):
294
+ notifications_code = _fmt_py_literal(notifications)
295
+ else:
296
+ notifications_code = "None"
297
+
298
+ # Output
299
+ output = spec.get("output")
300
+ if output and isinstance(output, dict):
301
+ formats = _fmt_list(output.get("formats", []))
302
+ template = output.get("template", "")
303
+ storage = output.get("storage", "")
304
+ output_code = (
305
+ f"TeamOutputSpec(formats={formats}, "
306
+ f'template="{template}", '
307
+ f'storage="{storage}")'
308
+ )
309
+ else:
310
+ output_code = "None"
311
+
312
+ code += f"{const_name} = TeamSpec(\n"
313
+ code += f' id="{full_team_id}",\n'
314
+ code += f' version="{version}",\n'
315
+ code += f' name="{spec["name"]}",\n'
316
+ code += f' description="{description}",\n'
317
+ code += f" tags={tags},\n"
318
+ code += f" enabled={spec.get('enabled', False)},\n"
319
+ code += f' icon="{spec.get("icon", "people")}",\n'
320
+ code += f' emoji="{spec.get("emoji", "👥")}",\n'
321
+ code += f' color="{spec.get("color", "#8250df")}",\n'
322
+ code += f' agent_spec_id="{spec.get("agent_spec_id", "")}",\n'
323
+ code += f' orchestration_protocol="{spec.get("orchestration_protocol", "datalayer")}",\n'
324
+ code += (
325
+ f' execution_mode="{spec.get("execution_mode", "sequential")}",\n'
326
+ )
327
+ code += f" supervisor={supervisor_code},\n"
328
+ code += f' routing_instructions="{routing}",\n'
329
+ code += f" validation={validation_code},\n"
330
+ code += f" agents={agents_code},\n"
331
+ if reaction_rules_code != "None":
332
+ code += f" reaction_rules={reaction_rules_code},\n"
333
+ if health_monitoring_code != "None":
334
+ code += f" health_monitoring={health_monitoring_code},\n"
335
+ if notifications_code != "None":
336
+ code += f" notifications={notifications_code},\n"
337
+ if output_code != "None":
338
+ code += f" output={output_code},\n"
339
+ code += ")\n\n"
340
+
341
+ # Generate registry
342
+ code += """# ============================================================================
343
+ # Team Specs Registry
344
+ # ============================================================================
345
+
346
+ TEAM_SPECS: Dict[str, TeamSpec] = {
347
+ """
348
+
349
+ for folder in sorted_folders:
350
+ folder_teams = [(tid, cname) for tid, cname, f in team_ids if f == folder]
351
+ if folder_teams and folder:
352
+ code += f" # {folder.replace('-', ' ').title()}\n"
353
+ for full_team_id, const_name in folder_teams:
354
+ code += f' "{full_team_id}": {const_name},\n'
355
+ if folder_teams and folder:
356
+ code += "\n"
357
+
358
+ code += """}
359
+
360
+
361
+ def get_team_spec(team_id: str) -> TeamSpec | None:
362
+ \"\"\"Get a team specification by ID.\"\"\"
363
+ spec = TEAM_SPECS.get(team_id)
364
+ if spec is not None:
365
+ return spec
366
+ base, _, ver = team_id.rpartition(':')
367
+ if base and '.' in ver:
368
+ return TEAM_SPECS.get(base)
369
+ return None
370
+
371
+
372
+ def list_team_specs(prefix: str | None = None) -> list[TeamSpec]:
373
+ \"\"\"List all available team specifications.
374
+
375
+ Args:
376
+ prefix: If provided, only return specs whose ID starts with this prefix.
377
+ \"\"\"
378
+ specs = list(TEAM_SPECS.values())
379
+ if prefix is not None:
380
+ specs = [s for s in specs if s.id.startswith(prefix)]
381
+ return specs
382
+ """
383
+
384
+ return code
385
+
386
+
387
+ def generate_typescript_code(
388
+ specs: List[tuple[str, Dict[str, Any]]], types_import_path: str = "../types"
389
+ ) -> str:
390
+ """Generate TypeScript code from team specifications."""
391
+ code = f"""/*
392
+ * Copyright (c) 2025-2026 Datalayer, Inc.
393
+ * Distributed under the terms of the Modified BSD License.
394
+ */
395
+
396
+ /**
397
+ * Team Specifications.
398
+ *
399
+ * THIS FILE IS AUTO-GENERATED from YAML team specifications.
400
+ * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.
401
+ */
402
+
403
+ import type {{ TeamSpec }} from '{types_import_path}';
404
+
405
+ // ============================================================================
406
+ // Team Definitions
407
+ // ============================================================================
408
+
409
+ """
410
+
411
+ team_ids = [] # (full_id, const_name, folder)
412
+
413
+ # Organize by folder
414
+ folders: Dict[str, list] = {}
415
+ for folder, spec in specs:
416
+ if folder not in folders:
417
+ folders[folder] = []
418
+ folders[folder].append(spec)
419
+
420
+ sorted_folders = sorted(folders.keys())
421
+
422
+ for folder in sorted_folders:
423
+ folder_specs = folders[folder]
424
+ if folder:
425
+ code += f"// {'=' * 76}\n"
426
+ code += f"// {folder.replace('-', ' ').title()}\n"
427
+ code += f"// {'=' * 76}\n\n"
428
+
429
+ for spec in folder_specs:
430
+ team_id = spec["id"]
431
+ version = spec["version"]
432
+ if folder:
433
+ full_team_id = f"{folder}/{team_id}"
434
+ const_name = _make_const_name(f"{folder}_{team_id}") + version_suffix(
435
+ version
436
+ )
437
+ else:
438
+ full_team_id = team_id
439
+ const_name = _make_const_name(team_id) + version_suffix(version)
440
+
441
+ team_ids.append((full_team_id, const_name, folder))
442
+
443
+ description = (
444
+ spec.get("description", "")
445
+ .replace("`", "\\`")
446
+ .replace("\n", " ")
447
+ .replace(" ", " ")
448
+ .strip()
449
+ )
450
+ tags = json.dumps(spec.get("tags", []))
451
+
452
+ # Supervisor
453
+ supervisor = spec.get("supervisor")
454
+ if supervisor and isinstance(supervisor, dict):
455
+ sup_name = supervisor.get("name", "").replace("'", "\\'")
456
+ sup_model = supervisor.get("model", "")
457
+ supervisor_ts = f"{{ name: '{sup_name}', model: '{sup_model}' }}"
458
+ else:
459
+ supervisor_ts = "undefined"
460
+
461
+ # Validation
462
+ validation = spec.get("validation")
463
+ if validation and isinstance(validation, dict):
464
+ timeout = validation.get("timeout")
465
+ retry = "true" if validation.get("retry_on_failure", False) else "false"
466
+ max_retries = validation.get("max_retries", 0)
467
+ timeout_ts = f"'{timeout}'" if timeout else "undefined"
468
+ validation_ts = f"{{ timeout: {timeout_ts}, retryOnFailure: {retry}, maxRetries: {max_retries} }}"
469
+ else:
470
+ validation_ts = "undefined"
471
+
472
+ # Team agents
473
+ agents = spec.get("agents", [])
474
+ if agents:
475
+ agents_parts = [_generate_team_agent_ts(a) for a in agents]
476
+ agents_ts = "[\n" + ",\n".join(agents_parts) + ",\n ]"
477
+ else:
478
+ agents_ts = "[]"
479
+
480
+ routing = (
481
+ spec.get("routing_instructions", "")
482
+ .replace("`", "\\`")
483
+ .replace("\n", " ")
484
+ .replace(" ", " ")
485
+ .strip()
486
+ )
487
+
488
+ # Reaction rules
489
+ reaction_rules = spec.get("reaction_rules", [])
490
+ if reaction_rules:
491
+ rr_ts = json.dumps(
492
+ [
493
+ {
494
+ "id": rr.get("id", ""),
495
+ "trigger": rr.get("trigger", ""),
496
+ "action": rr.get("action", ""),
497
+ "auto": rr.get("auto", True),
498
+ "maxRetries": rr.get("max_retries", 0),
499
+ "escalateAfterRetries": rr.get("escalate_after_retries", 0),
500
+ "priority": rr.get("priority", "medium"),
501
+ }
502
+ for rr in reaction_rules
503
+ ],
504
+ indent=2,
505
+ )
506
+ else:
507
+ rr_ts = None
508
+
509
+ # Health monitoring
510
+ health_monitoring = spec.get("health_monitoring")
511
+ if health_monitoring and isinstance(health_monitoring, dict):
512
+ hm = health_monitoring
513
+ hm_ts = json.dumps(
514
+ {
515
+ "heartbeatInterval": hm.get("heartbeat_interval", "30s"),
516
+ "staleThreshold": hm.get("stale_threshold", "120s"),
517
+ "unresponsiveThreshold": hm.get(
518
+ "unresponsive_threshold", "300s"
519
+ ),
520
+ "stuckThreshold": hm.get("stuck_threshold", "600s"),
521
+ "maxRestartAttempts": hm.get("max_restart_attempts", 3),
522
+ },
523
+ indent=2,
524
+ )
525
+ else:
526
+ hm_ts = None
527
+
528
+ # Notifications
529
+ notifications = spec.get("notifications")
530
+ if notifications and isinstance(notifications, dict):
531
+ notif_ts = json.dumps(
532
+ {k.replace("_", ""): v for k, v in notifications.items()}
533
+ if False
534
+ else notifications,
535
+ indent=2,
536
+ )
537
+ else:
538
+ notif_ts = None
539
+
540
+ # Output
541
+ output = spec.get("output")
542
+ if output and isinstance(output, dict):
543
+ output_ts = json.dumps(
544
+ {
545
+ "formats": output.get("formats", []),
546
+ "template": output.get("template", ""),
547
+ "storage": output.get("storage", ""),
548
+ },
549
+ indent=2,
550
+ )
551
+ else:
552
+ output_ts = None
553
+
554
+ code += f"export const {const_name}: TeamSpec = {{\n"
555
+ code += f" id: '{full_team_id}',\n"
556
+ code += f" version: '{version}',\n"
557
+ code += f" name: '{spec['name']}',\n"
558
+ code += f" description: `{description}`,\n"
559
+ code += f" tags: {tags},\n"
560
+ code += f" enabled: {str(spec.get('enabled', False)).lower()},\n"
561
+ code += f" icon: '{spec.get('icon', 'people')}',\n"
562
+ code += f" emoji: '{spec.get('emoji', '👥')}',\n"
563
+ code += f" color: '{spec.get('color', '#8250df')}',\n"
564
+ code += f" agentSpecId: '{spec.get('agent_spec_id', '')}',\n"
565
+ code += f" orchestrationProtocol: '{spec.get('orchestration_protocol', 'datalayer')}',\n"
566
+ code += f" executionMode: '{spec.get('execution_mode', 'sequential')}',\n"
567
+ code += f" supervisor: {supervisor_ts},\n"
568
+ code += f" routingInstructions: `{routing}`,\n"
569
+ code += f" validation: {validation_ts},\n"
570
+ code += f" agents: {agents_ts},\n"
571
+ if rr_ts is not None:
572
+ code += f" reactionRules: {rr_ts},\n"
573
+ if hm_ts is not None:
574
+ code += f" healthMonitoring: {hm_ts},\n"
575
+ if notif_ts is not None:
576
+ code += f" notifications: {notif_ts},\n"
577
+ if output_ts is not None:
578
+ code += f" output: {output_ts},\n"
579
+ code += "};\n\n"
580
+
581
+ # Registry
582
+ code += """// ============================================================================
583
+ // Team Specs Registry
584
+ // ============================================================================
585
+
586
+ export const TEAM_SPECS: Record<string, TeamSpec> = {
587
+ """
588
+
589
+ for folder in sorted_folders:
590
+ folder_teams = [(tid, cname) for tid, cname, f in team_ids if f == folder]
591
+ if folder_teams and folder:
592
+ code += f" // {folder.replace('-', ' ').title()}\n"
593
+ for full_team_id, const_name in folder_teams:
594
+ code += f" '{full_team_id}': {const_name},\n"
595
+ if folder_teams and folder:
596
+ code += "\n"
597
+
598
+ code += """};
599
+
600
+ function resolveTeamId(teamId: string): string {
601
+ if (teamId in TEAM_SPECS) return teamId;
602
+ const idx = teamId.lastIndexOf(':');
603
+ if (idx > 0) {
604
+ const base = teamId.slice(0, idx);
605
+ if (base in TEAM_SPECS) return base;
606
+ }
607
+ return teamId;
608
+ }
609
+
610
+ /**
611
+ * Get a team specification by ID.
612
+ */
613
+ export function getTeamSpec(teamId: string): TeamSpec | undefined {
614
+ return TEAM_SPECS[resolveTeamId(teamId)];
615
+ }
616
+
617
+ /**
618
+ * List all available team specifications.
619
+ *
620
+ * @param prefix - If provided, only return specs whose ID starts with this prefix.
621
+ */
622
+ export function listTeamSpecs(prefix?: string): TeamSpec[] {
623
+ const specs = Object.values(TEAM_SPECS);
624
+ return prefix !== undefined ? specs.filter(s => s.id.startsWith(prefix)) : specs;
625
+ }
626
+ """
627
+
628
+ return code
629
+
630
+
631
+ def generate_subfolder_structure(specs: List[tuple[str, Dict[str, Any]]], args):
632
+ """Generate separate team files per subfolder."""
633
+ from collections import defaultdict
634
+
635
+ # Organize specs by folder
636
+ specs_by_folder: Dict[str, List[Dict[str, Any]]] = defaultdict(list)
637
+ for folder, spec in specs:
638
+ specs_by_folder[folder].append(spec)
639
+
640
+ # Determine base directories
641
+ python_base = args.python_output.parent / "teams"
642
+ typescript_base = args.typescript_output.parent / "teams"
643
+ python_base.mkdir(parents=True, exist_ok=True)
644
+ typescript_base.mkdir(parents=True, exist_ok=True)
645
+
646
+ print(f"Generating subfolder structure in {python_base} and {typescript_base}...")
647
+
648
+ all_python_imports = []
649
+ all_typescript_imports = []
650
+
651
+ for folder, folder_specs in sorted(specs_by_folder.items()):
652
+ is_root = not folder
653
+ if is_root:
654
+ print(" Generating teams for root level")
655
+ else:
656
+ print(f" Generating teams for subfolder: {folder}")
657
+
658
+ folder_python_name = folder.replace("-", "_") if folder else "teams"
659
+
660
+ # Create Python output file
661
+ if is_root:
662
+ python_file = python_base / "teams.py"
663
+ else:
664
+ python_folder_dir = python_base / folder_python_name
665
+ python_folder_dir.mkdir(parents=True, exist_ok=True)
666
+ python_file = python_folder_dir / "teams.py"
667
+
668
+ python_code = generate_python_code([(folder, spec) for spec in folder_specs])
669
+ with open(python_file, "w") as f:
670
+ f.write(python_code)
671
+
672
+ if not is_root:
673
+ python_init = python_folder_dir / "__init__.py"
674
+ with open(python_init, "w") as f:
675
+ f.write("""# Copyright (c) 2025-2026 Datalayer, Inc.
676
+ # Distributed under the terms of the Modified BSD License.
677
+
678
+ from .teams import *
679
+
680
+ __all__ = ["TEAM_SPECS", "get_team_spec", "list_team_specs"]
681
+ """)
682
+
683
+ if is_root:
684
+ all_python_imports.append("from .teams import TEAM_SPECS as ROOT_TEAMS")
685
+ else:
686
+ all_python_imports.append(
687
+ f"from .{folder_python_name} import TEAM_SPECS as {folder_python_name.upper()}_TEAMS"
688
+ )
689
+
690
+ # Create TypeScript output file
691
+ if is_root:
692
+ typescript_file = typescript_base / "teams.ts"
693
+ else:
694
+ typescript_folder_dir = typescript_base / folder
695
+ typescript_folder_dir.mkdir(parents=True, exist_ok=True)
696
+ typescript_file = typescript_folder_dir / "teams.ts"
697
+
698
+ typescript_code = generate_typescript_code(
699
+ [(folder, spec) for spec in folder_specs],
700
+ types_import_path="../../types" if is_root else "../../../types",
701
+ )
702
+ with open(typescript_file, "w") as f:
703
+ f.write(typescript_code)
704
+
705
+ if not is_root:
706
+ typescript_index = typescript_folder_dir / "index.ts"
707
+ with open(typescript_index, "w") as f:
708
+ f.write("""/*
709
+ * Copyright (c) 2025-2026 Datalayer, Inc.
710
+ * Distributed under the terms of the Modified BSD License.
711
+ */
712
+
713
+ export * from './teams';
714
+ """)
715
+
716
+ if is_root:
717
+ all_typescript_imports.append("export * from './teams';")
718
+ else:
719
+ all_typescript_imports.append(f"export * from './{folder}';")
720
+
721
+ # Create main Python index file
722
+ python_index = python_base / "__init__.py"
723
+ python_index_content = """# Copyright (c) 2025-2026 Datalayer, Inc.
724
+ # Distributed under the terms of the Modified BSD License.
725
+
726
+ \"\"\"
727
+ Team Library - Subfolder Organization.
728
+
729
+ THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY.
730
+ \"\"\"
731
+
732
+ from typing import Dict
733
+ from agent_runtimes.types import TeamSpec
734
+
735
+ """
736
+
737
+ for imp in all_python_imports:
738
+ python_index_content += f"{imp}\n"
739
+
740
+ python_index_content += """
741
+ # Merge all team specs from subfolders
742
+ TEAM_SPECS: Dict[str, TeamSpec] = {}
743
+ """
744
+
745
+ for folder in sorted(specs_by_folder.keys()):
746
+ if folder:
747
+ folder_python_name = folder.replace("-", "_")
748
+ python_index_content += (
749
+ f"TEAM_SPECS.update({folder_python_name.upper()}_TEAMS)\n"
750
+ )
751
+ else:
752
+ python_index_content += "TEAM_SPECS.update(ROOT_TEAMS)\n"
753
+
754
+ python_index_content += """
755
+
756
+ def get_team_spec(team_id: str) -> TeamSpec | None:
757
+ \"\"\"Get a team specification by ID.\"\"\"
758
+ spec = TEAM_SPECS.get(team_id)
759
+ if spec is not None:
760
+ return spec
761
+ base, _, ver = team_id.rpartition(':')
762
+ if base and '.' in ver:
763
+ return TEAM_SPECS.get(base)
764
+ return None
765
+
766
+
767
+ def list_team_specs(prefix: str | None = None) -> list[TeamSpec]:
768
+ \"\"\"List all available team specifications.
769
+
770
+ Args:
771
+ prefix: If provided, only return specs whose ID starts with this prefix.
772
+ \"\"\"
773
+ specs = list(TEAM_SPECS.values())
774
+ if prefix is not None:
775
+ specs = [s for s in specs if s.id.startswith(prefix)]
776
+ return specs
777
+
778
+ __all__ = ["TEAM_SPECS", "get_team_spec", "list_team_specs"]
779
+ """
780
+
781
+ with open(python_index, "w") as f:
782
+ f.write(python_index_content)
783
+
784
+ # Create main TypeScript index file
785
+ typescript_index = typescript_base / "index.ts"
786
+ typescript_index_content = """/*
787
+ * Copyright (c) 2025-2026 Datalayer, Inc.
788
+ * Distributed under the terms of the Modified BSD License.
789
+ */
790
+
791
+ /**
792
+ * Team Library - Subfolder Organization.
793
+ *
794
+ * THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY.
795
+ */
796
+
797
+ import type { TeamSpec } from '../../types';
798
+
799
+ """
800
+
801
+ for folder in sorted(specs_by_folder.keys()):
802
+ if folder:
803
+ folder_const = folder.replace("-", "_").upper()
804
+ typescript_index_content += (
805
+ f"import {{ TEAM_SPECS as {folder_const}_TEAMS }} from './{folder}';\n"
806
+ )
807
+ else:
808
+ typescript_index_content += (
809
+ "import { TEAM_SPECS as ROOT_TEAMS } from './teams';\n"
810
+ )
811
+
812
+ typescript_index_content += """
813
+ // Merge all team specs from subfolders
814
+ export const TEAM_SPECS: Record<string, TeamSpec> = {
815
+ """
816
+
817
+ for folder in sorted(specs_by_folder.keys()):
818
+ if folder:
819
+ folder_const = folder.replace("-", "_").upper()
820
+ typescript_index_content += f" ...{folder_const}_TEAMS,\n"
821
+ else:
822
+ typescript_index_content += " ...ROOT_TEAMS,\n"
823
+
824
+ typescript_index_content += """};
825
+
826
+ function resolveTeamId(teamId: string): string {
827
+ if (teamId in TEAM_SPECS) return teamId;
828
+ const idx = teamId.lastIndexOf(':');
829
+ if (idx > 0) {
830
+ const base = teamId.slice(0, idx);
831
+ if (base in TEAM_SPECS) return base;
832
+ }
833
+ return teamId;
834
+ }
835
+
836
+ /**
837
+ * Get a team specification by ID.
838
+ */
839
+ export function getTeamSpec(teamId: string): TeamSpec | undefined {
840
+ return TEAM_SPECS[resolveTeamId(teamId)];
841
+ }
842
+
843
+ /**
844
+ * List all available team specifications.
845
+ *
846
+ * @param prefix - If provided, only return specs whose ID starts with this prefix.
847
+ */
848
+ export function listTeamSpecs(prefix?: string): TeamSpec[] {
849
+ const specs = Object.values(TEAM_SPECS);
850
+ return prefix !== undefined ? specs.filter(s => s.id.startsWith(prefix)) : specs;
851
+ }
852
+ """
853
+
854
+ with open(typescript_index, "w") as f:
855
+ f.write(typescript_index_content)
856
+
857
+ print(f"✓ Generated {len(specs_by_folder)} subfolder(s)")
858
+
859
+
860
+ def main():
861
+ """Main entry point."""
862
+ parser = argparse.ArgumentParser(
863
+ description="Generate Python and TypeScript code from YAML team specifications"
864
+ )
865
+ parser.add_argument(
866
+ "--specs-dir",
867
+ type=Path,
868
+ default=Path("specs/teams"),
869
+ help="Directory containing YAML team specifications",
870
+ )
871
+ parser.add_argument(
872
+ "--python-output",
873
+ type=Path,
874
+ default=Path("agent_runtimes/specs/teams.py"),
875
+ help="Output path for generated Python code",
876
+ )
877
+ parser.add_argument(
878
+ "--typescript-output",
879
+ type=Path,
880
+ default=Path("src/specs/teams.ts"),
881
+ help="Output path for generated TypeScript code",
882
+ )
883
+ parser.add_argument(
884
+ "--subfolder-structure",
885
+ action="store_true",
886
+ help="Generate separate files per subfolder instead of one combined file",
887
+ )
888
+
889
+ args = parser.parse_args()
890
+
891
+ # Check specs directory exists
892
+ if not args.specs_dir.exists():
893
+ print(f"Error: Specs directory not found: {args.specs_dir}", file=sys.stderr)
894
+ sys.exit(1)
895
+
896
+ # Load YAML specifications
897
+ print(f"Loading team specifications from {args.specs_dir}...")
898
+ specs = load_yaml_specs(args.specs_dir)
899
+ print(f"Loaded {len(specs)} team specification(s)")
900
+
901
+ if args.subfolder_structure:
902
+ generate_subfolder_structure(specs, args)
903
+ else:
904
+ # Generate Python code (single file)
905
+ print(f"Generating Python code to {args.python_output}...")
906
+ python_code = generate_python_code(specs)
907
+ args.python_output.parent.mkdir(parents=True, exist_ok=True)
908
+ with open(args.python_output, "w") as f:
909
+ f.write(python_code)
910
+
911
+ # Generate TypeScript code (single file)
912
+ print(f"Generating TypeScript code to {args.typescript_output}...")
913
+ typescript_code = generate_typescript_code(specs)
914
+ args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
915
+ with open(args.typescript_output, "w") as f:
916
+ f.write(typescript_code)
917
+
918
+ print("✅ Team code generation complete!")
919
+
920
+
921
+ if __name__ == "__main__":
922
+ main()