@heroui/agent 0.2.0-beta.8 → 0.2.0-beta.9

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 (47) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/chart-content-BBHQVMP4.js +1 -0
  3. package/dist/chunk-2XBFFSW2.js +1 -0
  4. package/dist/chunk-64RI74L5.js +1 -0
  5. package/dist/chunk-6ZJJN322.js +1 -0
  6. package/dist/chunk-7KCGPNEN.js +1 -0
  7. package/dist/chunk-BBB5EHDN.js +5 -0
  8. package/dist/chunk-CR3H7AVI.js +1 -0
  9. package/dist/chunk-HCLXS4HQ.js +1 -0
  10. package/dist/chunk-MXLGM4WV.js +1 -0
  11. package/dist/chunk-OA3TG5CS.js +1 -0
  12. package/dist/chunk-PZJ4NC3J.js +1 -0
  13. package/dist/chunk-RNNGE7KM.js +1 -0
  14. package/dist/chunk-S6OIAJSC.js +1 -0
  15. package/dist/chunk-SUDHJNTJ.js +2 -0
  16. package/dist/chunk-WUAFMD7Z.js +2 -0
  17. package/dist/component-renderer-GG6JVRUG.js +1 -0
  18. package/dist/composer-draft-NSKK65F3.js +1 -0
  19. package/dist/composer-image-draft-KAGTNQR7.js +1 -0
  20. package/dist/contracts.d.ts +1 -1
  21. package/dist/contracts.js +2 -2445
  22. package/dist/embed-runtime-GYXK7V6N.js +5 -0
  23. package/dist/index.js +1 -31
  24. package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
  25. package/dist/internal/client-tools.js +1 -0
  26. package/dist/internal/models.js +1 -0
  27. package/dist/internal/runtime.js +1 -0
  28. package/dist/internal/theme.js +1 -0
  29. package/dist/next.js +1 -25
  30. package/dist/server.js +1 -136
  31. package/package.json +4 -4
  32. package/dist/chart-content-E4NPTUPR.js +0 -2696
  33. package/dist/chunk-3FG5NRTX.js +0 -9
  34. package/dist/chunk-CMZDZGUZ.js +0 -1132
  35. package/dist/chunk-DS4X5K2R.js +0 -56
  36. package/dist/chunk-FNGGMHVR.js +0 -625
  37. package/dist/chunk-G6GFNSG4.js +0 -284
  38. package/dist/chunk-Q7LGTVBL.js +0 -43
  39. package/dist/chunk-TOOT6SZ2.js +0 -74
  40. package/dist/chunk-UUPU3MYB.js +0 -42
  41. package/dist/chunk-VJA52U5P.js +0 -137
  42. package/dist/chunk-W7SCMB3O.js +0 -1285
  43. package/dist/component-renderer-MDDQMQTU.js +0 -10629
  44. package/dist/composer-draft-DTQAEO5K.js +0 -20
  45. package/dist/composer-image-draft-IVJ352E6.js +0 -174
  46. package/dist/embed-runtime-VVAGDPYY.js +0 -9422
  47. package/dist/interactive-map-surface-67KHT3VB.js +0 -362
