@datalayer/agent-runtimes 1.3.113 → 1.4.0
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/chunks/{ChatView-D41Nx5rC.js → ChatView-BpKZPdcp.js} +4 -4
- package/dist-embed/datalayer-app-main.js +150 -150
- package/lib/apps/apps/appspec.d.ts +13 -0
- package/lib/apps/apps/appspec.js +125 -0
- package/lib/apps/apps/checks.d.ts +1 -1
- package/lib/apps/apps/checks.js +2 -2
- package/lib/apps/apps/customComponents.js +1 -1
- package/lib/apps/core/canvasBlocks.d.ts +3 -3
- package/lib/apps/core/canvasParts.d.ts +6 -4
- package/lib/apps/embed/AppEmbed.js +3 -7
- package/lib/apps/embed/embedSession.d.ts +8 -4
- package/lib/apps/embed/embedSession.js +16 -9
- package/lib/apps/plugins/a2ui-surface/AnswerShows.d.ts +21 -0
- package/lib/apps/plugins/a2ui-surface/AnswerShows.js +29 -0
- package/lib/apps/plugins/a2ui-surface/SurfaceToolResult.js +4 -7
- package/lib/apps/plugins/a2ui-surface/index.d.ts +2 -1
- package/lib/apps/plugins/a2ui-surface/index.js +10 -1
- package/lib/apps/plugins/a2ui-surface/toolResult.d.ts +20 -11
- package/lib/apps/plugins/a2ui-surface/toolResult.js +27 -11
- package/lib/apps/plugins/app-components/index.d.ts +1 -1
- package/lib/apps/plugins/app-components/index.js +2 -2
- package/lib/apps/plugins/app-elements/AppElements.d.ts +3 -3
- package/lib/apps/plugins/app-elements/AppElements.js +5 -20
- package/lib/apps/plugins/app-elements/QuestionView.d.ts +28 -0
- package/lib/apps/plugins/app-elements/QuestionView.js +57 -0
- package/lib/apps/plugins/app-elements/index.d.ts +7 -4
- package/lib/apps/plugins/app-elements/index.js +14 -5
- package/lib/apps/plugins/canvas-blocks/index.d.ts +13 -13
- package/lib/apps/plugins/canvas-blocks/index.js +24 -24
- package/lib/apps/plugins/canvas-parts/index.d.ts +7 -1
- package/lib/apps/plugins/canvas-parts/index.js +36 -0
- package/lib/apps/plugins/chat/ChatView.js +7 -0
- package/lib/chat/base/ChatBase.js +234 -43
- package/lib/chat/base/loopElement.d.ts +16 -17
- package/lib/chat/base/loopElement.js +11 -27
- package/lib/chat/base/loopStep.d.ts +15 -15
- package/lib/chat/base/loopStep.js +10 -13
- package/lib/chat/base/loopWindow.d.ts +15 -20
- package/lib/chat/base/loopWindow.js +26 -27
- package/lib/chat/base/uiOps.d.ts +96 -0
- package/lib/chat/base/uiOps.js +251 -0
- package/lib/chat/messages/ChatMessageList.d.ts +8 -1
- package/lib/chat/messages/ChatMessageList.js +4 -4
- package/lib/components/a2ui/datalayer/Chart.d.ts +1 -1
- package/lib/components/a2ui/datalayer/schema.js +1 -1
- package/lib/components/teams/AnswerSurfaces.d.ts +3 -2
- package/lib/components/teams/AnswerSurfaces.js +7 -7
- package/lib/components/teams/useA2ATeam.d.ts +1 -1
- package/lib/config/AgentConfiguration.d.ts +1 -1
- package/lib/protocols/AGUIAdapter.d.ts +7 -0
- package/lib/protocols/AGUIAdapter.js +43 -3
- package/lib/protocols/agentic-commerce/index.d.ts +5 -9
- package/lib/protocols/agentic-commerce/index.js +6 -10
- package/lib/protocols/commerce.d.ts +8 -9
- package/lib/protocols/commerce.js +29 -0
- package/lib/protocols/ucp/index.d.ts +5 -10
- package/lib/protocols/ucp/index.js +6 -11
- package/lib/specs/actions.d.ts +8 -0
- package/lib/specs/actions.js +56 -0
- package/lib/specs/agents/agents.js +338 -169
- package/lib/specs/apps.d.ts +1 -0
- package/lib/specs/apps.js +272 -0
- package/lib/specs/appspecSchema.js +125 -0
- package/lib/specs/cogs.js +6 -3
- package/lib/specs/index.d.ts +2 -1
- package/lib/specs/index.js +2 -1
- package/lib/specs/protocols.d.ts +24 -0
- package/lib/specs/protocols.js +197 -0
- package/lib/specs/ui.d.ts +21 -0
- package/lib/specs/{uiPlugins.js → ui.js} +14 -14
- package/lib/types/agentspecs.d.ts +72 -5
- package/lib/types/messages.d.ts +7 -0
- package/lib/types/protocol.d.ts +8 -0
- package/package.json +2 -2
- package/scripts/codegen/generate_agents.py +43 -8
- package/scripts/codegen/generate_apps.py +38 -1
- package/scripts/codegen/generate_protocols.py +207 -0
- package/scripts/codegen/generate_sandbox_agents.py +1 -1
- package/scripts/codegen/{generate_ui_plugins.py → generate_ui.py} +40 -40
- package/scripts/gen_workers.py +2 -2
- package/lib/chat/base/loopMessage.d.ts +0 -37
- package/lib/chat/base/loopMessage.js +0 -37
- package/lib/specs/uiPlugins.d.ts +0 -21
|
@@ -0,0 +1,207 @@
|
|
|
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 the YAML protocol specifications.
|
|
7
|
+
|
|
8
|
+
One YAML per agent protocol under ``agentspecs/protocols`` (AGENT_PROTOCOLS
|
|
9
|
+
PS-01); an agent spec's or an application's ``protocols`` names the ones it
|
|
10
|
+
speaks (PS-02).
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
python generate_protocols.py \\
|
|
14
|
+
--specs-dir agentspecs/agentspecs/protocols \\
|
|
15
|
+
--python-output agent_runtimes/specs/protocols.py \\
|
|
16
|
+
--typescript-output src/specs/protocols.ts
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
import yaml
|
|
25
|
+
from versioning import ensure_spec_version, version_suffix
|
|
26
|
+
|
|
27
|
+
LAYERS = ("transport", "consent", "identity", "commerce", "ui")
|
|
28
|
+
STATUSES = ("shipped", "planned")
|
|
29
|
+
BLOCKS = ("pap", "pact", "a2a")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def load_protocol_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
33
|
+
"""Every protocol spec of a directory, each named for its id, its layer, status and block known."""
|
|
34
|
+
specs = []
|
|
35
|
+
for yaml_file in sorted(specs_dir.glob("*.yaml")):
|
|
36
|
+
spec = yaml.safe_load(yaml_file.read_text()) or {}
|
|
37
|
+
ensure_spec_version(spec)
|
|
38
|
+
if spec["id"] != yaml_file.stem:
|
|
39
|
+
raise ValueError(
|
|
40
|
+
f"{yaml_file.name}: the file is named for {yaml_file.stem!r}, the spec says {spec['id']!r}"
|
|
41
|
+
)
|
|
42
|
+
if spec["layer"] not in LAYERS or spec["status"] not in STATUSES:
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"{yaml_file.name}: layer one of {LAYERS}, status one of {STATUSES}"
|
|
45
|
+
)
|
|
46
|
+
if spec.get("appspec_block") not in (None, *BLOCKS):
|
|
47
|
+
raise ValueError(f"{yaml_file.name}: appspec_block one of {BLOCKS}")
|
|
48
|
+
specs.append(spec)
|
|
49
|
+
return specs
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _const(spec: dict[str, Any]) -> str:
|
|
53
|
+
return (
|
|
54
|
+
spec["id"].replace("-", "_").upper()
|
|
55
|
+
+ "_PROTOCOL"
|
|
56
|
+
+ version_suffix(spec["version"])
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _s(value: Any) -> str:
|
|
61
|
+
return json.dumps(" ".join(str(value or "").split()), ensure_ascii=False)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
65
|
+
lines = [
|
|
66
|
+
"# Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
67
|
+
"# Distributed under the terms of the Modified BSD License.",
|
|
68
|
+
'"""',
|
|
69
|
+
"Protocol Catalog.",
|
|
70
|
+
"",
|
|
71
|
+
"The agent protocols Datalayer targets (AGENT_PROTOCOLS PS-01).",
|
|
72
|
+
"",
|
|
73
|
+
"This file is AUTO-GENERATED from YAML specifications.",
|
|
74
|
+
"DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
75
|
+
'"""',
|
|
76
|
+
"",
|
|
77
|
+
"from typing import Dict, List, Optional",
|
|
78
|
+
"",
|
|
79
|
+
"from agent_runtimes.types import ProtocolPackagesSpec, ProtocolSpec",
|
|
80
|
+
]
|
|
81
|
+
for spec in specs:
|
|
82
|
+
packages = spec.get("packages") or {}
|
|
83
|
+
block = spec.get("appspec_block")
|
|
84
|
+
lines += [
|
|
85
|
+
"",
|
|
86
|
+
f"{_const(spec)} = ProtocolSpec(",
|
|
87
|
+
f" id={_s(spec['id'])},",
|
|
88
|
+
f" version={_s(spec['version'])},",
|
|
89
|
+
f" name={_s(spec['name'])},",
|
|
90
|
+
f" description={_s(spec.get('description'))},",
|
|
91
|
+
f" publisher={_s(spec.get('publisher'))},",
|
|
92
|
+
f" layer={_s(spec['layer'])},",
|
|
93
|
+
f" spec_url={_s(spec.get('spec_url'))},",
|
|
94
|
+
f" spec_version={_s(spec.get('spec_version'))},",
|
|
95
|
+
f" status={_s(spec['status'])},",
|
|
96
|
+
f" connects={_s(spec.get('connects'))},",
|
|
97
|
+
" packages=ProtocolPackagesSpec(",
|
|
98
|
+
f" python={json.dumps(list(packages.get('python') or []))},",
|
|
99
|
+
f" typescript={json.dumps(list(packages.get('typescript') or []))},",
|
|
100
|
+
" ),",
|
|
101
|
+
f" protocol_tools={json.dumps(list(spec.get('protocol_tools') or []))},",
|
|
102
|
+
f" appspec_block={_s(block) if block else 'None'},",
|
|
103
|
+
")",
|
|
104
|
+
]
|
|
105
|
+
lines += [
|
|
106
|
+
"",
|
|
107
|
+
"",
|
|
108
|
+
"PROTOCOL_CATALOGUE: Dict[str, ProtocolSpec] = {",
|
|
109
|
+
*[f" {_s(spec['id'])}: {_const(spec)}," for spec in specs],
|
|
110
|
+
"}",
|
|
111
|
+
"",
|
|
112
|
+
"",
|
|
113
|
+
"def get_protocol(protocol_id: str) -> Optional[ProtocolSpec]:",
|
|
114
|
+
' """A protocol by id, or None."""',
|
|
115
|
+
" return PROTOCOL_CATALOGUE.get(protocol_id)",
|
|
116
|
+
"",
|
|
117
|
+
"",
|
|
118
|
+
"def list_protocols() -> List[ProtocolSpec]:",
|
|
119
|
+
' """Every protocol of the catalogue."""',
|
|
120
|
+
" return list(PROTOCOL_CATALOGUE.values())",
|
|
121
|
+
"",
|
|
122
|
+
]
|
|
123
|
+
return "\n".join(lines)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _t(value: Any) -> str:
|
|
127
|
+
return json.dumps(" ".join(str(value or "").split()), ensure_ascii=False)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
131
|
+
lines = [
|
|
132
|
+
"/*",
|
|
133
|
+
" * Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
134
|
+
" * Distributed under the terms of the Modified BSD License.",
|
|
135
|
+
" */",
|
|
136
|
+
"",
|
|
137
|
+
"/**",
|
|
138
|
+
" * Protocol Catalog.",
|
|
139
|
+
" *",
|
|
140
|
+
" * The agent protocols Datalayer targets (AGENT_PROTOCOLS PS-01).",
|
|
141
|
+
" *",
|
|
142
|
+
" * This file is AUTO-GENERATED from YAML specifications.",
|
|
143
|
+
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
144
|
+
" */",
|
|
145
|
+
"",
|
|
146
|
+
"import type { ProtocolSpec } from '../types/agentspecs';",
|
|
147
|
+
]
|
|
148
|
+
for spec in specs:
|
|
149
|
+
packages = spec.get("packages") or {}
|
|
150
|
+
block = spec.get("appspec_block")
|
|
151
|
+
lines += [
|
|
152
|
+
"",
|
|
153
|
+
f"export const {_const(spec)}: ProtocolSpec = {{",
|
|
154
|
+
f" id: {_t(spec['id'])},",
|
|
155
|
+
f" version: {_t(spec['version'])},",
|
|
156
|
+
f" name: {_t(spec['name'])},",
|
|
157
|
+
f" description: {_t(spec.get('description'))},",
|
|
158
|
+
f" publisher: {_t(spec.get('publisher'))},",
|
|
159
|
+
f" layer: {_t(spec['layer'])},",
|
|
160
|
+
f" specUrl: {_t(spec.get('spec_url'))},",
|
|
161
|
+
f" specVersion: {_t(spec.get('spec_version'))},",
|
|
162
|
+
f" status: {_t(spec['status'])},",
|
|
163
|
+
f" connects: {_t(spec.get('connects'))},",
|
|
164
|
+
" packages: {",
|
|
165
|
+
f" python: {json.dumps(list(packages.get('python') or []))},",
|
|
166
|
+
f" typescript: {json.dumps(list(packages.get('typescript') or []))},",
|
|
167
|
+
" },",
|
|
168
|
+
f" protocolTools: {json.dumps(list(spec.get('protocol_tools') or []))},",
|
|
169
|
+
*([f" appspecBlock: {_t(block)},"] if block else []),
|
|
170
|
+
"};",
|
|
171
|
+
]
|
|
172
|
+
lines += [
|
|
173
|
+
"",
|
|
174
|
+
"export const PROTOCOL_CATALOGUE: Record<string, ProtocolSpec> = {",
|
|
175
|
+
*[f" {_t(spec['id'])}: {_const(spec)}," for spec in specs],
|
|
176
|
+
"};",
|
|
177
|
+
"",
|
|
178
|
+
"/** A protocol by id. */",
|
|
179
|
+
"export function getProtocol(protocolId: string): ProtocolSpec | undefined {",
|
|
180
|
+
" return PROTOCOL_CATALOGUE[protocolId];",
|
|
181
|
+
"}",
|
|
182
|
+
"",
|
|
183
|
+
"/** Every protocol of the catalogue. */",
|
|
184
|
+
"export function listProtocolSpecs(): ProtocolSpec[] {",
|
|
185
|
+
" return Object.values(PROTOCOL_CATALOGUE);",
|
|
186
|
+
"}",
|
|
187
|
+
"",
|
|
188
|
+
]
|
|
189
|
+
return "\n".join(lines)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def main() -> None:
|
|
193
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
194
|
+
parser.add_argument("--specs-dir", type=Path, required=True)
|
|
195
|
+
parser.add_argument("--python-output", type=Path, required=True)
|
|
196
|
+
parser.add_argument("--typescript-output", type=Path, required=True)
|
|
197
|
+
args = parser.parse_args()
|
|
198
|
+
specs = load_protocol_specs(args.specs_dir)
|
|
199
|
+
args.python_output.write_text(generate_python_code(specs))
|
|
200
|
+
args.typescript_output.write_text(generate_typescript_code(specs))
|
|
201
|
+
print(
|
|
202
|
+
f"Generated {len(specs)} protocols: {args.python_output}, {args.typescript_output}"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
if __name__ == "__main__":
|
|
207
|
+
main()
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
# Distributed under the terms of the Modified BSD License.
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
|
-
Generate Python and TypeScript code from YAML UI
|
|
6
|
+
Generate Python and TypeScript code from YAML UI specifications.
|
|
7
7
|
|
|
8
|
-
A UI
|
|
8
|
+
A UI spec is how an agent's answer becomes an interface rather than text —
|
|
9
9
|
a protocol the host knows how to render (A2UI, MCP Apps, MCP UI). One YAML per
|
|
10
|
-
plugin under ``agentspecs/ui
|
|
11
|
-
one. A
|
|
10
|
+
plugin under ``agentspecs/ui``; an agent spec's ``ui`` names
|
|
11
|
+
one. A UI spec hosts the visual components it renders (LOOP C-13).
|
|
12
12
|
|
|
13
13
|
Usage:
|
|
14
|
-
python
|
|
15
|
-
--specs-dir agentspecs/agentspecs/ui
|
|
16
|
-
--python-output agent_runtimes/specs/
|
|
17
|
-
--typescript-output src/specs/
|
|
14
|
+
python generate_ui.py \\
|
|
15
|
+
--specs-dir agentspecs/agentspecs/ui \\
|
|
16
|
+
--python-output agent_runtimes/specs/ui.py \\
|
|
17
|
+
--typescript-output src/specs/ui.ts
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
import argparse
|
|
@@ -29,7 +29,7 @@ from versioning import ensure_spec_version, version_suffix
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def load_plugin_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
32
|
-
"""Load all UI
|
|
32
|
+
"""Load all UI YAML specifications from a directory."""
|
|
33
33
|
specs = []
|
|
34
34
|
for yaml_file in sorted(specs_dir.glob("*.yaml")):
|
|
35
35
|
with open(yaml_file) as f:
|
|
@@ -44,7 +44,7 @@ def load_plugin_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def _const_name(plugin_id: str) -> str:
|
|
47
|
-
return plugin_id.replace("-", "_").replace(".", "_").upper() + "
|
|
47
|
+
return plugin_id.replace("-", "_").replace(".", "_").upper() + "_UI"
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def _py(value: str) -> str:
|
|
@@ -196,12 +196,12 @@ def _py_calls(specs: list[dict[str, Any]]) -> list[str]:
|
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
199
|
-
"""Generate Python code from UI
|
|
199
|
+
"""Generate Python code from UI specifications."""
|
|
200
200
|
lines = [
|
|
201
201
|
"# Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
202
202
|
"# Distributed under the terms of the Modified BSD License.",
|
|
203
203
|
'"""',
|
|
204
|
-
"UI
|
|
204
|
+
"UI Catalog.",
|
|
205
205
|
"",
|
|
206
206
|
"How an agent's answer becomes an interface: the protocols a host renders.",
|
|
207
207
|
"",
|
|
@@ -211,10 +211,10 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
211
211
|
"",
|
|
212
212
|
"from typing import Any, Callable, Dict, List, Literal, Mapping, Optional, Union",
|
|
213
213
|
"",
|
|
214
|
-
"from agent_runtimes.types import ComponentBindingsSpec, ComponentSpec,
|
|
214
|
+
"from agent_runtimes.types import ComponentBindingsSpec, ComponentSpec, UISpec",
|
|
215
215
|
"",
|
|
216
216
|
"# " + "=" * 76,
|
|
217
|
-
"# UI
|
|
217
|
+
"# UI Definitions",
|
|
218
218
|
"# " + "=" * 76,
|
|
219
219
|
"",
|
|
220
220
|
]
|
|
@@ -222,7 +222,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
222
222
|
const = _const_name(spec["id"]) + version_suffix(spec["version"])
|
|
223
223
|
lines.extend(
|
|
224
224
|
[
|
|
225
|
-
f"{const} =
|
|
225
|
+
f"{const} = UISpec(",
|
|
226
226
|
f" id={_py(spec['id'])},",
|
|
227
227
|
f" version={_py(str(spec['version']))},",
|
|
228
228
|
f" name={_py(spec['name'])},",
|
|
@@ -241,10 +241,10 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
241
241
|
[
|
|
242
242
|
"",
|
|
243
243
|
"# " + "=" * 76,
|
|
244
|
-
"# UI
|
|
244
|
+
"# UI Catalog",
|
|
245
245
|
"# " + "=" * 76,
|
|
246
246
|
"",
|
|
247
|
-
"
|
|
247
|
+
"UI_CATALOGUE: Dict[str, UISpec] = {",
|
|
248
248
|
]
|
|
249
249
|
)
|
|
250
250
|
for spec in specs:
|
|
@@ -256,20 +256,20 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
256
256
|
"}",
|
|
257
257
|
"",
|
|
258
258
|
"",
|
|
259
|
-
"def
|
|
260
|
-
' """The
|
|
261
|
-
" return
|
|
259
|
+
"def get_ui(plugin_id: str) -> UISpec | None:",
|
|
260
|
+
' """The UI an agent spec\'s `ui` names, or None."""',
|
|
261
|
+
" return UI_CATALOGUE.get(plugin_id)",
|
|
262
262
|
"",
|
|
263
263
|
"",
|
|
264
|
-
"def
|
|
265
|
-
" return list(
|
|
264
|
+
"def list_ui() -> list[UISpec]:",
|
|
265
|
+
" return list(UI_CATALOGUE.values())",
|
|
266
266
|
"",
|
|
267
267
|
"",
|
|
268
|
-
"#: The visual components the enabled UI
|
|
268
|
+
"#: The visual components the enabled UI specs render, by the name a",
|
|
269
269
|
"#: surface gives them (LOOP C-13).",
|
|
270
270
|
"COMPONENT_CATALOGUE: Dict[str, ComponentSpec] = {",
|
|
271
271
|
" component.id: component",
|
|
272
|
-
" for plugin in
|
|
272
|
+
" for plugin in UI_CATALOGUE.values()",
|
|
273
273
|
" if plugin.enabled",
|
|
274
274
|
" for component in plugin.components",
|
|
275
275
|
"}",
|
|
@@ -290,7 +290,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
293
|
-
"""Generate TypeScript code from UI
|
|
293
|
+
"""Generate TypeScript code from UI specifications."""
|
|
294
294
|
lines = [
|
|
295
295
|
"/*",
|
|
296
296
|
" * Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
@@ -298,7 +298,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
298
298
|
" */",
|
|
299
299
|
"",
|
|
300
300
|
"/**",
|
|
301
|
-
" * UI
|
|
301
|
+
" * UI Catalog.",
|
|
302
302
|
" *",
|
|
303
303
|
" * How an agent's answer becomes an interface: the protocols a host renders.",
|
|
304
304
|
" *",
|
|
@@ -306,14 +306,14 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
306
306
|
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
307
307
|
" */",
|
|
308
308
|
"",
|
|
309
|
-
"import type { ComponentSpec,
|
|
309
|
+
"import type { ComponentSpec, UISpec } from '../types/agentspecs';",
|
|
310
310
|
"",
|
|
311
311
|
]
|
|
312
312
|
for spec in specs:
|
|
313
313
|
const = _const_name(spec["id"]) + version_suffix(spec["version"])
|
|
314
314
|
lines.extend(
|
|
315
315
|
[
|
|
316
|
-
f"export const {const}:
|
|
316
|
+
f"export const {const}: UISpec = {{",
|
|
317
317
|
f" id: {_ts(spec['id'])},",
|
|
318
318
|
f" version: {_ts(str(spec['version']))},",
|
|
319
319
|
f" name: {_ts(spec['name'])},",
|
|
@@ -326,7 +326,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
326
326
|
"",
|
|
327
327
|
]
|
|
328
328
|
)
|
|
329
|
-
lines.append("export const
|
|
329
|
+
lines.append("export const UI_CATALOGUE: Record<string, UISpec> = {")
|
|
330
330
|
for spec in specs:
|
|
331
331
|
lines.append(
|
|
332
332
|
f" {_ts(spec['id'])}: {_const_name(spec['id']) + version_suffix(spec['version'])},"
|
|
@@ -335,18 +335,18 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
335
335
|
[
|
|
336
336
|
"};",
|
|
337
337
|
"",
|
|
338
|
-
"/** The
|
|
339
|
-
"export function
|
|
340
|
-
" return
|
|
338
|
+
"/** The UI an agent spec's `ui` names, or undefined. */",
|
|
339
|
+
"export function getUI(pluginId: string): UISpec | undefined {",
|
|
340
|
+
" return UI_CATALOGUE[pluginId];",
|
|
341
341
|
"}",
|
|
342
342
|
"",
|
|
343
|
-
"export function
|
|
344
|
-
" return Object.values(
|
|
343
|
+
"export function listUI(): UISpec[] {",
|
|
344
|
+
" return Object.values(UI_CATALOGUE);",
|
|
345
345
|
"}",
|
|
346
346
|
"",
|
|
347
|
-
"/** The visual components the enabled UI
|
|
347
|
+
"/** The visual components the enabled UI specs render, by the name a surface gives them (LOOP C-13). */",
|
|
348
348
|
"export const COMPONENT_CATALOGUE: Record<string, ComponentSpec> = Object.fromEntries(",
|
|
349
|
-
" Object.values(
|
|
349
|
+
" Object.values(UI_CATALOGUE)",
|
|
350
350
|
" .filter(plugin => plugin.enabled)",
|
|
351
351
|
" .flatMap(plugin => plugin.components.map(component => [component.id, component])),",
|
|
352
352
|
");",
|
|
@@ -367,13 +367,13 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
367
367
|
|
|
368
368
|
def main():
|
|
369
369
|
parser = argparse.ArgumentParser(
|
|
370
|
-
description="Generate Python and TypeScript code from YAML UI
|
|
370
|
+
description="Generate Python and TypeScript code from YAML UI specifications"
|
|
371
371
|
)
|
|
372
372
|
parser.add_argument(
|
|
373
373
|
"--specs-dir",
|
|
374
374
|
type=Path,
|
|
375
375
|
required=True,
|
|
376
|
-
help="Directory containing UI
|
|
376
|
+
help="Directory containing UI YAML files",
|
|
377
377
|
)
|
|
378
378
|
parser.add_argument(
|
|
379
379
|
"--python-output", type=Path, required=True, help="Output path for Python file"
|
|
@@ -392,7 +392,7 @@ def main():
|
|
|
392
392
|
specs = load_plugin_specs(args.specs_dir)
|
|
393
393
|
if not specs:
|
|
394
394
|
print(
|
|
395
|
-
f"Warning: No UI
|
|
395
|
+
f"Warning: No UI specifications found in {args.specs_dir}",
|
|
396
396
|
file=sys.stderr,
|
|
397
397
|
)
|
|
398
398
|
return
|
|
@@ -402,7 +402,7 @@ def main():
|
|
|
402
402
|
args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
|
|
403
403
|
args.typescript_output.write_text(generate_typescript_code(specs))
|
|
404
404
|
print(f"Generated TypeScript code: {args.typescript_output}")
|
|
405
|
-
print(f"\n✓ Successfully generated code from {len(specs)} UI
|
|
405
|
+
print(f"\n✓ Successfully generated code from {len(specs)} UI specs")
|
|
406
406
|
|
|
407
407
|
|
|
408
408
|
if __name__ == "__main__":
|
package/scripts/gen_workers.py
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message of an application's code that changed after it was sent
|
|
3
|
-
* (LOOP P-15).
|
|
4
|
-
*
|
|
5
|
-
* The session API says a message's author, or that it was taken away, with a
|
|
6
|
-
* `CUSTOM` event named `loop.message` — `{id, author}` or `{id, removed: true}`
|
|
7
|
-
* — which the AG-UI adapter hands on as an `activity`. A message whose text
|
|
8
|
-
* changed needs nothing here: it is written again under its id, and the chat
|
|
9
|
-
* draws it in place.
|
|
10
|
-
*/
|
|
11
|
-
import type { MessageSpeaker } from '../../types/messages';
|
|
12
|
-
/** The `CUSTOM` event's name. */
|
|
13
|
-
export declare const LOOP_MESSAGE = "loop.message";
|
|
14
|
-
/** What changed about a message already in the conversation. */
|
|
15
|
-
export type LoopMessageChange = {
|
|
16
|
-
id: string;
|
|
17
|
-
removed: true;
|
|
18
|
-
} | {
|
|
19
|
-
id: string;
|
|
20
|
-
author: string;
|
|
21
|
-
};
|
|
22
|
-
/** The change an activity says, or `null` when it says none. */
|
|
23
|
-
export declare function loopMessageChange(activity: {
|
|
24
|
-
type: string;
|
|
25
|
-
data: unknown;
|
|
26
|
-
} | undefined): LoopMessageChange | null;
|
|
27
|
-
/** Who a message is by, as the chat draws a named voice. */
|
|
28
|
-
export declare function speakerOf(author: string): MessageSpeaker;
|
|
29
|
-
/**
|
|
30
|
-
* The conversation with the change made: the message taken away, or given its
|
|
31
|
-
* author. Items that are not that message — tool calls among them — are left
|
|
32
|
-
* as they are.
|
|
33
|
-
*/
|
|
34
|
-
export declare function withLoopMessage<T extends {
|
|
35
|
-
id?: string;
|
|
36
|
-
speaker?: MessageSpeaker;
|
|
37
|
-
}>(items: T[], change: LoopMessageChange): T[];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/** The `CUSTOM` event's name. */
|
|
6
|
-
export const LOOP_MESSAGE = 'loop.message';
|
|
7
|
-
/** The change an activity says, or `null` when it says none. */
|
|
8
|
-
export function loopMessageChange(activity) {
|
|
9
|
-
if (!activity || activity.type !== LOOP_MESSAGE)
|
|
10
|
-
return null;
|
|
11
|
-
const data = activity.data;
|
|
12
|
-
if (!data || typeof data.id !== 'string' || !data.id)
|
|
13
|
-
return null;
|
|
14
|
-
if (data.removed === true)
|
|
15
|
-
return { id: data.id, removed: true };
|
|
16
|
-
if (typeof data.author === 'string' && data.author.trim()) {
|
|
17
|
-
return { id: data.id, author: data.author.trim() };
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
/** Who a message is by, as the chat draws a named voice. */
|
|
22
|
-
export function speakerOf(author) {
|
|
23
|
-
return { id: `author:${author}`, name: author };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The conversation with the change made: the message taken away, or given its
|
|
27
|
-
* author. Items that are not that message — tool calls among them — are left
|
|
28
|
-
* as they are.
|
|
29
|
-
*/
|
|
30
|
-
export function withLoopMessage(items, change) {
|
|
31
|
-
if ('removed' in change) {
|
|
32
|
-
return items.filter(item => item.id !== change.id);
|
|
33
|
-
}
|
|
34
|
-
return items.map(item => item.id === change.id
|
|
35
|
-
? { ...item, speaker: speakerOf(change.author) }
|
|
36
|
-
: item);
|
|
37
|
-
}
|
package/lib/specs/uiPlugins.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UI Plugin Catalog.
|
|
3
|
-
*
|
|
4
|
-
* How an agent's answer becomes an interface: the protocols a host renders.
|
|
5
|
-
*
|
|
6
|
-
* This file is AUTO-GENERATED from YAML specifications.
|
|
7
|
-
* DO NOT EDIT MANUALLY - run 'make specs' to regenerate.
|
|
8
|
-
*/
|
|
9
|
-
import type { ComponentSpec, UIPluginSpec } from '../types/agentspecs';
|
|
10
|
-
export declare const A2UI_UI_PLUGIN_0_0_1: UIPluginSpec;
|
|
11
|
-
export declare const MCP_APPS_UI_PLUGIN_0_0_1: UIPluginSpec;
|
|
12
|
-
export declare const MCP_UI_UI_PLUGIN_0_0_1: UIPluginSpec;
|
|
13
|
-
export declare const UI_PLUGIN_CATALOGUE: Record<string, UIPluginSpec>;
|
|
14
|
-
/** The plugin an agent spec's `uiPlugin` names, or undefined. */
|
|
15
|
-
export declare function getUIPlugin(pluginId: string): UIPluginSpec | undefined;
|
|
16
|
-
export declare function listUIPlugins(): UIPluginSpec[];
|
|
17
|
-
/** The visual components the enabled UI plugins render, by the name a surface gives them (LOOP C-13). */
|
|
18
|
-
export declare const COMPONENT_CATALOGUE: Record<string, ComponentSpec>;
|
|
19
|
-
/** The component a layout names, or undefined. */
|
|
20
|
-
export declare function getComponent(name: string): ComponentSpec | undefined;
|
|
21
|
-
export declare function listComponents(): ComponentSpec[];
|