@datalayer/agent-runtimes 1.3.15 → 1.3.16

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/lib/chat/base/ChatBase.js +3 -2
  3. package/lib/config/AgentConfiguration.d.ts +1 -1
  4. package/lib/loop/embed/LoopEmbed.d.ts +6 -1
  5. package/lib/loop/embed/LoopEmbed.js +3 -2
  6. package/lib/loop/plugins/chat/ChatView.js +9 -4
  7. package/lib/loop/plugins/chat/index.d.ts +10 -0
  8. package/lib/loop/plugins/chat/index.js +1 -0
  9. package/lib/loop/presets.d.ts +6 -0
  10. package/lib/loop/presets.js +2 -1
  11. package/lib/loop/shell/LoopWorkspace.d.ts +14 -0
  12. package/lib/loop/shell/LoopWorkspace.js +20 -6
  13. package/lib/loop/shell/index.d.ts +1 -1
  14. package/lib/loop/shell/index.js +1 -1
  15. package/lib/loop/shell/useWorkspaceFullScreen.d.ts +17 -4
  16. package/lib/loop/shell/useWorkspaceFullScreen.js +23 -6
  17. package/lib/specs/agents/agents.d.ts +1 -0
  18. package/lib/specs/agents/agents.js +338 -284
  19. package/lib/specs/events.d.ts +6 -1
  20. package/lib/specs/events.js +144 -1
  21. package/lib/specs/index.d.ts +2 -0
  22. package/lib/specs/index.js +2 -0
  23. package/lib/specs/mcpServers.js +2 -2
  24. package/lib/specs/memory.js +4 -0
  25. package/lib/specs/modelProviders.d.ts +22 -0
  26. package/lib/specs/modelProviders.js +102 -0
  27. package/lib/specs/models.d.ts +31 -0
  28. package/lib/specs/models.js +215 -0
  29. package/lib/specs/outputs.js +2 -2
  30. package/lib/specs/skills.js +1 -1
  31. package/lib/specs/teams/teams.js +18 -18
  32. package/lib/specs/uiPlugins.d.ts +16 -0
  33. package/lib/specs/uiPlugins.js +40 -0
  34. package/lib/types/agentspecs.d.ts +18 -2
  35. package/lib/types/memory.d.ts +2 -0
  36. package/lib/types/models.d.ts +52 -0
  37. package/package.json +1 -1
  38. package/scripts/check-cloudflare-models.py +122 -0
  39. package/scripts/codegen/generate_agents.py +6 -4
  40. package/scripts/codegen/generate_memory.py +2 -0
  41. package/scripts/codegen/generate_model_providers.py +246 -0
  42. package/scripts/codegen/generate_models.py +135 -4
  43. package/scripts/codegen/generate_sandbox_agents.py +1 -1
  44. package/scripts/codegen/generate_ui_plugins.py +226 -0
  45. package/scripts/gen_workers.py +2 -2
@@ -38,7 +38,14 @@ def _make_const_name(model_id: str) -> str:
38
38
 
39
39
  E.g. 'anthropic:claude-sonnet-4-5-20250514' -> 'ANTHROPIC_CLAUDE_SONNET_4_5_20250514'
