@datalayer/agent-runtimes 0.0.10 → 0.0.12
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 -2
- package/lib/Agent.d.ts +29 -0
- package/lib/Agent.js +131 -0
- package/lib/AgentLexical.d.ts +34 -0
- package/lib/AgentLexical.js +296 -0
- package/lib/AgentNotebook.d.ts +19 -0
- package/lib/AgentNotebook.js +192 -0
- package/lib/agent-lexical-main.d.ts +1 -0
- package/lib/agent-lexical-main.js +11 -0
- package/lib/agent-main.d.ts +1 -0
- package/lib/agent-main.js +11 -0
- package/lib/agent-notebook-main.d.ts +1 -0
- package/lib/agent-notebook-main.js +12 -0
- package/lib/components/AgentConfiguration.d.ts +33 -21
- package/lib/components/AgentConfiguration.js +76 -21
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +164 -6
- package/lib/components/chat/components/Chat.d.ts +29 -3
- package/lib/components/chat/components/Chat.js +64 -59
- package/lib/components/chat/components/ChatFloating.d.ts +34 -12
- package/lib/components/chat/components/ChatFloating.js +54 -21
- package/lib/components/chat/components/ChatInline.d.ts +5 -1
- package/lib/components/chat/components/ChatInline.js +8 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +6 -1
- package/lib/components/chat/components/ChatSidebar.js +2 -2
- package/lib/components/chat/components/ChatStandalone.d.ts +6 -1
- package/lib/components/chat/components/ChatStandalone.js +2 -2
- package/lib/components/chat/components/ContextDistribution.js +2 -2
- package/lib/components/chat/components/ContextInspector.js +4 -2
- package/lib/components/chat/components/ContextPanel.js +1 -6
- package/lib/components/chat/components/base/ChatBase.d.ts +49 -8
- package/lib/components/chat/components/base/ChatBase.js +544 -149
- package/lib/components/chat/components/base/InputPrompt.d.ts +42 -0
- package/lib/components/chat/components/base/InputPrompt.js +131 -0
- package/lib/components/chat/components/index.d.ts +3 -3
- package/lib/components/chat/components/index.js +1 -1
- package/lib/components/chat/components/parts/ReasoningPart.js +2 -4
- package/lib/components/chat/components/parts/TextPart.js +2 -70
- package/lib/components/chat/components/styles/streamdownStyles.d.ts +23 -0
- package/lib/components/chat/components/styles/streamdownStyles.js +319 -0
- package/lib/components/chat/index.d.ts +1 -1
- package/lib/components/chat/index.js +1 -1
- package/lib/components/chat/inference/DatalayerInferenceProvider.js +16 -12
- package/lib/components/chat/inference/SelfHostedInferenceProvider.js +16 -12
- package/lib/components/chat/protocols/AGUIAdapter.d.ts +10 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +123 -44
- package/lib/components/chat/types/tool.d.ts +5 -2
- package/lib/components/index.d.ts +2 -19
- package/lib/components/index.js +1 -10
- package/lib/config/index.d.ts +0 -3
- package/lib/config/index.js +0 -3
- package/lib/examples/A2UiRestaurantExample.js +1 -1
- package/lib/examples/AgentRuntimeChatExample.d.ts +15 -0
- package/lib/examples/AgentRuntimeChatExample.js +126 -0
- package/lib/examples/{AgentSpaceFormExample.d.ts → AgentRuntimeFormExample.d.ts} +3 -3
- package/lib/examples/{AgentSpaceFormExample.js → AgentRuntimeFormExample.js} +61 -17
- package/lib/examples/AgentRuntimeLexicalExample.js +6 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +8 -1
- package/lib/examples/AgentRuntimeNotebookExample.js +6 -5
- package/lib/examples/CopilotKitNotebookExample.js +2 -2
- package/lib/examples/JupyterNotebookExample.js +2 -2
- package/lib/{components → examples/components}/Header.d.ts +2 -1
- package/lib/{components → examples/components}/HeaderControls.js +1 -1
- package/lib/{components → examples/components}/LexicalEditor.d.ts +6 -1
- package/lib/{components → examples/components}/LexicalEditor.js +4 -4
- package/lib/{components → examples/components}/MainContent.d.ts +1 -1
- package/lib/{components → examples/components}/MainContent.js +7 -5
- package/lib/examples/components/index.d.ts +16 -0
- package/lib/examples/components/index.js +13 -0
- package/lib/examples/example-selector.js +2 -1
- package/lib/examples/index.d.ts +1 -1
- package/lib/examples/index.js +1 -1
- package/lib/examples/main.js +2 -2
- package/lib/examples/stores/examplesStore.d.ts +2 -23
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/lexical/ChatInlinePlugin.d.ts +13 -2
- package/lib/lexical/ChatInlinePlugin.js +41 -179
- package/lib/lexical/index.d.ts +1 -0
- package/lib/lexical/index.js +1 -0
- package/lib/lexical/useChatInlineToolbarItems.d.ts +28 -0
- package/lib/lexical/useChatInlineToolbarItems.js +163 -0
- package/lib/runtime/useAgentRuntime.d.ts +1 -1
- package/lib/runtime/useAgentRuntime.js +1 -1
- package/lib/specs/agents/codeai/agents.d.ts +28 -0
- package/lib/specs/agents/codeai/agents.js +151 -0
- package/lib/specs/agents/codeai/index.d.ts +1 -0
- package/lib/specs/agents/codeai/index.js +5 -0
- package/lib/{config → specs/agents/codemode-paper}/agents.d.ts +4 -6
- package/lib/specs/agents/codemode-paper/agents.js +308 -0
- package/lib/specs/agents/codemode-paper/index.d.ts +1 -0
- package/lib/specs/agents/codemode-paper/index.js +5 -0
- package/lib/specs/agents/datalayer-ai/agents.d.ts +31 -0
- package/lib/{config → specs/agents/datalayer-ai}/agents.js +42 -184
- package/lib/specs/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/specs/agents/datalayer-ai/index.js +5 -0
- package/lib/specs/agents/index.d.ts +21 -0
- package/lib/specs/agents/index.js +47 -0
- package/lib/specs/envvars.d.ts +29 -0
- package/lib/specs/envvars.js +125 -0
- package/lib/specs/index.d.ts +5 -0
- package/lib/specs/index.js +9 -0
- package/lib/{config → specs}/mcpServers.d.ts +2 -1
- package/lib/{config → specs}/mcpServers.js +47 -1
- package/lib/specs/models.d.ts +68 -0
- package/lib/specs/models.js +239 -0
- package/lib/{config → specs}/skills.d.ts +2 -0
- package/lib/{config → specs}/skills.js +6 -0
- package/lib/state/substates/AIAgentState.d.ts +0 -1
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +11 -22
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +5 -5
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +4 -4
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +4 -4
- package/lib/{types.d.ts → types/Types.d.ts} +42 -8
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +11 -5
- package/scripts/codegen/generate_agents.py +608 -157
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +33 -21
- package/scripts/codegen/generate_models.py +486 -0
- package/scripts/codegen/generate_skills.py +21 -8
- package/style/primer-primitives.css +22 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +0 -37
- package/lib/components/chat/components/elements/ChatInputPrompt.js +0 -150
- /package/lib/{components → examples/components}/FooterMetrics.d.ts +0 -0
- /package/lib/{components → examples/components}/FooterMetrics.js +0 -0
- /package/lib/{components → examples/components}/Header.js +0 -0
- /package/lib/{components → examples/components}/HeaderControls.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.js +0 -0
- /package/lib/{components → examples/components}/SessionTabs.d.ts +0 -0
- /package/lib/{components → examples/components}/SessionTabs.js +0 -0
- /package/lib/{components → examples/components}/TimeTravel.d.ts +0 -0
- /package/lib/{components → examples/components}/TimeTravel.js +0 -0
- /package/lib/{types.js → types/Types.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
|
+
' 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()
|
|
@@ -88,14 +88,16 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
88
88
|
else:
|
|
89
89
|
env_formatted = None
|
|
90
90
|
|
|
91
|
-
# Format
|
|
92
|
-
|
|
93
|
-
if
|
|
94
|
-
|
|
95
|
-
"[" + ", ".join(f'"{v}"' for v in required_env) + "]"
|
|
96
|
-
)
|
|
91
|
+
# Format envvars
|
|
92
|
+
envvars = spec.get("envvars", [])
|
|
93
|
+
if envvars:
|
|
94
|
+
envvars_formatted = "[" + ", ".join(f'"{v}"' for v in envvars) + "]"
|
|
97
95
|
else:
|
|
98
|
-
|
|
96
|
+
envvars_formatted = "[]"
|
|
97
|
+
|
|
98
|
+
# Format optional fields
|
|
99
|
+
icon = f'"{spec.get("icon")}"' if spec.get("icon") else "None"
|
|
100
|
+
emoji = f'"{spec.get("emoji")}"' if spec.get("emoji") else "None"
|
|
99
101
|
|
|
100
102
|
lines.extend(
|
|
101
103
|
[
|
|
@@ -103,6 +105,8 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
103
105
|
f' id="{server_id}",',
|
|
104
106
|
f' name="{spec["name"]}",',
|
|
105
107
|
f' description="{spec["description"]}",',
|
|
108
|
+
f" icon={icon},",
|
|
109
|
+
f" emoji={emoji},",
|
|
106
110
|
f' command="{spec["command"]}",',
|
|
107
111
|
f" args={args_formatted},",
|
|
108
112
|
f' transport="{spec.get("transport", "stdio")}",',
|
|
@@ -117,7 +121,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
117
121
|
|
|
118
122
|
lines.extend(
|
|
119
123
|
[
|
|
120
|
-
f" required_env_vars={
|
|
124
|
+
f" required_env_vars={envvars_formatted},",
|
|
121
125
|
")",
|
|
122
126
|
"",
|
|
123
127
|
]
|
|
@@ -213,7 +217,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
213
217
|
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
214
218
|
" */",
|
|
215
219
|
"",
|
|
216
|
-
"import type { MCPServer } from '../types';",
|
|
220
|
+
"import type { MCPServer } from '../types/Types';",
|
|
217
221
|
"",
|
|
218
222
|
"// " + "=" * 76,
|
|
219
223
|
"// MCP Server Definitions",
|
|
@@ -230,28 +234,36 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
230
234
|
args_list = spec.get("args", [])
|
|
231
235
|
args_formatted = "[" + ", ".join(f"'{arg}'" for arg in args_list) + "]"
|
|
232
236
|
|
|
233
|
-
# Format
|
|
234
|
-
|
|
235
|
-
if
|
|
236
|
-
|
|
237
|
-
"[" + ", ".join(f"'{v}'" for v in required_env) + "]"
|
|
238
|
-
)
|
|
237
|
+
# Format envvars
|
|
238
|
+
envvars = spec.get("envvars", [])
|
|
239
|
+
if envvars:
|
|
240
|
+
envvars_formatted = "[" + ", ".join(f"'{v}'" for v in envvars) + "]"
|
|
239
241
|
else:
|
|
240
|
-
|
|
242
|
+
envvars_formatted = "[]"
|
|
243
|
+
|
|
244
|
+
# Format optional fields
|
|
245
|
+
icon = f"'{spec.get('icon')}'" if spec.get("icon") else "undefined"
|
|
246
|
+
emoji = f"'{spec.get('emoji')}'" if spec.get("emoji") else "undefined"
|
|
247
|
+
|
|
248
|
+
# Escape description for TypeScript
|
|
249
|
+
description = spec.get("description", "").replace("'", "\\'")
|
|
241
250
|
|
|
242
251
|
lines.extend(
|
|
243
252
|
[
|
|
244
253
|
f"export const {const_name}: MCPServer = {{",
|
|
245
254
|
f" id: '{server_id}',",
|
|
246
255
|
f" name: '{spec['name']}',",
|
|
247
|
-
f"
|
|
256
|
+
f" description: '{description}',",
|
|
257
|
+
f" icon: {icon},",
|
|
258
|
+
f" emoji: {emoji},",
|
|
259
|
+
" url: '',",
|
|
248
260
|
f" command: '{spec['command']}',",
|
|
249
261
|
f" args: {args_formatted},",
|
|
250
262
|
f" transport: '{spec.get('transport', 'stdio')}',",
|
|
251
263
|
f" enabled: {str(spec.get('enabled', True)).lower()},",
|
|
252
264
|
" isAvailable: false,",
|
|
253
265
|
" tools: [],",
|
|
254
|
-
f" requiredEnvVars: {
|
|
266
|
+
f" requiredEnvVars: {envvars_formatted},",
|
|
255
267
|
"};",
|
|
256
268
|
"",
|
|
257
269
|
]
|
|
@@ -398,14 +410,14 @@ def main():
|
|
|
398
410
|
print(f"Loaded {len(specs)} MCP server specifications")
|
|
399
411
|
|
|
400
412
|
# Generate Python code
|
|
401
|
-
print(
|
|
413
|
+
print("Generating Python code...")
|
|
402
414
|
python_code = generate_python_code(specs)
|
|
403
415
|
args.python_output.parent.mkdir(parents=True, exist_ok=True)
|
|
404
416
|
args.python_output.write_text(python_code)
|
|
405
417
|
print(f"✓ Generated {args.python_output}")
|
|
406
418
|
|
|
407
419
|
# Generate TypeScript code
|
|
408
|
-
print(
|
|
420
|
+
print("Generating TypeScript code...")
|
|
409
421
|
typescript_code = generate_typescript_code(specs)
|
|
410
422
|
args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
|
|
411
423
|
args.typescript_output.write_text(typescript_code)
|
|
@@ -414,7 +426,7 @@ def main():
|
|
|
414
426
|
# Update __init__.py with correct imports
|
|
415
427
|
init_file = args.python_output.parent / "__init__.py"
|
|
416
428
|
if init_file.exists():
|
|
417
|
-
print(
|
|
429
|
+
print("Updating imports in __init__.py...")
|
|
418
430
|
update_init_file(specs, init_file)
|
|
419
431
|
|
|
420
432
|
print(f"\n✓ Successfully generated code from {len(specs)} MCP server specs")
|