@copilotkit/shared 1.83.0 → 1.84.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.
Files changed (90) hide show
  1. package/dist/a2ui-envelope.cjs +2 -2
  2. package/dist/a2ui-envelope.cjs.map +1 -1
  3. package/dist/a2ui-envelope.d.cts +1 -1
  4. package/dist/a2ui-envelope.d.cts.map +1 -1
  5. package/dist/a2ui-envelope.d.mts +1 -1
  6. package/dist/a2ui-envelope.d.mts.map +1 -1
  7. package/dist/a2ui-envelope.mjs +2 -2
  8. package/dist/a2ui-envelope.mjs.map +1 -1
  9. package/dist/a2ui-prompts.cjs +21 -62
  10. package/dist/a2ui-prompts.cjs.map +1 -1
  11. package/dist/a2ui-prompts.d.cts +8 -1
  12. package/dist/a2ui-prompts.d.cts.map +1 -1
  13. package/dist/a2ui-prompts.d.mts +8 -1
  14. package/dist/a2ui-prompts.d.mts.map +1 -1
  15. package/dist/a2ui-prompts.mjs +22 -62
  16. package/dist/a2ui-prompts.mjs.map +1 -1
  17. package/dist/generative-ui/basic-functions.cjs +1 -1
  18. package/dist/generative-ui/basic-functions.cjs.map +1 -1
  19. package/dist/generative-ui/basic-functions.mjs +1 -1
  20. package/dist/generative-ui/basic-functions.mjs.map +1 -1
  21. package/dist/generative-ui/compact-schema.cjs +187 -0
  22. package/dist/generative-ui/compact-schema.cjs.map +1 -0
  23. package/dist/generative-ui/compact-schema.d.cts +55 -0
  24. package/dist/generative-ui/compact-schema.d.cts.map +1 -0
  25. package/dist/generative-ui/compact-schema.d.mts +55 -0
  26. package/dist/generative-ui/compact-schema.d.mts.map +1 -0
  27. package/dist/generative-ui/compact-schema.mjs +185 -0
  28. package/dist/generative-ui/compact-schema.mjs.map +1 -0
  29. package/dist/generative-ui/prompt-spec.cjs +225 -0
  30. package/dist/generative-ui/prompt-spec.cjs.map +1 -0
  31. package/dist/generative-ui/prompt-spec.d.cts +94 -0
  32. package/dist/generative-ui/prompt-spec.d.cts.map +1 -0
  33. package/dist/generative-ui/prompt-spec.d.mts +94 -0
  34. package/dist/generative-ui/prompt-spec.d.mts.map +1 -0
  35. package/dist/generative-ui/prompt-spec.mjs +220 -0
  36. package/dist/generative-ui/prompt-spec.mjs.map +1 -0
  37. package/dist/generative-ui/prompt.cjs +10 -36
  38. package/dist/generative-ui/prompt.cjs.map +1 -1
  39. package/dist/generative-ui/prompt.d.cts +2 -1
  40. package/dist/generative-ui/prompt.d.cts.map +1 -1
  41. package/dist/generative-ui/prompt.d.mts +2 -1
  42. package/dist/generative-ui/prompt.d.mts.map +1 -1
  43. package/dist/generative-ui/prompt.mjs +12 -38
  44. package/dist/generative-ui/prompt.mjs.map +1 -1
  45. package/dist/generative-ui/schema-render.cjs +242 -0
  46. package/dist/generative-ui/schema-render.cjs.map +1 -0
  47. package/dist/generative-ui/schema-render.d.cts +44 -0
  48. package/dist/generative-ui/schema-render.d.cts.map +1 -0
  49. package/dist/generative-ui/schema-render.d.mts +44 -0
  50. package/dist/generative-ui/schema-render.d.mts.map +1 -0
  51. package/dist/generative-ui/schema-render.mjs +239 -0
  52. package/dist/generative-ui/schema-render.mjs.map +1 -0
  53. package/dist/generative-ui/types.cjs +2 -2
  54. package/dist/generative-ui/types.cjs.map +1 -1
  55. package/dist/generative-ui/types.d.cts +7 -7
  56. package/dist/generative-ui/types.d.cts.map +1 -1
  57. package/dist/generative-ui/types.d.mts +7 -7
  58. package/dist/generative-ui/types.d.mts.map +1 -1
  59. package/dist/generative-ui/types.mjs +2 -2
  60. package/dist/generative-ui/types.mjs.map +1 -1
  61. package/dist/index.cjs +14 -0
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.cts +4 -1
  64. package/dist/index.d.cts.map +1 -1
  65. package/dist/index.d.mts +4 -1
  66. package/dist/index.d.mts.map +1 -1
  67. package/dist/index.mjs +4 -1
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/index.umd.js +756 -165
  70. package/dist/index.umd.js.map +1 -1
  71. package/dist/package.cjs +1 -1
  72. package/dist/package.mjs +1 -1
  73. package/package.json +1 -1
  74. package/src/__tests__/a2ui-envelope.test.ts +18 -13
  75. package/src/__tests__/a2ui-prompts.test.ts +47 -14
  76. package/src/__tests__/fixtures/prompt-goldens.json +354 -0
  77. package/src/__tests__/prompt-spec.test.ts +191 -0
  78. package/src/__tests__/schema-render.test.ts +245 -0
  79. package/src/a2ui-envelope.ts +5 -5
  80. package/src/a2ui-prompts.ts +47 -96
  81. package/src/generative-ui/__tests__/render-ui-args.test.ts +7 -7
  82. package/src/generative-ui/__tests__/validate-operation.test.ts +19 -13
  83. package/src/generative-ui/basic-functions.ts +1 -1
  84. package/src/generative-ui/compact-schema.ts +277 -0
  85. package/src/generative-ui/index.ts +3 -0
  86. package/src/generative-ui/prompt-spec.ts +335 -0
  87. package/src/generative-ui/prompt.ts +25 -75
  88. package/src/generative-ui/schema-render.ts +374 -0
  89. package/src/generative-ui/types.ts +10 -7
  90. package/src/utils/__tests__/conditions.test.ts +153 -43