40
40
  """
41
- return model_id.upper().replace(":", "_").replace("-", "_").replace(".", "_")
41
+ # A Cloudflare id carries a vendor segment: "cloudflare:openai/gpt-oss-120b".
42
+ return (
43
+ model_id.upper()
44
+ .replace(":", "_")
45
+ .replace("-", "_")
46
+ .replace(".", "_")
47
+ .replace("/", "_")
48
+ )
42
49
 
43
50
 
44
51
  def _pick_default(specs: list[dict]) -> Optional[dict]:
@@ -89,7 +96,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
89
96
  "from enum import Enum",
90
97
  "from typing import Dict, List, Optional",
91
98
  "",
92
- "from agent_runtimes.types import AIModel",
99
+ "from agent_runtimes.types import AIModel, ModelPricing",
93
100
  "",
94
101
  "",
95
102
  "# " + "=" * 76,
@@ -102,10 +109,18 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
102
109
  "",
103
110
  ]
104
111
 
105
- # Generate enum members
112
+ # Generate enum members; an older id keeps its member, with its older value.
113
+ seen = set()
106
114
  for spec in specs:
107
115
  enum_name = _make_enum_name(spec["id"])
108
116
  lines.append(f' {enum_name} = "{spec["id"]}"')
117
+ seen.add(enum_name)
118
+ for spec in specs:
119
+ for alias in spec.get("aliases") or []:
120
+ alias_name = _make_enum_name(alias)
121
+ if alias_name not in seen:
122
+ lines.append(f' {alias_name} = "{alias}" # before the id moved')
123
+ seen.add(alias_name)
109
124
 
110
125
  lines.extend(
111
126
  [
@@ -141,6 +156,11 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
141
156
  f' name="{spec["name"]}",',
142
157
  f' description="{spec.get("description", "")}",',
143
158
  f' provider="{spec["provider"]}",',
159
+ *(
160
+ [f' provider_url="{spec["provider_url"]}",']
161
+ if spec.get("provider_url")
162
+ else []
163
+ ),
144
164
  f" default={spec.get('default', False)},",
145
165
  # What is worth offering today, as distinct from what the platform
146
166
  # knows how to talk to.
@@ -160,6 +180,30 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
160
180
  if capabilities:
161
181
  formatted = "[" + ", ".join(f'"{c}"' for c in capabilities) + "]"
162
182
  model_lines.append(f" capabilities={formatted},")
183
+ if spec.get("billing"):
184
+ model_lines.append(f' billing="{spec["billing"]}",')
185
+ if spec.get("route"):
186
+ model_lines.append(f' route="{spec["route"]}",')
187
+ if spec.get("context_window") is not None:
188
+ model_lines.append(f" context_window={int(spec['context_window'])},")
189
+ if spec.get("zero_data_retention") is not None:
190
+ model_lines.append(
191
+ f" zero_data_retention={bool(spec['zero_data_retention'])},"
192
+ )
193
+ if spec.get("request_logging"):
194
+ model_lines.append(f' request_logging="{spec["request_logging"]}",')
195
+ aliases = spec.get("aliases") or []
196
+ if aliases:
197
+ model_lines.append(
198
+ " aliases=[" + ", ".join(f'"{a}"' for a in aliases) + "],"
199
+ )
200
+ pricing = spec.get("pricing") or {}
201
+ if pricing:
202
+ model_lines.append(
203
+ " pricing=ModelPricing("
204
+ f"input_usd_per_million={float(pricing['input_usd_per_million'])}, "
205
+ f"output_usd_per_million={float(pricing['output_usd_per_million'])}),"
206
+ )
163
207
 
164
208
  model_lines.extend([")", ""])
165
209
  lines.extend(model_lines)
@@ -180,6 +224,18 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
180
224
  const_name = _make_const_name(model_id) + version_suffix(spec["version"])
181
225
  lines.append(f' "{model_id}": {const_name},')
182
226
 
227
+ lines.extend(
228
+ [
229
+ "}",
230
+ "",
231
+ "# The ids a model answered to before its id moved, to the id it has now.",
232
+ "# Kept apart from the catalogue, which lists each model once.",
233
+ "AI_MODEL_ALIASES: Dict[str, str] = {",
234
+ ]
235
+ )
236
+ for spec in specs:
237
+ for alias in spec.get("aliases") or []:
238
+ lines.append(f' "{alias}": "{spec["id"]}",')
183
239
  lines.extend(
184
240
  [
185
241
  "}",
@@ -237,7 +293,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
237
293
  " Returns:",
238
294
  " The AIModel specification, or None if not found.",
239
295
  ' """',
240
- " model = AI_MODEL_CATALOGUE.get(model_id)",
296
+ " model = AI_MODEL_CATALOGUE.get(AI_MODEL_ALIASES.get(model_id, model_id))",
241
297
  " if model is not None:",
242
298
  " return model",
243
299
  " base, _, ver = model_id.rpartition(':')",
@@ -269,6 +325,19 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
269
325
  ' """',
270
326
  " return list(AI_MODEL_CATALOGUE.values())",
271
327
  "",
328
+ "",
329
+ "def is_chat_model(model: AIModel) -> bool:",
330
+ ' """A model a chat can run on: not a typed-judgment model (Jev), which',
331
+ " answers typed questions about a state and nothing else. A spec that",
332
+ " states no capability is read as a chat model.",
333
+ ' """',
334
+ ' return "judgments" not in model.capabilities',
335
+ "",
336
+ "",
337
+ "def list_chat_models() -> list[AIModel]:",
338
+ ' """The models a person choosing a chat model is offered from."""',
339
+ " return [model for model in AI_MODEL_CATALOGUE.values() if is_chat_model(model)]",
340
+ "",
272
341
  ]
273
342
  )
274
343
 