package/dist/contracts.js CHANGED
@@ -1,2445 +1,2 @@
1
- // src/contracts/attachments.ts
2
- var HEROUI_AGENT_MAX_ATTACHMENTS = 5;
3
- var HEROUI_AGENT_ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024;
4
- var HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE = {
5
- "application/json": "json",
6
- "application/pdf": "pdf",
7
- "image/gif": "gif",
8
- "image/jpeg": "jpg",
9
- "image/png": "png",
10
- "image/webp": "webp",
11
- "text/csv": "csv",
12
- "text/markdown": "md",
13
- "text/plain": "txt",
14
- "text/tab-separated-values": "tsv"
15
- };
16
- var HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES = Object.freeze(
17
- Object.keys(
18
- HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE
19
- )
20
- );
21
- var HEROUI_AGENT_ATTACHMENT_ACCEPT = HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES.join(",");
22
- var HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_SET = new Set(
23
- HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES
24
- );
25
- var HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES = /* @__PURE__ */ new Set([
26
- "application/json",
27
- "text/csv",
28
- "text/markdown",
29
- "text/plain",
30
- "text/tab-separated-values"
31
- ]);
32
- function isHeroUIAgentAttachmentContentType(value) {
33
- return HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_SET.has(value.trim().toLowerCase());
34
- }
35
-
36
- // src/contracts/appearance.ts
37
- var HEROUI_AGENT_REMOTE_CONFIG_VERSION = 1;
38
- var INVALID = Symbol("invalid");
39
- function isRecord(value) {
40
- return typeof value === "object" && value !== null && !Array.isArray(value);
41
- }
42
- function optionalString(value) {
43
- if (value === void 0) return void 0;
44
- return typeof value === "string" ? value : INVALID;
45
- }
46
- function optionalBoolean(value) {
47
- if (value === void 0) return void 0;
48
- return typeof value === "boolean" ? value : INVALID;
49
- }
50
- function optionalNumber(value) {
51
- if (value === void 0) return void 0;
52
- return typeof value === "number" && Number.isFinite(value) ? value : INVALID;
53
- }
54
- function optionalEnum(allowed) {
55
- return (value) => {
56
- if (value === void 0) return void 0;
57
- return typeof value === "string" && allowed.includes(value) ? value : INVALID;
58
- };
59
- }
60
- function optionalThemeColor(value) {
61
- if (value === void 0) return void 0;
62
- if (typeof value === "string") return value;
63
- if (!isRecord(value)) return INVALID;
64
- const dark = optionalString(value["dark"]);
65
- const light = optionalString(value["light"]);
66
- if (dark === INVALID || light === INVALID) return INVALID;
67
- return { ...dark === void 0 ? {} : { dark }, ...light === void 0 ? {} : { light } };
68
- }
69
- function optionalStringRecord(value) {
70
- if (value === void 0) return void 0;
71
- if (!isRecord(value)) return INVALID;
72
- const record = {};
73
- for (const [key2, entry] of Object.entries(value)) {
74
- if (typeof entry !== "string") return INVALID;
75
- record[key2] = entry;
76
- }
77
- return record;
78
- }
79
- function optionalStringArray(value) {
80
- if (value === void 0) return void 0;
81
- if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) return INVALID;
82
- return value;
83
- }
84
- function shape(value, validators2) {
85
- if (value === void 0) return INVALID;
86
- if (!isRecord(value)) return INVALID;
87
- const result = {};
88
- for (const [key2, validate] of Object.entries(validators2)) {
89
- const parsed = validate(value[key2]);
90
- if (parsed === INVALID) return INVALID;
91
- if (parsed !== void 0) result[key2] = parsed;
92
- }
93
- return result;
94
- }
95
- function group(parsed) {
96
- return parsed === INVALID ? void 0 : parsed;
97
- }
98
- var COLOR_KEYS = [
99
- "accent",
100
- "background",
101
- "foreground",
102
- "overlay",
103
- "surface",
104
- "surfaceSecondary",
105
- "tooltip"
106
- ];
107
- function parseAppearance(value) {
108
- return shape(value, {
109
- launcher: (launcher) => launcher === void 0 ? void 0 : shape(launcher, {
110
- background: optionalThemeColor,
111
- icon: optionalString,
112
- position: optionalEnum(["bottom-left", "bottom-right"]),
113
- style: optionalStringRecord
114
- }),
115
- panel: (panel) => panel === void 0 ? void 0 : shape(panel, {
116
- expandable: optionalBoolean,
117
- expanded: optionalBoolean,
118
- initialHeight: (entry) => entry === void 0 || typeof entry === "string" ? entry : optionalNumber(entry),
119
- initialWidth: (entry) => entry === void 0 || typeof entry === "string" ? entry : optionalNumber(entry)
120
- }),
121
- theme: (theme) => theme === void 0 ? void 0 : shape(theme, {
122
- colorScheme: optionalEnum(["dark", "light", "system"]),
123
- colors: (colors) => colors === void 0 ? void 0 : shape(
124
- colors,
125
- Object.fromEntries(COLOR_KEYS.map((key2) => [key2, optionalThemeColor]))
126
- ),
127
- designTheme: optionalEnum(["base", "brutalism", "glass", "mouve"]),
128
- radius: optionalEnum(["pill", "round", "sharp", "soft"]),
129
- typography: (typography) => typography === void 0 ? void 0 : shape(typography, { baseSize: optionalNumber, fontFamily: optionalString })
130
- }),
131
- viewMode: optionalEnum(["floating", "sidebar"])
132
- });
133
- }
134
- function parseComposer(value) {
135
- return shape(value, {
136
- attachments: (attachments) => {
137
- if (attachments === void 0 || attachments === false) return attachments;
138
- if (!Array.isArray(attachments)) return INVALID;
139
- const types = attachments.filter(
140
- (entry) => typeof entry === "string" && isHeroUIAgentAttachmentContentType(entry)
141
- );
142
- return types.length === attachments.length ? types : INVALID;
143
- },
144
- defaultModel: optionalString,
145
- dictation: optionalBoolean,
146
- disclaimer: (disclaimer) => disclaimer === false ? false : optionalString(disclaimer),
147
- modelPicker: optionalBoolean,
148
- placeholder: optionalString
149
- });
150
- }
151
- function parseMarkdown(value) {
152
- return shape(value, {
153
- animated: (animated) => {
154
- if (animated === void 0 || animated === false) return animated;
155
- if (!isRecord(animated)) return INVALID;
156
- const animation = optionalEnum(["blurIn", "fadeIn", "slideUp"])(
157
- animated["animation"]
158
- );
159
- if (animation === INVALID || animation === void 0) return INVALID;
160
- return { ...animated, animation };
161
- },
162
- caret: (caret) => caret === false ? false : optionalEnum(["block", "circle"])(caret)
163
- });
164
- }
165
- function parseResponseActions(value) {
166
- if (value === void 0 || value === false) return value;
167
- if (!Array.isArray(value)) return INVALID;
168
- const allowed = ["copy", "feedback", "retry"];
169
- const actions = value.filter(
170
- (entry) => typeof entry === "string" && allowed.includes(entry)
171
- );
172
- return actions.length === value.length ? actions : INVALID;
173
- }
174
- function parseAgentRemoteConfig(value) {
175
- if (!isRecord(value)) return null;
176
- if (value["version"] !== HEROUI_AGENT_REMOTE_CONFIG_VERSION) return null;
177
- const revision = value["revision"];
178
- if (typeof revision !== "string" || !revision) return null;
179
- const appearance = group(parseAppearance(value["appearance"]));
180
- const capabilities = group(
181
- shape(value["capabilities"], {
182
- imageSearch: optionalBoolean,
183
- newsSearch: optionalBoolean,
184
- webSearch: optionalBoolean
185
- })
186
- );
187
- const composer = group(parseComposer(value["composer"]));
188
- const markdown = group(parseMarkdown(value["markdown"]));
189
- const permissions = group(
190
- shape(value["permissions"], {
191
- defaultMode: optionalEnum(["ask", "auto", "full"]),
192
- showPicker: optionalBoolean
193
- })
194
- );
195
- const responseActions = group(parseResponseActions(value["responseActions"]));
196
- const startScreen = group(
197
- shape(value["startScreen"], {
198
- greeting: optionalString,
199
- promptShortcuts: optionalBoolean,
200
- prompts: optionalStringArray
201
- })
202
- );
203
- const webfont = group(
204
- shape(value["webfont"], {
205
- familyName: (familyName) => typeof familyName === "string" && familyName ? familyName : INVALID,
206
- fontFaceUrl: optionalString,
207
- stylesheetUrl: optionalString
208
- })
209
- );
210
- return {
211
- ...appearance ? { appearance } : {},
212
- ...capabilities ? { capabilities } : {},
213
- ...composer ? { composer } : {},
214
- ...markdown ? { markdown } : {},
215
- ...permissions ? { permissions } : {},
216
- ...responseActions === void 0 ? {} : { responseActions },
217
- ...startScreen ? { startScreen } : {},
218
- ...webfont ? { webfont } : {},
219
- revision,
220
- version: HEROUI_AGENT_REMOTE_CONFIG_VERSION
221
- };
222
- }
223
-
224
- // ../agent-ui/src/categories.ts
225
- var COMPONENT_CATEGORY_BY_KIND = {
226
- accordion: "display-information",
227
- "action-group": "actions",
228
- "area-chart": "data-visualization",
229
- "bar-chart": "data-visualization",
230
- callout: "display-information",
231
- "candlestick-chart": "data-visualization",
232
- "channel-message": "display-information",
233
- "code-block": "display-information",
234
- "comparison-list": "data-visualization",
235
- "composed-chart": "data-visualization",
236
- "create-event": "display-information",
237
- "data-table": "data-visualization",
238
- diagram: "display-information",
239
- "donut-chart": "data-visualization",
240
- "enable-notification": "display-information",
241
- "event-session": "display-information",
242
- "flight-tracker": "display-information",
243
- followup: "actions",
244
- form: "form-elements",
245
- "funnel-chart": "data-visualization",
246
- "gauge-chart": "data-visualization",
247
- heatmap: "data-visualization",
248
- image: "display-information",
249
- "kpi-grid": "data-visualization",
250
- "line-chart": "data-visualization",
251
- list: "display-information",
252
- "list-block": "display-information",
253
- map: "display-information",
254
- "meter-list": "data-visualization",
255
- "metric-grid": "data-visualization",
256
- "pie-chart": "data-visualization",
257
- "player-card": "display-information",
258
- playlist: "display-information",
259
- "product-card": "display-information",
260
- "product-signals": "data-visualization",
261
- "purchase-complete": "display-information",
262
- "purchase-items": "display-information",
263
- "radar-chart": "data-visualization",
264
- "radial-chart": "data-visualization",
265
- "record-card": "display-information",
266
- "ride-status": "display-information",
267
- "sankey-chart": "data-visualization",
268
- "scatter-chart": "data-visualization",
269
- steps: "display-information",
270
- "sunburst-chart": "data-visualization",
271
- "switch-group": "form-elements",
272
- tabs: "display-information",
273
- "tag-list": "display-information",
274
- text: "display-information",
275
- "toggle-group": "form-elements",
276
- "view-event": "display-information",
277
- "weather-current": "display-information",
278
- "weather-forecast": "display-information"
279
- };
280
-
281
- // ../agent-ui/src/contracts/components.ts
282
- import { z } from "zod";
283
-
284
- // ../agent-ui/src/utils/chart-values.ts
285
- function resolveGaugeBounds(component) {
286
- return {
287
- maximum: component.max ?? (component.format?.style === "percent" ? 1 : 100),
288
- minimum: component.min ?? 0
289
- };
290
- }
291
-
292
- // ../agent-ui/src/contracts/components.ts
293
- var agentIconNames = [
294
- "activity",
295
- "alert",
296
- "briefcase",
297
- "calendar",
298
- "chart",
299
- "check",
300
- "clock",
301
- "code",
302
- "credit-card",
303
- "database",
304
- "device-desktop",
305
- "device-mobile",
306
- "document",
307
- "dollar",
308
- "flag",
309
- "globe",
310
- "heart",
311
- "home",
312
- "info",
313
- "lightning",
314
- "location",
315
- "mail",
316
- "percent",
317
- "person",
318
- "question",
319
- "receipt",
320
- "rocket",
321
- "route",
322
- "search",
323
- "shopping-bag",
324
- "speedometer",
325
- "star",
326
- "tag",
327
- "target",
328
- "users"
329
- ];
330
- var weatherConditions = [
331
- "clear",
332
- "partly-cloudy",
333
- "cloudy",
334
- "fog",
335
- "drizzle",
336
- "rain",
337
- "snow",
338
- "thunderstorm",
339
- "windy",
340
- "unknown"
341
- ];
342
- var title = z.string().trim().min(1).max(120);
343
- var shortText = z.string().trim().min(1).max(320);
344
- var content = z.string().trim().min(1).max(1e4);
345
- var key = z.string().trim().min(1).max(80);
346
- var id = z.string().trim().min(1).max(100);
347
- var date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
348
- var time = z.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/);
349
- var datumValue = z.union([z.string().max(500), z.number(), z.boolean(), z.null()]);
350
- var datum = z.record(z.string().max(80), datumValue);
351
- var base = z.object({ description: shortText.optional(), id, title });
352
- var cardComponentVariantSchema = z.enum(["outline", "plain", "surface", "surface-secondary", "surface-tertiary", "widget"]).describe(
353
- "Card hierarchy: surface for the primary standalone group; surface-secondary for supporting information; surface-tertiary for one featured or emphasized group; outline for equal peers and comparisons; plain for a structural section already separated by surrounding layout; widget for a compact interactive group with actions or controls."
354
- );
355
- var recordCardLayoutSchema = z.enum(["compact", "details", "media"]).describe(
356
- "Record information layout: details for a full labeled fact set; compact for a brief summary or repeated peer cards; media for an image-led product, place, person, or event and only when an image is available."
357
- );
358
- var numberFormatSchema = z.discriminatedUnion("style", [
359
- z.object({ compact: z.boolean().optional(), style: z.literal("number") }),
360
- z.object({
361
- maximumFractionDigits: z.number().int().min(0).max(4).optional(),
362
- style: z.literal("percent")
363
- }),
364
- z.object({
365
- compact: z.boolean().optional(),
366
- currency: z.string().regex(/^[A-Z]{3}$/),
367
- style: z.literal("currency")
368
- })
369
- ]);
370
- var chartColorSchema = z.enum([
371
- "accent",
372
- "chart-1",
373
- "chart-2",
374
- "chart-3",
375
- "chart-4",
376
- "chart-5",
377
- "danger",
378
- "default",
379
- "success",
380
- "warning"
381
- ]);
382
- var chartColors = z.record(z.string().trim().min(1).max(80), chartColorSchema).refine((colors) => Object.keys(colors).length <= 50, "At most 50 category colors are allowed");
383
- var series = z.object({
384
- color: chartColorSchema.optional(),
385
- dataKey: key,
386
- format: numberFormatSchema.optional(),
387
- label: shortText
388
- });
389
- var composedSeries = series.extend({
390
- axis: z.enum(["left", "right"]).optional(),
391
- stacked: z.boolean().optional(),
392
- type: z.enum(["area", "bar", "line"])
393
- });
394
- var cartesianRange = z.object({
395
- id,
396
- label: shortText,
397
- maxItems: z.number().int().min(1).max(200).optional()
398
- });
399
- var cartesian = base.extend({
400
- data: z.array(datum).min(1).max(200),
401
- defaultRangeId: id.optional(),
402
- ranges: z.array(cartesianRange).min(2).max(8).optional(),
403
- series: z.array(series).min(1).max(5),
404
- showSummary: z.boolean().optional(),
405
- xKey: key
406
- });
407
- var proportional = base.extend({
408
- colors: chartColors.optional(),
409
- data: z.array(datum).min(1).max(50),
410
- format: numberFormatSchema.optional(),
411
- labelKey: key,
412
- valueKey: key
413
- });
414
- var scatter = base.extend({
415
- colors: chartColors.optional(),
416
- data: z.array(datum).min(1).max(200),
417
- format: numberFormatSchema.optional(),
418
- groupKey: key.optional(),
419
- kind: z.literal("scatter-chart"),
420
- labelKey: key.optional(),
421
- sizeKey: key.optional(),
422
- xKey: key,
423
- yKey: key
424
- });
425
- var heatmap = base.extend({
426
- color: chartColorSchema.optional(),
427
- data: z.array(datum).min(1).max(400),
428
- format: numberFormatSchema.optional(),
429
- kind: z.literal("heatmap"),
430
- valueKey: key,
431
- xKey: key,
432
- yKey: key
433
- });
434
- var line = cartesian.extend({
435
- baseline: z.number().finite().optional(),
436
- kind: z.literal("line-chart"),
437
- mode: z.enum(["live", "profit-loss", "standard"]).optional(),
438
- negativeColor: chartColorSchema.optional(),
439
- positiveColor: chartColorSchema.optional(),
440
- windowSize: z.number().int().min(2).max(200).optional()
441
- }).superRefine((component, ctx) => {
442
- if ((component.mode === "live" || component.mode === "profit-loss") && component.series.length !== 1) {
443
- ctx.addIssue({
444
- code: "custom",
445
- message: `${component.mode} line charts require exactly one series`,
446
- path: ["series"]
447
- });
448
- }
449
- });
450
- var candlestick = base.extend({
451
- closeKey: key,
452
- data: z.array(datum).min(1).max(200),
453
- downColor: chartColorSchema.optional(),
454
- format: numberFormatSchema.optional(),
455
- highKey: key,
456
- kind: z.literal("candlestick-chart"),
457
- lowKey: key,
458
- openKey: key,
459
- upColor: chartColorSchema.optional(),
460
- xKey: key
461
- }).superRefine((component, ctx) => {
462
- for (const [index, row] of component.data.entries()) {
463
- const open = row[component.openKey];
464
- const high = row[component.highKey];
465
- const low = row[component.lowKey];
466
- const close = row[component.closeKey];
467
- const values = [open, high, low, close];
468
- if (values.some((value) => typeof value !== "number" || !Number.isFinite(value))) {
469
- ctx.addIssue({
470
- code: "custom",
471
- message: "Every candlestick row needs finite open, high, low, and close values",
472
- path: ["data", index]
473
- });
474
- continue;
475
- }
476
- const numericOpen = open;
477
- const numericHigh = high;
478
- const numericLow = low;
479
- const numericClose = close;
480
- if (numericLow > Math.min(numericOpen, numericClose) || numericHigh < Math.max(numericOpen, numericClose) || numericLow > numericHigh) {
481
- ctx.addIssue({
482
- code: "custom",
483
- message: "Candlestick low/high values must contain the open and close values",
484
- path: ["data", index]
485
- });
486
- }
487
- }
488
- });
489
- var funnel = proportional.extend({
490
- data: z.array(datum).min(2).max(20),
491
- kind: z.literal("funnel-chart"),
492
- orientation: z.enum(["horizontal", "vertical"]).optional(),
493
- showPercentages: z.boolean().optional()
494
- }).superRefine((component, ctx) => {
495
- const values = component.data.map((row, index) => {
496
- const value = row[component.valueKey];
497
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
498
- ctx.addIssue({
499
- code: "custom",
500
- message: "Every funnel stage needs a finite, non-negative value",
501
- path: ["data", index, component.valueKey]
502
- });
503
- return 0;
504
- }
505
- return value;
506
- });
507
- if (!values.some((value) => value > 0)) {
508
- ctx.addIssue({
509
- code: "custom",
510
- message: "A funnel needs at least one stage above zero",
511
- path: ["data"]
512
- });
513
- }
514
- if ((values[0] ?? 0) <= 0) {
515
- ctx.addIssue({
516
- code: "custom",
517
- message: "A funnel's first stage must be above zero",
518
- path: ["data", 0, component.valueKey]
519
- });
520
- }
521
- for (let index = 1; index < values.length; index += 1) {
522
- if ((values[index] ?? 0) > (values[index - 1] ?? 0)) {
523
- ctx.addIssue({
524
- code: "custom",
525
- message: "Funnel stages must not increase",
526
- path: ["data", index, component.valueKey]
527
- });
528
- }
529
- }
530
- });
531
- var gauge = base.extend({
532
- color: chartColorSchema.optional(),
533
- format: numberFormatSchema.optional(),
534
- kind: z.literal("gauge-chart"),
535
- label: shortText,
536
- max: z.number().finite().optional(),
537
- min: z.number().finite().optional(),
538
- notches: z.number().int().min(6).max(60).optional(),
539
- orientation: z.enum(["arc", "linear"]).optional(),
540
- value: z.number().finite()
541
- }).superRefine((component, ctx) => {
542
- const { maximum, minimum } = resolveGaugeBounds(component);
543
- if (maximum <= minimum) {
544
- ctx.addIssue({ code: "custom", message: "Gauge max must be greater than min", path: ["max"] });
545
- } else if (component.value < minimum || component.value > maximum) {
546
- ctx.addIssue({
547
- code: "custom",
548
- message: "Gauge value must be within its min/max range",
549
- path: ["value"]
550
- });
551
- }
552
- });
553
- var sunburstNode = z.lazy(
554
- () => z.object({
555
- children: z.array(sunburstNode).min(1).max(12).optional(),
556
- color: chartColorSchema.optional(),
557
- id,
558
- label: shortText,
559
- value: z.number().finite().positive().optional()
560
- }).superRefine((node, ctx) => {
561
- if (node.children?.length && node.value !== void 0) {
562
- ctx.addIssue({
563
- code: "custom",
564
- message: "Sunburst branch values are derived from their children",
565
- path: ["value"]
566
- });
567
- }
568
- if (!node.children?.length && node.value === void 0) {
569
- ctx.addIssue({
570
- code: "custom",
571
- message: "Every sunburst leaf needs a positive value",
572
- path: ["value"]
573
- });
574
- }
575
- })
576
- );
577
- var sunburst = base.extend({
578
- data: sunburstNode,
579
- format: numberFormatSchema.optional(),
580
- kind: z.literal("sunburst-chart")
581
- }).superRefine((component, ctx) => {
582
- const ids = /* @__PURE__ */ new Set();
583
- let count = 0;
584
- let deepest = 0;
585
- const visit = (node, depth) => {
586
- count += 1;
587
- deepest = Math.max(deepest, depth);
588
- if (ids.has(node.id)) {
589
- ctx.addIssue({ code: "custom", message: `Duplicate sunburst node id "${node.id}"` });
590
- }
591
- ids.add(node.id);
592
- node.children?.forEach((child) => visit(child, depth + 1));
593
- };
594
- if (!component.data.children?.length) {
595
- ctx.addIssue({
596
- code: "custom",
597
- message: "A sunburst root needs at least one child",
598
- path: ["data", "children"]
599
- });
600
- }
601
- visit(component.data, 0);
602
- if (count > 60)
603
- ctx.addIssue({ code: "custom", message: "Sunburst charts allow at most 60 nodes" });
604
- if (deepest > 4)
605
- ctx.addIssue({ code: "custom", message: "Sunburst charts allow at most four nested levels" });
606
- });
607
- var option = z.object({ label: shortText, value: key });
608
- var formDateRange = z.object({ end: date, start: date }).refine((range) => range.start <= range.end, "The start date must not be after the end date");
609
- var fieldBase = {
610
- description: shortText.optional(),
611
- label: shortText,
612
- name: key,
613
- required: z.boolean().optional()
614
- };
615
- var formField = z.discriminatedUnion("kind", [
616
- z.object({
617
- ...fieldBase,
618
- defaultValue: z.string().max(500).optional(),
619
- inputType: z.enum(["email", "number", "password", "search", "tel", "text", "url"]).optional(),
620
- kind: z.literal("input"),
621
- placeholder: z.string().max(160).optional()
622
- }),
623
- z.object({
624
- ...fieldBase,
625
- defaultValue: z.string().max(2e3).optional(),
626
- kind: z.literal("textarea"),
627
- placeholder: z.string().max(160).optional(),
628
- rows: z.number().int().min(2).max(12).optional()
629
- }),
630
- z.object({
631
- ...fieldBase,
632
- defaultValue: key.optional(),
633
- kind: z.literal("select"),
634
- options: z.array(option).min(1).max(30),
635
- placeholder: z.string().max(160).optional()
636
- }),
637
- z.object({
638
- ...fieldBase,
639
- defaultValue: key.optional(),
640
- kind: z.literal("radio-group"),
641
- options: z.array(option).min(1).max(12),
642
- placeholder: z.string().max(160).optional()
643
- }),
644
- z.object({
645
- ...fieldBase,
646
- defaultValue: z.array(key).max(20).optional(),
647
- kind: z.literal("checkbox-group"),
648
- options: z.array(option).min(1).max(20)
649
- }),
650
- z.object({
651
- ...fieldBase,
652
- defaultValue: z.array(key).max(50).optional(),
653
- kind: z.literal("combobox"),
654
- options: z.array(option.extend({ description: z.string().trim().min(1).max(120).optional() })).min(1).max(200).describe(
655
- "Prefer this over select once there are more options than someone would scan \u2014 it filters as they type. Values must be unique."
656
- ),
657
- placeholder: z.string().max(160).optional(),
658
- selectionMode: z.enum(["multiple", "single"]).optional()
659
- }).superRefine((field, ctx) => {
660
- const values = new Set(field.options.map((entry) => entry.value));
661
- if (values.size !== field.options.length) {
662
- ctx.addIssue({
663
- code: "custom",
664
- message: "Combobox option values must be unique",
665
- path: ["options"]
666
- });
667
- }
668
- if ((field.selectionMode ?? "single") === "single" && (field.defaultValue?.length ?? 0) > 1) {
669
- ctx.addIssue({
670
- code: "custom",
671
- message: "A single-selection combobox takes at most one default value",
672
- path: ["defaultValue"]
673
- });
674
- }
675
- if (field.defaultValue?.some((value) => !values.has(value))) {
676
- ctx.addIssue({
677
- code: "custom",
678
- message: "Every combobox default value must be one of the options",
679
- path: ["defaultValue"]
680
- });
681
- }
682
- }),
683
- z.object({
684
- ...fieldBase,
685
- defaultValue: z.number().optional(),
686
- kind: z.literal("slider"),
687
- max: z.number(),
688
- min: z.number(),
689
- step: z.number().positive().optional()
690
- }),
691
- z.object({
692
- ...fieldBase,
693
- defaultValue: z.number().optional(),
694
- format: numberFormatSchema.optional(),
695
- kind: z.literal("number"),
696
- max: z.number().optional(),
697
- min: z.number().optional(),
698
- placeholder: z.string().max(160).optional(),
699
- step: z.number().positive().optional()
700
- }),
701
- z.object({
702
- ...fieldBase,
703
- defaultValue: z.boolean().optional(),
704
- kind: z.literal("switch")
705
- }),
706
- z.object({
707
- ...fieldBase,
708
- defaultValue: date.optional(),
709
- kind: z.literal("date-picker"),
710
- max: date.optional(),
711
- min: date.optional()
712
- }),
713
- z.object({
714
- ...fieldBase,
715
- defaultValue: formDateRange.optional(),
716
- kind: z.literal("date-range-picker"),
717
- max: date.optional(),
718
- min: date.optional()
719
- }),
720
- z.object({
721
- ...fieldBase,
722
- defaultValue: time.optional(),
723
- hourCycle: z.union([z.literal(12), z.literal(24)]).optional(),
724
- kind: z.literal("time-field"),
725
- max: time.optional(),
726
- min: time.optional()
727
- })
728
- ]);
729
- var actionVariant = z.enum(["danger", "outline", "primary", "secondary", "tertiary"]);
730
- var agentIconSchema = z.enum(agentIconNames);
731
- var actionToolCall = z.object({
732
- arguments: z.record(z.string().max(80), z.unknown()).refine(
733
- (value) => JSON.stringify(value).length <= 4096,
734
- "Tool call arguments must serialize to at most 4KB of JSON"
735
- ),
736
- name: z.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/)
737
- });
738
- var action = z.object({
739
- id,
740
- label: shortText,
741
- prompt: z.string().trim().min(1).max(2e3).optional(),
742
- toolCall: actionToolCall.optional(),
743
- variant: actionVariant.optional()
744
- });
745
- var mapCoordinate = z.object({
746
- latitude: z.number().finite().min(-85.051129).max(85.051129),
747
- longitude: z.number().finite().min(-180).max(180)
748
- });
749
- var httpUrl = z.string().trim().min(1).max(2e3).refine(
750
- (value) => {
751
- try {
752
- const url = new URL(value);
753
- return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password;
754
- } catch {
755
- return false;
756
- }
757
- },
758
- { message: "URL must use HTTP or HTTPS and cannot include credentials" }
759
- );
760
- var contactUrl = z.string().trim().min(1).max(2e3).refine(
761
- (value) => {
762
- try {
763
- const url = new URL(value);
764
- return ["http:", "https:", "mailto:", "tel:"].includes(url.protocol) && !url.username && !url.password;
765
- } catch {
766
- return false;
767
- }
768
- },
769
- { message: "Link must use HTTP, HTTPS, mailto, or tel and cannot include credentials" }
770
- );
771
- var mapActionBase = { id, label: shortText, variant: actionVariant.optional() };
772
- var telephoneUrl = z.string().trim().min(5).max(2e3).refine(
773
- (value) => /^tel:\+?[0-9().\-\s]+$/.test(value) && /\d/.test(value.slice(4)),
774
- "Phone links must use the tel: scheme and contain a phone number"
775
- );
776
- var mapLocationAction = z.discriminatedUnion("kind", [
777
- z.object({ ...mapActionBase, href: telephoneUrl, kind: z.literal("call") }),
778
- z.object({ ...mapActionBase, href: httpUrl, kind: z.literal("directions") }),
779
- z.object({ ...mapActionBase, href: contactUrl, kind: z.literal("other") }),
780
- z.object({ ...mapActionBase, href: httpUrl, kind: z.literal("website") })
781
- ]);
782
- var mapLocation = mapCoordinate.extend({
783
- actions: z.array(mapLocationAction).max(4).optional(),
784
- address: shortText.optional(),
785
- category: z.string().trim().min(1).max(100).optional(),
786
- id,
787
- images: z.array(z.object({ alt: shortText, src: httpUrl })).max(4).optional().describe(
788
- "Prefer one representative image per location when a trusted tool or web image search returns one. The first image becomes the result-card thumbnail; initials are the fallback."
789
- ),
790
- notes: z.string().trim().min(1).max(2e3).optional(),
791
- rating: z.number().finite().min(0).max(5).optional(),
792
- relevance: z.number().finite().min(0).max(1).optional(),
793
- reviewCount: z.number().int().nonnegative().max(1e9).optional(),
794
- title: shortText
795
- });
796
- var displayImageSrc = z.string().trim().min(1).max(2e3).refine(
797
- (value) => {
798
- if (value.startsWith("/")) return !value.startsWith("//");
799
- try {
800
- const url = new URL(value);
801
- return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password;
802
- } catch {
803
- return false;
804
- }
805
- },
806
- { message: "Image sources must be HTTP(S) URLs or root-relative paths" }
807
- );
808
- var agentUIImage = z.object({
809
- alt: shortText,
810
- src: displayImageSrc.refine(
811
- (value) => !value.split(/[?#]/, 1)[0]?.toLowerCase().endsWith(".svg"),
812
- "Response-composition images must be raster images"
813
- )
814
- });
815
- var currency = z.string().regex(/^[A-Z]{3}$/);
816
- var amount = z.object({
817
- amount: z.number().finite().nonnegative().max(1e9),
818
- currency
819
- });
820
- var weatherConditionSchema = z.enum(weatherConditions);
821
- var weatherUnit = z.enum(["celsius", "fahrenheit"]);
822
- var endpoint = z.object({
823
- label: shortText,
824
- status: shortText.optional(),
825
- time: z.string().trim().min(1).max(80)
826
- });
827
- var recordTone = z.enum(["accent", "danger", "default", "muted", "success", "warning"]);
828
- var productCardItem = z.object({
829
- actions: z.array(action).max(3).optional(),
830
- badge: z.object({ label: shortText, tone: recordTone.optional() }).optional(),
831
- description: shortText.optional(),
832
- id,
833
- image: z.object({ alt: shortText, src: displayImageSrc }),
834
- meta: z.string().trim().min(1).max(160).optional(),
835
- name: shortText,
836
- price: z.object({
837
- amount: z.number().finite().nonnegative().max(1e9),
838
- currency: currency.optional()
839
- }),
840
- rating: z.object({
841
- count: z.number().int().nonnegative().max(1e9).optional(),
842
- value: z.number().finite().min(0).max(5)
843
- }).optional()
844
- });
845
- var meterTone = z.enum(["accent", "danger", "default", "success", "warning"]);
846
- var meterItem = z.object({
847
- description: shortText.optional(),
848
- format: numberFormatSchema.optional(),
849
- id,
850
- label: shortText,
851
- max: z.number().optional(),
852
- min: z.number().optional(),
853
- tone: meterTone.optional(),
854
- value: z.number()
855
- }).superRefine((item, ctx) => {
856
- const min = item.min ?? 0;
857
- const max = item.max ?? (item.format?.style === "percent" ? 1 : 100);
858
- if (max <= min) {
859
- ctx.addIssue({ code: "custom", message: "Meter max must be greater than min" });
860
- }
861
- if (item.value < min || item.value > max) {
862
- ctx.addIssue({ code: "custom", message: "Meter value must be within its min/max range" });
863
- }
864
- });
865
- var validators = {
866
- accordion: base.extend({
867
- kind: z.literal("accordion"),
868
- sections: z.array(z.object({ content, defaultOpen: z.boolean().optional(), id, title: shortText })).min(1).max(12)
869
- }),
870
- actions: base.extend({
871
- actions: z.array(action).min(1).max(8),
872
- kind: z.literal("action-group"),
873
- orientation: z.enum(["horizontal", "vertical"]).optional()
874
- }),
875
- area: cartesian.extend({ kind: z.literal("area-chart"), stacked: z.boolean().optional() }),
876
- bar: cartesian.extend({
877
- kind: z.literal("bar-chart"),
878
- layout: z.enum(["horizontal", "vertical"]).optional(),
879
- stacked: z.boolean().optional()
880
- }),
881
- callout: base.extend({
882
- content,
883
- icon: agentIconSchema.optional(),
884
- kind: z.literal("callout"),
885
- tone: z.enum(["accent", "danger", "neutral", "success", "warning"]).optional()
886
- }),
887
- candlestick,
888
- channelMessage: base.extend({
889
- attachments: z.array(z.object({ id, image: agentUIImage.optional(), name: shortText })).max(8).optional(),
890
- author: z.object({ image: agentUIImage.optional(), name: shortText }),
891
- channel: shortText,
892
- content,
893
- kind: z.literal("channel-message"),
894
- timestamp: z.string().trim().min(1).max(80)
895
- }),
896
- code: base.extend({
897
- code: z.string().min(1).max(2e4),
898
- kind: z.literal("code-block"),
899
- language: z.string().trim().max(40).optional()
900
- }),
901
- comparison: base.extend({
902
- items: z.array(
903
- z.object({
904
- change: z.number().optional(),
905
- format: numberFormatSchema.optional(),
906
- label: shortText,
907
- note: z.string().trim().max(180).optional(),
908
- value: z.number()
909
- })
910
- ).min(1).max(12),
911
- kind: z.literal("comparison-list")
912
- }),
913
- composed: cartesian.extend({
914
- kind: z.literal("composed-chart"),
915
- series: z.array(composedSeries).min(2).max(5)
916
- }),
917
- createEvent: base.extend({
918
- actions: z.array(action).max(2).optional(),
919
- date: z.object({
920
- day: z.number().int().min(1).max(31),
921
- weekday: z.string().trim().min(1).max(20)
922
- }),
923
- events: z.array(
924
- z.object({
925
- id,
926
- status: z.enum(["existing", "proposed"]).optional(),
927
- time: z.string().trim().min(1).max(80),
928
- title: shortText,
929
- tone: recordTone.optional()
930
- })
931
- ).min(1).max(12),
932
- kind: z.literal("create-event")
933
- }),
934
- diagram: base.extend({
935
- chart: z.string().trim().min(1).max(4e3).describe(
936
- 'Mermaid source. Pick the diagram type from the relationship: "flowchart LR" for a process or decision path, "sequenceDiagram" for an exchange between parties over time, "erDiagram" for how records relate, "stateDiagram-v2" for the states something moves between. Example: "flowchart LR\\n A[Order placed] --> B{In stock?}\\n B -- yes --> C[Ship]\\n B -- no --> D[Backorder]". Never include HTML, script tags, or click directives.'
937
- ),
938
- kind: z.literal("diagram")
939
- }).superRefine((component, ctx) => {
940
- const forbidden = /<\s*script|javascript:|^\s*click\s+\S/im;
941
- if (forbidden.test(component.chart)) {
942
- ctx.addIssue({
943
- code: "custom",
944
- message: "Diagram source cannot contain HTML, script URLs, or click directives",
945
- path: ["chart"]
946
- });
947
- }
948
- }),
949
- donut: proportional.extend({ kind: z.literal("donut-chart") }),
950
- enableNotification: base.extend({
951
- actions: z.tuple([action, action]),
952
- kind: z.literal("enable-notification")
953
- }),
954
- eventSession: base.extend({
955
- action: action.optional(),
956
- eyebrow: z.string().trim().min(1).max(100).optional(),
957
- kind: z.literal("event-session"),
958
- location: shortText,
959
- speakers: z.array(z.object({ image: agentUIImage.optional(), name: shortText, role: shortText })).max(8),
960
- time: z.string().trim().min(1).max(80)
961
- }),
962
- flightTracker: base.extend({
963
- airline: z.object({ logo: agentUIImage.optional(), name: shortText }),
964
- date: z.string().trim().min(1).max(80),
965
- destination: endpoint,
966
- flightNumber: z.string().trim().min(1).max(40),
967
- kind: z.literal("flight-tracker"),
968
- origin: endpoint,
969
- progress: z.number().finite().min(0).max(100).optional()
970
- }),
971
- followup: base.extend({
972
- kind: z.literal("followup"),
973
- prompts: z.array(z.object({ id, label: shortText, prompt: content })).min(1).max(8)
974
- }),
975
- form: base.extend({
976
- actions: z.array(action).min(1).max(4),
977
- fields: z.array(formField).min(1).max(20),
978
- kind: z.literal("form")
979
- }),
980
- funnel,
981
- gauge,
982
- heatmap,
983
- image: base.extend({
984
- images: z.array(
985
- z.object({
986
- alt: shortText,
987
- aspectRatio: z.enum(["landscape", "portrait", "square", "wide"]).optional(),
988
- caption: shortText.optional(),
989
- src: displayImageSrc
990
- })
991
- ).min(1).max(6),
992
- kind: z.literal("image"),
993
- variant: z.enum(["grid", "horizontal"]).optional().describe("Use horizontal for a swipeable gallery in narrow chat interfaces.")
994
- }),
995
- kpiGrid: base.extend({
996
- kind: z.literal("kpi-grid"),
997
- metrics: z.array(
998
- z.object({
999
- change: z.number().optional(),
1000
- color: chartColorSchema.optional(),
1001
- format: numberFormatSchema.optional(),
1002
- icon: agentIconSchema.optional(),
1003
- label: shortText,
1004
- trend: z.array(z.number().finite()).min(2).max(60).describe(
1005
- "The values behind this KPI, oldest to newest, drawn as a sparkline. The last point should agree with value."
1006
- ),
1007
- value: z.number()
1008
- })
1009
- ).min(1).max(4)
1010
- }),
1011
- line,
1012
- list: base.extend({
1013
- items: z.array(
1014
- z.object({
1015
- checked: z.boolean().optional(),
1016
- children: z.array(shortText).max(8).optional(),
1017
- id,
1018
- text: shortText
1019
- })
1020
- ).min(1).max(30),
1021
- kind: z.literal("list"),
1022
- style: z.enum(["bulleted", "checklist", "numbered"]).optional()
1023
- }),
1024
- listBlock: base.extend({
1025
- items: z.array(
1026
- z.object({
1027
- description: shortText.optional(),
1028
- icon: agentIconSchema.optional(),
1029
- id,
1030
- imageAlt: shortText.optional(),
1031
- imageUrl: displayImageSrc.optional(),
1032
- meta: z.string().trim().max(100).optional(),
1033
- rating: z.number().min(0).max(5).optional(),
1034
- title: shortText
1035
- })
1036
- ).min(1).max(20),
1037
- kind: z.literal("list-block")
1038
- }),
1039
- map: base.extend({
1040
- initialLocationId: id.optional(),
1041
- kind: z.literal("map"),
1042
- locations: z.array(mapLocation).min(1).max(12),
1043
- viewport: z.object({ center: mapCoordinate, zoom: z.number().int().min(1).max(18) }).optional()
1044
- }).superRefine((map, ctx) => {
1045
- const locationIds = /* @__PURE__ */ new Set();
1046
- for (const [index, location] of map.locations.entries()) {
1047
- if (locationIds.has(location.id)) {
1048
- ctx.addIssue({
1049
- code: "custom",
1050
- message: `Duplicate map location id "${location.id}"`,
1051
- path: ["locations", index, "id"]
1052
- });
1053
- }
1054
- locationIds.add(location.id);
1055
- const actionIds = /* @__PURE__ */ new Set();
1056
- for (const [actionIndex, action2] of (location.actions ?? []).entries()) {
1057
- if (actionIds.has(action2.id)) {
1058
- ctx.addIssue({
1059
- code: "custom",
1060
- message: `Duplicate action id "${action2.id}" for map location "${location.id}"`,
1061
- path: ["locations", index, "actions", actionIndex, "id"]
1062
- });
1063
- }
1064
- actionIds.add(action2.id);
1065
- }
1066
- }
1067
- if (map.initialLocationId && !locationIds.has(map.initialLocationId)) {
1068
- ctx.addIssue({
1069
- code: "custom",
1070
- message: "The initial map location must reference one of the locations",
1071
- path: ["initialLocationId"]
1072
- });
1073
- }
1074
- }).describe(
1075
- "A ranked, map-synchronized set of places or professionals. Coordinates and listing facts must come from tools or user data; never invent them."
1076
- ),
1077
- meterList: base.extend({
1078
- items: z.array(meterItem).min(1).max(8),
1079
- kind: z.literal("meter-list")
1080
- }),
1081
- metricGrid: base.extend({
1082
- kind: z.literal("metric-grid"),
1083
- metrics: z.array(
1084
- z.object({
1085
- change: z.number().optional(),
1086
- format: numberFormatSchema.optional(),
1087
- icon: agentIconSchema.optional(),
1088
- label: shortText,
1089
- value: z.number()
1090
- })
1091
- ).min(1).max(4)
1092
- }),
1093
- pie: proportional.extend({ kind: z.literal("pie-chart") }),
1094
- playerCard: base.extend({
1095
- backgroundImage: agentUIImage.optional(),
1096
- jerseyNumber: z.string().trim().min(1).max(20).optional(),
1097
- kind: z.literal("player-card"),
1098
- playerName: shortText,
1099
- stats: z.array(
1100
- z.object({
1101
- label: z.string().trim().min(1).max(40),
1102
- value: z.union([z.string().trim().min(1).max(80), z.number().finite()])
1103
- })
1104
- ).min(1).max(8)
1105
- }),
1106
- playlist: base.extend({
1107
- actions: z.array(action).max(2).optional(),
1108
- cover: agentUIImage.optional(),
1109
- kind: z.literal("playlist"),
1110
- tracks: z.array(
1111
- z.object({
1112
- action: action.optional(),
1113
- artist: shortText,
1114
- id,
1115
- image: agentUIImage.optional(),
1116
- title: shortText
1117
- })
1118
- ).min(1).max(20)
1119
- }),
1120
- productCard: base.extend({
1121
- actions: z.array(action).max(3).optional(),
1122
- kind: z.literal("product-card"),
1123
- products: z.array(productCardItem).min(1).max(8),
1124
- variant: cardComponentVariantSchema.optional()
1125
- }).superRefine((card, ctx) => {
1126
- const productIds = /* @__PURE__ */ new Set();
1127
- for (const [index, item] of card.products.entries()) {
1128
- if (productIds.has(item.id)) {
1129
- ctx.addIssue({
1130
- code: "custom",
1131
- message: `Duplicate product id "${item.id}"`,
1132
- path: ["products", index, "id"]
1133
- });
1134
- }
1135
- productIds.add(item.id);
1136
- }
1137
- }).describe(
1138
- "A commerce product presentation: one product renders an image-led spotlight, several render a store-style grid. Product facts (id, name, image, price, rating, availability) must come from tools or user data; never invent them."
1139
- ),
1140
- purchaseComplete: base.extend({
1141
- action: action.optional(),
1142
- details: z.array(z.object({ label: shortText, value: shortText })).max(8),
1143
- kind: z.literal("purchase-complete"),
1144
- paid: amount.optional(),
1145
- product: z.object({
1146
- description: shortText.optional(),
1147
- image: agentUIImage.optional(),
1148
- name: shortText
1149
- })
1150
- }),
1151
- purchaseItems: base.extend({
1152
- actions: z.array(action).max(3).optional(),
1153
- currency,
1154
- items: z.array(
1155
- z.object({
1156
- description: shortText.optional(),
1157
- id,
1158
- image: agentUIImage.optional(),
1159
- name: shortText,
1160
- price: z.number().finite().nonnegative().max(1e9).optional(),
1161
- quantity: z.number().int().positive().max(1e4).optional()
1162
- })
1163
- ).min(1).max(20),
1164
- kind: z.literal("purchase-items"),
1165
- totals: z.array(
1166
- z.object({
1167
- amount: z.number().finite().nonnegative().max(1e9),
1168
- emphasis: z.boolean().optional(),
1169
- label: shortText
1170
- })
1171
- ).min(1).max(8)
1172
- }),
1173
- radar: base.extend({
1174
- angleKey: key,
1175
- data: z.array(datum).min(3).max(50),
1176
- kind: z.literal("radar-chart"),
1177
- series: z.array(series).min(1).max(5)
1178
- }),
1179
- radial: proportional.extend({
1180
- endAngle: z.number().min(-360).max(360).optional(),
1181
- kind: z.literal("radial-chart"),
1182
- maxValue: z.number().positive().optional(),
1183
- startAngle: z.number().min(-360).max(360).optional()
1184
- }),
1185
- recordCard: base.extend({
1186
- actions: z.array(action).max(4).optional(),
1187
- eyebrow: z.string().trim().max(100).optional(),
1188
- fields: z.array(
1189
- z.object({
1190
- icon: agentIconSchema.optional(),
1191
- label: shortText,
1192
- tone: recordTone.optional(),
1193
- value: z.string().trim().min(1).max(500)
1194
- })
1195
- ).max(12),
1196
- image: z.object({ alt: shortText, src: displayImageSrc }).optional(),
1197
- kind: z.literal("record-card"),
1198
- layout: recordCardLayoutSchema.optional(),
1199
- status: z.object({
1200
- label: shortText,
1201
- tone: recordTone.optional()
1202
- }).optional(),
1203
- variant: cardComponentVariantSchema.optional()
1204
- }).superRefine((card, ctx) => {
1205
- if (card.layout === "media" && !card.image) {
1206
- ctx.addIssue({
1207
- code: "custom",
1208
- message: "The media record layout requires an image",
1209
- path: ["image"]
1210
- });
1211
- }
1212
- if (card.layout === "compact" && card.fields.length > 4) {
1213
- ctx.addIssue({
1214
- code: "custom",
1215
- message: "The compact record layout supports at most four fields",
1216
- path: ["fields"]
1217
- });
1218
- }
1219
- }),
1220
- rideStatus: base.extend({
1221
- driver: z.object({ image: agentUIImage.optional(), name: shortText }),
1222
- eta: z.string().trim().min(1).max(80),
1223
- kind: z.literal("ride-status"),
1224
- pickup: shortText
1225
- }),
1226
- sankey: base.extend({
1227
- format: numberFormatSchema.optional(),
1228
- kind: z.literal("sankey-chart"),
1229
- links: z.array(z.object({ source: id, target: id, value: z.number().positive() })).min(1).max(100),
1230
- nodes: z.array(z.object({ id, label: shortText })).min(2).max(40)
1231
- }),
1232
- scatter,
1233
- steps: base.extend({
1234
- kind: z.literal("steps"),
1235
- steps: z.array(
1236
- z.object({
1237
- content: shortText.optional(),
1238
- icon: agentIconSchema.optional(),
1239
- id,
1240
- image: agentUIImage.optional().describe(
1241
- "A representative raster image for this step. Prefer this over icon for place itineraries when a trusted image URL is available."
1242
- ),
1243
- meta: z.string().trim().max(100).optional(),
1244
- progress: z.number().min(0).max(100).optional(),
1245
- status: z.enum([
1246
- "blocked",
1247
- "cancelled",
1248
- "completed",
1249
- "failed",
1250
- "in-progress",
1251
- "pending",
1252
- "complete",
1253
- "current",
1254
- "upcoming"
1255
- ]).optional(),
1256
- timestamp: z.string().trim().max(100).optional(),
1257
- title: shortText
1258
- })
1259
- ).min(1).max(12),
1260
- variant: z.enum(["steps", "timeline"]).optional()
1261
- }),
1262
- sunburst,
1263
- switches: base.extend({
1264
- items: z.array(
1265
- z.object({
1266
- defaultSelected: z.boolean().optional(),
1267
- description: shortText.optional(),
1268
- id,
1269
- label: shortText
1270
- })
1271
- ).min(1).max(20),
1272
- kind: z.literal("switch-group")
1273
- }),
1274
- table: base.extend({
1275
- columns: z.array(z.object({ format: numberFormatSchema.optional(), key, label: shortText })).min(1).max(12),
1276
- filterable: z.boolean().optional(),
1277
- kind: z.literal("data-table"),
1278
- rows: z.array(datum).max(200),
1279
- variant: z.enum(["primary", "secondary"]).optional()
1280
- }),
1281
- tabs: base.extend({
1282
- defaultValue: id.optional(),
1283
- kind: z.literal("tabs"),
1284
- tabs: z.array(
1285
- z.union([
1286
- z.object({
1287
- children: z.never().optional(),
1288
- content,
1289
- id,
1290
- label: shortText
1291
- }),
1292
- z.object({
1293
- children: z.array(z.lazy(() => agentUINodeSchema)).min(1).max(12),
1294
- content: z.never().optional(),
1295
- id,
1296
- label: shortText
1297
- })
1298
- ])
1299
- ).min(1).max(10),
1300
- variant: z.enum(["primary", "secondary"]).optional()
1301
- }),
1302
- tags: base.extend({ kind: z.literal("tag-list"), tags: z.array(shortText).min(1).max(30) }),
1303
- text: base.extend({
1304
- content,
1305
- kind: z.literal("text"),
1306
- variant: z.enum(["card", "clear"]).optional()
1307
- }),
1308
- toggles: base.extend({
1309
- defaultValue: z.array(id).max(12).optional(),
1310
- items: z.array(z.object({ id, label: shortText })).min(1).max(12),
1311
- kind: z.literal("toggle-group"),
1312
- selectionMode: z.enum(["multiple", "single"]).optional()
1313
- }),
1314
- viewEvent: base.extend({
1315
- date: z.string().trim().min(1).max(80),
1316
- kind: z.literal("view-event"),
1317
- time: z.string().trim().min(1).max(80),
1318
- tone: recordTone.optional()
1319
- }),
1320
- weatherCurrent: base.extend({
1321
- condition: weatherConditionSchema,
1322
- details: z.array(z.object({ label: shortText, value: shortText })).max(6).optional(),
1323
- kind: z.literal("weather-current"),
1324
- location: shortText,
1325
- temperature: z.number().finite().min(-150).max(150),
1326
- unit: weatherUnit
1327
- }),
1328
- weatherForecast: base.extend({
1329
- condition: weatherConditionSchema,
1330
- forecast: z.array(
1331
- z.object({
1332
- condition: weatherConditionSchema,
1333
- label: z.string().trim().min(1).max(40),
1334
- temperature: z.number().finite().min(-150).max(150)
1335
- })
1336
- ).min(2).max(10),
1337
- high: z.number().finite().min(-150).max(150),
1338
- kind: z.literal("weather-forecast"),
1339
- location: shortText,
1340
- low: z.number().finite().min(-150).max(150),
1341
- unit: weatherUnit
1342
- })
1343
- };
1344
- var metricGridComponentSchema = validators.metricGrid;
1345
- var kpiGridComponentSchema = validators.kpiGrid;
1346
- var lineChartComponentSchema = validators.line;
1347
- var areaChartComponentSchema = validators.area;
1348
- var barChartComponentSchema = validators.bar;
1349
- var composedChartComponentSchema = validators.composed;
1350
- var pieChartComponentSchema = validators.pie;
1351
- var donutChartComponentSchema = validators.donut;
1352
- var radarChartComponentSchema = validators.radar;
1353
- var radialChartComponentSchema = validators.radial;
1354
- var sankeyChartComponentSchema = validators.sankey;
1355
- var scatterChartComponentSchema = validators.scatter;
1356
- var heatmapComponentSchema = validators.heatmap;
1357
- var candlestickChartComponentSchema = validators.candlestick;
1358
- var funnelChartComponentSchema = validators.funnel;
1359
- var gaugeChartComponentSchema = validators.gauge;
1360
- var sunburstChartComponentSchema = validators.sunburst;
1361
- var dataTableComponentSchema = validators.table;
1362
- var comparisonListComponentSchema = validators.comparison;
1363
- var meterListComponentSchema = validators.meterList;
1364
- var formComponentSchema = validators.form;
1365
- var textComponentSchema = validators.text;
1366
- var calloutComponentSchema = validators.callout;
1367
- var imageComponentSchema = validators.image;
1368
- var mapComponentSchema = validators.map;
1369
- var tagListComponentSchema = validators.tags;
1370
- var listComponentSchema = validators.list;
1371
- var listBlockComponentSchema = validators.listBlock;
1372
- var accordionComponentSchema = validators.accordion;
1373
- var stepsComponentSchema = validators.steps;
1374
- var codeBlockComponentSchema = validators.code;
1375
- var diagramComponentSchema = validators.diagram;
1376
- var tabsComponentSchema = validators.tabs.superRefine(validateTabsComponent);
1377
- var actionGroupComponentSchema = validators.actions;
1378
- var followupComponentSchema = validators.followup;
1379
- var switchGroupComponentSchema = validators.switches;
1380
- var toggleGroupComponentSchema = validators.toggles;
1381
- var recordCardComponentSchema = validators.recordCard;
1382
- var productCardComponentSchema = validators.productCard;
1383
- var flightTrackerComponentSchema = validators.flightTracker;
1384
- var createEventComponentSchema = validators.createEvent;
1385
- var playlistComponentSchema = validators.playlist;
1386
- var rideStatusComponentSchema = validators.rideStatus;
1387
- var purchaseItemsComponentSchema = validators.purchaseItems;
1388
- var channelMessageComponentSchema = validators.channelMessage;
1389
- var purchaseCompleteComponentSchema = validators.purchaseComplete;
1390
- var playerCardComponentSchema = validators.playerCard;
1391
- var viewEventComponentSchema = validators.viewEvent;
1392
- var eventSessionComponentSchema = validators.eventSession;
1393
- var enableNotificationComponentSchema = validators.enableNotification;
1394
- var weatherForecastComponentSchema = validators.weatherForecast;
1395
- var weatherCurrentComponentSchema = validators.weatherCurrent;
1396
- var analyticalLeafComponentSchema = z.discriminatedUnion("kind", [
1397
- validators.metricGrid,
1398
- validators.kpiGrid,
1399
- validators.line,
1400
- validators.area,
1401
- validators.bar,
1402
- validators.composed,
1403
- validators.pie,
1404
- validators.donut,
1405
- validators.radar,
1406
- validators.radial,
1407
- validators.sankey,
1408
- validators.scatter,
1409
- validators.heatmap,
1410
- validators.candlestick,
1411
- validators.funnel,
1412
- validators.gauge,
1413
- validators.sunburst,
1414
- validators.table,
1415
- validators.comparison,
1416
- validators.meterList
1417
- ]);
1418
- var productSignalsShape = base.extend({
1419
- defaultValue: id.optional(),
1420
- kind: z.literal("product-signals"),
1421
- tabs: z.array(z.object({ component: analyticalLeafComponentSchema, id, label: shortText })).min(2).max(4)
1422
- });
1423
- var productSignalsComponentSchema = productSignalsShape.superRefine((signals, ctx) => {
1424
- const ids = /* @__PURE__ */ new Set();
1425
- for (const [index, tab] of signals.tabs.entries()) {
1426
- if (ids.has(tab.id)) {
1427
- ctx.addIssue({
1428
- code: "custom",
1429
- message: `Duplicate product signal tab id "${tab.id}"`,
1430
- path: ["tabs", index, "id"]
1431
- });
1432
- }
1433
- ids.add(tab.id);
1434
- }
1435
- if (signals.defaultValue && !ids.has(signals.defaultValue)) {
1436
- ctx.addIssue({
1437
- code: "custom",
1438
- message: "The default product signal must reference one of the tabs",
1439
- path: ["defaultValue"]
1440
- });
1441
- }
1442
- });
1443
- var standardAgentUILeafComponentSchema = z.discriminatedUnion("kind", [
1444
- validators.metricGrid,
1445
- validators.kpiGrid,
1446
- validators.line,
1447
- validators.area,
1448
- validators.bar,
1449
- validators.composed,
1450
- validators.pie,
1451
- validators.donut,
1452
- validators.radar,
1453
- validators.radial,
1454
- validators.sankey,
1455
- validators.scatter,
1456
- validators.heatmap,
1457
- validators.candlestick,
1458
- validators.funnel,
1459
- validators.gauge,
1460
- validators.sunburst,
1461
- validators.table,
1462
- validators.comparison,
1463
- validators.meterList,
1464
- validators.form,
1465
- validators.text,
1466
- validators.callout,
1467
- validators.image,
1468
- validators.map,
1469
- validators.tags,
1470
- validators.list,
1471
- validators.listBlock,
1472
- validators.accordion,
1473
- validators.steps,
1474
- validators.code,
1475
- validators.diagram,
1476
- validators.tabs,
1477
- validators.actions,
1478
- validators.followup,
1479
- validators.switches,
1480
- validators.toggles,
1481
- validators.recordCard,
1482
- validators.productCard,
1483
- validators.flightTracker,
1484
- validators.createEvent,
1485
- validators.playlist,
1486
- validators.rideStatus,
1487
- validators.purchaseItems,
1488
- validators.channelMessage,
1489
- validators.purchaseComplete,
1490
- validators.playerCard,
1491
- validators.viewEvent,
1492
- validators.eventSession,
1493
- validators.enableNotification,
1494
- validators.weatherForecast,
1495
- validators.weatherCurrent
1496
- ]);
1497
- function findDuplicateId(items) {
1498
- if (!items) return void 0;
1499
- const ids = /* @__PURE__ */ new Set();
1500
- for (const item of items) {
1501
- if (ids.has(item.id)) return item.id;
1502
- ids.add(item.id);
1503
- }
1504
- return void 0;
1505
- }
1506
- var agentUILeafComponentSchema = z.union([standardAgentUILeafComponentSchema, productSignalsComponentSchema]).superRefine((component, ctx) => {
1507
- const collections = [];
1508
- switch (component.kind) {
1509
- case "channel-message":
1510
- collections.push({ items: component.attachments, path: "attachments" });
1511
- break;
1512
- case "create-event":
1513
- collections.push({ items: component.events, path: "events" });
1514
- collections.push({ items: component.actions, path: "actions" });
1515
- break;
1516
- case "enable-notification":
1517
- collections.push({ items: component.actions, path: "actions" });
1518
- break;
1519
- case "playlist":
1520
- collections.push({ items: component.tracks, path: "tracks" });
1521
- collections.push({ items: component.actions, path: "actions" });
1522
- break;
1523
- case "purchase-items":
1524
- collections.push({ items: component.items, path: "items" });
1525
- collections.push({ items: component.actions, path: "actions" });
1526
- break;
1527
- case "tabs": {
1528
- validateTabsComponent(component, ctx);
1529
- break;
1530
- }
1531
- default:
1532
- break;
1533
- }
1534
- for (const collection of collections) {
1535
- const duplicateId = findDuplicateId(collection.items);
1536
- if (duplicateId) {
1537
- ctx.addIssue({
1538
- code: "custom",
1539
- message: `Duplicate ${collection.path} id "${duplicateId}"`,
1540
- path: [collection.path]
1541
- });
1542
- }
1543
- }
1544
- });
1545
- var dashboardShape = base.extend({
1546
- children: z.array(agentUILeafComponentSchema).min(1).max(4),
1547
- kind: z.literal("dashboard"),
1548
- layout: z.enum(["chart-table", "grid", "metrics-chart", "stack"])
1549
- });
1550
- var dashboardComponentSchema = dashboardShape;
1551
- var agentUIComponentSchema = z.union([
1552
- agentUILeafComponentSchema,
1553
- dashboardComponentSchema
1554
- ]);
1555
- var renderComponentInputSchema = z.object({
1556
- component: agentUIComponentSchema
1557
- });
1558
- var COMPOSED_UI_MAX_DEPTH = 6;
1559
- var COMPOSED_UI_MAX_NODES = 48;
1560
- var CONTAINER_KINDS = /* @__PURE__ */ new Set([
1561
- "card",
1562
- "col",
1563
- "grid",
1564
- "item-card",
1565
- "item-card-group",
1566
- "row"
1567
- ]);
1568
- var LAYOUT_LEAF_KINDS = /* @__PURE__ */ new Set(["divider", "spacer"]);
1569
- var PRIMITIVE_KINDS = /* @__PURE__ */ new Set([
1570
- "badge",
1571
- "button",
1572
- "heading",
1573
- "icon",
1574
- "progress",
1575
- "rating"
1576
- ]);
1577
- var AGENT_UI_CONTAINER_KINDS = CONTAINER_KINDS;
1578
- var AGENT_UI_LAYOUT_LEAF_KINDS = LAYOUT_LEAF_KINDS;
1579
- var AGENT_UI_PRIMITIVE_KINDS = PRIMITIVE_KINDS;
1580
- function isAgentUIContainerComponent(node) {
1581
- return CONTAINER_KINDS.has(node.kind);
1582
- }
1583
- function getAgentUIContainerChildren(node) {
1584
- if (node.kind === "item-card") {
1585
- return [...node.left ?? [], ...node.middle, ...node.right ?? []];
1586
- }
1587
- return node.children;
1588
- }
1589
- function isAgentUILayoutLeafComponent(node) {
1590
- return LAYOUT_LEAF_KINDS.has(node.kind);
1591
- }
1592
- function isAgentUIPrimitiveComponent(node) {
1593
- return PRIMITIVE_KINDS.has(node.kind);
1594
- }
1595
- var layoutBase = z.object({ id });
1596
- var layoutGap = z.enum(["lg", "md", "none", "sm"]);
1597
- var layoutAlign = z.enum(["center", "end", "start", "stretch"]);
1598
- var layoutJustify = z.enum(["between", "center", "end", "start"]);
1599
- var nodeChildren = z.array(z.lazy(() => agentUINodeSchema)).min(1).max(COMPOSED_UI_MAX_NODES);
1600
- var spacerComponentSchema = layoutBase.extend({
1601
- kind: z.literal("spacer"),
1602
- size: z.enum(["auto", "lg", "md", "sm"]).optional()
1603
- });
1604
- var dividerComponentSchema = layoutBase.extend({
1605
- kind: z.literal("divider")
1606
- });
1607
- var headingComponentSchema = layoutBase.extend({
1608
- icon: agentIconSchema.optional(),
1609
- kind: z.literal("heading"),
1610
- level: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]).optional(),
1611
- text: shortText
1612
- });
1613
- var buttonComponentSchema = layoutBase.extend({
1614
- icon: agentIconSchema.optional(),
1615
- kind: z.literal("button"),
1616
- label: shortText,
1617
- prompt: z.string().trim().min(1).max(2e3).optional(),
1618
- toolCall: actionToolCall.optional(),
1619
- variant: actionVariant.optional()
1620
- }).refine((button) => Boolean(button.prompt ?? button.toolCall), {
1621
- message: "Buttons need a prompt or a toolCall to do something when pressed"
1622
- });
1623
- var badgeComponentSchema = layoutBase.extend({
1624
- kind: z.literal("badge"),
1625
- label: shortText,
1626
- tone: recordTone.optional(),
1627
- variant: z.enum(["soft", "solid"]).optional()
1628
- });
1629
- var iconComponentSchema = layoutBase.extend({
1630
- kind: z.literal("icon"),
1631
- name: agentIconSchema,
1632
- size: z.enum(["lg", "md", "sm"]).optional(),
1633
- tone: recordTone.optional()
1634
- });
1635
- var ratingComponentSchema = layoutBase.extend({
1636
- count: z.number().int().nonnegative().max(1e9).optional(),
1637
- kind: z.literal("rating"),
1638
- value: z.number().finite().min(0).max(5)
1639
- });
1640
- var progressComponentSchema = layoutBase.extend({
1641
- kind: z.literal("progress"),
1642
- label: shortText.optional(),
1643
- value: z.number().finite().min(0).max(100)
1644
- });
1645
- var itemCardVariant = z.enum(["default", "outline", "secondary", "tertiary", "transparent"]);
1646
- var itemCardSlotNode = z.lazy(() => agentUINodeSchema);
1647
- var itemCardShape = base.extend({
1648
- action: action.optional().describe(
1649
- "Makes the whole row pressable. Omit when a slot contains its own button or other interactive control."
1650
- ),
1651
- isDisabled: z.boolean().optional(),
1652
- isSelected: z.boolean().optional(),
1653
- kind: z.literal("item-card"),
1654
- left: z.array(itemCardSlotNode).min(1).max(4).optional().describe("Leading slot. Prefer one icon node or a compact visual."),
1655
- middle: z.array(itemCardSlotNode).min(1).max(8).describe(
1656
- "Primary flexible slot. Prefer a level-4 heading followed by a clear text node for a title and description."
1657
- ),
1658
- right: z.array(itemCardSlotNode).min(1).max(4).optional().describe("Trailing slot. Prefer a badge, short value, icon, or button."),
1659
- variant: itemCardVariant.optional()
1660
- });
1661
- var INTERACTIVE_ITEM_CARD_DESCENDANT_KINDS = /* @__PURE__ */ new Set([
1662
- "accordion",
1663
- "action-group",
1664
- "button",
1665
- "followup",
1666
- "form",
1667
- "map",
1668
- "switch-group",
1669
- "tabs",
1670
- "toggle-group"
1671
- ]);
1672
- function containsInteractiveItemCardDescendant(nodes) {
1673
- for (const node of nodes) {
1674
- if (INTERACTIVE_ITEM_CARD_DESCENDANT_KINDS.has(node.kind)) return true;
1675
- if (isAgentUIContainerComponent(node) && containsInteractiveItemCardDescendant(getAgentUIContainerChildren(node))) {
1676
- return true;
1677
- }
1678
- }
1679
- return false;
1680
- }
1681
- var itemCardComponentSchema = itemCardShape.superRefine(
1682
- (card, ctx) => {
1683
- if (card.action && containsInteractiveItemCardDescendant([
1684
- ...card.left ?? [],
1685
- ...card.middle,
1686
- ...card.right ?? []
1687
- ])) {
1688
- ctx.addIssue({
1689
- code: "custom",
1690
- message: "A pressable item-card cannot contain buttons or other interactive descendants. Remove action from the card or move the nested control outside it."
1691
- });
1692
- }
1693
- }
1694
- );
1695
- var itemCardGroupShape = base.extend({
1696
- children: z.array(itemCardComponentSchema).min(1).max(12),
1697
- columns: z.union([z.literal(2), z.literal(3)]).optional(),
1698
- kind: z.literal("item-card-group"),
1699
- layout: z.enum(["grid", "list"]).optional(),
1700
- showHeader: z.boolean().optional(),
1701
- variant: itemCardVariant.optional()
1702
- });
1703
- var itemCardGroupComponentSchema = itemCardGroupShape.superRefine((group2, ctx) => {
1704
- if (group2.columns && group2.layout !== "grid") {
1705
- ctx.addIssue({
1706
- code: "custom",
1707
- message: "Item-card group columns only apply when layout is grid.",
1708
- path: ["columns"]
1709
- });
1710
- }
1711
- });
1712
- var rowShape = layoutBase.extend({
1713
- align: layoutAlign.optional(),
1714
- children: nodeChildren,
1715
- gap: layoutGap.optional(),
1716
- justify: layoutJustify.optional(),
1717
- kind: z.literal("row")
1718
- });
1719
- var colShape = layoutBase.extend({
1720
- align: layoutAlign.optional(),
1721
- children: nodeChildren,
1722
- gap: layoutGap.optional(),
1723
- justify: layoutJustify.optional(),
1724
- kind: z.literal("col")
1725
- });
1726
- var gridShape = layoutBase.extend({
1727
- children: nodeChildren,
1728
- columns: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]),
1729
- gap: layoutGap.optional(),
1730
- kind: z.literal("grid")
1731
- });
1732
- var cardShape = base.extend({
1733
- children: nodeChildren,
1734
- kind: z.literal("card"),
1735
- variant: cardComponentVariantSchema.optional()
1736
- });
1737
- var rowComponentSchema = rowShape;
1738
- var colComponentSchema = colShape;
1739
- var gridComponentSchema = gridShape;
1740
- var cardComponentSchema = cardShape;
1741
- var agentUINodeSchema = z.union([
1742
- agentUILeafComponentSchema,
1743
- spacerComponentSchema,
1744
- dividerComponentSchema,
1745
- headingComponentSchema,
1746
- buttonComponentSchema,
1747
- badgeComponentSchema,
1748
- iconComponentSchema,
1749
- ratingComponentSchema,
1750
- progressComponentSchema,
1751
- rowComponentSchema,
1752
- colComponentSchema,
1753
- gridComponentSchema,
1754
- cardComponentSchema,
1755
- itemCardComponentSchema,
1756
- itemCardGroupComponentSchema
1757
- ]);
1758
- function validateComposedTree(root, ctx) {
1759
- validateNodeTree(root, ctx);
1760
- }
1761
- function validateTabContentTrees(component, ctx) {
1762
- const richChildren = component.tabs.flatMap((tab) => tab.children ?? []);
1763
- if (richChildren.length === 0) return;
1764
- validateNodeForest(richChildren, ctx, component.id, 2, 1);
1765
- }
1766
- function validateTabsComponent(component, ctx) {
1767
- const tabIds = /* @__PURE__ */ new Set();
1768
- for (const [index, tab] of component.tabs.entries()) {
1769
- if (tabIds.has(tab.id)) {
1770
- ctx.addIssue({
1771
- code: "custom",
1772
- message: `Duplicate tab id "${tab.id}"`,
1773
- path: ["tabs", index, "id"]
1774
- });
1775
- }
1776
- tabIds.add(tab.id);
1777
- }
1778
- if (component.defaultValue && !tabIds.has(component.defaultValue)) {
1779
- ctx.addIssue({
1780
- code: "custom",
1781
- message: "The default tab must reference one of the tabs",
1782
- path: ["defaultValue"]
1783
- });
1784
- }
1785
- validateTabContentTrees(component, ctx);
1786
- }
1787
- function nestedNodeChildren(node) {
1788
- if (isAgentUIContainerComponent(node)) return getAgentUIContainerChildren(node);
1789
- if (node.kind === "tabs") return node.tabs.flatMap((tab) => tab.children ?? []);
1790
- return [];
1791
- }
1792
- function validateNodeForest(roots, ctx, reservedRootId, initialDepth = 1, initialNodeCount = 0) {
1793
- const ids = /* @__PURE__ */ new Set();
1794
- let nodeCount = initialNodeCount;
1795
- let deepest = initialNodeCount > 0 ? initialDepth - 1 : 0;
1796
- if (reservedRootId) ids.add(reservedRootId);
1797
- const walk = (node, depth) => {
1798
- nodeCount += 1;
1799
- deepest = Math.max(deepest, depth);
1800
- if (ids.has(node.id)) {
1801
- ctx.addIssue({
1802
- code: "custom",
1803
- message: `Duplicate component id "${node.id}" in the composed UI tree. Every node needs a unique id.`
1804
- });
1805
- }
1806
- ids.add(node.id);
1807
- if (depth > COMPOSED_UI_MAX_DEPTH) return;
1808
- for (const child of nestedNodeChildren(node)) walk(child, depth + 1);
1809
- };
1810
- for (const root of roots) walk(root, initialDepth);
1811
- if (deepest > COMPOSED_UI_MAX_DEPTH) {
1812
- ctx.addIssue({
1813
- code: "custom",
1814
- message: `Composed UI trees can nest at most ${COMPOSED_UI_MAX_DEPTH} levels deep.`
1815
- });
1816
- }
1817
- if (nodeCount > COMPOSED_UI_MAX_NODES) {
1818
- ctx.addIssue({
1819
- code: "custom",
1820
- message: `Composed UI trees can contain at most ${COMPOSED_UI_MAX_NODES} components.`
1821
- });
1822
- }
1823
- }
1824
- function validateNodeTree(root, ctx) {
1825
- validateNodeForest([root], ctx);
1826
- }
1827
- var composedUIComponentSchema = z.union([
1828
- rowComponentSchema,
1829
- colComponentSchema,
1830
- gridComponentSchema,
1831
- cardComponentSchema,
1832
- itemCardComponentSchema,
1833
- itemCardGroupComponentSchema
1834
- ]).superRefine(validateComposedTree);
1835
- var agentUIRenderableSchema = z.union([
1836
- agentUIComponentSchema,
1837
- composedUIComponentSchema
1838
- ]);
1839
- var composeUIInputSchema = z.object({
1840
- component: composedUIComponentSchema
1841
- });
1842
- var opaqueChildren = (max) => z.array(z.unknown()).min(1).max(max).describe("Child nodes. Each is any catalog component; look its kind up separately.");
1843
- var AGENT_UI_KIND_SCHEMAS = {
1844
- accordion: accordionComponentSchema,
1845
- "action-group": actionGroupComponentSchema,
1846
- "area-chart": areaChartComponentSchema,
1847
- badge: badgeComponentSchema,
1848
- "bar-chart": barChartComponentSchema,
1849
- button: buttonComponentSchema,
1850
- callout: calloutComponentSchema,
1851
- "candlestick-chart": candlestickChartComponentSchema,
1852
- card: cardShape.extend({ children: opaqueChildren(COMPOSED_UI_MAX_NODES) }),
1853
- "channel-message": channelMessageComponentSchema,
1854
- "code-block": codeBlockComponentSchema,
1855
- col: colShape.extend({ children: opaqueChildren(COMPOSED_UI_MAX_NODES) }),
1856
- "comparison-list": comparisonListComponentSchema,
1857
- "composed-chart": composedChartComponentSchema,
1858
- "create-event": createEventComponentSchema,
1859
- dashboard: dashboardShape.extend({ children: opaqueChildren(4) }),
1860
- "data-table": dataTableComponentSchema,
1861
- diagram: diagramComponentSchema,
1862
- divider: dividerComponentSchema,
1863
- "donut-chart": donutChartComponentSchema,
1864
- "enable-notification": enableNotificationComponentSchema,
1865
- "event-session": eventSessionComponentSchema,
1866
- "flight-tracker": flightTrackerComponentSchema,
1867
- followup: followupComponentSchema,
1868
- form: formComponentSchema,
1869
- "funnel-chart": funnelChartComponentSchema,
1870
- "gauge-chart": gaugeChartComponentSchema,
1871
- grid: gridShape.extend({ children: opaqueChildren(COMPOSED_UI_MAX_NODES) }),
1872
- heading: headingComponentSchema,
1873
- heatmap: heatmapComponentSchema,
1874
- icon: iconComponentSchema,
1875
- image: imageComponentSchema,
1876
- "item-card": itemCardShape.extend({
1877
- left: opaqueChildren(4).optional().describe("Leading slot nodes."),
1878
- middle: opaqueChildren(8).describe("Primary flexible slot nodes."),
1879
- right: opaqueChildren(4).optional().describe("Trailing slot nodes.")
1880
- }),
1881
- "item-card-group": itemCardGroupShape.extend({
1882
- children: z.array(z.unknown()).min(1).max(12).describe("One to twelve item-card children. Look up item-card for each child's schema.")
1883
- }),
1884
- "kpi-grid": kpiGridComponentSchema,
1885
- "line-chart": lineChartComponentSchema,
1886
- list: listComponentSchema,
1887
- "list-block": listBlockComponentSchema,
1888
- map: mapComponentSchema,
1889
- "meter-list": meterListComponentSchema,
1890
- "metric-grid": metricGridComponentSchema,
1891
- "pie-chart": pieChartComponentSchema,
1892
- "player-card": playerCardComponentSchema,
1893
- playlist: playlistComponentSchema,
1894
- "product-card": productCardComponentSchema,
1895
- "product-signals": productSignalsShape.extend({
1896
- tabs: z.array(
1897
- z.object({
1898
- component: z.unknown().describe(
1899
- "One analytical component: metric-grid, kpi-grid, any chart, data-table, comparison-list, or meter-list. Look its kind up separately."
1900
- ),
1901
- id,
1902
- label: shortText
1903
- })
1904
- ).min(2).max(4)
1905
- }),
1906
- progress: progressComponentSchema,
1907
- "purchase-complete": purchaseCompleteComponentSchema,
1908
- "purchase-items": purchaseItemsComponentSchema,
1909
- "radar-chart": radarChartComponentSchema,
1910
- "radial-chart": radialChartComponentSchema,
1911
- rating: ratingComponentSchema,
1912
- "record-card": recordCardComponentSchema,
1913
- "ride-status": rideStatusComponentSchema,
1914
- row: rowShape.extend({ children: opaqueChildren(COMPOSED_UI_MAX_NODES) }),
1915
- "sankey-chart": sankeyChartComponentSchema,
1916
- "scatter-chart": scatterChartComponentSchema,
1917
- spacer: spacerComponentSchema,
1918
- steps: stepsComponentSchema,
1919
- "sunburst-chart": sunburstChartComponentSchema,
1920
- "switch-group": switchGroupComponentSchema,
1921
- tabs: base.extend({
1922
- defaultValue: id.optional(),
1923
- kind: z.literal("tabs"),
1924
- tabs: z.array(
1925
- z.union([
1926
- z.object({
1927
- content,
1928
- id,
1929
- label: shortText
1930
- }),
1931
- z.object({
1932
- children: opaqueChildren(12).describe(
1933
- "Rich panel nodes rendered as one vertical stack. Look up every child kind separately."
1934
- ),
1935
- id,
1936
- label: shortText
1937
- })
1938
- ])
1939
- ).min(1).max(10),
1940
- variant: z.enum(["primary", "secondary"]).optional()
1941
- }),
1942
- "tag-list": tagListComponentSchema,
1943
- text: textComponentSchema,
1944
- "toggle-group": toggleGroupComponentSchema,
1945
- "view-event": viewEventComponentSchema,
1946
- "weather-current": weatherCurrentComponentSchema,
1947
- "weather-forecast": weatherForecastComponentSchema
1948
- };
1949
-
1950
- // ../agent-ui/src/contracts/catalog.ts
1951
- var SUMMARIES = {
1952
- accordion: "collapsible sections of longer prose",
1953
- "action-group": "buttons that send prompts or call client tools",
1954
- "area-chart": "one continuous time series with a filled trend",
1955
- badge: "a small toned status label",
1956
- "bar-chart": "ranked or categorical comparison, horizontal layout for rankings",
1957
- button: "one action with a prompt or client-tool call",
1958
- callout: "one short toned notice: info, success, warning, or danger",
1959
- "candlestick-chart": "open-high-low-close price movement over ordered periods",
1960
- card: "titled surface grouping related children",
1961
- "channel-message": "a quoted workspace message with author and attachments",
1962
- "code-block": "a syntax-highlighted snippet",
1963
- col: "stacks children vertically",
1964
- "comparison-list": "labeled values with change deltas, no axes",
1965
- "composed-chart": "two to five mixed area/bar/line series, optional dual axis",
1966
- "create-event": "a proposed calendar slot beside surrounding events",
1967
- dashboard: "up to four analytical children in a fixed layout",
1968
- "data-table": "exact values in filterable rows and columns",
1969
- diagram: "a flowchart, sequence, ER, or state diagram from Mermaid source, for processes and relationships prose cannot show",
1970
- divider: "a rule between sections",
1971
- "donut-chart": "proportions of a whole with a hollow center",
1972
- "enable-notification": "a binary notification opt-in with two actions",
1973
- "event-session": "a conference session with time, location, and speakers",
1974
- "flight-tracker": "a flight's route, times, and live progress",
1975
- followup: "suggested next prompts the user can send",
1976
- form: "input fields with submit actions",
1977
- "funnel-chart": "drop-off through ordered conversion or pipeline stages",
1978
- "gauge-chart": "one bounded value against its minimum and maximum",
1979
- grid: "one to four equal columns of peers",
1980
- heading: "a section title, levels one to four",
1981
- heatmap: "two-dimensional intensity across x and y",
1982
- icon: "one semantic glyph from the icon vocabulary",
1983
- image: "one to six real image URLs with captions in a grid or horizontal chat gallery",
1984
- "item-card": "one compact three-slot row with composable left, middle, and right content",
1985
- "item-card-group": "one to twelve related item-card rows in a list or grid",
1986
- "kpi-grid": "up to four headline KPIs, each with a sparkline of its own history",
1987
- "line-chart": "overlapping series, a live signal, or one series split around a baseline",
1988
- list: "bulleted, numbered, or checklist items with optional children",
1989
- "list-block": "richer rows with title, description, meta, rating, icon, or image",
1990
- map: "ranked places pinned by exact latitude and longitude",
1991
- "meter-list": "bounded quantities such as quota, utilization, or budget",
1992
- "metric-grid": "up to four headline KPIs with no history to plot",
1993
- "pie-chart": "proportions of a whole",
1994
- "player-card": "an athlete with jersey, portrait, and stat lines",
1995
- playlist: "a track collection with cover and per-track actions",
1996
- "product-card": "purchasable items with image, price, rating, availability",
1997
- "product-signals": "two to four related analytical views in tabs",
1998
- progress: "a zero to one hundred percentage bar",
1999
- "purchase-complete": "confirmation after a successful transaction",
2000
- "purchase-items": "a cart or order summary with line items and totals",
2001
- "radar-chart": "multivariate comparison across three or more axes",
2002
- "radial-chart": "compact circular measure",
2003
- rating: "a zero to five star score with optional count",
2004
- "record-card": "one entity's labeled facts, layouts details/compact/media",
2005
- "ride-status": "pickup ETA and driver for a ride in progress",
2006
- row: "places complementary children side by side",
2007
- "sankey-chart": "flow volumes between source and target nodes",
2008
- "scatter-chart": "correlation between two numeric fields, optional grouping",
2009
- spacer: "a gap between siblings",
2010
- steps: "task progress or a chronological timeline, up to twelve entries",
2011
- "sunburst-chart": "hierarchical part-to-whole values across nested levels",
2012
- "switch-group": "toggleable boolean preferences",
2013
- tabs: "parallel text or rich multi-component sections behind labeled tabs",
2014
- "tag-list": "short keyword chips",
2015
- text: "explanatory markdown prose",
2016
- "toggle-group": "single or multiple choice from short options",
2017
- "view-event": "one calendar event's date, time, and tone",
2018
- "weather-current": "current conditions in one location",
2019
- "weather-forecast": "multi-day or future conditions with highs and lows"
2020
- };
2021
- var GROUP_BY_CATEGORY = {
2022
- actions: "actions",
2023
- "data-visualization": "data",
2024
- "display-information": "display",
2025
- "form-elements": "forms"
2026
- };
2027
- function groupFor(kind) {
2028
- if (kind === "dashboard" || AGENT_UI_CONTAINER_KINDS.has(kind)) return "containers";
2029
- if (AGENT_UI_LAYOUT_LEAF_KINDS.has(kind)) return "layout";
2030
- if (AGENT_UI_PRIMITIVE_KINDS.has(kind)) return "primitives";
2031
- return GROUP_BY_CATEGORY[COMPONENT_CATEGORY_BY_KIND[kind]] ?? "display";
2032
- }
2033
- var AGENT_UI_CATALOG = Object.fromEntries(
2034
- Object.entries(SUMMARIES).map(([kind, summary]) => [
2035
- kind,
2036
- { group: groupFor(kind), summary }
2037
- ])
2038
- );
2039
- var AGENT_UI_KIND_NAMES = Object.keys(
2040
- SUMMARIES
2041
- ).sort();
2042
- var GROUP_LABELS = [
2043
- ["containers", "Containers"],
2044
- ["layout", "Layout"],
2045
- ["primitives", "Primitives"],
2046
- ["data", "Data"],
2047
- ["display", "Content"],
2048
- ["actions", "Actions"],
2049
- ["forms", "Forms"]
2050
- ];
2051
- function renderAgentUICatalogPrompt() {
2052
- const lines = GROUP_LABELS.map(([group2, label]) => {
2053
- const entries = AGENT_UI_KIND_NAMES.filter(
2054
- (kind) => AGENT_UI_CATALOG[kind].group === group2
2055
- ).map((kind) => `${kind} \u2014 ${AGENT_UI_CATALOG[kind].summary}`);
2056
- return `${label}: ${entries.join("; ")}.`;
2057
- });
2058
- return lines.join("\n");
2059
- }
2060
-
2061
- // src/contracts/client-tools.ts
2062
- import { z as z2 } from "zod";
2063
- var RESERVED_AGENT_TOOL_NAMES = [
2064
- "callMcpTool",
2065
- "composeUI",
2066
- "executeSandbox",
2067
- "getComponentSchema",
2068
- "renderComponent",
2069
- "searchKnowledge",
2070
- "searchMcpTools",
2071
- "searchWeb"
2072
- ];
2073
- var RESERVED_AGENT_TOOL_PREFIX = "mcp_";
2074
- var MAX_CLIENT_TOOLS = 20;
2075
- var MAX_CLIENT_TOOLS_BYTES = 16 * 1024;
2076
- var clientToolManifestEntrySchema = z2.object({
2077
- description: z2.string().trim().min(1).max(1e3),
2078
- inputSchema: z2.record(z2.string(), z2.unknown()),
2079
- name: z2.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(
2080
- (name) => !RESERVED_AGENT_TOOL_NAMES.includes(name) && !name.toLowerCase().startsWith(RESERVED_AGENT_TOOL_PREFIX),
2081
- "Client tool name is reserved by the HeroUI Agent runtime"
2082
- ),
2083
- needsApproval: z2.boolean().optional()
2084
- });
2085
- var clientToolsSchema = z2.array(clientToolManifestEntrySchema).max(MAX_CLIENT_TOOLS).superRefine((tools, context) => {
2086
- const names = /* @__PURE__ */ new Set();
2087
- for (const entry of tools) {
2088
- if (names.has(entry.name)) {
2089
- context.addIssue({ code: "custom", message: `Duplicate client tool name: ${entry.name}` });
2090
- }
2091
- names.add(entry.name);
2092
- }
2093
- if (new TextEncoder().encode(JSON.stringify(tools)).byteLength > MAX_CLIENT_TOOLS_BYTES) {
2094
- context.addIssue({ code: "custom", message: "Client tool manifest exceeds 16KB" });
2095
- }
2096
- });
2097
-
2098
- // src/contracts/identity.ts
2099
- import { z as z3 } from "zod";
2100
-
2101
- // src/contracts/version.ts
2102
- var HEROUI_AGENT_PROTOCOL_VERSION = 6;
2103
- var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.8";
2104
-
2105
- // src/contracts/identity.ts
2106
- var agentThemeSchema = z3.enum(["light", "dark", "system"]);
2107
- var agentSurfaceVariantSchema = z3.enum([
2108
- "outline",
2109
- "plain",
2110
- "surface",
2111
- "surface-secondary"
2112
- ]);
2113
- var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
2114
- "[object object]",
2115
- "0",
2116
- "anonymous",
2117
- "distinct_id",
2118
- "distinctid",
2119
- "email",
2120
- "false",
2121
- "guest",
2122
- "id",
2123
- "nan",
2124
- "none",
2125
- "not_authenticated",
2126
- "null",
2127
- "true",
2128
- "undefined"
2129
- ]);
2130
- var agentIdentityIdSchema = z3.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
2131
- message: "Identity id is reserved"
2132
- });
2133
- var agentAuthIdentitySchema = z3.discriminatedUnion("type", [
2134
- z3.object({
2135
- id: agentIdentityIdSchema,
2136
- type: z3.literal("anonymous")
2137
- }),
2138
- z3.object({
2139
- id: agentIdentityIdSchema,
2140
- type: z3.literal("user")
2141
- })
2142
- ]);
2143
- var agentAuthProfileSchema = z3.object({
2144
- avatarUrl: z3.string().trim().pipe(z3.url()).optional(),
2145
- email: z3.string().trim().max(320).pipe(z3.email()).optional(),
2146
- name: z3.string().trim().max(120).optional()
2147
- });
2148
- var createAgentAuthTokenRequestSchema = z3.object({
2149
- /**
2150
- * Browser-scoped id the SDK passed to the host callback. Sending it together
2151
- * with an identified `identity` merges that anonymous person's conversations
2152
- * into the identified user, so history survives login.
2153
- */
2154
- anonymousId: agentIdentityIdSchema.optional(),
2155
- identity: agentAuthIdentitySchema,
2156
- profile: agentAuthProfileSchema.optional()
2157
- });
2158
- var agentAuthTokenSchema = z3.object({
2159
- expiresAt: z3.number().int().positive(),
2160
- token: z3.string().trim().min(1)
2161
- });
2162
- var agentTokenClaimsSchema = z3.object({
2163
- agentId: z3.string().trim().min(1).max(100),
2164
- apiKeyId: z3.string().trim().min(1).max(100),
2165
- aud: z3.literal("heroui-agent"),
2166
- exp: z3.number().int().positive(),
2167
- iat: z3.number().int().positive(),
2168
- iss: z3.literal("https://api.heroui.com"),
2169
- jti: z3.uuid(),
2170
- protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2171
- sub: z3.string().trim().min(1).max(200)
2172
- });
2173
- var AGENT_CONVERSATION_SOURCE = {
2174
- embed: "embed",
2175
- preview: "preview"
2176
- };
2177
- var agentProjectConfigSchema = z3.object({
2178
- agentId: z3.string(),
2179
- minimumProtocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2180
- name: z3.string().trim().min(1).max(120),
2181
- protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2182
- sdkVersion: z3.string().default(HEROUI_AGENT_SDK_VERSION),
2183
- suggestedPrompts: z3.array(z3.string().trim().min(1).max(160)).max(5),
2184
- surfaceVariant: agentSurfaceVariantSchema.default("plain"),
2185
- theme: agentThemeSchema
2186
- });
2187
-
2188
- // src/contracts/messages.ts
2189
- import { z as z4 } from "zod";
2190
- var agentSourceBaseSchema = z4.object({
2191
- excerpt: z4.string().trim().min(1).max(2e3).optional(),
2192
- locator: z4.string().trim().min(1).max(160).optional(),
2193
- sourceId: z4.string().trim().min(1).max(120)
2194
- });
2195
- var safeSourceUrlSchema = z4.string().trim().max(2048).refine((value) => {
2196
- try {
2197
- return ["http:", "https:"].includes(new URL(value).protocol);
2198
- } catch {
2199
- return false;
2200
- }
2201
- });
2202
- var agentSourceSchema = z4.union([
2203
- agentSourceBaseSchema.extend({
2204
- sourceType: z4.literal("document"),
2205
- title: z4.string().trim().min(1).max(200)
2206
- }),
2207
- agentSourceBaseSchema.extend({
2208
- sourceType: z4.literal("url").optional(),
2209
- title: z4.string().trim().min(1).max(200).optional(),
2210
- url: safeSourceUrlSchema
2211
- })
2212
- ]);
2213
- var agentSourcesSchema = z4.object({
2214
- items: z4.array(agentSourceSchema).min(1).max(16)
2215
- });
2216
-
2217
- // src/contracts/models.ts
2218
- var AGENT_MODEL_IDS = [
2219
- "moonshotai/Kimi-K3",
2220
- "openai/gpt-5.6-luna",
2221
- "openai/gpt-5.6-terra",
2222
- "openai/gpt-5.6-sol",
2223
- "google/gemini-3.6-flash",
2224
- "anthropic/claude-sonnet-5",
2225
- "anthropic/claude-opus-4.8"
2226
- ];
2227
- var LEGACY_AGENT_MODEL_IDS = {
2228
- "google/gemini-3.5-flash": "google/gemini-3.6-flash"
2229
- };
2230
- function resolveAgentModelId(value) {
2231
- return LEGACY_AGENT_MODEL_IDS[value] ?? value;
2232
- }
2233
- var DEFAULT_AGENT_PICKER_MODEL_ID = "openai/gpt-5.6-luna";
2234
- var AGENT_MODEL_OPTIONS = [
2235
- {
2236
- description: "Flagship model for coding, reasoning, and knowledge work",
2237
- id: "moonshotai/Kimi-K3",
2238
- label: "Kimi K3",
2239
- provider: "Moonshot AI",
2240
- tier: "light"
2241
- },
2242
- {
2243
- description: "Fast answers and lightweight agent workflows",
2244
- id: "openai/gpt-5.6-luna",
2245
- label: "GPT-5.6 Luna",
2246
- provider: "OpenAI",
2247
- tier: "light"
2248
- },
2249
- {
2250
- description: "Balanced reasoning for everyday agent tasks",
2251
- id: "openai/gpt-5.6-terra",
2252
- label: "GPT-5.6 Terra",
2253
- provider: "OpenAI",
2254
- tier: "codegen"
2255
- },
2256
- {
2257
- description: "Deep reasoning for complex, multi-step analysis",
2258
- id: "openai/gpt-5.6-sol",
2259
- label: "GPT-5.6 Sol",
2260
- provider: "OpenAI",
2261
- tier: "complex"
2262
- },
2263
- {
2264
- description: "Fast multimodal analysis with a large context window",
2265
- id: "google/gemini-3.6-flash",
2266
- label: "Gemini 3.6 Flash",
2267
- provider: "Google",
2268
- tier: "light"
2269
- },
2270
- {
2271
- description: "Strong agentic reasoning and polished UI decisions",
2272
- id: "anthropic/claude-sonnet-5",
2273
- label: "Claude Sonnet 5",
2274
- provider: "Anthropic",
2275
- tier: "codegen"
2276
- },
2277
- {
2278
- description: "Highest-capability Claude for difficult research and analysis",
2279
- id: "anthropic/claude-opus-4.8",
2280
- label: "Claude Opus 4.8",
2281
- provider: "Anthropic",
2282
- tier: "complex"
2283
- }
2284
- ];
2285
- var AGENT_MODEL_ID_SET = new Set(AGENT_MODEL_IDS);
2286
- function isAgentModelId(value) {
2287
- return typeof value === "string" && AGENT_MODEL_ID_SET.has(value);
2288
- }
2289
- function getAgentModelTier(modelId) {
2290
- const resolved = modelId ? resolveAgentModelId(modelId) : void 0;
2291
- return AGENT_MODEL_OPTIONS.find((option2) => option2.id === resolved)?.tier ?? "light";
2292
- }
2293
-
2294
- // src/contracts/models.schema.ts
2295
- import { z as z5 } from "zod";
2296
- var agentModelIdSchema = z5.preprocess(
2297
- (value) => typeof value === "string" ? resolveAgentModelId(value) : value,
2298
- z5.enum(AGENT_MODEL_IDS)
2299
- );
2300
-
2301
- // src/contracts/runtime.ts
2302
- var HEROUI_AGENT_RUNTIME_TIMING_EVENT = "heroui-agent:runtime-timing";
2303
- var HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE = "heroui_agent_turn_admitted";
2304
- var HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD = "getTurnAdmissionStatuses";
2305
- var HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS = 50;
2306
- export {
2307
- AGENT_CONVERSATION_SOURCE,
2308
- AGENT_MODEL_IDS,
2309
- AGENT_MODEL_OPTIONS,
2310
- AGENT_UI_CATALOG,
2311
- AGENT_UI_CONTAINER_KINDS,
2312
- AGENT_UI_KIND_NAMES,
2313
- AGENT_UI_KIND_SCHEMAS,
2314
- AGENT_UI_LAYOUT_LEAF_KINDS,
2315
- AGENT_UI_PRIMITIVE_KINDS,
2316
- COMPOSED_UI_MAX_DEPTH,
2317
- COMPOSED_UI_MAX_NODES,
2318
- DEFAULT_AGENT_PICKER_MODEL_ID,
2319
- HEROUI_AGENT_ATTACHMENT_ACCEPT,
2320
- HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES,
2321
- HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE,
2322
- HEROUI_AGENT_ATTACHMENT_MAX_BYTES,
2323
- HEROUI_AGENT_MAX_ATTACHMENTS,
2324
- HEROUI_AGENT_PROTOCOL_VERSION,
2325
- HEROUI_AGENT_REMOTE_CONFIG_VERSION,
2326
- HEROUI_AGENT_RUNTIME_TIMING_EVENT,
2327
- HEROUI_AGENT_SDK_VERSION,
2328
- HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES,
2329
- HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS,
2330
- HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD,
2331
- HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE,
2332
- LEGACY_AGENT_MODEL_IDS,
2333
- MAX_CLIENT_TOOLS,
2334
- MAX_CLIENT_TOOLS_BYTES,
2335
- RESERVED_AGENT_TOOL_NAMES,
2336
- RESERVED_AGENT_TOOL_PREFIX,
2337
- accordionComponentSchema,
2338
- actionGroupComponentSchema,
2339
- agentAuthIdentitySchema,
2340
- agentAuthProfileSchema,
2341
- agentAuthTokenSchema,
2342
- agentIconNames,
2343
- agentIconSchema,
2344
- agentIdentityIdSchema,
2345
- agentModelIdSchema,
2346
- agentProjectConfigSchema,
2347
- agentSourceSchema,
2348
- agentSourcesSchema,
2349
- agentSurfaceVariantSchema,
2350
- agentThemeSchema,
2351
- agentTokenClaimsSchema,
2352
- agentUIComponentSchema,
2353
- agentUILeafComponentSchema,
2354
- agentUINodeSchema,
2355
- agentUIRenderableSchema,
2356
- analyticalLeafComponentSchema,
2357
- areaChartComponentSchema,
2358
- badgeComponentSchema,
2359
- barChartComponentSchema,
2360
- buttonComponentSchema,
2361
- calloutComponentSchema,
2362
- candlestickChartComponentSchema,
2363
- cardComponentSchema,
2364
- cardComponentVariantSchema,
2365
- channelMessageComponentSchema,
2366
- chartColorSchema,
2367
- clientToolManifestEntrySchema,
2368
- clientToolsSchema,
2369
- codeBlockComponentSchema,
2370
- colComponentSchema,
2371
- comparisonListComponentSchema,
2372
- composeUIInputSchema,
2373
- composedChartComponentSchema,
2374
- composedUIComponentSchema,
2375
- createAgentAuthTokenRequestSchema,
2376
- createEventComponentSchema,
2377
- dashboardComponentSchema,
2378
- dataTableComponentSchema,
2379
- diagramComponentSchema,
2380
- dividerComponentSchema,
2381
- donutChartComponentSchema,
2382
- enableNotificationComponentSchema,
2383
- eventSessionComponentSchema,
2384
- flightTrackerComponentSchema,
2385
- followupComponentSchema,
2386
- formComponentSchema,
2387
- funnelChartComponentSchema,
2388
- gaugeChartComponentSchema,
2389
- getAgentModelTier,
2390
- getAgentUIContainerChildren,
2391
- gridComponentSchema,
2392
- headingComponentSchema,
2393
- heatmapComponentSchema,
2394
- iconComponentSchema,
2395
- imageComponentSchema,
2396
- isAgentModelId,
2397
- isAgentUIContainerComponent,
2398
- isAgentUILayoutLeafComponent,
2399
- isAgentUIPrimitiveComponent,
2400
- isHeroUIAgentAttachmentContentType,
2401
- itemCardComponentSchema,
2402
- itemCardGroupComponentSchema,
2403
- kpiGridComponentSchema,
2404
- lineChartComponentSchema,
2405
- listBlockComponentSchema,
2406
- listComponentSchema,
2407
- mapComponentSchema,
2408
- meterListComponentSchema,
2409
- metricGridComponentSchema,
2410
- numberFormatSchema,
2411
- parseAgentRemoteConfig,
2412
- pieChartComponentSchema,
2413
- playerCardComponentSchema,
2414
- playlistComponentSchema,
2415
- productCardComponentSchema,
2416
- productSignalsComponentSchema,
2417
- progressComponentSchema,
2418
- purchaseCompleteComponentSchema,
2419
- purchaseItemsComponentSchema,
2420
- radarChartComponentSchema,
2421
- radialChartComponentSchema,
2422
- ratingComponentSchema,
2423
- recordCardComponentSchema,
2424
- recordCardLayoutSchema,
2425
- renderAgentUICatalogPrompt,
2426
- renderComponentInputSchema,
2427
- resolveAgentModelId,
2428
- rideStatusComponentSchema,
2429
- rowComponentSchema,
2430
- sankeyChartComponentSchema,
2431
- scatterChartComponentSchema,
2432
- spacerComponentSchema,
2433
- stepsComponentSchema,
2434
- sunburstChartComponentSchema,
2435
- switchGroupComponentSchema,
2436
- tabsComponentSchema,
2437
- tagListComponentSchema,
2438
- textComponentSchema,
2439
- toggleGroupComponentSchema,
2440
- viewEventComponentSchema,
2441
- weatherConditionSchema,
2442
- weatherConditions,
2443
- weatherCurrentComponentSchema,
2444
- weatherForecastComponentSchema
2445
- };
1
+ var xo=5,Ao=10485760,ut={"application/json":"json","application/pdf":"pdf","image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp","text/csv":"csv","text/markdown":"md","text/plain":"txt","text/tab-separated-values":"tsv"},ue=Object.freeze(Object.keys(ut)),ko=ue.join(","),gt=new Set(ue),Io=new Set(["application/json","text/csv","text/markdown","text/plain","text/tab-separated-values"]);function ge(t){return gt.has(t.trim().toLowerCase())}var he=1,u=Symbol("invalid");function B(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function S(t){if(t!==void 0)return typeof t=="string"?t:u}function w(t){if(t!==void 0)return typeof t=="boolean"?t:u}function $(t){if(t!==void 0)return typeof t=="number"&&Number.isFinite(t)?t:u}function U(t){return n=>{if(n!==void 0)return typeof n=="string"&&t.includes(n)?n:u}}function fe(t){if(t===void 0)return;if(typeof t=="string")return t;if(!B(t))return u;let n=S(t.dark),a=S(t.light);return n===u||a===u?u:{...n===void 0?{}:{dark:n},...a===void 0?{}:{light:a}}}function ht(t){if(t===void 0)return;if(!B(t))return u;let n={};for(let[a,i]of Object.entries(t)){if(typeof i!="string")return u;n[a]=i}return n}function ft(t){if(t!==void 0)return!Array.isArray(t)||t.some(n=>typeof n!="string")?u:t}function b(t,n){if(t===void 0||!B(t))return u;let a={};for(let[i,l]of Object.entries(n)){let d=l(t[i]);if(d===u)return u;d!==void 0&&(a[i]=d)}return a}function E(t){return t===u?void 0:t}var yt=["accent","background","foreground","overlay","surface","surfaceSecondary","tooltip"];function Ct(t){return b(t,{launcher:n=>n===void 0?void 0:b(n,{background:fe,icon:S,position:U(["bottom-left","bottom-right"]),style:ht}),panel:n=>n===void 0?void 0:b(n,{expandable:w,expanded:w,initialHeight:a=>a===void 0||typeof a=="string"?a:$(a),initialWidth:a=>a===void 0||typeof a=="string"?a:$(a)}),theme:n=>n===void 0?void 0:b(n,{colorScheme:U(["dark","light","system"]),colors:a=>a===void 0?void 0:b(a,Object.fromEntries(yt.map(i=>[i,fe]))),designTheme:U(["base","brutalism","glass","mouve"]),radius:U(["pill","round","sharp","soft"]),typography:a=>a===void 0?void 0:b(a,{baseSize:$,fontFamily:S})}),viewMode:U(["floating","sidebar"])})}function bt(t){return b(t,{attachments:n=>{if(n===void 0||n===!1)return n;if(!Array.isArray(n))return u;let a=n.filter(i=>typeof i=="string"&&ge(i));return a.length===n.length?a:u},defaultModel:S,dictation:w,disclaimer:n=>n===!1?!1:S(n),modelPicker:w,placeholder:S})}function xt(t){return b(t,{animated:n=>{if(n===void 0||n===!1)return n;if(!B(n))return u;let a=U(["blurIn","fadeIn","slideUp"])(n.animation);return a===u||a===void 0?u:{...n,animation:a}},caret:n=>n===!1?!1:U(["block","circle"])(n)})}function At(t){if(t===void 0||t===!1)return t;if(!Array.isArray(t))return u;let n=["copy","feedback","retry"],a=t.filter(i=>typeof i=="string"&&n.includes(i));return a.length===t.length?a:u}function vo(t){if(!B(t)||t.version!==he)return null;let n=t.revision;if(typeof n!="string"||!n)return null;let a=E(Ct(t.appearance)),i=E(b(t.capabilities,{imageSearch:w,newsSearch:w,webSearch:w})),l=E(bt(t.composer)),d=E(xt(t.markdown)),h=E(b(t.permissions,{defaultMode:U(["ask","auto","full"]),showPicker:w})),g=E(At(t.responseActions)),_=E(b(t.startScreen,{greeting:S,promptShortcuts:w,prompts:ft})),C=E(b(t.webfont,{familyName:T=>typeof T=="string"&&T?T:u,fontFaceUrl:S,stylesheetUrl:S}));return{...a?{appearance:a}:{},...i?{capabilities:i}:{},...l?{composer:l}:{},...d?{markdown:d}:{},...h?{permissions:h}:{},...g===void 0?{}:{responseActions:g},..._?{startScreen:_}:{},...C?{webfont:C}:{},revision:n,version:he}}var ye={accordion:"display-information","action-group":"actions","area-chart":"data-visualization","bar-chart":"data-visualization",callout:"display-information","candlestick-chart":"data-visualization","channel-message":"display-information","code-block":"display-information","comparison-list":"data-visualization","composed-chart":"data-visualization","create-event":"display-information","data-table":"data-visualization",diagram:"display-information","donut-chart":"data-visualization","enable-notification":"display-information","event-session":"display-information","flight-tracker":"display-information",followup:"actions",form:"form-elements","funnel-chart":"data-visualization","gauge-chart":"data-visualization",heatmap:"data-visualization",image:"display-information","kpi-grid":"data-visualization","line-chart":"data-visualization",list:"display-information","list-block":"display-information",map:"display-information","meter-list":"data-visualization","metric-grid":"data-visualization","pie-chart":"data-visualization","player-card":"display-information",playlist:"display-information","product-card":"display-information","product-signals":"data-visualization","purchase-complete":"display-information","purchase-items":"display-information","radar-chart":"data-visualization","radial-chart":"data-visualization","record-card":"display-information","ride-status":"display-information","sankey-chart":"data-visualization","scatter-chart":"data-visualization",steps:"display-information","sunburst-chart":"data-visualization","switch-group":"form-elements",tabs:"display-information","tag-list":"display-information",text:"display-information","toggle-group":"form-elements","view-event":"display-information","weather-current":"display-information","weather-forecast":"display-information"};import{z as e}from"zod";function Ce(t){return{maximum:t.max??(t.format?.style==="percent"?1:100),minimum:t.min??0}}var kt=["activity","alert","briefcase","calendar","chart","check","clock","code","credit-card","database","device-desktop","device-mobile","document","dollar","flag","globe","heart","home","info","lightning","location","mail","percent","person","question","receipt","rocket","route","search","shopping-bag","speedometer","star","tag","target","users"],It=["clear","partly-cloudy","cloudy","fog","drizzle","rain","snow","thunderstorm","windy","unknown"],Tt=e.string().trim().min(1).max(120),r=e.string().trim().min(1).max(320),L=e.string().trim().min(1).max(1e4),c=e.string().trim().min(1).max(80),m=e.string().trim().min(1).max(100),M=e.string().regex(/^\d{4}-\d{2}-\d{2}$/),Y=e.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/),St=e.union([e.string().max(500),e.number(),e.boolean(),e.null()]),z=e.record(e.string().max(80),St),s=e.object({description:r.optional(),id:m,title:Tt}),Q=e.enum(["outline","plain","surface","surface-secondary","surface-tertiary","widget"]).describe("Card hierarchy: surface for the primary standalone group; surface-secondary for supporting information; surface-tertiary for one featured or emphasized group; outline for equal peers and comparisons; plain for a structural section already separated by surrounding layout; widget for a compact interactive group with actions or controls."),vt=e.enum(["compact","details","media"]).describe("Record information layout: details for a full labeled fact set; compact for a brief summary or repeated peer cards; media for an image-led product, place, person, or event and only when an image is available."),y=e.discriminatedUnion("style",[e.object({compact:e.boolean().optional(),style:e.literal("number")}),e.object({maximumFractionDigits:e.number().int().min(0).max(4).optional(),style:e.literal("percent")}),e.object({compact:e.boolean().optional(),currency:e.string().regex(/^[A-Z]{3}$/),style:e.literal("currency")})]),v=e.enum(["accent","chart-1","chart-2","chart-3","chart-4","chart-5","danger","default","success","warning"]),Ae=e.record(e.string().trim().min(1).max(80),v).refine(t=>Object.keys(t).length<=50,"At most 50 category colors are allowed"),te=e.object({color:v.optional(),dataKey:c,format:y.optional(),label:r}),wt=te.extend({axis:e.enum(["left","right"]).optional(),stacked:e.boolean().optional(),type:e.enum(["area","bar","line"])}),Nt=e.object({id:m,label:r,maxItems:e.number().int().min(1).max(200).optional()}),Z=s.extend({data:e.array(z).min(1).max(200),defaultRangeId:m.optional(),ranges:e.array(Nt).min(2).max(8).optional(),series:e.array(te).min(1).max(5),showSummary:e.boolean().optional(),xKey:c}),F=s.extend({colors:Ae.optional(),data:e.array(z).min(1).max(50),format:y.optional(),labelKey:c,valueKey:c}),Rt=s.extend({colors:Ae.optional(),data:e.array(z).min(1).max(200),format:y.optional(),groupKey:c.optional(),kind:e.literal("scatter-chart"),labelKey:c.optional(),sizeKey:c.optional(),xKey:c,yKey:c}),_t=s.extend({color:v.optional(),data:e.array(z).min(1).max(400),format:y.optional(),kind:e.literal("heatmap"),valueKey:c,xKey:c,yKey:c}),Et=Z.extend({baseline:e.number().finite().optional(),kind:e.literal("line-chart"),mode:e.enum(["live","profit-loss","standard"]).optional(),negativeColor:v.optional(),positiveColor:v.optional(),windowSize:e.number().int().min(2).max(200).optional()}).superRefine((t,n)=>{(t.mode==="live"||t.mode==="profit-loss")&&t.series.length!==1&&n.addIssue({code:"custom",message:`${t.mode} line charts require exactly one series`,path:["series"]})}),Ut=s.extend({closeKey:c,data:e.array(z).min(1).max(200),downColor:v.optional(),format:y.optional(),highKey:c,kind:e.literal("candlestick-chart"),lowKey:c,openKey:c,upColor:v.optional(),xKey:c}).superRefine((t,n)=>{for(let[a,i]of t.data.entries()){let l=i[t.openKey],d=i[t.highKey],h=i[t.lowKey],g=i[t.closeKey];if([l,d,h,g].some(de=>typeof de!="number"||!Number.isFinite(de))){n.addIssue({code:"custom",message:"Every candlestick row needs finite open, high, low, and close values",path:["data",a]});continue}let C=l,T=d,P=h,ce=g;(P>Math.min(C,ce)||T<Math.max(C,ce)||P>T)&&n.addIssue({code:"custom",message:"Candlestick low/high values must contain the open and close values",path:["data",a]})}}),zt=F.extend({data:e.array(z).min(2).max(20),kind:e.literal("funnel-chart"),orientation:e.enum(["horizontal","vertical"]).optional(),showPercentages:e.boolean().optional()}).superRefine((t,n)=>{let a=t.data.map((i,l)=>{let d=i[t.valueKey];return typeof d!="number"||!Number.isFinite(d)||d<0?(n.addIssue({code:"custom",message:"Every funnel stage needs a finite, non-negative value",path:["data",l,t.valueKey]}),0):d});a.some(i=>i>0)||n.addIssue({code:"custom",message:"A funnel needs at least one stage above zero",path:["data"]}),(a[0]??0)<=0&&n.addIssue({code:"custom",message:"A funnel's first stage must be above zero",path:["data",0,t.valueKey]});for(let i=1;i<a.length;i+=1)(a[i]??0)>(a[i-1]??0)&&n.addIssue({code:"custom",message:"Funnel stages must not increase",path:["data",i,t.valueKey]})}),Ot=s.extend({color:v.optional(),format:y.optional(),kind:e.literal("gauge-chart"),label:r,max:e.number().finite().optional(),min:e.number().finite().optional(),notches:e.number().int().min(6).max(60).optional(),orientation:e.enum(["arc","linear"]).optional(),value:e.number().finite()}).superRefine((t,n)=>{let{maximum:a,minimum:i}=Ce(t);a<=i?n.addIssue({code:"custom",message:"Gauge max must be greater than min",path:["max"]}):(t.value<i||t.value>a)&&n.addIssue({code:"custom",message:"Gauge value must be within its min/max range",path:["value"]})}),ke=e.lazy(()=>e.object({children:e.array(ke).min(1).max(12).optional(),color:v.optional(),id:m,label:r,value:e.number().finite().positive().optional()}).superRefine((t,n)=>{t.children?.length&&t.value!==void 0&&n.addIssue({code:"custom",message:"Sunburst branch values are derived from their children",path:["value"]}),!t.children?.length&&t.value===void 0&&n.addIssue({code:"custom",message:"Every sunburst leaf needs a positive value",path:["value"]})})),Lt=s.extend({data:ke,format:y.optional(),kind:e.literal("sunburst-chart")}).superRefine((t,n)=>{let a=new Set,i=0,l=0,d=(h,g)=>{i+=1,l=Math.max(l,g),a.has(h.id)&&n.addIssue({code:"custom",message:`Duplicate sunburst node id "${h.id}"`}),a.add(h.id),h.children?.forEach(_=>d(_,g+1))};t.data.children?.length||n.addIssue({code:"custom",message:"A sunburst root needs at least one child",path:["data","children"]}),d(t.data,0),i>60&&n.addIssue({code:"custom",message:"Sunburst charts allow at most 60 nodes"}),l>4&&n.addIssue({code:"custom",message:"Sunburst charts allow at most four nested levels"})}),V=e.object({label:r,value:c}),Mt=e.object({end:M,start:M}).refine(t=>t.start<=t.end,"The start date must not be after the end date"),x={description:r.optional(),label:r,name:c,required:e.boolean().optional()},jt=e.discriminatedUnion("kind",[e.object({...x,defaultValue:e.string().max(500).optional(),inputType:e.enum(["email","number","password","search","tel","text","url"]).optional(),kind:e.literal("input"),placeholder:e.string().max(160).optional()}),e.object({...x,defaultValue:e.string().max(2e3).optional(),kind:e.literal("textarea"),placeholder:e.string().max(160).optional(),rows:e.number().int().min(2).max(12).optional()}),e.object({...x,defaultValue:c.optional(),kind:e.literal("select"),options:e.array(V).min(1).max(30),placeholder:e.string().max(160).optional()}),e.object({...x,defaultValue:c.optional(),kind:e.literal("radio-group"),options:e.array(V).min(1).max(12),placeholder:e.string().max(160).optional()}),e.object({...x,defaultValue:e.array(c).max(20).optional(),kind:e.literal("checkbox-group"),options:e.array(V).min(1).max(20)}),e.object({...x,defaultValue:e.array(c).max(50).optional(),kind:e.literal("combobox"),options:e.array(V.extend({description:e.string().trim().min(1).max(120).optional()})).min(1).max(200).describe("Prefer this over select once there are more options than someone would scan \u2014 it filters as they type. Values must be unique."),placeholder:e.string().max(160).optional(),selectionMode:e.enum(["multiple","single"]).optional()}).superRefine((t,n)=>{let a=new Set(t.options.map(i=>i.value));a.size!==t.options.length&&n.addIssue({code:"custom",message:"Combobox option values must be unique",path:["options"]}),(t.selectionMode??"single")==="single"&&(t.defaultValue?.length??0)>1&&n.addIssue({code:"custom",message:"A single-selection combobox takes at most one default value",path:["defaultValue"]}),t.defaultValue?.some(i=>!a.has(i))&&n.addIssue({code:"custom",message:"Every combobox default value must be one of the options",path:["defaultValue"]})}),e.object({...x,defaultValue:e.number().optional(),kind:e.literal("slider"),max:e.number(),min:e.number(),step:e.number().positive().optional()}),e.object({...x,defaultValue:e.number().optional(),format:y.optional(),kind:e.literal("number"),max:e.number().optional(),min:e.number().optional(),placeholder:e.string().max(160).optional(),step:e.number().positive().optional()}),e.object({...x,defaultValue:e.boolean().optional(),kind:e.literal("switch")}),e.object({...x,defaultValue:M.optional(),kind:e.literal("date-picker"),max:M.optional(),min:M.optional()}),e.object({...x,defaultValue:Mt.optional(),kind:e.literal("date-range-picker"),max:M.optional(),min:M.optional()}),e.object({...x,defaultValue:Y.optional(),hourCycle:e.union([e.literal(12),e.literal(24)]).optional(),kind:e.literal("time-field"),max:Y.optional(),min:Y.optional()})]),ne=e.enum(["danger","outline","primary","secondary","tertiary"]),R=e.enum(kt),Ie=e.object({arguments:e.record(e.string().max(80),e.unknown()).refine(t=>JSON.stringify(t).length<=4096,"Tool call arguments must serialize to at most 4KB of JSON"),name:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/)}),f=e.object({id:m,label:r,prompt:e.string().trim().min(1).max(2e3).optional(),toolCall:Ie.optional(),variant:ne.optional()}),Te=e.object({latitude:e.number().finite().min(-85.051129).max(85.051129),longitude:e.number().finite().min(-180).max(180)}),ee=e.string().trim().min(1).max(2e3).refine(t=>{try{let n=new URL(t);return["http:","https:"].includes(n.protocol)&&!n.username&&!n.password}catch{return!1}},{message:"URL must use HTTP or HTTPS and cannot include credentials"}),Gt=e.string().trim().min(1).max(2e3).refine(t=>{try{let n=new URL(t);return["http:","https:","mailto:","tel:"].includes(n.protocol)&&!n.username&&!n.password}catch{return!1}},{message:"Link must use HTTP, HTTPS, mailto, or tel and cannot include credentials"}),K={id:m,label:r,variant:ne.optional()},Bt=e.string().trim().min(5).max(2e3).refine(t=>/^tel:\+?[0-9().\-\s]+$/.test(t)&&/\d/.test(t.slice(4)),"Phone links must use the tel: scheme and contain a phone number"),Dt=e.discriminatedUnion("kind",[e.object({...K,href:Bt,kind:e.literal("call")}),e.object({...K,href:ee,kind:e.literal("directions")}),e.object({...K,href:Gt,kind:e.literal("other")}),e.object({...K,href:ee,kind:e.literal("website")})]),Pt=Te.extend({actions:e.array(Dt).max(4).optional(),address:r.optional(),category:e.string().trim().min(1).max(100).optional(),id:m,images:e.array(e.object({alt:r,src:ee})).max(4).optional().describe("Prefer one representative image per location when a trusted tool or web image search returns one. The first image becomes the result-card thumbnail; initials are the fallback."),notes:e.string().trim().min(1).max(2e3).optional(),rating:e.number().finite().min(0).max(5).optional(),relevance:e.number().finite().min(0).max(1).optional(),reviewCount:e.number().int().nonnegative().max(1e9).optional(),title:r}),D=e.string().trim().min(1).max(2e3).refine(t=>{if(t.startsWith("/"))return!t.startsWith("//");try{let n=new URL(t);return["http:","https:"].includes(n.protocol)&&!n.username&&!n.password}catch{return!1}},{message:"Image sources must be HTTP(S) URLs or root-relative paths"}),k=e.object({alt:r,src:D.refine(t=>!t.split(/[?#]/,1)[0]?.toLowerCase().endsWith(".svg"),"Response-composition images must be raster images")}),oe=e.string().regex(/^[A-Z]{3}$/),Vt=e.object({amount:e.number().finite().nonnegative().max(1e9),currency:oe}),W=e.enum(It),be=e.enum(["celsius","fahrenheit"]),xe=e.object({label:r,status:r.optional(),time:e.string().trim().min(1).max(80)}),j=e.enum(["accent","danger","default","muted","success","warning"]),Kt=e.object({actions:e.array(f).max(3).optional(),badge:e.object({label:r,tone:j.optional()}).optional(),description:r.optional(),id:m,image:e.object({alt:r,src:D}),meta:e.string().trim().min(1).max(160).optional(),name:r,price:e.object({amount:e.number().finite().nonnegative().max(1e9),currency:oe.optional()}),rating:e.object({count:e.number().int().nonnegative().max(1e9).optional(),value:e.number().finite().min(0).max(5)}).optional()}),Zt=e.enum(["accent","danger","default","success","warning"]),Ft=e.object({description:r.optional(),format:y.optional(),id:m,label:r,max:e.number().optional(),min:e.number().optional(),tone:Zt.optional(),value:e.number()}).superRefine((t,n)=>{let a=t.min??0,i=t.max??(t.format?.style==="percent"?1:100);i<=a&&n.addIssue({code:"custom",message:"Meter max must be greater than min"}),(t.value<a||t.value>i)&&n.addIssue({code:"custom",message:"Meter value must be within its min/max range"})}),o={accordion:s.extend({kind:e.literal("accordion"),sections:e.array(e.object({content:L,defaultOpen:e.boolean().optional(),id:m,title:r})).min(1).max(12)}),actions:s.extend({actions:e.array(f).min(1).max(8),kind:e.literal("action-group"),orientation:e.enum(["horizontal","vertical"]).optional()}),area:Z.extend({kind:e.literal("area-chart"),stacked:e.boolean().optional()}),bar:Z.extend({kind:e.literal("bar-chart"),layout:e.enum(["horizontal","vertical"]).optional(),stacked:e.boolean().optional()}),callout:s.extend({content:L,icon:R.optional(),kind:e.literal("callout"),tone:e.enum(["accent","danger","neutral","success","warning"]).optional()}),candlestick:Ut,channelMessage:s.extend({attachments:e.array(e.object({id:m,image:k.optional(),name:r})).max(8).optional(),author:e.object({image:k.optional(),name:r}),channel:r,content:L,kind:e.literal("channel-message"),timestamp:e.string().trim().min(1).max(80)}),code:s.extend({code:e.string().min(1).max(2e4),kind:e.literal("code-block"),language:e.string().trim().max(40).optional()}),comparison:s.extend({items:e.array(e.object({change:e.number().optional(),format:y.optional(),label:r,note:e.string().trim().max(180).optional(),value:e.number()})).min(1).max(12),kind:e.literal("comparison-list")}),composed:Z.extend({kind:e.literal("composed-chart"),series:e.array(wt).min(2).max(5)}),createEvent:s.extend({actions:e.array(f).max(2).optional(),date:e.object({day:e.number().int().min(1).max(31),weekday:e.string().trim().min(1).max(20)}),events:e.array(e.object({id:m,status:e.enum(["existing","proposed"]).optional(),time:e.string().trim().min(1).max(80),title:r,tone:j.optional()})).min(1).max(12),kind:e.literal("create-event")}),diagram:s.extend({chart:e.string().trim().min(1).max(4e3).describe('Mermaid source. Pick the diagram type from the relationship: "flowchart LR" for a process or decision path, "sequenceDiagram" for an exchange between parties over time, "erDiagram" for how records relate, "stateDiagram-v2" for the states something moves between. Example: "flowchart LR\\n A[Order placed] --> B{In stock?}\\n B -- yes --> C[Ship]\\n B -- no --> D[Backorder]". Never include HTML, script tags, or click directives.'),kind:e.literal("diagram")}).superRefine((t,n)=>{/<\s*script|javascript:|^\s*click\s+\S/im.test(t.chart)&&n.addIssue({code:"custom",message:"Diagram source cannot contain HTML, script URLs, or click directives",path:["chart"]})}),donut:F.extend({kind:e.literal("donut-chart")}),enableNotification:s.extend({actions:e.tuple([f,f]),kind:e.literal("enable-notification")}),eventSession:s.extend({action:f.optional(),eyebrow:e.string().trim().min(1).max(100).optional(),kind:e.literal("event-session"),location:r,speakers:e.array(e.object({image:k.optional(),name:r,role:r})).max(8),time:e.string().trim().min(1).max(80)}),flightTracker:s.extend({airline:e.object({logo:k.optional(),name:r}),date:e.string().trim().min(1).max(80),destination:xe,flightNumber:e.string().trim().min(1).max(40),kind:e.literal("flight-tracker"),origin:xe,progress:e.number().finite().min(0).max(100).optional()}),followup:s.extend({kind:e.literal("followup"),prompts:e.array(e.object({id:m,label:r,prompt:L})).min(1).max(8)}),form:s.extend({actions:e.array(f).min(1).max(4),fields:e.array(jt).min(1).max(20),kind:e.literal("form")}),funnel:zt,gauge:Ot,heatmap:_t,image:s.extend({images:e.array(e.object({alt:r,aspectRatio:e.enum(["landscape","portrait","square","wide"]).optional(),caption:r.optional(),src:D})).min(1).max(6),kind:e.literal("image"),variant:e.enum(["grid","horizontal"]).optional().describe("Use horizontal for a swipeable gallery in narrow chat interfaces.")}),kpiGrid:s.extend({kind:e.literal("kpi-grid"),metrics:e.array(e.object({change:e.number().optional(),color:v.optional(),format:y.optional(),icon:R.optional(),label:r,trend:e.array(e.number().finite()).min(2).max(60).describe("The values behind this KPI, oldest to newest, drawn as a sparkline. The last point should agree with value."),value:e.number()})).min(1).max(4)}),line:Et,list:s.extend({items:e.array(e.object({checked:e.boolean().optional(),children:e.array(r).max(8).optional(),id:m,text:r})).min(1).max(30),kind:e.literal("list"),style:e.enum(["bulleted","checklist","numbered"]).optional()}),listBlock:s.extend({items:e.array(e.object({description:r.optional(),icon:R.optional(),id:m,imageAlt:r.optional(),imageUrl:D.optional(),meta:e.string().trim().max(100).optional(),rating:e.number().min(0).max(5).optional(),title:r})).min(1).max(20),kind:e.literal("list-block")}),map:s.extend({initialLocationId:m.optional(),kind:e.literal("map"),locations:e.array(Pt).min(1).max(12),viewport:e.object({center:Te,zoom:e.number().int().min(1).max(18)}).optional()}).superRefine((t,n)=>{let a=new Set;for(let[i,l]of t.locations.entries()){a.has(l.id)&&n.addIssue({code:"custom",message:`Duplicate map location id "${l.id}"`,path:["locations",i,"id"]}),a.add(l.id);let d=new Set;for(let[h,g]of(l.actions??[]).entries())d.has(g.id)&&n.addIssue({code:"custom",message:`Duplicate action id "${g.id}" for map location "${l.id}"`,path:["locations",i,"actions",h,"id"]}),d.add(g.id)}t.initialLocationId&&!a.has(t.initialLocationId)&&n.addIssue({code:"custom",message:"The initial map location must reference one of the locations",path:["initialLocationId"]})}).describe("A ranked, map-synchronized set of places or professionals. Coordinates and listing facts must come from tools or user data; never invent them."),meterList:s.extend({items:e.array(Ft).min(1).max(8),kind:e.literal("meter-list")}),metricGrid:s.extend({kind:e.literal("metric-grid"),metrics:e.array(e.object({change:e.number().optional(),format:y.optional(),icon:R.optional(),label:r,value:e.number()})).min(1).max(4)}),pie:F.extend({kind:e.literal("pie-chart")}),playerCard:s.extend({backgroundImage:k.optional(),jerseyNumber:e.string().trim().min(1).max(20).optional(),kind:e.literal("player-card"),playerName:r,stats:e.array(e.object({label:e.string().trim().min(1).max(40),value:e.union([e.string().trim().min(1).max(80),e.number().finite()])})).min(1).max(8)}),playlist:s.extend({actions:e.array(f).max(2).optional(),cover:k.optional(),kind:e.literal("playlist"),tracks:e.array(e.object({action:f.optional(),artist:r,id:m,image:k.optional(),title:r})).min(1).max(20)}),productCard:s.extend({actions:e.array(f).max(3).optional(),kind:e.literal("product-card"),products:e.array(Kt).min(1).max(8),variant:Q.optional()}).superRefine((t,n)=>{let a=new Set;for(let[i,l]of t.products.entries())a.has(l.id)&&n.addIssue({code:"custom",message:`Duplicate product id "${l.id}"`,path:["products",i,"id"]}),a.add(l.id)}).describe("A commerce product presentation: one product renders an image-led spotlight, several render a store-style grid. Product facts (id, name, image, price, rating, availability) must come from tools or user data; never invent them."),purchaseComplete:s.extend({action:f.optional(),details:e.array(e.object({label:r,value:r})).max(8),kind:e.literal("purchase-complete"),paid:Vt.optional(),product:e.object({description:r.optional(),image:k.optional(),name:r})}),purchaseItems:s.extend({actions:e.array(f).max(3).optional(),currency:oe,items:e.array(e.object({description:r.optional(),id:m,image:k.optional(),name:r,price:e.number().finite().nonnegative().max(1e9).optional(),quantity:e.number().int().positive().max(1e4).optional()})).min(1).max(20),kind:e.literal("purchase-items"),totals:e.array(e.object({amount:e.number().finite().nonnegative().max(1e9),emphasis:e.boolean().optional(),label:r})).min(1).max(8)}),radar:s.extend({angleKey:c,data:e.array(z).min(3).max(50),kind:e.literal("radar-chart"),series:e.array(te).min(1).max(5)}),radial:F.extend({endAngle:e.number().min(-360).max(360).optional(),kind:e.literal("radial-chart"),maxValue:e.number().positive().optional(),startAngle:e.number().min(-360).max(360).optional()}),recordCard:s.extend({actions:e.array(f).max(4).optional(),eyebrow:e.string().trim().max(100).optional(),fields:e.array(e.object({icon:R.optional(),label:r,tone:j.optional(),value:e.string().trim().min(1).max(500)})).max(12),image:e.object({alt:r,src:D}).optional(),kind:e.literal("record-card"),layout:vt.optional(),status:e.object({label:r,tone:j.optional()}).optional(),variant:Q.optional()}).superRefine((t,n)=>{t.layout==="media"&&!t.image&&n.addIssue({code:"custom",message:"The media record layout requires an image",path:["image"]}),t.layout==="compact"&&t.fields.length>4&&n.addIssue({code:"custom",message:"The compact record layout supports at most four fields",path:["fields"]})}),rideStatus:s.extend({driver:e.object({image:k.optional(),name:r}),eta:e.string().trim().min(1).max(80),kind:e.literal("ride-status"),pickup:r}),sankey:s.extend({format:y.optional(),kind:e.literal("sankey-chart"),links:e.array(e.object({source:m,target:m,value:e.number().positive()})).min(1).max(100),nodes:e.array(e.object({id:m,label:r})).min(2).max(40)}),scatter:Rt,steps:s.extend({kind:e.literal("steps"),steps:e.array(e.object({content:r.optional(),icon:R.optional(),id:m,image:k.optional().describe("A representative raster image for this step. Prefer this over icon for place itineraries when a trusted image URL is available."),meta:e.string().trim().max(100).optional(),progress:e.number().min(0).max(100).optional(),status:e.enum(["blocked","cancelled","completed","failed","in-progress","pending","complete","current","upcoming"]).optional(),timestamp:e.string().trim().max(100).optional(),title:r})).min(1).max(12),variant:e.enum(["steps","timeline"]).optional()}),sunburst:Lt,switches:s.extend({items:e.array(e.object({defaultSelected:e.boolean().optional(),description:r.optional(),id:m,label:r})).min(1).max(20),kind:e.literal("switch-group")}),table:s.extend({columns:e.array(e.object({format:y.optional(),key:c,label:r})).min(1).max(12),filterable:e.boolean().optional(),kind:e.literal("data-table"),rows:e.array(z).max(200),variant:e.enum(["primary","secondary"]).optional()}),tabs:s.extend({defaultValue:m.optional(),kind:e.literal("tabs"),tabs:e.array(e.union([e.object({children:e.never().optional(),content:L,id:m,label:r}),e.object({children:e.array(e.lazy(()=>se)).min(1).max(12),content:e.never().optional(),id:m,label:r})])).min(1).max(10),variant:e.enum(["primary","secondary"]).optional()}),tags:s.extend({kind:e.literal("tag-list"),tags:e.array(r).min(1).max(30)}),text:s.extend({content:L,kind:e.literal("text"),variant:e.enum(["card","clear"]).optional()}),toggles:s.extend({defaultValue:e.array(m).max(12).optional(),items:e.array(e.object({id:m,label:r})).min(1).max(12),kind:e.literal("toggle-group"),selectionMode:e.enum(["multiple","single"]).optional()}),viewEvent:s.extend({date:e.string().trim().min(1).max(80),kind:e.literal("view-event"),time:e.string().trim().min(1).max(80),tone:j.optional()}),weatherCurrent:s.extend({condition:W,details:e.array(e.object({label:r,value:r})).max(6).optional(),kind:e.literal("weather-current"),location:r,temperature:e.number().finite().min(-150).max(150),unit:be}),weatherForecast:s.extend({condition:W,forecast:e.array(e.object({condition:W,label:e.string().trim().min(1).max(40),temperature:e.number().finite().min(-150).max(150)})).min(2).max(10),high:e.number().finite().min(-150).max(150),kind:e.literal("weather-forecast"),location:r,low:e.number().finite().min(-150).max(150),unit:be})},Ht=o.metricGrid,qt=o.kpiGrid,$t=o.line,Yt=o.area,Wt=o.bar,Xt=o.composed,Jt=o.pie,Qt=o.donut,en=o.radar,tn=o.radial,nn=o.sankey,on=o.scatter,an=o.heatmap,rn=o.candlestick,sn=o.funnel,ln=o.gauge,pn=o.sunburst,mn=o.table,cn=o.comparison,dn=o.meterList,un=o.form,gn=o.text,hn=o.callout,fn=o.image,yn=o.map,Cn=o.tags,bn=o.list,xn=o.listBlock,An=o.accordion,kn=o.steps,In=o.code,Tn=o.diagram,Uo=o.tabs.superRefine(rt),Sn=o.actions,vn=o.followup,wn=o.switches,Nn=o.toggles,Rn=o.recordCard,_n=o.productCard,En=o.flightTracker,Un=o.createEvent,zn=o.playlist,On=o.rideStatus,Ln=o.purchaseItems,Mn=o.channelMessage,jn=o.purchaseComplete,Gn=o.playerCard,Bn=o.viewEvent,Dn=o.eventSession,Pn=o.enableNotification,Vn=o.weatherForecast,Kn=o.weatherCurrent,Zn=e.discriminatedUnion("kind",[o.metricGrid,o.kpiGrid,o.line,o.area,o.bar,o.composed,o.pie,o.donut,o.radar,o.radial,o.sankey,o.scatter,o.heatmap,o.candlestick,o.funnel,o.gauge,o.sunburst,o.table,o.comparison,o.meterList]),Se=s.extend({defaultValue:m.optional(),kind:e.literal("product-signals"),tabs:e.array(e.object({component:Zn,id:m,label:r})).min(2).max(4)}),Fn=Se.superRefine((t,n)=>{let a=new Set;for(let[i,l]of t.tabs.entries())a.has(l.id)&&n.addIssue({code:"custom",message:`Duplicate product signal tab id "${l.id}"`,path:["tabs",i,"id"]}),a.add(l.id);t.defaultValue&&!a.has(t.defaultValue)&&n.addIssue({code:"custom",message:"The default product signal must reference one of the tabs",path:["defaultValue"]})}),Hn=e.discriminatedUnion("kind",[o.metricGrid,o.kpiGrid,o.line,o.area,o.bar,o.composed,o.pie,o.donut,o.radar,o.radial,o.sankey,o.scatter,o.heatmap,o.candlestick,o.funnel,o.gauge,o.sunburst,o.table,o.comparison,o.meterList,o.form,o.text,o.callout,o.image,o.map,o.tags,o.list,o.listBlock,o.accordion,o.steps,o.code,o.diagram,o.tabs,o.actions,o.followup,o.switches,o.toggles,o.recordCard,o.productCard,o.flightTracker,o.createEvent,o.playlist,o.rideStatus,o.purchaseItems,o.channelMessage,o.purchaseComplete,o.playerCard,o.viewEvent,o.eventSession,o.enableNotification,o.weatherForecast,o.weatherCurrent]);function qn(t){if(!t)return;let n=new Set;for(let a of t){if(n.has(a.id))return a.id;n.add(a.id)}}var ae=e.union([Hn,Fn]).superRefine((t,n)=>{let a=[];switch(t.kind){case"channel-message":a.push({items:t.attachments,path:"attachments"});break;case"create-event":a.push({items:t.events,path:"events"}),a.push({items:t.actions,path:"actions"});break;case"enable-notification":a.push({items:t.actions,path:"actions"});break;case"playlist":a.push({items:t.tracks,path:"tracks"}),a.push({items:t.actions,path:"actions"});break;case"purchase-items":a.push({items:t.items,path:"items"}),a.push({items:t.actions,path:"actions"});break;case"tabs":{rt(t,n);break}default:break}for(let i of a){let l=qn(i.items);l&&n.addIssue({code:"custom",message:`Duplicate ${i.path} id "${l}"`,path:[i.path]})}}),ve=s.extend({children:e.array(ae).min(1).max(4),kind:e.literal("dashboard"),layout:e.enum(["chart-table","grid","metrics-chart","stack"])}),$n=ve,we=e.union([ae,$n]),zo=e.object({component:we}),X=6,G=48,Ne=new Set(["card","col","grid","item-card","item-card-group","row"]),Re=new Set(["divider","spacer"]),_e=new Set(["badge","button","heading","icon","progress","rating"]),Ee=Ne,Ue=Re,ze=_e;function Oe(t){return Ne.has(t.kind)}function Le(t){return t.kind==="item-card"?[...t.left??[],...t.middle,...t.right??[]]:t.children}function Oo(t){return Re.has(t.kind)}function Lo(t){return _e.has(t.kind)}var I=e.object({id:m}),re=e.enum(["lg","md","none","sm"]),Me=e.enum(["center","end","start","stretch"]),je=e.enum(["between","center","end","start"]),H=e.array(e.lazy(()=>se)).min(1).max(G),Ge=I.extend({kind:e.literal("spacer"),size:e.enum(["auto","lg","md","sm"]).optional()}),Be=I.extend({kind:e.literal("divider")}),De=I.extend({icon:R.optional(),kind:e.literal("heading"),level:e.union([e.literal(1),e.literal(2),e.literal(3),e.literal(4)]).optional(),text:r}),Pe=I.extend({icon:R.optional(),kind:e.literal("button"),label:r,prompt:e.string().trim().min(1).max(2e3).optional(),toolCall:Ie.optional(),variant:ne.optional()}).refine(t=>!!(t.prompt??t.toolCall),{message:"Buttons need a prompt or a toolCall to do something when pressed"}),Ve=I.extend({kind:e.literal("badge"),label:r,tone:j.optional(),variant:e.enum(["soft","solid"]).optional()}),Ke=I.extend({kind:e.literal("icon"),name:R,size:e.enum(["lg","md","sm"]).optional(),tone:j.optional()}),Ze=I.extend({count:e.number().int().nonnegative().max(1e9).optional(),kind:e.literal("rating"),value:e.number().finite().min(0).max(5)}),Fe=I.extend({kind:e.literal("progress"),label:r.optional(),value:e.number().finite().min(0).max(100)}),He=e.enum(["default","outline","secondary","tertiary","transparent"]),J=e.lazy(()=>se),qe=s.extend({action:f.optional().describe("Makes the whole row pressable. Omit when a slot contains its own button or other interactive control."),isDisabled:e.boolean().optional(),isSelected:e.boolean().optional(),kind:e.literal("item-card"),left:e.array(J).min(1).max(4).optional().describe("Leading slot. Prefer one icon node or a compact visual."),middle:e.array(J).min(1).max(8).describe("Primary flexible slot. Prefer a level-4 heading followed by a clear text node for a title and description."),right:e.array(J).min(1).max(4).optional().describe("Trailing slot. Prefer a badge, short value, icon, or button."),variant:He.optional()}),Yn=new Set(["accordion","action-group","button","followup","form","map","switch-group","tabs","toggle-group"]);function $e(t){for(let n of t)if(Yn.has(n.kind)||Oe(n)&&$e(Le(n)))return!0;return!1}var ie=qe.superRefine((t,n)=>{t.action&&$e([...t.left??[],...t.middle,...t.right??[]])&&n.addIssue({code:"custom",message:"A pressable item-card cannot contain buttons or other interactive descendants. Remove action from the card or move the nested control outside it."})}),Ye=s.extend({children:e.array(ie).min(1).max(12),columns:e.union([e.literal(2),e.literal(3)]).optional(),kind:e.literal("item-card-group"),layout:e.enum(["grid","list"]).optional(),showHeader:e.boolean().optional(),variant:He.optional()}),We=Ye.superRefine((t,n)=>{t.columns&&t.layout!=="grid"&&n.addIssue({code:"custom",message:"Item-card group columns only apply when layout is grid.",path:["columns"]})}),Xe=I.extend({align:Me.optional(),children:H,gap:re.optional(),justify:je.optional(),kind:e.literal("row")}),Je=I.extend({align:Me.optional(),children:H,gap:re.optional(),justify:je.optional(),kind:e.literal("col")}),Qe=I.extend({children:H,columns:e.union([e.literal(1),e.literal(2),e.literal(3),e.literal(4)]),gap:re.optional(),kind:e.literal("grid")}),et=s.extend({children:H,kind:e.literal("card"),variant:Q.optional()}),tt=Xe,nt=Je,ot=Qe,at=et,se=e.union([ae,Ge,Be,De,Pe,Ve,Ke,Ze,Fe,tt,nt,ot,at,ie,We]);function Wn(t,n){Qn(t,n)}function Xn(t,n){let a=t.tabs.flatMap(i=>i.children??[]);a.length!==0&&it(a,n,t.id,2,1)}function rt(t,n){let a=new Set;for(let[i,l]of t.tabs.entries())a.has(l.id)&&n.addIssue({code:"custom",message:`Duplicate tab id "${l.id}"`,path:["tabs",i,"id"]}),a.add(l.id);t.defaultValue&&!a.has(t.defaultValue)&&n.addIssue({code:"custom",message:"The default tab must reference one of the tabs",path:["defaultValue"]}),Xn(t,n)}function Jn(t){return Oe(t)?Le(t):t.kind==="tabs"?t.tabs.flatMap(n=>n.children??[]):[]}function it(t,n,a,i=1,l=0){let d=new Set,h=l,g=l>0?i-1:0;a&&d.add(a);let _=(C,T)=>{if(h+=1,g=Math.max(g,T),d.has(C.id)&&n.addIssue({code:"custom",message:`Duplicate component id "${C.id}" in the composed UI tree. Every node needs a unique id.`}),d.add(C.id),!(T>X))for(let P of Jn(C))_(P,T+1)};for(let C of t)_(C,i);g>X&&n.addIssue({code:"custom",message:`Composed UI trees can nest at most ${X} levels deep.`}),h>G&&n.addIssue({code:"custom",message:`Composed UI trees can contain at most ${G} components.`})}function Qn(t,n){it([t],n)}var st=e.union([tt,nt,ot,at,ie,We]).superRefine(Wn),Mo=e.union([we,st]),jo=e.object({component:st}),N=t=>e.array(e.unknown()).min(1).max(t).describe("Child nodes. Each is any catalog component; look its kind up separately."),Go={accordion:An,"action-group":Sn,"area-chart":Yt,badge:Ve,"bar-chart":Wt,button:Pe,callout:hn,"candlestick-chart":rn,card:et.extend({children:N(G)}),"channel-message":Mn,"code-block":In,col:Je.extend({children:N(G)}),"comparison-list":cn,"composed-chart":Xt,"create-event":Un,dashboard:ve.extend({children:N(4)}),"data-table":mn,diagram:Tn,divider:Be,"donut-chart":Qt,"enable-notification":Pn,"event-session":Dn,"flight-tracker":En,followup:vn,form:un,"funnel-chart":sn,"gauge-chart":ln,grid:Qe.extend({children:N(G)}),heading:De,heatmap:an,icon:Ke,image:fn,"item-card":qe.extend({left:N(4).optional().describe("Leading slot nodes."),middle:N(8).describe("Primary flexible slot nodes."),right:N(4).optional().describe("Trailing slot nodes.")}),"item-card-group":Ye.extend({children:e.array(e.unknown()).min(1).max(12).describe("One to twelve item-card children. Look up item-card for each child's schema.")}),"kpi-grid":qt,"line-chart":$t,list:bn,"list-block":xn,map:yn,"meter-list":dn,"metric-grid":Ht,"pie-chart":Jt,"player-card":Gn,playlist:zn,"product-card":_n,"product-signals":Se.extend({tabs:e.array(e.object({component:e.unknown().describe("One analytical component: metric-grid, kpi-grid, any chart, data-table, comparison-list, or meter-list. Look its kind up separately."),id:m,label:r})).min(2).max(4)}),progress:Fe,"purchase-complete":jn,"purchase-items":Ln,"radar-chart":en,"radial-chart":tn,rating:Ze,"record-card":Rn,"ride-status":On,row:Xe.extend({children:N(G)}),"sankey-chart":nn,"scatter-chart":on,spacer:Ge,steps:kn,"sunburst-chart":pn,"switch-group":wn,tabs:s.extend({defaultValue:m.optional(),kind:e.literal("tabs"),tabs:e.array(e.union([e.object({content:L,id:m,label:r}),e.object({children:N(12).describe("Rich panel nodes rendered as one vertical stack. Look up every child kind separately."),id:m,label:r})])).min(1).max(10),variant:e.enum(["primary","secondary"]).optional()}),"tag-list":Cn,text:gn,"toggle-group":Nn,"view-event":Bn,"weather-current":Kn,"weather-forecast":Vn};var pt={accordion:"collapsible sections of longer prose","action-group":"buttons that send prompts or call client tools","area-chart":"one continuous time series with a filled trend",badge:"a small toned status label","bar-chart":"ranked or categorical comparison, horizontal layout for rankings",button:"one action with a prompt or client-tool call",callout:"one short toned notice: info, success, warning, or danger","candlestick-chart":"open-high-low-close price movement over ordered periods",card:"titled surface grouping related children","channel-message":"a quoted workspace message with author and attachments","code-block":"a syntax-highlighted snippet",col:"stacks children vertically","comparison-list":"labeled values with change deltas, no axes","composed-chart":"two to five mixed area/bar/line series, optional dual axis","create-event":"a proposed calendar slot beside surrounding events",dashboard:"up to four analytical children in a fixed layout","data-table":"exact values in filterable rows and columns",diagram:"a flowchart, sequence, ER, or state diagram from Mermaid source, for processes and relationships prose cannot show",divider:"a rule between sections","donut-chart":"proportions of a whole with a hollow center","enable-notification":"a binary notification opt-in with two actions","event-session":"a conference session with time, location, and speakers","flight-tracker":"a flight's route, times, and live progress",followup:"suggested next prompts the user can send",form:"input fields with submit actions","funnel-chart":"drop-off through ordered conversion or pipeline stages","gauge-chart":"one bounded value against its minimum and maximum",grid:"one to four equal columns of peers",heading:"a section title, levels one to four",heatmap:"two-dimensional intensity across x and y",icon:"one semantic glyph from the icon vocabulary",image:"one to six real image URLs with captions in a grid or horizontal chat gallery","item-card":"one compact three-slot row with composable left, middle, and right content","item-card-group":"one to twelve related item-card rows in a list or grid","kpi-grid":"up to four headline KPIs, each with a sparkline of its own history","line-chart":"overlapping series, a live signal, or one series split around a baseline",list:"bulleted, numbered, or checklist items with optional children","list-block":"richer rows with title, description, meta, rating, icon, or image",map:"ranked places pinned by exact latitude and longitude","meter-list":"bounded quantities such as quota, utilization, or budget","metric-grid":"up to four headline KPIs with no history to plot","pie-chart":"proportions of a whole","player-card":"an athlete with jersey, portrait, and stat lines",playlist:"a track collection with cover and per-track actions","product-card":"purchasable items with image, price, rating, availability","product-signals":"two to four related analytical views in tabs",progress:"a zero to one hundred percentage bar","purchase-complete":"confirmation after a successful transaction","purchase-items":"a cart or order summary with line items and totals","radar-chart":"multivariate comparison across three or more axes","radial-chart":"compact circular measure",rating:"a zero to five star score with optional count","record-card":"one entity's labeled facts, layouts details/compact/media","ride-status":"pickup ETA and driver for a ride in progress",row:"places complementary children side by side","sankey-chart":"flow volumes between source and target nodes","scatter-chart":"correlation between two numeric fields, optional grouping",spacer:"a gap between siblings",steps:"task progress or a chronological timeline, up to twelve entries","sunburst-chart":"hierarchical part-to-whole values across nested levels","switch-group":"toggleable boolean preferences",tabs:"parallel text or rich multi-component sections behind labeled tabs","tag-list":"short keyword chips",text:"explanatory markdown prose","toggle-group":"single or multiple choice from short options","view-event":"one calendar event's date, time, and tone","weather-current":"current conditions in one location","weather-forecast":"multi-day or future conditions with highs and lows"},eo={actions:"actions","data-visualization":"data","display-information":"display","form-elements":"forms"};function to(t){return t==="dashboard"||Ee.has(t)?"containers":Ue.has(t)?"layout":ze.has(t)?"primitives":eo[ye[t]]??"display"}var lt=Object.fromEntries(Object.entries(pt).map(([t,n])=>[t,{group:to(t),summary:n}])),no=Object.keys(pt).sort(),oo=[["containers","Containers"],["layout","Layout"],["primitives","Primitives"],["data","Data"],["display","Content"],["actions","Actions"],["forms","Forms"]];function Vo(){return oo.map(([n,a])=>{let i=no.filter(l=>lt[l].group===n).map(l=>`${l} \u2014 ${lt[l].summary}`);return`${a}: ${i.join("; ")}.`}).join(`
2
+ `)}import{z as O}from"zod";var ao=["callMcpTool","composeUI","executeSandbox","getComponentSchema","renderComponent","searchKnowledge","searchMcpTools","searchWeb"],ro="mcp_",io=20,so=16*1024,lo=O.object({description:O.string().trim().min(1).max(1e3),inputSchema:O.record(O.string(),O.unknown()),name:O.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(t=>!ao.includes(t)&&!t.toLowerCase().startsWith(ro),"Client tool name is reserved by the HeroUI Agent runtime"),needsApproval:O.boolean().optional()}),Fo=O.array(lo).max(io).superRefine((t,n)=>{let a=new Set;for(let i of t)a.has(i.name)&&n.addIssue({code:"custom",message:`Duplicate client tool name: ${i.name}`}),a.add(i.name);new TextEncoder().encode(JSON.stringify(t)).byteLength>so&&n.addIssue({code:"custom",message:"Client tool manifest exceeds 16KB"})});import{z as p}from"zod";var q=6,mt="0.2.0-beta.9";var po=p.enum(["light","dark","system"]),mo=p.enum(["outline","plain","surface","surface-secondary"]),co=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),le=p.string().trim().min(1).max(200).refine(t=>!co.has(t.toLowerCase()),{message:"Identity id is reserved"}),uo=p.discriminatedUnion("type",[p.object({id:le,type:p.literal("anonymous")}),p.object({id:le,type:p.literal("user")})]),go=p.object({avatarUrl:p.string().trim().pipe(p.url()).optional(),email:p.string().trim().max(320).pipe(p.email()).optional(),name:p.string().trim().max(120).optional()}),Wo=p.object({anonymousId:le.optional(),identity:uo,profile:go.optional()}),Xo=p.object({expiresAt:p.number().int().positive(),token:p.string().trim().min(1)}),Jo=p.object({agentId:p.string().trim().min(1).max(100),apiKeyId:p.string().trim().min(1).max(100),aud:p.literal("heroui-agent"),exp:p.number().int().positive(),iat:p.number().int().positive(),iss:p.literal("https://api.heroui.com"),jti:p.uuid(),protocolVersion:p.literal(6),sub:p.string().trim().min(1).max(200)}),Qo={embed:"embed",preview:"preview"},ea=p.object({agentId:p.string(),minimumProtocolVersion:p.literal(6),name:p.string().trim().min(1).max(120),protocolVersion:p.literal(6),sdkVersion:p.string().default(mt),suggestedPrompts:p.array(p.string().trim().min(1).max(160)).max(5),surfaceVariant:mo.default("plain"),theme:po});import{z as A}from"zod";var ct=A.object({excerpt:A.string().trim().min(1).max(2e3).optional(),locator:A.string().trim().min(1).max(160).optional(),sourceId:A.string().trim().min(1).max(120)}),ho=A.string().trim().max(2048).refine(t=>{try{return["http:","https:"].includes(new URL(t).protocol)}catch{return!1}}),fo=A.union([ct.extend({sourceType:A.literal("document"),title:A.string().trim().min(1).max(200)}),ct.extend({sourceType:A.literal("url").optional(),title:A.string().trim().min(1).max(200).optional(),url:ho})]),oa=A.object({items:A.array(fo).min(1).max(16)});var pe=["moonshotai/Kimi-K3","openai/gpt-5.6-luna","openai/gpt-5.6-terra","openai/gpt-5.6-sol","google/gemini-3.6-flash","anthropic/claude-sonnet-5","anthropic/claude-opus-4.8"],yo={"google/gemini-3.5-flash":"google/gemini-3.6-flash"};function me(t){return yo[t]??t}var ra="openai/gpt-5.6-luna",Co=[{description:"Flagship model for coding, reasoning, and knowledge work",id:"moonshotai/Kimi-K3",label:"Kimi K3",provider:"Moonshot AI",tier:"light"},{description:"Fast answers and lightweight agent workflows",id:"openai/gpt-5.6-luna",label:"GPT-5.6 Luna",provider:"OpenAI",tier:"light"},{description:"Balanced reasoning for everyday agent tasks",id:"openai/gpt-5.6-terra",label:"GPT-5.6 Terra",provider:"OpenAI",tier:"codegen"},{description:"Deep reasoning for complex, multi-step analysis",id:"openai/gpt-5.6-sol",label:"GPT-5.6 Sol",provider:"OpenAI",tier:"complex"},{description:"Fast multimodal analysis with a large context window",id:"google/gemini-3.6-flash",label:"Gemini 3.6 Flash",provider:"Google",tier:"light"},{description:"Strong agentic reasoning and polished UI decisions",id:"anthropic/claude-sonnet-5",label:"Claude Sonnet 5",provider:"Anthropic",tier:"codegen"},{description:"Highest-capability Claude for difficult research and analysis",id:"anthropic/claude-opus-4.8",label:"Claude Opus 4.8",provider:"Anthropic",tier:"complex"}],bo=new Set(pe);function ia(t){return typeof t=="string"&&bo.has(t)}function sa(t){let n=t?me(t):void 0;return Co.find(a=>a.id===n)?.tier??"light"}import{z as dt}from"zod";var ca=dt.preprocess(t=>typeof t=="string"?me(t):t,dt.enum(pe));var ua="heroui-agent:runtime-timing",ga="heroui_agent_turn_admitted",ha="getTurnAdmissionStatuses",fa=50;export{Qo as AGENT_CONVERSATION_SOURCE,pe as AGENT_MODEL_IDS,Co as AGENT_MODEL_OPTIONS,lt as AGENT_UI_CATALOG,Ee as AGENT_UI_CONTAINER_KINDS,no as AGENT_UI_KIND_NAMES,Go as AGENT_UI_KIND_SCHEMAS,Ue as AGENT_UI_LAYOUT_LEAF_KINDS,ze as AGENT_UI_PRIMITIVE_KINDS,X as COMPOSED_UI_MAX_DEPTH,G as COMPOSED_UI_MAX_NODES,ra as DEFAULT_AGENT_PICKER_MODEL_ID,ko as HEROUI_AGENT_ATTACHMENT_ACCEPT,ue as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES,ut as HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE,Ao as HEROUI_AGENT_ATTACHMENT_MAX_BYTES,xo as HEROUI_AGENT_MAX_ATTACHMENTS,q as HEROUI_AGENT_PROTOCOL_VERSION,he as HEROUI_AGENT_REMOTE_CONFIG_VERSION,ua as HEROUI_AGENT_RUNTIME_TIMING_EVENT,mt as HEROUI_AGENT_SDK_VERSION,Io as HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES,fa as HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS,ha as HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD,ga as HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE,yo as LEGACY_AGENT_MODEL_IDS,io as MAX_CLIENT_TOOLS,so as MAX_CLIENT_TOOLS_BYTES,ao as RESERVED_AGENT_TOOL_NAMES,ro as RESERVED_AGENT_TOOL_PREFIX,An as accordionComponentSchema,Sn as actionGroupComponentSchema,uo as agentAuthIdentitySchema,go as agentAuthProfileSchema,Xo as agentAuthTokenSchema,kt as agentIconNames,R as agentIconSchema,le as agentIdentityIdSchema,ca as agentModelIdSchema,ea as agentProjectConfigSchema,fo as agentSourceSchema,oa as agentSourcesSchema,mo as agentSurfaceVariantSchema,po as agentThemeSchema,Jo as agentTokenClaimsSchema,we as agentUIComponentSchema,ae as agentUILeafComponentSchema,se as agentUINodeSchema,Mo as agentUIRenderableSchema,Zn as analyticalLeafComponentSchema,Yt as areaChartComponentSchema,Ve as badgeComponentSchema,Wt as barChartComponentSchema,Pe as buttonComponentSchema,hn as calloutComponentSchema,rn as candlestickChartComponentSchema,at as cardComponentSchema,Q as cardComponentVariantSchema,Mn as channelMessageComponentSchema,v as chartColorSchema,lo as clientToolManifestEntrySchema,Fo as clientToolsSchema,In as codeBlockComponentSchema,nt as colComponentSchema,cn as comparisonListComponentSchema,jo as composeUIInputSchema,Xt as composedChartComponentSchema,st as composedUIComponentSchema,Wo as createAgentAuthTokenRequestSchema,Un as createEventComponentSchema,$n as dashboardComponentSchema,mn as dataTableComponentSchema,Tn as diagramComponentSchema,Be as dividerComponentSchema,Qt as donutChartComponentSchema,Pn as enableNotificationComponentSchema,Dn as eventSessionComponentSchema,En as flightTrackerComponentSchema,vn as followupComponentSchema,un as formComponentSchema,sn as funnelChartComponentSchema,ln as gaugeChartComponentSchema,sa as getAgentModelTier,Le as getAgentUIContainerChildren,ot as gridComponentSchema,De as headingComponentSchema,an as heatmapComponentSchema,Ke as iconComponentSchema,fn as imageComponentSchema,ia as isAgentModelId,Oe as isAgentUIContainerComponent,Oo as isAgentUILayoutLeafComponent,Lo as isAgentUIPrimitiveComponent,ge as isHeroUIAgentAttachmentContentType,ie as itemCardComponentSchema,We as itemCardGroupComponentSchema,qt as kpiGridComponentSchema,$t as lineChartComponentSchema,xn as listBlockComponentSchema,bn as listComponentSchema,yn as mapComponentSchema,dn as meterListComponentSchema,Ht as metricGridComponentSchema,y as numberFormatSchema,vo as parseAgentRemoteConfig,Jt as pieChartComponentSchema,Gn as playerCardComponentSchema,zn as playlistComponentSchema,_n as productCardComponentSchema,Fn as productSignalsComponentSchema,Fe as progressComponentSchema,jn as purchaseCompleteComponentSchema,Ln as purchaseItemsComponentSchema,en as radarChartComponentSchema,tn as radialChartComponentSchema,Ze as ratingComponentSchema,Rn as recordCardComponentSchema,vt as recordCardLayoutSchema,Vo as renderAgentUICatalogPrompt,zo as renderComponentInputSchema,me as resolveAgentModelId,On as rideStatusComponentSchema,tt as rowComponentSchema,nn as sankeyChartComponentSchema,on as scatterChartComponentSchema,Ge as spacerComponentSchema,kn as stepsComponentSchema,pn as sunburstChartComponentSchema,wn as switchGroupComponentSchema,Uo as tabsComponentSchema,Cn as tagListComponentSchema,gn as textComponentSchema,Nn as toggleGroupComponentSchema,Bn as viewEventComponentSchema,W as weatherConditionSchema,It as weatherConditions,Kn as weatherCurrentComponentSchema,Vn as weatherForecastComponentSchema};