@@ -0,0 +1,374 @@
1
+ import { functionCallers } from "./basic-functions";
2
+ import {
3
+ buildCompactGenerativeUISchema,
4
+ compactProps,
5
+ compactType,
6
+ } from "./compact-schema";
7
+ import type { GenerativeUISchemaSettings } from "./prompt-spec";
8
+ import { GENERATIVE_UI_AGENT_FUNCTION_CALLS } from "./types";
9
+ import type {
10
+ GenerativeUIComponentManifest,
11
+ GenerativeUIJSONSchema,
12
+ GenerativeUIManifest,
13
+ } from "./types";
14
+
15
+ type SchemaManifest = Pick<
16
+ GenerativeUIManifest,
17
+ "catalogId" | "components" | "functions" | "targets" | "surfaces"
18
+ >;
19
+
20
+ /** An own key (shared compiles to ES2017, which has no Object.hasOwn). */
21
+ const hasOwn = (target: object, key: string) =>
22
+ Object.prototype.hasOwnProperty.call(target, key);
23
+
24
+ function isRecord(value: unknown): value is Record<string, unknown> {
25
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
+ }
27
+
28
+ /** The props schema without the description of each prop. */
29
+ function withoutPropDescriptions(
30
+ schema: GenerativeUIJSONSchema,
31
+ ): GenerativeUIJSONSchema {
32
+ if (!isRecord(schema.properties)) return schema;
33
+ return {
34
+ ...schema,
35
+ properties: Object.fromEntries(
36
+ Object.entries(schema.properties).map(([key, value]) => {
37
+ if (!isRecord(value)) return [key, value];
38
+ const { description: _description, ...rest } = value;
39
+ return [key, rest];
40
+ }),
41
+ ),
42
+ };
43
+ }
44
+
45
+ /** The short signature of a function: its built-in signature, or its schema made short. */
46
+ function functionSignature(fn: GenerativeUIManifest["functions"][string]) {
47
+ const signature = fn.parameters.description;
48
+ const hasSignature =
49
+ typeof signature === "string" &&
50
+ signature.startsWith("{") &&
51
+ Object.keys(fn.parameters).length === 2;
52
+ return hasSignature ? signature : compactType(fn.parameters, 0);
53
+ }
54
+
55
+ /**
56
+ * A function name with its parameters: `pick{ id: string }`, `clearCart{}`
57
+ * for no arguments, `setVolume(number)` for a parameter that is not an object.
58
+ */
59
+ function nameWithParameters(name: string, parameters: string) {
60
+ if (parameters.startsWith("{")) return `${name}${parameters}`;
61
+ if (parameters === "object") return `${name}{}`;
62
+ return `${name}(${parameters})`;
63
+ }
64
+
65
+ /**
66
+ * One component as a TypeScript-like signature line, with its events and
67
+ * slots on the lines below:
68
+ * `- Text(text?: string // The text): Shows text`.
69
+ */
70
+ function signatureLines(
71
+ name: string,
72
+ component: GenerativeUIComponentManifest,
73
+ settings: GenerativeUISchemaSettings,
74
+ ) {
75
+ const props = Object.entries(
76
+ compactProps(component.props, settings.propDescriptions),
77
+ ).map(([key, type]) => `${key}: ${type}`);
78
+ const lines = [
79
+ `- ${name}(${props.join(", ")})${component.description ? `: ${oneLine(component.description)}` : ""}`,
80
+ ];
81
+ const events = Object.entries(component.events ?? {}).map(
82
+ ([event, definition]) =>
83
+ `${event}(${definition.description ? oneLine(definition.description) : compactType(definition.parameters, 0)})`,
84
+ );
85
+ if (events.length > 0) lines.push(` events: ${events.join(", ")}`);
86
+ const slots = Object.entries(component.slots ?? {}).map(
87
+ ([slot, kind]) => `${slot} (${kind})`,
88
+ );
89
+ if (slots.length > 0) lines.push(` slots: ${slots.join(", ")}`);
90
+ return lines;
91
+ }
92
+
93
+ /** The whole schema as signature text: targets, functions, components, surfaces. */
94
+ function signatureSchema(
95
+ manifest: SchemaManifest,
96
+ settings: GenerativeUISchemaSettings,
97
+ ) {
98
+ const targets = manifest.targets.map((t) => {
99
+ const limit = t.components ? `; only ${t.components.join(", ")}` : "";
100
+ return `- ${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
101
+ });
102
+ const functions = Object.entries(manifest.functions).map(([name, fn]) => {
103
+ const callers = functionCallers(fn);
104
+ const who =
105
+ callers.agent && GENERATIVE_UI_AGENT_FUNCTION_CALLS
106
+ ? callers.renderer
107
+ ? " (UI or agent)"
108
+ : " (agent only)"
109
+ : "";
110
+ return `- ${nameWithParameters(name, functionSignature(fn))}${who}${fn.description ? `: ${oneLine(fn.description)}` : ""}`;
111
+ });
112
+ const components = Object.entries(manifest.components).flatMap(
113
+ ([name, component]) => signatureLines(name, component, settings),
114
+ );
115
+ const surfaces = Object.entries(manifest.surfaces).map(
116
+ ([id, s]) =>
117
+ `- ${id} (target ${s.target})${s.status ? ` status: ${s.status}` : ""}${s.dataModel ? ` user values: ${JSON.stringify(s.dataModel)}` : ""}${(s.rejected ?? []).map((r) => ` rejected: ${r}`).join("")}`,
118
+ );
119
+ return [
120
+ `Catalog: ${manifest.catalogId}`,
121
+ `Targets:\n${targets.join("\n") || "- none"}`,
122
+ `Functions:\n${functions.join("\n") || "- none"}`,
123
+ `Components:\n${components.join("\n") || "- none"}`,
124
+ `Surfaces:\n${surfaces.join("\n") || "- none"}`,
125
+ ].join("\n\n");
126
+ }
127
+
128
+ /** A description on one line, so its lines cannot read as new entries. */
129
+ function oneLine(text: string) {
130
+ return text.replace(/\s*\n\s*/g, " ");
131
+ }
132
+
133
+ /** Values that would read as a type or a number once their quotes are gone. */
134
+ const AMBIGUOUS_VALUE =
135
+ /^(?:string|number|integer|boolean|true|false|null|object|array|unknown|any|-?\d[\d.]*)$/;
136
+
137
+ /**
138
+ * A compact type with bare enum values and tight unions:
139
+ * `"sm" | "md" | "lg"` becomes `sm|md|lg`. A union keeps its quotes when it
140
+ * also holds a type (`"sm" | number`) or a value that reads as a type or a
141
+ * number (`"number" | "currency"`, `"1" | "2"`), and so do values that are
142
+ * not plain words.
143
+ */
144
+ function bareType(type: string) {
145
+ return type
146
+ .replace(
147
+ /"[A-Za-z0-9_#%.-]+"(?: \| "[A-Za-z0-9_#%.-]+")*(?! \|)/g,
148
+ (union: string, offset: number, whole: string) => {
149
+ if (whole.slice(offset - 2, offset) === "| ") return union;
150
+ const values = union.split(" | ").map((v) => v.slice(1, -1));
151
+ if (values.some((v) => AMBIGUOUS_VALUE.test(v))) return union;
152
+ return values.join("|");
153
+ },
154
+ )
155
+ .replace(/ \| /g, "|");
156
+ }
157
+
158
+ /** A compact prop (`type // description`) as `name: type - description`. */
159
+ function propLine(key: string, value: string) {
160
+ const name = key.endsWith("?") ? key.slice(0, -1) : `${key}*`;
161
+ const cut = value.indexOf(" // ");
162
+ const type = bareType(cut < 0 ? value : value.slice(0, cut));
163
+ const text = cut < 0 ? "" : value.slice(cut + 4).trim();
164
+ const description = text ? ` - ${oneLine(text)}` : "";
165
+ return ` ${name}: ${type}${description}`;
166
+ }
167
+
168
+ /**
169
+ * The whole schema as plain lines: a header line per component and one
170
+ * indented line per prop: events are `action` props and slots `componentId`
171
+ * or `childList` props. Props are optional unless marked `*`, enum values
172
+ * are bare, and the common props are listed once. It carries the same names, types and descriptions as
173
+ * `compact`, in fewer tokens.
174
+ */
175
+ function linesSchema(
176
+ manifest: SchemaManifest,
177
+ settings: GenerativeUISchemaSettings,
178
+ ) {
179
+ const compact = buildCompactGenerativeUISchema(manifest, {
180
+ propDescriptions: settings.propDescriptions,
181
+ commonProps: settings.commonProps,
182
+ });
183
+ const targets = compact.targets
184
+ .map((t) => {
185
+ const limit = t.components ? `, only ${t.components.join(", ")}` : "";
186
+ return `${t.id} (${t.kind}${limit})${t.description ? `: ${oneLine(t.description)}` : ""}`;
187
+ })
188
+ .join("; ");
189
+ const functions = Object.entries(compact.functions).map(
190
+ ([name, fn]) =>
191
+ `${nameWithParameters(name, fn.parameters)}${"callers" in fn ? ` (${fn.callers})` : ""}${fn.description ? `: ${oneLine(fn.description)}` : ""}`,
192
+ );
193
+ const common = compact.commonProps
194
+ ? Object.entries(compact.commonProps).map(([k, v]) => propLine(k, v))
195
+ : [];
196
+ const lineSets = Object.entries(compact.components).map(([name, c]) => ({
197
+ name,
198
+ c,
199
+ own: [
200
+ ...Object.entries(c.props).map(([k, v]) => propLine(k, v)),
201
+ ...Object.entries(c.events ?? {}).map(
202
+ ([e, d]) => ` ${e}: action - ${oneLine(d)}`,
203
+ ),
204
+ ],
205
+ }));
206
+ const components = lineSets.flatMap(({ name, c, own }) => {
207
+ const lines = [
208
+ `${name}${c.includesCommonProps ? " +common" : ""}${c.description ? `: ${oneLine(c.description)}` : ""}`,
209
+ ...own,
210
+ ];
211
+ // Slots are props that take component ids.
212
+ for (const [slot, kind] of Object.entries(c.slots ?? {})) {
213
+ lines.push(
214
+ ` ${slot}: ${kind === "single" ? "componentId" : "childList"}`,
215
+ );
216
+ }
217
+ return lines;
218
+ });
219
+ const surfaces = Object.keys(compact.surfaces).length
220
+ ? JSON.stringify(compact.surfaces)
221
+ : "none";
222
+ return [
223
+ `Catalog ${compact.catalogId}. Targets: ${targets || "none"}`,
224
+ 'Props are optional unless marked *. a|b|c is one of those strings, quoted when one reads as a type or a number. A component marked +common also takes every common prop. A prop of type action is an event prop: give it {"event":{...}} or {"functionCall":{...}}. A componentId prop takes one component id; a childList prop takes a list of ids or a template.',
225
+ `Functions:\n${functions.join("\n")}`,
226
+ ...(common.length ? [`Common props:\n${common.join("\n")}`] : []),
227
+ `Components:\n${components.join("\n")}`,
228
+ `Surfaces: ${surfaces}`,
229
+ ].join("\n\n");
230
+ }
231
+
232
+ /**
233
+ * The component schema of the markdown transport, as the text of its
234
+ * context entry, in the notation of `settings`. `compact` is the schema that
235
+ * ships (`buildCompactGenerativeUISchema`), `json-schema` the manifest parts
236
+ * as JSON, `ts-signature` one line per component, `lines` one line per
237
+ * prop with bare enums (the fewest tokens).
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * const value = renderGenerativeUISchema(manifest, spec.schema.markdown);
242
+ * ```
243
+ */
244
+ export function renderGenerativeUISchema(
245
+ manifest: SchemaManifest,
246
+ settings: GenerativeUISchemaSettings,
247
+ ): string {
248
+ switch (settings.notation) {
249
+ case "compact":
250
+ return JSON.stringify(
251
+ buildCompactGenerativeUISchema(manifest, {
252
+ propDescriptions: settings.propDescriptions,
253
+ commonProps: settings.commonProps,
254
+ }),
255
+ );
256
+ case "json-schema": {
257
+ const components = Object.fromEntries(
258
+ Object.entries(manifest.components).map(([name, c]) => [
259
+ name,
260
+ settings.propDescriptions
261
+ ? c
262
+ : { ...c, props: withoutPropDescriptions(c.props) },
263
+ ]),
264
+ );
265
+ return JSON.stringify({
266
+ catalogId: manifest.catalogId,
267
+ targets: manifest.targets,
268
+ functions: manifest.functions,
269
+ components,
270
+ surfaces: manifest.surfaces,
271
+ });
272
+ }
273
+ case "ts-signature":
274
+ return signatureSchema(manifest, settings);
275
+ case "lines":
276
+ return linesSchema(manifest, settings);
277
+ }
278
+ }
279
+
280
+ /**
281
+ * The component list of the tool guide, one entry per component, in the
282
+ * notation of `settings`. `json-schema` is the list that ships.
283
+ */
284
+ export function renderGenerativeUIComponentList(
285
+ components: GenerativeUIManifest["components"],
286
+ settings: GenerativeUISchemaSettings,
287
+ ): string {
288
+ return Object.entries(components)
289
+ .map(([name, c]) => {
290
+ if (
291
+ settings.notation === "ts-signature" ||
292
+ settings.notation === "lines"
293
+ ) {
294
+ return signatureLines(name, c, settings).join("\n");
295
+ }
296
+ const props =
297
+ settings.notation === "compact"
298
+ ? compactProps(c.props, settings.propDescriptions)
299
+ : settings.propDescriptions
300
+ ? c.props
301
+ : withoutPropDescriptions(c.props);
302
+ const lines = [
303
+ `- **${name}**${c.description ? `: ${oneLine(c.description)}` : ""}`,
304
+ ` props: ${JSON.stringify(props)}`,
305
+ ];
306
+ if (c.events) lines.push(` event props: ${JSON.stringify(c.events)}`);
307
+ if (c.slots)
308
+ lines.push(` slot props (component ids): ${JSON.stringify(c.slots)}`);
309
+ return lines.join("\n");
310
+ })
311
+ .join("\n");
312
+ }
313
+
314
+ /**
315
+ * The manifest with replaced descriptions: `"Name"` replaces the
316
+ * description of a component, `"Name.prop"` the description of one of its
317
+ * props. Keys that name no component or prop are left out of the result
318
+ * and listed in `unknown`. The manifest is not changed.
319
+ */
320
+ export function applyDescriptionOverrides<
321
+ M extends Pick<GenerativeUIManifest, "components">,
322
+ >(
323
+ manifest: M,
324
+ overrides: Record<string, string>,
325
+ ): { manifest: M; unknown: string[] } {
326
+ const components = structuredClone(manifest.components);
327
+ const unknown: string[] = [];
328
+ for (const [key, description] of Object.entries(overrides)) {
329
+ const [name, prop, ...rest] = key.split(".");
330
+ // Own keys only: "__proto__" must never reach Object.prototype.
331
+ const component = hasOwn(components, name) ? components[name] : undefined;
332
+ if (!component || rest.length > 0) {
333
+ unknown.push(key);
334
+ continue;
335
+ }
336
+ if (prop === undefined) {
337
+ component.description = description;
338
+ continue;
339
+ }
340
+ const properties = component.props.properties;
341
+ const property =
342
+ isRecord(properties) && hasOwn(properties, prop)
343
+ ? properties[prop]
344
+ : undefined;
345
+ if (!isRecord(property)) {
346
+ unknown.push(key);
347
+ continue;
348
+ }
349
+ property.description = description;
350
+ }
351
+ return { manifest: { ...manifest, components }, unknown };
352
+ }
353
+
354
+ /**
355
+ * The components and props of `manifest` whose names do not appear in
356
+ * `rendered`. A schema notation that leaves one out would hide part of the
357
+ * catalog from the model.
358
+ */
359
+ export function schemaCoverage(
360
+ manifest: Pick<GenerativeUIManifest, "components">,
361
+ rendered: string,
362
+ ): { missing: string[] } {
363
+ const missing: string[] = [];
364
+ for (const [name, component] of Object.entries(manifest.components)) {
365
+ if (!rendered.includes(name)) missing.push(name);
366
+ const properties = isRecord(component.props.properties)
367
+ ? component.props.properties
368
+ : {};
369
+ for (const prop of Object.keys(properties)) {
370
+ if (!rendered.includes(prop)) missing.push(`${name}.${prop}`);
371
+ }
372
+ }
373
+ return { missing };
374
+ }
@@ -1,5 +1,5 @@
1
1
  /** A2UI protocol version used on the wire. */
2
- export const A2UI_VERSION = "v1.0";
2
+ export const A2UI_VERSION = "1.0";
3
3
  /** Activity type of a generated surface message. */
4
4
  export const GENERATIVE_UI_ACTIVITY_TYPE = "generative-ui-surface";
5
5
  /** Activity type of a function call that the agent asks the client to run. */
@@ -83,7 +83,7 @@ export type A2UIFunctionCall = {
83
83
 
84
84
  export type A2UIOperation =
85
85
  | {
86
- version: "v1.0";
86
+ version: typeof A2UI_VERSION;
87
87
  createSurface: {
88
88
  surfaceId: string;
89
89
  /** Left out by the model. The run's catalog id is filled in. */
@@ -97,20 +97,23 @@ export type A2UIOperation =
97
97
  };
98
98
  }
99
99
  | {
100
- version: "v1.0";
100
+ version: typeof A2UI_VERSION;
101
101
  updateComponents: { surfaceId: string; components: A2UIComponentNode[] };
102
102
  }
103
103
  | {
104
- version: "v1.0";
104
+ version: typeof A2UI_VERSION;
105
105
  /**
106
106
  * Sets `value` at `path`. A `null` value deletes the key at `path`.
107
107
  * With no `path`, or `"/"`, it sets the whole data model.
108
108
  */
109
109
  updateDataModel: { surfaceId: string; path?: string; value: unknown };
110
110
  }
111
- | { version: "v1.0"; deleteSurface: { surfaceId: string } }
112
111
  | {
113
- version: "v1.0";
112
+ version: typeof A2UI_VERSION;
113
+ deleteSurface: { surfaceId: string };
114
+ }
115
+ | {
116
+ version: typeof A2UI_VERSION;
114
117
  /** Runs an app function in the browser, with no user interaction. */
115
118
  callRendererFunction: {
116
119
  functionCallId: string;
@@ -292,7 +295,7 @@ export interface A2UIActionMessage {
292
295
  * @example
293
296
  * ```ts
294
297
  * toA2UIActionMessage({ name: "buy", surfaceId: "s1", componentId: "b", context: { sku: "a" } });
295
- * // { version: "v1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
298
+ * // { version: "1.0", action: { name: "buy", surfaceId: "s1", sourceComponentId: "b", timestamp: "2026-…", context: { sku: "a" } } }
296
299
  * ```
297
300
  */
298
301
  export function toA2UIActionMessage(