@@ -342,6 +411,11 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
342
411
  f" name: '{spec['name']}',",
343
412
  f" description: '{description}',",
344
413
  f" provider: '{spec['provider']}',",
414
+ *(
415
+ [f" providerUrl: '{spec['provider_url']}',"]
416
+ if spec.get("provider_url")
417
+ else []
418
+ ),
345
419
  f" default: {str(spec.get('default', False)).lower()},",
346
420
  f" available: {str(spec.get('available', False)).lower()},",
347
421
  f" requiredEnvVars: {env_vars_formatted},",
@@ -358,6 +432,30 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
358
432
  if capabilities:
359
433
  formatted = "[" + ", ".join(f"'{c}'" for c in capabilities) + "]"
360
434
  model_lines.append(f" capabilities: {formatted},")
435
+ if spec.get("billing"):
436
+ model_lines.append(f" billing: '{spec['billing']}',")
437
+ if spec.get("route"):
438
+ model_lines.append(f" route: '{spec['route']}',")
439
+ if spec.get("context_window") is not None:
440
+ model_lines.append(f" contextWindow: {int(spec['context_window'])},")
441
+ if spec.get("zero_data_retention") is not None:
442
+ model_lines.append(
443
+ f" zeroDataRetention: {'true' if spec['zero_data_retention'] else 'false'},"
444
+ )
445
+ if spec.get("request_logging"):
446
+ model_lines.append(f" requestLogging: '{spec['request_logging']}',")
447
+ aliases = spec.get("aliases") or []
448
+ if aliases:
449
+ model_lines.append(
450
+ " aliases: [" + ", ".join(f"'{a}'" for a in aliases) + "],"
451
+ )
452
+ pricing = spec.get("pricing") or {}
453
+ if pricing:
454
+ model_lines.append(
455
+ " pricing: { "
456
+ f"inputUsdPerMillion: {float(pricing['input_usd_per_million'])}, "
457
+ f"outputUsdPerMillion: {float(pricing['output_usd_per_million'])} }},"
458
+ )
361
459
  model_lines.extend(
362
460
  [
363
461
  "};",
@@ -386,6 +484,39 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
386
484
  [
387
485
  "};",
388
486
  "",
487
+ "/**",
488
+ " * The ids a model answered to before its id moved, to the id it has now.",
489
+ " * Kept apart from the catalogue, which lists each model once.",
490
+ " */",
491
+ "export const AI_MODEL_ALIASES: Record<string, string> = {",
492
+ ]
493
+ )
494
+ for spec in specs:
495
+ for alias in spec.get("aliases") or []:
496
+ lines.append(f" '{alias}': '{spec['id']}',")
497
+ lines.extend(
498
+ [
499
+ "};",
500
+ "",
501
+ "/** A model by its id, or by an id it had before; undefined when the catalogue has neither. */",
502
+ "export function getModel(modelId: string): AIModel | undefined {",
503
+ " return AI_MODEL_CATALOGUE[AI_MODEL_ALIASES[modelId] ?? modelId];",
504
+ "}",
505
+ "",
506
+ "/**",
507
+ " * A model a chat can run on: not a typed-judgment model (Jev), which",
508
+ " * answers typed questions about a state and nothing else. A spec that",
509
+ " * states no capability is read as a chat model.",
510
+ " */",
511
+ "export function isChatModel(model: AIModel): boolean {",
512
+ " return !(model.capabilities ?? []).includes('judgments');",
513
+ "}",
514
+ "",
515
+ "/** The models a person choosing a chat model is offered from. */",
516
+ "export function listChatModels(): AIModel[] {",
517
+ " return Object.values(AI_MODEL_CATALOGUE).filter(isChatModel);",
518
+ "}",
519
+ "",
389
520
  ]
390
521
  )
391
522
 
@@ -73,7 +73,7 @@ tags:
73
73
  - code-execution
74
74
  - {key}
75
75
 
76
- enabled: true
76
+ enabled: false
77
77
  model: "bedrock:us.anthropic.claude-sonnet-4-6"
78
78
  harness: pydantic-ai
79
79
 
@@ -0,0 +1,226 @@
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 UI-plugin specifications.
7
+
8
+ A UI plugin is how an agent's answer becomes an interface rather than text —
9
+ a protocol the host knows how to render (A2UI, MCP Apps, MCP UI). One YAML per
10
+ plugin under ``agentspecs/ui-plugins``; an agent spec's ``ui_plugin`` names
11
+ one. They were called UI extensions before agentspecs 0.0.11.
12
+
13
+ Usage:
14
+ python generate_ui_plugins.py \\
15
+ --specs-dir agentspecs/agentspecs/ui-plugins \\
16
+ --python-output agent_runtimes/specs/ui_plugins.py \\
17
+ --typescript-output src/specs/uiPlugins.ts
18
+ """
19
+
20
+ import argparse
21
+ import sys
22
+ from pathlib import Path
23
+ from typing import Any
24
+
25
+ import yaml
26
+ from versioning import ensure_spec_version, version_suffix
27
+
28
+
29
+ def load_plugin_specs(specs_dir: Path) -> list[dict[str, Any]]:
30
+ """Load all UI-plugin YAML specifications from a directory."""
31
+ specs = []
32
+ for yaml_file in sorted(specs_dir.glob("*.yaml")):
33
+ with open(yaml_file) as f:
34
+ spec = yaml.safe_load(f)
35
+ ensure_spec_version(spec)
36
+ if spec["id"] != yaml_file.stem:
37
+ raise ValueError(
38
+ f"{yaml_file.name}: the file is named for id {yaml_file.stem!r}, the spec says {spec['id']!r}"
39
+ )
40
+ specs.append(spec)
41
+ return specs
42
+
43
+
44
+ def _const_name(plugin_id: str) -> str:
45
+ return plugin_id.replace("-", "_").replace(".", "_").upper() + "_UI_PLUGIN"
46
+
47
+
48
+ def _py(value: str) -> str:
49
+ return '"' + value.replace("\\", "\\\\").replace('"', '\\"') + '"'
50
+
51
+
52
+ def _ts(value: str) -> str:
53
+ return "'" + value.replace("\\", "\\\\").replace("'", "\\'") + "'"
54
+
55
+
56
+ def generate_python_code(specs: list[dict[str, Any]]) -> str:
57
+ """Generate Python code from UI-plugin specifications."""
58
+ lines = [
59
+ "# Copyright (c) 2025-2026 Datalayer, Inc.",
60
+ "# Distributed under the terms of the Modified BSD License.",
61
+ '"""',
62
+ "UI Plugin Catalog.",
63
+ "",
64
+ "How an agent's answer becomes an interface: the protocols a host renders.",
65
+ "",
66
+ "This file is AUTO-GENERATED from YAML specifications.",
67
+ "DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
68
+ '"""',
69
+ "",
70
+ "from typing import Dict",
71
+ "",
72
+ "from agent_runtimes.types import UIPluginSpec",
73
+ "",
74
+ "",
75
+ "# " + "=" * 76,
76
+ "# UI Plugin Definitions",
77
+ "# " + "=" * 76,
78
+ "",
79
+ ]
80
+ for spec in specs:
81
+ const = _const_name(spec["id"]) + version_suffix(spec["version"])
82
+ lines.extend(
83
+ [
84
+ f"{const} = UIPluginSpec(",
85
+ f" id={_py(spec['id'])},",
86
+ f" version={_py(str(spec['version']))},",
87
+ f" name={_py(spec['name'])},",
88
+ f" description={_py(str(spec.get('description', '')).strip())},",
89
+ f" docs_url={_py(str(spec.get('docs_url', '')))},",
90
+ f" enabled={bool(spec.get('enabled', True))},",
91
+ ")",
92
+ "",
93
+ ]
94
+ )
95
+ lines.extend(
96
+ [
97
+ "",
98
+ "# " + "=" * 76,
99
+ "# UI Plugin Catalog",
100
+ "# " + "=" * 76,
101
+ "",
102
+ "UI_PLUGIN_CATALOGUE: Dict[str, UIPluginSpec] = {",
103
+ ]
104
+ )
105
+ for spec in specs:
106
+ lines.append(
107
+ f" {_py(spec['id'])}: {_const_name(spec['id']) + version_suffix(spec['version'])},"
108
+ )
109
+ lines.extend(
110
+ [
111
+ "}",
112
+ "",
113
+ "",
114
+ "def get_ui_plugin(plugin_id: str) -> UIPluginSpec | None:",
115
+ ' """The plugin an agent spec\'s `ui_plugin` names, or None."""',
116
+ " return UI_PLUGIN_CATALOGUE.get(plugin_id)",
117
+ "",
118
+ "",
119
+ "def list_ui_plugins() -> list[UIPluginSpec]:",
120
+ " return list(UI_PLUGIN_CATALOGUE.values())",
121
+ "",
122
+ ]
123
+ )
124
+ return "\n".join(lines)
125
+
126
+
127
+ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
128
+ """Generate TypeScript code from UI-plugin specifications."""
129
+ lines = [
130
+ "/*",
131
+ " * Copyright (c) 2025-2026 Datalayer, Inc.",
132
+ " * Distributed under the terms of the Modified BSD License.",
133
+ " */",
134
+ "",
135
+ "/**",
136
+ " * UI Plugin Catalog.",
137
+ " *",
138
+ " * How an agent's answer becomes an interface: the protocols a host renders.",
139
+ " *",
140
+ " * This file is AUTO-GENERATED from YAML specifications.",
141
+ " * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
142
+ " */",
143
+ "",
144
+ "import type { UIPluginSpec } from '../types/agentspecs';",
145
+ "",
146
+ ]
147
+ for spec in specs:
148
+ const = _const_name(spec["id"]) + version_suffix(spec["version"])
149
+ lines.extend(
150
+ [
151
+ f"export const {const}: UIPluginSpec = {{",
152
+ f" id: {_ts(spec['id'])},",
153
+ f" version: {_ts(str(spec['version']))},",
154
+ f" name: {_ts(spec['name'])},",
155
+ f" description: {_ts(str(spec.get('description', '')).strip())},",
156
+ f" docsUrl: {_ts(str(spec.get('docs_url', '')))},",
157
+ f" enabled: {'true' if spec.get('enabled', True) else 'false'},",
158
+ "};",
159
+ "",
160
+ ]
161
+ )
162
+ lines.append("export const UI_PLUGIN_CATALOGUE: Record<string, UIPluginSpec> = {")
163
+ for spec in specs:
164
+ lines.append(
165
+ f" {_ts(spec['id'])}: {_const_name(spec['id']) + version_suffix(spec['version'])},"
166
+ )
167
+ lines.extend(
168
+ [
169
+ "};",
170
+ "",
171
+ "/** The plugin an agent spec's `uiPlugin` names, or undefined. */",
172
+ "export function getUIPlugin(pluginId: string): UIPluginSpec | undefined {",
173
+ " return UI_PLUGIN_CATALOGUE[pluginId];",
174
+ "}",
175
+ "",
176
+ "export function listUIPlugins(): UIPluginSpec[] {",
177
+ " return Object.values(UI_PLUGIN_CATALOGUE);",
178
+ "}",
179
+ "",
180
+ ]
181
+ )
182
+ return "\n".join(lines)
183
+
184
+
185
+ def main():
186
+ parser = argparse.ArgumentParser(
187
+ description="Generate Python and TypeScript code from YAML UI-plugin specifications"
188
+ )
189
+ parser.add_argument(
190
+ "--specs-dir",
191
+ type=Path,
192
+ required=True,
193
+ help="Directory containing UI-plugin YAML files",
194
+ )
195
+ parser.add_argument(
196
+ "--python-output", type=Path, required=True, help="Output path for Python file"
197
+ )
198
+ parser.add_argument(
199
+ "--typescript-output",
200
+ type=Path,
201
+ required=True,
202
+ help="Output path for TypeScript file",
203
+ )
204
+ args = parser.parse_args()
205
+
206
+ if not args.specs_dir.exists():
207
+ print(f"Error: Specs directory not found: {args.specs_dir}", file=sys.stderr)
208
+ sys.exit(1)
209
+ specs = load_plugin_specs(args.specs_dir)
210
+ if not specs:
211
+ print(
212
+ f"Warning: No UI-plugin specifications found in {args.specs_dir}",
213
+ file=sys.stderr,
214
+ )
215
+ return
216
+ args.python_output.parent.mkdir(parents=True, exist_ok=True)
217
+ args.python_output.write_text(generate_python_code(specs))
218
+ print(f"Generated Python code: {args.python_output}")
219
+ args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
220
+ args.typescript_output.write_text(generate_typescript_code(specs))
221
+ print(f"Generated TypeScript code: {args.typescript_output}")
222
+ print(f"\n✓ Successfully generated code from {len(specs)} UI-plugin specs")
223
+
224
+
225
+ if __name__ == "__main__":
226
+ main()
@@ -441,9 +441,9 @@ color: "{color}"
441
441
  goal: >-
442
442
  {goal}
443
443
 
444
- # Protocols & UI Extensions
444
+ # Protocols & UI Plugins
445
445
  protocol: vercel-ai
446
- ui_extension: a2ui
446
+ ui_plugin: a2ui
447
447
 
448
448
  # Model configuration
449
449
  model_config: