@datalayer/agent-runtimes 1.6.8 → 1.6.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/dist-embed/datalayer-app-main.js +6 -6
- package/lib/specs/actions.js +6 -0
- package/lib/specs/agents/agents.js +2 -0
- package/lib/specs/cogs.js +5 -0
- package/lib/specs/envvars.js +1 -1
- package/lib/specs/mcpServers.d.ts +1 -0
- package/lib/specs/mcpServers.js +127 -1
- package/lib/specs/policies.d.ts +5 -0
- package/lib/specs/policies.js +85 -0
- package/lib/specs/skills.js +46 -1
- package/lib/specs/stages.js +1 -1
- package/lib/types/agentspecs.d.ts +13 -0
- package/lib/types/mcp.d.ts +3 -0
- package/lib/types/skills.d.ts +12 -0
- package/package.json +1 -1
- package/scripts/codegen/generate_agents.py +2 -0
- package/scripts/codegen/generate_mcp_servers.py +49 -1
- package/scripts/codegen/generate_sandbox_agents.py +1 -0
- package/scripts/codegen/generate_skills.py +52 -1
|
@@ -22,6 +22,40 @@ import yaml
|
|
|
22
22
|
from marks import check_marks
|
|
23
23
|
from versioning import ensure_spec_version, version_suffix
|
|
24
24
|
|
|
25
|
+
#: What an ``install`` says is installed (agentspecs: mcp-servers, skills).
|
|
26
|
+
INSTALL_TYPES = ("npm", "python", "docker", "git", "remote", "built-in", "other")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def install_of(spec: dict) -> dict | None:
|
|
30
|
+
"""A spec's ``install``, checked: ``{type, command, note?}``; None when it has none.
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
ValueError
|
|
35
|
+
When it is not of that shape, in a sentence naming the spec.
|
|
36
|
+
"""
|
|
37
|
+
install = spec.get("install")
|
|
38
|
+
if install is None:
|
|
39
|
+
return None
|
|
40
|
+
where = f"{spec.get('id')}: install"
|
|
41
|
+
if not isinstance(install, dict) or set(install) - {"type", "command", "note"}:
|
|
42
|
+
raise ValueError(f"{where} is {{type, command, note}}, not {install!r}")
|
|
43
|
+
if install.get("type") not in INSTALL_TYPES:
|
|
44
|
+
raise ValueError(
|
|
45
|
+
f"{where}.type is one of {', '.join(INSTALL_TYPES)}, not {install.get('type')!r}"
|
|
46
|
+
)
|
|
47
|
+
command = install.get("command", "")
|
|
48
|
+
if not isinstance(command, str):
|
|
49
|
+
raise ValueError(f"{where}.command is a shell command, a string")
|
|
50
|
+
if not command.strip() and install["type"] not in ("remote", "built-in", "other"):
|
|
51
|
+
raise ValueError(
|
|
52
|
+
f"{where}.command says how a {install['type']} install is run: it is empty"
|
|
53
|
+
)
|
|
54
|
+
out = {"type": install["type"], "command": command.strip()}
|
|
55
|
+
if install.get("note"):
|
|
56
|
+
out["note"] = " ".join(str(install["note"]).split())
|
|
57
|
+
return out
|
|
58
|
+
|
|
25
59
|
|
|
26
60
|
def load_mcp_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
27
61
|
"""Load all MCP server YAML specifications from a directory."""
|
|
@@ -53,7 +87,9 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
53
87
|
"import tempfile",
|
|
54
88
|
"from typing import Dict",
|
|
55
89
|
"",
|
|
56
|
-
"from agent_runtimes.types import
|
|
90
|
+
"from agent_runtimes.types import "
|
|
91
|
+
+ ("InstallSpec, " if any(spec.get("install") for spec in specs) else "")
|
|
92
|
+
+ "MCPServer"
|
|
57
93
|
+ (", MCPServerAuth" if any(spec.get("auth") for spec in specs) else ""),
|
|
58
94
|
"",
|
|
59
95
|
"# " + "=" * 76,
|
|
@@ -170,6 +206,13 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
170
206
|
for key in ("documentation_url", "signup_url", "api_key_url", "setup"):
|
|
171
207
|
if spec.get(key):
|
|
172
208
|
lines.append(f" {key}={str(spec[key])!r},")
|
|
209
|
+
install = install_of(spec)
|
|
210
|
+
if install:
|
|
211
|
+
lines.append(
|
|
212
|
+
" install=InstallSpec("
|
|
213
|
+
+ ", ".join(f"{k}={v!r}" for k, v in install.items())
|
|
214
|
+
+ "),"
|
|
215
|
+
)
|
|
173
216
|
if spec.get("actions"):
|
|
174
217
|
lines.append(f" actions={_actions_of(spec)!r},")
|
|
175
218
|
lines.extend([")", ""])
|
|
@@ -379,6 +422,11 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
379
422
|
)
|
|
380
423
|
if spec.get(key)
|
|
381
424
|
],
|
|
425
|
+
*(
|
|
426
|
+
[f" install: {json.dumps(install_of(spec), ensure_ascii=False)},"]
|
|
427
|
+
if spec.get("install")
|
|
428
|
+
else []
|
|
429
|
+
),
|
|
382
430
|
*(
|
|
383
431
|
[f" actions: {json.dumps(_actions_of(spec), ensure_ascii=False)},"]
|
|
384
432
|
if spec.get("actions")
|
|
@@ -13,6 +13,7 @@ Usage:
|
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
import argparse
|
|
16
|
+
import json
|
|
16
17
|
import sys
|
|
17
18
|
from pathlib import Path
|
|
18
19
|
from typing import Any
|
|
@@ -21,6 +22,40 @@ import yaml
|
|
|
21
22
|
from marks import check_marks
|
|
22
23
|
from versioning import ensure_spec_version, version_suffix
|
|
23
24
|
|
|
25
|
+
#: What an ``install`` says is installed (agentspecs: mcp-servers, skills).
|
|
26
|
+
INSTALL_TYPES = ("npm", "python", "docker", "git", "remote", "built-in", "other")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def install_of(spec: dict) -> dict | None:
|
|
30
|
+
"""A spec's ``install``, checked: ``{type, command, note?}``; None when it has none.
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
ValueError
|
|
35
|
+
When it is not of that shape, in a sentence naming the spec.
|
|
36
|
+
"""
|
|
37
|
+
install = spec.get("install")
|
|
38
|
+
if install is None:
|
|
39
|
+
return None
|
|
40
|
+
where = f"{spec.get('id')}: install"
|
|
41
|
+
if not isinstance(install, dict) or set(install) - {"type", "command", "note"}:
|
|
42
|
+
raise ValueError(f"{where} is {{type, command, note}}, not {install!r}")
|
|
43
|
+
if install.get("type") not in INSTALL_TYPES:
|
|
44
|
+
raise ValueError(
|
|
45
|
+
f"{where}.type is one of {', '.join(INSTALL_TYPES)}, not {install.get('type')!r}"
|
|
46
|
+
)
|
|
47
|
+
command = install.get("command", "")
|
|
48
|
+
if not isinstance(command, str):
|
|
49
|
+
raise ValueError(f"{where}.command is a shell command, a string")
|
|
50
|
+
if not command.strip() and install["type"] not in ("remote", "built-in", "other"):
|
|
51
|
+
raise ValueError(
|
|
52
|
+
f"{where}.command says how a {install['type']} install is run: it is empty"
|
|
53
|
+
)
|
|
54
|
+
out = {"type": install["type"], "command": command.strip()}
|
|
55
|
+
if install.get("note"):
|
|
56
|
+
out["note"] = " ".join(str(install["note"]).split())
|
|
57
|
+
return out
|
|
58
|
+
|
|
24
59
|
|
|
25
60
|
def _fmt_list(items: list[str]) -> str:
|
|
26
61
|
"""Format a list of strings with double quotes for ruff compliance."""
|
|
@@ -57,7 +92,9 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
57
92
|
"import os",
|
|
58
93
|
"from typing import Dict, List",
|
|
59
94
|
"",
|
|
60
|
-
"from agent_runtimes.types import
|
|
95
|
+
"from agent_runtimes.types import "
|
|
96
|
+
+ ("InstallSpec, " if any(spec.get("install") for spec in specs) else "")
|
|
97
|
+
+ "SkillSpec",
|
|
61
98
|
"",
|
|
62
99
|
"",
|
|
63
100
|
"# " + "=" * 76,
|
|
@@ -113,6 +150,15 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
113
150
|
f" envvars={_fmt_list(spec.get('envvars', []))},",
|
|
114
151
|
f" optional_env_vars={_fmt_list(spec.get('optional_env_vars', []))},",
|
|
115
152
|
f" dependencies={_fmt_list(spec.get('dependencies', []))},",
|
|
153
|
+
*(
|
|
154
|
+
[
|
|
155
|
+
" install=InstallSpec("
|
|
156
|
+
+ ", ".join(f"{k}={v!r}" for k, v in install_of(spec).items())
|
|
157
|
+
+ "),"
|
|
158
|
+
]
|
|
159
|
+
if spec.get("install")
|
|
160
|
+
else []
|
|
161
|
+
),
|
|
116
162
|
f" tags={_fmt_list(spec.get('tags', []))},",
|
|
117
163
|
f" icon={icon},",
|
|
118
164
|
f" emoji={emoji},",
|
|
@@ -277,6 +323,11 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
277
323
|
f" requiredEnvVars: {envvars_json},",
|
|
278
324
|
f" optionalEnvVars: {optional_env_vars_json},",
|
|
279
325
|
f" dependencies: {dependencies_json},",
|
|
326
|
+
*(
|
|
327
|
+
[f" install: {json.dumps(install_of(spec), ensure_ascii=False)},"]
|
|
328
|
+
if spec.get("install")
|
|
329
|
+
else []
|
|
330
|
+
),
|
|
280
331
|
f" tags: {tags_json},",
|
|
281
332
|
f" icon: {icon},",
|
|
282
333
|
f" emoji: {emoji},",
|