@datalayer/agent-runtimes 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -1
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/App.js +1 -1
- package/lib/agent-node/themeStore.d.ts +3 -0
- package/lib/agent-node/themeStore.js +156 -0
- package/lib/agent-node-main.d.ts +1 -0
- package/lib/agent-node-main.js +14 -0
- package/lib/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -106
- package/lib/chat/Chat.js +20 -14
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +3 -3
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +83 -51
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1414 -174
- package/lib/chat/display/FloatingBrandButton.js +8 -1
- package/lib/chat/header/ChatHeader.d.ts +3 -1
- package/lib/chat/header/ChatHeader.js +15 -12
- package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
- package/lib/chat/header/ChatHeaderBase.js +41 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +91 -56
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +154 -114
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +21 -6
- package/lib/chat/prompt/InputFooter.js +76 -20
- package/lib/chat/prompt/InputPrompt.d.ts +5 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +0 -18
- package/lib/client/AgentsMixin.js +20 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +5 -1
- package/lib/config/AgentConfiguration.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -28
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +603 -169
- package/lib/examples/AgentEvalsExample.js +339 -53
- package/lib/examples/AgentGuardrailsExample.js +383 -66
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +122 -0
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +481 -0
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +78 -33
- package/lib/examples/AgentMonitoringExample.js +261 -200
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +114 -33
- package/lib/examples/AgentOtelExample.js +32 -42
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +433 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +248 -0
- package/lib/examples/AgentSandboxExample.d.ts +3 -3
- package/lib/examples/AgentSandboxExample.js +74 -45
- package/lib/examples/AgentSkillsExample.js +95 -103
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +49 -561
- package/lib/examples/AgentTriggersExample.js +823 -569
- package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +16 -28
- package/lib/examples/ChatExample.js +13 -29
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +66 -17
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ExampleWrapper.d.ts +9 -3
- package/lib/examples/components/ExampleWrapper.js +45 -9
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +4 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +108 -41
- package/lib/examples/index.d.ts +10 -6
- package/lib/examples/index.js +10 -6
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +257 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +153 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +70 -4
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +21 -4
- package/lib/specs/agents/agents.js +2879 -316
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.js +27 -20
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +20 -15
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +1 -1
- package/lib/specs/skills.js +23 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +208 -0
- package/lib/stores/agentRuntimeStore.js +650 -0
- package/lib/stores/conversationStore.js +2 -2
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +54 -1
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +325 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +19 -11
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +187 -45
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +35 -14
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/AgentspecExample.js +0 -705
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
|
@@ -11,6 +11,7 @@ Generates Python and TypeScript code from YAML agent specifications.
|
|
|
11
11
|
import argparse
|
|
12
12
|
import json
|
|
13
13
|
import sys
|
|
14
|
+
from copy import deepcopy
|
|
14
15
|
from pathlib import Path
|
|
15
16
|
from typing import Any, Dict, List
|
|
16
17
|
|
|
@@ -27,7 +28,7 @@ def _fmt_list(items: list[str]) -> str:
|
|
|
27
28
|
"""Format a list of strings with double quotes for ruff compliance."""
|
|
28
29
|
if not items:
|
|
29
30
|
return "[]"
|
|
30
|
-
return "[" + ", ".join(
|
|
31
|
+
return "[" + ", ".join(_fmt_py_literal(item) for item in items) + "]"
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
def _fmt_py_literal(value: Any) -> str:
|
|
@@ -44,6 +45,68 @@ def _fmt_ts_literal(value: Any) -> str:
|
|
|
44
45
|
return json.dumps(value, ensure_ascii=False)
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
def _normalize_subagents_for_typescript(value: Any) -> Any:
|
|
49
|
+
"""Convert subagents config keys from YAML snake_case to TS camelCase."""
|
|
50
|
+
if not isinstance(value, dict):
|
|
51
|
+
return value
|
|
52
|
+
|
|
53
|
+
top_level_map = {
|
|
54
|
+
"default_model": "defaultModel",
|
|
55
|
+
"include_general_purpose": "includeGeneralPurpose",
|
|
56
|
+
"max_nesting_depth": "maxNestingDepth",
|
|
57
|
+
}
|
|
58
|
+
subagent_map = {
|
|
59
|
+
"can_ask_questions": "canAskQuestions",
|
|
60
|
+
"max_questions": "maxQuestions",
|
|
61
|
+
"preferred_mode": "preferredMode",
|
|
62
|
+
"typical_complexity": "typicalComplexity",
|
|
63
|
+
"typically_needs_context": "typicallyNeedsContext",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
normalized: dict[str, Any] = {}
|
|
67
|
+
for key, raw_val in value.items():
|
|
68
|
+
mapped_key = top_level_map.get(key, key)
|
|
69
|
+
if mapped_key == "subagents" and isinstance(raw_val, list):
|
|
70
|
+
normalized_subagents: list[Any] = []
|
|
71
|
+
for subagent in raw_val:
|
|
72
|
+
if isinstance(subagent, dict):
|
|
73
|
+
normalized_subagent: dict[str, Any] = {}
|
|
74
|
+
for sa_key, sa_val in subagent.items():
|
|
75
|
+
normalized_subagent[subagent_map.get(sa_key, sa_key)] = sa_val
|
|
76
|
+
normalized_subagents.append(normalized_subagent)
|
|
77
|
+
else:
|
|
78
|
+
normalized_subagents.append(subagent)
|
|
79
|
+
normalized[mapped_key] = normalized_subagents
|
|
80
|
+
else:
|
|
81
|
+
normalized[mapped_key] = raw_val
|
|
82
|
+
|
|
83
|
+
return normalized
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _sanitize_tool_hooks_for_codegen(value: Any) -> Any:
|
|
87
|
+
"""Normalize tool hook paths that would trigger bandit in generated code."""
|
|
88
|
+
if not isinstance(value, dict):
|
|
89
|
+
return value
|
|
90
|
+
|
|
91
|
+
tool_hooks = deepcopy(value)
|
|
92
|
+
for key in ("audit_log_path", "auditLogPath"):
|
|
93
|
+
raw_path = tool_hooks.get(key)
|
|
94
|
+
if isinstance(raw_path, str):
|
|
95
|
+
raw_parts = Path(raw_path).parts
|
|
96
|
+
if len(raw_parts) >= 3 and raw_parts[0] == "/" and raw_parts[1] == "tmp":
|
|
97
|
+
tool_hooks[key] = Path(raw_path).name
|
|
98
|
+
return tool_hooks
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _sanitize_spec_for_codegen(spec: Dict[str, Any]) -> Dict[str, Any]:
|
|
102
|
+
"""Return a spec copy sanitized for generated Python/TypeScript outputs."""
|
|
103
|
+
sanitized = deepcopy(spec)
|
|
104
|
+
sanitized["tool_hooks"] = _sanitize_tool_hooks_for_codegen(
|
|
105
|
+
sanitized.get("tool_hooks")
|
|
106
|
+
)
|
|
107
|
+
return sanitized
|
|
108
|
+
|
|
109
|
+
|
|
47
110
|
def load_yaml_specs(specs_dir: Path) -> List[tuple[str, Dict[str, Any]]]:
|
|
48
111
|
"""
|
|
49
112
|
Load all YAML agent specifications from directory and subdirectories.
|
|
@@ -91,7 +154,7 @@ Generated from YAML specifications in specs/agents/
|
|
|
91
154
|
from typing import Dict
|
|
92
155
|
|
|
93
156
|
from agent_runtimes.mcp.catalog_mcp_servers import MCP_SERVER_CATALOG
|
|
94
|
-
from agent_runtimes.types import AgentSpec
|
|
157
|
+
from agent_runtimes.types import AgentSpec, SubAgentSpecConfig, SubAgentsConfig
|
|
95
158
|
|
|
96
159
|
# ============================================================================
|
|
97
160
|
# Agent Specs
|
|
@@ -123,6 +186,7 @@ from agent_runtimes.types import AgentSpec
|
|
|
123
186
|
code += f"# {'=' * 76}\n\n"
|
|
124
187
|
|
|
125
188
|
for spec in folder_specs:
|
|
189
|
+
spec = _sanitize_spec_for_codegen(spec)
|
|
126
190
|
agent_id = spec["id"]
|
|
127
191
|
version = spec["version"]
|
|
128
192
|
# Prefix agent ID with folder name for uniqueness
|
|
@@ -166,7 +230,7 @@ from agent_runtimes.types import AgentSpec
|
|
|
166
230
|
suggestions = spec.get("suggestions", [])
|
|
167
231
|
suggestions_str = (
|
|
168
232
|
"[\n "
|
|
169
|
-
+ ",\n ".join(
|
|
233
|
+
+ ",\n ".join(_fmt_py_literal(s) for s in suggestions)
|
|
170
234
|
+ ",\n ]"
|
|
171
235
|
if suggestions
|
|
172
236
|
else "[]"
|
|
@@ -210,6 +274,10 @@ from agent_runtimes.types import AgentSpec
|
|
|
210
274
|
# Model field
|
|
211
275
|
model_id = spec.get("model")
|
|
212
276
|
model_str = f'"{model_id}"' if model_id else "None"
|
|
277
|
+
inference_provider = spec.get("inference_provider")
|
|
278
|
+
inference_provider_str = (
|
|
279
|
+
f'"{inference_provider}"' if inference_provider else "None"
|
|
280
|
+
)
|
|
213
281
|
|
|
214
282
|
# Sandbox variant field
|
|
215
283
|
sandbox_variant = spec.get("sandbox_variant")
|
|
@@ -217,11 +285,12 @@ from agent_runtimes.types import AgentSpec
|
|
|
217
285
|
|
|
218
286
|
# New flow-level fields
|
|
219
287
|
goal_raw = spec.get("goal")
|
|
220
|
-
|
|
221
|
-
|
|
288
|
+
goal_clean = (
|
|
289
|
+
goal_raw.replace(chr(10), " ").replace(" ", " ").strip()
|
|
222
290
|
if goal_raw
|
|
223
|
-
else
|
|
291
|
+
else None
|
|
224
292
|
)
|
|
293
|
+
goal_str = _fmt_py_literal(goal_clean)
|
|
225
294
|
protocol_val = spec.get("protocol")
|
|
226
295
|
protocol_str = f'"{protocol_val}"' if protocol_val else "None"
|
|
227
296
|
ui_ext = spec.get("ui_extension")
|
|
@@ -239,6 +308,49 @@ from agent_runtimes.types import AgentSpec
|
|
|
239
308
|
notifs = spec.get("notifications")
|
|
240
309
|
memory_val = spec.get("memory")
|
|
241
310
|
memory_str = f'"{memory_val}"' if memory_val else "None"
|
|
311
|
+
pre_hooks_val = spec.get("pre_hooks")
|
|
312
|
+
post_hooks_val = spec.get("post_hooks")
|
|
313
|
+
tool_hooks_val = spec.get("tool_hooks")
|
|
314
|
+
parameters_val = spec.get("parameters")
|
|
315
|
+
subagents_val = spec.get("subagents")
|
|
316
|
+
|
|
317
|
+
# Build subagents code if present
|
|
318
|
+
subagents_str = "None"
|
|
319
|
+
if isinstance(subagents_val, dict) and subagents_val.get("subagents"):
|
|
320
|
+
sa_items = []
|
|
321
|
+
for sa in subagents_val["subagents"]:
|
|
322
|
+
sa_fields = [
|
|
323
|
+
f"name={_fmt_py_literal(sa['name'])}",
|
|
324
|
+
f"description={_fmt_py_literal(sa['description'])}",
|
|
325
|
+
f"instructions={_fmt_py_literal(sa['instructions'])}",
|
|
326
|
+
]
|
|
327
|
+
for opt_key in (
|
|
328
|
+
"model",
|
|
329
|
+
"can_ask_questions",
|
|
330
|
+
"max_questions",
|
|
331
|
+
"preferred_mode",
|
|
332
|
+
"typical_complexity",
|
|
333
|
+
"typically_needs_context",
|
|
334
|
+
):
|
|
335
|
+
opt_val = sa.get(opt_key)
|
|
336
|
+
if opt_val is not None:
|
|
337
|
+
sa_fields.append(f"{opt_key}={_fmt_py_literal(opt_val)}")
|
|
338
|
+
sa_items.append("SubAgentSpecConfig(" + ", ".join(sa_fields) + ")")
|
|
339
|
+
sa_list_str = "[" + ", ".join(sa_items) + "]"
|
|
340
|
+
cfg_parts = [f"subagents={sa_list_str}"]
|
|
341
|
+
if subagents_val.get("default_model") is not None:
|
|
342
|
+
cfg_parts.append(
|
|
343
|
+
f"default_model={_fmt_py_literal(subagents_val['default_model'])}"
|
|
344
|
+
)
|
|
345
|
+
if subagents_val.get("include_general_purpose") is not None:
|
|
346
|
+
cfg_parts.append(
|
|
347
|
+
f"include_general_purpose={_fmt_py_literal(subagents_val['include_general_purpose'])}"
|
|
348
|
+
)
|
|
349
|
+
if subagents_val.get("max_nesting_depth") is not None:
|
|
350
|
+
cfg_parts.append(
|
|
351
|
+
f"max_nesting_depth={_fmt_py_literal(subagents_val['max_nesting_depth'])}"
|
|
352
|
+
)
|
|
353
|
+
subagents_str = "SubAgentsConfig(" + ", ".join(cfg_parts) + ")"
|
|
242
354
|
|
|
243
355
|
code += f'''{const_name} = AgentSpec(
|
|
244
356
|
id="{full_agent_id}",
|
|
@@ -248,6 +360,7 @@ from agent_runtimes.types import AgentSpec
|
|
|
248
360
|
tags={_fmt_list(spec.get("tags", []))},
|
|
249
361
|
enabled={spec.get("enabled", True)},
|
|
250
362
|
model={model_str},
|
|
363
|
+
inference_provider={inference_provider_str},
|
|
251
364
|
mcp_servers=[{mcp_servers_str}],
|
|
252
365
|
skills={_fmt_list(skill_refs)},
|
|
253
366
|
tools={_fmt_list(tool_refs)},
|
|
@@ -277,6 +390,11 @@ from agent_runtimes.types import AgentSpec
|
|
|
277
390
|
authorization_policy={auth_policy_str},
|
|
278
391
|
notifications={_fmt_py_literal(notifs)},
|
|
279
392
|
memory={memory_str},
|
|
393
|
+
pre_hooks={_fmt_py_literal(pre_hooks_val)},
|
|
394
|
+
post_hooks={_fmt_py_literal(post_hooks_val)},
|
|
395
|
+
tool_hooks={_fmt_py_literal(tool_hooks_val)},
|
|
396
|
+
parameters={_fmt_py_literal(parameters_val)},
|
|
397
|
+
subagents={subagents_str},
|
|
280
398
|
)
|
|
281
399
|
|
|
282
400
|
'''
|
|
@@ -564,15 +682,15 @@ const SKILL_MAP: Record<string, any> = {
|
|
|
564
682
|
code += "};\n"
|
|
565
683
|
code += """
|
|
566
684
|
function toAgentSkillSpec(skill: SkillSpec) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
685
|
+
return {
|
|
686
|
+
id: skill.id,
|
|
687
|
+
name: skill.name,
|
|
688
|
+
description: skill.description,
|
|
571
689
|
version: skill.version ?? '0.0.1',
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
690
|
+
tags: skill.tags,
|
|
691
|
+
enabled: skill.enabled,
|
|
692
|
+
requiredEnvVars: skill.requiredEnvVars,
|
|
693
|
+
};
|
|
576
694
|
}
|
|
577
695
|
"""
|
|
578
696
|
|
|
@@ -629,6 +747,7 @@ const FRONTEND_TOOL_MAP: Record<string, any> = {
|
|
|
629
747
|
code += f"// {'=' * 76}\n\n"
|
|
630
748
|
|
|
631
749
|
for spec in folder_specs:
|
|
750
|
+
spec = _sanitize_spec_for_codegen(spec)
|
|
632
751
|
agent_id = spec["id"]
|
|
633
752
|
version = spec["version"]
|
|
634
753
|
# Prefix agent ID with folder name for uniqueness
|
|
@@ -663,7 +782,8 @@ const FRONTEND_TOOL_MAP: Record<string, any> = {
|
|
|
663
782
|
]
|
|
664
783
|
if has_skills and skill_ids_list:
|
|
665
784
|
skills_str = ", ".join(
|
|
666
|
-
f"
|
|
785
|
+
f"(SKILL_MAP['{sid}'] ? toAgentSkillSpec(SKILL_MAP['{sid}']) : undefined)"
|
|
786
|
+
for sid in skill_ids_list
|
|
667
787
|
)
|
|
668
788
|
else:
|
|
669
789
|
skills_str = ""
|
|
@@ -731,6 +851,10 @@ const FRONTEND_TOOL_MAP: Record<string, any> = {
|
|
|
731
851
|
# Model field
|
|
732
852
|
model_id = spec.get("model")
|
|
733
853
|
model_ts = f"'{model_id}'" if model_id else "undefined"
|
|
854
|
+
inference_provider = spec.get("inference_provider")
|
|
855
|
+
inference_provider_ts = (
|
|
856
|
+
f"'{inference_provider}'" if inference_provider else "undefined"
|
|
857
|
+
)
|
|
734
858
|
|
|
735
859
|
# Sandbox variant field
|
|
736
860
|
sandbox_variant = spec.get("sandbox_variant")
|
|
@@ -764,44 +888,62 @@ const FRONTEND_TOOL_MAP: Record<string, any> = {
|
|
|
764
888
|
notifs = spec.get("notifications")
|
|
765
889
|
memory_val = spec.get("memory")
|
|
766
890
|
memory_ts = f"'{memory_val}'" if memory_val else "undefined"
|
|
891
|
+
pre_hooks_val = spec.get("pre_hooks")
|
|
892
|
+
post_hooks_val = spec.get("post_hooks")
|
|
893
|
+
tool_hooks_val = spec.get("tool_hooks")
|
|
894
|
+
parameters_val = spec.get("parameters")
|
|
895
|
+
subagents_val = spec.get("subagents")
|
|
896
|
+
subagents_ts = _fmt_ts_literal(
|
|
897
|
+
_normalize_subagents_for_typescript(subagents_val)
|
|
898
|
+
)
|
|
899
|
+
inference_provider_line = (
|
|
900
|
+
f" inferenceProvider: {inference_provider_ts},\n"
|
|
901
|
+
if inference_provider
|
|
902
|
+
else ""
|
|
903
|
+
)
|
|
767
904
|
|
|
768
905
|
code += f"""export const {const_name}: AgentSpec = {{
|
|
769
|
-
|
|
906
|
+
id: '{full_agent_id}',
|
|
770
907
|
version: '{version}',
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
908
|
+
name: '{spec["name"]}',
|
|
909
|
+
description: `{description}`,
|
|
910
|
+
tags: {tags_str},
|
|
911
|
+
enabled: {str(spec.get("enabled", True)).lower()},
|
|
912
|
+
model: {model_ts},
|
|
913
|
+
{inference_provider_line} mcpServers: [{mcp_servers_str}],
|
|
914
|
+
skills: [{skills_str}].filter(Boolean) as SkillSpec[],
|
|
778
915
|
tools: [{tools_str}],
|
|
779
916
|
frontendTools: [{frontend_tools_str}],
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
917
|
+
environmentName: '{spec.get("environment_name", "ai-agents-env")}',
|
|
918
|
+
icon: {icon},
|
|
919
|
+
emoji: {emoji},
|
|
920
|
+
color: {color},
|
|
921
|
+
suggestions: {suggestions_str},
|
|
785
922
|
welcomeMessage: {_fmt_ts_literal(welcome_message)},
|
|
786
923
|
welcomeNotebook: {_fmt_ts_literal(welcome_notebook)},
|
|
787
924
|
welcomeDocument: {_fmt_ts_literal(welcome_document)},
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
925
|
+
sandboxVariant: {sandbox_variant_ts},
|
|
926
|
+
systemPrompt: {f"`{system_prompt}`" if system_prompt else "undefined"},
|
|
927
|
+
systemPromptCodemodeAddons: {f"`{system_prompt_codemode_addons}`" if system_prompt_codemode_addons else "undefined"},
|
|
928
|
+
goal: {goal_ts},
|
|
929
|
+
protocol: {protocol_ts},
|
|
930
|
+
uiExtension: {ui_ext_ts},
|
|
931
|
+
trigger: {_fmt_ts_literal(trigger_val)},
|
|
932
|
+
modelConfig: {_fmt_ts_literal(model_cfg)},
|
|
933
|
+
mcpServerTools: {_fmt_ts_literal(mcp_srv_tools)},
|
|
934
|
+
guardrails: {_fmt_ts_literal(guardrails_val)},
|
|
935
|
+
evals: {_fmt_ts_literal(evals_val)},
|
|
936
|
+
codemode: {_fmt_ts_literal(codemode_val)},
|
|
937
|
+
output: {_fmt_ts_literal(output_val)},
|
|
938
|
+
advanced: {_fmt_ts_literal(advanced_val)},
|
|
939
|
+
authorizationPolicy: {auth_policy_ts},
|
|
940
|
+
notifications: {_fmt_ts_literal(notifs)},
|
|
941
|
+
memory: {memory_ts},
|
|
942
|
+
preHooks: {_fmt_ts_literal(pre_hooks_val)},
|
|
943
|
+
postHooks: {_fmt_ts_literal(post_hooks_val)},
|
|
944
|
+
toolHooks: {_fmt_ts_literal(tool_hooks_val)},
|
|
945
|
+
parameters: {_fmt_ts_literal(parameters_val)},
|
|
946
|
+
subagents: {subagents_ts},
|
|
805
947
|
}};
|
|
806
948
|
|
|
807
949
|
"""
|