orbital-ds 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/AGENTS.md +1 -1
  2. package/components.manifest.json +221 -1
  3. package/dist/hooks/use-ds-messages.d.ts +82 -0
  4. package/dist/lib/a2ui-catalog.d.ts +42 -0
  5. package/dist/lib/a2ui-catalog.js +558 -0
  6. package/dist/lib/a2ui.d.ts +289 -0
  7. package/dist/lib/a2ui.js +215 -0
  8. package/dist/lib/ai-events.d.ts +15 -0
  9. package/dist/lib/ai-events.js +202 -0
  10. package/dist/lib/auth-flow.d.ts +3 -1
  11. package/dist/lib/auth-flow.js +24 -3
  12. package/dist/lib/i18n.d.ts +82 -0
  13. package/dist/lib/i18n.js +246 -0
  14. package/dist/styles.css +23 -1
  15. package/dist/ui/a2ui-renderer.d.ts +33 -0
  16. package/dist/ui/a2ui-renderer.js +793 -0
  17. package/dist/ui/agent-events.d.ts +32 -0
  18. package/dist/ui/agent-events.js +108 -0
  19. package/dist/ui/alert.d.ts +1 -1
  20. package/dist/ui/attachment.d.ts +2 -2
  21. package/dist/ui/auth-form.d.ts +3 -1
  22. package/dist/ui/auth-form.js +34 -6
  23. package/dist/ui/badge.d.ts +1 -1
  24. package/dist/ui/banner.d.ts +1 -1
  25. package/dist/ui/bubble.d.ts +1 -1
  26. package/dist/ui/button-group.d.ts +1 -1
  27. package/dist/ui/button.d.ts +2 -2
  28. package/dist/ui/chain-of-thought.d.ts +19 -0
  29. package/dist/ui/chain-of-thought.js +90 -0
  30. package/dist/ui/chat-composer.d.ts +39 -0
  31. package/dist/ui/chat-composer.js +192 -0
  32. package/dist/ui/conversation-list.d.ts +24 -0
  33. package/dist/ui/conversation-list.js +141 -0
  34. package/dist/ui/empty.d.ts +1 -1
  35. package/dist/ui/field.d.ts +1 -1
  36. package/dist/ui/generated-image.d.ts +14 -0
  37. package/dist/ui/generated-image.js +65 -0
  38. package/dist/ui/generated-table.d.ts +11 -0
  39. package/dist/ui/generated-table.js +59 -0
  40. package/dist/ui/icon-tile.d.ts +2 -2
  41. package/dist/ui/item.d.ts +2 -2
  42. package/dist/ui/markdown.d.ts +14 -0
  43. package/dist/ui/markdown.js +123 -0
  44. package/dist/ui/marker.d.ts +1 -1
  45. package/dist/ui/message-actions.d.ts +12 -0
  46. package/dist/ui/message-actions.js +79 -0
  47. package/dist/ui/panel.d.ts +1 -1
  48. package/dist/ui/reasoning.d.ts +10 -0
  49. package/dist/ui/reasoning.js +62 -0
  50. package/dist/ui/sidebar.d.ts +1 -1
  51. package/dist/ui/sparkline.d.ts +1 -1
  52. package/dist/ui/stat.d.ts +1 -1
  53. package/dist/ui/status-badge.d.ts +3 -3
  54. package/dist/ui/suggestions.d.ts +8 -0
  55. package/dist/ui/suggestions.js +39 -0
  56. package/dist/ui/tabs.d.ts +1 -1
  57. package/dist/ui/toggle.d.ts +1 -1
  58. package/dist/ui/tool-call.d.ts +15 -0
  59. package/dist/ui/tool-call.js +74 -0
  60. package/dist/ui/workflow-run.d.ts +23 -0
  61. package/dist/ui/workflow-run.js +185 -0
  62. package/docs/designer/criterio.md +87 -87
  63. package/docs/designer/patrones.md +3 -1
  64. package/package.json +238 -228
