@datalayer/agent-runtimes 1.0.2 → 1.0.4
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.
- package/README.md +14 -132
- package/lib/Agent.js +2 -2
- package/lib/AgentLexical.d.ts +1 -12
- package/lib/AgentLexical.js +3 -14
- package/lib/AgentNotebook.js +3 -3
- package/lib/App.js +2 -2
- package/lib/{components/chat/components → agents}/AgentDetails.d.ts +13 -2
- package/lib/{components/chat/components → agents}/AgentDetails.js +6 -12
- package/lib/api/agents.d.ts +47 -0
- package/lib/api/agents.js +106 -0
- package/lib/api/context.d.ts +17 -0
- package/lib/api/context.js +45 -0
- package/lib/api/evals.d.ts +27 -0
- package/lib/api/evals.js +63 -0
- package/lib/api/events.d.ts +17 -0
- package/lib/api/events.js +93 -0
- package/lib/{components/chat → api}/handler.js +1 -1
- package/lib/api/index.d.ts +15 -0
- package/lib/api/index.js +20 -0
- package/lib/api/notifications.d.ts +39 -0
- package/lib/api/notifications.js +103 -0
- package/lib/api/output.d.ts +28 -0
- package/lib/api/output.js +64 -0
- package/lib/api/tool-approvals.d.ts +62 -0
- package/lib/api/tool-approvals.js +145 -0
- package/lib/{components/chat/components → chat}/Chat.d.ts +26 -15
- package/lib/{components/chat/components → chat}/Chat.js +16 -16
- package/lib/{components/chat/components → chat}/ChatFloating.d.ts +17 -9
- package/lib/{components/chat/components → chat}/ChatFloating.js +17 -9
- package/lib/{components/chat/components → chat}/ChatInline.d.ts +2 -2
- package/lib/{components/chat/components → chat}/ChatInline.js +8 -6
- package/lib/{components/chat/components → chat}/ChatPopupStandalone.d.ts +3 -4
- package/lib/{components/chat/components → chat}/ChatPopupStandalone.js +6 -6
- package/lib/{components/chat/components → chat}/ChatSidebar.d.ts +14 -5
- package/lib/{components/chat/components → chat}/ChatSidebar.js +48 -26
- package/lib/{components/chat/components → chat}/ChatStandalone.d.ts +3 -4
- package/lib/{components/chat/components → chat}/ChatStandalone.js +5 -5
- package/lib/chat/base/ChatBase.d.ts +6 -0
- package/lib/chat/base/ChatBase.js +1338 -0
- package/lib/chat/display/EmptyState.d.ts +27 -0
- package/lib/chat/display/EmptyState.js +41 -0
- package/lib/{components/chat/components/elements → chat/display}/FloatingBrandButton.d.ts +1 -1
- package/lib/{components/chat/components/elements → chat/display}/FloatingBrandButton.js +1 -1
- package/lib/{components/chat/components/elements → chat/display}/PoweredByTag.d.ts +1 -1
- package/lib/{components/chat/components/elements → chat/header}/ChatHeader.d.ts +1 -4
- package/lib/{components/chat/components/elements → chat/header}/ChatHeader.js +1 -1
- package/lib/chat/header/ChatHeaderBase.d.ts +38 -0
- package/lib/chat/header/ChatHeaderBase.js +83 -0
- package/lib/chat/index.d.ts +66 -0
- package/lib/chat/index.js +74 -0
- package/lib/chat/indicators/McpStatusIndicator.d.ts +9 -0
- package/lib/chat/indicators/McpStatusIndicator.js +128 -0
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +10 -0
- package/lib/chat/indicators/SandboxStatusIndicator.js +175 -0
- package/lib/chat/indicators/index.d.ts +17 -0
- package/lib/chat/indicators/index.js +19 -0
- package/lib/chat/messages/ChatMessageList.d.ts +49 -0
- package/lib/chat/messages/ChatMessageList.js +332 -0
- package/lib/{components/chat/components/elements → chat/messages}/ChatMessages.d.ts +2 -2
- package/lib/{components/chat/components/elements → chat/messages}/ChatMessages.js +6 -4
- package/lib/{components/chat/components → chat}/parts/DynamicToolPart.d.ts +1 -1
- package/lib/{components/chat/components/elements → chat/parts}/MessagePart.d.ts +1 -1
- package/lib/{components/chat/components/elements → chat/parts}/MessagePart.js +4 -4
- package/lib/{components/chat/components → chat}/parts/ReasoningPart.js +1 -1
- package/lib/{components/chat/components → chat}/parts/TextPart.d.ts +1 -1
- package/lib/{components/chat/components → chat}/parts/ToolPart.js +1 -1
- package/lib/{components/chat/components → chat}/parts/index.d.ts +2 -1
- package/lib/{components/chat/components → chat}/parts/index.js +2 -1
- package/lib/chat/prompt/InputFooter.d.ts +43 -0
- package/lib/chat/prompt/InputFooter.js +135 -0
- package/lib/chat/prompt/InputPrompt.d.ts +60 -0
- package/lib/chat/prompt/InputPrompt.js +83 -0
- package/lib/chat/prompt/InputPromptFooter.d.ts +25 -0
- package/lib/chat/prompt/InputPromptFooter.js +15 -0
- package/lib/chat/prompt/InputPromptHeader.d.ts +15 -0
- package/lib/chat/prompt/InputPromptHeader.js +15 -0
- package/lib/chat/prompt/InputPromptLexical.d.ts +16 -0
- package/lib/chat/prompt/InputPromptLexical.js +122 -0
- package/lib/chat/prompt/InputPromptText.d.ts +24 -0
- package/lib/chat/prompt/InputPromptText.js +66 -0
- package/lib/chat/prompt/index.d.ts +11 -0
- package/lib/chat/prompt/index.js +15 -0
- package/lib/{components/chat/components → chat}/styles/streamdownStyles.d.ts +1 -1
- package/lib/chat/tools/ToolApprovalBanner.d.ts +31 -0
- package/lib/chat/tools/ToolApprovalBanner.js +62 -0
- package/lib/{components/chat/components/elements → chat/tools}/ToolApprovalDialog.js +1 -1
- package/lib/{components/chat/components/display → chat/tools}/ToolCallDisplay.d.ts +13 -4
- package/lib/{components/chat/components/display → chat/tools}/ToolCallDisplay.js +18 -8
- package/lib/chat/tools/index.d.ts +8 -0
- package/lib/{components/chat/components/display → chat/tools}/index.js +3 -1
- package/lib/chat/usage/TokenUsageBar.d.ts +8 -0
- package/lib/chat/usage/TokenUsageBar.js +213 -0
- package/lib/client/AgentsMixin.d.ts +216 -0
- package/lib/client/AgentsMixin.js +388 -0
- package/lib/client/index.d.ts +6 -0
- package/lib/client/index.js +10 -0
- package/lib/components/NotificationEventCard.d.ts +8 -0
- package/lib/components/NotificationEventCard.js +177 -0
- package/lib/components/OutputCard.d.ts +8 -0
- package/lib/components/OutputCard.js +94 -0
- package/lib/components/ToolApprovalCard.d.ts +33 -0
- package/lib/components/ToolApprovalCard.js +78 -0
- package/lib/components/index.d.ts +3 -7
- package/lib/components/index.js +3 -4
- package/lib/{components → config}/AgentConfiguration.d.ts +43 -21
- package/lib/{components → config}/AgentConfiguration.js +48 -28
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.js +1 -0
- package/lib/{components/chat/components → context}/ContextInspector.js +38 -8
- package/lib/{components/chat/components → context}/ContextPanel.js +27 -6
- package/lib/context/CostTracker.d.ts +37 -0
- package/lib/context/CostTracker.js +124 -0
- package/lib/context/TokenUsageChart.d.ts +10 -0
- package/lib/context/TokenUsageChart.js +288 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +20 -0
- package/lib/examples/A2UiComponentGalleryExample.js +568 -0
- package/lib/examples/A2UiContactCardExample.d.ts +21 -0
- package/lib/examples/A2UiContactCardExample.js +432 -0
- package/lib/examples/A2UiRestaurantExample.d.ts +11 -3
- package/lib/examples/A2UiRestaurantExample.js +63 -98
- package/lib/examples/A2UiViewerExample.d.ts +21 -0
- package/lib/examples/A2UiViewerExample.js +563 -0
- package/lib/examples/AgUiAgenticExample.js +3 -3
- package/lib/examples/AgUiBackendToolRenderingExample.js +3 -3
- package/lib/examples/{AgUiHaikuGenUIExample.d.ts → AgUiHaikuGenUiExample.d.ts} +4 -4
- package/lib/examples/{AgUiHaikuGenUIExample.js → AgUiHaikuGenUiExample.js} +7 -7
- package/lib/examples/AgUiHumanInTheLoopExample.js +3 -3
- package/lib/examples/AgUiSharedStateExample.js +3 -3
- package/lib/examples/{AgUiToolsBasedGenUIExample.d.ts → AgUiToolsBasedGenUiExample.d.ts} +4 -4
- package/lib/examples/{AgUiToolsBasedGenUIExample.js → AgUiToolsBasedGenUiExample.js} +7 -7
- package/lib/examples/AgentCheckpointsExample.d.ts +19 -0
- package/lib/examples/AgentCheckpointsExample.js +500 -0
- package/lib/examples/AgentCodemodeExample.d.ts +14 -0
- package/lib/examples/AgentCodemodeExample.js +256 -0
- package/lib/examples/AgentEvalsExample.d.ts +14 -0
- package/lib/examples/AgentEvalsExample.js +210 -0
- package/lib/examples/AgentGuardrailsExample.d.ts +14 -0
- package/lib/examples/AgentGuardrailsExample.js +212 -0
- package/lib/examples/AgentMemoryExample.d.ts +14 -0
- package/lib/examples/AgentMemoryExample.js +228 -0
- package/lib/examples/AgentMonitoringExample.d.ts +13 -0
- package/lib/examples/AgentMonitoringExample.js +305 -0
- package/lib/examples/AgentNotificationsExample.d.ts +14 -0
- package/lib/examples/AgentNotificationsExample.js +267 -0
- package/lib/examples/AgentOtelExample.d.ts +25 -0
- package/lib/examples/AgentOtelExample.js +281 -0
- package/lib/examples/AgentOutputsExample.d.ts +14 -0
- package/lib/examples/AgentOutputsExample.js +205 -0
- package/lib/examples/AgentSandboxExample.d.ts +17 -0
- package/lib/examples/AgentSandboxExample.js +490 -0
- package/lib/examples/AgentSkillsExample.d.ts +3 -0
- package/lib/examples/AgentSkillsExample.js +284 -0
- package/lib/examples/AgentToolApprovalsExample.d.ts +3 -0
- package/lib/examples/AgentToolApprovalsExample.js +737 -0
- package/lib/examples/AgentTriggersExample.d.ts +14 -0
- package/lib/examples/AgentTriggersExample.js +1090 -0
- package/lib/examples/{AgentRuntimeFormExample.d.ts → AgentspecExample.d.ts} +3 -4
- package/lib/examples/{AgentRuntimeFormExample.js → AgentspecExample.js} +92 -34
- package/lib/examples/{JupyterCellExample.js → CellSimpleExample.js} +1 -1
- package/lib/examples/{AgentRuntimeCustomExample.js → ChatCustomExample.js} +3 -3
- package/lib/examples/{AgentRuntimeChatExample.js → ChatExample.js} +6 -14
- package/lib/examples/{AgentRuntimeStandaloneExample.js → ChatStandaloneExample.js} +2 -2
- package/lib/examples/CopilotKitLexicalExample.d.ts +3 -14
- package/lib/examples/CopilotKitLexicalExample.js +4 -15
- package/lib/examples/CopilotKitNotebookExample.js +4 -6
- package/lib/examples/DatalayerNotebookExample.js +2 -2
- package/lib/examples/{AgentRuntimeLexical2Example.d.ts → Lexical2Example.d.ts} +2 -13
- package/lib/examples/{AgentRuntimeLexical2Example.js → Lexical2Example.js} +8 -17
- package/lib/examples/{AgentRuntimeLexicalExample.d.ts → LexicalExample.d.ts} +1 -12
- package/lib/examples/{AgentRuntimeLexicalExample.js → LexicalExample.js} +28 -27
- package/lib/examples/{AgentRuntimeLexicalSidebarExample.d.ts → LexicalSidebarExample.d.ts} +2 -13
- package/lib/examples/{AgentRuntimeLexicalSidebarExample.js → LexicalSidebarExample.js} +6 -18
- package/lib/examples/{AgentRuntimeNotebookExample.js → NotebookExample.js} +14 -10
- package/lib/examples/{AgentRuntimeNotebookSidebarExample.js → NotebookSidebarExample.js} +5 -8
- package/lib/examples/{JupyterNotebookExample.js → NotebookSimpleExample.js} +2 -2
- package/lib/examples/ag-ui/weather/InlineWeatherCard.js +1 -1
- package/lib/examples/components/ErrorView.d.ts +14 -0
- package/lib/examples/components/ErrorView.js +20 -0
- package/lib/examples/components/ExampleWrapper.d.ts +12 -0
- package/lib/examples/components/ExampleWrapper.js +16 -0
- package/lib/examples/components/Header.d.ts +2 -2
- package/lib/examples/components/HeaderControls.js +1 -1
- package/lib/examples/components/LexicalEditor.d.ts +1 -12
- package/lib/examples/components/LexicalEditor.js +1 -12
- package/lib/examples/components/MainContent.d.ts +4 -11
- package/lib/examples/components/MainContent.js +6 -60
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +2 -0
- package/lib/examples/example-selector.d.ts +1 -1
- package/lib/examples/example-selector.js +35 -22
- package/lib/examples/index.d.ts +26 -13
- package/lib/examples/index.js +26 -12
- package/lib/examples/main.d.ts +7 -0
- package/lib/examples/main.js +21 -43
- package/lib/examples/utils/examplesStore.d.ts +4 -0
- package/lib/examples/{stores → utils}/examplesStore.js +1 -1
- package/lib/examples/utils/notebooks/Empty.ipynb.json +33 -0
- package/lib/examples/utils/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/utils/themeStore.d.ts +8 -0
- package/lib/examples/utils/themeStore.js +14 -0
- package/lib/extensions/A2UIExtension.d.ts +65 -0
- package/lib/extensions/A2UIExtension.js +202 -0
- package/lib/{components/chat/extensions → extensions}/ExtensionRegistry.d.ts +2 -3
- package/lib/{components/chat/extensions → extensions}/ExtensionRegistry.js +0 -2
- package/lib/{components/chat/extensions → extensions}/MCPUIExtension.d.ts +2 -2
- package/lib/{components/chat/extensions → extensions}/MCPUIExtension.js +1 -1
- package/lib/extensions/index.d.ts +9 -0
- package/lib/{components/chat/extensions → extensions}/index.js +2 -2
- package/lib/hooks/index.d.ts +33 -16
- package/lib/hooks/index.js +33 -16
- package/lib/hooks/useAIAgentsWebSocket.d.ts +29 -0
- package/lib/hooks/useAIAgentsWebSocket.js +136 -0
- package/lib/hooks/{useAGUI.d.ts → useAgUi.d.ts} +2 -2
- package/lib/hooks/{useAGUI.js → useAgUi.js} +2 -2
- package/lib/hooks/useAgents.d.ts +150 -11
- package/lib/hooks/useAgents.js +623 -61
- package/lib/hooks/{useAgentStore.d.ts → useAgentsCatalog.d.ts} +3 -8
- package/lib/hooks/{useAgentStore.js → useAgentsCatalog.js} +9 -3
- package/lib/hooks/useAgentsRegistry.d.ts +10 -0
- package/lib/hooks/useAgentsRegistry.js +20 -0
- package/lib/hooks/useAgentsService.d.ts +22 -0
- package/lib/hooks/useAgentsService.js +146 -0
- package/lib/hooks/useChat.d.ts +2 -2
- package/lib/hooks/useChat.js +14 -8
- package/lib/hooks/useCheckpoints.d.ts +176 -0
- package/lib/hooks/useCheckpoints.js +466 -0
- package/lib/hooks/useConfig.d.ts +11 -0
- package/lib/hooks/useConfig.js +46 -0
- package/lib/hooks/useContextSnapshot.d.ts +11 -0
- package/lib/hooks/useContextSnapshot.js +44 -0
- package/lib/hooks/useMonitoring.d.ts +24 -0
- package/lib/hooks/useMonitoring.js +111 -0
- package/lib/hooks/useNotifications.d.ts +67 -0
- package/lib/hooks/useNotifications.js +208 -0
- package/lib/hooks/useSandbox.d.ts +12 -0
- package/lib/hooks/useSandbox.js +49 -0
- package/lib/hooks/useSkills.d.ts +13 -0
- package/lib/hooks/useSkills.js +46 -0
- package/lib/hooks/useToolApprovals.d.ts +45 -0
- package/lib/hooks/useToolApprovals.js +126 -0
- package/lib/hooks/useTools.d.ts +4 -4
- package/lib/hooks/useTools.js +2 -2
- package/lib/hooks/{useVercelChat.d.ts → useVercelAI.d.ts} +3 -3
- package/lib/hooks/{useVercelChat.js → useVercelAI.js} +2 -2
- package/lib/{components/chat/components → identity}/AgentIdentity.d.ts +1 -1
- package/lib/{components/chat/components → identity}/AgentIdentity.js +4 -3
- package/lib/identity/index.d.ts +1 -0
- package/lib/identity/index.js +2 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +3 -2
- package/lib/{components/chat/inference → inference}/BaseInferenceProvider.d.ts +3 -3
- package/lib/{components/chat/inference → inference}/DatalayerInferenceProvider.d.ts +3 -3
- package/lib/{components/chat/inference → inference}/DatalayerInferenceProvider.js +1 -1
- package/lib/{components/chat/inference → inference}/SelfHostedInferenceProvider.d.ts +2 -2
- package/lib/{components/chat/inference → inference}/SelfHostedInferenceProvider.js +1 -1
- package/lib/{components/chat/inference → inference}/index.d.ts +1 -1
- package/lib/{components/chat/inference → inference}/index.js +1 -1
- package/lib/lexical/ChatInlinePlugin.d.ts +1 -1
- package/lib/lexical/ChatInlinePlugin.js +1 -1
- package/lib/{components → mcp}/McpServerManager.d.ts +1 -2
- package/lib/mcp/index.d.ts +1 -0
- package/lib/{specs/agents/codeai → mcp}/index.js +1 -1
- package/lib/{components/chat/middleware → middleware}/MiddlewarePipeline.d.ts +3 -3
- package/lib/{components/chat/middleware → middleware}/index.d.ts +1 -1
- package/lib/{components/chat/middleware → middleware}/index.js +1 -1
- package/lib/{components/chat/protocols → protocols}/A2AAdapter.d.ts +6 -6
- package/lib/{components/chat/protocols → protocols}/A2AAdapter.js +3 -3
- package/lib/{components/chat/protocols → protocols}/ACPAdapter.d.ts +6 -6
- package/lib/{components/chat/protocols → protocols}/ACPAdapter.js +4 -4
- package/lib/{components/chat/protocols → protocols}/AGUIAdapter.d.ts +14 -6
- package/lib/{components/chat/protocols → protocols}/AGUIAdapter.js +72 -10
- package/lib/{components/chat/protocols → protocols}/BaseProtocolAdapter.d.ts +6 -6
- package/lib/{components/chat/protocols → protocols}/BaseProtocolAdapter.js +1 -1
- package/lib/{components/chat/protocols → protocols}/VercelAIAdapter.d.ts +33 -7
- package/lib/protocols/VercelAIAdapter.js +748 -0
- package/lib/{components/chat/protocols → protocols}/index.d.ts +1 -2
- package/lib/{components/chat/protocols → protocols}/index.js +1 -1
- package/lib/shims/json5.d.ts +4 -0
- package/lib/shims/json5.js +8 -0
- package/lib/specs/agents/agents.d.ts +54 -0
- package/lib/specs/agents/agents.js +1489 -0
- package/lib/specs/agents/index.js +15 -12
- package/lib/specs/envvars.d.ts +11 -19
- package/lib/specs/envvars.js +52 -38
- package/lib/specs/evals.d.ts +20 -0
- package/lib/specs/evals.js +133 -0
- package/lib/specs/events.d.ts +26 -0
- package/lib/specs/events.js +140 -0
- package/lib/specs/frontendTools.d.ts +14 -0
- package/lib/specs/frontendTools.js +53 -0
- package/lib/specs/guardrails.d.ts +29 -0
- package/lib/specs/guardrails.js +310 -0
- package/lib/specs/index.d.ts +15 -2
- package/lib/specs/index.js +15 -2
- package/lib/specs/mcpServers.d.ts +13 -11
- package/lib/specs/mcpServers.js +75 -50
- package/lib/specs/memory.d.ts +36 -0
- package/lib/specs/memory.js +112 -0
- package/lib/specs/models.d.ts +21 -34
- package/lib/specs/models.js +66 -66
- package/lib/specs/notifications.d.ts +17 -0
- package/lib/specs/notifications.js +103 -0
- package/lib/specs/outputs.d.ts +19 -0
- package/lib/specs/outputs.js +106 -0
- package/lib/specs/skills.d.ts +7 -16
- package/lib/specs/skills.js +95 -18
- package/lib/specs/teams/index.d.ts +17 -0
- package/lib/specs/teams/index.js +35 -0
- package/lib/specs/teams/teams.d.ts +27 -0
- package/lib/specs/teams/teams.js +1000 -0
- package/lib/specs/tools.d.ts +15 -0
- package/lib/specs/tools.js +86 -0
- package/lib/specs/triggers.d.ts +15 -0
- package/lib/specs/triggers.js +67 -0
- package/lib/stores/agentsStore.d.ts +123 -0
- package/lib/stores/agentsStore.js +270 -0
- package/lib/{components/chat/store → stores}/chatStore.d.ts +3 -2
- package/lib/{components/chat/store → stores}/chatStore.js +2 -2
- package/lib/{components/chat/store → stores}/conversationStore.d.ts +1 -1
- package/lib/{components/chat/store → stores}/conversationStore.js +1 -1
- package/lib/{components/chat/store → stores}/index.d.ts +3 -2
- package/lib/{components/chat/store → stores}/index.js +3 -2
- package/lib/{components/chat/tools → tools}/ToolExecutor.d.ts +2 -2
- package/lib/{components/chat/tools → tools}/ToolExecutor.js +1 -1
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +1 -1
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +14 -10
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +31 -21
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +1 -1
- package/lib/tools/index.d.ts +3 -0
- package/lib/tools/index.js +3 -7
- package/lib/types/a2a.d.ts +39 -0
- package/lib/types/acp.d.ts +21 -0
- package/lib/types/ag-ui.d.ts +25 -0
- package/lib/types/agents-lifecycle.d.ts +36 -0
- package/lib/types/agents.d.ts +80 -0
- package/lib/types/agents.js +22 -0
- package/lib/types/agentspecs.d.ts +90 -0
- package/lib/{components/chat/components/base/ChatBase.d.ts → types/chat.d.ts} +59 -99
- package/lib/types/checkpoints.d.ts +32 -0
- package/lib/types/checkpoints.js +5 -0
- package/lib/types/config.d.ts +67 -0
- package/lib/{runtime/types.js → types/config.js} +2 -2
- package/lib/types/connection.d.ts +31 -0
- package/lib/types/connection.js +5 -0
- package/lib/types/context.d.ts +67 -0
- package/lib/types/context.js +5 -0
- package/lib/types/cost.d.ts +42 -0
- package/lib/types/cost.js +5 -0
- package/lib/types/envvars.d.ts +21 -0
- package/lib/types/envvars.js +5 -0
- package/lib/types/evals.d.ts +66 -0
- package/lib/types/evals.js +5 -0
- package/lib/types/events.d.ts +49 -0
- package/lib/types/events.js +5 -0
- package/lib/types/eventspecs.d.ts +39 -0
- package/lib/types/eventspecs.js +5 -0
- package/lib/types/examples.d.ts +31 -0
- package/lib/types/examples.js +5 -0
- package/lib/{components/chat/types → types}/execution.d.ts +10 -1
- package/lib/{components/chat/types/extension.d.ts → types/extensions.d.ts} +3 -3
- package/lib/types/guardrails.d.ts +106 -0
- package/lib/types/guardrails.js +5 -0
- package/lib/types/index.d.ts +36 -2
- package/lib/types/index.js +35 -2
- package/lib/{components/chat/types → types}/inference.d.ts +3 -3
- package/lib/types/inference.js +5 -0
- package/lib/types/mcp.d.ts +117 -0
- package/lib/types/mcp.js +27 -0
- package/lib/types/memory.d.ts +23 -0
- package/lib/types/memory.js +5 -0
- package/lib/{components/chat/types/message.d.ts → types/messages.d.ts} +20 -1
- package/lib/{components/chat/types → types}/middleware.d.ts +3 -3
- package/lib/types/models.d.ts +63 -0
- package/lib/types/models.js +5 -0
- package/lib/types/notifications.d.ts +85 -0
- package/lib/types/notifications.js +5 -0
- package/lib/types/outputs.d.ts +51 -0
- package/lib/types/outputs.js +5 -0
- package/lib/{components/chat/types → types}/protocol.d.ts +37 -99
- package/lib/types/protocol.js +5 -0
- package/lib/types/sandbox.d.ts +27 -0
- package/lib/types/sandbox.js +24 -0
- package/lib/types/skills.d.ts +74 -0
- package/lib/types/skills.js +5 -0
- package/lib/types/teams.d.ts +133 -0
- package/lib/types/teams.js +5 -0
- package/lib/types/tool-approvals.d.ts +39 -0
- package/lib/types/tool-approvals.js +5 -0
- package/lib/{components/chat/types/tool.d.ts → types/tools.d.ts} +61 -4
- package/lib/types/triggers.d.ts +48 -0
- package/lib/types/triggers.js +5 -0
- package/lib/types/usage.d.ts +36 -0
- package/lib/types/usage.js +5 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/utils.d.ts +60 -0
- package/lib/utils/utils.js +205 -0
- package/package.json +13 -14
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +377 -61
- package/scripts/codegen/generate_envvars.py +36 -35
- package/scripts/codegen/generate_evals.py +279 -0
- package/scripts/codegen/generate_events.py +320 -0
- package/scripts/codegen/generate_frontend_tools.py +266 -0
- package/scripts/codegen/generate_guardrails.py +475 -0
- package/scripts/codegen/generate_mcp_servers.py +36 -9
- package/scripts/codegen/generate_memory.py +468 -0
- package/scripts/codegen/generate_models.py +22 -46
- package/scripts/codegen/generate_notifications.py +309 -0
- package/scripts/codegen/generate_outputs.py +267 -0
- package/scripts/codegen/generate_skills.py +108 -51
- package/scripts/codegen/generate_teams.py +922 -0
- package/scripts/codegen/generate_tools.py +346 -0
- package/scripts/codegen/generate_triggers.py +295 -0
- package/scripts/codegen/versioning.py +53 -0
- package/style/primer-primitives.css +1 -6
- package/lib/components/chat/components/base/ChatBase.js +0 -2242
- package/lib/components/chat/components/base/InputPrompt.d.ts +0 -42
- package/lib/components/chat/components/base/InputPrompt.js +0 -131
- package/lib/components/chat/components/display/index.d.ts +0 -6
- package/lib/components/chat/components/index.d.ts +0 -26
- package/lib/components/chat/components/index.js +0 -39
- package/lib/components/chat/extensions/A2UIExtension.d.ts +0 -87
- package/lib/components/chat/extensions/A2UIExtension.js +0 -312
- package/lib/components/chat/extensions/index.d.ts +0 -10
- package/lib/components/chat/index.d.ts +0 -61
- package/lib/components/chat/index.js +0 -76
- package/lib/components/chat/protocols/VercelAIAdapter.js +0 -315
- package/lib/components/chat/tools/index.d.ts +0 -8
- package/lib/components/chat/tools/index.js +0 -11
- package/lib/components/chat/types/index.d.ts +0 -12
- package/lib/components/chat/types/index.js +0 -17
- package/lib/components/sparklines/Sparklines.d.ts +0 -16
- package/lib/components/sparklines/Sparklines.js +0 -65
- package/lib/components/sparklines/SparklinesLine.d.ts +0 -8
- package/lib/components/sparklines/SparklinesLine.js +0 -37
- package/lib/components/sparklines/dataProcessing.d.ts +0 -25
- package/lib/components/sparklines/dataProcessing.js +0 -35
- package/lib/components/sparklines/index.d.ts +0 -4
- package/lib/components/sparklines/index.js +0 -7
- package/lib/components/sparklines/types.d.ts +0 -36
- package/lib/examples/stores/examplesStore.d.ts +0 -5
- package/lib/examples/stores/notebooks/Empty.ipynb.json +0 -33
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +0 -48
- package/lib/examples/stores/themeStore.d.ts +0 -33
- package/lib/examples/stores/themeStore.js +0 -38
- package/lib/hooks/useAgentRuntimes.d.ts +0 -350
- package/lib/hooks/useAgentRuntimes.js +0 -78
- package/lib/hooks/useKeyboardShortcuts.d.ts +0 -47
- package/lib/hooks/useKeyboardShortcuts.js +0 -153
- package/lib/hooks/useMobile.d.ts +0 -1
- package/lib/hooks/useMobile.js +0 -19
- package/lib/hooks/useNotebookAIAgent.d.ts +0 -8
- package/lib/hooks/useNotebookAIAgent.js +0 -73
- package/lib/renderers/a2ui/components/A2UIRenderer.d.ts +0 -7
- package/lib/renderers/a2ui/components/A2UIRenderer.js +0 -102
- package/lib/renderers/a2ui/components/SurfaceRenderer.d.ts +0 -7
- package/lib/renderers/a2ui/components/SurfaceRenderer.js +0 -101
- package/lib/renderers/a2ui/components/content/AudioPlayer.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/AudioPlayer.js +0 -38
- package/lib/renderers/a2ui/components/content/Divider.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/Divider.js +0 -35
- package/lib/renderers/a2ui/components/content/Icon.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/Icon.js +0 -110
- package/lib/renderers/a2ui/components/content/Image.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/Image.js +0 -61
- package/lib/renderers/a2ui/components/content/Text.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/Text.js +0 -64
- package/lib/renderers/a2ui/components/content/Video.d.ts +0 -9
- package/lib/renderers/a2ui/components/content/Video.js +0 -37
- package/lib/renderers/a2ui/components/content/index.d.ts +0 -6
- package/lib/renderers/a2ui/components/content/index.js +0 -25
- package/lib/renderers/a2ui/components/index.d.ts +0 -5
- package/lib/renderers/a2ui/components/index.js +0 -24
- package/lib/renderers/a2ui/components/interactive/Button.d.ts +0 -11
- package/lib/renderers/a2ui/components/interactive/Button.js +0 -71
- package/lib/renderers/a2ui/components/interactive/CheckBox.d.ts +0 -9
- package/lib/renderers/a2ui/components/interactive/CheckBox.js +0 -48
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.d.ts +0 -9
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.js +0 -62
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.d.ts +0 -9
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.js +0 -73
- package/lib/renderers/a2ui/components/interactive/Slider.d.ts +0 -9
- package/lib/renderers/a2ui/components/interactive/Slider.js +0 -53
- package/lib/renderers/a2ui/components/interactive/TextField.d.ts +0 -9
- package/lib/renderers/a2ui/components/interactive/TextField.js +0 -72
- package/lib/renderers/a2ui/components/interactive/index.d.ts +0 -6
- package/lib/renderers/a2ui/components/interactive/index.js +0 -25
- package/lib/renderers/a2ui/components/layout/Card.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/Card.js +0 -30
- package/lib/renderers/a2ui/components/layout/Column.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/Column.js +0 -65
- package/lib/renderers/a2ui/components/layout/List.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/List.js +0 -55
- package/lib/renderers/a2ui/components/layout/Modal.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/Modal.js +0 -58
- package/lib/renderers/a2ui/components/layout/Row.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/Row.js +0 -65
- package/lib/renderers/a2ui/components/layout/Tabs.d.ts +0 -11
- package/lib/renderers/a2ui/components/layout/Tabs.js +0 -48
- package/lib/renderers/a2ui/components/layout/index.d.ts +0 -6
- package/lib/renderers/a2ui/components/layout/index.js +0 -25
- package/lib/renderers/a2ui/context/A2UIContext.d.ts +0 -17
- package/lib/renderers/a2ui/context/A2UIContext.js +0 -54
- package/lib/renderers/a2ui/context/ThemeContext.d.ts +0 -20
- package/lib/renderers/a2ui/context/ThemeContext.js +0 -333
- package/lib/renderers/a2ui/hooks/useA2UI.d.ts +0 -36
- package/lib/renderers/a2ui/hooks/useA2UI.js +0 -62
- package/lib/renderers/a2ui/hooks/useDataBinding.d.ts +0 -8
- package/lib/renderers/a2ui/hooks/useDataBinding.js +0 -83
- package/lib/renderers/a2ui/index.d.ts +0 -9
- package/lib/renderers/a2ui/index.js +0 -28
- package/lib/renderers/a2ui/lib/utils.d.ts +0 -11
- package/lib/renderers/a2ui/lib/utils.js +0 -38
- package/lib/renderers/a2ui/types/index.d.ts +0 -17
- package/lib/runtime/index.d.ts +0 -38
- package/lib/runtime/index.js +0 -40
- package/lib/runtime/runtimeStore.d.ts +0 -76
- package/lib/runtime/runtimeStore.js +0 -184
- package/lib/runtime/types.d.ts +0 -84
- package/lib/runtime/useAgentConnection.d.ts +0 -45
- package/lib/runtime/useAgentConnection.js +0 -112
- package/lib/runtime/useAgentRuntime.d.ts +0 -93
- package/lib/runtime/useAgentRuntime.js +0 -125
- package/lib/specs/agents/codeai/agents.d.ts +0 -28
- package/lib/specs/agents/codeai/agents.js +0 -179
- package/lib/specs/agents/codeai/index.d.ts +0 -1
- package/lib/specs/agents/codemode-paper/agents.d.ts +0 -31
- package/lib/specs/agents/codemode-paper/agents.js +0 -378
- package/lib/specs/agents/codemode-paper/index.d.ts +0 -1
- package/lib/specs/agents/codemode-paper/index.js +0 -5
- package/lib/specs/agents/datalayer-ai/agents.d.ts +0 -31
- package/lib/specs/agents/datalayer-ai/agents.js +0 -352
- package/lib/specs/agents/datalayer-ai/index.d.ts +0 -1
- package/lib/specs/agents/datalayer-ai/index.js +0 -5
- package/lib/specs/agents/mocks/agents.d.ts +0 -43
- package/lib/specs/agents/mocks/agents.js +0 -2293
- package/lib/specs/agents/mocks/index.d.ts +0 -1
- package/lib/specs/agents/mocks/index.js +0 -5
- package/lib/state/index.d.ts +0 -1
- package/lib/state/index.js +0 -5
- package/lib/state/substates/AIAgentState.d.ts +0 -80
- package/lib/state/substates/AIAgentState.js +0 -108
- package/lib/state/substates/index.d.ts +0 -1
- package/lib/state/substates/index.js +0 -5
- package/lib/types/AIAgent.d.ts +0 -17
- package/lib/types/Types.d.ts +0 -217
- /package/lib/{components/chat → api}/handler.d.ts +0 -0
- /package/lib/{renderers/index.d.ts → api/utils.d.ts} +0 -0
- /package/lib/{renderers/index.js → api/utils.js} +0 -0
- /package/lib/{components/chat/components/elements → chat/display}/PoweredByTag.js +0 -0
- /package/lib/{components/chat/components → chat}/parts/DynamicToolPart.js +0 -0
- /package/lib/{components/chat/components → chat}/parts/ReasoningPart.d.ts +0 -0
- /package/lib/{components/chat/components → chat}/parts/TextPart.js +0 -0
- /package/lib/{components/chat/components → chat}/parts/ToolPart.d.ts +0 -0
- /package/lib/{components/chat/components → chat}/styles/streamdownStyles.js +0 -0
- /package/lib/{components/chat/components/elements → chat/tools}/ToolApprovalDialog.d.ts +0 -0
- /package/lib/{components/chat/components → context}/ContextDistribution.d.ts +0 -0
- /package/lib/{components/chat/components → context}/ContextDistribution.js +0 -0
- /package/lib/{components/chat/components → context}/ContextInspector.d.ts +0 -0
- /package/lib/{components/chat/components → context}/ContextPanel.d.ts +0 -0
- /package/lib/{components/chat/components → context}/ContextUsage.d.ts +0 -0
- /package/lib/{components/chat/components → context}/ContextUsage.js +0 -0
- /package/lib/examples/{JupyterCellExample.d.ts → CellSimpleExample.d.ts} +0 -0
- /package/lib/examples/{AgentRuntimeCustomExample.d.ts → ChatCustomExample.d.ts} +0 -0
- /package/lib/examples/{AgentRuntimeChatExample.d.ts → ChatExample.d.ts} +0 -0
- /package/lib/examples/{AgentRuntimeStandaloneExample.d.ts → ChatStandaloneExample.d.ts} +0 -0
- /package/lib/examples/{AgentRuntimeNotebookExample.d.ts → NotebookExample.d.ts} +0 -0
- /package/lib/examples/{AgentRuntimeNotebookSidebarExample.d.ts → NotebookSidebarExample.d.ts} +0 -0
- /package/lib/examples/{JupyterNotebookExample.d.ts → NotebookSimpleExample.d.ts} +0 -0
- /package/lib/examples/{stores → utils}/agents/earthquake-detector.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/agents/earthquake-detector.json +0 -0
- /package/lib/examples/{stores → utils}/agents/earthquake-detector.lexical.json +0 -0
- /package/lib/examples/{stores → utils}/agents/sales-forecaster.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/agents/sales-forecaster.json +0 -0
- /package/lib/examples/{stores → utils}/agents/sales-forecaster.lexical.json +0 -0
- /package/lib/examples/{stores → utils}/agents/social-post-generator.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/agents/social-post-generator.json +0 -0
- /package/lib/examples/{stores → utils}/agents/social-post-generator.lexical.json +0 -0
- /package/lib/examples/{stores → utils}/agents/stock-market.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/agents/stock-market.json +0 -0
- /package/lib/examples/{stores → utils}/agents/stock-market.lexical.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/IPyWidgetsExample.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/IPyWidgetsExampleWithState.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/Lite.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/Matplotlib.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/NotebookExample1.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/NotebookOutputs.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/NotebookToCExample.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/notebooks/OutputIPyWidgetsExample.d.ts +0 -0
- /package/lib/examples/{stores → utils}/notebooks/OutputIPyWidgetsExample.js +0 -0
- /package/lib/examples/{stores → utils}/notebooks/PyGWalker.ipynb.json +0 -0
- /package/lib/examples/{stores → utils}/themedProvider.d.ts +0 -0
- /package/lib/examples/{stores → utils}/themedProvider.js +0 -0
- /package/lib/{components/chat/inference → inference}/BaseInferenceProvider.js +0 -0
- /package/lib/{components → mcp}/McpServerManager.js +0 -0
- /package/lib/{components/chat/middleware → middleware}/MiddlewarePipeline.js +0 -0
- /package/lib/{components/chat/types/inference.js → types/a2a.js} +0 -0
- /package/lib/{components/chat/types/protocol.js → types/acp.js} +0 -0
- /package/lib/{components/sparklines/types.js → types/ag-ui.js} +0 -0
- /package/lib/{renderers/a2ui/types/index.js → types/agents-lifecycle.js} +0 -0
- /package/lib/types/{AIAgent.js → agentspecs.js} +0 -0
- /package/lib/types/{Types.js → chat.js} +0 -0
- /package/lib/{components/chat/types → types}/execution.js +0 -0
- /package/lib/{components/chat/types/extension.js → types/extensions.js} +0 -0
- /package/lib/{components/chat/types/message.js → types/messages.js} +0 -0
- /package/lib/{components/chat/types → types}/middleware.js +0 -0
- /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()
|