@wodecorp/openui-vue-a2ui 0.1.4 → 0.1.6

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/index.cjs CHANGED
@@ -1,791 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let _openuidev_lang_core = require("@openuidev/lang-core");
3
- const require_json_pointer = require("./json-pointer-Bk-C0knO.cjs");
4
- let zod_v4 = require("zod/v4");
5
- // src/protocol-schema.ts
6
- const jsonValueSchema = zod_v4.z.json();
7
- const jsonObjectSchema = zod_v4.z.record(zod_v4.z.string(), jsonValueSchema);
8
- const versionSchema = zod_v4.z.literal("v1.0");
9
- const surfaceIdSchema = zod_v4.z.string();
10
- const extensionKeySchema = zod_v4.z.string().regex(/^[\p{XID_Start}_][\p{XID_Continue}]*$/u);
11
- const extensionsSchema = zod_v4.z.record(extensionKeySchema, jsonValueSchema);
12
- const messageMetadataSchema = zod_v4.z.strictObject({ extensions: extensionsSchema.optional() });
13
- const langComponentsSchema = zod_v4.z.array(zod_v4.z.string().min(1)).min(1).describe("Complete OpenUI Lang statements or statement blocks, merged by statement ID in array order.");
14
- const a2uiFunctionCallSchema = zod_v4.z.strictObject({
15
- call: zod_v4.z.string(),
16
- catalogId: zod_v4.z.string().optional(),
17
- args: jsonObjectSchema.optional()
18
- });
19
- const a2uiFunctionResponseSchema = zod_v4.z.union([zod_v4.z.strictObject({
20
- functionCallId: zod_v4.z.string(),
21
- value: jsonValueSchema
22
- }), zod_v4.z.strictObject({
23
- functionCallId: zod_v4.z.string(),
24
- error: zod_v4.z.strictObject({
25
- code: zod_v4.z.string(),
26
- message: zod_v4.z.string()
27
- })
28
- })]);
29
- const createSurfaceMessageSchema = zod_v4.z.strictObject({
30
- version: versionSchema,
31
- createSurface: zod_v4.z.strictObject({
32
- surfaceId: surfaceIdSchema,
33
- catalogId: zod_v4.z.string().optional(),
34
- sendDataModel: zod_v4.z.boolean().optional().meta({ default: false }),
35
- components: langComponentsSchema.optional().describe("Optional initial OpenUI Lang statements for single-message surface creation."),
36
- dataModel: jsonObjectSchema.optional(),
37
- metadata: messageMetadataSchema.optional()
38
- })
39
- });
40
- const updateComponentsMessageSchema = zod_v4.z.strictObject({
41
- version: versionSchema,
42
- updateComponents: zod_v4.z.strictObject({
43
- surfaceId: surfaceIdSchema,
44
- components: langComponentsSchema
45
- })
46
- });
47
- const updateDataModelMessageSchema = zod_v4.z.strictObject({
48
- version: versionSchema,
49
- updateDataModel: zod_v4.z.strictObject({
50
- surfaceId: surfaceIdSchema,
51
- path: zod_v4.z.string().optional(),
52
- value: jsonValueSchema
53
- })
54
- });
55
- const deleteSurfaceMessageSchema = zod_v4.z.strictObject({
56
- version: versionSchema,
57
- deleteSurface: zod_v4.z.strictObject({ surfaceId: surfaceIdSchema })
58
- });
59
- const callRendererFunctionMessageSchema = zod_v4.z.strictObject({
60
- version: versionSchema,
61
- callRendererFunction: zod_v4.z.strictObject({
62
- functionCallId: zod_v4.z.string(),
63
- callFunction: a2uiFunctionCallSchema.extend({ catalogId: zod_v4.z.string() })
64
- })
65
- });
66
- const agentFunctionResponseMessageSchema = zod_v4.z.strictObject({
67
- version: versionSchema,
68
- agentFunctionResponse: a2uiFunctionResponseSchema
69
- });
70
- const agentToRendererMessageSchema = zod_v4.z.union([
71
- createSurfaceMessageSchema,
72
- updateComponentsMessageSchema,
73
- updateDataModelMessageSchema,
74
- deleteSurfaceMessageSchema,
75
- callRendererFunctionMessageSchema,
76
- agentFunctionResponseMessageSchema
77
- ]);
78
- const actionMessageSchema = zod_v4.z.strictObject({
79
- version: versionSchema,
80
- action: zod_v4.z.strictObject({
81
- name: zod_v4.z.string(),
82
- userMessage: zod_v4.z.string().optional(),
83
- surfaceId: surfaceIdSchema,
84
- sourceComponentId: zod_v4.z.string(),
85
- timestamp: zod_v4.z.iso.datetime({ offset: true }),
86
- context: jsonObjectSchema,
87
- metadata: messageMetadataSchema.optional()
88
- })
89
- });
90
- const callAgentFunctionMessageSchema = zod_v4.z.strictObject({
91
- version: versionSchema,
92
- callAgentFunction: zod_v4.z.strictObject({
93
- surfaceId: surfaceIdSchema,
94
- functionCallId: zod_v4.z.string(),
95
- callFunction: a2uiFunctionCallSchema
96
- })
97
- });
98
- const rendererFunctionResponseMessageSchema = zod_v4.z.strictObject({
99
- version: versionSchema,
100
- rendererFunctionResponse: a2uiFunctionResponseSchema
101
- });
102
- const validationErrorCodeSchema = zod_v4.z.enum([
103
- "VALIDATION_FAILED",
104
- "UNALLOWED_PARENT",
105
- "UNALLOWED_CHILD"
106
- ]);
107
- const validationFailedErrorMessageSchema = zod_v4.z.strictObject({
108
- version: versionSchema,
109
- error: zod_v4.z.strictObject({
110
- code: validationErrorCodeSchema,
111
- surfaceId: surfaceIdSchema,
112
- path: zod_v4.z.string(),
113
- message: zod_v4.z.string()
114
- })
115
- });
116
- const genericErrorCodeSchema = zod_v4.z.string().refine((code) => !validationErrorCodeSchema.options.includes(code));
117
- const genericErrorMessageSchema = zod_v4.z.union([zod_v4.z.strictObject({
118
- version: versionSchema,
119
- error: zod_v4.z.strictObject({
120
- code: genericErrorCodeSchema,
121
- message: zod_v4.z.string(),
122
- surfaceId: surfaceIdSchema
123
- })
124
- }), zod_v4.z.strictObject({
125
- version: versionSchema,
126
- error: zod_v4.z.strictObject({
127
- code: genericErrorCodeSchema,
128
- message: zod_v4.z.string(),
129
- functionCallId: zod_v4.z.string()
130
- })
131
- })]);
132
- const rendererToAgentMessageSchema = zod_v4.z.union([
133
- actionMessageSchema,
134
- callAgentFunctionMessageSchema,
135
- rendererFunctionResponseMessageSchema,
136
- validationFailedErrorMessageSchema,
137
- genericErrorMessageSchema
138
- ]);
139
- const rendererCapabilitiesSchema = zod_v4.z.strictObject({ "v1.0": zod_v4.z.strictObject({
140
- supportedCatalogIds: zod_v4.z.array(zod_v4.z.string()),
141
- inlineCatalogs: zod_v4.z.array(jsonObjectSchema).optional()
142
- }) });
143
- const agentCapabilitiesSchema = zod_v4.z.strictObject({ "v1.0": zod_v4.z.strictObject({
144
- supportedCatalogIds: zod_v4.z.array(zod_v4.z.string()).optional(),
145
- acceptsInlineCatalogs: zod_v4.z.boolean().optional().meta({ default: false })
146
- }) });
147
- const rendererDataModelSchema = zod_v4.z.strictObject({
148
- version: versionSchema,
149
- surfaces: zod_v4.z.record(zod_v4.z.string(), jsonObjectSchema)
150
- });
151
- // src/runtime-schema.ts
152
- function escapePointerToken(token) {
153
- return String(token).replace(/~/g, "~0").replace(/\//g, "~1");
154
- }
155
- function issuePath(path) {
156
- return path.length === 0 ? "/" : `/${path.map(escapePointerToken).join("/")}`;
157
- }
158
- function validateAgentToRendererMessage(input) {
159
- const object = input != null && typeof input === "object" && !Array.isArray(input) ? input : void 0;
160
- const presentKeys = object ? [
161
- "createSurface",
162
- "updateComponents",
163
- "updateDataModel",
164
- "deleteSurface",
165
- "callRendererFunction",
166
- "agentFunctionResponse"
167
- ].filter((key) => Object.prototype.hasOwnProperty.call(object, key)) : [];
168
- const result = (presentKeys.length === 1 ? {
169
- createSurface: createSurfaceMessageSchema,
170
- updateComponents: updateComponentsMessageSchema,
171
- updateDataModel: updateDataModelMessageSchema,
172
- deleteSurface: deleteSurfaceMessageSchema,
173
- callRendererFunction: callRendererFunctionMessageSchema,
174
- agentFunctionResponse: agentFunctionResponseMessageSchema
175
- }[presentKeys[0]] : agentToRendererMessageSchema).safeParse(input);
176
- if (result.success) return {
177
- success: true,
178
- message: result.data
179
- };
180
- return {
181
- success: false,
182
- issues: result.error.issues.map((issue) => ({
183
- path: issuePath(issue.path),
184
- message: issue.message
185
- }))
186
- };
187
- }
188
- // src/statement-patch.ts
189
- const STATEMENT_PATTERN = /^(\$?[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([\s\S]*)$/u;
190
- function stripFences(source) {
191
- const trimmed = source.trim();
192
- if (!trimmed.startsWith("```")) return trimmed;
193
- const firstLineEnd = trimmed.indexOf("\n");
194
- const lastFence = trimmed.lastIndexOf("```");
195
- if (firstLineEnd === -1 || lastFence <= firstLineEnd) return trimmed;
196
- return trimmed.slice(firstLineEnd + 1, lastFence).trim();
197
- }
198
- function splitStatements(source) {
199
- const statements = [];
200
- let depth = 0;
201
- let ternaryDepth = 0;
202
- let quote = false;
203
- let escaped = false;
204
- let start = 0;
205
- for (let index = 0; index < source.length; index += 1) {
206
- const character = source[index];
207
- if (escaped) {
208
- escaped = false;
209
- continue;
210
- }
211
- if (character === "\\" && quote) {
212
- escaped = true;
213
- continue;
214
- }
215
- if (quote) {
216
- if (character === quote) quote = false;
217
- continue;
218
- }
219
- if (character === "\"" || character === "'") {
220
- quote = character;
221
- continue;
222
- }
223
- if (character === "(" || character === "[" || character === "{") depth += 1;
224
- else if (character === ")" || character === "]" || character === "}") depth = Math.max(0, depth - 1);
225
- else if (character === "?" && depth === 0) ternaryDepth += 1;
226
- else if (character === ":" && depth === 0 && ternaryDepth > 0) ternaryDepth -= 1;
227
- else if (character === "\n" && depth === 0 && ternaryDepth === 0) {
228
- let next = index + 1;
229
- while (next < source.length && /\s/u.test(source[next])) next += 1;
230
- if (source[next] === "?") continue;
231
- const statement = source.slice(start, index).trim();
232
- if (statement) statements.push(statement);
233
- start = index + 1;
234
- }
235
- }
236
- const finalStatement = source.slice(start).trim();
237
- if (finalStatement) statements.push(finalStatement);
238
- return statements;
239
- }
240
- function parseStatements(source) {
241
- return splitStatements(stripFences(source)).map((raw) => {
242
- const match = STATEMENT_PATTERN.exec(raw);
243
- if (!match) throw new Error(`Invalid OpenUI Lang statement: ${raw}`);
244
- return {
245
- id: match[1],
246
- expression: match[2].trim(),
247
- raw
248
- };
249
- });
250
- }
251
- /**
252
- * Applies statement-level A2UI component patches without removing temporarily
253
- * unreachable statements. A later update may attach those statements to root.
254
- */
255
- function mergeComponentStatements(existing, components) {
256
- const statements = /* @__PURE__ */ new Map();
257
- const order = [];
258
- const upsert = (source, allowDeletion) => {
259
- for (const statement of parseStatements(source)) {
260
- if (allowDeletion && statement.expression === "null") {
261
- statements.delete(statement.id);
262
- const index = order.indexOf(statement.id);
263
- if (index !== -1) order.splice(index, 1);
264
- continue;
265
- }
266
- if (!statements.has(statement.id)) order.push(statement.id);
267
- statements.set(statement.id, statement.raw);
268
- }
269
- };
270
- if (existing.trim()) upsert(existing, false);
271
- for (const component of components) upsert(component, true);
272
- return order.map((id) => statements.get(id)).join("\n");
273
- }
274
- // src/client.ts
275
- var A2UIFunctionError = class extends Error {
276
- code;
277
- constructor(code, message) {
278
- super(message);
279
- this.name = "A2UIFunctionError";
280
- this.code = code;
281
- }
282
- };
283
- function defaultId() {
284
- return globalThis.crypto?.randomUUID?.() ?? `a2ui-${Date.now()}-${Math.random().toString(16).slice(2)}`;
285
- }
286
- function parseError(error) {
287
- return {
288
- source: "parser",
289
- code: error.code,
290
- message: error.message,
291
- statementId: error.statementId,
292
- component: error.component,
293
- path: error.path
294
- };
295
- }
296
- function isCreateSurface(message) {
297
- return "createSurface" in message;
298
- }
299
- function isUpdateComponents(message) {
300
- return "updateComponents" in message;
301
- }
302
- function isUpdateDataModel(message) {
303
- return "updateDataModel" in message;
304
- }
305
- function isDeleteSurface(message) {
306
- return "deleteSurface" in message;
307
- }
308
- function isCallRendererFunction(message) {
309
- return "callRendererFunction" in message;
310
- }
311
- function record(value) {
312
- return value != null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
313
- }
314
- function validationTarget(input) {
315
- const message = record(input);
316
- if (!message) return {};
317
- for (const key of [
318
- "createSurface",
319
- "updateComponents",
320
- "updateDataModel",
321
- "deleteSurface"
322
- ]) {
323
- const payload = record(message[key]);
324
- if (typeof payload?.surfaceId === "string") return { surfaceId: payload.surfaceId };
325
- }
326
- for (const key of ["callRendererFunction", "agentFunctionResponse"]) {
327
- const payload = record(message[key]);
328
- if (typeof payload?.functionCallId === "string") return { functionCallId: payload.functionCallId };
329
- }
330
- return {};
331
- }
332
- var A2UIClient = class {
333
- #parser;
334
- #functions;
335
- #onMessage;
336
- #rendererCapabilities;
337
- #now;
338
- #createId;
339
- #surfaces = /* @__PURE__ */ new Map();
340
- #surfaceListeners = /* @__PURE__ */ new Set();
341
- #messageListeners = /* @__PURE__ */ new Set();
342
- #pendingAgentFunctions = /* @__PURE__ */ new Map();
343
- #revision = 0;
344
- constructor(options) {
345
- this.#parser = (0, _openuidev_lang_core.createParser)(options.schema, options.rootName);
346
- this.#functions = options.functions;
347
- this.#onMessage = options.onMessage;
348
- this.#rendererCapabilities = options.rendererCapabilities;
349
- this.#now = options.now ?? (() => /* @__PURE__ */ new Date());
350
- this.#createId = options.createId ?? defaultId;
351
- }
352
- subscribe(listener) {
353
- this.#surfaceListeners.add(listener);
354
- return () => this.#surfaceListeners.delete(listener);
355
- }
356
- subscribeMessages(listener) {
357
- this.#messageListeners.add(listener);
358
- return () => this.#messageListeners.delete(listener);
359
- }
360
- getSurface(surfaceId) {
361
- return this.#surfaces.get(surfaceId);
362
- }
363
- getSurfaces() {
364
- return [...this.#surfaces.values()];
365
- }
366
- getRendererDataModel() {
367
- const surfaces = Object.fromEntries([...this.#surfaces].filter(([, surface]) => surface.sendDataModel).map(([surfaceId, surface]) => [surfaceId, structuredClone(surface.dataModel)]));
368
- if (Object.keys(surfaces).length === 0) return void 0;
369
- return {
370
- version: "v1.0",
371
- surfaces
372
- };
373
- }
374
- getRendererMetadata() {
375
- const dataModel = this.getRendererDataModel();
376
- return {
377
- ...this.#rendererCapabilities ? { a2uiRendererCapabilities: structuredClone(this.#rendererCapabilities) } : {},
378
- ...dataModel ? { a2uiRendererDataModel: dataModel } : {}
379
- };
380
- }
381
- async process(input) {
382
- const outbound = [];
383
- const capture = (next) => outbound.push(next);
384
- this.#messageListeners.add(capture);
385
- try {
386
- const validated = validateAgentToRendererMessage(input);
387
- if (!validated.success) return this.#invalidMessage(input, validated.issues, outbound);
388
- const message = validated.message;
389
- if (isCreateSurface(message)) return this.#createSurface(message, outbound);
390
- if (isUpdateComponents(message)) return this.#updateComponents(message, outbound);
391
- if (isUpdateDataModel(message)) return this.#updateDataModel(message, outbound);
392
- if (isDeleteSurface(message)) return this.#deleteSurface(message, outbound);
393
- if (isCallRendererFunction(message)) return await this.#callRendererFunction(message, outbound);
394
- return this.#agentFunctionResponse(message, outbound);
395
- } finally {
396
- this.#messageListeners.delete(capture);
397
- }
398
- }
399
- updateSurfaceFromOpenUIState(surfaceId, state) {
400
- const surface = this.#surfaces.get(surfaceId);
401
- if (!surface) return false;
402
- const dataModel = require_json_pointer.mergeOpenUIStateIntoDataModel(surface.dataModel, state);
403
- if (JSON.stringify(dataModel) === JSON.stringify(surface.dataModel)) return false;
404
- this.#replaceSurface({
405
- ...surface,
406
- dataModel
407
- });
408
- return true;
409
- }
410
- dispatchOpenUIAction(surfaceId, event, options = {}) {
411
- const eventSourceComponentId = event.sourceComponentId;
412
- const context = {
413
- ...require_json_pointer.toJsonObject(event.params),
414
- ...event.formState ? { formState: require_json_pointer.toJsonObject(event.formState) } : {},
415
- ...options.context
416
- };
417
- this.dispatchAction({
418
- surfaceId,
419
- sourceComponentId: options.sourceComponentId ?? (typeof eventSourceComponentId === "string" ? eventSourceComponentId : "root"),
420
- name: options.name ?? event.type,
421
- userMessage: (options.userMessage ?? event.humanFriendlyMessage) || void 0,
422
- context,
423
- metadata: options.metadata
424
- });
425
- }
426
- dispatchAction(input) {
427
- if (!this.#surfaces.has(input.surfaceId)) {
428
- this.#emitGenericError("SURFACE_NOT_FOUND", `Unknown surface: ${input.surfaceId}`, input.surfaceId);
429
- return;
430
- }
431
- const message = {
432
- version: "v1.0",
433
- action: {
434
- name: input.name,
435
- ...input.userMessage ? { userMessage: input.userMessage } : {},
436
- surfaceId: input.surfaceId,
437
- sourceComponentId: input.sourceComponentId,
438
- timestamp: this.#now().toISOString(),
439
- context: input.context ?? {},
440
- ...input.metadata ? { metadata: input.metadata } : {}
441
- }
442
- };
443
- this.#emit(message);
444
- }
445
- callAgentFunction(input) {
446
- if (!this.#surfaces.has(input.surfaceId)) {
447
- const message = `Unknown surface: ${input.surfaceId}`;
448
- this.#emitGenericError("SURFACE_NOT_FOUND", message, input.surfaceId);
449
- return Promise.reject(new A2UIFunctionError("SURFACE_NOT_FOUND", message));
450
- }
451
- const functionCallId = this.#createId();
452
- return new Promise((resolve, reject) => {
453
- this.#pendingAgentFunctions.set(functionCallId, {
454
- surfaceId: input.surfaceId,
455
- resolve,
456
- reject
457
- });
458
- this.#emit({
459
- version: "v1.0",
460
- callAgentFunction: {
461
- surfaceId: input.surfaceId,
462
- functionCallId,
463
- callFunction: {
464
- call: input.call,
465
- ...input.catalogId ? { catalogId: input.catalogId } : {},
466
- ...input.args ? { args: input.args } : {}
467
- }
468
- }
469
- });
470
- });
471
- }
472
- dispose() {
473
- for (const pending of this.#pendingAgentFunctions.values()) pending.reject(new A2UIFunctionError("CLIENT_DISPOSED", "A2UI client was disposed"));
474
- this.#pendingAgentFunctions.clear();
475
- this.#surfaces.clear();
476
- this.#surfaceListeners.clear();
477
- this.#messageListeners.clear();
478
- }
479
- #createSurface(message, outbound) {
480
- const input = message.createSurface;
481
- if (this.#surfaces.has(input.surfaceId)) {
482
- this.#emitGenericError("SURFACE_ALREADY_EXISTS", `Surface already exists: ${input.surfaceId}`, input.surfaceId);
483
- return {
484
- ok: false,
485
- outbound
486
- };
487
- }
488
- const supportedCatalogIds = this.#rendererCapabilities?.["v1.0"].supportedCatalogIds ?? [];
489
- if (input.catalogId && supportedCatalogIds.length > 0 && !supportedCatalogIds.includes(input.catalogId)) {
490
- this.#emitGenericError("UNSUPPORTED_CATALOG", `Renderer does not support catalog: ${input.catalogId}`, input.surfaceId);
491
- return {
492
- ok: false,
493
- outbound
494
- };
495
- }
496
- let source = "";
497
- let parseResult = null;
498
- let errors = [];
499
- if (input.components) try {
500
- ({source, parseResult, errors} = this.#mergeComponents("", input.components));
501
- } catch (error) {
502
- this.#emitValidationError(input.surfaceId, "/createSurface/components", error instanceof Error ? error.message : String(error));
503
- return {
504
- ok: false,
505
- outbound
506
- };
507
- }
508
- this.#replaceSurface({
509
- surfaceId: input.surfaceId,
510
- catalogId: input.catalogId,
511
- metadata: input.metadata,
512
- sendDataModel: input.sendDataModel ?? false,
513
- source,
514
- dataModel: structuredClone(input.dataModel ?? {}),
515
- parseResult,
516
- errors,
517
- revision: 0
518
- });
519
- for (const error of errors) this.#emitValidationError(input.surfaceId, "/createSurface/components", error.statementId ? `${error.statementId}: ${error.message}` : error.message);
520
- return {
521
- ok: errors.length === 0,
522
- outbound
523
- };
524
- }
525
- #updateComponents(message, outbound) {
526
- const input = message.updateComponents;
527
- const surface = this.#requireSurface(input.surfaceId);
528
- if (!surface) return {
529
- ok: false,
530
- outbound
531
- };
532
- try {
533
- const { source, parseResult, errors } = this.#mergeComponents(surface.source, input.components);
534
- this.#replaceSurface({
535
- ...surface,
536
- source,
537
- parseResult,
538
- errors
539
- });
540
- for (const error of errors) this.#emitValidationError(input.surfaceId, "/updateComponents/components", error.statementId ? `${error.statementId}: ${error.message}` : error.message);
541
- return {
542
- ok: errors.length === 0,
543
- outbound
544
- };
545
- } catch (error) {
546
- this.#emitValidationError(input.surfaceId, "/updateComponents/components", error instanceof Error ? error.message : String(error));
547
- return {
548
- ok: false,
549
- outbound
550
- };
551
- }
552
- }
553
- #updateDataModel(message, outbound) {
554
- const input = message.updateDataModel;
555
- const surface = this.#requireSurface(input.surfaceId);
556
- if (!surface) return {
557
- ok: false,
558
- outbound
559
- };
560
- try {
561
- const dataModel = require_json_pointer.applyDataModelUpdate(surface.dataModel, input.path, input.value);
562
- this.#replaceSurface({
563
- ...surface,
564
- dataModel
565
- });
566
- return {
567
- ok: true,
568
- outbound
569
- };
570
- } catch (error) {
571
- this.#emitValidationError(input.surfaceId, "/updateDataModel/path", error instanceof Error ? error.message : String(error));
572
- return {
573
- ok: false,
574
- outbound
575
- };
576
- }
577
- }
578
- #deleteSurface(message, outbound) {
579
- const surfaceId = message.deleteSurface.surfaceId;
580
- if (!this.#requireSurface(surfaceId)) return {
581
- ok: false,
582
- outbound
583
- };
584
- this.#surfaces.delete(surfaceId);
585
- for (const [functionCallId, pending] of this.#pendingAgentFunctions) if (pending.surfaceId === surfaceId) {
586
- pending.reject(new A2UIFunctionError("SURFACE_DELETED", `Surface was deleted: ${surfaceId}`));
587
- this.#pendingAgentFunctions.delete(functionCallId);
588
- }
589
- this.#notify();
590
- return {
591
- ok: true,
592
- outbound
593
- };
594
- }
595
- async #callRendererFunction(message, outbound) {
596
- const { functionCallId, callFunction } = message.callRendererFunction;
597
- const { call, catalogId, args = {} } = callFunction;
598
- const registration = this.#functions?.[call];
599
- if (!registration) {
600
- this.#emitGenericError("INVALID_FUNCTION_CALL", `Renderer function is not registered: ${call}`, void 0, functionCallId);
601
- return {
602
- ok: false,
603
- outbound
604
- };
605
- }
606
- const fn = typeof registration === "function" ? registration : registration.handler;
607
- if (typeof registration === "function" || (registration.allowedCallers ?? "rendererOnly") === "rendererOnly" || registration.catalogId !== catalogId) {
608
- this.#emitGenericError("INVALID_FUNCTION_CALL", `Renderer function is not callable from catalog ${catalogId}: ${call}`, void 0, functionCallId);
609
- return {
610
- ok: false,
611
- outbound
612
- };
613
- }
614
- try {
615
- const value = await fn(args);
616
- this.#emit({
617
- version: "v1.0",
618
- rendererFunctionResponse: {
619
- functionCallId,
620
- value
621
- }
622
- });
623
- return {
624
- ok: true,
625
- outbound
626
- };
627
- } catch (error) {
628
- this.#emit({
629
- version: "v1.0",
630
- rendererFunctionResponse: {
631
- functionCallId,
632
- error: {
633
- code: "EXECUTION_FAILED",
634
- message: error instanceof Error ? error.message : String(error)
635
- }
636
- }
637
- });
638
- return {
639
- ok: false,
640
- outbound
641
- };
642
- }
643
- }
644
- #agentFunctionResponse(message, outbound) {
645
- const response = message.agentFunctionResponse;
646
- const pending = this.#pendingAgentFunctions.get(response.functionCallId);
647
- if (!pending) return {
648
- ok: false,
649
- outbound,
650
- issues: [{
651
- path: "/agentFunctionResponse/functionCallId",
652
- message: `Unknown functionCallId: ${response.functionCallId}`
653
- }]
654
- };
655
- this.#pendingAgentFunctions.delete(response.functionCallId);
656
- if ("error" in response) {
657
- pending.reject(new A2UIFunctionError(response.error.code, response.error.message));
658
- return {
659
- ok: true,
660
- outbound
661
- };
662
- }
663
- pending.resolve(response.value);
664
- return {
665
- ok: true,
666
- outbound
667
- };
668
- }
669
- #replaceSurface(surface) {
670
- this.#revision += 1;
671
- this.#surfaces.set(surface.surfaceId, {
672
- ...surface,
673
- revision: this.#revision
674
- });
675
- this.#notify();
676
- }
677
- #mergeComponents(existing, components) {
678
- const source = mergeComponentStatements(existing, components);
679
- const parseResult = this.#parser.parse(source);
680
- return {
681
- source,
682
- parseResult,
683
- errors: parseResult.meta.errors.map(parseError)
684
- };
685
- }
686
- #invalidMessage(input, issues, outbound) {
687
- const target = validationTarget(input);
688
- const issue = issues[0] ?? {
689
- path: "/",
690
- message: "Invalid A2UI message"
691
- };
692
- if (target.surfaceId !== void 0) {
693
- this.#emitValidationError(target.surfaceId, issue.path, issue.message);
694
- return {
695
- ok: false,
696
- outbound,
697
- issues
698
- };
699
- }
700
- if (target.functionCallId !== void 0) {
701
- this.#emitGenericError("INVALID_MESSAGE", `${issue.path}: ${issue.message}`, void 0, target.functionCallId);
702
- return {
703
- ok: false,
704
- outbound,
705
- issues
706
- };
707
- }
708
- return {
709
- ok: false,
710
- outbound,
711
- issues
712
- };
713
- }
714
- #requireSurface(surfaceId) {
715
- const surface = this.#surfaces.get(surfaceId);
716
- if (!surface) this.#emitGenericError("SURFACE_NOT_FOUND", `Unknown surface: ${surfaceId}`, surfaceId);
717
- return surface;
718
- }
719
- #emitValidationError(surfaceId, path, message) {
720
- const error = {
721
- version: "v1.0",
722
- error: {
723
- code: "VALIDATION_FAILED",
724
- surfaceId,
725
- path,
726
- message
727
- }
728
- };
729
- this.#emit(error);
730
- }
731
- #emitGenericError(code, message, surfaceId, functionCallId) {
732
- if (surfaceId === void 0 && functionCallId === void 0) return;
733
- const error = surfaceId !== void 0 ? {
734
- version: "v1.0",
735
- error: {
736
- code,
737
- message,
738
- surfaceId
739
- }
740
- } : {
741
- version: "v1.0",
742
- error: {
743
- code,
744
- message,
745
- functionCallId
746
- }
747
- };
748
- this.#emit(error);
749
- }
750
- #emit(message) {
751
- const metadata = this.getRendererMetadata();
752
- this.#onMessage?.(message, metadata);
753
- for (const listener of this.#messageListeners) listener(message, metadata);
754
- }
755
- #notify() {
756
- for (const listener of this.#surfaceListeners) listener();
757
- }
758
- };
759
- function createA2UIClient(options) {
760
- return new A2UIClient(options);
761
- }
762
- exports.A2UIClient = A2UIClient;
763
- exports.A2UIFunctionError = A2UIFunctionError;
764
- exports.a2uiFunctionCallSchema = a2uiFunctionCallSchema;
765
- exports.a2uiFunctionResponseSchema = a2uiFunctionResponseSchema;
766
- exports.actionMessageSchema = actionMessageSchema;
767
- exports.agentCapabilitiesSchema = agentCapabilitiesSchema;
768
- exports.agentFunctionResponseMessageSchema = agentFunctionResponseMessageSchema;
769
- exports.agentToRendererMessageSchema = agentToRendererMessageSchema;
770
- exports.applyDataModelUpdate = require_json_pointer.applyDataModelUpdate;
771
- exports.callAgentFunctionMessageSchema = callAgentFunctionMessageSchema;
772
- exports.callRendererFunctionMessageSchema = callRendererFunctionMessageSchema;
773
- exports.createA2UIClient = createA2UIClient;
774
- exports.createSurfaceMessageSchema = createSurfaceMessageSchema;
775
- exports.dataModelToOpenUIState = require_json_pointer.dataModelToOpenUIState;
776
- exports.deleteSurfaceMessageSchema = deleteSurfaceMessageSchema;
777
- exports.genericErrorMessageSchema = genericErrorMessageSchema;
778
- exports.jsonObjectSchema = jsonObjectSchema;
779
- exports.jsonValueSchema = jsonValueSchema;
780
- exports.mergeOpenUIStateIntoDataModel = require_json_pointer.mergeOpenUIStateIntoDataModel;
781
- exports.messageMetadataSchema = messageMetadataSchema;
782
- exports.rendererCapabilitiesSchema = rendererCapabilitiesSchema;
783
- exports.rendererDataModelSchema = rendererDataModelSchema;
784
- exports.rendererFunctionResponseMessageSchema = rendererFunctionResponseMessageSchema;
785
- exports.rendererToAgentMessageSchema = rendererToAgentMessageSchema;
786
- exports.updateComponentsMessageSchema = updateComponentsMessageSchema;
787
- exports.updateDataModelMessageSchema = updateDataModelMessageSchema;
788
- exports.validateAgentToRendererMessage = validateAgentToRendererMessage;
789
- exports.validationFailedErrorMessageSchema = validationFailedErrorMessageSchema;
790
-
791
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@openuidev/lang-core");const t=require("./json-pointer-DTPkya-j.cjs");let n=require("zod/v4");const r=n.z.json(),i=n.z.record(n.z.string(),r),a=n.z.literal(`v1.0`),o=n.z.string(),s=n.z.string().regex(/^[\p{XID_Start}_][\p{XID_Continue}]*$/u),c=n.z.record(s,r),l=n.z.strictObject({extensions:c.optional()}),u=n.z.array(n.z.string().min(1)).min(1).describe(`Complete OpenUI Lang statements or statement blocks, merged by statement ID in array order.`),d=n.z.strictObject({call:n.z.string(),catalogId:n.z.string().optional(),args:i.optional()}),f=n.z.union([n.z.strictObject({functionCallId:n.z.string(),value:r}),n.z.strictObject({functionCallId:n.z.string(),error:n.z.strictObject({code:n.z.string(),message:n.z.string()})})]),p=n.z.strictObject({version:a,createSurface:n.z.strictObject({surfaceId:o,catalogId:n.z.string().optional(),sendDataModel:n.z.boolean().optional().meta({default:!1}),components:u.optional().describe(`Optional initial OpenUI Lang statements for single-message surface creation.`),dataModel:i.optional(),metadata:l.optional()})}),m=n.z.strictObject({version:a,updateComponents:n.z.strictObject({surfaceId:o,components:u})}),h=n.z.strictObject({version:a,updateDataModel:n.z.strictObject({surfaceId:o,path:n.z.string().optional(),value:r})}),g=n.z.strictObject({version:a,deleteSurface:n.z.strictObject({surfaceId:o})}),_=n.z.strictObject({version:a,callRendererFunction:n.z.strictObject({functionCallId:n.z.string(),callFunction:d.extend({catalogId:n.z.string()})})}),v=n.z.strictObject({version:a,agentFunctionResponse:f}),y=n.z.union([p,m,h,g,_,v]),b=n.z.strictObject({version:a,action:n.z.strictObject({name:n.z.string(),userMessage:n.z.string().optional(),surfaceId:o,sourceComponentId:n.z.string(),timestamp:n.z.iso.datetime({offset:!0}),context:i,metadata:l.optional()})}),x=n.z.strictObject({version:a,callAgentFunction:n.z.strictObject({surfaceId:o,functionCallId:n.z.string(),callFunction:d})}),S=n.z.strictObject({version:a,rendererFunctionResponse:f}),C=n.z.enum([`VALIDATION_FAILED`,`UNALLOWED_PARENT`,`UNALLOWED_CHILD`]),w=n.z.strictObject({version:a,error:n.z.strictObject({code:C,surfaceId:o,path:n.z.string(),message:n.z.string()})}),T=n.z.string().refine(e=>!C.options.includes(e)),E=n.z.union([n.z.strictObject({version:a,error:n.z.strictObject({code:T,message:n.z.string(),surfaceId:o})}),n.z.strictObject({version:a,error:n.z.strictObject({code:T,message:n.z.string(),functionCallId:n.z.string()})})]),D=n.z.union([b,x,S,w,E]),O=n.z.strictObject({"v1.0":n.z.strictObject({supportedCatalogIds:n.z.array(n.z.string()),inlineCatalogs:n.z.array(i).optional()})}),k=n.z.strictObject({"v1.0":n.z.strictObject({supportedCatalogIds:n.z.array(n.z.string()).optional(),acceptsInlineCatalogs:n.z.boolean().optional().meta({default:!1})})}),A=n.z.strictObject({version:a,surfaces:n.z.record(n.z.string(),i)});function j(e){return String(e).replace(/~/g,`~0`).replace(/\//g,`~1`)}function M(e){return e.length===0?`/`:`/${e.map(j).join(`/`)}`}function N(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,n=t?[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`,`callRendererFunction`,`agentFunctionResponse`].filter(e=>Object.prototype.hasOwnProperty.call(t,e)):[],r=(n.length===1?{createSurface:p,updateComponents:m,updateDataModel:h,deleteSurface:g,callRendererFunction:_,agentFunctionResponse:v}[n[0]]:y).safeParse(e);return r.success?{success:!0,message:r.data}:{success:!1,issues:r.error.issues.map(e=>({path:M(e.path),message:e.message}))}}const P=/^(\$?[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([\s\S]*)$/u;function F(e){let t=e.trim();if(!t.startsWith("```"))return t;let n=t.indexOf(`
2
+ `),r=t.lastIndexOf("```");return n===-1||r<=n?t:t.slice(n+1,r).trim()}function I(e){let t=[],n=0,r=0,i=!1,a=!1,o=0;for(let s=0;s<e.length;s+=1){let c=e[s];if(a)a=!1;else if(c===`\\`&&i)a=!0;else if(i)c===i&&(i=!1);else if(c===`"`||c===`'`)i=c;else if(c===`(`||c===`[`||c===`{`)n+=1;else if(c===`)`||c===`]`||c===`}`)n=Math.max(0,n-1);else if(c===`?`&&n===0)r+=1;else if(c===`:`&&n===0&&r>0)--r;else if(c===`
3
+ `&&n===0&&r===0){let n=s+1;for(;n<e.length&&/\s/u.test(e[n]);)n+=1;if(e[n]===`?`)continue;let r=e.slice(o,s).trim();r&&t.push(r),o=s+1}}let s=e.slice(o).trim();return s&&t.push(s),t}function L(e){return I(F(e)).map(e=>{let t=P.exec(e);if(!t)throw Error(`Invalid OpenUI Lang statement: ${e}`);return{id:t[1],expression:t[2].trim(),raw:e}})}function R(e,t){let n=/* @__PURE__ */ new Map,r=[],i=(e,t)=>{for(let i of L(e))if(t&&i.expression===`null`){n.delete(i.id);let e=r.indexOf(i.id);e!==-1&&r.splice(e,1)}else n.has(i.id)||r.push(i.id),n.set(i.id,i.raw)};e.trim()&&i(e,!1);for(let e of t)i(e,!0);return r.map(e=>n.get(e)).join(`
4
+ `)}var z=class extends Error{code;constructor(e,t){super(t),this.name=`A2UIFunctionError`,this.code=e}};function B(){return globalThis.crypto?.randomUUID?.()??`a2ui-${Date.now()}-${Math.random().toString(16).slice(2)}`}function V(e){return{source:`parser`,code:e.code,message:e.message,statementId:e.statementId,component:e.component,path:e.path}}function H(e){return`createSurface`in e}function U(e){return`updateComponents`in e}function W(e){return`updateDataModel`in e}function G(e){return`deleteSurface`in e}function K(e){return`callRendererFunction`in e}function q(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function J(e){let t=q(e);if(!t)return{};for(let e of[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]){let n=q(t[e]);if(typeof n?.surfaceId==`string`)return{surfaceId:n.surfaceId}}for(let e of[`callRendererFunction`,`agentFunctionResponse`]){let n=q(t[e]);if(typeof n?.functionCallId==`string`)return{functionCallId:n.functionCallId}}return{}}var Y=class{#e;#t;#n;#r;#i;#a;#o=/* @__PURE__ */ new Map;#s=/* @__PURE__ */ new Set;#c=/* @__PURE__ */ new Set;#l=/* @__PURE__ */ new Map;#u=0;constructor(t){this.#e=(0,e.createParser)(t.schema,t.rootName),this.#t=t.functions,this.#n=t.onMessage,this.#r=t.rendererCapabilities,this.#i=t.now??(()=>/* @__PURE__ */ new Date),this.#a=t.createId??B}subscribe(e){return this.#s.add(e),()=>this.#s.delete(e)}subscribeMessages(e){return this.#c.add(e),()=>this.#c.delete(e)}getSurface(e){return this.#o.get(e)}getSurfaces(){return[...this.#o.values()]}getRendererDataModel(){let e=Object.fromEntries([...this.#o].filter(([,e])=>e.sendDataModel).map(([e,t])=>[e,structuredClone(t.dataModel)]));if(Object.keys(e).length!==0)return{version:`v1.0`,surfaces:e}}getRendererMetadata(){let e=this.getRendererDataModel();return{...this.#r?{a2uiRendererCapabilities:structuredClone(this.#r)}:{},...e?{a2uiRendererDataModel:e}:{}}}async process(e){let t=[],n=e=>t.push(e);this.#c.add(n);try{let n=N(e);if(!n.success)return this.#y(e,n.issues,t);let r=n.message;return H(r)?this.#d(r,t):U(r)?this.#f(r,t):W(r)?this.#p(r,t):G(r)?this.#m(r,t):K(r)?await this.#h(r,t):this.#g(r,t)}finally{this.#c.delete(n)}}updateSurfaceFromOpenUIState(e,n){let r=this.#o.get(e);if(!r)return!1;let i=t.r(r.dataModel,n);return JSON.stringify(i)!==JSON.stringify(r.dataModel)&&(this.#_({...r,dataModel:i}),!0)}dispatchOpenUIAction(e,n,r={}){let i=n.sourceComponentId,a={...t.i(n.params),...n.formState?{formState:t.i(n.formState)}:{},...r.context};this.dispatchAction({surfaceId:e,sourceComponentId:r.sourceComponentId??(typeof i==`string`?i:`root`),name:r.name??n.type,userMessage:(r.userMessage??n.humanFriendlyMessage)||void 0,context:a,metadata:r.metadata})}dispatchAction(e){if(!this.#o.has(e.surfaceId)){this.#S(`SURFACE_NOT_FOUND`,`Unknown surface: ${e.surfaceId}`,e.surfaceId);return}let t={version:`v1.0`,action:{name:e.name,...e.userMessage?{userMessage:e.userMessage}:{},surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:this.#i().toISOString(),context:e.context??{},...e.metadata?{metadata:e.metadata}:{}}};this.#C(t)}callAgentFunction(e){if(!this.#o.has(e.surfaceId)){let t=`Unknown surface: ${e.surfaceId}`;return this.#S(`SURFACE_NOT_FOUND`,t,e.surfaceId),Promise.reject(new z(`SURFACE_NOT_FOUND`,t))}let t=this.#a();return new Promise((n,r)=>{this.#l.set(t,{surfaceId:e.surfaceId,resolve:n,reject:r}),this.#C({version:`v1.0`,callAgentFunction:{surfaceId:e.surfaceId,functionCallId:t,callFunction:{call:e.call,...e.catalogId?{catalogId:e.catalogId}:{},...e.args?{args:e.args}:{}}}})})}dispose(){for(let e of this.#l.values())e.reject(new z(`CLIENT_DISPOSED`,`A2UI client was disposed`));this.#l.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear()}#d(e,t){let n=e.createSurface;if(this.#o.has(n.surfaceId))return this.#S(`SURFACE_ALREADY_EXISTS`,`Surface already exists: ${n.surfaceId}`,n.surfaceId),{ok:!1,outbound:t};let r=this.#r?.[`v1.0`].supportedCatalogIds??[];if(n.catalogId&&r.length>0&&!r.includes(n.catalogId))return this.#S(`UNSUPPORTED_CATALOG`,`Renderer does not support catalog: ${n.catalogId}`,n.surfaceId),{ok:!1,outbound:t};let i=``,a=null,o=[];if(n.components)try{({source:i,parseResult:a,errors:o}=this.#v(``,n.components))}catch(e){return this.#x(n.surfaceId,`/createSurface/components`,e instanceof Error?e.message:String(e)),{ok:!1,outbound:t}}this.#_({surfaceId:n.surfaceId,catalogId:n.catalogId,metadata:n.metadata,sendDataModel:n.sendDataModel??!1,source:i,dataModel:structuredClone(n.dataModel??{}),parseResult:a,errors:o,revision:0});for(let e of o)this.#x(n.surfaceId,`/createSurface/components`,e.statementId?`${e.statementId}: ${e.message}`:e.message);return{ok:o.length===0,outbound:t}}#f(e,t){let n=e.updateComponents,r=this.#b(n.surfaceId);if(!r)return{ok:!1,outbound:t};try{let{source:e,parseResult:i,errors:a}=this.#v(r.source,n.components);this.#_({...r,source:e,parseResult:i,errors:a});for(let e of a)this.#x(n.surfaceId,`/updateComponents/components`,e.statementId?`${e.statementId}: ${e.message}`:e.message);return{ok:a.length===0,outbound:t}}catch(e){return this.#x(n.surfaceId,`/updateComponents/components`,e instanceof Error?e.message:String(e)),{ok:!1,outbound:t}}}#p(e,n){let r=e.updateDataModel,i=this.#b(r.surfaceId);if(!i)return{ok:!1,outbound:n};try{let e=t.t(i.dataModel,r.path,r.value);return this.#_({...i,dataModel:e}),{ok:!0,outbound:n}}catch(e){return this.#x(r.surfaceId,`/updateDataModel/path`,e instanceof Error?e.message:String(e)),{ok:!1,outbound:n}}}#m(e,t){let n=e.deleteSurface.surfaceId;if(!this.#b(n))return{ok:!1,outbound:t};this.#o.delete(n);for(let[e,t]of this.#l)t.surfaceId===n&&(t.reject(new z(`SURFACE_DELETED`,`Surface was deleted: ${n}`)),this.#l.delete(e));return this.#w(),{ok:!0,outbound:t}}async#h(e,t){let{functionCallId:n,callFunction:r}=e.callRendererFunction,{call:i,catalogId:a,args:o={}}=r,s=this.#t?.[i];if(!s)return this.#S(`INVALID_FUNCTION_CALL`,`Renderer function is not registered: ${i}`,void 0,n),{ok:!1,outbound:t};let c=typeof s==`function`?s:s.handler;if(typeof s==`function`||(s.allowedCallers??`rendererOnly`)===`rendererOnly`||s.catalogId!==a)return this.#S(`INVALID_FUNCTION_CALL`,`Renderer function is not callable from catalog ${a}: ${i}`,void 0,n),{ok:!1,outbound:t};try{let e=await c(o);return this.#C({version:`v1.0`,rendererFunctionResponse:{functionCallId:n,value:e}}),{ok:!0,outbound:t}}catch(e){return this.#C({version:`v1.0`,rendererFunctionResponse:{functionCallId:n,error:{code:`EXECUTION_FAILED`,message:e instanceof Error?e.message:String(e)}}}),{ok:!1,outbound:t}}}#g(e,t){let n=e.agentFunctionResponse,r=this.#l.get(n.functionCallId);return r?(this.#l.delete(n.functionCallId),`error`in n?(r.reject(new z(n.error.code,n.error.message)),{ok:!0,outbound:t}):(r.resolve(n.value),{ok:!0,outbound:t})):{ok:!1,outbound:t,issues:[{path:`/agentFunctionResponse/functionCallId`,message:`Unknown functionCallId: ${n.functionCallId}`}]}}#_(e){this.#u+=1,this.#o.set(e.surfaceId,{...e,revision:this.#u}),this.#w()}#v(e,t){let n=R(e,t),r=this.#e.parse(n);return{source:n,parseResult:r,errors:r.meta.errors.map(V)}}#y(e,t,n){let r=J(e),i=t[0]??{path:`/`,message:`Invalid A2UI message`};return r.surfaceId===void 0?(r.functionCallId===void 0||this.#S(`INVALID_MESSAGE`,`${i.path}: ${i.message}`,void 0,r.functionCallId),{ok:!1,outbound:n,issues:t}):(this.#x(r.surfaceId,i.path,i.message),{ok:!1,outbound:n,issues:t})}#b(e){let t=this.#o.get(e);return t||this.#S(`SURFACE_NOT_FOUND`,`Unknown surface: ${e}`,e),t}#x(e,t,n){let r={version:`v1.0`,error:{code:`VALIDATION_FAILED`,surfaceId:e,path:t,message:n}};this.#C(r)}#S(e,t,n,r){if(n===void 0&&r===void 0)return;let i=n===void 0?{version:`v1.0`,error:{code:e,message:t,functionCallId:r}}:{version:`v1.0`,error:{code:e,message:t,surfaceId:n}};this.#C(i)}#C(e){let t=this.getRendererMetadata();this.#n?.(e,t);for(let n of this.#c)n(e,t)}#w(){for(let e of this.#s)e()}};exports.A2UIClient=Y,exports.A2UIFunctionError=z,exports.a2uiFunctionCallSchema=d,exports.a2uiFunctionResponseSchema=f,exports.actionMessageSchema=b,exports.agentCapabilitiesSchema=k,exports.agentFunctionResponseMessageSchema=v,exports.agentToRendererMessageSchema=y,exports.applyDataModelUpdate=t.t,exports.callAgentFunctionMessageSchema=x,exports.callRendererFunctionMessageSchema=_,exports.createA2UIClient=function(e){return new Y(e)},exports.createSurfaceMessageSchema=p,exports.dataModelToOpenUIState=t.n,exports.deleteSurfaceMessageSchema=g,exports.genericErrorMessageSchema=E,exports.jsonObjectSchema=i,exports.jsonValueSchema=r,exports.mergeOpenUIStateIntoDataModel=t.r,exports.messageMetadataSchema=l,exports.rendererCapabilitiesSchema=O,exports.rendererDataModelSchema=A,exports.rendererFunctionResponseMessageSchema=S,exports.rendererToAgentMessageSchema=D,exports.updateComponentsMessageSchema=m,exports.updateDataModelMessageSchema=h,exports.validateAgentToRendererMessage=N,exports.validationFailedErrorMessageSchema=w;