@datalayer/agent-runtimes 0.0.9 → 0.0.11
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 +2 -1
- package/lib/{examples/components → components}/AgentConfiguration.d.ts +54 -9
- package/lib/components/AgentConfiguration.js +585 -0
- package/lib/{examples/components → components}/FooterMetrics.d.ts +1 -2
- package/lib/{examples/components → components}/Header.d.ts +1 -6
- package/lib/{examples/components → components}/Header.js +5 -39
- package/lib/{examples/components → components}/HeaderControls.d.ts +1 -2
- package/lib/{examples/components → components}/HeaderControls.js +1 -1
- package/lib/{examples/components → components}/LexicalEditor.d.ts +2 -3
- package/lib/{examples/components → components}/LexicalEditor.js +2 -2
- package/lib/components/MainContent.d.ts +34 -0
- package/lib/{examples/components → components}/MainContent.js +18 -9
- package/lib/components/McpServerManager.d.ts +30 -0
- package/lib/components/McpServerManager.js +331 -0
- package/lib/{examples/components → components}/MockFileBrowser.d.ts +1 -2
- package/lib/{examples/components → components}/SessionTabs.d.ts +2 -3
- package/lib/{examples/components → components}/TimeTravel.d.ts +1 -2
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +472 -22
- package/lib/components/chat/components/Chat.d.ts +37 -3
- package/lib/components/chat/components/Chat.js +29 -10
- package/lib/components/chat/components/ChatFloating.d.ts +27 -2
- package/lib/components/chat/components/ChatFloating.js +17 -10
- package/lib/components/chat/components/ChatPopupStandalone.js +1 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.js +1 -1
- package/lib/components/chat/components/ContextDistribution.d.ts +70 -6
- package/lib/components/chat/components/ContextDistribution.js +13 -6
- package/lib/components/chat/components/ContextInspector.d.ts +81 -0
- package/lib/components/chat/components/ContextInspector.js +263 -0
- package/lib/components/chat/components/ContextPanel.d.ts +112 -0
- package/lib/components/chat/components/ContextPanel.js +368 -0
- package/lib/components/chat/components/base/ChatBase.d.ts +74 -19
- package/lib/components/chat/components/base/ChatBase.js +296 -37
- package/lib/components/chat/components/index.d.ts +3 -1
- package/lib/components/chat/components/index.js +2 -0
- package/lib/components/chat/extensions/ExtensionRegistry.d.ts +1 -1
- package/lib/components/chat/extensions/index.d.ts +1 -0
- package/lib/components/chat/index.d.ts +3 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +24 -4
- package/lib/components/chat/protocols/VercelAIAdapter.js +35 -1
- package/lib/components/chat/store/chatStore.d.ts +2 -3
- package/lib/components/chat/store/conversationStore.d.ts +83 -0
- package/lib/components/chat/store/conversationStore.js +174 -0
- package/lib/components/chat/store/index.d.ts +2 -1
- package/lib/components/chat/store/index.js +1 -0
- package/lib/components/chat/types/inference.d.ts +17 -0
- package/lib/components/chat/types/protocol.d.ts +10 -0
- package/lib/components/index.d.ts +23 -0
- package/lib/components/index.js +11 -0
- package/lib/config/agents/code-ai/agents.d.ts +25 -0
- package/lib/config/agents/code-ai/agents.js +70 -0
- package/lib/config/agents/code-ai/index.d.ts +1 -0
- package/lib/config/agents/code-ai/index.js +5 -0
- package/lib/config/agents/codemode-paper/agents.d.ts +29 -0
- package/lib/config/agents/codemode-paper/agents.js +288 -0
- package/lib/config/agents/codemode-paper/index.d.ts +1 -0
- package/lib/config/agents/codemode-paper/index.js +5 -0
- package/lib/config/agents/datalayer-ai/agents.d.ts +29 -0
- package/lib/config/agents/datalayer-ai/agents.js +267 -0
- package/lib/config/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/config/agents/datalayer-ai/index.js +5 -0
- package/lib/config/agents/index.d.ts +19 -0
- package/lib/config/agents/index.js +38 -0
- package/lib/config/envvars.d.ts +28 -0
- package/lib/config/envvars.js +115 -0
- package/lib/config/index.d.ts +5 -0
- package/lib/config/index.js +9 -0
- package/lib/config/mcpServers.d.ts +18 -0
- package/lib/config/mcpServers.js +153 -0
- package/lib/config/skills.d.ts +27 -0
- package/lib/config/skills.js +60 -0
- package/lib/{lib → config}/utils.d.ts +1 -1
- package/lib/{lib → config}/utils.js +2 -2
- package/lib/examples/AgentRuntimeLexical2Example.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexical2Example.js +3 -2
- package/lib/examples/AgentRuntimeLexicalExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalExample.js +5 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
- package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
- package/lib/examples/AgentSpaceFormExample.d.ts +2 -2
- package/lib/examples/AgentSpaceFormExample.js +215 -35
- package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
- package/lib/examples/CopilotKitLexicalExample.js +3 -2
- package/lib/examples/index.d.ts +1 -0
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +43 -43
- package/lib/hooks/useAGUI.d.ts +1 -1
- package/lib/hooks/useAGUI.js +1 -1
- package/lib/identity/types.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/runtime/index.d.ts +3 -0
- package/lib/runtime/runtimeStore.d.ts +3 -4
- package/lib/runtime/useAgentConnection.d.ts +2 -3
- package/lib/runtime/useAgentRuntime.d.ts +2 -3
- package/lib/stories/Cell.stories.js +1 -1
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +1 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -0
- package/lib/types.d.ts +158 -0
- package/package.json +5 -6
- package/scripts/apply-patches.sh +1 -1
- package/scripts/codegen/generate_agents.py +863 -0
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +436 -0
- package/scripts/codegen/generate_skills.py +334 -0
- package/scripts/download-ai-elements.py +35 -20
- package/scripts/sync-jupyter.sh +6 -0
- package/lib/components/ui/accordion.d.ts +0 -7
- package/lib/components/ui/accordion.js +0 -22
- package/lib/components/ui/alert-dialog.d.ts +0 -14
- package/lib/components/ui/alert-dialog.js +0 -43
- package/lib/components/ui/alert.d.ts +0 -9
- package/lib/components/ui/alert.js +0 -24
- package/lib/components/ui/aspect-ratio.d.ts +0 -3
- package/lib/components/ui/aspect-ratio.js +0 -11
- package/lib/components/ui/avatar.d.ts +0 -6
- package/lib/components/ui/avatar.js +0 -18
- package/lib/components/ui/badge.d.ts +0 -9
- package/lib/components/ui/badge.js +0 -22
- package/lib/components/ui/breadcrumb.d.ts +0 -11
- package/lib/components/ui/breadcrumb.js +0 -27
- package/lib/components/ui/button-group.d.ts +0 -11
- package/lib/components/ui/button-group.js +0 -31
- package/lib/components/ui/button.d.ts +0 -13
- package/lib/components/ui/button.js +0 -39
- package/lib/components/ui/calendar.d.ts +0 -8
- package/lib/components/ui/calendar.js +0 -80
- package/lib/components/ui/card.d.ts +0 -9
- package/lib/components/ui/card.js +0 -24
- package/lib/components/ui/carousel.d.ts +0 -19
- package/lib/components/ui/carousel.js +0 -95
- package/lib/components/ui/chart.d.ts +0 -53
- package/lib/components/ui/chart.js +0 -136
- package/lib/components/ui/checkbox.d.ts +0 -4
- package/lib/components/ui/checkbox.js +0 -13
- package/lib/components/ui/collapsible.d.ts +0 -5
- package/lib/components/ui/collapsible.js +0 -17
- package/lib/components/ui/command.d.ts +0 -18
- package/lib/components/ui/command.js +0 -38
- package/lib/components/ui/context-menu.d.ts +0 -25
- package/lib/components/ui/context-menu.js +0 -55
- package/lib/components/ui/dialog.d.ts +0 -15
- package/lib/components/ui/dialog.js +0 -40
- package/lib/components/ui/drawer.d.ts +0 -13
- package/lib/components/ui/drawer.js +0 -39
- package/lib/components/ui/dropdown-menu.d.ts +0 -25
- package/lib/components/ui/dropdown-menu.js +0 -55
- package/lib/components/ui/empty.d.ts +0 -11
- package/lib/components/ui/empty.js +0 -37
- package/lib/components/ui/field.d.ts +0 -24
- package/lib/components/ui/field.js +0 -80
- package/lib/components/ui/form.d.ts +0 -24
- package/lib/components/ui/form.js +0 -63
- package/lib/components/ui/hover-card.d.ts +0 -6
- package/lib/components/ui/hover-card.js +0 -18
- package/lib/components/ui/input-group.d.ts +0 -19
- package/lib/components/ui/input-group.js +0 -69
- package/lib/components/ui/input-otp.d.ts +0 -11
- package/lib/components/ui/input-otp.js +0 -25
- package/lib/components/ui/input.d.ts +0 -3
- package/lib/components/ui/input.js +0 -6
- package/lib/components/ui/item.d.ts +0 -23
- package/lib/components/ui/item.js +0 -66
- package/lib/components/ui/kbd.d.ts +0 -3
- package/lib/components/ui/kbd.js +0 -13
- package/lib/components/ui/label.d.ts +0 -4
- package/lib/components/ui/label.js +0 -12
- package/lib/components/ui/menubar.d.ts +0 -26
- package/lib/components/ui/menubar.js +0 -58
- package/lib/components/ui/navigation-menu.d.ts +0 -14
- package/lib/components/ui/navigation-menu.js +0 -31
- package/lib/components/ui/pagination.d.ts +0 -13
- package/lib/components/ui/pagination.js +0 -29
- package/lib/components/ui/popover.d.ts +0 -7
- package/lib/components/ui/popover.js +0 -21
- package/lib/components/ui/progress.d.ts +0 -4
- package/lib/components/ui/progress.js +0 -12
- package/lib/components/ui/radio-group.d.ts +0 -5
- package/lib/components/ui/radio-group.js +0 -16
- package/lib/components/ui/resizable.d.ts +0 -8
- package/lib/components/ui/resizable.js +0 -19
- package/lib/components/ui/scroll-area.d.ts +0 -5
- package/lib/components/ui/scroll-area.js +0 -17
- package/lib/components/ui/select.d.ts +0 -15
- package/lib/components/ui/select.js +0 -42
- package/lib/components/ui/separator.d.ts +0 -4
- package/lib/components/ui/separator.js +0 -12
- package/lib/components/ui/sheet.d.ts +0 -13
- package/lib/components/ui/sheet.js +0 -44
- package/lib/components/ui/sidebar.d.ts +0 -69
- package/lib/components/ui/sidebar.js +0 -216
- package/lib/components/ui/skeleton.d.ts +0 -2
- package/lib/components/ui/skeleton.js +0 -10
- package/lib/components/ui/slider.d.ts +0 -4
- package/lib/components/ui/slider.js +0 -18
- package/lib/components/ui/sonner.d.ts +0 -3
- package/lib/components/ui/sonner.js +0 -25
- package/lib/components/ui/spinner.d.ts +0 -2
- package/lib/components/ui/spinner.js +0 -11
- package/lib/components/ui/switch.d.ts +0 -4
- package/lib/components/ui/switch.js +0 -12
- package/lib/components/ui/table.d.ts +0 -10
- package/lib/components/ui/table.js +0 -32
- package/lib/components/ui/tabs.d.ts +0 -7
- package/lib/components/ui/tabs.js +0 -21
- package/lib/components/ui/textarea.d.ts +0 -3
- package/lib/components/ui/textarea.js +0 -6
- package/lib/components/ui/toast.d.ts +0 -15
- package/lib/components/ui/toast.js +0 -38
- package/lib/components/ui/toaster.d.ts +0 -1
- package/lib/components/ui/toaster.js +0 -14
- package/lib/components/ui/toggle-group.d.ts +0 -9
- package/lib/components/ui/toggle-group.js +0 -26
- package/lib/components/ui/toggle.d.ts +0 -9
- package/lib/components/ui/toggle.js +0 -30
- package/lib/components/ui/tooltip.d.ts +0 -7
- package/lib/components/ui/tooltip.js +0 -21
- package/lib/components/vercel-ai-elements/artifact.d.ts +0 -23
- package/lib/components/vercel-ai-elements/artifact.js +0 -24
- package/lib/components/vercel-ai-elements/code-block.d.ts +0 -17
- package/lib/components/vercel-ai-elements/code-block.js +0 -94
- package/lib/components/vercel-ai-elements/conversation.d.ts +0 -15
- package/lib/components/vercel-ai-elements/conversation.js +0 -21
- package/lib/components/vercel-ai-elements/loader.d.ts +0 -5
- package/lib/components/vercel-ai-elements/loader.js +0 -8
- package/lib/components/vercel-ai-elements/message.d.ts +0 -46
- package/lib/components/vercel-ai-elements/message.js +0 -109
- package/lib/components/vercel-ai-elements/model-selector.d.ts +0 -35
- package/lib/components/vercel-ai-elements/model-selector.js +0 -22
- package/lib/components/vercel-ai-elements/prompt-input.d.ts +0 -195
- package/lib/components/vercel-ai-elements/prompt-input.js +0 -589
- package/lib/components/vercel-ai-elements/reasoning.d.ts +0 -26
- package/lib/components/vercel-ai-elements/reasoning.js +0 -80
- package/lib/components/vercel-ai-elements/shimmer.d.ts +0 -9
- package/lib/components/vercel-ai-elements/shimmer.js +0 -22
- package/lib/components/vercel-ai-elements/sources.d.ts +0 -12
- package/lib/components/vercel-ai-elements/sources.js +0 -13
- package/lib/components/vercel-ai-elements/suggestion.d.ts +0 -10
- package/lib/components/vercel-ai-elements/suggestion.js +0 -16
- package/lib/components/vercel-ai-elements/tool.d.ts +0 -23
- package/lib/components/vercel-ai-elements/tool.js +0 -52
- package/lib/examples/components/AgentConfiguration.js +0 -382
- package/lib/examples/components/MainContent.d.ts +0 -19
- package/lib/examples/components/index.d.ts +0 -10
- package/lib/examples/components/index.js +0 -13
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +0 -12
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +0 -69
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +0 -85
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +0 -62
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +0 -51
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +0 -56
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +0 -50
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +0 -16
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +0 -72
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +0 -43
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +0 -31
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +0 -54
- package/lib/examples/vercel-ai-elements/index.d.ts +0 -13
- package/lib/examples/vercel-ai-elements/index.js +0 -17
- package/lib/examples/vercel-ai-elements/main.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/main.js +0 -9
- package/lib/examples/vercel-ai-elements/showcase.css +0 -128
- package/lib/hooks/useToast.d.ts +0 -44
- package/lib/hooks/useToast.js +0 -128
- package/patches/@datalayer+jupyter-lexical+1.0.8.patch +0 -11628
- package/patches/@datalayer+jupyter-react+2.0.2.patch +0 -5338
- package/style/showcase-vercel-ai.css +0 -137
- /package/lib/{examples/components → components}/FooterMetrics.js +0 -0
- /package/lib/{examples/components → components}/MockFileBrowser.js +0 -0
- /package/lib/{examples/components → components}/SessionTabs.js +0 -0
- /package/lib/{examples/components → components}/TimeTravel.js +0 -0
- /package/lib/{models → types}/AIAgent.d.ts +0 -0
- /package/lib/{models → types}/AIAgent.js +0 -0
- /package/lib/{models → types}/index.d.ts +0 -0
- /package/lib/{models → types}/index.js +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
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 environment variable specifications.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
python generate_envvars.py \\
|
|
10
|
+
--specs-dir specs/envvars \\
|
|
11
|
+
--python-output agent_runtimes/config/envvars.py \\
|
|
12
|
+
--typescript-output src/config/envvars.ts
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
import yaml
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _fmt_list(items: list[str]) -> str:
|
|
24
|
+
"""Format a list of strings with double quotes for ruff compliance."""
|
|
25
|
+
if not items:
|
|
26
|
+
return "[]"
|
|
27
|
+
return "[" + ", ".join(f'"{item}"' for item in items) + "]"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def load_envvar_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
31
|
+
"""Load all envvar YAML specifications from a directory."""
|
|
32
|
+
specs = []
|
|
33
|
+
for yaml_file in sorted(specs_dir.glob("*.yaml")):
|
|
34
|
+
with open(yaml_file) as f:
|
|
35
|
+
spec = yaml.safe_load(f)
|
|
36
|
+
specs.append(spec)
|
|
37
|
+
return specs
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
41
|
+
"""Generate Python code from environment variable specifications."""
|
|
42
|
+
lines = [
|
|
43
|
+
"# Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
44
|
+
"# Distributed under the terms of the Modified BSD License.",
|
|
45
|
+
'"""',
|
|
46
|
+
"Environment Variable Catalog.",
|
|
47
|
+
"",
|
|
48
|
+
"Predefined environment variable specifications.",
|
|
49
|
+
"",
|
|
50
|
+
"This file is AUTO-GENERATED from YAML specifications.",
|
|
51
|
+
"DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
52
|
+
'"""',
|
|
53
|
+
"",
|
|
54
|
+
"from dataclasses import dataclass",
|
|
55
|
+
"from typing import Dict, List, Optional",
|
|
56
|
+
"",
|
|
57
|
+
"",
|
|
58
|
+
"# " + "=" * 76,
|
|
59
|
+
"# Environment Variable Specification",
|
|
60
|
+
"# " + "=" * 76,
|
|
61
|
+
"",
|
|
62
|
+
"@dataclass",
|
|
63
|
+
"class EnvvarSpec:",
|
|
64
|
+
' """Environment variable specification."""',
|
|
65
|
+
"",
|
|
66
|
+
" id: str",
|
|
67
|
+
" name: str",
|
|
68
|
+
" description: str",
|
|
69
|
+
" registrationUrl: Optional[str]",
|
|
70
|
+
" tags: List[str]",
|
|
71
|
+
" icon: Optional[str]",
|
|
72
|
+
" emoji: Optional[str]",
|
|
73
|
+
"",
|
|
74
|
+
"",
|
|
75
|
+
"# " + "=" * 76,
|
|
76
|
+
"# Environment Variable Definitions",
|
|
77
|
+
"# " + "=" * 76,
|
|
78
|
+
"",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
# Generate envvar constants
|
|
82
|
+
for spec in specs:
|
|
83
|
+
envvar_id = spec["id"]
|
|
84
|
+
const_name = f"{envvar_id}_SPEC"
|
|
85
|
+
|
|
86
|
+
registration_url_value = (
|
|
87
|
+
f'"{spec.get("registrationUrl")}"'
|
|
88
|
+
if spec.get("registrationUrl")
|
|
89
|
+
else "None"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Format optional fields
|
|
93
|
+
icon = f'"{spec.get("icon")}"' if spec.get("icon") else "None"
|
|
94
|
+
emoji = f'"{spec.get("emoji")}"' if spec.get("emoji") else "None"
|
|
95
|
+
|
|
96
|
+
lines.extend(
|
|
97
|
+
[
|
|
98
|
+
f"{const_name} = EnvvarSpec(",
|
|
99
|
+
f' id="{envvar_id}",',
|
|
100
|
+
f' name="{spec["name"]}",',
|
|
101
|
+
f' description="{spec["description"]}",',
|
|
102
|
+
f" registrationUrl={registration_url_value},",
|
|
103
|
+
f" tags={_fmt_list(spec.get('tags', []))},",
|
|
104
|
+
f" icon={icon},",
|
|
105
|
+
f" emoji={emoji},",
|
|
106
|
+
")",
|
|
107
|
+
"",
|
|
108
|
+
]
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Generate catalog dictionary
|
|
112
|
+
lines.extend(
|
|
113
|
+
[
|
|
114
|
+
"# " + "=" * 76,
|
|
115
|
+
"# Environment Variable Catalog",
|
|
116
|
+
"# " + "=" * 76,
|
|
117
|
+
"",
|
|
118
|
+
"ENVVAR_CATALOG: Dict[str, EnvvarSpec] = {",
|
|
119
|
+
]
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
for spec in specs:
|
|
123
|
+
envvar_id = spec["id"]
|
|
124
|
+
const_name = f"{envvar_id}_SPEC"
|
|
125
|
+
lines.append(f' "{envvar_id}": {const_name},')
|
|
126
|
+
|
|
127
|
+
lines.extend(
|
|
128
|
+
[
|
|
129
|
+
"}",
|
|
130
|
+
"",
|
|
131
|
+
"",
|
|
132
|
+
"def get_envvar_spec(envvar_id: str) -> EnvvarSpec:",
|
|
133
|
+
' """Get environment variable specification by ID."""',
|
|
134
|
+
" if envvar_id not in ENVVAR_CATALOG:",
|
|
135
|
+
f' raise ValueError(f"Unknown environment variable: {{envvar_id}}")',
|
|
136
|
+
" return ENVVAR_CATALOG[envvar_id]",
|
|
137
|
+
"",
|
|
138
|
+
]
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return "\n".join(lines)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
145
|
+
"""Generate TypeScript code from environment variable specifications."""
|
|
146
|
+
lines = [
|
|
147
|
+
"/*",
|
|
148
|
+
" * Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
149
|
+
" * Distributed under the terms of the Modified BSD License.",
|
|
150
|
+
" */",
|
|
151
|
+
"",
|
|
152
|
+
"/**",
|
|
153
|
+
" * Environment Variable Catalog",
|
|
154
|
+
" *",
|
|
155
|
+
" * Predefined environment variable specifications.",
|
|
156
|
+
" *",
|
|
157
|
+
" * This file is AUTO-GENERATED from YAML specifications.",
|
|
158
|
+
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
159
|
+
" */",
|
|
160
|
+
"",
|
|
161
|
+
"export interface EnvvarSpec {",
|
|
162
|
+
" id: string;",
|
|
163
|
+
" name: string;",
|
|
164
|
+
" description: string;",
|
|
165
|
+
" registrationUrl?: string;",
|
|
166
|
+
" tags: string[];",
|
|
167
|
+
" icon?: string;",
|
|
168
|
+
" emoji?: string;",
|
|
169
|
+
"}",
|
|
170
|
+
"",
|
|
171
|
+
"// " + "=" * 76,
|
|
172
|
+
"// Environment Variable Definitions",
|
|
173
|
+
"// " + "=" * 76,
|
|
174
|
+
"",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
# Generate envvar constants
|
|
178
|
+
for spec in specs:
|
|
179
|
+
envvar_id = spec["id"]
|
|
180
|
+
const_name = f"{envvar_id}_SPEC"
|
|
181
|
+
|
|
182
|
+
# Format arrays for TypeScript
|
|
183
|
+
tags_json = str(spec.get("tags", [])).replace("'", '"')
|
|
184
|
+
registration_url = (
|
|
185
|
+
f"registrationUrl: '{spec['registrationUrl']}',"
|
|
186
|
+
if spec.get("registrationUrl")
|
|
187
|
+
else ""
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Format optional fields
|
|
191
|
+
icon = f"'{spec.get('icon')}'" if spec.get("icon") else "undefined"
|
|
192
|
+
emoji = f"'{spec.get('emoji')}'" if spec.get("emoji") else "undefined"
|
|
193
|
+
|
|
194
|
+
lines.extend(
|
|
195
|
+
[
|
|
196
|
+
f"export const {const_name}: EnvvarSpec = {{",
|
|
197
|
+
f" id: '{envvar_id}',",
|
|
198
|
+
f" name: '{spec['name']}',",
|
|
199
|
+
f" description: '{spec['description']}',",
|
|
200
|
+
]
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
if registration_url:
|
|
204
|
+
lines.append(f" {registration_url}")
|
|
205
|
+
|
|
206
|
+
lines.extend(
|
|
207
|
+
[
|
|
208
|
+
f" tags: {tags_json},",
|
|
209
|
+
f" icon: {icon},",
|
|
210
|
+
f" emoji: {emoji},",
|
|
211
|
+
"};",
|
|
212
|
+
"",
|
|
213
|
+
]
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
# Generate catalog object
|
|
217
|
+
lines.extend(
|
|
218
|
+
[
|
|
219
|
+
"// " + "=" * 76,
|
|
220
|
+
"// Environment Variable Catalog",
|
|
221
|
+
"// " + "=" * 76,
|
|
222
|
+
"",
|
|
223
|
+
"export const ENVVAR_CATALOG: Record<string, EnvvarSpec> = {",
|
|
224
|
+
]
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
for spec in specs:
|
|
228
|
+
envvar_id = spec["id"]
|
|
229
|
+
const_name = f"{envvar_id}_SPEC"
|
|
230
|
+
lines.append(f" '{envvar_id}': {const_name},")
|
|
231
|
+
|
|
232
|
+
lines.extend(
|
|
233
|
+
[
|
|
234
|
+
"};",
|
|
235
|
+
"",
|
|
236
|
+
"export function getEnvvarSpec(envvarId: string): EnvvarSpec {",
|
|
237
|
+
" const spec = ENVVAR_CATALOG[envvarId];",
|
|
238
|
+
" if (!spec) {",
|
|
239
|
+
" throw new Error(`Unknown environment variable: ${envvarId}`);",
|
|
240
|
+
" }",
|
|
241
|
+
" return spec;",
|
|
242
|
+
"}",
|
|
243
|
+
"",
|
|
244
|
+
]
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
return "\n".join(lines)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def main():
|
|
251
|
+
parser = argparse.ArgumentParser(
|
|
252
|
+
description="Generate Python and TypeScript code from YAML environment variable specifications"
|
|
253
|
+
)
|
|
254
|
+
parser.add_argument(
|
|
255
|
+
"--specs-dir",
|
|
256
|
+
type=Path,
|
|
257
|
+
required=True,
|
|
258
|
+
help="Directory containing envvar YAML files",
|
|
259
|
+
)
|
|
260
|
+
parser.add_argument(
|
|
261
|
+
"--python-output",
|
|
262
|
+
type=Path,
|
|
263
|
+
required=True,
|
|
264
|
+
help="Output path for Python file",
|
|
265
|
+
)
|
|
266
|
+
parser.add_argument(
|
|
267
|
+
"--typescript-output",
|
|
268
|
+
type=Path,
|
|
269
|
+
required=True,
|
|
270
|
+
help="Output path for TypeScript file",
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
args = parser.parse_args()
|
|
274
|
+
|
|
275
|
+
if not args.specs_dir.exists():
|
|
276
|
+
print(f"Error: Specs directory not found: {args.specs_dir}", file=sys.stderr)
|
|
277
|
+
sys.exit(1)
|
|
278
|
+
|
|
279
|
+
# Load specs
|
|
280
|
+
specs = load_envvar_specs(args.specs_dir)
|
|
281
|
+
if not specs:
|
|
282
|
+
print(
|
|
283
|
+
f"Warning: No envvar specifications found in {args.specs_dir}",
|
|
284
|
+
file=sys.stderr,
|
|
285
|
+
)
|
|
286
|
+
return
|
|
287
|
+
|
|
288
|
+
# Generate Python code
|
|
289
|
+
python_code = generate_python_code(specs)
|
|
290
|
+
args.python_output.parent.mkdir(parents=True, exist_ok=True)
|
|
291
|
+
args.python_output.write_text(python_code)
|
|
292
|
+
print(f"Generated Python code: {args.python_output}")
|
|
293
|
+
|
|
294
|
+
# Generate TypeScript code
|
|
295
|
+
typescript_code = generate_typescript_code(specs)
|
|
296
|
+
args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
|
|
297
|
+
args.typescript_output.write_text(typescript_code)
|
|
298
|
+
print(f"Generated TypeScript code: {args.typescript_output}")
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
if __name__ == "__main__":
|
|
302
|
+
main()
|