@@ -0,0 +1,289 @@
1
+ declare const A2UI_VERSION: "1.0";
2
+ /** Identificador del catálogo de Orbital (el básico de A2UI + piezas del sistema de diseño). No es una URL que resolver. */
3
+ declare const ORBITAL_CATALOG_ID = "https://orbital-ds.dev/a2ui/catalogs/orbital/v1";
4
+ interface PathBinding {
5
+ "@path": string;
6
+ }
7
+ interface FunctionCall {
8
+ "@call": string;
9
+ args?: Record<string, unknown>;
10
+ }
11
+ type DynamicString = string | PathBinding | FunctionCall;
12
+ type DynamicNumber = number | PathBinding | FunctionCall;
13
+ type DynamicBoolean = boolean | PathBinding | FunctionCall;
14
+ type DynamicStringList = string[] | PathBinding | FunctionCall;
15
+ type ComponentId = string;
16
+ /** Hijos repetidos por cada elemento de una lista del modelo de datos: `componentId` se pinta con ámbito `path/i`. */
17
+ interface TemplateChildren {
18
+ componentId: ComponentId;
19
+ path: string;
20
+ }
21
+ type ChildList = ComponentId[] | TemplateChildren;
22
+ /** Comprobación de un campo o botón: si `condition` da falso, se muestra `message` y el botón se desactiva. */
23
+ interface Check {
24
+ condition: DynamicBoolean;
25
+ message: string;
26
+ }
27
+ type A2UIAction = {
28
+ event: {
29
+ name: string;
30
+ userMessage?: string;
31
+ context?: Record<string, unknown>;
32
+ };
33
+ } | {
34
+ functionCall: FunctionCall;
35
+ };
36
+ /** Lo que recibe la app cuando una persona acciona algo. `context` ya viene con los enlaces resueltos. */
37
+ type A2UIActionEvent = {
38
+ type: "event";
39
+ surfaceId: string;
40
+ componentId: ComponentId;
41
+ name: string;
42
+ userMessage?: string;
43
+ context: Record<string, unknown>;
44
+ /** Copia del modelo de datos si la superficie se creó con `sendDataModel: true`. */
45
+ dataModel?: Record<string, unknown>;
46
+ } | {
47
+ type: "functionCall";
48
+ surfaceId: string;
49
+ componentId: ComponentId;
50
+ call: string;
51
+ args: Record<string, unknown>;
52
+ };
53
+ type A2UITone = "neutral" | "primary" | "info" | "success" | "warning" | "danger";
54
+ type Justify = "start" | "center" | "end" | "stretch" | "spaceBetween" | "spaceAround" | "spaceEvenly";
55
+ type Align = "start" | "center" | "end" | "stretch";
56
+ interface BaseNode<TName extends string> {
57
+ id: ComponentId;
58
+ component: TName;
59
+ /** Solo con un padre Row o Column: reparto del espacio sobrante (como `flex-grow`). */
60
+ weight?: number;
61
+ "@catalogId"?: string;
62
+ "@accessibility"?: {
63
+ label?: DynamicString;
64
+ description?: DynamicString;
65
+ };
66
+ }
67
+ interface Checkable {
68
+ "@checks"?: Check[];
69
+ }
70
+ interface RowNode extends BaseNode<"Row"> {
71
+ children: ChildList;
72
+ justify?: Justify;
73
+ align?: Align;
74
+ }
75
+ interface ColumnNode extends BaseNode<"Column"> {
76
+ children: ChildList;
77
+ justify?: Justify;
78
+ align?: Align;
79
+ }
80
+ interface ListNode extends BaseNode<"List"> {
81
+ children: ChildList;
82
+ direction?: "vertical" | "horizontal";
83
+ align?: Align;
84
+ }
85
+ interface CardNode extends BaseNode<"Card"> {
86
+ child: ComponentId;
87
+ }
88
+ interface TabsNode extends BaseNode<"Tabs"> {
89
+ tabs: Array<{
90
+ title: DynamicString;
91
+ child: ComponentId;
92
+ }>;
93
+ }
94
+ interface ModalNode extends BaseNode<"Modal"> {
95
+ /** Título accesible del diálogo (se anuncia, no se ve); sin él, el texto genérico del idioma activo. */
96
+ title?: DynamicString;
97
+ trigger: ComponentId;
98
+ content: ComponentId;
99
+ }
100
+ interface DividerNode extends BaseNode<"Divider"> {
101
+ axis?: "horizontal" | "vertical";
102
+ }
103
+ interface TextNode extends BaseNode<"Text"> {
104
+ text: DynamicString;
105
+ variant?: "body" | "caption";
106
+ }
107
+ interface ImageNode extends BaseNode<"Image"> {
108
+ url: DynamicString;
109
+ description?: DynamicString;
110
+ fit?: "contain" | "cover" | "fill" | "none" | "scaleDown";
111
+ variant?: "icon" | "avatar" | "smallFeature" | "mediumFeature" | "largeFeature" | "header";
112
+ }
113
+ interface IconNode extends BaseNode<"Icon"> {
114
+ name: string | PathBinding;
115
+ }
116
+ interface VideoNode extends BaseNode<"Video"> {
117
+ url: DynamicString;
118
+ posterUrl?: DynamicString;
119
+ }
120
+ interface AudioPlayerNode extends BaseNode<"AudioPlayer"> {
121
+ url: DynamicString;
122
+ description?: DynamicString;
123
+ }
124
+ interface ButtonNode extends BaseNode<"Button">, Checkable {
125
+ child: ComponentId;
126
+ action: A2UIAction;
127
+ variant?: "default" | "primary" | "borderless";
128
+ }
129
+ interface TextFieldNode extends BaseNode<"TextField">, Checkable {
130
+ label: DynamicString;
131
+ value: DynamicString;
132
+ placeholder?: DynamicString;
133
+ variant?: "shortText" | "longText" | "number" | "obscured";
134
+ }
135
+ interface CheckBoxNode extends BaseNode<"CheckBox">, Checkable {
136
+ label: DynamicString;
137
+ value: DynamicBoolean;
138
+ }
139
+ interface ChoicePickerNode extends BaseNode<"ChoicePicker">, Checkable {
140
+ label?: DynamicString;
141
+ options: Array<{
142
+ label: DynamicString;
143
+ value: string;
144
+ }>;
145
+ value: DynamicStringList;
146
+ variant?: "multipleSelection" | "mutuallyExclusive";
147
+ displayStyle?: "checkbox" | "chips";
148
+ filterable?: boolean;
149
+ }
150
+ interface SliderNode extends BaseNode<"Slider">, Checkable {
151
+ label?: DynamicString;
152
+ value: DynamicNumber;
153
+ max: number;
154
+ min?: number;
155
+ steps?: number;
156
+ }
157
+ interface DateTimeInputNode extends BaseNode<"DateTimeInput">, Checkable {
158
+ label?: DynamicString;
159
+ value: DynamicString;
160
+ enableDate?: boolean;
161
+ enableTime?: boolean;
162
+ min?: DynamicString;
163
+ max?: DynamicString;
164
+ }
165
+ interface PanelNode extends BaseNode<"Panel"> {
166
+ child: ComponentId;
167
+ title?: DynamicString;
168
+ description?: DynamicString;
169
+ icon?: string;
170
+ tone?: A2UITone;
171
+ /** Acciones al pie. */
172
+ footer?: ComponentId;
173
+ }
174
+ interface HeadingNode extends BaseNode<"Heading"> {
175
+ text: DynamicString;
176
+ level?: 1 | 2 | 3;
177
+ description?: DynamicString;
178
+ }
179
+ interface IconTileNode extends BaseNode<"IconTile"> {
180
+ name: string;
181
+ tone?: A2UITone;
182
+ size?: "sm" | "md" | "lg";
183
+ }
184
+ interface BadgeNode extends BaseNode<"Badge"> {
185
+ text: DynamicString;
186
+ tone?: A2UITone;
187
+ }
188
+ interface ProgressNode extends BaseNode<"Progress"> {
189
+ value: DynamicNumber;
190
+ max?: number;
191
+ label?: DynamicString;
192
+ tone?: A2UITone;
193
+ }
194
+ interface StatNode extends BaseNode<"Stat"> {
195
+ label: DynamicString;
196
+ value: DynamicString | DynamicNumber;
197
+ /** Variación frente al periodo anterior, en %. */
198
+ delta?: DynamicNumber;
199
+ description?: DynamicString;
200
+ icon?: string;
201
+ tone?: "neutral" | "good" | "warn" | "bad";
202
+ }
203
+ interface AlertNode extends BaseNode<"Alert"> {
204
+ text: DynamicString;
205
+ title?: DynamicString;
206
+ tone?: "info" | "success" | "warning" | "danger";
207
+ }
208
+ interface ListItemNode extends BaseNode<"ListItem"> {
209
+ title: DynamicString;
210
+ description?: DynamicString;
211
+ icon?: DynamicString;
212
+ tone?: DynamicString;
213
+ badge?: DynamicString;
214
+ badgeTone?: DynamicString;
215
+ /** Componente a la derecha (p. ej. un Button). */
216
+ action?: ComponentId;
217
+ }
218
+ type ChartKind = "line" | "area" | "bar" | "horizontalBar" | "donut" | "pie" | "gauge";
219
+ interface ChartNode extends BaseNode<"Chart"> {
220
+ kind: ChartKind;
221
+ title?: DynamicString;
222
+ description?: DynamicString;
223
+ /** Etiquetas del eje (line, area, bar). Lista literal o `{ "@path" }`. */
224
+ categories?: Array<string | number> | PathBinding;
225
+ /** Series `[{ name, data: number[] }]` (line, area, bar). Literal o `{ "@path" }`. */
226
+ series?: Array<{
227
+ name: string;
228
+ data: Array<number | null>;
229
+ }> | PathBinding;
230
+ /** Porciones `[{ name, value }]` (donut, pie). Literal o `{ "@path" }`. */
231
+ slices?: Array<{
232
+ name: string;
233
+ value: number;
234
+ }> | PathBinding;
235
+ /** Valor del gauge. */
236
+ value?: DynamicNumber;
237
+ min?: number;
238
+ max?: number;
239
+ stacked?: boolean;
240
+ size?: "glance" | "standard" | "focus";
241
+ }
242
+ type A2UIComponent = RowNode | ColumnNode | ListNode | CardNode | TabsNode | ModalNode | DividerNode | TextNode | ImageNode | IconNode | VideoNode | AudioPlayerNode | ButtonNode | TextFieldNode | CheckBoxNode | ChoicePickerNode | SliderNode | DateTimeInputNode | PanelNode | HeadingNode | IconTileNode | BadgeNode | ProgressNode | StatNode | AlertNode | ListItemNode | ChartNode;
243
+ type A2UIMessage = {
244
+ version: "1.0";
245
+ createSurface: {
246
+ surfaceId: string;
247
+ catalogId?: string;
248
+ /** Componentes y datos iniciales: la superficie aparece pintada en un solo mensaje. */
249
+ components?: A2UIComponent[];
250
+ dataModel?: Record<string, unknown>;
251
+ sendDataModel?: boolean;
252
+ };
253
+ } | {
254
+ version: "1.0";
255
+ updateComponents: {
256
+ surfaceId: string;
257
+ components: A2UIComponent[];
258
+ };
259
+ } | {
260
+ version: "1.0";
261
+ updateDataModel: {
262
+ surfaceId: string;
263
+ path?: string;
264
+ value?: unknown;
265
+ };
266
+ } | {
267
+ version: "1.0";
268
+ deleteSurface: {
269
+ surfaceId: string;
270
+ };
271
+ };
272
+ /**
273
+ * Devuelve un modelo nuevo con `value` en `path` (crea los tramos que falten; `value` nulo o indefinido borra la
274
+ * clave). Sin ruta (o `/`) sustituye el modelo entero por un objeto.
275
+ */
276
+ declare function applyUpdate(model: Record<string, unknown>, path: string | undefined, value: unknown): Record<string, unknown>;
277
+ declare function isPathBinding(raw: unknown): raw is PathBinding;
278
+ declare function isFunctionCall(raw: unknown): raw is FunctionCall;
279
+ /** Ruta absoluta de un puntero, relativa al ámbito (`scopePath`) cuando no empieza por `/`. */
280
+ declare function buildFullPath(pointer: string, scopePath: string | undefined): string;
281
+ /** Valor literal tal cual; `{ "@path" }` = lo que haya en el modelo de datos; `{ "@call" }` = el resultado de la función. */
282
+ /** `locale`: idioma activo (BCP 47) para los formatos de número, moneda, fecha y plural; sin él, el del entorno. */
283
+ declare function resolveDynamic<T = unknown>(raw: unknown, data: Record<string, unknown>, scopePath?: string, depth?: number, locale?: string): T | undefined;
284
+ /** Resuelve los enlaces de un objeto (el `context` de una acción) un nivel hacia dentro. */
285
+ declare function resolveContext(context: Record<string, unknown> | undefined, data: Record<string, unknown>, scopePath?: string, locale?: string): Record<string, unknown>;
286
+ /** ¿Pasan todas las comprobaciones? Devuelve los mensajes de las que fallan. */
287
+ declare function failedChecks(checks: Check[] | undefined, data: Record<string, unknown>, scopePath?: string, locale?: string): string[];
288
+
289
+ export { type A2UIAction, type A2UIActionEvent, type A2UIComponent, type A2UIMessage, type A2UITone, A2UI_VERSION, type AlertNode, type AudioPlayerNode, type BadgeNode, type ButtonNode, type CardNode, type ChartKind, type ChartNode, type Check, type CheckBoxNode, type ChildList, type ChoicePickerNode, type ColumnNode, type ComponentId, type DateTimeInputNode, type DividerNode, type DynamicBoolean, type DynamicNumber, type DynamicString, type DynamicStringList, type FunctionCall, type HeadingNode, type IconNode, type IconTileNode, type ImageNode, type ListItemNode, type ListNode, type ModalNode, ORBITAL_CATALOG_ID, type PanelNode, type PathBinding, type ProgressNode, type RowNode, type SliderNode, type StatNode, type TabsNode, type TemplateChildren, type TextFieldNode, type TextNode, type VideoNode, applyUpdate, buildFullPath, failedChecks, isFunctionCall, isPathBinding, resolveContext, resolveDynamic };
@@ -0,0 +1,215 @@
1
+ const A2UI_VERSION = "1.0";
2
+ const ORBITAL_CATALOG_ID = "https://orbital-ds.dev/a2ui/catalogs/orbital/v1";
3
+ function decodeToken(token) {
4
+ return token.replace(/~1/g, "/").replace(/~0/g, "~");
5
+ }
6
+ function pointerToTokens(pointer) {
7
+ if (pointer === "") return [];
8
+ if (pointer === "/") return [""];
9
+ if (!pointer.startsWith("/")) return pointer.split("/").map(decodeToken);
10
+ return pointer.slice(1).split("/").map(decodeToken);
11
+ }
12
+ const INDEX = /^(0|[1-9]\d*)$/;
13
+ const FORBIDDEN = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
14
+ function getByPointer(data, pointer) {
15
+ let cursor = data;
16
+ for (const token of pointerToTokens(pointer)) {
17
+ if (cursor === null || cursor === void 0) return void 0;
18
+ if (Array.isArray(cursor)) {
19
+ if (!INDEX.test(token)) return void 0;
20
+ const index = Number(token);
21
+ if (index >= cursor.length) return void 0;
22
+ cursor = cursor[index];
23
+ continue;
24
+ }
25
+ if (typeof cursor === "object") {
26
+ const obj = cursor;
27
+ if (!Object.prototype.hasOwnProperty.call(obj, token)) return void 0;
28
+ cursor = obj[token];
29
+ continue;
30
+ }
31
+ return void 0;
32
+ }
33
+ return cursor;
34
+ }
35
+ function applyUpdate(model, path, value) {
36
+ if (path === void 0 || path === "" || path === "/") {
37
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) return structuredClone(value);
38
+ return {};
39
+ }
40
+ const tokens = pointerToTokens(path);
41
+ const cloned = structuredClone(model);
42
+ if (tokens.length === 0 || tokens.some((t) => FORBIDDEN.has(t))) return cloned;
43
+ const remove = value === void 0 || value === null;
44
+ let cursor = cloned;
45
+ for (let i = 0; i < tokens.length - 1; i++) {
46
+ const token = tokens[i];
47
+ const nextIsIndex = INDEX.test(tokens[i + 1]);
48
+ if (Array.isArray(cursor)) {
49
+ const index = Number(token);
50
+ if (!Number.isInteger(index) || index < 0) return cloned;
51
+ if (cursor[index] === void 0 || cursor[index] === null) {
52
+ if (remove) return cloned;
53
+ cursor[index] = nextIsIndex ? [] : {};
54
+ }
55
+ cursor = cursor[index];
56
+ continue;
57
+ }
58
+ if (typeof cursor === "object" && cursor !== null) {
59
+ const obj = cursor;
60
+ const own = Object.prototype.hasOwnProperty.call(obj, token) ? obj[token] : void 0;
61
+ if (typeof own !== "object" || own === null) {
62
+ if (remove) return cloned;
63
+ obj[token] = nextIsIndex ? [] : {};
64
+ }
65
+ cursor = obj[token];
66
+ continue;
67
+ }
68
+ return cloned;
69
+ }
70
+ const last = tokens[tokens.length - 1];
71
+ if (Array.isArray(cursor)) {
72
+ const index = Number(last);
73
+ if (!Number.isInteger(index) || index < 0) return cloned;
74
+ if (remove) {
75
+ if (index < cursor.length) cursor.splice(index, 1);
76
+ } else cursor[index] = value;
77
+ } else if (typeof cursor === "object" && cursor !== null) {
78
+ const obj = cursor;
79
+ if (remove) delete obj[last];
80
+ else obj[last] = value;
81
+ }
82
+ return cloned;
83
+ }
84
+ function isPathBinding(raw) {
85
+ return typeof raw === "object" && raw !== null && typeof raw["@path"] === "string";
86
+ }
87
+ function isFunctionCall(raw) {
88
+ return typeof raw === "object" && raw !== null && typeof raw["@call"] === "string";
89
+ }
90
+ function buildFullPath(pointer, scopePath) {
91
+ if (pointer.startsWith("/")) return pointer;
92
+ if (pointer === "") return scopePath ?? "";
93
+ const scope = scopePath ?? "";
94
+ const trimmed = scope.endsWith("/") ? scope.slice(0, -1) : scope;
95
+ return trimmed ? `${trimmed}/${pointer}` : `/${pointer}`;
96
+ }
97
+ const MAX_DEPTH = 8;
98
+ const MAX_REGEX = 200;
99
+ const MAX_INPUT = 2e3;
100
+ const asText = (v) => v === null || v === void 0 ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
101
+ const asNumber = (v) => {
102
+ if (typeof v === "number") return Number.isFinite(v) ? v : void 0;
103
+ if (typeof v === "string" && v.trim() !== "") {
104
+ const n = Number(v);
105
+ return Number.isFinite(n) ? n : void 0;
106
+ }
107
+ return void 0;
108
+ };
109
+ function runFunction(call, data, scopePath, depth, locale) {
110
+ const raw = call.args ?? {};
111
+ const arg = (name) => resolveDynamic(raw[name], data, scopePath, depth + 1, locale);
112
+ try {
113
+ switch (call["@call"]) {
114
+ case "formatString": {
115
+ const template = asText(arg("value"));
116
+ return template.replace(/\$\{([^}]*)\}/g, (_m, expr) => asText(resolveDynamic({ "@path": expr.trim() }, data, scopePath, depth + 1, locale)));
117
+ }
118
+ case "formatNumber": {
119
+ const n = asNumber(arg("value"));
120
+ if (n === void 0) return "";
121
+ const decimals = asNumber(arg("decimals"));
122
+ return new Intl.NumberFormat(locale, {
123
+ useGrouping: arg("grouping") !== false,
124
+ ...decimals !== void 0 ? { minimumFractionDigits: decimals, maximumFractionDigits: decimals } : {}
125
+ }).format(n);
126
+ }
127
+ case "formatCurrency": {
128
+ const n = asNumber(arg("value"));
129
+ const currency = asText(arg("currency")).toUpperCase();
130
+ if (n === void 0 || !/^[A-Z]{3}$/.test(currency)) return "";
131
+ return new Intl.NumberFormat(locale, { style: "currency", currency }).format(n);
132
+ }
133
+ case "formatDate": {
134
+ const v = arg("value");
135
+ const date = new Date(typeof v === "number" || typeof v === "string" ? v : NaN);
136
+ if (Number.isNaN(date.getTime())) return "";
137
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(date);
138
+ }
139
+ case "pluralize": {
140
+ const n = asNumber(arg("value")) ?? 0;
141
+ const category = new Intl.PluralRules(locale).select(n);
142
+ const picked = arg(category) ?? arg("other");
143
+ return asText(picked);
144
+ }
145
+ case "required": {
146
+ const v = arg("value");
147
+ return v !== void 0 && v !== null && !(typeof v === "string" && v.trim() === "") && !(Array.isArray(v) && v.length === 0);
148
+ }
149
+ case "regex": {
150
+ const pattern = asText(arg("pattern"));
151
+ const value = asText(arg("value"));
152
+ if (pattern.length > MAX_REGEX || value.length > MAX_INPUT) return false;
153
+ return new RegExp(pattern).test(value);
154
+ }
155
+ case "length": {
156
+ const v = arg("value");
157
+ const len = typeof v === "string" || Array.isArray(v) ? v.length : 0;
158
+ const min = asNumber(arg("min"));
159
+ const max = asNumber(arg("max"));
160
+ return (min === void 0 || len >= min) && (max === void 0 || len <= max);
161
+ }
162
+ case "numeric": {
163
+ const n = asNumber(arg("value"));
164
+ if (n === void 0) return false;
165
+ const min = asNumber(arg("min"));
166
+ const max = asNumber(arg("max"));
167
+ return (min === void 0 || n >= min) && (max === void 0 || n <= max);
168
+ }
169
+ case "email":
170
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(asText(arg("value")));
171
+ case "and":
172
+ case "or": {
173
+ const values = arg("values");
174
+ if (!Array.isArray(values)) return false;
175
+ return call["@call"] === "and" ? values.every(Boolean) : values.some(Boolean);
176
+ }
177
+ case "not":
178
+ return !arg("value");
179
+ default:
180
+ return void 0;
181
+ }
182
+ } catch {
183
+ return void 0;
184
+ }
185
+ }
186
+ function resolveDynamic(raw, data, scopePath, depth = 0, locale) {
187
+ if (depth > MAX_DEPTH) return void 0;
188
+ if (isPathBinding(raw)) return getByPointer(data, buildFullPath(raw["@path"], scopePath));
189
+ if (isFunctionCall(raw)) return runFunction(raw, data, scopePath, depth, locale);
190
+ return raw;
191
+ }
192
+ function resolveContext(context, data, scopePath, locale) {
193
+ const out = {};
194
+ if (!context) return out;
195
+ for (const [key, value] of Object.entries(context)) {
196
+ if (FORBIDDEN.has(key)) continue;
197
+ out[key] = resolveDynamic(value, data, scopePath, 0, locale);
198
+ }
199
+ return out;
200
+ }
201
+ function failedChecks(checks, data, scopePath, locale) {
202
+ if (!Array.isArray(checks)) return [];
203
+ return checks.filter((c) => resolveDynamic(c.condition, data, scopePath, 0, locale) === false).map((c) => c.message);
204
+ }
205
+ export {
206
+ A2UI_VERSION,
207
+ ORBITAL_CATALOG_ID,
208
+ applyUpdate,
209
+ buildFullPath,
210
+ failedChecks,
211
+ isFunctionCall,
212
+ isPathBinding,
213
+ resolveContext,
214
+ resolveDynamic
215
+ };
@@ -0,0 +1,15 @@
1
+ import { AgentEventChip, AgentEvent } from '../ui/agent-events.js';
2
+ import 'react';
3
+
4
+ /** Chips (modelo, tokens, coste) a partir de los metadatos habituales de un evento. */
5
+ declare function chipsFromMeta(meta: {
6
+ model?: string;
7
+ tokensIn?: number;
8
+ tokensOut?: number;
9
+ costUsd?: number;
10
+ }): AgentEventChip[];
11
+ declare function toAgentEvents(stream: unknown[]): AgentEvent[];
12
+ /** Partes de un mensaje del AI SDK (`message.parts`) → eventos. */
13
+ declare function fromUiMessageParts(parts: unknown[]): AgentEvent[];
14
+
15
+ export { chipsFromMeta, fromUiMessageParts, toAgentEvents };